From 65a8b999b4e6531ad43d83783cd10f425ce0e9f1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 29 Oct 2016 02:44:48 -0400 Subject: [PATCH] wxWidgets (gtk): Patch that allows label switching to work for wxToolBar This applies a patch that was merged into the mainline wxWidgets tree to support label changing with wxToolBar. This originally only worked on Windows and macOS, which is kind of annoying. This is beneficial because it means that a tool doesn't have to be removed and then reinserted into a wxToolBar instance in order to change the label. For more details, see ticket #17567 on the wxWidgets issue tracker. --- Externals/wxWidgets3/src/gtk/toolbar.cpp | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Externals/wxWidgets3/src/gtk/toolbar.cpp b/Externals/wxWidgets3/src/gtk/toolbar.cpp index ff5bcdefa4..1ae765e9d0 100644 --- a/Externals/wxWidgets3/src/gtk/toolbar.cpp +++ b/Externals/wxWidgets3/src/gtk/toolbar.cpp @@ -56,6 +56,7 @@ public: void SetImage(); void CreateDropDown(); void ShowDropdown(GtkToggleButton* button); + virtual void SetLabel(const wxString& label) wxOVERRIDE; GtkToolItem* m_item; }; @@ -318,6 +319,36 @@ void wxToolBarTool::ShowDropdown(GtkToggleButton* button) } } +void wxToolBarTool::SetLabel(const wxString& label) +{ + wxASSERT_MSG( IsButton(), + wxS("Label can be set for button tool only") ); + + if ( label == m_label ) + return; + + wxToolBarToolBase::SetLabel(label); + if ( IsButton() ) + { + if ( !label.empty() ) + { + wxString newLabel = wxControl::RemoveMnemonics(label); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(m_item), + wxGTK_CONV(newLabel)); + // To show the label for toolbar with wxTB_HORZ_LAYOUT. + gtk_tool_item_set_is_important(m_item, true); + } + else + { + gtk_tool_button_set_label(GTK_TOOL_BUTTON(m_item), NULL); + // To hide the label for toolbar with wxTB_HORZ_LAYOUT. + gtk_tool_item_set_is_important(m_item, false); + } + } + + // TODO: Set label for control tool, if it's possible. +} + wxToolBarToolBase *wxToolBar::CreateTool(int id, const wxString& text, const wxBitmap& bitmap1,