MyPanel(wxFrame *frame, int x, int y, int w, int h);
virtual ~MyPanel();
- void OnSize( wxSizeEvent& event );
void OnIdle( wxIdleEvent &event );
void OnListBox( wxCommandEvent &event );
void OnListBoxDoubleClick( wxCommandEvent &event );
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
: wxRadioBox(parent, id, title, pos, size, n, choices, majorDim,
- style, validator, name) { SetForegroundColour(*wxRED); }
+ style, validator, name)
+ {
+ }
protected:
void OnFocusGot(wxFocusEvent& event)
const int ID_SIZER_CHECKBIG = 206;
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)
m_text = new wxTextCtrl(this, wxID_ANY, _T("This is the log window.\n"),
wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
- m_text->SetBackgroundColour(wxT("wheat"));
m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
wxButton *button = new MyButton( panel, ID_LISTBOX_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
button->SetDefault();
- button->SetForegroundColour(*wxBLUE);
#if wxUSE_TOOLTIPS
button->SetToolTip( _T("Press here to set italic font") );
SetChoiceClientData(wxT("choice"), m_choiceSorted);
m_choice->SetSelection(2);
- m_choice->SetBackgroundColour( wxT("red") );
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_SEL_STR, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_CLEAR, _T("&Clear"), wxPoint(180,80), wxSize(140,30) );
m_combo = new MyComboBox( panel, ID_COMBO, _T("This"),
wxPoint(20,25), wxSize(120, wxDefaultCoord),
5, choices,
- wxCB_READONLY | wxPROCESS_ENTER);
- m_combo->SetBackgroundColour(*wxBLUE);
+ wxTE_PROCESS_ENTER);
(void)new wxButton( panel, ID_COMBO_SEL_NUM, _T("Select #&2"), wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_SEL_STR, _T("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
panel = new wxPanel(m_book);
(void)new MyRadioBox( panel, ID_RADIOBOX, _T("&That"), wxPoint(10,160), wxDefaultSize, WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
m_radio = new wxRadioBox( panel, ID_RADIOBOX, _T("T&his"), wxPoint(10,10), wxDefaultSize, WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS );
- m_radio->SetForegroundColour(*wxRED);
#if wxUSE_TOOLTIPS
m_combo->SetToolTip(_T("This is a natural\ncombobox - can you believe me?"));
m_fontButton = new wxButton( panel, ID_SET_FONT, _T("Set &more Italic font"), wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_FONT, _T("Set &Italic font"), wxPoint(340,80), wxSize(140,30) );
(void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, _T("&Disable"), wxPoint(340,130), wxDefaultSize );
+
wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, _T("Radiobutton1"), wxPoint(210,170), wxDefaultSize, wxRB_GROUP );
rb->SetValue( false );
(void)new wxRadioButton( panel, ID_RADIOBUTTON_2, _T("&Radiobutton2"), wxPoint(340,170), wxDefaultSize );
wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
gauge_sizer->Add( sz );
m_gauge = new wxGauge( panel, wxID_ANY, 200, wxDefaultPosition, wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER );
- m_gauge->SetBackgroundColour(*wxGREEN);
- m_gauge->SetForegroundColour(*wxRED);
sz->Add( m_gauge, 0, wxALL, 10 );
m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200,
wxDefaultPosition, wxSize(155,wxDefaultCoord),
panel->SetSizer( sizer );
m_book->AddPage(panel, _T("wxSizer"));
-}
-void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
-{
- int x = 0;
- int y = 0;
- GetClientSize( &x, &y );
-
- if (m_book) m_book->SetSize( 2, 2, x-4, y*2/3-4 );
- if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
+ // set the sizer for the panel itself
+ sizer = new wxBoxSizer(wxVERTICAL);
+ sizer->Add(m_book, wxSizerFlags().Border().Expand());
+ sizer->Add(m_text, wxSizerFlags(1).Border().Expand());
+ SetSizer(sizer);
}
void MyPanel::OnIdle(wxIdleEvent& event)
}
#if wxUSE_CHOICE
+
+static const wxChar *GetDataString(wxClientData *data)
+{
+ return data ? wx_static_cast(wxStringClientData *, data)->GetData().c_str()
+ : _T("none");
+}
+
void MyPanel::OnChoice( wxCommandEvent &event )
{
wxChoice *choice = event.GetId() == ID_CHOICE ? m_choice
: m_choiceSorted;
- m_text->AppendText( _T("Choice event selection string is: '") );
- m_text->AppendText( event.GetString() );
- m_text->AppendText( _T("'\n") );
- m_text->AppendText( _T("Choice control selection string is: '") );
- m_text->AppendText( choice->GetStringSelection() );
- m_text->AppendText( _T("'\n") );
-
- wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
- m_text->AppendText( _T("Choice event client data string is: '") );
+ const int sel = choice->GetSelection();
- if (obj)
- m_text->AppendText( obj->GetData() );
- else
- m_text->AppendText( wxString(_T("none")) );
+ wxClientData *dataEvt = event.GetClientObject(),
+ *dataCtrl = choice->GetClientObject(sel);
- m_text->AppendText( _T("'\n") );
- m_text->AppendText( _T("Choice control client data string is: '") );
- obj = (wxStringClientData *)choice->GetClientObject(choice->GetSelection());
-
- if (obj)
- m_text->AppendText( obj->GetData() );
- else
- m_text->AppendText( wxString(_T("none")) );
- m_text->AppendText( _T("'\n") );
+ wxLogMessage(_T("EVT_CHOICE: item %d/%d (event/control), ")
+ _T("string \"%s\"/\"%s\", ")
+ _T("data \"%s\"/\"%s\""),
+ (int)event.GetInt(),
+ sel,
+ event.GetString().c_str(),
+ choice->GetStringSelection().c_str(),
+ GetDataString(dataEvt),
+ GetDataString(dataCtrl));
}
void MyPanel::OnChoiceButtons( wxCommandEvent &event )
switch (event.GetId())
{
case ID_RADIOBOX_ENABLE:
- {
- m_radio->Enable( event.GetInt() == 0 );
- break;
- }
+ m_radio->Enable( event.GetInt() == 0 );
+ break;
+
case ID_RADIOBOX_SEL_NUM:
- {
- m_radio->SetSelection( 2 );
- break;
- }
+ m_radio->SetSelection( 2 );
+ break;
+
case ID_RADIOBOX_SEL_STR:
- {
- m_radio->SetStringSelection( _T("This") );
- break;
- }
- case ID_RADIOBOX_FONT:
- {
- m_radio->SetForegroundColour(*wxGREEN);
+ m_radio->SetStringSelection( _T("This") );
+ break;
- m_radio->SetFont( *wxITALIC_FONT );
- break;
- }
+ case ID_RADIOBOX_FONT:
+ m_radio->SetFont( *wxITALIC_FONT );
+ break;
}
}