]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/combobox.cpp
Use template class instead of template function in wxVectorSort().
[wxWidgets.git] / samples / widgets / combobox.cpp
index 58bcf7ce4d4854f080605d5149989ec158287af1..32d3642b246fb47631c0b66f65c855bf0e3d8d03 100644 (file)
@@ -43,7 +43,6 @@
 
 #include "itemcontainer.h"
 #include "widgets.h"
 
 #include "itemcontainer.h"
 #include "widgets.h"
-#if 1
 #include "icons/combobox.xpm"
 
 // ----------------------------------------------------------------------------
 #include "icons/combobox.xpm"
 
 // ----------------------------------------------------------------------------
@@ -54,6 +53,8 @@
 enum
 {
     ComboPage_Reset = wxID_HIGHEST,
 enum
 {
     ComboPage_Reset = wxID_HIGHEST,
+    ComboPage_Popup,
+    ComboPage_Dismiss,
     ComboPage_SetCurrent,
     ComboPage_CurText,
     ComboPage_InsertionPointText,
     ComboPage_SetCurrent,
     ComboPage_CurText,
     ComboPage_InsertionPointText,
@@ -103,6 +104,8 @@ public:
 protected:
     // event handlers
     void OnButtonReset(wxCommandEvent& event);
 protected:
     // event handlers
     void OnButtonReset(wxCommandEvent& event);
+    void OnButtonPopup(wxCommandEvent&) { m_combobox->Popup(); }
+    void OnButtonDismiss(wxCommandEvent&) { m_combobox->Dismiss(); }
     void OnButtonChange(wxCommandEvent& event);
     void OnButtonDelete(wxCommandEvent& event);
     void OnButtonDeleteSel(wxCommandEvent& event);
     void OnButtonChange(wxCommandEvent& event);
     void OnButtonDelete(wxCommandEvent& event);
     void OnButtonDeleteSel(wxCommandEvent& event);
@@ -171,6 +174,8 @@ private:
 
 BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
     EVT_BUTTON(ComboPage_Reset, ComboboxWidgetsPage::OnButtonReset)
 
 BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
     EVT_BUTTON(ComboPage_Reset, ComboboxWidgetsPage::OnButtonReset)
+    EVT_BUTTON(ComboPage_Popup, ComboboxWidgetsPage::OnButtonPopup)
+    EVT_BUTTON(ComboPage_Dismiss, ComboboxWidgetsPage::OnButtonDismiss)
     EVT_BUTTON(ComboPage_Change, ComboboxWidgetsPage::OnButtonChange)
     EVT_BUTTON(ComboPage_Delete, ComboboxWidgetsPage::OnButtonDelete)
     EVT_BUTTON(ComboPage_DeleteSel, ComboboxWidgetsPage::OnButtonDeleteSel)
     EVT_BUTTON(ComboPage_Change, ComboboxWidgetsPage::OnButtonChange)
     EVT_BUTTON(ComboPage_Delete, ComboboxWidgetsPage::OnButtonDelete)
     EVT_BUTTON(ComboPage_DeleteSel, ComboboxWidgetsPage::OnButtonDeleteSel)
@@ -247,8 +252,7 @@ void ComboboxWidgetsPage::CreateContent()
     */
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     */
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
-    // left pane
-    wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("&Set style"));
+    // upper left pane
 
     // should be in sync with ComboKind_XXX values
     static const wxString kinds[] =
 
     // should be in sync with ComboKind_XXX values
     static const wxString kinds[] =
@@ -263,18 +267,31 @@ void ComboboxWidgetsPage::CreateContent()
                                  WXSIZEOF(kinds), kinds,
                                  1, wxRA_SPECIFY_COLS);
 
                                  WXSIZEOF(kinds), kinds,
                                  1, wxRA_SPECIFY_COLS);
 
-    wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
+    wxSizer *sizerLeftTop = new wxStaticBoxSizer(wxVERTICAL, this, "&Set style");
 
 
-    m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Sort items"));
-    m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Read only"));
-    m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&File name"));
+    m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Sort items"));
+    m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Read only"));
+    m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&File name"));
     m_chkFilename->Disable(); // not implemented yet
 
     m_chkFilename->Disable(); // not implemented yet
 
-    sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
-    sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
+    sizerLeftTop->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
+    sizerLeftTop->Add(m_radioKind, 0, wxGROW | wxALL, 5);
 
     wxButton *btn = new wxButton(this, ComboPage_Reset, wxT("&Reset"));
 
     wxButton *btn = new wxButton(this, ComboPage_Reset, wxT("&Reset"));
-    sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
+    sizerLeftTop->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
+
+    // lower left pane
+    wxSizer *sizerLeftBottom = new wxStaticBoxSizer(wxVERTICAL, this, "&Popup");
+    sizerLeftBottom->Add(new wxButton(this, ComboPage_Popup, "&Show"),
+                         wxSizerFlags().Border().Centre());
+    sizerLeftBottom->Add(new wxButton(this, ComboPage_Dismiss, "&Hide"),
+                         wxSizerFlags().Border().Centre());
+
+
+    wxSizer *sizerLeft = new wxBoxSizer(wxVERTICAL);
+    sizerLeft->Add(sizerLeftTop);
+    sizerLeft->AddSpacer(10);
+    sizerLeft->Add(sizerLeftBottom);
 
     // middle pane
     wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
 
     // middle pane
     wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
@@ -654,6 +671,4 @@ void ComboboxWidgetsPage::OnCloseup(wxCommandEvent& WXUNUSED(event))
     wxLogMessage(wxT("Combobox closed up"));
 }
 
     wxLogMessage(wxT("Combobox closed up"));
 }
 
-#endif //wxUSE_COMBOBOX
-
-#endif
+#endif // wxUSE_COMBOBOX