X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1301e2289f81208bdd2cb1ac92a0d13c3d0959c4..a97d569cbbf90ba8bb293214055c3a8c19d447b5:/samples/widgets/combobox.cpp?ds=sidebyside diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index d3e703bea4..5485a1b09f 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); @@ -131,7 +134,8 @@ protected: // the checkboxes for styles wxCheckBox *m_chkSort, - *m_chkReadonly; + *m_chkReadonly, + *m_chkFilename; // the combobox itself and the sizer it is in wxComboBox *m_combobox; @@ -192,21 +196,31 @@ 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 -ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book, +IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"), + FAMILY_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS + ); + +ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) - : WidgetsPage(book) + : WidgetsPage(book, imaglist, combobox_xpm) { // init everything m_chkSort = - m_chkReadonly = (wxCheckBox *)NULL; + m_chkReadonly = + m_chkFilename = (wxCheckBox *)NULL; 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 @@ -235,6 +249,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book, m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Sort items")); m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Read only")); + m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&File name")); + m_chkFilename->Disable(); // not implemented yet sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5); @@ -306,7 +322,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book, wxDefaultPosition, wxDefaultSize, 0, NULL, 0); - sizerRight->Add(m_combobox, 1, wxGROW | wxALL, 5); + sizerRight->Add(m_combobox, 0, wxGROW | wxALL, 5); sizerRight->SetMinSize(150, 0); m_sizerCombo = sizerRight; // save it to modify it later @@ -331,6 +347,7 @@ void ComboboxWidgetsPage::Reset() { m_chkSort->SetValue(false); m_chkReadonly->SetValue(false); + m_chkFilename->SetValue(false); } void ComboboxWidgetsPage::CreateCombo() @@ -378,6 +395,11 @@ void ComboboxWidgetsPage::CreateCombo() 0, NULL, flags); +#if 0 + if ( m_chkFilename->GetValue() ) + ; +#endif // TODO + unsigned int count = items.GetCount(); for ( unsigned int n = 0; n < count; n++ ) { @@ -402,7 +424,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()); @@ -497,8 +519,9 @@ void ComboboxWidgetsPage::OnUpdateUIInsertionPointText(wxUpdateUIEvent& event) void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) { - if (m_combobox) - event.Enable( m_chkSort->GetValue() || m_chkReadonly->GetValue() ); + event.Enable( m_chkSort->GetValue() || + m_chkReadonly->GetValue() || + m_chkFilename->GetValue() ); } void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event) @@ -525,7 +548,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)