]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/bookctrl.h
MinGW warning fix.
[wxWidgets.git] / include / wx / bookctrl.h
index 0f03436ae50acb39797404be7a51d37f9c75d233..e1605aef7310da1e771aee91a47eb2e16c0d2d2b 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Name:        wx/bookctrl.h
 ///////////////////////////////////////////////////////////////////////////////
 // Name:        wx/bookctrl.h
-// Purpose:     wxBookCtrl: common base class for wxList/Tree/Notebook
+// Purpose:     wxBookCtrlBase: common base class for wxList/Tree/Notebook
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     19.08.03
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     19.08.03
@@ -32,26 +32,26 @@ WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
 class WXDLLEXPORT wxImageList;
 
 // ----------------------------------------------------------------------------
 class WXDLLEXPORT wxImageList;
 
 // ----------------------------------------------------------------------------
-// wxBookCtrl
+// wxBookCtrlBase
 // ----------------------------------------------------------------------------
 
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxBookCtrl : public wxControl
+class WXDLLEXPORT wxBookCtrlBase : public wxControl
 {
 public:
     // construction
     // ------------
 
 {
 public:
     // construction
     // ------------
 
-    wxBookCtrl()
+    wxBookCtrlBase()
     {
         Init();
     }
 
     {
         Init();
     }
 
-    wxBookCtrl(wxWindow *parent,
-               wxWindowID winid,
-               const wxPoint& pos = wxDefaultPosition,
-               const wxSize& size = wxDefaultSize,
-               long style = 0,
-               const wxString& name = wxEmptyString)
+    wxBookCtrlBase(wxWindow *parent,
+                   wxWindowID winid,
+                   const wxPoint& pos = wxDefaultPosition,
+                   const wxSize& size = wxDefaultSize,
+                   long style = 0,
+                   const wxString& name = wxEmptyString)
     {
         Init();
 
     {
         Init();
 
@@ -67,7 +67,7 @@ public:
                 const wxString& name = wxEmptyString);
 
     // dtor
                 const wxString& name = wxEmptyString);
 
     // dtor
-    virtual ~wxBookCtrl();
+    virtual ~wxBookCtrlBase();
 
 
     // accessors
 
 
     // accessors
@@ -79,6 +79,14 @@ public:
     // get the panel which represents the given page
     virtual wxWindow *GetPage(size_t n) { return m_pages[n]; }
 
     // get the panel which represents the given page
     virtual wxWindow *GetPage(size_t n) { return m_pages[n]; }
 
+    // get the current page or NULL if none
+    wxWindow *GetCurrentPage() const
+    {
+        int n = GetSelection();
+        return n == wxNOT_FOUND ? NULL
+                                : wx_const_cast(wxBookCtrlBase *, this)->GetPage(n);
+    }
+
     // get the currently selected page or wxNOT_FOUND if none
     virtual int GetSelection() const = 0;
 
     // get the currently selected page or wxNOT_FOUND if none
     virtual int GetSelection() const = 0;
 
@@ -156,7 +164,7 @@ public:
     // set the currently selected page, return the index of the previously
     // selected one (or -1 on error)
     //
     // set the currently selected page, return the index of the previously
     // selected one (or -1 on error)
     //
-    // NB: this function will _not_ generate PAGE_CHANGING/ED events
+    // NB: this function will generate PAGE_CHANGING/ED events
     virtual int SetSelection(size_t n) = 0;
 
 
     virtual int SetSelection(size_t n) = 0;
 
 
@@ -171,8 +179,10 @@ public:
         }
     }
 
         }
     }
 
+    // override some base class virtuals
     virtual void ApplyParentThemeBackground(const wxColour& bg)
         { SetBackgroundColour(bg); }
     virtual void ApplyParentThemeBackground(const wxColour& bg)
         { SetBackgroundColour(bg); }
+    virtual bool ProvidesBackground() const { return true; }
 
 protected:
     // remove the page and return a pointer to it
 
 protected:
     // remove the page and return a pointer to it
@@ -200,18 +210,18 @@ protected:
     bool m_ownsImageList;
 
 
     bool m_ownsImageList;
 
 
-    DECLARE_NO_COPY_CLASS(wxBookCtrl)
+    DECLARE_NO_COPY_CLASS(wxBookCtrlBase)
 };
 
 // ----------------------------------------------------------------------------
 };
 
 // ----------------------------------------------------------------------------
-// wxBookCtrlEvent: page changing events generated by derived classes
+// wxBookCtrlBaseEvent: page changing events generated by derived classes
 // ----------------------------------------------------------------------------
 
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxBookCtrlEvent : public wxNotifyEvent
+class WXDLLEXPORT wxBookCtrlBaseEvent : public wxNotifyEvent
 {
 public:
 {
 public:
-    wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
-                    int nSel = -1, int nOldSel = -1)
+    wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
+                        int nSel = -1, int nOldSel = -1)
         : wxNotifyEvent(commandType, winid)
         {
             m_nSel = nSel;
         : wxNotifyEvent(commandType, winid)
         {
             m_nSel = nSel;
@@ -231,6 +241,35 @@ private:
         m_nOldSel;  // previously selected page
 };
 
         m_nOldSel;  // previously selected page
 };
 
+// make a default book control for given platform
+#if defined(__WXMSW__) && defined(__SMARTPHONE__)
+    #include "wx/choicebk.h"
+    #define wxBookCtrl                             wxChoicebook
+    #define wxBookCtrlEvent                        wxChoicebookEvent
+    #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED    wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED
+    #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING   wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING
+    #define EVT_BOOKCTRL_PAGE_CHANGED(id, fn)      EVT_CHOICEBOOK_PAGE_CHANGED(id, fn)
+    #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn)     EVT_CHOICEBOOK_PAGE_CHANGING(id, fn)
+    #define wxBC_TOP                               wxCHB_TOP
+    #define wxBC_BOTTOM                            wxCHB_BOTTOM
+    #define wxBC_LEFT                              wxCHB_LEFT
+    #define wxBC_RIGHT                             wxCHB_RIGHT
+    #define wxBC_DEFAULT                           wxCHB_DEFAULT
+#else
+    #include "wx/notebook.h"
+    #define wxBookCtrl                             wxNotebook
+    #define wxBookCtrlEvent                        wxNotebookEvent
+    #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGED    wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
+    #define wxEVT_COMMAND_BOOKCTRL_PAGE_CHANGING   wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
+    #define EVT_BOOKCTRL_PAGE_CHANGED(id, fn)      EVT_NOTEBOOK_PAGE_CHANGED(id, fn)
+    #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn)     EVT_NOTEBOOK_PAGE_CHANGING(id, fn)
+    #define wxBC_TOP                               wxNB_TOP
+    #define wxBC_BOTTOM                            wxNB_BOTTOM
+    #define wxBC_LEFT                              wxNB_LEFT
+    #define wxBC_RIGHT                             wxNB_RIGHT
+    #define wxBC_DEFAULT                           wxNB_DEFAULT
+#endif
+
 #endif // wxUSE_BOOKCTRL
 
 #endif // _WX_BOOKCTRL_H_
 #endif // wxUSE_BOOKCTRL
 
 #endif // _WX_BOOKCTRL_H_