From 6a27c749b302e17446080bb232ef8010b60f3d00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 15 Feb 2005 07:24:37 +0000 Subject: [PATCH] wxDatePicker and wxDateTime for PalmOS. Remove conflict with internal maxDays in PalmOS. #if wxUSE_XXX for limited builds. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/palmos/makefile | 1 + docs/changes.txt | 1 + docs/latex/wx/datectrl.tex | 2 +- include/wx/palmos/datectrl.h | 3 +++ include/wx/palmos/setup0.h | 4 ++-- src/common/datetime.cpp | 8 +++++--- src/palmos/datectrl.cpp | 27 +++++++++++++++++++++------ src/palmos/toplevel.cpp | 19 +++++++++++++++++++ 8 files changed, 53 insertions(+), 12 deletions(-) diff --git a/build/palmos/makefile b/build/palmos/makefile index 2bbb2f3ff8..32ed198007 100644 --- a/build/palmos/makefile +++ b/build/palmos/makefile @@ -152,6 +152,7 @@ SOURCES = ../../samples/minimal/minimal.cpp \ ../../src/common/socket.cpp \ ../../src/common/statbar.cpp \ ../../src/common/stockitem.cpp \ +../../src/common/stopwatch.cpp \ ../../src/common/strconv.cpp \ ../../src/common/stream.cpp \ ../../src/common/string.cpp \ diff --git a/docs/changes.txt b/docs/changes.txt index 6977466302..3edb51b5b1 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -140,6 +140,7 @@ wxPalmOS: - native wxToggleButton implementation - native wxRadioButton implementation - native wxStaticText implementation +- native wxDatePickerCtrl implementation 2.5.3 diff --git a/docs/latex/wx/datectrl.tex b/docs/latex/wx/datectrl.tex index add36bdfc3..46e88106c5 100644 --- a/docs/latex/wx/datectrl.tex +++ b/docs/latex/wx/datectrl.tex @@ -15,7 +15,7 @@ This control allows the user to select a date. Unlike wxDatePickerCtrl is implemented as a small window showing the currently selected date. The control can be edited using the keyboard, and can also display a popup window for more user-friendly date selection, depending on the styles used and -the platform. +the platform, except PalmOS where date is selected using native dialog. It is only available if \texttt{wxUSE\_DATEPICKCTRL} is set to $1$. diff --git a/include/wx/palmos/datectrl.h b/include/wx/palmos/datectrl.h index e5c1921412..cac08bbaab 100644 --- a/include/wx/palmos/datectrl.h +++ b/include/wx/palmos/datectrl.h @@ -53,6 +53,9 @@ public: virtual void SetRange(const wxDateTime& dt1, const wxDateTime& dt2); virtual bool GetRange(wxDateTime *dt1, wxDateTime *dt2) const; + // send a notification event, return true if processed + bool SendClickEvent(); + protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index 04b68df6f4..e124c1ab56 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -311,7 +311,7 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_DATETIME 0 +#define wxUSE_DATETIME 1 // Set wxUSE_TIMER to 1 to compile wxTimer class // @@ -519,7 +519,7 @@ #define wxUSE_CHECKLISTBOX 0 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) #define wxUSE_CHOICE 0 // wxChoice #define wxUSE_COMBOBOX 0 // wxComboBox -#define wxUSE_DATEPICKCTRL 0 // wxDatePickerCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl #define wxUSE_GAUGE 0 // wxGauge #define wxUSE_LISTBOX 0 // wxListBox #define wxUSE_LISTCTRL 0 // wxListCtrl diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 9ef9b72690..17410c7443 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -120,7 +120,9 @@ wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter , wxFromStringCon #endif #if !defined(WX_TIMEZONE) && !defined(WX_GMTOFF_IN_TM) - #if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__) + #if defined(__WXPALMOS__) + #define WX_GMTOFF_IN_TM + #elif defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__) #define WX_TIMEZONE _timezone #elif defined(__MWERKS__) long wxmw_timezone = 28800; @@ -3563,14 +3565,14 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date) } else // may be either day or year { - wxDateTime_t maxDays = (wxDateTime_t)( + wxDateTime_t max_days = (wxDateTime_t)( haveMon ? GetNumOfDaysInMonth(haveYear ? year : Inv_Year, mon) : 31 ); // can it be day? - if ( (val == 0) || (val > (unsigned long)maxDays) ) + if ( (val == 0) || (val > (unsigned long)max_days) ) { // no isYear = true; diff --git a/src/palmos/datectrl.cpp b/src/palmos/datectrl.cpp index 5461f6471d..c453c8ac61 100644 --- a/src/palmos/datectrl.cpp +++ b/src/palmos/datectrl.cpp @@ -59,9 +59,9 @@ bool wxDatePickerCtrl::Create(wxWindow *parent, wxString label; if ( dt.IsValid() ) - label = _T("test2"); + label = dt.FormatDate(); - ig(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size)) + if(!wxControl::PalmCreateControl(selectorTriggerCtl, label, pos, size)) return false; return true; @@ -73,9 +73,7 @@ bool wxDatePickerCtrl::Create(wxWindow *parent, wxSize wxDatePickerCtrl::DoGetBestSize() const { - const int y = GetCharHeight(); - - return wxSize(DEFAULT_ITEM_WIDTH, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); + return wxSize(16,16); } // ---------------------------------------------------------------------------- @@ -84,7 +82,10 @@ wxSize wxDatePickerCtrl::DoGetBestSize() const void wxDatePickerCtrl::SetValue(const wxDateTime& dt) { - SetLabel(_T("test1")); + if ( dt.IsValid() ) + SetLabel(dt.FormatDate()); + else + SetLabel(wxEmptyString); } wxDateTime wxDatePickerCtrl::GetValue() const @@ -105,5 +106,19 @@ bool wxDatePickerCtrl::GetRange(wxDateTime *dt1, wxDateTime *dt2) const return false; } +// ---------------------------------------------------------------------------- +// helpers +// ---------------------------------------------------------------------------- + +bool wxDatePickerCtrl::SendClickEvent() +{ + wxDateTime dt(wxDateTime::Today()); + int16_t month = dt.GetMonth(); + int16_t day = dt.GetDay(); + int16_t year = dt.GetYear(); + + if(SelectDay(selectDayByMonth,&month,&day,&year,_T("Pick date"))); +} + #endif // wxUSE_DATEPICKCTRL diff --git a/src/palmos/toplevel.cpp b/src/palmos/toplevel.cpp index 6e62444228..0fe4043a0f 100644 --- a/src/palmos/toplevel.cpp +++ b/src/palmos/toplevel.cpp @@ -48,6 +48,7 @@ #include "wx/radiobut.h" #include "wx/tglbtn.h" #include "wx/slider.h" +#include "wx/datectrl.h" // ---------------------------------------------------------------------------- // globals @@ -257,25 +258,41 @@ bool wxTopLevelWindowPalm::HandleControlSelect(EventType* event) if(win==NULL) return false; +#if wxUSE_BUTTON wxButton* button = wxDynamicCast(win,wxButton); if(button) return button->SendClickEvent(); +#endif // wxUSE_BUTTON +#if wxUSE_CHECKBOX wxCheckBox* checkbox = wxDynamicCast(win,wxCheckBox); if(checkbox) return checkbox->SendClickEvent(); +#endif // wxUSE_CHECKBOX +#if wxUSE_TOGGLEBTN wxToggleButton* toggle = wxDynamicCast(win,wxToggleButton); if(toggle) return toggle->SendClickEvent(); +#endif // wxUSE_TOGGLEBTN +#if wxUSE_RADIOBTN wxRadioButton* radio = wxDynamicCast(win,wxRadioButton); if(radio) return radio->SendClickEvent(); +#endif // wxUSE_RADIOBTN +#if wxUSE_DATEPICKCTRL + wxDatePickerCtrl* datepicker = wxDynamicCast(win,wxDatePickerCtrl); + if(datepicker) + return datepicker->SendClickEvent(); +#endif // wxUSE_DATEPICKCTRL + +#if wxUSE_SLIDER wxSlider* slider = wxDynamicCast(win,wxSlider); if(slider) return slider->SendUpdatedEvent(); +#endif // wxUSE_SLIDER return false; } @@ -288,9 +305,11 @@ bool wxTopLevelWindowPalm::HandleControlRepeat(EventType* event) if(win==NULL) return false; +#if wxUSE_SLIDER wxSlider* slider = wxDynamicCast(win,wxSlider); if(slider) return slider->SendScrollEvent(event); +#endif // wxUSE_SLIDER return false; } -- 2.45.2