From 82857cfa9d3cd5e0b6bef0879581b848796e5940 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Feb 2019 02:03:23 +0100 Subject: [PATCH] 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. --- include/wx/msw/toolbar.h | 10 ++++++++++ src/msw/toolbar.cpp | 6 +----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/wx/msw/toolbar.h b/include/wx/msw/toolbar.h index 5423f771f1..ff5da800c5 100644 --- a/include/wx/msw/toolbar.h +++ b/include/wx/msw/toolbar.h @@ -174,6 +174,16 @@ private: WXHBRUSH MSWGetToolbarBgBrush(); #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_DYNAMIC_CLASS(wxToolBar); wxDECLARE_NO_COPY_CLASS(wxToolBar); diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index dbe67831e9..8158d1cd9f 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1050,11 +1050,7 @@ bool wxToolBar::Realize() case wxTOOL_STYLE_CONTROL: if ( wxStaticText *staticText = tool->GetStaticText() ) { - // Display control and its label only if buttons have icons - // and texts as otherwise there is not enough room on the - // toolbar to fit the label. - staticText-> - Show(HasFlag(wxTB_TEXT) && !HasFlag(wxTB_NOICONS)); + staticText->Show(AreControlLabelsShown()); } // Set separator width/height to fit the control width/height