summaryrefslogtreecommitdiffabout
path: root/microkde/kdatetbl.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /microkde/kdatetbl.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'microkde/kdatetbl.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdatetbl.h308
1 files changed, 308 insertions, 0 deletions
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
new file mode 100644
index 0000000..df7b7ef
--- a/dev/null
+++ b/microkde/kdatetbl.h
@@ -0,0 +1,308 @@
1/* -*- C++ -*-
2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20#ifndef KDATETBL_H
21#define KDATETBL_H
22
23#include <qvalidator.h>
24#include <qgridview.h>
25#include <qlineedit.h>
26#include <qdatetime.h>
27
28/**
29* A table containing month names. It is used to pick a month directly.
30* @internal
31* @version $Id$
32* @author Tim Gilman, Mirko Boehm
33*/
34class KDateInternalMonthPicker : public QGridView
35{
36 Q_OBJECT
37protected:
38 /**
39 * Store the month that has been clicked [1..12].
40 */
41 int result;
42 /**
43 * the cell under mouse cursor when LBM is pressed
44 */
45 short int activeCol;
46 short int activeRow;
47 /**
48 * Contains the largest rectangle needed by the month names.
49 */
50 QRect max;
51signals:
52 /**
53 * This is send from the mouse click event handler.
54 */
55 void closeMe(int);
56public:
57 /**
58 * The constructor.
59 */
60 KDateInternalMonthPicker(int fontsize, QWidget* parent, const char* name=0);
61 /**
62 * The size hint.
63 */
64 QSize sizeHint() const;
65 /**
66 * Return the result. 0 means no selection (reject()), 1..12 are the
67 * months.
68 */
69 int getResult() const;
70protected:
71 /**
72 * Set up the painter.
73 */
74 void setupPainter(QPainter *p);
75 /**
76 * The resize event.
77 */
78 void viewportResizeEvent(QResizeEvent*);
79 /**
80 * Paint a cell. This simply draws the month names in it.
81 */
82 virtual void paintCell(QPainter* painter, int row, int col);
83 /**
84 * Catch mouse click and move events to paint a rectangle around the item.
85 */
86 void contentsMousePressEvent(QMouseEvent *e);
87 void contentsMouseMoveEvent(QMouseEvent *e);
88 /**
89 * Emit monthSelected(int) when a cell has been released.
90 */
91 void contentsMouseReleaseEvent(QMouseEvent *e);
92
93private:
94 class KDateInternalMonthPrivate;
95 KDateInternalMonthPrivate *d;
96};
97
98/** Year selection widget.
99* @internal
100* @version $Id$
101* @author Tim Gilman, Mirko Boehm
102*/
103class KDateInternalYearSelector : public QLineEdit
104{
105 Q_OBJECT
106protected:
107 QIntValidator *val;
108 int result;
109public slots:
110 void yearEnteredSlot();
111signals:
112 void closeMe(int);
113public:
114 KDateInternalYearSelector(int fontsize,
115 QWidget* parent=0,
116 const char* name=0);
117 int getYear();
118 void setYear(int year);
119
120private:
121 class KDateInternalYearPrivate;
122 KDateInternalYearPrivate *d;
123};
124
125/**
126 * Frame with popup menu behaviour.
127 * @author Tim Gilman, Mirko Boehm
128 * @version $Id$
129 */
130class KPopupFrame : public QFrame
131{
132 Q_OBJECT
133protected:
134 /**
135 * The result. It is returned from exec() when the popup window closes.
136 */
137 int result;
138 /**
139 * Catch key press events.
140 */
141 void keyPressEvent(QKeyEvent* e);
142 /**
143 * The only subwidget that uses the whole dialog window.
144 */
145 QWidget *main;
146public slots:
147 /**
148 * Close the popup window. This is called from the main widget, usually.
149 * @p r is the result returned from exec().
150 */
151 void close(int r);
152public:
153 /**
154 * The contructor. Creates a dialog without buttons.
155 */
156 KPopupFrame(QWidget* parent=0, const char* name=0);
157 /**
158 * Set the main widget. You cannot set the main widget from the constructor,
159 * since it must be a child of the frame itselfes.
160 * Be careful: the size is set to the main widgets size. It is up to you to
161 * set the main widgets correct size before setting it as the main
162 * widget.
163 */
164 void setMainWidget(QWidget* m);
165 /**
166 * The resize event. Simply resizes the main widget to the whole
167 * widgets client size.
168 */
169 void resizeEvent(QResizeEvent*);
170 /**
171 * Open the popup window at position pos.
172 */
173 void popup(const QPoint &pos);
174 /**
175 * Execute the popup window.
176 */
177 int exec(QPoint p);
178 /**
179 * Dito.
180 */
181 int exec(int x, int y);
182
183private:
184
185 virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); }
186protected:
187 virtual void virtual_hook( int id, void* data );
188private:
189 class KPopupFramePrivate;
190 KPopupFramePrivate *d;
191};
192
193/**
194* Validates user-entered dates.
195*/
196class KDateValidator : public QValidator
197{
198public:
199 KDateValidator(QWidget* parent=0, const char* name=0);
200 virtual State validate(QString&, int&) const;
201 virtual void fixup ( QString & input ) const;
202 State date(const QString&, QDate&) const;
203};
204
205/**
206 * Date selection table.
207 * This is a support class for the KDatePicker class. It just
208 * draws the calender table without titles, but could theoretically
209 * be used as a standalone.
210 *
211 * When a date is selected by the user, it emits a signal:
212 * dateSelected(QDate)
213 *
214 * @internal
215 * @version $Id$
216 * @author Tim Gilman, Mirko Boehm
217 */
218class KDateTable : public QGridView
219{
220 Q_OBJECT
221public:
222 /**
223 * The constructor.
224 */
225 KDateTable(QWidget *parent=0,
226 QDate date=QDate::currentDate(),
227 const char* name=0, WFlags f=0);
228 /**
229 * Returns a recommended size for the widget.
230 * To save some time, the size of the largest used cell content is
231 * calculated in each paintCell() call, since all calculations have
232 * to be done there anyway. The size is stored in maxCell. The
233 * sizeHint() simply returns a multiple of maxCell.
234 */
235 virtual QSize sizeHint() const;
236 /**
237 * Set the font size of the date table.
238 */
239 void setFontSize(int size);
240 /**
241 * Select and display this date.
242 */
243 bool setDate(const QDate&);
244 const QDate& getDate() const;
245
246
247protected:
248 /**
249 * Paint a cell.
250 */
251 virtual void paintCell(QPainter*, int, int);
252 /**
253 * Handle the resize events.
254 */
255 virtual void viewportResizeEvent(QResizeEvent *);
256 /**
257 * React on mouse clicks that select a date.
258 */
259 virtual void contentsMousePressEvent(QMouseEvent *);
260 virtual void keyPressEvent( QKeyEvent *e );
261 virtual void focusInEvent( QFocusEvent *e );
262 virtual void focusOutEvent( QFocusEvent *e );
263 /**
264 * The font size of the displayed text.
265 */
266 int fontsize;
267 /**
268 * The currently selected date.
269 */
270 QDate date;
271 /**
272 * The day of the first day in the month [1..7].
273 */
274 int firstday;
275 /**
276 * The number of days in the current month.
277 */
278 int numdays;
279 /**
280 * The number of days in the previous month.
281 */
282 int numDaysPrevMonth;
283 /**
284 * unused
285 */
286 bool unused_hasSelection;
287 /**
288 * Save the size of the largest used cell content.
289 */
290 QRect maxCell;
291signals:
292 /**
293 * The selected date changed.
294 */
295 void dateChanged(QDate);
296 /**
297 * A date has been selected by clicking on the table.
298 */
299 void tableClicked();
300
301protected:
302 virtual void virtual_hook( int id, void* data );
303private:
304 class KDateTablePrivate;
305 KDateTablePrivate *d;
306};
307
308#endif // KDATETBL_H