kdeui Library API Documentation

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., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 #ifndef KDATETBL_H
00021 #define KDATETBL_H
00022 
00023 #include <qvalidator.h>
00024 #include <qgridview.h>
00025 #include <qlineedit.h>
00026 #include <qdatetime.h>
00027 #include <qcolor.h>
00028 
00029 class KPopupMenu;
00030 
00036 class KDateInternalWeekSelector : public QLineEdit
00037 {
00038   Q_OBJECT
00039 protected:
00040   QIntValidator *val;
00041   int result;
00042 public slots:
00043   void weekEnteredSlot();
00044   void setMaxWeek(int max);
00045 signals:
00046   void closeMe(int);
00047 public:
00048   KDateInternalWeekSelector( QWidget* parent=0, const char* name=0);
00049   int getWeek();
00050   void setWeek(int week);
00051 
00052 private:
00053   class KDateInternalWeekPrivate;
00054   KDateInternalWeekPrivate *d;
00055 };
00056 
00063 class KDateInternalMonthPicker : public QGridView
00064 {
00065   Q_OBJECT
00066 protected:
00070   int result;
00074   short int activeCol;
00075   short int activeRow;
00079   QRect max;
00080 signals:
00084   void closeMe(int);
00085 public:
00089   KDateInternalMonthPicker(const QDate& date, QWidget* parent, const char* name=0);
00093   ~KDateInternalMonthPicker();
00097   QSize sizeHint() const;
00102   int getResult() const;
00103 protected:
00107   void setupPainter(QPainter *p);
00111   virtual void viewportResizeEvent(QResizeEvent*);
00115   virtual void paintCell(QPainter* painter, int row, int col);
00119   virtual void contentsMousePressEvent(QMouseEvent *e);
00120   virtual void contentsMouseMoveEvent(QMouseEvent *e);
00124   virtual void contentsMouseReleaseEvent(QMouseEvent *e);
00125 
00126 private:
00127   class KDateInternalMonthPrivate;
00128   KDateInternalMonthPrivate *d;
00129 };
00130 
00136 class KDateInternalYearSelector : public QLineEdit
00137 {
00138   Q_OBJECT
00139 protected:
00140   QIntValidator *val;
00141   int result;
00142 public slots:
00143   void yearEnteredSlot();
00144 signals:
00145   void closeMe(int);
00146 public:
00147   KDateInternalYearSelector( QWidget* parent=0, const char* name=0);
00148   int getYear();
00149   void setYear(int year);
00150 
00151 private:
00152   class KDateInternalYearPrivate;
00153   KDateInternalYearPrivate *d;
00154 
00155 };
00156 
00162 class KPopupFrame : public QFrame
00163 {
00164   Q_OBJECT
00165 protected:
00169   int result;
00173   virtual void keyPressEvent(QKeyEvent* e);
00177   QWidget *main;
00178 public slots:
00183   void close(int r);
00184 public:
00188   KPopupFrame(QWidget* parent=0, const char*  name=0);
00196   void setMainWidget(QWidget* m);
00201   virtual void resizeEvent(QResizeEvent*);
00205   void popup(const QPoint &pos);
00209   int exec(QPoint p);
00213   int exec(int x, int y);
00214 
00215 private:
00216 
00217   virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); }
00218 protected:
00219   virtual void virtual_hook( int id, void* data );
00220 private:
00221   class KPopupFramePrivate;
00222   KPopupFramePrivate *d;
00223 };
00224 
00228 class KDateValidator : public QValidator
00229 {
00230 public:
00231     KDateValidator(QWidget* parent=0, const char* name=0);
00232     virtual State validate(QString&, int&) const;
00233     virtual void fixup ( QString & input ) const;
00234     State date(const QString&, QDate&) const;
00235 };
00236 
00250 class KDateTable : public QGridView
00251 {
00252     Q_OBJECT
00253     Q_PROPERTY( QDate date READ getDate WRITE setDate )
00254     Q_PROPERTY( bool popupMenu READ popupMenuEnabled WRITE setPopupMenuEnabled )
00255     
00256 public:
00260     KDateTable(QWidget *parent=0,
00261            QDate date=QDate::currentDate(),
00262            const char* name=0, WFlags f=0);
00263            
00267     ~KDateTable();
00268     
00276     virtual QSize sizeHint() const;
00280     void setFontSize(int size);
00284     bool setDate(const QDate&);
00285     // ### 4.0 rename to date()
00286     const QDate& getDate() const;
00287 
00296     void setPopupMenuEnabled( bool enable );
00297 
00301     bool popupMenuEnabled() const;
00302 
00303     enum BackgroundMode { NoBgMode=0, RectangleMode, CircleMode };
00304 
00311     void setCustomDatePainting( const QDate &date, const QColor &fgColor, BackgroundMode bgMode=NoBgMode, const QColor &bgColor=QColor());
00312 
00318     void unsetCustomDatePainting( const QDate &date );
00319 
00320 protected:
00324     int posFromDate( const QDate &date ); // KDE4: make this virtual, so subclasses can reimplement this and use a different default for the start of the matrix
00329     QDate dateFromPos( int pos ); // KDE4: make this virtual
00330     
00334     virtual void paintCell(QPainter*, int, int);
00338     virtual void viewportResizeEvent(QResizeEvent *);
00342     virtual void contentsMousePressEvent(QMouseEvent *);
00343     virtual void wheelEvent( QWheelEvent * e );
00344     virtual void keyPressEvent( QKeyEvent *e );
00345     virtual void focusInEvent( QFocusEvent *e );
00346     virtual void focusOutEvent( QFocusEvent *e );
00347 
00348     // ### KDE 4.0 make the following private and mark as members
00349     
00353     int fontsize;
00357     QDate date;
00361     int firstday;
00365     int numdays;
00369     int numDaysPrevMonth;
00374     bool unused_hasSelection;
00378     QRect maxCell;
00379 signals:
00383     // ### KDE 4.0 make parameter a const reference
00384     void dateChanged(QDate);
00391     void dateChanged(const QDate& cur, const QDate& old);
00395     void tableClicked();
00396 
00404     void aboutToShowContextMenu( KPopupMenu * menu, const QDate &date);
00405 
00406 protected:
00407   virtual void virtual_hook( int id, void* data );
00408 private:
00409     class KDateTablePrivate;
00410     KDateTablePrivate *d;
00411 };
00412 
00413 #endif // KDATETBL_H
KDE Logo
This file is part of the documentation for kdeui Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Apr 21 18:43:14 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003