X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/62f6be4448a1a8ba6b3ddc920df7c0957b7b1f31..33d8353fa58dbc66fc9d22fcd510ded6b26ce719:/samples/toolbar/toolbar.cpp diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 7d0a678acd..8f8da745bc 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -37,7 +37,7 @@ // 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__ +#ifdef __WINDOWS__ #define USE_XPM_BITMAPS 0 #else #define USE_XPM_BITMAPS 1 @@ -60,8 +60,8 @@ // resources // ---------------------------------------------------------------------------- -#if !defined(__WXMSW__) && !defined(__WXPM__) - #include "mondrian.xpm" +#ifndef wxHAS_IMAGES_IN_RESOURCES + #include "../sample.xpm" #endif #if USE_XPM_BITMAPS @@ -315,8 +315,6 @@ bool MyApp::OnInit() wxInitAllImageHandlers(); - SetTopWindow(frame); - return true; } @@ -496,7 +494,7 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) { // create a tool with a custom bitmap for testing wxImage img(m_pathBmp); - if ( img.Ok() ) + if ( img.IsOk() ) { if ( img.GetWidth() > w && img.GetHeight() > h ) img = img.GetSubImage(wxRect(0, 0, w, h)); @@ -510,7 +508,8 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) // the changes toolBar->Realize(); - toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows); + toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows + : m_rows); } // ---------------------------------------------------------------------------- @@ -543,7 +542,7 @@ MyFrame::MyFrame(wxFrame* parent, #endif // Give it an icon - SetIcon(wxICON(mondrian)); + SetIcon(wxICON(sample)); // Make a menubar wxMenu *tbarMenu = new wxMenu; @@ -642,7 +641,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); @@ -725,8 +724,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) { if ( m_tbar ) { - delete m_tbar; - m_tbar = NULL; + wxDELETE(m_tbar); } else { @@ -765,7 +763,9 @@ void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event)) // m_rows may be only 1 or 2 m_rows = 3 - m_rows; - GetToolBar()->SetRows(!(GetToolBar()->IsVertical()) ? m_rows : 10 / m_rows); + wxToolBar* const toolBar = GetToolBar(); + toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows + : m_rows); //RecreateToolbar(); -- this is unneeded } @@ -928,12 +928,12 @@ void MyFrame::OnChangeToolTip(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToolbarStyle(wxCommandEvent& event) { long style = GetToolBar()->GetWindowStyle(); - style &= ~(wxTB_NOICONS | wxTB_TEXT); + style &= ~(wxTB_NOICONS | wxTB_HORZ_TEXT); switch ( event.GetId() ) { case IDM_TOOLBAR_SHOW_TEXT: - style |= wxTB_NOICONS | wxTB_TEXT; + style |= wxTB_NOICONS | (m_horzText ? wxTB_HORZ_TEXT : wxTB_TEXT); break; case IDM_TOOLBAR_SHOW_ICONS: @@ -941,7 +941,7 @@ void MyFrame::OnToolbarStyle(wxCommandEvent& event) break; case IDM_TOOLBAR_SHOW_BOTH: - style |= wxTB_TEXT; + style |= (m_horzText ? wxTB_HORZ_TEXT : wxTB_TEXT); } GetToolBar()->SetWindowStyle(style);