]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/combobox.cpp
use wxDC::GetMultiLineTextExtent() instead of duplicating its code in wxButton::DoGet...
[wxWidgets.git] / samples / widgets / combobox.cpp
index 4fe53e9572ec0710e915fc2e49ff5ada36a30f40..72c4b023f123fbddc8d34dde7610d1ba98f8c063 100644 (file)
@@ -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);
@@ -543,6 +545,8 @@ 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& WXUNUSED(event))