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