]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/calctrl.cpp
floating pane size now restores after perspective restore
[wxWidgets.git] / src / generic / calctrl.cpp
index 7648d8917e66406d708cfa6a3c0cc4218023520c..2fb1c4172545e31bfa8cae08e4d8786afefeea66 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) )
@@ -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