X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1301e2289f81208bdd2cb1ac92a0d13c3d0959c4..a0ef88bde8e4e0b9f6268b9b0001eb6b6beca708:/samples/widgets/combobox.cpp diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index d3e703bea4..2ac76337af 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -52,7 +52,7 @@ // control ids enum { - ComboPage_Reset = 100, + ComboPage_Reset = wxID_HIGHEST, ComboPage_CurText, ComboPage_InsertionPointText, ComboPage_Insert, @@ -85,11 +85,14 @@ enum class ComboboxWidgetsPage : public WidgetsPage { public: - ComboboxWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist); + ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist); virtual wxControl *GetWidget() const { return m_combobox; } virtual void RecreateWidget() { CreateCombo(); } + // lazy creation of the content + virtual void CreateContent(); + protected: // event handlers void OnButtonReset(wxCommandEvent& event); @@ -192,11 +195,19 @@ END_EVENT_TABLE() // implementation // ============================================================================ -IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox")); +#if defined(__WXUNIVERSAL__) + #define FAMILY_CTRLS UNIVERSAL_CTRLS +#else + #define FAMILY_CTRLS NATIVE_CTRLS +#endif + +IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"), + FAMILY_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS + ); -ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book, +ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, combobox_xpm) { // init everything m_chkSort = @@ -204,9 +215,10 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book, m_combobox = (wxComboBox *)NULL; m_sizerCombo = (wxSizer *)NULL; +} - imaglist->Add(wxBitmap(combobox_xpm)); - +void ComboboxWidgetsPage::CreateContent() +{ /* What we create here is a frame having 3 panes: style pane is the leftmost one, in the middle the pane with buttons allowing to perform @@ -402,7 +414,7 @@ void ComboboxWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event)) { int sel = m_combobox->GetSelection(); - if ( sel != -1 ) + if ( sel != wxNOT_FOUND ) { #ifndef __WXGTK__ m_combobox->SetString(sel, m_textChange->GetValue()); @@ -525,7 +537,7 @@ void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event) void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event) { if (m_combobox) - event.Enable(m_combobox->GetSelection() != -1); + event.Enable(m_combobox->GetSelection() != wxNOT_FOUND); } void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)