X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/243dbf1a5088be31980df51b97831b52cb6986cd..c4e2838090992384911a6a6aa44cac985d79a555:/samples/widgets/combobox.cpp diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index 0fb153f667..72c4b023f1 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Program: wxWindows Widgets Sample +// Program: wxWidgets Widgets Sample // Name: combobox.cpp // Purpose: Part of the widgets sample showing wxComboBox // Author: Vadim Zeitlin @@ -84,7 +84,9 @@ enum class ComboboxWidgetsPage : public WidgetsPage { public: - ComboboxWidgetsPage(wxNotebook *notebook, wxImageList *imaglist); + ComboboxWidgetsPage(wxBookCtrl *book, wxImageList *imaglist); + + virtual wxControl *GetWidget() const { return m_combobox; } protected: // event handlers @@ -178,8 +180,8 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage) EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText) EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText) - EVT_CHECKBOX(-1, ComboboxWidgetsPage::OnCheckOrRadioBox) - EVT_RADIOBOX(-1, ComboboxWidgetsPage::OnCheckOrRadioBox) + EVT_CHECKBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox) + EVT_RADIOBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox) END_EVENT_TABLE() // ============================================================================ @@ -188,9 +190,9 @@ END_EVENT_TABLE() IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox")); -ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, - wxImageList *imaglist) - : WidgetsPage(notebook) +ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrl *book, + wxImageList *imaglist) + : WidgetsPage(book) { // init everything m_chkSort = @@ -210,7 +212,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); // left pane - wxStaticBox *box = new wxStaticBox(this, -1, _T("&Set style")); + wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style")); // should be in sync with ComboKind_XXX values static const wxString kinds[] = @@ -220,7 +222,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, _T("drop down"), }; - m_radioKind = new wxRadioBox(this, -1, _T("Combobox &kind:"), + m_radioKind = new wxRadioBox(this, wxID_ANY, _T("Combobox &kind:"), wxDefaultPosition, wxDefaultSize, WXSIZEOF(kinds), kinds, 1, wxRA_SPECIFY_COLS); @@ -237,7 +239,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); // middle pane - wxStaticBox *box2 = new wxStaticBox(this, -1, _T("&Change combobox contents")); + wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, + _T("&Change combobox contents")); wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL); wxSizer *sizerRow; @@ -246,7 +249,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, sizerRow = CreateSizerWithTextAndLabel(_T("Current selection"), ComboPage_CurText, &text); - text->SetEditable(FALSE); + text->SetEditable(false); sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5); @@ -288,7 +291,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, // right pane wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL); - m_combobox = new wxComboBox(this, ComboPage_Combo, _T(""), + m_combobox = new wxComboBox(this, ComboPage_Combo, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0); @@ -304,7 +307,6 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, // final initializations Reset(); - SetAutoLayout(TRUE); SetSizer(sizerTop); sizerTop->Fit(this); @@ -316,8 +318,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook, void ComboboxWidgetsPage::Reset() { - m_chkSort->SetValue(FALSE); - m_chkReadonly->SetValue(FALSE); + m_chkSort->SetValue(false); + m_chkReadonly->SetValue(false); } void ComboboxWidgetsPage::CreateCombo() @@ -360,7 +362,7 @@ void ComboboxWidgetsPage::CreateCombo() delete m_combobox; } - m_combobox = new wxComboBox(this, ComboPage_Combo, _T(""), + m_combobox = new wxComboBox(this, ComboPage_Combo, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, flags); @@ -420,12 +422,12 @@ void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event)) } } -void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event)) { m_combobox->Clear(); } -void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event)) { static unsigned int s_item = 0; @@ -440,7 +442,7 @@ void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event) m_combobox->Insert(s, m_combobox->GetSelection()); } -void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event)) { static unsigned int s_item = 0; @@ -463,7 +465,7 @@ void ComboboxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event)) } } -void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(event)) { m_combobox->Append(_T("First")); m_combobox->Append(_T("another one")); @@ -543,9 +545,11 @@ void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event) m_textDelete->SetValue(wxString::Format(_T("%ld"), sel)); wxLogMessage(_T("Combobox item %ld selected"), sel); + + wxLogMessage(_T("Combobox GetValue(): %s"), m_combobox->GetValue().c_str() ); } -void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateCombo(); }