From: Francesco Montorsi Date: Sun, 8 Feb 2009 21:34:02 +0000 (+0000) Subject: use a single update UI handler for all menu commands which act only on the default... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ea6e41e45e2f4c5a5503098393bb43fcff99afd9 use a single update UI handler for all menu commands which act only on the default status bar git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index ff9113fb19..a8b0c69a8a 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -174,9 +174,7 @@ private: } m_statbarKind; - void OnUpdateSetStatusTexts(wxUpdateUIEvent& event); - void OnUpdateResetFieldsWidth(wxUpdateUIEvent& event); - void OnUpdateSetStatusFields(wxUpdateUIEvent& event); + void OnUpdateForDefaultStatusbar(wxUpdateUIEvent& event); void OnUpdateStatusBarToggle(wxUpdateUIEvent& event); void OnUpdateSetStyleNormal(wxUpdateUIEvent& event); void OnUpdateSetStyleFlat(wxUpdateUIEvent& event); @@ -210,9 +208,11 @@ enum { // menu items StatusBar_Quit = 1, + StatusBar_SetFields, StatusBar_SetTexts, StatusBar_ResetFieldsWidth, + StatusBar_Recreate, StatusBar_About, StatusBar_Toggle, @@ -249,10 +249,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(StatusBar_SetStyleFlat, MyFrame::OnSetStyleFlat) EVT_MENU(StatusBar_SetStyleRaised, MyFrame::OnSetStyleRaised) - EVT_UPDATE_UI(StatusBar_ResetFieldsWidth, MyFrame::OnUpdateResetFieldsWidth) + EVT_UPDATE_UI_RANGE(StatusBar_SetFields, StatusBar_ResetFieldsWidth, + MyFrame::OnUpdateForDefaultStatusbar) EVT_UPDATE_UI(StatusBar_Toggle, MyFrame::OnUpdateStatusBarToggle) - EVT_UPDATE_UI(StatusBar_SetTexts, MyFrame::OnUpdateSetStatusTexts) - EVT_UPDATE_UI(StatusBar_SetFields, MyFrame::OnUpdateSetStatusFields) EVT_UPDATE_UI(StatusBar_SetStyleNormal, MyFrame::OnUpdateSetStyleNormal) EVT_UPDATE_UI(StatusBar_SetStyleFlat, MyFrame::OnUpdateSetStyleFlat) EVT_UPDATE_UI(StatusBar_SetStyleRaised, MyFrame::OnUpdateSetStyleRaised) @@ -421,10 +420,9 @@ void MyFrame::DoCreateStatusBar(MyFrame::StatBarKind kind) // main frame - event handlers // ---------------------------------------------------------------------------- -void MyFrame::OnUpdateSetStatusTexts(wxUpdateUIEvent& event) +void MyFrame::OnUpdateForDefaultStatusbar(wxUpdateUIEvent& event) { - // only allow the settings of the text of status fields for the default - // status bar + // only allow this feature for the default status bar wxStatusBar *sb = GetStatusBar(); event.Enable(sb == m_statbarDefault); } @@ -444,14 +442,6 @@ void MyFrame::OnSetStatusTexts(wxCommandEvent& WXUNUSED(event)) } } -void MyFrame::OnUpdateSetStatusFields(wxUpdateUIEvent& event) -{ - // only allow the settings of the number of status fields for the default - // status bar - wxStatusBar *sb = GetStatusBar(); - event.Enable(sb == m_statbarDefault); -} - void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event)) { wxStatusBar *sb = GetStatusBar(); @@ -510,14 +500,6 @@ void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event)) } } -void MyFrame::OnUpdateResetFieldsWidth(wxUpdateUIEvent& event) -{ - // only allow the settings of the number of status fields for the default - // status bar - wxStatusBar *sb = GetStatusBar(); - event.Enable(sb == m_statbarDefault); -} - void MyFrame::OnResetFieldsWidth(wxCommandEvent& WXUNUSED(event)) { wxStatusBar *pStat = GetStatusBar(); @@ -741,7 +723,11 @@ void MyStatusBar::OnSize(wxSizeEvent& event) #endif wxRect rect; - GetFieldRect(Field_Checkbox, rect); + if (!GetFieldRect(Field_Checkbox, rect)) + { + event.Skip(); + return; + } #if wxUSE_CHECKBOX m_checkbox->SetSize(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4);