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