From 9c2076b79fc6cbe837e93b453b06ef3843effe39 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 17 Jun 2016 23:18:10 +0200 Subject: [PATCH] Implemented wxToolBarTool::SetLabel (GTK) Labels can be changed only for button tools because control tools with labels are not implemented under wxGTK. Closes #17567 --- src/gtk/toolbar.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/gtk/toolbar.cpp b/src/gtk/toolbar.cpp index 64a7c70c06..cc1dcc794c 100644 --- a/src/gtk/toolbar.cpp +++ b/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,