From 9f29226d68edcee8170d69f42ab0904c887f7861 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Thu, 1 Sep 2005 15:53:16 +0000 Subject: [PATCH] Sizing fixes for wxListbook and wxChoicebook. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35402 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/choicbkg.cpp | 10 +++++----- src/generic/listbkg.cpp | 40 ++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/generic/choicbkg.cpp b/src/generic/choicbkg.cpp index 05b057a16f..91389e2c3b 100644 --- a/src/generic/choicbkg.cpp +++ b/src/generic/choicbkg.cpp @@ -123,7 +123,7 @@ wxChoicebook::Create(wxWindow *parent, wxSize wxChoicebook::GetChoiceSize() const { const wxSize sizeClient = GetClientSize(), - sizeChoice = m_choice->GetBestSize(); + sizeChoice = m_choice->GetBestFittingSize(); wxSize size; if ( IsVertical() ) @@ -142,7 +142,7 @@ wxSize wxChoicebook::GetChoiceSize() const wxRect wxChoicebook::GetPageRect() const { - const wxSize sizeChoice = m_choice->GetSize(); + const wxSize sizeChoice = m_choice->GetBestFittingSize(); wxPoint pt; wxRect rectPage(pt, GetClientSize()); @@ -207,8 +207,8 @@ void wxChoicebook::OnSize(wxSizeEvent& event) break; } - m_choice->Move(posChoice.x, posChoice.y); - m_choice->SetSize(sizeChoice.x, sizeChoice.y); + m_choice->Move(posChoice); + m_choice->SetSize(sizeChoice); // resize the currently shown page if ( m_selection != wxNOT_FOUND ) @@ -258,7 +258,7 @@ int wxChoicebook::GetPageImage(size_t WXUNUSED(n)) const { wxFAIL_MSG( _T("wxChoicebook::GetPageImage() not implemented") ); - return -1; + return wxNOT_FOUND; } bool wxChoicebook::SetPageImage(size_t WXUNUSED(n), int WXUNUSED(imageId)) diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index fdbe49e578..27ca8e070f 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -151,7 +151,8 @@ wxListbook::Create(wxWindow *parent, wxSize wxListbook::GetListSize() const { const wxSize sizeClient = GetClientSize(), - sizeList = m_list->GetViewRect().GetSize(); + sizeBorder = m_list->GetSize() - m_list->GetClientSize(), + sizeList = m_list->GetViewRect().GetSize() + sizeBorder; wxSize size; if ( IsVertical() ) @@ -210,10 +211,21 @@ void wxListbook::OnSize(wxSizeEvent& event) 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 ) { @@ -227,23 +239,16 @@ void wxListbook::OnSize(wxSizeEvent& event) break; case wxLB_BOTTOM: - posList.y = sizeClient.y - sizeList.y; + posList.y = sizeClient.y - sizeNew.y; break; case wxLB_RIGHT: - posList.x = sizeClient.x - sizeList.x; + posList.x = sizeClient.x - sizeNew.x; break; } - // 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(); if ( m_list->GetPosition() != posList ) - m_list->Move(posList.x, posList.y); - m_list->SetClientSize(sizeList.x, sizeList.y); + m_list->Move(posList); #if wxUSE_LINE_IN_LISTBOOK if ( m_line ) @@ -253,23 +258,23 @@ void wxListbook::OnSize(wxSizeEvent& event) switch ( GetWindowStyle() & wxLB_ALIGN_MASK ) { case wxLB_TOP: - rectLine.y = sizeList.y + 1; + rectLine.y = sizeNew.y + 1; rectLine.height = MARGIN - 2; break; case wxLB_BOTTOM: rectLine.height = MARGIN - 2; - rectLine.y = sizeClient.y - sizeList.y - rectLine.height; + rectLine.y = sizeClient.y - sizeNew.y - rectLine.height; break; case wxLB_LEFT: - rectLine.x = sizeList.x + 1; + rectLine.x = sizeNew.x + 1; rectLine.width = MARGIN - 2; break; case wxLB_RIGHT: rectLine.width = MARGIN - 2; - rectLine.x = sizeClient.x - sizeList.x - rectLine.width; + rectLine.x = sizeClient.x - sizeNew.x - rectLine.width; break; } @@ -325,7 +330,7 @@ int wxListbook::GetPageImage(size_t WXUNUSED(n)) const { wxFAIL_MSG( _T("wxListbook::GetPageImage() not implemented") ); - return -1; + return wxNOT_FOUND; } bool wxListbook::SetPageImage(size_t n, int imageId) @@ -430,6 +435,7 @@ wxListbook::InsertPage(size_t n, SetSelection(selNew); InvalidateBestSize(); + m_list->Arrange(); return true; } @@ -457,6 +463,8 @@ wxWindow *wxListbook::DoRemovePage(size_t page) if ((sel != wxNOT_FOUND) && (sel != m_selection)) SetSelection(sel); } + + m_list->Arrange(); } return win; -- 2.45.2