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.
This commit is contained in:
Lioncash 2016-10-29 02:44:48 -04:00
parent 5e8ccb15ff
commit 65a8b999b4
1 changed files with 31 additions and 0 deletions

View File

@ -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,