]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/notebook.cpp
more wxFD_XXX renamings (patch 1488371)
[wxWidgets.git] / samples / widgets / notebook.cpp
index f65f461179a6c4e461b64a3a269494e450e3a8bc..21cdf14029e6595360574c4a45bd217da43311aa 100644 (file)
@@ -44,6 +44,7 @@
 #include "wx/sizer.h"
 #include "wx/bookctrl.h"
 #include "wx/artprov.h"
+#include "wx/imaglist.h"
 
 #include "widgets.h"
 
@@ -85,7 +86,7 @@ enum Orient
 class BookWidgetsPage : public WidgetsPage
 {
 public:
-    BookWidgetsPage(WidgetsBookCtrl *book);
+    BookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist, char* icon[]);
     virtual ~BookWidgetsPage();
 
     virtual wxControl *GetWidget() const { return m_book; }
@@ -93,11 +94,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);
@@ -123,8 +119,10 @@ protected:
     void RecreateBook();
     virtual wxBookCtrlBase *CreateBook(long flags) = 0;
 
+#if USE_ICONS_IN_BOOK
     // create or destroy the image list
     void CreateImageList();
+#endif // USE_ICONS_IN_BOOK
 
     // create a new page
     wxWindow *CreateNewPage();
@@ -155,8 +153,10 @@ protected:
     wxBookCtrlBase *m_book;
     wxSizer *m_sizerBook;
 
-    // thei mage list for our book
+#if USE_ICONS_IN_BOOK
+    // the image list for our book
     wxImageList *m_imageList;
+#endif // USE_ICONS_IN_BOOK
 
 private:
     DECLARE_EVENT_TABLE()
@@ -181,11 +181,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()
@@ -194,12 +189,14 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book)
-                :WidgetsPage(book)
+BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist, char* icon[])
+                :WidgetsPage(book, imaglist, icon)
 {
     // init everything
     m_chkImages = NULL;
+#if USE_ICONS_IN_BOOK
     m_imageList = NULL;
+#endif // USE_ICONS_IN_BOOK
 
     m_book = NULL;
     m_sizerBook = (wxSizer *)NULL;
@@ -284,7 +281,9 @@ BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book)
 
     // final initializations
     Reset();
+#if USE_ICONS_IN_BOOK
     CreateImageList();
+#endif // USE_ICONS_IN_BOOK
 
     SetSizer(sizerTop);
 
@@ -293,7 +292,9 @@ BookWidgetsPage::BookWidgetsPage(WidgetsBookCtrl *book)
 
 BookWidgetsPage::~BookWidgetsPage()
 {
+#if USE_ICONS_IN_BOOK
     delete m_imageList;
+#endif // USE_ICONS_IN_BOOK
 }
 
 // ----------------------------------------------------------------------------
@@ -306,6 +307,7 @@ void BookWidgetsPage::Reset()
     m_radioOrient->SetSelection(Orient_Top);
 }
 
+#if USE_ICONS_IN_BOOK
 void BookWidgetsPage::CreateImageList()
 {
     if ( m_chkImages->GetValue() )
@@ -337,6 +339,7 @@ void BookWidgetsPage::CreateImageList()
     // it would be logical if this removed the image list from book, under
     // MSW it crashes instead - FIXME
 }
+#endif // USE_ICONS_IN_BOOK
 
 void BookWidgetsPage::RecreateBook()
 {
@@ -368,7 +371,9 @@ void BookWidgetsPage::RecreateBook()
 
     m_book = CreateBook(flags);
 
+#if USE_ICONS_IN_BOOK
     CreateImageList();
+#endif // USE_ICONS_IN_BOOK
 
     if ( oldBook )
     {
@@ -416,6 +421,7 @@ int BookWidgetsPage::GetTextValue(wxTextCtrl *text) const
 
 int BookWidgetsPage::GetIconIndex() const
 {
+#if USE_ICONS_IN_BOOK
     if ( m_imageList )
     {
        int nImages = m_imageList->GetImageCount();
@@ -424,6 +430,7 @@ int BookWidgetsPage::GetIconIndex() const
            return m_book->GetPageCount() % nImages;
        }
     }
+#endif // USE_ICONS_IN_BOOK
 
     return -1;
 }
@@ -516,29 +523,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"
@@ -552,15 +536,18 @@ class NotebookWidgetsPage : public BookWidgetsPage
 {
 public:
     NotebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
-        : BookWidgetsPage(book)
+        : BookWidgetsPage(book, imaglist, notebook_xpm)
     {
-        imaglist->Add(wxBitmap(notebook_xpm));
         RecreateBook();
     }
     virtual ~NotebookWidgetsPage() {}
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxNotebookEvent& event);
+    void OnPageChanged(wxNotebookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -580,14 +567,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
@@ -603,15 +618,18 @@ class ListbookWidgetsPage : public BookWidgetsPage
 {
 public:
     ListbookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
-        : BookWidgetsPage(book)
+        : BookWidgetsPage(book, imaglist, listbook_xpm)
     {
-        imaglist->Add(wxBitmap(listbook_xpm));
         RecreateBook();
     }
     virtual ~ListbookWidgetsPage() {}
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxListbookEvent& event);
+    void OnPageChanged(wxListbookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -631,12 +649,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
@@ -652,15 +692,18 @@ class ChoicebookWidgetsPage : public BookWidgetsPage
 {
 public:
     ChoicebookWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
-        : BookWidgetsPage(book)
+        : BookWidgetsPage(book, imaglist, choicebk_xpm)
     {
-        imaglist->Add(wxBitmap(choicebk_xpm));
         RecreateBook();
     }
     virtual ~ChoicebookWidgetsPage() {}
 
 protected:
 
+    // event handlers
+    void OnPageChanging(wxChoicebookEvent& event);
+    void OnPageChanged(wxChoicebookEvent& event);
+
     // (re)create book
     virtual wxBookCtrlBase *CreateBook(long flags)
     {
@@ -680,12 +723,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