sptk2 logo
SPTK Home Page
CDateTimeInput.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/sptk.h>
30
31#include <sptk5/DateTime.h>
32#include <sptk5/gui/CControl.h>
33#include <sptk5/gui/CInput.h>
34
35namespace sptk {
36
42class CPopupCalendar;
43
44class CDateControl;
45
51class SP_EXPORT CDateTimeBaseInput
52 : public CInput
53{
54 using inherited = class CInput;
55
59 DateTime m_minValue;
60
64 DateTime m_maxValue;
65
69 void ctor_init();
70
71protected:
75 CPopupCalendar* m_calendarWindow {nullptr};
76
80 CDateControl* m_dateInput {nullptr};
81
85 CInput_* m_timeInput {nullptr};
86
90 void load(Query*) override;
91
95 void save(Query*) override;
96
105 void load(const xdoc::SNode& node, CLayoutXMLmode xmlMode) override;
106
115 void save(const xdoc::SNode& node, CLayoutXMLmode xmlMode) const override;
116
120 bool valid() const override;
121
129 CDateTimeBaseInput(const char* label, int layoutSize, CLayoutAlign layoutAlign, bool autoCreate);
130
134 static void calendarButtonPressed(Fl_Widget* btn, void* data);
135
136#ifdef __COMPATIBILITY_MODE__
145 CDateTimeBaseInput(int x, int y, int w, int h, const char* label, bool autoCreate);
146#endif
147
151 bool showCalendar(Fl_Widget* btn);
152
153public:
160 void setLimits(bool limited, DateTime min = DateTime(), DateTime max = DateTime());
161
165 virtual DateTime dateTimeValue() const;
166
170 virtual void dateTimeValue(DateTime dt);
171};
172
173class CTimeInput;
174
180class SP_EXPORT CDateInput
181 : public CDateTimeBaseInput
182{
186 void ctor_init();
187
188public:
195 explicit CDateInput(const char* label = nullptr, int layoutSize = 10,
196 CLayoutAlign layoutAlign = CLayoutAlign::TOP);
197
198#ifdef __COMPATIBILITY_MODE__
207 CDateInput(int x, int y, int w, int h, const char* label = 0);
208#endif
209
210 ~CDateInput() override;
211
216 CControlKind kind() const override
217 {
218 return CControlKind::DATE;
219 }
220
224 String className() const override
225 {
226 return "date_input";
227 }
228
233 Variant data() const override;
234
238 void data(const Variant& v) override;
239
247 void resize(int x, int y, int w, int h) override;
248
253 void preferredHeight(int& h) const override;
254
258 static CLayoutClient* creator(const xdoc::SNode& node);
259};
260
266class SP_EXPORT CTimeInput
267 : public CDateTimeBaseInput
268{
269public:
276 explicit CTimeInput(const char* label = nullptr, int layoutSize = 10,
277 CLayoutAlign layoutAlign = CLayoutAlign::TOP);
278
279#ifdef __COMPATIBILITY_MODE__
288 CTimeInput(int x, int y, int w, int h, const char* label = 0);
289#endif
290
295 CControlKind kind() const override
296 {
297 return CControlKind::TIME;
298 }
299
303 String className() const override
304 {
305 return "time_input";
306 }
307
312 void preferredWidth(int& w) const override;
313
317 static CLayoutClient* creator(const xdoc::SNode& node);
318};
319
326class SP_EXPORT CDateTimeInput
327 : public CDateTimeBaseInput
328{
329
333 void ctor_init();
334
335public:
342 CDateTimeInput(const char* label = nullptr, int layoutSize = 10,
343 CLayoutAlign layoutAlign = CLayoutAlign::TOP);
344
345#ifdef __COMPATIBILITY_MODE__
354 CDateTimeInput(int x, int y, int w, int h, const char* label = 0);
355#endif
356
361 CControlKind kind() const override
362 {
364 }
365
369 String className() const override
370 {
371 return "date_time_input";
372 }
373
381 void resize(int x, int y, int w, int h) override;
382
386 DateTime dateTimeValue() const override;
387
391 void dateTimeValue(DateTime dt) override;
392
396 Variant data() const override;
397
401 void data(const Variant& v) override;
402
406 static CLayoutClient* creator(const xdoc::SNode& node);
407};
411} // namespace sptk
Date input widget.
Definition: CDateControl.h:48
Date input widget.
Definition: CDateTimeInput.h:182
String className() const override
Returns the control class name, SPTK-style RTTI.
Definition: CDateTimeInput.h:224
void resize(int x, int y, int w, int h) override
Resizes the control and inside widgets.
static CLayoutClient * creator(const xdoc::SNode &node)
Creates a widget based on the XML node information.
Variant data() const override
Universal data connection, returns data from date control. Data is returned as VAR_DATE.
CControlKind kind() const override
Returns the control kind, SPTK-style RTTI.
Definition: CDateTimeInput.h:216
CDateInput(const char *label=nullptr, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
Constructor in SPTK style.
void data(const Variant &v) override
Universal data connection, sets data to date control.
void preferredHeight(int &h) const override
Base date and time input widget.
Definition: CDateTimeInput.h:53
bool showCalendar(Fl_Widget *btn)
Shows drop-down calendar.
void load(const xdoc::SNode &node, CLayoutXMLmode xmlMode) override
Loads control data from XML.
virtual void dateTimeValue(DateTime dt)
Sets widget date or time value.
CDateTimeBaseInput(const char *label, int layoutSize, CLayoutAlign layoutAlign, bool autoCreate)
Constructor in SPTK style.
void setLimits(bool limited, DateTime min=DateTime(), DateTime max=DateTime())
Sets limits for the value inside.
virtual DateTime dateTimeValue() const
Returns widget date or time value.
void save(Query *) override
Saves data to query.
bool valid() const override
Returns true if the input data is valid.
static void calendarButtonPressed(Fl_Widget *btn, void *data)
Internal callback function.
void save(const xdoc::SNode &node, CLayoutXMLmode xmlMode) const override
Saves control data to XML.
void load(Query *) override
Loads data from query.
Date and time input widget.
Definition: CDateTimeInput.h:328
CControlKind kind() const override
Returns the control kind, SPTK-style RTTI.
Definition: CDateTimeInput.h:361
void resize(int x, int y, int w, int h) override
Resizes the control and inside widgets.
String className() const override
Returns the control class name, SPTK-style RTTI.
Definition: CDateTimeInput.h:369
DateTime dateTimeValue() const override
Returns widget date or time value.
Variant data() const override
Universal data connection, returns data from control.
static CLayoutClient * creator(const xdoc::SNode &node)
Creates a widget based on the XML node information.
CDateTimeInput(const char *label=nullptr, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
Constructor in SPTK style.
void data(const Variant &v) override
Universal data connection, sets data from control.
void dateTimeValue(DateTime dt) override
Sets widget date or time value.
Definition: CInput.h:56
Definition: CInput.h:197
Definition: CLayoutClient.h:82
Popup Calendar.
Definition: CCalendar.h:150
Time input widget.
Definition: CDateTimeInput.h:268
String className() const override
Returns the control class name, SPTK-style RTTI.
Definition: CDateTimeInput.h:303
CControlKind kind() const override
Returns the control kind, SPTK-style RTTI.
Definition: CDateTimeInput.h:295
void preferredWidth(int &w) const override
Computes the optimal widget width.
CTimeInput(const char *label=nullptr, int layoutSize=10, CLayoutAlign layoutAlign=CLayoutAlign::TOP)
Constructor in SPTK style.
static CLayoutClient * creator(const xdoc::SNode &node)
Creates a widget based on the XML node information.
Definition: DateTime.h:86
Definition: Query.h:239
Definition: String.h:49
Definition: Variant.h:372
CControlKind
Control kind is the constant to report the internal SPTK RTTI.
Definition: CControl.h:50
CLayoutAlign
Definition: CLayoutClient.h:44
CLayoutXMLmode
Definition: CLayoutClient.h:57
@ TOP
Align to the right.

Fri Oct 14 2022 09:58:31: SPTK 5.4.1