]>
Commit | Line | Data |
---|---|---|
324eeecb WS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/palmos/datectrl.cpp | |
3 | // Purpose: wxDatePickerCtrl implementation | |
4 | // Author: Wlodzimierz ABX Skiba | |
5 | // Modified by: | |
6 | // Created: 02/14/05 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Wlodzimierz Skiba | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #ifndef WX_PRECOMP | |
27 | #endif | |
28 | ||
29 | #if wxUSE_DATEPICKCTRL | |
30 | ||
31 | #include "wx/datectrl.h" | |
32 | #include "wx/app.h" | |
33 | #include "wx/intl.h" | |
34 | #include "wx/dynlib.h" | |
35 | ||
36 | #define _WX_DEFINE_DATE_EVENTS_ | |
37 | #include "wx/dateevt.h" | |
38 | ||
39 | // ============================================================================ | |
40 | // implementation | |
41 | // ============================================================================ | |
42 | ||
43 | // ---------------------------------------------------------------------------- | |
44 | // wxDatePickerCtrl creation | |
45 | // ---------------------------------------------------------------------------- | |
46 | ||
47 | bool wxDatePickerCtrl::Create(wxWindow *parent, | |
48 | wxWindowID id, | |
49 | const wxDateTime& dt, | |
50 | const wxPoint& pos, | |
51 | const wxSize& size, | |
52 | long style, | |
53 | const wxValidator& validator, | |
54 | const wxString& name) | |
55 | { | |
56 | if(!wxControl::Create(parent, id, pos, size, style, validator, name)) | |
57 | return false; | |
58 | ||
59 | wxString label; | |
60 | ||
61 | if ( dt.IsValid() ) | |
60582201 | 62 | { |
6a27c749 | 63 | label = dt.FormatDate(); |
60582201 WS |
64 | m_dt = dt; |
65 | } | |
324eeecb | 66 | |
6a27c749 | 67 | if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size)) |
324eeecb WS |
68 | return false; |
69 | ||
70 | return true; | |
71 | } | |
72 | ||
73 | // ---------------------------------------------------------------------------- | |
74 | // wxDatePickerCtrl geometry | |
75 | // ---------------------------------------------------------------------------- | |
76 | ||
77 | wxSize wxDatePickerCtrl::DoGetBestSize() const | |
78 | { | |
6a27c749 | 79 | return wxSize(16,16); |
324eeecb WS |
80 | } |
81 | ||
82 | // ---------------------------------------------------------------------------- | |
83 | // wxDatePickerCtrl operations | |
84 | // ---------------------------------------------------------------------------- | |
85 | ||
86 | void wxDatePickerCtrl::SetValue(const wxDateTime& dt) | |
87 | { | |
6a27c749 | 88 | if ( dt.IsValid() ) |
60582201 WS |
89 | m_dt = dt; |
90 | ||
91 | SetLabel(m_dt.FormatDate()); | |
324eeecb WS |
92 | } |
93 | ||
94 | wxDateTime wxDatePickerCtrl::GetValue() const | |
95 | { | |
60582201 | 96 | return m_dt; |
324eeecb WS |
97 | } |
98 | ||
99 | void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2) | |
100 | { | |
101 | // TODO | |
102 | } | |
103 | ||
104 | bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const | |
105 | { | |
106 | // TODO | |
107 | return false; | |
108 | } | |
109 | ||
6a27c749 WS |
110 | // ---------------------------------------------------------------------------- |
111 | // helpers | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
114 | bool wxDatePickerCtrl::SendClickEvent() | |
115 | { | |
60582201 WS |
116 | int16_t month = m_dt.GetMonth(); |
117 | int16_t day = m_dt.GetDay(); | |
118 | int16_t year = m_dt.GetYear(); | |
6a27c749 | 119 | |
60582201 WS |
120 | if(!SelectDay(selectDayByDay,&month,&day,&year,_T("Pick date"))) |
121 | return false; | |
122 | wxDateTime dt(m_dt); | |
123 | dt.Set((wxDateTime::wxDateTime_t)day, (wxDateTime::Month)month, (int)year); | |
124 | SetValue(dt); | |
125 | return true; | |
6a27c749 WS |
126 | } |
127 | ||
324eeecb WS |
128 | #endif // wxUSE_DATEPICKCTRL |
129 |