virtual ~MyPanel();
void OnSize( wxSizeEvent& event );
+ void OnIdle( wxIdleEvent &event );
void OnListBox( wxCommandEvent &event );
void OnListBoxDoubleClick( wxCommandEvent &event );
void OnListBoxButtons( wxCommandEvent &event );
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
//----------------------------------------------------------------------
enum
{
- CONTROLS_QUIT = 100,
- CONTROLS_TEXT,
- CONTROLS_ABOUT,
+ CONTROLS_QUIT = wxID_EXIT,
+ CONTROLS_ABOUT = wxID_ABOUT,
+ CONTROLS_TEXT = 100,
CONTROLS_CLEAR_LOG,
// tooltip menu
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize)
+EVT_IDLE ( MyPanel::OnIdle)
EVT_BOOKCTRL_PAGE_CHANGING(ID_BOOK, MyPanel::OnPageChanging)
EVT_BOOKCTRL_PAGE_CHANGED(ID_BOOK, MyPanel::OnPageChanged)
EVT_LISTBOX (ID_LISTBOX, MyPanel::OnListBox)
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
// ============================================================================
#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);
#if wxUSE_SLIDER && wxUSE_GAUGE
panel = new wxPanel(m_book);
-
+
wxBoxSizer *main_sizer = new wxBoxSizer( wxHORIZONTAL );
panel->SetSizer( main_sizer );
-
+
wxStaticBoxSizer *gauge_sizer = new wxStaticBoxSizer( wxHORIZONTAL, panel, _T("&wxGauge and wxSlider") );
main_sizer->Add( gauge_sizer, 0, wxALL, 5 );
wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
m_slider->SetToolTip(_T("This is a sliding slider"));
#endif // wxUSE_TOOLTIPS
sz->Add( m_slider, 0, wxALL, 10 );
-
+
m_gaugeVert = new wxGauge( panel, wxID_ANY, 100,
wxDefaultPosition, wxSize(wxDefaultCoord, 90),
wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER );
if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
}
+void MyPanel::OnIdle(wxIdleEvent& event)
+{
+ static const int INVALID_SELECTION = -2;
+
+ static int s_selCombo = INVALID_SELECTION;
+ int sel = m_combo->GetSelection();
+ if ( sel != s_selCombo )
+ {
+ if ( s_selCombo != INVALID_SELECTION )
+ {
+ wxLogMessage(_T("EVT_IDLE: combobox selection changed from %d to %d"),
+ s_selCombo, sel);
+ }
+
+ s_selCombo = sel;
+ }
+
+ static int s_selChoice = INVALID_SELECTION;
+ sel = m_choice->GetSelection();
+ if ( sel != s_selChoice )
+ {
+ if ( s_selChoice != INVALID_SELECTION )
+ {
+ wxLogMessage(_T("EVT_IDLE: choice selection changed from %d to %d"),
+ s_selChoice, sel);
+ }
+
+ s_selChoice = sel;
+ }
+
+ event.Skip();
+}
+
void MyPanel::OnPageChanging( wxBookCtrlEvent &event )
{
int selOld = event.GetOldSelection();
void MyPanel::OnCombo( wxCommandEvent &event )
{
- m_text->AppendText( _T("ComboBox event selection string is: ") );
- m_text->AppendText( event.GetString() );
- m_text->AppendText( _T("\n") );
- m_text->AppendText( _T("ComboBox control selection string is: ") );
- m_text->AppendText( m_combo->GetStringSelection() );
- m_text->AppendText( _T("\n") );
+ wxLogMessage(_T("EVT_COMBOBOX: item %d/%d (event/control), string \"%s\"/\"%s\""),
+ (int)event.GetInt(),
+ m_combo->GetSelection(),
+ event.GetString().c_str(),
+ m_combo->GetStringSelection().c_str());
}
void MyPanel::OnComboTextChanged(wxCommandEvent& event)
{
- wxString str;
- str.Printf( wxT("Text in the combobox changed: now is '%s'."),
- event.GetString().c_str() );
- wxLogMessage( str.c_str() );
+ wxLogMessage(wxT("EVT_TEXT for the combobox: \"%s\" (event) or \"%s\" (control)."),
+ event.GetString().c_str(),
+ m_combo->GetValue().c_str());
}
void MyPanel::OnComboTextEnter(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
+ SetSize(800, 600);
+#if 0
wxBusyCursor bc;
wxMessageDialog dialog(this, _T("This is a control sample"), _T("About Controls"), wxOK );
dialog.ShowModal();
+#endif
}
void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))