]> git.saurik.com Git - wxWidgets.git/commitdiff
wxDatePicker and wxDateTime for PalmOS. Remove conflict with internal maxDays in...
authorWłodzimierz Skiba <abx@abx.art.pl>
Tue, 15 Feb 2005 07:24:37 +0000 (07:24 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Tue, 15 Feb 2005 07:24:37 +0000 (07:24 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/palmos/makefile
docs/changes.txt
docs/latex/wx/datectrl.tex
include/wx/palmos/datectrl.h
include/wx/palmos/setup0.h
src/common/datetime.cpp
src/palmos/datectrl.cpp
src/palmos/toplevel.cpp

index 2bbb2f3ff8de4c50064b91ae4cd1d1c4fa98d944..32ed198007020effb570dc7118721a0f33156e3b 100644 (file)
@@ -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 \
index 6977466302d1a3cbcef8bf410ddf63c1874a6546..3edb51b5b1a5f292f5f9a185254c0f81238316d4 100644 (file)
@@ -140,6 +140,7 @@ wxPalmOS:
 - native wxToggleButton implementation
 - native wxRadioButton implementation
 - native wxStaticText implementation
+- native wxDatePickerCtrl implementation
 
 
 2.5.3
index add36bdfc3cda62eb979a3b02bbab5cdd94ba2cd..46e88106c53be5919228ccfa38b7bf8ded3e236d 100644 (file)
@@ -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$.
 
index e5c1921412033c89cff0c3f1e30bcbdc824c256b..cac08bbaabca095c5285b330626afdf4f7b0d120 100644 (file)
@@ -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;
 
index 04b68df6f4f78f78780de589b74ac78583f34e6c..e124c1ab5637221a84450dae94ea72f2a153f54f 100644 (file)
 // Default is 1
 //
 // Recommended setting: 1
-#define wxUSE_DATETIME      0
+#define wxUSE_DATETIME      1
 
 // Set wxUSE_TIMER to 1 to compile wxTimer class
 //
 #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
index 9ef9b7269087594ace937fc89a55af6c9402b998..17410c7443abfd99cf2b28f35e021e04c56bcfc9 100644 (file)
@@ -120,7 +120,9 @@ wxCUSTOM_TYPE_INFO(wxDateTime, wxToStringConverter<wxDateTime> , 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;
index 5461f6471dd8f2ebbe5033e79771408f1175aebf..c453c8ac61a93d559d6671dcd8b7a7c7d174ccdc 100644 (file)
@@ -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
 
index 6e624442284cef55e55aa15b5544183107bf8963..0fe4043a0f2f1f8e069ed04343f030ecfc926c4a 100644 (file)
@@ -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;
 }