]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/datectrl.cpp
guard for 10.2
[wxWidgets.git] / src / palmos / datectrl.cpp
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 IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxControl)
40
41 // ============================================================================
42 // implementation
43 // ============================================================================
44
45 // ----------------------------------------------------------------------------
46 // wxDatePickerCtrl creation
47 // ----------------------------------------------------------------------------
48
49 bool wxDatePickerCtrl::Create(wxWindow *parent,
50 wxWindowID id,
51 const wxDateTime& dt,
52 const wxPoint& pos,
53 const wxSize& size,
54 long style,
55 const wxValidator& validator,
56 const wxString& name)
57 {
58 if(!wxControl::Create(parent, id, pos, size, style, validator, name))
59 return false;
60
61 wxString label;
62
63 if ( dt.IsValid() )
64 {
65 label = dt.FormatDate();
66 m_dt = dt;
67 }
68
69 if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size))
70 return false;
71
72 return true;
73 }
74
75 // ----------------------------------------------------------------------------
76 // wxDatePickerCtrl geometry
77 // ----------------------------------------------------------------------------
78
79 wxSize wxDatePickerCtrl::DoGetBestSize() const
80 {
81 return wxSize(16,16);
82 }
83
84 // ----------------------------------------------------------------------------
85 // wxDatePickerCtrl operations
86 // ----------------------------------------------------------------------------
87
88 void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
89 {
90 if ( dt.IsValid() )
91 m_dt = dt;
92
93 SetLabel(m_dt.FormatDate());
94 }
95
96 wxDateTime wxDatePickerCtrl::GetValue() const
97 {
98 return m_dt;
99 }
100
101 void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
102 {
103 // TODO
104 }
105
106 bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
107 {
108 // TODO
109 return false;
110 }
111
112 // ----------------------------------------------------------------------------
113 // helpers
114 // ----------------------------------------------------------------------------
115
116 bool wxDatePickerCtrl::SendClickEvent()
117 {
118 int16_t month = (int16_t)m_dt.GetMonth() + 1;
119 int16_t day = m_dt.GetDay();
120 int16_t year = m_dt.GetYear();
121
122 if(!SelectDay(selectDayByDay,&month,&day,&year,_T("Pick date")))
123 return false;
124 wxDateTime dt(m_dt);
125 dt.Set((wxDateTime::wxDateTime_t)day,
126 (wxDateTime::Month)(month-1),
127 (int)year);
128 SetValue(dt);
129 return true;
130 }
131
132 #endif // wxUSE_DATEPICKCTRL
133