The definition of this method was needlessly duplicated in all of
wx{Choice,List,Tool,Tree}book and in all of them except the first one it
didn't account correctly for the case when the size of the controller was
greater than the size of the page.
Avoid the duplication and fix the best size determination in such case by
providing a single, correct version of the function in the base class itself.
Closes #11793.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63632
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
wxSize GetControllerSize() const;
// calculate the size of the control from the size of its page
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
+ //
+ // by default this simply returns size enough to fit both the page and the
+ // controller
+ virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
// get/set size of area between book control area and page area
unsigned int GetInternalBorder() const { return m_internalBorder; }
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual bool InsertPage(size_t n,
wxWindow *page,
const wxString& text,
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
wxControl::InvalidateBestSize();
}
+wxSize wxBookCtrlBase::CalcSizeFromPage(const wxSize& sizePage) const
+{
+ // we need to add the size of the choice control and the border between
+ const wxSize sizeController = GetControllerSize();
+
+ wxSize size = sizePage;
+ if ( IsVertical() )
+ {
+ if ( sizeController.x > sizePage.x )
+ size.x = sizeController.x;
+ size.y += sizeController.y + GetInternalBorder();
+ }
+ else // left/right aligned
+ {
+ size.x += sizeController.x + GetInternalBorder();
+ if ( sizeController.y > sizePage.y )
+ size.y = sizeController.y;
+ }
+
+ return size;
+}
+
void wxBookCtrlBase::SetPageSize(const wxSize& size)
{
SetClientSize(CalcSizeFromPage(size));
return true;
}
-// ----------------------------------------------------------------------------
-// wxChoicebook geometry management
-// ----------------------------------------------------------------------------
-
-wxSize wxChoicebook::CalcSizeFromPage(const wxSize& sizePage) const
-{
- // we need to add the size of the choice control and the border between
- const wxSize sizeChoice = GetControllerSize();
-
- wxSize size = sizePage;
- if ( IsVertical() )
- {
- if ( sizeChoice.x > sizePage.x )
- size.x = sizeChoice.x;
- size.y += sizeChoice.y + GetInternalBorder();
- }
- else // left/right aligned
- {
- size.x += sizeChoice.x + GetInternalBorder();
- if ( sizeChoice.y > sizePage.y )
- size.y = sizeChoice.y;
- }
-
- return size;
-}
-
-
// ----------------------------------------------------------------------------
// accessing the pages
// ----------------------------------------------------------------------------
return pagePos;
}
-wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
-{
- // we need to add the size of the list control and the border between
- const wxSize sizeList = GetControllerSize();
-
- wxSize size = sizePage;
- if ( IsVertical() )
- {
- size.y += sizeList.y + GetInternalBorder();
- }
- else // left/right aligned
- {
- size.x += sizeList.x + GetInternalBorder();
- }
-
- return size;
-}
-
void wxListbook::UpdateSize()
{
// we should find a more elegant way to force a layout than generating this
wxBookCtrlBase::OnSize(event);
}
-wxSize wxToolbook::CalcSizeFromPage(const wxSize& sizePage) const
-{
- // we need to add the size of the list control and the border between
- const wxSize sizeToolBar = GetControllerSize();
-
- wxSize size = sizePage;
- if ( IsVertical() )
- {
- size.y += sizeToolBar.y + GetInternalBorder();
- }
- else // left/right aligned
- {
- size.x += sizeToolBar.x + GetInternalBorder();
- }
-
- return size;
-}
-
// ----------------------------------------------------------------------------
// accessing the pages
// ----------------------------------------------------------------------------
return true;
}
-wxSize wxTreebook::CalcSizeFromPage(const wxSize& sizePage) const
-{
- const wxSize sizeTree = GetControllerSize();
-
- wxSize size = sizePage;
- size.x += sizeTree.x;
-
- return size;
-}
-
int wxTreebook::GetSelection() const
{
return m_selection;