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