#include <wx/toolbar.h>
#include <wx/log.h>
#include <wx/image.h>
-#include <wx/spinctrl.h>
// 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
void OnSize(wxSizeEvent& event);
+ void OnToggleToolbar(wxCommandEvent& event);
void OnToggleAnotherToolbar(wxCommandEvent& event);
void OnToggleToolbarSize(wxCommandEvent& event);
const int ID_TOOLBAR = 500;
-static const long TOOLBAR_STYLE = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE;
+static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT ;
+// static const long TOOLBAR_STYLE = 0;
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,
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)
// Create the main frame window
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
"wxToolBar Sample",
- wxPoint(100, 100), wxSize(450, 300));
+ wxPoint(100, 100), wxSize(550, 300));
frame->Show(TRUE);
// 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();
// Associate the menu bar with the frame
SetMenuBar(menuBar);
+ menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, TRUE);
+
// Create the toolbar
RecreateToolbar();
}
}
}
+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 )
style);
m_tbar->AddRadioTool(wxID_NEW, _T("First"), wxBITMAP(new));
- m_tbar->AddRadioTool(wxID_NEW, _T("Second"), wxBITMAP(new));
- m_tbar->AddRadioTool(wxID_NEW, _T("Third"), wxBITMAP(new));
+ m_tbar->AddRadioTool(wxID_OPEN, _T("Second"), wxBITMAP(open));
+ m_tbar->AddRadioTool(wxID_SAVE, _T("Third"), wxBITMAP(save));
m_tbar->AddSeparator();
m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help));