]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/searchctrl.cpp
The alignment controls are now left-aligned if the floating controls are not shown.
[wxWidgets.git] / samples / widgets / searchctrl.cpp
index 97a95881031398e95c902f63f067d0031e6bf414..32739204796f271033c626ff678fd9d048eae290 100644 (file)
@@ -4,7 +4,6 @@
 // Purpose:     Shows wxSearchCtrl
 // Author:      Robin Dunn
 // Created:     9-Dec-2006
-// Id:          $Id$
 // Copyright:   (c) 2006
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -73,7 +72,7 @@ public:
 
     virtual wxControl *GetWidget() const { return m_srchCtrl; }
     virtual wxTextEntryBase *GetTextEntry() const { return m_srchCtrl; }
-    virtual void RecreateWidget() { CreateControl(); }
+    virtual void RecreateWidget();
 
     // lazy creation of the content
     virtual void CreateContent();
@@ -85,6 +84,7 @@ protected:
     void OnToggleSearchMenu(wxCommandEvent&);
 
     void OnSearch(wxCommandEvent& event);
+    void OnSearchCancel(wxCommandEvent& event);
 
     wxMenu* CreateTestMenu();
 
@@ -112,6 +112,7 @@ BEGIN_EVENT_TABLE(SearchCtrlWidgetsPage, WidgetsPage)
     EVT_CHECKBOX(ID_MENU_CB, SearchCtrlWidgetsPage::OnToggleSearchMenu)
 
     EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, SearchCtrlWidgetsPage::OnSearch)
+    EVT_SEARCHCTRL_CANCEL_BTN(wxID_ANY, SearchCtrlWidgetsPage::OnSearchCancel)
 END_EVENT_TABLE()
 
 // ============================================================================
@@ -172,6 +173,14 @@ void SearchCtrlWidgetsPage::CreateControl()
                                   wxSize(150, -1), style);
 }
 
+void SearchCtrlWidgetsPage::RecreateWidget()
+{
+    CreateControl();
+
+    GetSizer()->Add(m_srchCtrl, wxSizerFlags().Centre().TripleBorder());
+
+    Layout();
+}
 
 wxMenu* SearchCtrlWidgetsPage::CreateTestMenu()
 {
@@ -188,7 +197,7 @@ wxMenu* SearchCtrlWidgetsPage::CreateTestMenu()
 //     target->Connect(
 //         ID_SEARCHMENU,
 //         ID_SEARCHMENU+SEARCH_MENU_SIZE,
-//         wxEVT_COMMAND_MENU_SELECTED,
+//         wxEVT_MENU,
 //         wxCommandEventHandler(MySearchCtrl::OnSearchMenu)
 //         );
     return menu;
@@ -223,4 +232,11 @@ void SearchCtrlWidgetsPage::OnSearch(wxCommandEvent& event)
     wxLogMessage("Search button: search for \"%s\".", event.GetString());
 }
 
+void SearchCtrlWidgetsPage::OnSearchCancel(wxCommandEvent& event)
+{
+    wxLogMessage("Cancel button pressed.");
+
+    event.Skip();
+}
+
 #endif  //  wxUSE_SEARCHCTRL