From: Vadim Zeitlin Date: Sun, 19 Nov 2006 15:15:44 +0000 (+0000) Subject: recreate the control when wxCAL_SEQUENTIAL_MONTH_SELECTION style is toggled X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2522d529176639f52467f6a1b1ad8415966ce4c0 recreate the control when wxCAL_SEQUENTIAL_MONTH_SELECTION style is toggled git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index cac040b249..b8952dfcfa 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -93,6 +93,7 @@ public: private: wxCalendarCtrl *m_calendar; wxStaticText *m_date; + wxSizer *m_sizer; DECLARE_EVENT_TABLE() }; @@ -516,7 +517,7 @@ MyPanel::MyPanel(wxFrame *frame) // adjust to vertical/horizontal display, check mostly dedicated to WinCE bool horizontal = ( wxSystemSettings::GetMetric(wxSYS_SCREEN_X) > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) ); - wxBoxSizer *m_sizer = new wxBoxSizer( horizontal ? wxHORIZONTAL : wxVERTICAL ); + m_sizer = new wxBoxSizer( horizontal ? wxHORIZONTAL : wxVERTICAL ); m_sizer->Add(m_date, 0, wxALIGN_CENTER | wxALL, 10 ); m_sizer->Add(m_calendar, 0, wxALIGN_CENTER | wxALIGN_LEFT); @@ -563,9 +564,26 @@ void MyPanel::ToggleCalStyle(bool on, int flag) else style &= ~flag; - m_calendar->SetWindowStyle(style); + if ( flag == wxCAL_SEQUENTIAL_MONTH_SELECTION ) + { + // changing this style requires recreating the control + wxCalendarCtrl *calendar = new wxCalendarCtrl(this, Calendar_CalCtrl, + m_calendar->GetDate(), + wxDefaultPosition, + wxDefaultSize, + style); + m_sizer->Replace(m_calendar, calendar); + delete m_calendar; + m_calendar = calendar; + + m_sizer->Layout(); + } + else // just changing the style is enough + { + m_calendar->SetWindowStyle(style); - m_calendar->Refresh(); + m_calendar->Refresh(); + } } void MyPanel::HighlightSpecial(bool on)