+void MyFrame::OnSize(wxSizeEvent& event)
+{
+ if ( m_tbar )
+ {
+ LayoutChildren();
+ }
+ else
+ {
+ event.Skip();
+ }
+}
+
+void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
+{
+ wxToolBar *tbar = GetToolBar();
+
+ if ( !tbar )
+ {
+ RecreateToolbar();
+ }
+ else
+ {
+ // notice that there is no need to call SetToolBar(NULL) here (although
+ // this it is harmless to do and it must be called if you do not delete
+ // the toolbar but keep it for later reuse), just delete the toolbar
+ // directly and it will reset the associated frame toolbar pointer
+ delete tbar;
+ }
+}
+
+void MyFrame::OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event))
+{
+ m_horzText = !m_horzText;
+
+ RecreateToolbar();
+}
+
+void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
+{
+ if ( m_tbar )
+ {
+ wxDELETE(m_tbar);
+ }
+ else
+ {
+ long style = GetToolBar() ? GetToolBar()->GetWindowStyle()
+ : TOOLBAR_STYLE;
+ style &= ~wxTB_HORIZONTAL;
+ style |= wxTB_VERTICAL;
+
+ m_tbar = new wxToolBar(this, wxID_ANY,
+ wxDefaultPosition, wxDefaultSize,
+ style);
+
+ m_tbar->SetMargins(4, 4);
+
+ m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_1, wxT("First"), wxBITMAP(new));
+ m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_2, wxT("Second"), wxBITMAP(open));
+ m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_3, wxT("Third"), wxBITMAP(save));
+ m_tbar->AddSeparator();
+ m_tbar->AddTool(wxID_HELP, wxT("Help"), wxBITMAP(help));
+
+ m_tbar->Realize();
+ }
+
+ LayoutChildren();
+}