On screens with restricted space, it's useful to be able to add controls
to e.g. the wxChoice control of a wxChoicebook. GetControlSizer allows an app to do that, and we also add a control margin which may or may not be respected by individual book controls. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38698 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,8 +20,13 @@ identical to wxNotebook (except for the features clearly related to tabs
|
|||||||
only), so please refer to that class documentation for now. You can also
|
only), so please refer to that class documentation for now. You can also
|
||||||
use the \helpref{notebook sample}{samplenotebook} to see wxChoicebook in action.
|
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}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
wxBookCtrlBase\\
|
||||||
\helpref{wxControl}{wxcontrol}\\
|
\helpref{wxControl}{wxcontrol}\\
|
||||||
\helpref{wxWindow}{wxwindow}\\
|
\helpref{wxWindow}{wxwindow}\\
|
||||||
\helpref{wxEvtHandler}{wxevthandler}\\
|
\helpref{wxEvtHandler}{wxevthandler}\\
|
||||||
|
@@ -128,6 +128,10 @@ public:
|
|||||||
m_internalBorder = internalBorder;
|
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
|
// returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
|
||||||
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
|
bool IsVertical() const { return HasFlag(wxBK_BOTTOM | wxBK_TOP); }
|
||||||
|
|
||||||
@@ -135,6 +139,9 @@ public:
|
|||||||
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
|
void SetFitToCurrentPage(bool fit) { m_fitToCurrentPage = fit; }
|
||||||
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
|
bool GetFitToCurrentPage() const { return m_fitToCurrentPage; }
|
||||||
|
|
||||||
|
// returns the sizer containing the control, if any
|
||||||
|
wxSizer* GetControlSizer() const { return m_controlSizer; }
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
// ----------
|
// ----------
|
||||||
|
|
||||||
@@ -236,6 +243,12 @@ protected:
|
|||||||
// Whether to shrink to fit current page
|
// Whether to shrink to fit current page
|
||||||
bool m_fitToCurrentPage;
|
bool m_fitToCurrentPage;
|
||||||
|
|
||||||
|
// the sizer containing the choice control
|
||||||
|
wxSizer* m_controlSizer;
|
||||||
|
|
||||||
|
// the margin around the choice control
|
||||||
|
int m_controlMargin;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
|
@@ -60,6 +60,9 @@ void wxBookCtrlBase::Init()
|
|||||||
#else
|
#else
|
||||||
m_internalBorder = 5;
|
m_internalBorder = 5;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_controlMargin = 0;
|
||||||
|
m_controlSizer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -265,6 +268,10 @@ void wxBookCtrlBase::DoSize()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetSizer())
|
||||||
|
Layout();
|
||||||
|
else
|
||||||
|
{
|
||||||
// resize controller and the page area to fit inside our new size
|
// resize controller and the page area to fit inside our new size
|
||||||
const wxSize sizeClient( GetClientSize() ),
|
const wxSize sizeClient( GetClientSize() ),
|
||||||
sizeBorder( m_bookctrl->GetSize() - m_bookctrl->GetClientSize() ),
|
sizeBorder( m_bookctrl->GetSize() - m_bookctrl->GetClientSize() ),
|
||||||
@@ -296,6 +303,7 @@ void wxBookCtrlBase::DoSize()
|
|||||||
|
|
||||||
if ( m_bookctrl->GetPosition() != posCtrl )
|
if ( m_bookctrl->GetPosition() != posCtrl )
|
||||||
m_bookctrl->Move(posCtrl);
|
m_bookctrl->Move(posCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
// resize the currently shown page
|
// resize the currently shown page
|
||||||
if (GetSelection() != wxNOT_FOUND )
|
if (GetSelection() != wxNOT_FOUND )
|
||||||
|
@@ -96,6 +96,15 @@ wxChoicebook::Create(wxWindow *parent,
|
|||||||
wxDefaultSize
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +115,8 @@ wxChoicebook::Create(wxWindow *parent,
|
|||||||
wxSize wxChoicebook::GetControllerSize() const
|
wxSize wxChoicebook::GetControllerSize() const
|
||||||
{
|
{
|
||||||
const wxSize sizeClient = GetClientSize(),
|
const wxSize sizeClient = GetClientSize(),
|
||||||
sizeChoice = m_bookctrl->GetBestFittingSize();
|
// sizeChoice = m_bookctrl->GetBestFittingSize();
|
||||||
|
sizeChoice = m_controlSizer->CalcMin();
|
||||||
|
|
||||||
wxSize size;
|
wxSize size;
|
||||||
if ( IsVertical() )
|
if ( IsVertical() )
|
||||||
|
Reference in New Issue
Block a user