X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..1cff04deb5c17c95bef9c83e72645f105b90e750:/src/generic/calctrl.cpp diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index b1e3317091..2965710e11 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -60,6 +60,7 @@ private: wxCalendarCtrl *m_cal; DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxMonthComboBox) }; class wxYearSpinCtrl : public wxSpinCtrl @@ -74,6 +75,7 @@ private: wxCalendarCtrl *m_cal; DECLARE_EVENT_TABLE() + DECLARE_NO_COPY_CLASS(wxYearSpinCtrl) }; // ---------------------------------------------------------------------------- @@ -147,6 +149,7 @@ wxYearSpinCtrl::wxYearSpinCtrl(wxCalendarCtrl *cal) wxDefaultSize, wxSP_ARROW_KEYS | wxCLIP_SIBLINGS, -4300, 10000, cal->GetDate().GetYear()) + { m_cal = cal; } @@ -755,9 +758,39 @@ void wxCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) { wxSize sizeCombo = m_comboMonth->GetSize(); wxSize sizeStatic = m_staticMonth->GetSize(); - + wxSize sizeSpin = m_spinYear->GetSize(); int dy = (sizeCombo.y - sizeStatic.y) / 2; - +/* +In the calender the size of the combobox for the year +is just defined by a margin from the month combobox to +the left border. While in wxUniv the year control can't +show all 4 digits, in wxMsw it show almost twice as +much. Instead the year should use it's best size and be +left aligned to the calendar. Just in case the month in +any language is longer than it has space in the +calendar it is shortend.This way the year always can +show the 4 digits. + +This patch relies on the fact that a combobox has a +good best size implementation. This is not the case +with wxMSW but I don't know why. + +Otto Wyss +*/ + +#ifdef __WXUNIVERSAL__ + if (sizeCombo.x + HORZ_MARGIN - sizeSpin.x > width) + { + m_comboMonth->SetSize(x, y, width - HORZ_MARGIN - sizeSpin.x, sizeCombo.y); + } + else + { + m_comboMonth->Move(x, y); + } + m_staticMonth->Move(x, y + dy); + m_spinYear->Move(x + width - sizeSpin.x, y); + m_staticYear->Move(x + width - sizeSpin.x, y + dy); +#else m_comboMonth->Move(x, y); m_staticMonth->SetSize(x, y + dy, sizeCombo.x, sizeStatic.y); @@ -765,8 +798,7 @@ void wxCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) m_spinYear->SetSize(x + xDiff, y, width - xDiff, sizeCombo.y); m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y); - - wxSize sizeSpin = m_spinYear->GetSize(); +#endif yDiff = wxMax(sizeSpin.y, sizeCombo.y) + VERT_MARGIN; } else // no controls on the top @@ -1569,7 +1601,7 @@ void wxCalendarCtrl::OnYearChange(wxCommandEvent& event) void wxCalendarCtrl::OnChar(wxKeyEvent& event) { wxDateTime target; - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case _T('+'): case WXK_ADD: