X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1dd815f36321dc92f5b7a4db479a6b2e8a42d04f..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index e1a921006c..0cd2b4f593 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -314,6 +314,42 @@ private: DECLARE_EVENT_TABLE() }; +// a choice which handles focus set/kill (for testing) +class MyChoice : public wxChoice +{ +public: + MyChoice(wxWindow *parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxChoiceNameStr ) + : wxChoice(parent, id, pos, size, n, choices, + style, validator, name) { } + +protected: + void OnFocusGot(wxFocusEvent& event) + { + wxLogMessage(_T("MyChoice::OnFocusGot")); + + event.Skip(); + } + + void OnFocusLost(wxFocusEvent& event) + { + wxLogMessage(_T("MyChoice::OnFocusLost")); + + event.Skip(); + } + +private: + DECLARE_EVENT_TABLE() +}; + + + //---------------------------------------------------------------------- // other //---------------------------------------------------------------------- @@ -332,9 +368,9 @@ IMPLEMENT_APP(MyApp) enum { - CONTROLS_QUIT = 100, - CONTROLS_TEXT, - CONTROLS_ABOUT, + CONTROLS_QUIT = wxID_EXIT, + CONTROLS_ABOUT = wxID_ABOUT, + CONTROLS_TEXT = 100, CONTROLS_CLEAR_LOG, // tooltip menu @@ -538,6 +574,11 @@ BEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox) EVT_KILL_FOCUS(MyRadioBox::OnFocusLost) END_EVENT_TABLE() +BEGIN_EVENT_TABLE(MyChoice, wxChoice) + EVT_SET_FOCUS(MyChoice::OnFocusGot) + EVT_KILL_FOCUS(MyChoice::OnFocusLost) +END_EVENT_TABLE() + // ============================================================================ // implementation // ============================================================================ @@ -721,8 +762,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #if wxUSE_CHOICE panel = new wxPanel(m_book); - m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,wxDefaultCoord), 5, choices ); - m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,wxDefaultCoord), + m_choice = new MyChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,wxDefaultCoord), 5, choices ); + m_choiceSorted = new MyChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,wxDefaultCoord), 5, choices, wxCB_SORT ); SetChoiceClientData(wxT("choice"), m_choice); @@ -1512,7 +1553,7 @@ void MyPanel::OnSpinUpdate( wxSpinEvent &event ) m_text->AppendText(value); } -void MyPanel::OnNewText( wxCommandEvent &event ) +void MyPanel::OnNewText( wxCommandEvent& /* event */) { m_nonWrappingText->SetLabel( wxT("This text is short\nbut still spans\nover three lines.") ); m_wrappingText->SetLabel( wxT("This text is short but will still be wrapped if it is too long.") );