X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/69bc65e3f8462f63785d7daa656d4e0d573004d8..935919963272d114cb46da3f7393b2e3a161c8b0:/samples/toolbar/toolbar.cpp diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 9fc57c6030..e1fdb33f7a 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -61,7 +61,7 @@ // ---------------------------------------------------------------------------- #if !defined(__WXMSW__) && !defined(__WXPM__) - #include "mondrian.xpm" + #include "../sample.xpm" #endif #if USE_XPM_BITMAPS @@ -543,7 +543,7 @@ MyFrame::MyFrame(wxFrame* parent, #endif // Give it an icon - SetIcon(wxICON(mondrian)); + SetIcon(wxICON(sample)); // Make a menubar wxMenu *tbarMenu = new wxMenu; @@ -627,6 +627,7 @@ MyFrame::MyFrame(wxFrame* parent, // Associate the menu bar with the frame SetMenuBar(menuBar); + menuBar->Check(IDM_TOOLBAR_TOGGLE_TOOLBAR, true); menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true); menuBar->Check(IDM_TOOLBAR_TOGGLETOOLTIPS, true); @@ -641,7 +642,7 @@ MyFrame::MyFrame(wxFrame* parent, m_extraToolBar = new wxToolBar(m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_TEXT|wxTB_FLAT|wxTB_TOP); PopulateToolbar(m_extraToolBar); #endif - + m_textWindow = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); @@ -705,9 +706,11 @@ void MyFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event)) } 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; - - SetToolBar(NULL); } } @@ -722,8 +725,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) { if ( m_tbar ) { - delete m_tbar; - m_tbar = NULL; + wxDELETE(m_tbar); } else {