| 1 |
#include "tool_bar.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include <event_notifier.h> |
| 4 |
|
| 5 |
extern const wxEventType wxEVT_PREVIEW_BAR_SELECTED; |
| 6 |
|
| 7 |
ToolBar::ToolBar(wxWindow* parent) |
| 8 |
: wxPanel(parent) |
| 9 |
, m_wxtb(NULL) |
| 10 |
|
| 11 |
{ |
| 12 |
wxBoxSizer* sz = new wxBoxSizer(wxVERTICAL); |
| 13 |
SetSizer(sz); |
| 14 |
} |
| 15 |
|
| 16 |
ToolBar::~ToolBar() {} |
| 17 |
|
| 18 |
void ToolBar::AddToolbar(wxToolBar* tb) |
| 19 |
{ |
| 20 |
GetSizer()->Add(tb, 0, wxEXPAND); |
| 21 |
Connect(wxID_ANY, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(ToolBar::OnClick), NULL, this); |
| 22 |
m_wxtb = tb; |
| 23 |
} |
| 24 |
|
| 25 |
void ToolBar::OnClick(wxCommandEvent& e) |
| 26 |
{ |
| 27 |
e.Skip(); |
| 28 |
if(m_wxtb) { |
| 29 |
wxToolBarToolBase* tool = m_wxtb->FindById(e.GetId()); |
| 30 |
if(tool) { |
| 31 |
wxString label = tool->GetLabel(); |
| 32 |
wxString s; |
| 33 |
s << m_wxtb->GetName() << wxT(":") << label; |
| 34 |
wxCommandEvent evt(wxEVT_PREVIEW_BAR_SELECTED); |
| 35 |
evt.SetString(s); |
| 36 |
evt.SetInt(ID_WXTOOLBAR); |
| 37 |
EventNotifier::Get()->AddPendingEvent(evt); |
| 38 |
} |
| 39 |
} |
| 40 |
} |