From f0fa4312b1a537189ada21bec53cff5618e6660b Mon Sep 17 00:00:00 2001
From: =?utf8?q?W=C5=82odzimierz=20Skiba?= <abx@abx.art.pl>
Date: Mon, 22 May 2006 10:39:40 +0000
Subject: [PATCH] Continuation of 'widgets' sample improvements.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39265 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 samples/widgets/button.cpp   |  11 +---
 samples/widgets/checkbox.cpp |  12 ++--
 samples/widgets/combobox.cpp |  11 +++-
 samples/widgets/datepick.cpp |   9 ++-
 samples/widgets/gauge.cpp    |  12 ++--
 samples/widgets/listbox.cpp  |  11 +++-
 samples/widgets/notebook.cpp | 123 +++++++++++++++++++++++++----------
 samples/widgets/radiobox.cpp |  11 +++-
 samples/widgets/slider.cpp   |  10 ++-
 samples/widgets/spinbtn.cpp  |  11 +++-
 samples/widgets/static.cpp   |   2 +-
 samples/widgets/textctrl.cpp |  13 +++-
 12 files changed, 162 insertions(+), 74 deletions(-)

diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp
index 805126fef1..1c2304b364 100644
--- a/samples/widgets/button.cpp
+++ b/samples/widgets/button.cpp
@@ -52,7 +52,7 @@
 // control ids
 enum
 {
-    ButtonPage_Reset = 100,
+    ButtonPage_Reset = wxID_HIGHEST,
     ButtonPage_ChangeLabel,
     ButtonPage_Button
 };
@@ -156,15 +156,8 @@ END_EVENT_TABLE()
 
 #if defined(__WXUNIVERSAL__)
     #define FAMILY_CTRLS UNIVERSAL_CTRLS
-#elif defined(__WXMSW__)    || \
-      defined(__WXMOTIF__)  || \
-      defined(__WXGTK__)    || \
-      defined(__WXMAC__)    || \
-      defined(__WXPM__)     || \
-      defined(__WXPALMOS__)
-    #define FAMILY_CTRLS NATIVE_CTRLS
 #else
-    #define FAMILY_CTRLS GENERIC_CTRLS
+    #define FAMILY_CTRLS NATIVE_CTRLS
 #endif
 
 IMPLEMENT_WIDGETS_PAGE(ButtonWidgetsPage, _T("Button"), FAMILY_CTRLS );
diff --git a/samples/widgets/checkbox.cpp b/samples/widgets/checkbox.cpp
index c683f6774c..375a7a370f 100644
--- a/samples/widgets/checkbox.cpp
+++ b/samples/widgets/checkbox.cpp
@@ -50,7 +50,7 @@
 // control ids
 enum
 {
-    CheckboxPage_Reset = 100,
+    CheckboxPage_Reset = wxID_HIGHEST,
     CheckboxPage_ChangeLabel,
     CheckboxPage_Check,
     CheckboxPage_Uncheck,
@@ -148,9 +148,13 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       );
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"), FAMILY_CTRLS );
 
 CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book,
                                          wxImageList *imaglist)
diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp
index 04c4214933..aa9a6a8a05 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,
@@ -192,9 +192,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | WITH_ITEMS_CTRLS | COMBO_CTRLS
+                       FAMILY_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS
                        );
 
 ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
