]> git.saurik.com Git - wxWidgets.git/blob - include/wx/timectrl.h
add support for GtkFontChooserDialog, new in GTK 3.2
[wxWidgets.git] / include / wx / timectrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/timectrl.h
3 // Purpose: Declaration of wxTimePickerCtrl class.
4 // Author: Vadim Zeitlin
5 // Created: 2011-09-22
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_TIMECTRL_H_
12 #define _WX_TIMECTRL_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_TIMEPICKCTRL
17
18 #include "wx/datetimectrl.h"
19
20 #define wxTimePickerCtrlNameStr wxS("timectrl")
21
22 // No special styles are currently defined for this control but still define a
23 // symbolic constant for the default style for consistency.
24 enum
25 {
26 wxTP_DEFAULT = 0
27 };
28
29 // ----------------------------------------------------------------------------
30 // wxTimePickerCtrl: Allow the user to enter the time.
31 // ----------------------------------------------------------------------------
32
33 class WXDLLIMPEXP_ADV wxTimePickerCtrlBase : public wxDateTimePickerCtrl
34 {
35 public:
36 /*
37 The derived classes should implement ctor and Create() method with the
38 following signature:
39
40 bool Create(wxWindow *parent,
41 wxWindowID id,
42 const wxDateTime& dt = wxDefaultDateTime,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxTP_DEFAULT,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxTimePickerCtrlNameStr);
48 */
49
50 /*
51 We also inherit Set/GetValue() methods from the base class which define
52 our public API. Notice that the date portion of the date passed as
53 input or received as output is or should be ignored, only the time part
54 of wxDateTime objects is really significant here. Use Set/GetTime()
55 below for possibly simpler interface.
56 */
57
58 // Set the given time.
59 bool SetTime(int hour, int min, int sec)
60 {
61 // Notice that we should use a date on which DST doesn't change to
62 // avoid any problems with time discontinuity so use a fixed date (on
63 // which nobody changes DST) instead of e.g. today.
64 wxDateTime dt(1, wxDateTime::Jan, 2012, hour, min, sec);
65 if ( !dt.IsValid() )
66 {
67 // No need to assert here, wxDateTime already does it for us.
68 return false;
69 }
70
71 SetValue(dt);
72
73 return true;
74 }
75
76 // Get the current time components. All pointers must be non-NULL.
77 bool GetTime(int* hour, int* min, int* sec) const
78 {
79 wxCHECK_MSG( hour && min && sec, false,
80 wxS("Time component pointers must be non-NULL") );
81
82 const wxDateTime::Tm tm = GetValue().GetTm();
83 *hour = tm.hour;
84 *min = tm.min;
85 *sec = tm.sec;
86
87 return true;
88 }
89 };
90
91 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
92 #include "wx/msw/timectrl.h"
93
94 #define wxHAS_NATIVE_TIMEPICKERCTRL
95 #elif defined(__WXOSX_COCOA__) && !defined(__WXUNIVERSAL__)
96 #include "wx/osx/timectrl.h"
97
98 #define wxHAS_NATIVE_TIMEPICKERCTRL
99 #else
100 #include "wx/generic/timectrl.h"
101
102 class WXDLLIMPEXP_ADV wxTimePickerCtrl : public wxTimePickerCtrlGeneric
103 {
104 public:
105 wxTimePickerCtrl() { }
106 wxTimePickerCtrl(wxWindow *parent,
107 wxWindowID id,
108 const wxDateTime& date = wxDefaultDateTime,
109 const wxPoint& pos = wxDefaultPosition,
110 const wxSize& size = wxDefaultSize,
111 long style = wxTP_DEFAULT,
112 const wxValidator& validator = wxDefaultValidator,
113 const wxString& name = wxTimePickerCtrlNameStr)
114 : wxTimePickerCtrlGeneric(parent, id, date, pos, size, style, validator, name)
115 {
116 }
117
118 private:
119 wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxTimePickerCtrl);
120 };
121 #endif
122
123 #endif // wxUSE_TIMEPICKCTRL
124
125 #endif // _WX_TIMECTRL_H_