]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/combobox.cpp
removed the menu item which could be used to remove the icon and leave the user witho...
[wxWidgets.git] / samples / widgets / combobox.cpp
index d92a7989f1aa78882ec2f936d6dc832d855cae4f..6518ddd09f519452cc1ea5c2a241222900647b90 100644 (file)
@@ -41,6 +41,7 @@
 
 #include "wx/sizer.h"
 
+#include "itemcontainer.h"
 #include "widgets.h"
 #if 1
 #include "icons/combobox.xpm"
@@ -68,7 +69,10 @@ enum
     ComboPage_Delete,
     ComboPage_DeleteText,
     ComboPage_DeleteSel,
-    ComboPage_Combo
+    ComboPage_SetValue,
+    ComboPage_SetValueText,
+    ComboPage_Combo,
+    ComboPage_ContainerTests
 };
 
 // kinds of comboboxes
@@ -83,12 +87,13 @@ enum
 // ComboboxWidgetsPage
 // ----------------------------------------------------------------------------
 
-class ComboboxWidgetsPage : public WidgetsPage
+class ComboboxWidgetsPage : public ItemContainerWidgetsPage
 {
 public:
     ComboboxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
 
     virtual wxControl *GetWidget() const { return m_combobox; }
+    virtual wxItemContainer* GetContainer() const { return m_combobox; }
     virtual void RecreateWidget() { CreateCombo(); }
 
     // lazy creation of the content
@@ -105,6 +110,7 @@ protected:
     void OnButtonAdd(wxCommandEvent& event);
     void OnButtonAddSeveral(wxCommandEvent& event);
     void OnButtonAddMany(wxCommandEvent& event);
+    void OnButtonSetValue(wxCommandEvent& event);
     void OnButtonSetCurrent(wxCommandEvent& event);
 
     void OnComboBox(wxCommandEvent& event);
@@ -147,6 +153,7 @@ protected:
     wxTextCtrl *m_textInsert,
                *m_textAdd,
                *m_textChange,
+               *m_textSetValue,
                *m_textDelete,
                *m_textCur;
 
@@ -169,7 +176,9 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
     EVT_BUTTON(ComboPage_Add, ComboboxWidgetsPage::OnButtonAdd)
     EVT_BUTTON(ComboPage_AddSeveral, ComboboxWidgetsPage::OnButtonAddSeveral)
     EVT_BUTTON(ComboPage_AddMany, ComboboxWidgetsPage::OnButtonAddMany)
+    EVT_BUTTON(ComboPage_SetValue, ComboboxWidgetsPage::OnButtonSetValue)
     EVT_BUTTON(ComboPage_SetCurrent, ComboboxWidgetsPage::OnButtonSetCurrent)
+    EVT_BUTTON(ComboPage_ContainerTests, ItemContainerWidgetsPage::OnButtonTestItemContainer)
 
     EVT_TEXT_ENTER(ComboPage_InsertText, ComboboxWidgetsPage::OnButtonInsert)
     EVT_TEXT_ENTER(ComboPage_AddText, ComboboxWidgetsPage::OnButtonAdd)
@@ -212,7 +221,7 @@ IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"),
 
 ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
                                          wxImageList *imaglist)
-                  : WidgetsPage(book, imaglist, combobox_xpm)
+                  : ItemContainerWidgetsPage(book, imaglist, combobox_xpm)
 {
     // init everything
     m_chkSort =
@@ -320,6 +329,17 @@ void ComboboxWidgetsPage::CreateContent()
     btn = new wxButton(this, ComboPage_Clear, _T("&Clear"));
     sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
 
+    sizerRow = CreateSizerWithTextAndButton(ComboPage_SetValue,
+                                            _T("SetValue"),
+                                            ComboPage_SetValueText,
+                                            &m_textSetValue);
+    sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
+
+    btn = new wxButton(this, ComboPage_ContainerTests, _T("Run &tests"));
+    sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
+
+
+
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);
     m_combobox = new wxComboBox(this, ComboPage_Combo, wxEmptyString,
@@ -457,6 +477,12 @@ void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
     }
 }
 
+void ComboboxWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
+{
+    wxString value = m_textSetValue->GetValue();
+    m_combobox->SetValue( value );
+}
+
 void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
 {
     m_combobox->Clear();