Add small helper function to wxMSW wxToolBar code
Encapsulate the logic for deciding whether we should show the labels for the embedded controls or not in a small helper function, to make it simpler to change it in the future if needed and also to have a single place to explain why do we do what we do now. No real changes.
This commit is contained in:
@@ -174,6 +174,16 @@ private:
|
|||||||
WXHBRUSH MSWGetToolbarBgBrush();
|
WXHBRUSH MSWGetToolbarBgBrush();
|
||||||
#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
||||||
|
|
||||||
|
// Return true if we're showing the labels for the embedded controls: we
|
||||||
|
// only do it if text is enabled and, somewhat less expectedly, if icons
|
||||||
|
// are enabled too because showing both the control and its label when only
|
||||||
|
// text is shown for the other buttons is too inconsistent to be useful.
|
||||||
|
bool AreControlLabelsShown() const
|
||||||
|
{
|
||||||
|
return HasFlag(wxTB_TEXT) && !HasFlag(wxTB_NOICONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxToolBar);
|
wxDECLARE_DYNAMIC_CLASS(wxToolBar);
|
||||||
wxDECLARE_NO_COPY_CLASS(wxToolBar);
|
wxDECLARE_NO_COPY_CLASS(wxToolBar);
|
||||||
|
@@ -1050,11 +1050,7 @@ bool wxToolBar::Realize()
|
|||||||
case wxTOOL_STYLE_CONTROL:
|
case wxTOOL_STYLE_CONTROL:
|
||||||
if ( wxStaticText *staticText = tool->GetStaticText() )
|
if ( wxStaticText *staticText = tool->GetStaticText() )
|
||||||
{
|
{
|
||||||
// Display control and its label only if buttons have icons
|
staticText->Show(AreControlLabelsShown());
|
||||||
// and texts as otherwise there is not enough room on the
|
|
||||||
// toolbar to fit the label.
|
|
||||||
staticText->
|
|
||||||
Show(HasFlag(wxTB_TEXT) && !HasFlag(wxTB_NOICONS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set separator width/height to fit the control width/height
|
// Set separator width/height to fit the control width/height
|
||||||
|
Reference in New Issue
Block a user