diff --git a/samples/widgets/datepick.cpp b/samples/widgets/datepick.cpp
index b9aab44eeb..9babbf8c02 100644
--- a/samples/widgets/datepick.cpp
+++ b/samples/widgets/datepick.cpp
@@ -119,9 +119,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXMSW__)
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#else
+    #define FAMILY_CTRLS GENERIC_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(DatePickerWidgetsPage, wxT("DatePicker"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | PICKER_CTRLS
+                       FAMILY_CTRLS | PICKER_CTRLS
                        );
 
 DatePickerWidgetsPage::DatePickerWidgetsPage(WidgetsBookCtrl *book,
diff --git a/samples/widgets/gauge.cpp b/samples/widgets/gauge.cpp
index 5c779721cb..4affd9ab33 100644
--- a/samples/widgets/gauge.cpp
+++ b/samples/widgets/gauge.cpp
@@ -52,7 +52,7 @@
 // control ids
 enum
 {
-    GaugePage_Reset = 100,
+    GaugePage_Reset = wxID_HIGHEST,
     GaugePage_Progress,
     GaugePage_Clear,
     GaugePage_SetValue,
@@ -157,9 +157,13 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(GaugeWidgetsPage, _T("Gauge"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       );
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(GaugeWidgetsPage, _T("Gauge"), FAMILY_CTRLS );
 
 GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
                                    wxImageList *imaglist)
diff --git a/samples/widgets/listbox.cpp b/samples/widgets/listbox.cpp
index 0a40eb74e1..1a43e7b4a2 100644
--- a/samples/widgets/listbox.cpp
+++ b/samples/widgets/listbox.cpp
@@ -55,7 +55,7 @@
 // control ids
 enum
 {
-    ListboxPage_Reset = 100,
+    ListboxPage_Reset = wxID_HIGHEST,
     ListboxPage_Add,
     ListboxPage_AddText,
     ListboxPage_AddSeveral,
@@ -193,9 +193,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(ListboxWidgetsPage, _T("Listbox"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | WITH_ITEMS_CTRLS
+                       FAMILY_CTRLS | WITH_ITEMS_CTRLS
                        );
 
 ListboxWidgetsPage::ListboxWidgetsPage(WidgetsBookCtrl *book,
diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp
index f65f461179..357ac05684 100644
--- a/samples/widgets/notebook.cpp
+++ b/samples/widgets/notebook.cpp
@@ -93,11 +93,6 @@ public:
 
 protected:
     // event handlers
-#ifdef ABX
-    void OnPageChanging(wxNotebookEvent& event);
-    void OnPageChanged(wxNotebookEvent& event);
-#endif
-
     void OnButtonReset(wxCommandEvent& event);
     void OnButtonDeleteAll(wxCommandEvent& event);
     void OnButtonSelectPage(wxCommandEvent& event);
@@ -181,11 +176,6 @@ BEGIN_EVENT_TABLE(BookWidgetsPage, WidgetsPage)
     EVT_UPDATE_UI(BookPage_InsertPage, BookWidgetsPage::OnUpdateUIInsertButton)
     EVT_UPDATE_UI(BookPage_RemovePage, BookWidgetsPage::OnUpdateUIRemoveButton)
 
-#ifdef ABX
-    EVT_NOTEBOOK_PAGE_CHANGING(wxID_ANY, BookWidgetsPage::OnPageChanging)
-    EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, NotebookWidgetsPage::OnPageChanged)
-#endif
-
     EVT_CHECKBOX(wxID_ANY, BookWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, BookWidgetsPage::OnCheckOrRadioBox)
 END_EVENT_TABLE()
@@ -516,29 +506,6 @@ void BookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
     RecreateBook();
 }
 
-#ifdef ABX
-void BookWidgetsPage::OnPageChanging(wxBookEvent& event)
-{
-    wxLogMessage(_T("Notebook page changing from %d to %d (currently %d)."),
-                 event.GetOldSelection(),
-                 event.GetSelection(),
-                 m_notebook->GetSelection());
-
-    event.Skip();
-}
-
-void NotebookWidgetsPage::OnPageChanged(wxNotebookEvent& event)
-{
-    wxLogMessage(_T("Notebook page changed from %d to %d (currently %d)."),
-                 event.GetOldSelection(),
-                 event.GetSelection(),
-                 m_notebook->GetSelection());
-
-    event.Skip();
-}
-
-#endif
-
 #if wxUSE_NOTEBOOK
 
 #include "icons/notebook.xpm"
@@ -561,6 +528,10 @@ public:
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxNotebookEvent& event);
+    void OnPageChanged(wxNotebookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -580,14 +551,42 @@ private:
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(NotebookWidgetsPage, BookWidgetsPage)
+    EVT_NOTEBOOK_PAGE_CHANGING(wxID_ANY, NotebookWidgetsPage::OnPageChanging)
+    EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, NotebookWidgetsPage::OnPageChanged)
 END_EVENT_TABLE()
 
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#elif defined(__WXMOTIF__)
+    #define FAMILY_CTRLS GENERIC_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(NotebookWidgetsPage, _T("Notebook"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                                                     .ElseIf(wxGTK,NATIVE_CTRLS)
-                       | BOOK_CTRLS
+                       FAMILY_CTRLS | BOOK_CTRLS
                        );
 
+void NotebookWidgetsPage::OnPageChanging(wxNotebookEvent& event)
+{
+    wxLogMessage(_T("Notebook page changing from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
+void NotebookWidgetsPage::OnPageChanged(wxNotebookEvent& event)
+{
+    wxLogMessage(_T("Notebook page changed from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
 #endif // wxUSE_NOTEBOOK
 
 #if wxUSE_LISTBOOK
@@ -612,6 +611,10 @@ public:
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxListbookEvent& event);
+    void OnPageChanged(wxListbookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -631,12 +634,34 @@ private:
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(ListbookWidgetsPage, BookWidgetsPage)
+    EVT_LISTBOOK_PAGE_CHANGING(wxID_ANY, ListbookWidgetsPage::OnPageChanging)
+    EVT_LISTBOOK_PAGE_CHANGED(wxID_ANY, ListbookWidgetsPage::OnPageChanged)
 END_EVENT_TABLE()
 
 IMPLEMENT_WIDGETS_PAGE(ListbookWidgetsPage, _T("Listbook"),
                        GENERIC_CTRLS | BOOK_CTRLS
                        );
 
+void ListbookWidgetsPage::OnPageChanging(wxListbookEvent& event)
+{
+    wxLogMessage(_T("Listbook page changing from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
+void ListbookWidgetsPage::OnPageChanged(wxListbookEvent& event)
+{
+    wxLogMessage(_T("Listbook page changed from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
 #endif // wxUSE_LISTBOOK
 
 #if wxUSE_CHOICEBOOK
@@ -661,6 +686,10 @@ public:
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxChoicebookEvent& event);
+    void OnPageChanged(wxChoicebookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -680,12 +709,34 @@ private:
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(ChoicebookWidgetsPage, BookWidgetsPage)
+    EVT_CHOICEBOOK_PAGE_CHANGING(wxID_ANY, ChoicebookWidgetsPage::OnPageChanging)
+    EVT_CHOICEBOOK_PAGE_CHANGED(wxID_ANY, ChoicebookWidgetsPage::OnPageChanged)
 END_EVENT_TABLE()
 
 IMPLEMENT_WIDGETS_PAGE(ChoicebookWidgetsPage, _T("Choicebook"),
                        GENERIC_CTRLS | BOOK_CTRLS
                        );
 
+void ChoicebookWidgetsPage::OnPageChanging(wxChoicebookEvent& event)
+{
+    wxLogMessage(_T("Choicebook page changing from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
+void ChoicebookWidgetsPage::OnPageChanged(wxChoicebookEvent& event)
+{
+    wxLogMessage(_T("Choicebook page changed from %d to %d (currently %d)."),
+                 event.GetOldSelection(),
+                 event.GetSelection(),
+                 m_book->GetSelection());
+
+    event.Skip();
+}
+
 #endif // wxUSE_CHOICEBOOK
 
 #endif // wxUSE_BOOKCTRL
diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp
index 1fd80178a4..088da04a98 100644
--- a/samples/widgets/radiobox.cpp
+++ b/samples/widgets/radiobox.cpp
@@ -51,7 +51,7 @@
 // control ids
 enum
 {
-    RadioPage_Reset = 100,
+    RadioPage_Reset = wxID_HIGHEST,
     RadioPage_Update,
     RadioPage_Selection,
     RadioPage_Label,
@@ -173,9 +173,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(RadioWidgetsPage, _T("Radio"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | WITH_ITEMS_CTRLS
+                       FAMILY_CTRLS | WITH_ITEMS_CTRLS
                        );
 
 RadioWidgetsPage::RadioWidgetsPage(WidgetsBookCtrl *book,
diff --git a/samples/widgets/slider.cpp b/samples/widgets/slider.cpp
index ce234a2c4d..75c5839332 100644
--- a/samples/widgets/slider.cpp
+++ b/samples/widgets/slider.cpp
@@ -198,9 +198,13 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, _T("Slider"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       );
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, _T("Slider"), FAMILY_CTRLS );
 
 SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
                                      wxImageList *imaglist)
diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp
index 1b0fbf2055..9cb2f46153 100644
--- a/samples/widgets/spinbtn.cpp
+++ b/samples/widgets/spinbtn.cpp
@@ -54,7 +54,7 @@
 // control ids
 enum
 {
-    SpinBtnPage_Reset = 100,
+    SpinBtnPage_Reset = wxID_HIGHEST,
     SpinBtnPage_Clear,
     SpinBtnPage_SetValue,
     SpinBtnPage_SetMinAndMax,
@@ -166,9 +166,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(SpinBtnWidgetsPage, _T("Spin"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | EDITABLE_CTRLS
+                       FAMILY_CTRLS | EDITABLE_CTRLS
                        );
 
 SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book,
diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp
index 1866e8d469..0082fde6fd 100644
--- a/samples/widgets/static.cpp
+++ b/samples/widgets/static.cpp
@@ -51,7 +51,7 @@
 // control ids
 enum
 {
-    StaticPage_Reset = 100,
+    StaticPage_Reset = wxID_HIGHEST,
     StaticPage_BoxText,
     StaticPage_LabelText
 };
diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp
index c01eb60d76..7728ba3cc9 100644
--- a/samples/widgets/textctrl.cpp
+++ b/samples/widgets/textctrl.cpp
@@ -53,7 +53,7 @@
 // control ids
 enum
 {
-    TextPage_Reset = 100,
+    TextPage_Reset = wxID_HIGHEST,
 
     TextPage_Set,
     TextPage_Add,
@@ -329,9 +329,16 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
+#if defined(__WXX11__)
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#elif defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
 IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       | EDITABLE_CTRLS
+                       FAMILY_CTRLS | EDITABLE_CTRLS
                        );
 
 // ----------------------------------------------------------------------------
-- 
2.47.2