]> git.saurik.com Git - wxWidgets.git/commitdiff
Unified flags for orienting wxBookCtrls (with backward compatibility). Centralised...
authorWłodzimierz Skiba <abx@abx.art.pl>
Fri, 21 Oct 2005 19:03:06 +0000 (19:03 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Fri, 21 Oct 2005 19:03:06 +0000 (19:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

14 files changed:
samples/notebook/notebook.cpp
samples/widgets/notebook.cpp
samples/widgets/widgets.cpp
src/common/bookctrl.cpp
src/common/nbkbase.cpp
src/generic/choicbkg.cpp
src/generic/listbkg.cpp
src/generic/propdlg.cpp
src/generic/treebkg.cpp
src/msw/notebook.cpp
src/xrc/xh_choicbk.cpp
src/xrc/xh_listbk.cpp
src/xrc/xh_notbk.cpp
src/xrc/xh_treebk.cpp

index 319c60e0553dec1acaf3f45bf6d317a95f5bc8ea..ca1adf709a63e3789f18fdef4d068f62659955b0 100644 (file)
@@ -307,34 +307,26 @@ MyFrame::~MyFrame()
 // part is control class-specific
 #if wxUSE_NOTEBOOK
     #define CASE_NOTEBOOK(x) case Type_Notebook: x; break;
-    #define FLAG_NOTEBOOK(x) wxNB_##x
 #else
     #define CASE_NOTEBOOK(x)
-    #define FLAG_NOTEBOOK(x) 0
 #endif
 
 #if wxUSE_LISTBOOK
     #define CASE_LISTBOOK(x) case Type_Listbook: x; break;
-    #define FLAG_LISTBOOK(x) wxLB_##x
 #else
     #define CASE_LISTBOOK(x)
-    #define FLAG_LISTBOOK(x) 0
 #endif
 
 #if wxUSE_CHOICEBOOK
     #define CASE_CHOICEBOOK(x) case Type_Choicebook: x; break;
-    #define FLAG_CHOICEBOOK(x) wxCHB_##x
 #else
     #define CASE_CHOICEBOOK(x)
-    #define FLAG_CHOICEBOOK(x) 0
 #endif
 
 #if wxUSE_TREEBOOK
     #define CASE_TREEBOOK(x) case Type_Treebook: x; break;
-    #define FLAG_TREEBOOK(x) wxTBK_##x
 #else
     #define CASE_TREEBOOK(x)
-    #define FLAG_TREEBOOK(x) 0
 #endif
 
 #define DISPATCH_ON_TYPE(before, nb, lb, cb, tb, after)                       \
@@ -360,34 +352,29 @@ int MyFrame::TranslateBookFlag(int nb, int lb, int chb, int tbk) const
 
 void MyFrame::RecreateBook()
 {
-#define SELECT_FLAG(f) \
-    TranslateBookFlag(FLAG_NOTEBOOK(f), FLAG_LISTBOOK(f), FLAG_CHOICEBOOK(f), FLAG_TREEBOOK(f))
-
     int flags;
     switch ( m_orient )
     {
         case ID_ORIENT_TOP:
-            flags = SELECT_FLAG(TOP);
+            flags = wxBK_TOP;
             break;
 
         case ID_ORIENT_BOTTOM:
-            flags = SELECT_FLAG(BOTTOM);
+            flags = wxBK_BOTTOM;
             break;
 
         case ID_ORIENT_LEFT:
-            flags = SELECT_FLAG(LEFT);
+            flags = wxBK_LEFT;
             break;
 
         case ID_ORIENT_RIGHT:
-            flags = SELECT_FLAG(RIGHT);
+            flags = wxBK_RIGHT;
             break;
 
         default:
-            flags = SELECT_FLAG(DEFAULT);
+            flags = wxBK_DEFAULT;
     }
 
-#undef SELECT_FLAG
-
     if ( m_multi && m_type == Type_Notebook )
         flags |= wxNB_MULTILINE;
     flags |= wxDOUBLE_BORDER;
@@ -823,4 +810,3 @@ void MyFrame::OnBookCtrl(wxBookCtrlBaseEvent& event)
     m_text->SetInsertionPointEnd();
 #endif
 }
-
index bbdc0cae8afccae640be56e05b00786d1223f136..44279c70d1fe1db8c8d7cf4bf05d0b43bcdbf953 100644 (file)
@@ -355,19 +355,19 @@ void NotebookWidgetsPage::CreateNotebook()
             // fall through
 
         case Orient_Top:
-            flags = wxNB_TOP;
+            flags = wxBK_TOP;
             break;
 
         case Orient_Bottom:
-            flags = wxNB_BOTTOM;
+            flags = wxBK_BOTTOM;
             break;
 
         case Orient_Left:
-            flags = wxNB_LEFT;
+            flags = wxBK_LEFT;
             break;
 
         case Orient_Right:
-            flags = wxNB_RIGHT;
+            flags = wxBK_RIGHT;
             break;
     }
 
@@ -506,7 +506,7 @@ void NotebookWidgetsPage::OnUpdateUIRemoveButton(wxUpdateUIEvent& event)
 void NotebookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
     event.Enable( !m_chkImages->GetValue() ||
-                  m_radioOrient->GetSelection() != wxNB_TOP );
+                  m_radioOrient->GetSelection() != wxBK_TOP );
 }
 
 void NotebookWidgetsPage::OnUpdateUINumPagesText(wxUpdateUIEvent& event)
index d656113dd7415095849539bb8372cf217c971e87..2b03a39c03e416147ed7d6866df7710f5181b6fe 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Program:     wxWidgets Widgets Sample
-// Name:        widgets.cpp
+// Name:        samples/widgets/widgets.cpp
 // Purpose:     Sample showing most of the simple wxWidgets widgets
 // Author:      Vadim Zeitlin
 // Created:     27.03.01
@@ -322,13 +322,13 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
     // we have 2 panes: book with pages demonstrating the controls in the
     // upper one and the log window with some buttons in the lower
 
