X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c631abdae995a4ceae512d7853f6424fbfb27e83..8f8edad80ec9d9163a9c108f609cc59d8b77f050:/samples/toolbar/toolbar.cpp diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 4d5307987b..47854b9fb9 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -31,12 +31,12 @@ #include #include #include -#include // define this to 1 to use wxToolBarSimple instead of the native one #define USE_GENERIC_TBAR 0 // define this to use XPMs everywhere (by default, BMPs are used under Win) +// BMPs use less space, but aren't compiled into the executable on other platforms #ifdef __WXMSW__ #define USE_XPM_BITMAPS 0 #else @@ -101,6 +101,7 @@ public: void OnSize(wxSizeEvent& event); + void OnToggleToolbar(wxCommandEvent& event); void OnToggleAnotherToolbar(wxCommandEvent& event); void OnToggleToolbarSize(wxCommandEvent& event); @@ -152,7 +153,8 @@ private: const int ID_TOOLBAR = 500; -static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT; +static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT ; +// static const long TOOLBAR_STYLE = 0; enum { @@ -163,6 +165,7 @@ enum IDM_TOOLBAR_DELETEPRINT, IDM_TOOLBAR_INSERTPRINT, IDM_TOOLBAR_TOGGLEHELP, + IDM_TOOLBAR_TOGGLE_TOOLBAR, IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, IDM_TOOLBAR_CHANGE_TOOLTIP, IDM_TOOLBAR_SHOW_TEXT, @@ -185,6 +188,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(wxID_EXIT, MyFrame::OnQuit) EVT_MENU(wxID_HELP, MyFrame::OnAbout) + EVT_MENU(IDM_TOOLBAR_TOGGLE_TOOLBAR, MyFrame::OnToggleToolbar) EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar) EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize) @@ -351,23 +355,25 @@ MyFrame::MyFrame(wxFrame* parent, // Make a menubar wxMenu *tbarMenu = new wxMenu; - tbarMenu->Append(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, - "Toggle &another toolbar\tCtrl-A", - "Show/hide another test toolbar", - TRUE); - - tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARSIZE, - "&Toggle toolbar size\tCtrl-S", - "Toggle between big/small toolbar", - TRUE); - tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARORIENT, - "Toggle toolbar &orientation\tCtrl-O", - "Toggle toolbar orientation", - TRUE); - tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARROWS, - "Toggle number of &rows\tCtrl-R", - "Toggle number of toolbar rows between 1 and 2", - TRUE); + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_TOOLBAR, + "Toggle &toolbar\tCtrl-Z", + "Show or hide the toolbar"); + + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, + "Toggle &another toolbar\tCtrl-A", + "Show/hide another test toolbar"); + + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARSIZE, + "&Toggle toolbar size\tCtrl-S", + "Toggle between big/small toolbar"); + + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARORIENT, + "Toggle toolbar &orientation\tCtrl-O", + "Toggle toolbar orientation"); + + tbarMenu->AppendCheckItem(IDM_TOOLBAR_TOGGLETOOLBARROWS, + "Toggle number of &rows\tCtrl-R", + "Toggle number of toolbar rows between 1 and 2"); tbarMenu->AppendSeparator(); @@ -448,6 +454,22 @@ void MyFrame::OnSize(wxSizeEvent& event) } } +void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)) +{ + wxToolBar *tbar = GetToolBar(); + + if ( !tbar ) + { + RecreateToolbar(); + } + else + { + delete tbar; + + SetToolBar(NULL); + } +} + void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) { if ( m_tbar )