X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/170acdc90e9f92f8b8120fa6c04acdbf45c89582..9e1fc0e42822fdf1159582f1b73cde0c7d15bc92:/src/generic/calctrl.cpp diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index 7648d8917e..2fb1c41725 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -202,6 +202,9 @@ bool wxCalendarCtrl::Create(wxWindow *parent, long style, const wxString& name) { + // set the style first to avoid assert in our SetWindowStyleFlag() + m_windowStyle = style; + if ( !wxControl::Create(parent, id, pos, size, style | wxCLIP_CHILDREN | wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE, wxDefaultValidator, name) ) @@ -253,6 +256,25 @@ wxCalendarCtrl::~wxCalendarCtrl() { delete m_attrs[n]; } + + if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) + { + delete m_comboMonth; + delete m_staticMonth; + delete m_spinYear; + delete m_staticYear; + } +} + +void wxCalendarCtrl::SetWindowStyleFlag(long style) +{ + // changing this style doesn't work because the controls are not + // created/shown/hidden accordingly + wxASSERT_MSG( (style & wxCAL_SEQUENTIAL_MONTH_SELECTION) == + (m_windowStyle & wxCAL_SEQUENTIAL_MONTH_SELECTION), + _T("wxCAL_SEQUENTIAL_MONTH_SELECTION can't be changed after creation") ); + + wxControl::SetWindowStyleFlag(style); } // ---------------------------------------------------------------------------- @@ -394,6 +416,7 @@ void wxCalendarCtrl::ShowCurrentControls() m_spinYear->Hide(); m_staticYear->Show(); } + //else: these controls are not even created, don't show/hide them } wxControl *wxCalendarCtrl::GetMonthControl() const