]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrl.cpp
avoid assert when creating the control with wxCAL_SEQUENTIAL_MONTH_SELECTION style...
[wxWidgets.git] / src / generic / calctrl.cpp
index 7648d8917e66406d708cfa6a3c0cc4218023520c..1b4e84226fbe88cc7d946f28964c98d16a26e02d 100644 (file)
@@ -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) )
@@ -255,6 +258,17 @@ wxCalendarCtrl::~wxCalendarCtrl()
     }
 }
 
+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);
+}
+
 // ----------------------------------------------------------------------------
 // Create the wxComboBox and wxSpinCtrl
 // ----------------------------------------------------------------------------
@@ -394,6 +408,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