X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2a5e6376f23d5d61e485fde07cd4bcd88ca28c3b..974a50f1bbd6bcff1666fa492ee9802a6ee5b8da:/src/generic/datectlg.cpp?ds=sidebyside diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 2c2a33d58a..ab5d7448d7 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: generic/datectlg.cpp +// Name: src/generic/datectlg.cpp // Purpose: generic wxDatePickerCtrlGeneric implementation // Author: Andreas Pflug // Modified by: @@ -128,9 +128,8 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator); - virtual void DoMoveWindow(int x, int y, int w, int h); - protected: + virtual void DoMoveWindow(int x, int y, int w, int h); void OnSize(wxSizeEvent& event); void OnMouseEnter(wxMouseEvent& event); @@ -570,14 +569,18 @@ void wxDatePickerCtrlGeneric::DoMoveWindow(int x, int y, int w, int h) wxControl::DoMoveWindow(x, y, w, h); if (m_dropped) - DropDown(true); + DropDown(false); } wxSize wxDatePickerCtrlGeneric::DoGetBestSize() const { - int bh=m_btn->GetBestSize().y; - int eh=m_txt->GetBestSize().y; - return wxSize(DEFAULT_ITEM_WIDTH, bh > eh ? bh : eh); + if (m_btn && m_txt) + { + int bh=m_btn->GetBestSize().y; + int eh=m_txt->GetBestSize().y; + return wxSize(DEFAULT_ITEM_WIDTH, bh > eh ? bh : eh); + } + return wxControl::DoGetBestSize(); } @@ -633,14 +636,14 @@ wxDatePickerCtrlGeneric::SetDateRange(const wxDateTime& lowerdate, bool wxDatePickerCtrlGeneric::SetFormat(const wxChar *fmt) { + m_format.clear(); + wxDateTime dt; dt.ParseFormat(wxT("2003-10-13"), wxT("%Y-%m-%d")); - wxString str=dt.Format(fmt); - wxChar *p=(wxChar*)str.c_str(); - - m_format=wxEmptyString; + wxString str(dt.Format(fmt)); - while (*p) + const wxChar *p = str.c_str(); + while ( *p ) { int n=wxAtoi(p); if (n == dt.GetDay()) @@ -670,19 +673,19 @@ bool wxDatePickerCtrlGeneric::SetFormat(const wxChar *fmt) m_format.Append(*p++); } - if (m_txt) + if ( m_txt ) { wxArrayString allowedChars; for ( wxChar c = _T('0'); c <= _T('9'); c++ ) allowedChars.Add(wxString(c, 1)); - const wxChar *p = m_format.c_str(); - while (*p) + const wxChar *p2 = m_format.c_str(); + while ( *p2 ) { - if (*p == '%') - p += 2; + if ( *p2 == '%') + p2 += 2; else - allowedChars.Add(wxString(*p++, 1)); + allowedChars.Add(wxString(*p2++, 1)); } #if wxUSE_VALIDATORS @@ -737,7 +740,7 @@ bool wxDatePickerCtrlGeneric::GetRange(wxDateTime *dt1, wxDateTime *dt2) const { if (dt1) *dt1 = m_cal->GetLowerDateLimit(); - if (dt1) + if (dt2) *dt2 = m_cal->GetUpperDateLimit(); return true; } @@ -954,4 +957,3 @@ void wxDatePickerCtrlGeneric::OnCalKey(wxKeyEvent & ev) #endif // wxUSE_DATEPICKCTRL_GENERIC #endif // wxUSE_DATEPICKCTRL -