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;
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
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();
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);
}
wxAboutBox(info);
}
-void MyFrame::UpdateUI(wxUpdateUIEvent& event)
+void MyFrame::OnCollapseUpdateUI(wxUpdateUIEvent& event)
{
- GetMenuBar()->Enable(PANE_COLLAPSE, !m_collPane->IsCollapsed());
- GetMenuBar()->Enable(PANE_EXPAND, m_collPane->IsCollapsed());
+ event.Enable(!m_collPane->IsCollapsed());
+}
+
+void MyFrame::OnExpandUpdateUI(wxUpdateUIEvent& event)
+{
+ event.Enable(m_collPane->IsCollapsed());
}
// now add test controls in the collapsible pane
wxWindow *win = m_collPane->GetPane();
- wxSizer *paneSz = new wxGridSizer(2, 2, 5, 5);
- paneSz->Add(new wxColourPickerCtrl(win, -1), 1, wxGROW|wxALL, 2);
- paneSz->Add(new wxFontPickerCtrl(win, -1), 1, wxGROW|wxALL, 2);
- paneSz->Add(new wxFilePickerCtrl(win, -1), 1, wxALL|wxALIGN_CENTER, 2);
- paneSz->Add(new wxDirPickerCtrl(win, -1), 1, wxALL|wxALIGN_CENTER, 2);
+ wxSizer *paneSz = new wxGridSizer(4, 1, 5, 5);
+ paneSz->Add(new wxColourPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
+ paneSz->Add(new wxFontPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
+ paneSz->Add(new wxFilePickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
+ paneSz->Add(new wxDirPickerCtrl(win, -1), 1, wxALL|wxALIGN_LEFT, 2);
win->SetSizer(paneSz);
paneSz->SetSizeHints(win);