-    int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxBC_DEFAULT;
+    int style = wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN|wxBK_DEFAULT;
     // Uncomment to suppress page theme (draw in solid colour)
     //style |= wxNB_NOPAGETHEME;
 
     m_book = new wxBookCtrl(m_panel, wxID_ANY, wxDefaultPosition,
 #ifdef __WXMOTIF__
-        wxSize(500, -1), // under Motif, height is a function of the width...
+        wxSize(500, wxDefaultCoord), // under Motif, height is a function of the width...
 #else
         wxDefaultSize,
 #endif
@@ -698,4 +698,3 @@ wxCheckBox *WidgetsPage::CreateCheckBoxAndAddToSizer(wxSizer *sizer,
 
     return checkbox;
 }
-
index 992b2a67132305d469df4921fe27ac58425e3cdd..2431b05ac5584f3a9506ac94b5bf6738013c0889 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        common/bookctrl.cpp
+// Name:        src/common/bookctrl.cpp
 // Purpose:     wxBookCtrlBase implementation
 // Author:      Vadim Zeitlin
 // Modified by:
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// event table
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxBookCtrlBase, wxControl)
+
+BEGIN_EVENT_TABLE(wxBookCtrlBase, wxControl)
+    EVT_SIZE(wxBookCtrlBase::OnSize)
+END_EVENT_TABLE()
+
 // ----------------------------------------------------------------------------
 // constructors and destructors
 // ----------------------------------------------------------------------------
 
 void wxBookCtrlBase::Init()
 {
+    m_bookctrl = NULL;
     m_imageList = NULL;
     m_ownsImageList = false;
 
@@ -151,7 +162,8 @@ wxBookCtrlBase::InsertPage(size_t nPage,
                            bool WXUNUSED(bSelect),
                            int WXUNUSED(imageId))
 {
-    wxCHECK_MSG( page || AllowNullPage(), false, _T("NULL page in wxBookCtrlBase::InsertPage()") );
+    wxCHECK_MSG( page || AllowNullPage(), false,
+                 _T("NULL page in wxBookCtrlBase::InsertPage()") );
     wxCHECK_MSG( nPage <= m_pages.size(), false,
                  _T("invalid page index in wxBookCtrlBase::InsertPage()") );
 
@@ -208,4 +220,112 @@ int wxBookCtrlBase::GetNextPage(bool forward) const
     return nPage;
 }
 
+wxRect wxBookCtrlBase::GetPageRect() const
+{
+    const wxSize size = GetControllerSize();
+
+    wxPoint pt;
+    wxRect rectPage(pt, GetClientSize());
+    switch ( GetWindowStyle() & wxBK_ALIGN_MASK )
+    {
+        default:
+            wxFAIL_MSG( _T("unexpected alignment") );
+            // fall through
+
+        case wxBK_TOP:
+            rectPage.y = size.y + GetInternalBorder();
+            // fall through
+
+        case wxBK_BOTTOM:
+            rectPage.height -= size.y + GetInternalBorder();
+            break;
+
+        case wxBK_LEFT:
+            rectPage.x = size.x + GetInternalBorder();
+            // fall through
+
+        case wxBK_RIGHT:
+            rectPage.width -= size.x + GetInternalBorder();
+            break;
+    }
+
+    return rectPage;
+}
+
+void wxBookCtrlBase::OnSize(wxSizeEvent& event)
+{
+    event.Skip();
+
+    if ( !m_bookctrl )
+    {
+        // we're not fully created yet or OnSize() should be hidden by derived class
+        return;
+    }
+
+    // resize controller and the page area to fit inside our new size
+    const wxSize sizeClient( GetClientSize() ),
+                 sizeBorder( m_bookctrl->GetSize() - m_bookctrl->GetClientSize() ),
+                 sizeCtrl( GetControllerSize() );
+
+    m_bookctrl->SetClientSize( sizeCtrl.x - sizeBorder.x, sizeCtrl.y - sizeBorder.y );
+
+    const wxSize sizeNew = m_bookctrl->GetSize();
+    wxPoint posCtrl;
+    switch ( GetWindowStyle() & wxBK_ALIGN_MASK )
+    {
+        default:
+            wxFAIL_MSG( _T("unexpected alignment") );
+            // fall through
+
+        case wxBK_TOP:
+        case wxBK_LEFT:
+            // posCtrl is already ok
+            break;
+
+        case wxBK_BOTTOM:
+            posCtrl.y = sizeClient.y - sizeNew.y;
+            break;
+
+        case wxBK_RIGHT:
+            posCtrl.x = sizeClient.x - sizeNew.x;
+            break;
+    }
+
+    if ( m_bookctrl->GetPosition() != posCtrl )
+        m_bookctrl->Move(posCtrl);
+
+    // resize the currently shown page
+    if (GetSelection() != wxNOT_FOUND )
+    {
+        wxWindow *page = m_pages[GetSelection()];
+        wxCHECK_RET( page, _T("NULL page?") );
+        page->SetSize(GetPageRect());
+    }
+}
+
+wxSize wxBookCtrlBase::GetControllerSize() const
+{
+    if(!m_bookctrl)
+        return wxSize(0,0);
+
+    const wxSize sizeClient = GetClientSize(),
+                 sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(),
+                 sizeCtrl = m_bookctrl->GetBestSize() + sizeBorder;
+
+    wxSize size;
+
+    if ( IsVertical() )
+    {
+        size.x = sizeClient.x;
+        size.y = sizeCtrl.y;
+    }
+    else // left/right aligned
+    {
+        size.x = sizeCtrl.x;
+        size.y = sizeClient.y;
+    }
+
+    return size;
+}
+
 #endif // wxUSE_BOOKCTRL
index 4e7e5f19cd67f6ad0e447e22c082e94906017428..47011be7039af1a7933ccc82d9875f54d31ba8b1 100644 (file)
@@ -45,7 +45,7 @@ wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage) const
     // default because not all ports implement this
     wxSize sizeTotal = sizePage;
 
-    if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
+    if ( HasFlag(wxBK_LEFT) || HasFlag(wxBK_RIGHT) )
     {
         sizeTotal.x += 90;
         sizeTotal.y += 10;
@@ -60,4 +60,3 @@ wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage) const
 }
 
 #endif // wxUSE_NOTEBOOK
-
index 26f6759282bb7e5882602d54a410a49e204ab2b1..ca3d019f5d1bf74e9ac735dbfd61e2ae75b97c61 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        generic/choicbkg.cpp
+// Name:        src/generic/choicbkg.cpp
 // Purpose:     generic implementation of wxChoicebook
 // Author:      Vadim Zeitlin
 // Modified by: Wlodzimierz ABX Skiba from generic/listbkg.cpp
@@ -42,7 +42,7 @@
 // event table
 // ----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxChoicebook, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxChoicebook, wxBookCtrlBase)
 IMPLEMENT_DYNAMIC_CLASS(wxChoicebookEvent, wxNotifyEvent)
 
 const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING = wxNewEventType();
@@ -50,7 +50,6 @@ const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED = wxNewEventType();
 const int wxID_CHOICEBOOKCHOICE = wxNewId();
 
 BEGIN_EVENT_TABLE(wxChoicebook, wxBookCtrlBase)
-    EVT_SIZE(wxChoicebook::OnSize)
     EVT_CHOICE(wxID_CHOICEBOOKCHOICE, wxChoicebook::OnChoiceSelected)
 END_EVENT_TABLE()
 
@@ -64,7 +63,6 @@ END_EVENT_TABLE()
 
 void wxChoicebook::Init()
 {
-    m_choice = NULL;
     m_selection = wxNOT_FOUND;
 }
 
@@ -76,9 +74,9 @@ wxChoicebook::Create(wxWindow *parent,
                      long style,
                      const wxString& name)
 {
-    if ( (style & wxCHB_ALIGN_MASK) == wxCHB_DEFAULT )
+    if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
     {
-        style |= wxCHB_TOP;
+        style |= wxBK_TOP;
     }
 
     // no border for this control, it doesn't look nice together with
@@ -90,7 +88,7 @@ wxChoicebook::Create(wxWindow *parent,
                             wxDefaultValidator, name) )
         return false;
 
