]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wx.Choicebook
authorRobin Dunn <robin@alldunn.com>
Sat, 18 Sep 2004 23:51:14 +0000 (23:51 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 18 Sep 2004 23:51:14 +0000 (23:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/Choicebook.py [new file with mode: 0644]
wxPython/demo/Listbook.py
wxPython/demo/Main.py
wxPython/src/_notebook.i

diff --git a/wxPython/demo/Choicebook.py b/wxPython/demo/Choicebook.py
new file mode 100644 (file)
index 0000000..de304a9
--- /dev/null
@@ -0,0 +1,80 @@
+
+import  wx
+
+#----------------------------------------------------------------------------
+
+pageTexts = [ "Yet",
+              "Another",
+              "Way",
+              "To",
+              "Select",
+              "Pages"
+              ]
+          
+
+class TestCB(wx.Choicebook):
+    def __init__(self, parent, id, log):
+        wx.Choicebook.__init__(self, parent, id
+                            )
+        self.log = log
+
+        # Now make a bunch of panels for the choice book
+        count = 1
+        for txt in pageTexts:
+            win = wx.Panel(self)
+            if count == 1:
+                st = wx.StaticText(win, -1,
+                          "wx.Choicebook is yet another way to switch between 'page' windows",
+                          (10, 10))
+            else:
+                st = wx.StaticText(win, -1, "Page: %d" % count, (10,10))
+            count += 1
+            
+            self.AddPage(win, txt)
+
+        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
+        self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
+
+
+    def OnPageChanged(self, event):
+        old = event.GetOldSelection()
+        new = event.GetSelection()
+        sel = self.GetSelection()
+        self.log.write('OnPageChanged,  old:%d, new:%d, sel:%d\n' % (old, new, sel))
+        event.Skip()
+
+    def OnPageChanging(self, event):
+        old = event.GetOldSelection()
+        new = event.GetSelection()
+        sel = self.GetSelection()
+        self.log.write('OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel))
+        event.Skip()
+
+#----------------------------------------------------------------------------
+
+def runTest(frame, nb, log):
+    testWin = TestCB(nb, -1, log)
+    return testWin
+
+#----------------------------------------------------------------------------
+
+
+overview = """\
+<html><body>
+<h2>wx.Choicebook</h2>
+<p>
+
+This class is a control similar to a notebook control, but uses a
+wx.Choice to manage the selection of the pages.
+
+"""
+
+
+
+if __name__ == '__main__':
+    import sys,os
+    import run
+    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
+
+
+
index cc3f2f77d956cc72e50bc28b7199ec8aa76c7826..cb620fe83d67569427d8d39f559506ae66fc99c8 100644 (file)
@@ -1,6 +1,4 @@
 
-import  sys
-
 import  wx
 
 import ColorPanel
index 37b4fa8b837c4e984905024030ee69bad00bb895..eed065bf0f517b6dd7ad893c2201f4ae3a440927 100644 (file)
@@ -49,6 +49,7 @@ _treeList = [
     ('Recent Additions/Updates', [
         'StockButtons',
         'Ticker',
+        'Choicebook',
         ]),
 
     # managed windows == things with a (optional) caption you can close
@@ -89,6 +90,7 @@ _treeList = [
         'CheckBox',
         'CheckListBox',
         'Choice',
+        'Choicebook',
         'ComboBox',
         'Gauge',
         'Grid',
index db05752cf2e2efcc2836566dc76adbaa9d7abff3..f17b14e993b9a62837d77ef1cb599e22c5b5a58e 100644 (file)
@@ -261,7 +261,7 @@ class NotebookPage(wx.Panel):
         wx.Panel.__init__(self, parent, id, pos, size, style, name)
         self.child = None
         EVT_SIZE(self, self.OnSize)
-        
+
     def OnSize(self, evt):
         if self.child is None:
             children = self.GetChildren()
@@ -321,7 +321,7 @@ public:
     // returns True if we have wxLB_TOP or wxLB_BOTTOM style
     bool IsVertical() const;
 
-    wxListView* GetListView();    
+    wxListView* GetListView();
 };
 
 
@@ -343,6 +343,72 @@ public:
 }
 
 
+//---------------------------------------------------------------------------
+
+%{
+#include <wx/choicebk.h>
+%}
+
+/*
+ * wxChoicebook flags
+ */
+enum {
+    wxCHB_DEFAULT,
+    wxCHB_TOP,
+    wxCHB_BOTTOM,
+    wxCHB_LEFT,
+    wxCHB_RIGHT,
+    wxCHB_ALIGN_MASK
+};
+
+
+MustHaveApp(wxChoicebook);
+
+class wxChoicebook : public wxBookCtrl
+{
+public:
+    %pythonAppend wxChoicebook         "self._setOORInfo(self)"
+    %pythonAppend wxChoicebook()       ""
+
+    wxChoicebook(wxWindow *parent,
+                 wxWindowID id,
+                 const wxPoint& pos = wxDefaultPosition,
+                 const wxSize& size = wxDefaultSize,
+                 long style = 0,
+                 const wxString& name = wxPyEmptyString);
+    %name(PreChoicebook)wxChoicebook();
+
+    // quasi ctor
+    bool Create(wxWindow *parent,
+                wxWindowID id,
+                const wxPoint& pos = wxDefaultPosition,
+                const wxSize& size = wxDefaultSize,
+                long style = 0,
+                const wxString& name = wxPyEmptyString);
+
+
+    // returns true if we have wxCHB_TOP or wxCHB_BOTTOM style
+    bool IsVertical() const { return HasFlag(wxCHB_BOTTOM | wxCHB_TOP); }
+
+    virtual bool DeleteAllPages();
+};
+
+
+class wxChoicebookEvent : public wxBookCtrlEvent
+{
+public:
+    wxChoicebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
+                      int nSel = -1, int nOldSel = -1);
+};
+
+%constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
+%constant wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
+
+%pythoncode {
+    EVT_CHOICEBOOK_PAGE_CHANGED  = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED, 1 )
+    EVT_CHOICEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, 1 )
+}
+
 //---------------------------------------------------------------------------
 %newgroup;
 
@@ -353,7 +419,7 @@ public:
     %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)"
 
     wxBookCtrlSizer( wxBookCtrl *nb );
-    
+
     void RecalcSizes();
     wxSize CalcMin();
     wxBookCtrl *GetControl();
@@ -365,7 +431,7 @@ public:
     %pythonAppend wxNotebookSizer "self._setOORInfo(self)"
 
     wxNotebookSizer( wxNotebook *nb );
-    
+
     void RecalcSizes();
     wxSize CalcMin();
     wxNotebook *GetNotebook();