added wxBookCtrlSizer; derive wxNotebookSizer from it

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-08-21 23:09:35 +00:00
parent 1e54be64fd
commit ade4eb65af
2 changed files with 55 additions and 31 deletions

View File

@@ -499,27 +499,47 @@ private:
#endif // wxUSE_STATBOX #endif // wxUSE_STATBOX
//--------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxNotebookSizer // wxBookCtrlSizer
//--------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_BOOKCTRL
// this sizer works with wxNotebook/wxListbook/... and sizes the control to
// fit its pages
class WXDLLEXPORT wxBookCtrl;
class WXDLLEXPORT wxBookCtrlSizer : public wxSizer
{
public:
wxBookCtrlSizer(wxBookCtrl *bookctrl);
virtual void RecalcSizes();
virtual wxSize CalcMin();
wxBookCtrl *GetControl() const { return m_bookctrl; }
protected:
wxBookCtrl *m_bookctrl;
private:
DECLARE_CLASS(wxBookCtrlSizer)
DECLARE_NO_COPY_CLASS(wxBookCtrlSizer)
};
#if wxUSE_NOTEBOOK #if wxUSE_NOTEBOOK
// before wxBookCtrl we only had wxNotebookSizer, keep it for backwards
// compatibility
class WXDLLEXPORT wxNotebook; class WXDLLEXPORT wxNotebook;
class WXDLLEXPORT wxNotebookSizer: public wxSizer class WXDLLEXPORT wxNotebookSizer : public wxBookCtrlSizer
{ {
public: public:
wxNotebookSizer( wxNotebook *nb ); wxNotebookSizer(wxNotebook *nb);
void RecalcSizes(); wxNotebook *GetNotebook() const { return (wxNotebook *)m_bookctrl; }
wxSize CalcMin();
wxNotebook *GetNotebook() const
{ return m_notebook; }
protected:
wxNotebook *m_notebook;
private: private:
DECLARE_CLASS(wxNotebookSizer) DECLARE_CLASS(wxNotebookSizer)
@@ -528,6 +548,7 @@ private:
#endif // wxUSE_NOTEBOOK #endif // wxUSE_NOTEBOOK
#endif // wxUSE_BOOKCTRL
#endif // __WXSIZER_H__
#endif
// __WXSIZER_H__

View File

@@ -37,9 +37,12 @@ IMPLEMENT_CLASS(wxBoxSizer, wxSizer)
#if wxUSE_STATBOX #if wxUSE_STATBOX
IMPLEMENT_CLASS(wxStaticBoxSizer, wxBoxSizer) IMPLEMENT_CLASS(wxStaticBoxSizer, wxBoxSizer)
#endif #endif
#if wxUSE_BOOKCTRL
IMPLEMENT_CLASS(wxBookCtrlSizer, wxSizer)
#if wxUSE_NOTEBOOK #if wxUSE_NOTEBOOK
IMPLEMENT_CLASS(wxNotebookSizer, wxSizer) IMPLEMENT_CLASS(wxNotebookSizer, wxBookCtrlSizer)
#endif #endif // wxUSE_NOTEBOOK
#endif // wxUSE_BOOKCTRL
WX_DEFINE_EXPORTED_LIST( wxSizerItemList ); WX_DEFINE_EXPORTED_LIST( wxSizerItemList );
@@ -1555,31 +1558,31 @@ wxSize wxStaticBoxSizer::CalcMin()
#endif // wxUSE_STATBOX #endif // wxUSE_STATBOX
//--------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxNotebookSizer // wxNotebookSizer
//--------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_NOTEBOOK #if wxUSE_BOOKCTRL
wxNotebookSizer::wxNotebookSizer( wxNotebook *nb ) wxBookCtrlSizer::wxBookCtrlSizer(wxBookCtrl *bookctrl)
: m_notebook( nb ) : 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.x += 5;
sizeBorder.y += 5; sizeBorder.y += 5;
if (m_notebook->GetChildren().GetCount() == 0) if ( m_bookctrl->GetPageCount() == 0 )
{ {
return wxSize(sizeBorder.x + 10, sizeBorder.y + 10); return wxSize(sizeBorder.x + 10, sizeBorder.y + 10);
} }
@@ -1587,7 +1590,8 @@ wxSize wxNotebookSizer::CalcMin()
int maxX = 0; int maxX = 0;
int maxY = 0; int maxY = 0;
wxWindowList::compatibility_iterator node = m_notebook->GetChildren().GetFirst(); wxWindowList::compatibility_iterator
node = m_bookctrl->GetChildren().GetFirst();
while (node) while (node)
{ {
wxWindow *item = node->GetData(); wxWindow *item = node->GetData();
@@ -1609,6 +1613,5 @@ wxSize wxNotebookSizer::CalcMin()
return wxSize( maxX, maxY ) + sizeBorder; return wxSize( maxX, maxY ) + sizeBorder;
} }
#endif // wxUSE_NOTEBOOK #endif // wxUSE_BOOKCTRL
// vi:sts=4:sw=4:et