-    m_choice = new wxChoice
+    m_bookctrl = new wxChoice
                  (
                     this,
                     wxID_CHOICEBOOKCHOICE,
@@ -105,10 +103,10 @@ wxChoicebook::Create(wxWindow *parent,
 // wxChoicebook geometry management
 // ----------------------------------------------------------------------------
 
-wxSize wxChoicebook::GetChoiceSize() const
+wxSize wxChoicebook::GetControllerSize() const
 {
     const wxSize sizeClient = GetClientSize(),
-                 sizeChoice = m_choice->GetBestFittingSize();
+                 sizeChoice = m_bookctrl->GetBestFittingSize();
 
     wxSize size;
     if ( IsVertical() )
@@ -125,89 +123,10 @@ wxSize wxChoicebook::GetChoiceSize() const
     return size;
 }
 
-wxRect wxChoicebook::GetPageRect() const
-{
-    const wxSize sizeChoice = m_choice->GetBestFittingSize();
-
-    wxPoint pt;
-    wxRect rectPage(pt, GetClientSize());
-    switch ( GetWindowStyle() & wxCHB_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxChoicebook alignment") );
-            // fall through
-
-        case wxCHB_TOP:
-            rectPage.y = sizeChoice.y + GetInternalBorder();
-            // fall through
-
-        case wxCHB_BOTTOM:
-            rectPage.height -= sizeChoice.y + GetInternalBorder();
-            break;
-
-        case wxCHB_LEFT:
-            rectPage.x = sizeChoice.x + GetInternalBorder();
-            // fall through
-
-        case wxCHB_RIGHT:
-            rectPage.width -= sizeChoice.x + GetInternalBorder();
-            break;
-    }
-
-    return rectPage;
-}
-
-void wxChoicebook::OnSize(wxSizeEvent& event)
-{
-    event.Skip();
-
-    if ( !m_choice )
-    {
-        // we're not fully created yet
-        return;
-    }
-
-    // resize the choice control and the page area to fit inside our new size
-    const wxSize sizeClient = GetClientSize(),
-                 sizeChoice = GetChoiceSize();
-
-    wxPoint posChoice;
-    switch ( GetWindowStyle() & wxCHB_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxChoicebook alignment") );
-            // fall through
-
-        case wxCHB_TOP:
-        case wxCHB_LEFT:
-            // posChoice is already ok
-            break;
-
-        case wxCHB_BOTTOM:
-            posChoice.y = sizeClient.y - sizeChoice.y;
-            break;
-
-        case wxCHB_RIGHT:
-            posChoice.x = sizeClient.x - sizeChoice.x;
-            break;
-    }
-
-    m_choice->Move(posChoice);
-    m_choice->SetSize(sizeChoice);
-
-    // resize the currently shown page
-    if ( m_selection != wxNOT_FOUND )
-    {
-        wxWindow *page = m_pages[m_selection];
-        wxCHECK_RET( page, _T("NULL page in wxChoicebook?") );
-        page->SetSize(GetPageRect());
-    }
-}
-
 wxSize wxChoicebook::CalcSizeFromPage(const wxSize& sizePage) const
 {
     // we need to add the size of the choice control and the border between
-    const wxSize sizeChoice = GetChoiceSize();
+    const wxSize sizeChoice = GetControllerSize();
 
     wxSize size = sizePage;
     if ( IsVertical() )
@@ -229,14 +148,14 @@ wxSize wxChoicebook::CalcSizeFromPage(const wxSize& sizePage) const
 
 bool wxChoicebook::SetPageText(size_t n, const wxString& strText)
 {
-    m_choice->SetString(n, strText);
+    GetChoiceCtrl()->SetString(n, strText);
 
     return true;
 }
 
 wxString wxChoicebook::GetPageText(size_t n) const
 {
-    return m_choice->GetString(n);
+    return GetChoiceCtrl()->GetString(n);
 }
 
 int wxChoicebook::GetPageImage(size_t WXUNUSED(n)) const
@@ -297,7 +216,7 @@ int wxChoicebook::SetSelection(size_t n)
 
             // change m_selection now to ignore the selection change event
             m_selection = n;
-            m_choice->Select(n);
+            GetChoiceCtrl()->Select(n);
 
             // program allows the page change
             event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED);
@@ -322,7 +241,7 @@ wxChoicebook::InsertPage(size_t n,
     if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) )
         return false;
 
-    m_choice->Insert(text, n);
+    GetChoiceCtrl()->Insert(text, n);
 
     // if the inserted page is before the selected one, we must update the
     // index of the selected page
@@ -330,7 +249,7 @@ wxChoicebook::InsertPage(size_t n,
     {
         // one extra page added
         m_selection++;
-        m_choice->Select(m_selection);
+        GetChoiceCtrl()->Select(m_selection);
     }
 
     // some page should be selected: either this one or the first one if there
@@ -358,7 +277,7 @@ wxWindow *wxChoicebook::DoRemovePage(size_t page)
 
     if ( win )
     {
-        m_choice->Delete(page);
+        GetChoiceCtrl()->Delete(page);
 
         if (m_selection >= (int)page)
         {
@@ -383,7 +302,7 @@ wxWindow *wxChoicebook::DoRemovePage(size_t page)
 
 bool wxChoicebook::DeleteAllPages()
 {
-    m_choice->Clear();
+    GetChoiceCtrl()->Clear();
     return wxBookCtrlBase::DeleteAllPages();
 }
 
@@ -407,7 +326,7 @@ void wxChoicebook::OnChoiceSelected(wxCommandEvent& eventChoice)
 
     // change wasn't allowed, return to previous state
     if (m_selection != selNew)
-        m_choice->Select(m_selection);
+        GetChoiceCtrl()->Select(m_selection);
 }
 
 #endif // wxUSE_CHOICEBOOK
index 508474d08c19d5d8e5667ee087ad43ba2df6b449..1985558dfab29b3b799830fbfc1d3bff3f63e688 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        generic/listbkg.cpp
+// Name:        src/generic/listbkg.cpp
 // Purpose:     generic implementation of wxListbook
 // Author:      Vadim Zeitlin
 // Modified by:
@@ -43,7 +43,7 @@
 // event table
 // ----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxListbook, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListbook, wxBookCtrlBase)
 IMPLEMENT_DYNAMIC_CLASS(wxListbookEvent, wxNotifyEvent)
 
 const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wxNewEventType();
@@ -65,10 +65,6 @@ END_EVENT_TABLE()
 
 void wxListbook::Init()
 {
-    m_list = NULL;
-#if wxUSE_LINE_IN_LISTBOOK
-    m_line = NULL;
-#endif // wxUSE_LINE_IN_LISTBOOK
     m_selection = wxNOT_FOUND;
 }
 
@@ -80,12 +76,12 @@ wxListbook::Create(wxWindow *parent,
                    long style,
                    const wxString& name)
 {
-    if ( (style & wxLB_ALIGN_MASK) == wxLB_DEFAULT )
+    if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
     {
 #ifdef __WXMAC__
-        style |= wxLB_TOP;
+        style |= wxBK_TOP;
 #else // !__WXMAC__
-        style |= wxLB_LEFT;
+        style |= wxBK_LEFT;
 #endif // __WXMAC__/!__WXMAC__
     }
 
@@ -98,7 +94,7 @@ wxListbook::Create(wxWindow *parent,
                             wxDefaultValidator, name) )
         return false;
 
-    m_list = new wxListView
+    m_bookctrl = new wxListView
                  (
                     this,
                     wxID_LISTBOOKLISTVIEW,
@@ -108,19 +104,8 @@ wxListbook::Create(wxWindow *parent,
                         (IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP)
                  );
 
-#if wxUSE_LINE_IN_LISTBOOK
-    m_line = new wxStaticLine
-                 (
-                    this,
-                    wxID_ANY,
-                    wxDefaultPosition,
-                    wxDefaultSize,
-                    IsVertical() ? wxLI_HORIZONTAL : wxLI_VERTICAL
-                 );
-#endif // wxUSE_LINE_IN_LISTBOOK
-
 #ifdef __WXMSW__
-    // On XP with themes enabled the GetViewRect used in GetListSize to
+    // On XP with themes enabled the GetViewRect used in GetControllerSize() to
     // determine the space needed for the list view will incorrectly return
     // (0,0,0,0) the first time.  So send a pending event so OnSize will be
     // called again after the window is ready to go.  Technically we don't
@@ -136,13 +121,14 @@ wxListbook::Create(wxWindow *parent,
 // wxListbook geometry management
 // ----------------------------------------------------------------------------
 
-wxSize wxListbook::GetListSize() const
+wxSize wxListbook::GetControllerSize() const
 {
     const wxSize sizeClient = GetClientSize(),
-                 sizeBorder = m_list->GetSize() - m_list->GetClientSize(),
-                 sizeList = m_list->GetViewRect().GetSize() + sizeBorder;
+                 sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(),
+                 sizeList = GetListView()->GetViewRect().GetSize() + sizeBorder;
 
     wxSize size;
+
     if ( IsVertical() )
     {
         size.x = sizeClient.x;
@@ -157,132 +143,22 @@ wxSize wxListbook::GetListSize() const
     return size;
 }
 
-wxRect wxListbook::GetPageRect() const
-{
-    const wxSize sizeList = m_list->GetSize();
-
-    wxPoint pt;
-    wxRect rectPage(pt, GetClientSize());
-    switch ( GetWindowStyle() & wxLB_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxListbook alignment") );
-            // fall through
-
-        case wxLB_TOP:
-            rectPage.y = sizeList.y + GetInternalBorder();
-            // fall through
-
-        case wxLB_BOTTOM:
-            rectPage.height -= sizeList.y + GetInternalBorder();
-            break;
-
-        case wxLB_LEFT:
-            rectPage.x = sizeList.x + GetInternalBorder();
-            // fall through
-
-        case wxLB_RIGHT:
-            rectPage.width -= sizeList.x + GetInternalBorder();
-            break;
-    }
-
-    return rectPage;
-}
-
 void wxListbook::OnSize(wxSizeEvent& event)
 {
-    event.Skip();
-
-    if ( !m_list )
-    {
-        // we're not fully created yet
-        return;
-    }
-
     // arrange the icons before calling SetClientSize(), otherwise it wouldn't
     // account for the scrollbars the list control might need and, at least
     // under MSW, we'd finish with an ugly looking list control with both
     // vertical and horizontal scrollbar (with one of them being added because
     // the other one is not accounted for in client size computations)
-    m_list->Arrange();
-
-    // resize the list control and the page area to fit inside our new size
-    const wxSize sizeClient = GetClientSize(),
-                 sizeBorder = m_list->GetSize() - m_list->GetClientSize(),
-                 sizeList = GetListSize();
-
-    m_list->SetClientSize( sizeList.x - sizeBorder.x, sizeList.y - sizeBorder.y );
-
-    const wxSize sizeNew = m_list->GetSize();
-    wxPoint posList;
-    switch ( GetWindowStyle() & wxLB_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxListbook alignment") );
-            // fall through
-
-        case wxLB_TOP:
-        case wxLB_LEFT:
-            // posList is already ok
-            break;
-
-        case wxLB_BOTTOM:
-            posList.y = sizeClient.y - sizeNew.y;
-            break;
-
-        case wxLB_RIGHT:
-            posList.x = sizeClient.x - sizeNew.x;
-            break;
-    }
-
-    if ( m_list->GetPosition() != posList )
-        m_list->Move(posList);
-
-#if wxUSE_LINE_IN_LISTBOOK
-    if ( m_line )
-    {
-        wxRect rectLine(sizeClient);
-
-        switch ( GetWindowStyle() & wxLB_ALIGN_MASK )
-        {
-            case wxLB_TOP:
-                rectLine.y = sizeNew.y + 1;
-                rectLine.height = GetInternalBorder() - 2;
-                break;
-
-            case wxLB_BOTTOM:
-                rectLine.height = GetInternalBorder() - 2;
-                rectLine.y = sizeClient.y - sizeNew.y - rectLine.height;
-                break;
-
-            case wxLB_LEFT:
-                rectLine.x = sizeNew.x + 1;
-                rectLine.width = GetInternalBorder() - 2;
-                break;
-
-            case wxLB_RIGHT:
-                rectLine.width = GetInternalBorder() - 2;
-                rectLine.x = sizeClient.x - sizeNew.x - rectLine.width;
-                break;
-        }
-
-        m_line->SetSize(rectLine);
-    }
-#endif // wxUSE_LINE_IN_LISTBOOK
-
-    // resize the currently shown page
-    if (m_selection != wxNOT_FOUND )
-    {
-        wxWindow *page = m_pages[m_selection];
-        wxCHECK_RET( page, _T("NULL page in wxListbook?") );
-        page->SetSize(GetPageRect());
-    }
+    wxListView *list = GetListView();
+    if (list) list->Arrange();
+    wxBookCtrlBase::OnSize(event);
 }
 
 wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
 {
     // we need to add the size of the list control and the border between
-    const wxSize sizeList = GetListSize();
+    const wxSize sizeList = GetControllerSize();
 
     wxSize size = sizePage;
     if ( IsVertical() )
@@ -304,14 +180,14 @@ wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
 
 bool wxListbook::SetPageText(size_t n, const wxString& strText)
 {
-    m_list->SetItemText(n, strText);
+    GetListView()->SetItemText(n, strText);
 
     return true;
 }
 
 wxString wxListbook::GetPageText(size_t n) const
 {
-    return m_list->GetItemText(n);
+    return GetListView()->GetItemText(n);
 }
 
 int wxListbook::GetPageImage(size_t WXUNUSED(n)) const
@@ -323,7 +199,7 @@ int wxListbook::GetPageImage(size_t WXUNUSED(n)) const
 
 bool wxListbook::SetPageImage(size_t n, int imageId)
 {
-    return m_list->SetItemImage(n, imageId);
+    return GetListView()->SetItemImage(n, imageId);
 }
 
 // ----------------------------------------------------------------------------
@@ -332,7 +208,7 @@ bool wxListbook::SetPageImage(size_t n, int imageId)
 
 void wxListbook::SetImageList(wxImageList *imageList)
 {
-    m_list->SetImageList(imageList, wxIMAGE_LIST_NORMAL);
+    GetListView()->SetImageList(imageList, wxIMAGE_LIST_NORMAL);
 
     wxBookCtrlBase::SetImageList(imageList);
 }
@@ -370,8 +246,8 @@ int wxListbook::SetSelection(size_t n)
 
             // change m_selection now to ignore the selection change event
             m_selection = n;
-            m_list->Select(n);
-            m_list->Focus(n);
+            GetListView()->Select(n);
+            GetListView()->Focus(n);
 
             // program allows the page change
             event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED);
@@ -396,7 +272,7 @@ wxListbook::InsertPage(size_t n,
     if ( !wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId) )
         return false;
 
-    m_list->InsertItem(n, text, imageId);
+    GetListView()->InsertItem(n, text, imageId);
 
     // if the inserted page is before the selected one, we must update the
     // index of the selected page
@@ -404,8 +280,8 @@ wxListbook::InsertPage(size_t n,
     {
         // one extra page added
         m_selection++;
-        m_list->Select(m_selection);
-        m_list->Focus(m_selection);
+        GetListView()->Select(m_selection);
+        GetListView()->Focus(m_selection);
     }
 
     // some page should be selected: either this one or the first one if there
@@ -423,7 +299,7 @@ wxListbook::InsertPage(size_t n,
         SetSelection(selNew);
 
     InvalidateBestSize();
-    m_list->Arrange();
+    GetListView()->Arrange();
     return true;
 }
 
@@ -434,7 +310,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
 
     if ( win )
     {
-        m_list->DeleteItem(page);
+        GetListView()->DeleteItem(page);
 
         if (m_selection >= (int)page)
         {
@@ -452,7 +328,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
                 SetSelection(sel);
         }
 
-        m_list->Arrange();
+        GetListView()->Arrange();
     }
 
     return win;
@@ -461,7 +337,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
 
 bool wxListbook::DeleteAllPages()
 {
-    m_list->DeleteAllItems();
+    GetListView()->DeleteAllItems();
     return wxBookCtrlBase::DeleteAllPages();
 }
 
@@ -486,8 +362,8 @@ void wxListbook::OnListSelected(wxListEvent& eventList)
     // change wasn't allowed, return to previous state
     if (m_selection != selNew)
     {
-        m_list->Select(m_selection);
-        m_list->Focus(m_selection);
+        GetListView()->Select(m_selection);
+        GetListView()->Focus(m_selection);
     }
 }
 
index 7fd8f4f371a09d07f5494249cc07de3625d5f548..352c00b54b77938497b159846a2a0febded1d2bc 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        propdlg.cpp
+// Name:        src/generic/propdlg.cpp
 // Purpose:     wxPropertySheetDialog
 // Author:      Julian Smart
 // Modified by:
@@ -110,9 +110,9 @@ wxBookCtrlBase* wxPropertySheetDialog::CreateBookCtrl()
 {
     int style = wxCLIP_CHILDREN;
 #if defined(__POCKETPC__) && wxUSE_NOTEBOOK
-    style |= wxNB_BOTTOM|wxNB_FLAT;
+    style |= wxBK_BOTTOM|wxNB_FLAT;
 #else
-    style |= wxBC_DEFAULT;
+    style |= wxBK_DEFAULT;
 #endif
     return new wxBookCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style );
 }
index 3fa1842cfdd8b161ffe35dff425ea7892843b98c..47fefdc7d06b7cdc616880bc42334f5da1feffc0 100644 (file)
@@ -41,7 +41,7 @@
 // event table
 // ----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxTreebook, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxTreebook, wxBookCtrlBase)
 IMPLEMENT_DYNAMIC_CLASS(wxTreebookEvent, wxNotifyEvent)
 
 const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING = wxNewEventType();
@@ -51,7 +51,6 @@ const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED = wxNewEventType();
 const int wxID_TREEBOOKTREEVIEW = wxNewId();
 
 BEGIN_EVENT_TABLE(wxTreebook, wxBookCtrlBase)
-    EVT_SIZE(wxTreebook::OnSize)
     EVT_TREE_SEL_CHANGED   (wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeSelectionChange)
     EVT_TREE_ITEM_EXPANDED (wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeNodeExpandedCollapsed)
     EVT_TREE_ITEM_COLLAPSED(wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeNodeExpandedCollapsed)
@@ -67,7 +66,6 @@ END_EVENT_TABLE()
 
 void wxTreebook::Init()
 {
-    m_tree = NULL;
     m_selection =
     m_actualSelection = wxNOT_FOUND;
 }
@@ -81,14 +79,9 @@ wxTreebook::Create(wxWindow *parent,
                    const wxString& name)
 {
     // Check the style flag to have either wxTBK_RIGHT or wxTBK_LEFT
-    if ( style & wxTBK_RIGHT )
+    if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
     {
-        wxASSERT_MSG( !(style & wxTBK_LEFT),
-                            _T("RIGHT and LEFT can't be used together") );
-    }
-    else
-    {
-        style |= wxTBK_LEFT;
+        style |= wxBK_LEFT;
     }
 
     // no border for this control, it doesn't look nice together with the tree
@@ -99,7 +92,7 @@ wxTreebook::Create(wxWindow *parent,
                             style, wxDefaultValidator, name) )
         return false;
 
-    m_tree = new wxTreeCtrl
+    m_bookctrl = new wxTreeCtrl
                  (
                     this,
                     wxID_TREEBOOKTREEVIEW,
@@ -110,16 +103,10 @@ wxTreebook::Create(wxWindow *parent,
                     wxTR_HIDE_ROOT |
                     wxTR_SINGLE
                  );
-    m_tree->AddRoot(wxEmptyString); // label doesn't matter, it's hidden
+    GetTreeCtrl()->AddRoot(wxEmptyString); // label doesn't matter, it's hidden
 
 #ifdef __WXMSW__
-    // see listbook.h for origins of that
-    // On XP with themes enabled the GetViewRect used in GetListSize to
-    // determine the space needed for the list view will incorrectly return
-    // (0,0,0,0) the first time.  So send a pending event so OnSize will be
-    // called again after the window is ready to go.  Technically we don't
-    // need to do this on non-XP windows, but if things are already sized
-    // correctly then nothing changes and so there is no harm.
+    // We need to add dummy size event to force possible scrollbar hiding
     wxSizeEvent evt;
     GetEventHandler()->AddPendingEvent(evt);
 #endif
@@ -172,31 +159,32 @@ bool wxTreebook::DoInsertPage(size_t pagePos,
     if ( !wxBookCtrlBase::InsertPage(pagePos, page, text, bSelect, imageId) )
         return false;
 
+    wxTreeCtrl *tree = GetTreeCtrl();
     wxTreeItemId newId;
     if ( pagePos == DoInternalGetPageCount() )
     {
         // append the page to the end
-        wxTreeItemId rootId = m_tree->GetRootItem();
+        wxTreeItemId rootId = tree->GetRootItem();
 
-        newId = m_tree->AppendItem(rootId, text, imageId);
+        newId = tree->AppendItem(rootId, text, imageId);
     }
     else // insert the new page before the given one
     {
         wxTreeItemId nodeId = m_treeIds[pagePos];
 
-        wxTreeItemId previousId = m_tree->GetPrevSibling(nodeId);
-        wxTreeItemId parentId = m_tree->GetItemParent(nodeId);
+        wxTreeItemId previousId = tree->GetPrevSibling(nodeId);
+        wxTreeItemId parentId = tree->GetItemParent(nodeId);
 
         if ( previousId.IsOk() )
         {
             // insert before the sibling - previousId
-            newId = m_tree->InsertItem(parentId, previousId, text, imageId);
+            newId = tree->InsertItem(parentId, previousId, text, imageId);
         }
         else // no prev siblings -- insert as a first child
         {
             wxASSERT_MSG( parentId.IsOk(), wxT( "Tree has no root node?" ) );
 
-            newId = m_tree->PrependItem(parentId, text, imageId);
+            newId = tree->PrependItem(parentId, text, imageId);
         }
     }
 
@@ -213,23 +201,25 @@ bool wxTreebook::DoInsertPage(size_t pagePos,
 
     DoUpdateSelection(bSelect, pagePos);
 
-    m_tree->InvalidateBestSize();
+    m_bookctrl->InvalidateBestSize();
 
     return true;
 }
 
 bool wxTreebook::DoAddSubPage(wxWindow *page, const wxString& text, bool bSelect, int imageId)
 {
-    wxTreeItemId rootId = m_tree->GetRootItem();
+    wxTreeCtrl *tree = GetTreeCtrl();
 
-    wxTreeItemId lastNodeId = m_tree->GetLastChild(rootId);
+    wxTreeItemId rootId = tree->GetRootItem();
+
+    wxTreeItemId lastNodeId = tree->GetLastChild(rootId);
 
     wxCHECK_MSG( lastNodeId.IsOk(), false,
                         _T("Can't insert sub page when there are no pages") );
 
     // now calculate its position (should we save/update it too?)
-    size_t newPos = m_tree->GetCount() -
-                        (m_tree->GetChildrenCount(lastNodeId, true) + 1);
+    size_t newPos = tree->GetCount() -
+                        (tree->GetChildrenCount(lastNodeId, true) + 1);
 
     return DoInsertSubPage(newPos, page, text, bSelect, imageId);
 }
@@ -243,14 +233,16 @@ bool wxTreebook::DoInsertSubPage(size_t pagePos,
     wxTreeItemId parentId = DoInternalGetPage(pagePos);
     wxCHECK_MSG( parentId.IsOk(), false, wxT("invalid tree item") );
 
-    size_t newPos = pagePos + m_tree->GetChildrenCount(parentId, true) + 1;
+    wxTreeCtrl *tree = GetTreeCtrl();
+
+    size_t newPos = pagePos + tree->GetChildrenCount(parentId, true) + 1;
     wxASSERT_MSG( newPos <= DoInternalGetPageCount(),
                     wxT("Internal error in tree insert point calculation") );
 
     if ( !wxBookCtrlBase::InsertPage(newPos, page, text, bSelect, imageId) )
         return false;
 
-    wxTreeItemId newId = m_tree->AppendItem(parentId, text, imageId);
+    wxTreeItemId newId = tree->AppendItem(parentId, text, imageId);
 
     if ( !newId.IsOk() )
     {
@@ -264,7 +256,7 @@ bool wxTreebook::DoInsertSubPage(size_t pagePos,
 
     DoUpdateSelection(bSelect, newPos);
 
-    m_tree->InvalidateBestSize();
+    m_bookctrl->InvalidateBestSize();
 
     return true;
 }
@@ -288,8 +280,9 @@ wxTreebookPage *wxTreebook::DoRemovePage(size_t pagePos)
     wxCHECK_MSG( pageId.IsOk(), NULL, wxT("Invalid tree index") );
 
     wxTreebookPage * oldPage = GetPage(pagePos);
+    wxTreeCtrl *tree = GetTreeCtrl();
 
-    size_t subCount = m_tree->GetChildrenCount(pageId, true);
+    size_t subCount = tree->GetChildrenCount(pageId, true);
     wxASSERT_MSG ( IS_VALID_PAGE(pagePos + subCount),
                         wxT("Internal error in wxTreebook::DoRemovePage") );
 
@@ -311,9 +304,9 @@ wxTreebookPage *wxTreebook::DoRemovePage(size_t pagePos)
 
     DoInternalRemovePageRange(pagePos, subCount);
 
-    m_tree->DeleteChildren( pageId );
-    m_tree->Delete( pageId );
-    m_tree->InvalidateBestSize();
+    tree->DeleteChildren( pageId );
+    tree->Delete( pageId );
+    tree->InvalidateBestSize();
 
     return oldPage;
 }
@@ -325,7 +318,8 @@ bool wxTreebook::DeleteAllPages()
     m_selection =
     m_actualSelection = wxNOT_FOUND;
 
-    m_tree->DeleteChildren(m_tree->GetRootItem());
+    wxTreeCtrl *tree = GetTreeCtrl();
+    tree->DeleteChildren(tree->GetRootItem());
 
     return true;
 }
@@ -389,9 +383,11 @@ void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount)
         }
         else if ( (size_t)m_selection >= pagePos )
         {
+            wxTreeCtrl *tree = GetTreeCtrl();
+
             // as selected page is going to be deleted, try to select the next
             // sibling if exists, if not then the parent
-            wxTreeItemId nodeId = m_tree->GetNextSibling(pageId);
+            wxTreeItemId nodeId = tree->GetNextSibling(pageId);
 
             m_selection = wxNOT_FOUND;
             m_actualSelection = wxNOT_FOUND;
@@ -399,15 +395,15 @@ void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount)
             if ( nodeId.IsOk() )
             {
                 // selecting next siblings
-                m_tree->SelectItem(nodeId);
+                tree->SelectItem(nodeId);
             }
             else // no next sibling, select the parent
             {
-                wxTreeItemId parentId = m_tree->GetItemParent(pageId);
+                wxTreeItemId parentId = tree->GetItemParent(pageId);
 
-                if ( parentId.IsOk() && parentId != m_tree->GetRootItem() )
+                if ( parentId.IsOk() && parentId != tree->GetRootItem() )
                 {
-                    m_tree->SelectItem(parentId);
+                    tree->SelectItem(parentId);
                 }
                 else // parent is root
                 {
@@ -486,7 +482,7 @@ bool wxTreebook::IsNodeExpanded(size_t pagePos) const
 
     wxCHECK_MSG( pageId.IsOk(), false, wxT("invalid tree item") );
 
-    return m_tree->IsExpanded(pageId);
+    return GetTreeCtrl()->IsExpanded(pageId);
 }
 
 bool wxTreebook::ExpandNode(size_t pagePos, bool expand)
@@ -497,11 +493,11 @@ bool wxTreebook::ExpandNode(size_t pagePos, bool expand)
 
     if ( expand )
     {
-        m_tree->Expand( pageId );
+        GetTreeCtrl()->Expand( pageId );
     }
     else // collapse
     {
-        m_tree->Collapse( pageId );
+        GetTreeCtrl()->Collapse( pageId );
 
         // rely on the events generated by wxTreeCtrl to update selection
     }
@@ -514,7 +510,7 @@ int wxTreebook::GetPageParent(size_t pagePos) const
     wxTreeItemId nodeId = DoInternalGetPage( pagePos );
     wxCHECK_MSG( nodeId.IsOk(), wxNOT_FOUND, wxT("Invalid page index spacified!") );
 
-    const wxTreeItemId parent = m_tree->GetItemParent( nodeId );
+    const wxTreeItemId parent = GetTreeCtrl()->GetItemParent( nodeId );
 
     return parent.IsOk() ? DoInternalFindPageById(parent) : wxNOT_FOUND;
 }
@@ -525,7 +521,7 @@ bool wxTreebook::SetPageText(size_t n, const wxString& strText)
 
     wxCHECK_MSG( pageId.IsOk(), false, wxT("invalid tree item") );
 
-    m_tree->SetItemText(pageId, strText);
+    GetTreeCtrl()->SetItemText(pageId, strText);
 
     return true;
 }
@@ -536,7 +532,7 @@ wxString wxTreebook::GetPageText(size_t n) const
 
     wxCHECK_MSG( pageId.IsOk(), wxString(), wxT("invalid tree item") );
 
-    return m_tree->GetItemText(pageId);
+    return GetTreeCtrl()->GetItemText(pageId);
 }
 
 int wxTreebook::GetPageImage(size_t n) const
@@ -545,7 +541,7 @@ int wxTreebook::GetPageImage(size_t n) const
 
     wxCHECK_MSG( pageId.IsOk(), wxNOT_FOUND, wxT("invalid tree item") );
 
-    return m_tree->GetItemImage(pageId);
+    return GetTreeCtrl()->GetItemImage(pageId);
 }
 
 bool wxTreebook::SetPageImage(size_t n, int imageId)
@@ -554,14 +550,14 @@ bool wxTreebook::SetPageImage(size_t n, int imageId)
 
     wxCHECK_MSG( pageId.IsOk(), false, wxT("invalid tree item") );
 
-    m_tree->SetItemImage(pageId, imageId);
+    GetTreeCtrl()->SetItemImage(pageId, imageId);
 
     return true;
 }
 
 wxSize wxTreebook::CalcSizeFromPage(const wxSize& sizePage) const
 {
-    const wxSize sizeTree = GetTreeSize();
+    const wxSize sizeTree = GetControllerSize();
 
     wxSize size = sizePage;
     size.x += sizeTree.x;
@@ -590,6 +586,7 @@ int wxTreebook::DoSetSelection(size_t pagePos)
                   wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!"));
 
     const int oldSel = m_selection;
+    wxTreeCtrl *tree = GetTreeCtrl();
 
     wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId);
     event.SetEventObject(this);
@@ -619,7 +616,7 @@ int wxTreebook::DoSetSelection(size_t pagePos)
             while ( !page && childId.IsOk() )
             {
                 wxTreeItemIdValue cookie;
-                childId = m_tree->GetFirstChild( childId, cookie );
+                childId = tree->GetFirstChild( childId, cookie );
                 if ( childId.IsOk() )
                 {
                     page = wxBookCtrlBase::GetPage(++m_actualSelection);
@@ -635,7 +632,7 @@ int wxTreebook::DoSetSelection(size_t pagePos)
             page->Show();
         }
 
-        m_tree->SelectItem(DoInternalGetPage(pagePos));
+        tree->SelectItem(DoInternalGetPage(pagePos));
 
         // notify about the (now completed) page change
         event.SetEventType(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED);
@@ -644,7 +641,7 @@ int wxTreebook::DoSetSelection(size_t pagePos)
     else // page change vetoed
     {
         // tree selection might have already had changed
-        m_tree->SelectItem(DoInternalGetPage(oldSel));
+        tree->SelectItem(DoInternalGetPage(oldSel));
     }
 
     return oldSel;
@@ -653,13 +650,13 @@ int wxTreebook::DoSetSelection(size_t pagePos)
 void wxTreebook::SetImageList(wxImageList *imageList)
 {
     wxBookCtrlBase::SetImageList(imageList);
-    m_tree->SetImageList(imageList);
+    GetTreeCtrl()->SetImageList(imageList);
 }
 
 void wxTreebook::AssignImageList(wxImageList *imageList)
 {
     wxBookCtrlBase::AssignImageList(imageList);
-    m_tree->SetImageList(imageList);
+    GetTreeCtrl()->SetImageList(imageList);
 }
 
 // ----------------------------------------------------------------------------
@@ -671,7 +668,7 @@ void wxTreebook::OnTreeSelectionChange(wxTreeEvent& event)
     wxTreeItemId newId = event.GetItem();
 
     if ( (m_selection == wxNOT_FOUND &&
-                (!newId.IsOk() || newId == m_tree->GetRootItem())) ||
+                (!newId.IsOk() || newId == GetTreeCtrl()->GetRootItem())) ||
             (m_selection != wxNOT_FOUND && newId == m_treeIds[m_selection]) )
     {
         // this event can only come when we modify the tree selection ourselves
@@ -688,12 +685,12 @@ void wxTreebook::OnTreeSelectionChange(wxTreeEvent& event)
 void wxTreebook::OnTreeNodeExpandedCollapsed(wxTreeEvent & event)
 {
     wxTreeItemId nodeId = event.GetItem();
-    if ( !nodeId.IsOk() || nodeId == m_tree->GetRootItem() )
+    if ( !nodeId.IsOk() || nodeId == GetTreeCtrl()->GetRootItem() )
         return;
     int pagePos = DoInternalFindPageById(nodeId);
     wxCHECK_RET( pagePos != wxNOT_FOUND, wxT("Internal problem in wxTreebook!..") );
 
-    wxTreebookEvent ev(m_tree->IsExpanded(nodeId)
+    wxTreebookEvent ev(GetTreeCtrl()->IsExpanded(nodeId)
             ? wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED
             : wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED,
         m_windowId);
@@ -709,90 +706,6 @@ void wxTreebook::OnTreeNodeExpandedCollapsed(wxTreeEvent & event)
 // wxTreebook geometry management
 // ----------------------------------------------------------------------------
 
-wxSize wxTreebook::GetTreeSize() const
-{
-    const wxSize sizeClient = GetClientSize(),
-                 sizeBorder = m_tree->GetSize() - m_tree->GetClientSize(),
-                 sizeTree = m_tree->GetBestSize() + sizeBorder;
-
-    wxSize size;
-
-    size.x = sizeTree.x;
-    size.y = sizeClient.y;
-
-    return size;
-}
-
-wxRect wxTreebook::GetPageRect() const
-{
-    const wxSize sizeTree = m_tree->GetSize();
-
-    wxPoint pt;
-    wxRect rectPage(pt, GetClientSize());
-    switch ( GetWindowStyle() & wxTBK_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxTreebook alignment") );
-            // fall through
-
-        case wxTBK_LEFT:
-            rectPage.x = sizeTree.x; // + MARGIN;
-            // fall through
-
-        case wxTBK_RIGHT:
-            rectPage.width -= sizeTree.x; // + MARGIN;
-            break;
-    }
-
-    return rectPage;
-}
-
-void wxTreebook::OnSize(wxSizeEvent& event)
-{
-    event.Skip();
-
-    if ( !m_tree )
-    {
-        // we're not fully created yet
-        return;
-    }
-
-    // resize the list control and the page area to fit inside our new size
-    const wxSize sizeClient = GetClientSize(),
-                 sizeBorder = m_tree->GetSize() - m_tree->GetClientSize(),
-                 sizeTree = GetTreeSize();
-
-    m_tree->SetClientSize( sizeTree.x - sizeBorder.x, sizeTree.y - sizeBorder.y );
-
-    const wxSize sizeNew = m_tree->GetSize();
-    wxPoint posTree;
-    switch ( GetWindowStyle() & wxTBK_ALIGN_MASK )
-    {
-        default:
-            wxFAIL_MSG( _T("unexpected wxTreebook alignment") );
-            // fall through
-
-        case wxTBK_LEFT:
-            // posTree is already ok
-            break;
-
-        case wxTBK_RIGHT:
-            posTree.x = sizeClient.x - sizeNew.x;
-            break;
-    }
-
-    if ( m_tree->GetPosition() != posTree )
-        m_tree->Move(posTree);
-
-    // resize the currently shown page
-    wxTreebookPage *page = DoGetCurrentPage();
-    if ( page )
-    {
-        wxRect rectPage = GetPageRect();
-        page->SetSize(rectPage);
-    }
-}
-
 wxTreebookPage * wxTreebook::DoGetCurrentPage() const
 {
     if ( m_selection == wxNOT_FOUND )
@@ -808,4 +721,3 @@ wxTreebookPage * wxTreebook::DoGetCurrentPage() const
 }
 
 #endif // wxUSE_TREEBOOK
-
index 0d338135846ccdc6a5bdeef0dc90f7ab0cc8dbdc..1d8d4501042f7dcba9886f4410f72ee93c8570f4 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        msw/notebook.cpp
+// Name:        src/msw/notebook.cpp
 // Purpose:     implementation of wxNotebook
 // Author:      Vadim Zeitlin
 // Modified by:
@@ -153,9 +153,11 @@ wxBEGIN_FLAGS( wxNotebookStyle )
     wxFLAGS_MEMBER(wxHSCROLL)
 
     wxFLAGS_MEMBER(wxNB_FIXEDWIDTH)
-    wxFLAGS_MEMBER(wxNB_LEFT)
-    wxFLAGS_MEMBER(wxNB_RIGHT)
-    wxFLAGS_MEMBER(wxNB_BOTTOM)
+    wxFLAGS_MEMBER(wxBK_DEFAULT)
+    wxFLAGS_MEMBER(wxBK_TOP)
+    wxFLAGS_MEMBER(wxBK_LEFT)
+    wxFLAGS_MEMBER(wxBK_RIGHT)
+    wxFLAGS_MEMBER(wxBK_BOTTOM)
     wxFLAGS_MEMBER(wxNB_NOPAGETHEME)
     wxFLAGS_MEMBER(wxNB_FLAT)
 
@@ -283,7 +285,7 @@ bool wxNotebook::Create(wxWindow *parent,
         if ( wxUxThemeEngine::GetIfActive() )
 #endif
         {
-            style &= ~(wxNB_BOTTOM | wxNB_LEFT | wxNB_RIGHT);
+            style &= ~(wxBK_BOTTOM | wxBK_LEFT | wxBK_RIGHT);
         }
     }
 
@@ -374,11 +376,11 @@ WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const
     if ( style & wxNB_FIXEDWIDTH )
         tabStyle |= TCS_FIXEDWIDTH;
 
-    if ( style & wxNB_BOTTOM )
+    if ( style & wxBK_BOTTOM )
         tabStyle |= TCS_RIGHT;
-    else if ( style & wxNB_LEFT )
+    else if ( style & wxBK_LEFT )
         tabStyle |= TCS_VERTICAL;
-    else if ( style & wxNB_RIGHT )
+    else if ( style & wxBK_RIGHT )
         tabStyle |= TCS_VERTICAL | TCS_RIGHT;
 
     // ex style
@@ -566,7 +568,7 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
         tabSize.x = rect.right - rect.left;
         tabSize.y = rect.bottom - rect.top;
     }
-    if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
+    if ( HasFlag(wxBK_LEFT) || HasFlag(wxBK_RIGHT) )
     {
         sizeTotal.x += tabSize.x + 7;
         sizeTotal.y += 7;
index a67f330d10f9cd617433e3f31d5c1f2317494bea..48a00b3044464919dfba318813b55576aff2a463 100644 (file)
@@ -1,8 +1,9 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_choicbk.cpp
+// Name:        src/xrc/xh_choicbk.cpp
 // Purpose:     XRC resource for wxChoicebook
 // Author:      Vaclav Slavik
 // Created:     2000/03/21
+// RCS-ID:      $Id$
 // Copyright:   (c) 2000 Vaclav Slavik
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -28,11 +29,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoicebookXmlHandler, wxXmlResourceHandler)
 wxChoicebookXmlHandler::wxChoicebookXmlHandler()
 : wxXmlResourceHandler(), m_isInside(false), m_choicebook(NULL)
 {
+    XRC_ADD_STYLE(wxBK_DEFAULT);
+    XRC_ADD_STYLE(wxBK_LEFT);
+    XRC_ADD_STYLE(wxBK_RIGHT);
+    XRC_ADD_STYLE(wxBK_TOP);
+    XRC_ADD_STYLE(wxBK_BOTTOM);
+
+#if WXWIN_COMPATIBILITY_2_6
     XRC_ADD_STYLE(wxCHB_DEFAULT);
     XRC_ADD_STYLE(wxCHB_LEFT);
     XRC_ADD_STYLE(wxCHB_RIGHT);
     XRC_ADD_STYLE(wxCHB_TOP);
     XRC_ADD_STYLE(wxCHB_BOTTOM);
+#endif
 
     AddWindowStyles();
 }
index a550903bb6423b39bbf893489b33b459f44499bd..c0d9742a6a77219811d034251871afe79babf43a 100644 (file)
@@ -1,8 +1,9 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_listbk.cpp
+// Name:        src/xrc/xh_listbk.cpp
 // Purpose:     XRC resource for wxListbook
 // Author:      Vaclav Slavik
 // Created:     2000/03/21
+// RCS-ID:      $Id$
 // Copyright:   (c) 2000 Vaclav Slavik
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -28,11 +29,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxListbookXmlHandler, wxXmlResourceHandler)
 wxListbookXmlHandler::wxListbookXmlHandler()
 : wxXmlResourceHandler(), m_isInside(false), m_listbook(NULL)
 {
+    XRC_ADD_STYLE(wxBK_DEFAULT);
+    XRC_ADD_STYLE(wxBK_LEFT);
+    XRC_ADD_STYLE(wxBK_RIGHT);
+    XRC_ADD_STYLE(wxBK_TOP);
+    XRC_ADD_STYLE(wxBK_BOTTOM);
+
+#if WXWIN_COMPATIBILITY_2_6
     XRC_ADD_STYLE(wxLB_DEFAULT);
     XRC_ADD_STYLE(wxLB_LEFT);
     XRC_ADD_STYLE(wxLB_RIGHT);
     XRC_ADD_STYLE(wxLB_TOP);
     XRC_ADD_STYLE(wxLB_BOTTOM);
+#endif
 
     AddWindowStyles();
 }
index 64d25359e527383c7d8e32c47c8570fe93be2705..15efb8fca06e3ba6faa92b25678b37e8c38d5a0b 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_notbk.cpp
+// Name:        src/xrc/xh_notbk.cpp
 // Purpose:     XRC resource for wxNotebook
 // Author:      Vaclav Slavik
 // Created:     2000/03/21
@@ -29,11 +29,19 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookXmlHandler, wxXmlResourceHandler)
 wxNotebookXmlHandler::wxNotebookXmlHandler()
 : wxXmlResourceHandler(), m_isInside(false), m_notebook(NULL)
 {
+    XRC_ADD_STYLE(wxBK_DEFAULT);
+    XRC_ADD_STYLE(wxBK_LEFT);
+    XRC_ADD_STYLE(wxBK_RIGHT);
+    XRC_ADD_STYLE(wxBK_TOP);
+    XRC_ADD_STYLE(wxBK_BOTTOM);
+
+#if WXWIN_COMPATIBILITY_2_6
     XRC_ADD_STYLE(wxNB_DEFAULT);
     XRC_ADD_STYLE(wxNB_LEFT);
     XRC_ADD_STYLE(wxNB_RIGHT);
     XRC_ADD_STYLE(wxNB_TOP);
     XRC_ADD_STYLE(wxNB_BOTTOM);
+#endif
 
     XRC_ADD_STYLE(wxNB_FIXEDWIDTH);
     XRC_ADD_STYLE(wxNB_MULTILINE);
index 9b4513fdcc24ccdb289f6cd97db7f37c509c86ff..a79a01b9a34e818e785fb533520603bc97f44f82 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_treebk.cpp
+// Name:        src/xrc/xh_treebk.cpp
 // Purpose:     XRC resource handler for wxTreebook
 // Author:      Evgeniy Tarassov
 // Created:     2005/09/28
@@ -28,9 +28,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreebookXmlHandler, wxXmlResourceHandler)
 wxTreebookXmlHandler::wxTreebookXmlHandler()
 : wxXmlResourceHandler(), m_isInside(false), m_tbk(NULL), m_treeContext()
 {
-    XRC_ADD_STYLE(wxTBK_DEFAULT);
-    XRC_ADD_STYLE(wxTBK_LEFT);
-    XRC_ADD_STYLE(wxTBK_RIGHT);
+    XRC_ADD_STYLE(wxBK_DEFAULT);
+    XRC_ADD_STYLE(wxBK_TOP);
+    XRC_ADD_STYLE(wxBK_BOTTOM);
+    XRC_ADD_STYLE(wxBK_LEFT);
+    XRC_ADD_STYLE(wxBK_RIGHT);
 
     AddWindowStyles();
 }
@@ -92,7 +94,7 @@ wxObject *wxTreebookXmlHandler::DoCreateResource()
     }
 
     size_t depth = GetLong( wxT("depth") );
-    
+
     if( depth <= m_treeContext.Count() )
     {
         // first prepare the icon
@@ -122,9 +124,9 @@ wxObject *wxTreebookXmlHandler::DoCreateResource()
             m_tbk->AddSubPage(m_treeContext.Item(depth - 1), wnd,
                 GetText(wxT("label")), GetBool(wxT("selected")), imgIndex);
         }
-        
+
         m_treeContext.Add( m_tbk->GetPageCount() - 1);
-        
+
     }
     else
         wxLogError(wxT("Error in resource. wxTreebookPage has an invalid depth."));