only), so please refer to that class documentation for now. You can also
use the \helpref{notebook sample}{samplenotebook} to see wxChoicebook in action.
+wxChoicebook allows the use of wxBookCtrl::GetControlSizer, allowing a program
+to add other controls next to the choice control. This is particularly useful
+when screen space is restricted, as it often is when wxChoicebook is being employed.
+
\wxheading{Derived from}
+wxBookCtrlBase\\
\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
m_internalBorder = internalBorder;
}
+ // Sets/gets the margin around the controller
+ void SetControlMargin(int margin) { m_controlMargin = margin; }
+ int GetControlMargin() const { return m_controlMargin; }
+
// returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
+ // returns the sizer containing the control, if any
+ wxSizer* GetControlSizer() const { return m_controlSizer; }
+
// operations
// ----------
// Whether to shrink to fit current page
bool m_fitToCurrentPage;
+ // the sizer containing the choice control
+ wxSizer* m_controlSizer;
+
+ // the margin around the choice control
+ int m_controlMargin;
+
private:
// common part of all ctors
#else
m_internalBorder = 5;
#endif
+
+ m_controlMargin = 0;
+ m_controlSizer = NULL;
}
bool
// 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 )
+
+ if (GetSizer())
+ Layout();
+ else
{
- default:
- wxFAIL_MSG( _T("unexpected alignment") );
- // fall through
+ // 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() );
- case wxBK_TOP:
- case wxBK_LEFT:
- // posCtrl is already ok
- break;
+ m_bookctrl->SetClientSize( sizeCtrl.x - sizeBorder.x, sizeCtrl.y - sizeBorder.y );
- case wxBK_BOTTOM:
- posCtrl.y = sizeClient.y - sizeNew.y;
- break;
+ 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;
+ }
- case wxBK_RIGHT:
- posCtrl.x = sizeClient.x - sizeNew.x;
- break;
+ if ( m_bookctrl->GetPosition() != posCtrl )
+ m_bookctrl->Move(posCtrl);
}
- if ( m_bookctrl->GetPosition() != posCtrl )
- m_bookctrl->Move(posCtrl);
-
// resize the currently shown page
if (GetSelection() != wxNOT_FOUND )
{
wxDefaultSize
);
+ wxSizer* mainSizer = new wxBoxSizer(IsVertical() ? wxVERTICAL : wxHORIZONTAL);
+
+ if (style & wxCHB_RIGHT || style & wxCHB_BOTTOM)
+ mainSizer->Add(0, 0, 1, wxEXPAND, 0);
+
+ m_controlSizer = new wxBoxSizer(IsVertical() ? wxHORIZONTAL : wxVERTICAL);
+ m_controlSizer->Add(m_bookctrl, 1, (IsVertical() ? wxALIGN_CENTRE_VERTICAL : wxALIGN_CENTRE) |wxGROW, 0);
+ mainSizer->Add(m_controlSizer, 0, wxGROW|wxALL, m_controlMargin);
+ SetSizer(mainSizer);
return true;
}
wxSize wxChoicebook::GetControllerSize() const
{
const wxSize sizeClient = GetClientSize(),
- sizeChoice = m_bookctrl->GetBestFittingSize();
+ // sizeChoice = m_bookctrl->GetBestFittingSize();
+ sizeChoice = m_controlSizer->CalcMin();
wxSize size;
if ( IsVertical() )