X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/912c39325bfc8e9625d79d9114f67eb8d68326ce..30386aeb867e0b6311450a87c056c42301765a65:/samples/collpane/collpane.cpp?ds=inline diff --git a/samples/collpane/collpane.cpp b/samples/collpane/collpane.cpp index 4d535eef94..74ea1e83c9 100644 --- a/samples/collpane/collpane.cpp +++ b/samples/collpane/collpane.cpp @@ -88,8 +88,9 @@ public: void Quit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); - // Menu command update functions - void UpdateUI(wxUpdateUIEvent& event); + // UI update handlers + void OnCollapseUpdateUI(wxUpdateUIEvent& event); + void OnExpandUpdateUI(wxUpdateUIEvent& event); private: wxCollapsiblePane *m_collPane; @@ -126,6 +127,9 @@ IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + // create and show the main frame MyFrame* frame = new MyFrame; @@ -146,7 +150,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(PANE_ABOUT, MyFrame::OnAbout) EVT_MENU(PANE_QUIT, MyFrame::Quit) - EVT_UPDATE_UI(wxID_ANY, MyFrame::UpdateUI) + EVT_UPDATE_UI(PANE_COLLAPSE, MyFrame::OnCollapseUpdateUI) + EVT_UPDATE_UI(PANE_EXPAND, MyFrame::OnExpandUpdateUI) END_EVENT_TABLE() // My frame constructor @@ -164,7 +169,7 @@ MyFrame::MyFrame() paneMenu->Append(PANE_COLLAPSE, _T("Collapse\tCtrl-C")); paneMenu->Append(PANE_EXPAND, _T("Expand\tCtrl-E")); paneMenu->AppendSeparator(); - paneMenu->Append(PANE_SETLABEL, _T("Set label...\tCtrl-S")); + paneMenu->Append(PANE_SETLABEL, _T("Set label...\tCtrl-L")); paneMenu->AppendSeparator(); paneMenu->Append(PANE_SHOWDLG, _T("Show dialog...\tCtrl-S")); paneMenu->AppendSeparator(); @@ -210,7 +215,12 @@ void MyFrame::OnExpand(wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnSetLabel(wxCommandEvent& WXUNUSED(event) ) { - wxString text = wxGetTextFromUser(wxT("Input the new label")); + wxString text = wxGetTextFromUser + ( + wxT("Enter new label"), + wxGetTextFromUserPromptStr, + m_collPane->GetLabel() + ); m_collPane->SetLabel(text); } @@ -230,10 +240,14 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) ) wxAboutBox(info); } -void MyFrame::UpdateUI(wxUpdateUIEvent& event) +void MyFrame::OnCollapseUpdateUI(wxUpdateUIEvent& event) +{ + event.Enable(!m_collPane->IsCollapsed()); +} + +void MyFrame::OnExpandUpdateUI(wxUpdateUIEvent& event) { - GetMenuBar()->Enable(PANE_COLLAPSE, !m_collPane->IsCollapsed()); - GetMenuBar()->Enable(PANE_EXPAND, m_collPane->IsCollapsed()); + event.Enable(m_collPane->IsCollapsed()); }