kdatepicker.h
00001 /* -*- C++ -*- 00002 This file is part of the KDE libraries 00003 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 00004 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef KDATEPICKER_H 00021 #define KDATEPICKER_H 00022 #include <tqdatetime.h> 00023 #include <tqframe.h> 00024 #include <kdelibs_export.h> 00025 00026 class TQLineEdit; 00027 class TQToolButton; 00028 class KDateValidator; 00029 class KDateTable; 00030 00051 class KDEUI_EXPORT KDatePicker: public TQFrame 00052 { 00053 Q_OBJECT 00054 Q_PROPERTY( TQDate date READ date WRITE setDate) 00055 Q_PROPERTY( bool closeButton READ hasCloseButton WRITE setCloseButton ) 00056 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize ) 00057 00058 public: 00062 KDatePicker(TQWidget *parent=0, 00063 TQDate=TQDate::currentDate(), 00064 const char *name=0); 00065 00070 KDatePicker(TQWidget *parent, 00071 TQDate, 00072 const char *name, 00073 WFlags f); // ### KDE 4.0: Merge 00074 00080 KDatePicker( TQWidget *parent, const char *name ); 00081 00085 virtual ~KDatePicker(); 00086 00093 TQSize sizeHint() const; 00094 00101 bool setDate(const TQDate&); 00102 00107 const TQDate& getDate() const KDE_DEPRECATED; 00108 00112 const TQDate &date() const; 00113 00117 void setEnabled(bool); 00118 00124 KDateTable *dateTable() const { return table; } 00125 00129 void setFontSize(int); 00133 int fontSize() const 00134 { return fontsize; } 00135 00145 void setCloseButton( bool enable ); 00146 00152 bool hasCloseButton() const; 00153 00154 protected: 00156 virtual bool eventFilter(TQObject *o, TQEvent *e ); 00158 virtual void resizeEvent(TQResizeEvent*); 00160 TQToolButton *yearForward; 00162 TQToolButton *yearBackward; 00164 TQToolButton *monthForward; 00166 TQToolButton *monthBackward; 00168 TQToolButton *selectMonth; 00170 TQToolButton *selectYear; 00172 TQLineEdit *line; 00174 KDateValidator *val; 00176 KDateTable *table; 00178 // TQSize sizehint; 00180 TQSize maxMonthRect; 00181 protected slots: 00182 void dateChangedSlot(TQDate); 00183 void tableClickedSlot(); 00184 void monthForwardClicked(); 00185 void monthBackwardClicked(); 00186 void yearForwardClicked(); 00187 void yearBackwardClicked(); 00192 void selectWeekClicked(); 00196 void selectMonthClicked(); 00200 void selectYearClicked(); 00204 void lineEnterPressed(); 00208 void todayButtonClicked(); 00212 void weekSelected(int); 00213 00214 signals: 00215 // ### KDE 4.0 Make all TQDate parameters const references 00216 00223 void dateChanged(TQDate); 00229 void dateSelected(TQDate); 00235 void dateEntered(TQDate); 00239 void tableClicked(); 00240 00241 private slots: 00242 void ensureSelectYearIsUp(); 00243 00244 private: 00246 int fontsize; 00247 00248 protected: 00249 virtual void virtual_hook( int id, void* data ); 00250 private: 00251 void init( const TQDate &dt ); 00252 void fillWeeksCombo(const TQDate &date); 00253 class KDatePickerPrivate; 00254 KDatePickerPrivate *d; 00255 }; 00256 00257 #endif // KDATEPICKER_H