X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3bf4189d96db28d4e13d9c4d6e94f7492baccb1d..c4e2838090992384911a6a6aa44cac985d79a555:/samples/toolbar/toolbar.cpp diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 507af20593..747a49f142 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -88,7 +88,7 @@ class MyFrame: public wxFrame { public: MyFrame(wxFrame *parent, - wxWindowID id = -1, + wxWindowID id = wxID_ANY, const wxString& title = _T("wxToolBar Sample"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -119,6 +119,7 @@ public: void OnToolbarStyle(wxCommandEvent& event); void OnToolLeftClick(wxCommandEvent& event); + void OnToolRightClick(wxCommandEvent& event); void OnToolEnter(wxCommandEvent& event); void OnCombo(wxCommandEvent& event); @@ -223,11 +224,12 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU_RANGE(IDM_TOOLBAR_SHOW_TEXT, IDM_TOOLBAR_SHOW_BOTH, MyFrame::OnToolbarStyle) - EVT_MENU(-1, MyFrame::OnToolLeftClick) + EVT_MENU(wxID_ANY, MyFrame::OnToolLeftClick) EVT_COMBOBOX(ID_COMBO, MyFrame::OnCombo) EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter) + EVT_TOOL_RCLICKED(wxID_ANY, MyFrame::OnToolRightClick) EVT_UPDATE_UI(wxID_COPY, MyFrame::OnUpdateCopyAndCut) EVT_UPDATE_UI(wxID_CUT, MyFrame::OnUpdateCopyAndCut) @@ -254,22 +256,24 @@ IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { // Create the main frame window - MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, + MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY, _T("wxToolBar Sample"), #ifdef __WXWINCE__ - wxPoint(0, 0), wxDefaultSize, wxNO_BORDER + wxDefaultPosition, wxDefaultSize #else wxPoint(100, 100), wxSize(550, 300) #endif ); - frame->Show(TRUE); + frame->Show(true); - frame->SetStatusText(_T("Hello, wxWindows")); +#if wxUSE_STATUSBAR + frame->SetStatusText(_T("Hello, wxWidgets")); +#endif SetTopWindow(frame); - return TRUE; + return true; } void MyFrame::RecreateToolbar() @@ -277,7 +281,7 @@ void MyFrame::RecreateToolbar() #ifdef __WXWINCE__ // On Windows CE, we should not delete the // previous toolbar in case it contains the menubar. - // We'll try to accomodate this usage in due course. + // We'll try to accommodate this usage in due course. wxToolBar* toolBar = CreateToolBar(); #else // delete and recreate the toolbar @@ -341,7 +345,7 @@ void MyFrame::RecreateToolbar() // adding a combo to a vertical toolbar is not very smart if ( m_horzToolbar ) { - wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, _T(""), wxDefaultPosition, wxSize(200,-1) ); + wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO, _T(""), wxDefaultPosition, wxSize(200,wxDefaultCoord) ); combo->Append(_T("This")); combo->Append(_T("is a")); combo->Append(_T("combobox")); @@ -380,15 +384,14 @@ MyFrame::MyFrame(wxFrame* parent, : wxFrame(parent, id, title, pos, size, style) { m_tbar = NULL; - m_textWindow = new wxTextCtrl(this, -1, _T(""), wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE); - m_smallToolbar = TRUE; - m_horzToolbar = TRUE; - m_horzText = FALSE; + m_smallToolbar = true; + m_horzToolbar = true; + m_horzText = false; m_rows = 1; m_nPrint = 1; -#ifndef __WXWINCE__ +#if wxUSE_STATUSBAR // Give it a status line CreateStatusBar(); #endif @@ -454,10 +457,12 @@ MyFrame::MyFrame(wxFrame* parent, // Associate the menu bar with the frame SetMenuBar(menuBar); - menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, TRUE); + menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, true); // Create the toolbar RecreateToolbar(); + + m_textWindow = new wxTextCtrl(this, wxID_ANY, _T(""), wxPoint(0, 0), wxDefaultSize, wxTE_MULTILINE); } #if USE_GENERIC_TBAR @@ -480,7 +485,7 @@ void MyFrame::LayoutChildren() int offset; if ( m_tbar ) { - m_tbar->SetSize(-1, size.y); + m_tbar->SetSize(wxDefaultCoord, size.y); m_tbar->Move(0, 0); offset = m_tbar->GetSize().x; @@ -541,7 +546,7 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event)) style &= ~wxTB_HORIZONTAL; style |= wxTB_VERTICAL; - m_tbar = new wxToolBar(this, -1, + m_tbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style); @@ -585,7 +590,7 @@ void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { - Close(TRUE); + Close(true); } void MyFrame::OnAbout(wxCommandEvent& event) @@ -595,7 +600,7 @@ void MyFrame::OnAbout(wxCommandEvent& event) else m_textWindow->WriteText( _T("Help button up now.\n") ); - (void)wxMessageBox(_T("wxWindows toolbar sample"), _T("About wxToolBar")); + (void)wxMessageBox(_T("wxWidgets toolbar sample"), _T("About wxToolBar")); } void MyFrame::OnToolLeftClick(wxCommandEvent& event) @@ -620,6 +625,13 @@ void MyFrame::OnToolLeftClick(wxCommandEvent& event) } } +void MyFrame::OnToolRightClick(wxCommandEvent& event) +{ + m_textWindow->AppendText( + wxString::Format(_T("Tool %d right clicked.\n"), + (int) event.GetInt())); +} + void MyFrame::OnCombo(wxCommandEvent& event) { wxLogStatus(_T("Combobox string '%s' selected"), event.GetString().c_str()); @@ -708,6 +720,7 @@ void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToolEnter(wxCommandEvent& event) { +#if wxUSE_STATUSBAR if (event.GetSelection() > -1) { wxString str; @@ -716,6 +729,9 @@ void MyFrame::OnToolEnter(wxCommandEvent& event) } else SetStatusText(_T("")); +#else + wxUnusedVar(event); +#endif // wxUSE_STATUSBAR } void MyFrame::OnToggleRadioBtn(wxCommandEvent& event)