kdatetbl.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 KDATETBL_H 00021 #define KDATETBL_H 00022 00023 // KDE4: rename this file to kdatetable.h 00024 00025 #include <tqvalidator.h> 00026 #include <tqgridview.h> 00027 #include <tqlineedit.h> 00028 #include <tqdatetime.h> 00029 #include <tqcolor.h> 00030 00031 #include <tdelibs_export.h> 00032 00033 class TDEPopupMenu; 00034 00040 class TDEUI_EXPORT KDateInternalWeekSelector : public TQLineEdit 00041 { 00042 Q_OBJECT 00043 protected: 00044 TQIntValidator *val; 00045 int result; 00046 public slots: 00047 void weekEnteredSlot(); 00048 void setMaxWeek(int max); 00049 signals: 00050 void closeMe(int); 00051 public: 00052 KDateInternalWeekSelector( TQWidget* parent=0, const char* name=0); 00053 int getWeek(); 00054 void setWeek(int week); 00055 00056 private: 00057 class KDateInternalWeekPrivate; 00058 KDateInternalWeekPrivate *d; 00059 }; 00060 00067 class TDEUI_EXPORT KDateInternalMonthPicker : public TQGridView 00068 { 00069 Q_OBJECT 00070 protected: 00074 int result; 00078 short int activeCol; 00079 short int activeRow; 00083 TQRect max; 00084 signals: 00088 void closeMe(int); 00089 public: 00093 KDateInternalMonthPicker(const TQDate& date, TQWidget* parent, const char* name=0); 00097 ~KDateInternalMonthPicker(); 00101 TQSize sizeHint() const; 00106 int getResult() const; 00107 protected: 00111 void setupPainter(TQPainter *p); 00115 virtual void viewportResizeEvent(TQResizeEvent*); 00119 virtual void paintCell(TQPainter* painter, int row, int col); 00123 virtual void contentsMousePressEvent(TQMouseEvent *e); 00124 virtual void contentsMouseMoveEvent(TQMouseEvent *e); 00128 virtual void contentsMouseReleaseEvent(TQMouseEvent *e); 00129 00130 private: 00131 class KDateInternalMonthPrivate; 00132 KDateInternalMonthPrivate *d; 00133 }; 00134 00140 class TDEUI_EXPORT KDateInternalYearSelector : public TQLineEdit 00141 { 00142 Q_OBJECT 00143 protected: 00144 TQIntValidator *val; 00145 int result; 00146 public slots: 00147 void yearEnteredSlot(); 00148 signals: 00149 void closeMe(int); 00150 public: 00151 KDateInternalYearSelector( TQWidget* parent=0, const char* name=0); 00152 int getYear(); 00153 void setYear(int year); 00154 00155 private: 00156 class KDateInternalYearPrivate; 00157 KDateInternalYearPrivate *d; 00158 00159 }; 00160 00166 class TDEUI_EXPORT TDEPopupFrame : public TQFrame 00167 { 00168 Q_OBJECT 00169 protected: 00173 int result; 00177 virtual void keyPressEvent(TQKeyEvent* e); 00181 TQWidget *main; 00182 public slots: 00187 void close(int r); 00191 void hide(); 00192 00193 public: 00197 TDEPopupFrame(TQWidget* parent=0, const char* name=0); 00201 ~TDEPopupFrame(); 00209 void setMainWidget(TQWidget* m); 00214 virtual void resizeEvent(TQResizeEvent*); 00218 void popup(const TQPoint &pos); 00222 int exec(TQPoint p); // KDE4: const TQPoint& 00226 int exec(int x, int y); 00227 00228 private: 00229 00230 virtual bool close(bool alsoDelete) { return TQFrame::close(alsoDelete); } 00231 protected: 00232 virtual void virtual_hook( int id, void* data ); 00233 private: 00234 class TDEPopupFramePrivate; 00235 TDEPopupFramePrivate *d; 00236 }; 00237 00241 class TDEUI_EXPORT KDateValidator : public TQValidator 00242 { 00243 public: 00244 KDateValidator(TQWidget* parent=0, const char* name=0); 00245 virtual State validate(TQString&, int&) const; 00246 virtual void fixup ( TQString & input ) const; 00247 State date(const TQString&, TQDate&) const; 00248 }; 00249 00263 class TDEUI_EXPORT KDateTable : public TQGridView 00264 { 00265 Q_OBJECT 00266 TQ_PROPERTY( TQDate date READ getDate WRITE setDate ) 00267 TQ_PROPERTY( bool popupMenu READ popupMenuEnabled WRITE setPopupMenuEnabled ) 00268 00269 public: 00273 KDateTable(TQWidget *parent=0, TQDate date=TQDate::currentDate(), 00274 const char* name=0, WFlags f=0); 00275 00280 KDateTable(TQWidget *parent, const char* name, WFlags f=0); 00281 00285 ~KDateTable(); 00286 00294 virtual TQSize sizeHint() const; 00298 void setFontSize(int size); 00302 bool setDate(const TQDate&); 00303 // ### KDE 4.0 rename to date() 00304 const TQDate& getDate() const; 00305 00314 void setPopupMenuEnabled( bool enable ); 00315 00319 bool popupMenuEnabled() const; 00320 00321 enum BackgroundMode { NoBgMode=0, RectangleMode, CircleMode }; 00322 00329 void setCustomDatePainting( const TQDate &date, const TQColor &fgColor, BackgroundMode bgMode=NoBgMode, const TQColor &bgColor=TQColor()); 00330 00336 void unsetCustomDatePainting( const TQDate &date ); 00337 00338 protected: 00342 int posFromDate( const TQDate &date ); // KDE4: make this virtual, so subclasses can reimplement this and use a different default for the start of the matrix 00347 TQDate dateFromPos( int pos ); // KDE4: make this virtual 00348 00352 virtual void paintCell(TQPainter*, int, int); 00353 00357 virtual void paintEmptyArea(TQPainter*, int, int, int, int); 00358 00362 virtual void viewportResizeEvent(TQResizeEvent *); 00366 virtual void contentsMousePressEvent(TQMouseEvent *); 00367 virtual void wheelEvent( TQWheelEvent * e ); 00368 virtual void keyPressEvent( TQKeyEvent *e ); 00369 virtual void focusInEvent( TQFocusEvent *e ); 00370 virtual void focusOutEvent( TQFocusEvent *e ); 00371 00372 // ### KDE 4.0 make the following private and mark as members 00373 00377 int fontsize; 00381 TQDate date; 00385 int firstday; 00389 int numdays; 00393 int numDaysPrevMonth; 00398 bool unused_hasSelection; 00402 TQRect maxCell; 00403 signals: 00407 // ### KDE 4.0 make parameter a const reference 00408 void dateChanged(TQDate); 00415 void dateChanged(const TQDate& cur, const TQDate& old); 00419 void tableClicked(); 00420 00428 void aboutToShowContextMenu( TDEPopupMenu * menu, const TQDate &date); 00429 00430 private slots: 00431 void nextMonth(); 00432 void previousMonth(); 00433 void beginningOfMonth(); 00434 void endOfMonth(); 00435 void beginningOfWeek(); 00436 void endOfWeek(); 00437 00438 protected: 00439 virtual void virtual_hook( int id, void* data ); 00440 private: 00441 class KDateTablePrivate; 00442 KDateTablePrivate *d; 00443 00444 void initAccels(); 00445 }; 00446 00447 #endif // KDATETBL_H