]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/datectrl.cpp
Further improvements to the spec file.
[wxWidgets.git] / src / palmos / datectrl.cpp
CommitLineData
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
a69e2a0a
VZ
39IMPLEMENT_DYNAMIC_CLASS(wxDatePickerCtrl, wxControl)
40
324eeecb
WS
41// ============================================================================
42// implementation
43// ============================================================================
44
45// ----------------------------------------------------------------------------
46// wxDatePickerCtrl creation
47// ----------------------------------------------------------------------------
48
49bool 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() )
60582201 64 {
6a27c749 65 label = dt.FormatDate();
60582201
WS
66 m_dt = dt;
67 }
324eeecb 68
6a27c749 69 if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size))
324eeecb
WS
70 return false;
71
72 return true;
73}
74
75// ----------------------------------------------------------------------------
76// wxDatePickerCtrl geometry
77// ----------------------------------------------------------------------------
78
79wxSize wxDatePickerCtrl::DoGetBestSize() const
80{
6a27c749 81 return wxSize(16,16);
324eeecb
WS
82}
83
84// ----------------------------------------------------------------------------
85// wxDatePickerCtrl operations
86// ----------------------------------------------------------------------------
87
88void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
89{
6a27c749 90 if ( dt.IsValid() )
60582201
WS
91 m_dt = dt;
92
93 SetLabel(m_dt.FormatDate());
324eeecb
WS
94}
95
96wxDateTime wxDatePickerCtrl::GetValue() const
97{
60582201 98 return m_dt;
324eeecb
WS
99}
100
101void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
102{
103 // TODO
104}
105
106bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const
107{
108 // TODO
109 return false;
110}
111
6a27c749
WS
112// ----------------------------------------------------------------------------
113// helpers
114// ----------------------------------------------------------------------------
115
116bool wxDatePickerCtrl::SendClickEvent()
117{
df57c15c 118 int16_t month = (int16_t)m_dt.GetMonth() + 1;
60582201
WS
119 int16_t day = m_dt.GetDay();
120 int16_t year = m_dt.GetYear();
6a27c749 121
60582201
WS
122 if(!SelectDay(selectDayByDay,&month,&day,&year,_T("Pick date")))
123 return false;
124 wxDateTime dt(m_dt);
df57c15c
WS
125 dt.Set((wxDateTime::wxDateTime_t)day,
126 (wxDateTime::Month)(month-1),
127 (int)year);
60582201
WS
128 SetValue(dt);
129 return true;
6a27c749
WS
130}
131
324eeecb
WS
132#endif // wxUSE_DATEPICKCTRL
133