+void MyFrame::LayoutChildren()
+{
+ wxSize size = GetClientSize();
+
+ int offset;
+ if ( m_tbar )
+ {
+ m_tbar->SetSize(wxDefaultCoord, size.y);
+ m_tbar->Move(0, 0);
+
+ offset = m_tbar->GetSize().x;
+ }
+ else
+ {
+ offset = 0;
+ }
+
+ m_textWindow->SetSize(offset, 0, size.x - offset, size.y);
+}
+
+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
+ {
+ delete tbar;
+
+ SetToolBar(NULL);
+ }
+}
+
+void MyFrame::OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event))
+{
+ m_horzText = !m_horzText;
+
+ RecreateToolbar();
+}
+
+void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
+{
+ if ( m_tbar )
+ {
+ delete m_tbar;
+ m_tbar = NULL;
+ }
+ else
+ {
+ long style = GetToolBar()->GetWindowStyle();
+ 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, _T("First"), wxBITMAP(new));
+ m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_2, _T("Second"), wxBITMAP(open));
+ m_tbar->AddRadioTool(IDM_TOOLBAR_OTHER_3, _T("Third"), wxBITMAP(save));
+ m_tbar->AddSeparator();
+ m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help));
+
+ m_tbar->Realize();
+ }
+
+ LayoutChildren();
+}
+