Attach toolbars to the frame before populating them

Works around a wxOSX-Cocoa bug (http://trac.wxwidgets.org/ticket/13888)
that resulted in items never being added to the toolbar.

Originally committed to SVN as r6826.
This commit is contained in:
Thomas Goyne 2012-05-19 01:13:00 +00:00
parent 48c3b39cd1
commit ba40e24326
1 changed files with 14 additions and 1 deletions

View File

@ -183,12 +183,25 @@ namespace {
Populate(); Populate();
Bind(wxEVT_COMMAND_TOOL_CLICKED, &Toolbar::OnClick, this); Bind(wxEVT_COMMAND_TOOL_CLICKED, &Toolbar::OnClick, this);
} }
Toolbar(wxFrame *parent, std::string const& name, agi::Context *c, std::string const& ht_context)
: wxToolBar(parent, -1, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_HORIZONTAL)
, name(name)
, context(c)
, ht_context(ht_context)
, icon_size_slot(OPT_SUB("App/Toolbar Icon Size", &Toolbar::RegenerateToolbar, this))
, hotkeys_changed_slot(hotkey::inst->AddHotkeyChangeListener(&Toolbar::RegenerateToolbar, this))
{
parent->SetToolBar(this);
Populate();
Bind(wxEVT_COMMAND_TOOL_CLICKED, &Toolbar::OnClick, this);
}
}; };
} }
namespace toolbar { namespace toolbar {
void AttachToolbar(wxFrame *frame, std::string const& name, agi::Context *c, std::string const& hotkey) { void AttachToolbar(wxFrame *frame, std::string const& name, agi::Context *c, std::string const& hotkey) {
frame->SetToolBar(new Toolbar(frame, name, c, hotkey, false)); new Toolbar(frame, name, c, hotkey);
} }
wxToolBar *GetToolbar(wxWindow *parent, std::string const& name, agi::Context *c, std::string const& hotkey, bool vertical) { wxToolBar *GetToolbar(wxWindow *parent, std::string const& name, agi::Context *c, std::string const& hotkey, bool vertical) {