]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxBookCtrlSizer; derive wxNotebookSizer from it
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 21 Aug 2003 23:09:35 +0000 (23:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 21 Aug 2003 23:09:35 +0000 (23:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/sizer.h
src/common/sizer.cpp

index 96024f1559e0b11edfa3592612c47441940f3967..76687aed61dde6c18db52cb517895589f787b792 100644 (file)
@@ -499,27 +499,47 @@ private:
 
 #endif // wxUSE_STATBOX
 
-//---------------------------------------------------------------------------
-// wxNotebookSizer
-//---------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// wxBookCtrlSizer
+// ----------------------------------------------------------------------------
 
-#if wxUSE_NOTEBOOK
+#if wxUSE_BOOKCTRL
 
-class WXDLLEXPORT wxNotebook;
+// this sizer works with wxNotebook/wxListbook/... and sizes the control to
+// fit its pages
+class WXDLLEXPORT wxBookCtrl;
 
-class WXDLLEXPORT wxNotebookSizer: public wxSizer
+class WXDLLEXPORT wxBookCtrlSizer : public wxSizer
 {
 public:
-    wxNotebookSizer( wxNotebook *nb );
+    wxBookCtrlSizer(wxBookCtrl *bookctrl);
 
-    void RecalcSizes();
-    wxSize CalcMin();
+    virtual void RecalcSizes();
+    virtual wxSize CalcMin();
 
-    wxNotebook *GetNotebook() const
-        { return m_notebook; }
+    wxBookCtrl *GetControl() const { return m_bookctrl; }
 
 protected:
-    wxNotebook   *m_notebook;
+    wxBookCtrl *m_bookctrl;
+
+private:
+    DECLARE_CLASS(wxBookCtrlSizer)
+    DECLARE_NO_COPY_CLASS(wxBookCtrlSizer)
+};
+
+
+#if wxUSE_NOTEBOOK
+
+// before wxBookCtrl we only had wxNotebookSizer, keep it for backwards
+// compatibility
+class WXDLLEXPORT wxNotebook;
+
+class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer
+{
+public:
+    wxNotebookSizer(wxNotebook *nb);
+
+    wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; }
 
 private:
     DECLARE_CLASS(wxNotebookSizer)
@@ -528,6 +548,7 @@ private:
 
 #endif // wxUSE_NOTEBOOK
 
+#endif // wxUSE_BOOKCTRL
+
+#endif // __WXSIZER_H__
 
-#endif
-  // __WXSIZER_H__
index 3643d5f54ee0a508c3ca2b134f963c590a452936..2950163aee77e5454abe200f479b687fdf39c147 100644 (file)
@@ -37,9 +37,12 @@ IMPLEMENT_CLASS(wxBoxSizer, wxSizer)
 #if wxUSE_STATBOX
 IMPLEMENT_CLASS(wxStaticBoxSizer, wxBoxSizer)
 #endif
+#if wxUSE_BOOKCTRL
+IMPLEMENT_CLASS(wxBookCtrlSizer, wxSizer)
 #if wxUSE_NOTEBOOK
-IMPLEMENT_CLASS(wxNotebookSizer, wxSizer)
-#endif
+IMPLEMENT_CLASS(wxNotebookSizer, wxBookCtrlSizer)
+#endif // wxUSE_NOTEBOOK
+#endif // wxUSE_BOOKCTRL
 
 WX_DEFINE_EXPORTED_LIST( wxSizerItemList );
 
@@ -1555,31 +1558,31 @@ wxSize wxStaticBoxSizer::CalcMin()
 
 #endif // wxUSE_STATBOX
 
-//---------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxNotebookSizer
-//---------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
-#if wxUSE_NOTEBOOK
+#if wxUSE_BOOKCTRL
 
-wxNotebookSizer::wxNotebookSizer( wxNotebook *nb )
-    : m_notebook( nb )
+wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrl *bookctrl)
+               : m_bookctrl(bookctrl)
 {
-    wxASSERT_MSG( nb, wxT("wxNotebookSizer needs a notebook") );
+    wxASSERT_MSG( bookctrl, wxT("wxBookCtrlSizer needs a control") );
 }
 
-void wxNotebookSizer::RecalcSizes()
+void wxBookCtrlSizer::RecalcSizes()
 {
-    m_notebook->SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
+    m_bookctrl->SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
 }
 
-wxSize wxNotebookSizer::CalcMin()
+wxSize wxBookCtrlSizer::CalcMin()
 {
-    wxSize sizeBorder = m_notebook->CalcSizeFromPage(wxSize(0, 0));
+    wxSize sizeBorder = m_bookctrl->CalcSizeFromPage(wxSize(0, 0));
 
     sizeBorder.x += 5;
     sizeBorder.y += 5;
 
-    if (m_notebook->GetChildren().GetCount() == 0)
+    if ( m_bookctrl->GetPageCount() == 0 )
     {
         return wxSize(sizeBorder.x + 10, sizeBorder.y + 10);
     }
@@ -1587,7 +1590,8 @@ wxSize wxNotebookSizer::CalcMin()
     int maxX = 0;
     int maxY = 0;
 
-    wxWindowList::compatibility_iterator node = m_notebook->GetChildren().GetFirst();
+    wxWindowList::compatibility_iterator
+        node = m_bookctrl->GetChildren().GetFirst();
     while (node)
     {
         wxWindow *item = node->GetData();
@@ -1609,6 +1613,5 @@ wxSize wxNotebookSizer::CalcMin()
     return wxSize( maxX, maxY ) + sizeBorder;
 }
 
-#endif // wxUSE_NOTEBOOK
+#endif // wxUSE_BOOKCTRL
 
-// vi:sts=4:sw=4:et