X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dd9f7fea29e3f8bb61861f52984b7943512346ac..f78e4942ec0f3f6abd2992502e2d6c5c2e8e55f6:/wxPython/src/_notebook.i?ds=sidebyside diff --git a/wxPython/src/_notebook.i b/wxPython/src/_notebook.i index 9f3274e835..aa897f2220 100644 --- a/wxPython/src/_notebook.i +++ b/wxPython/src/_notebook.i @@ -15,28 +15,28 @@ //--------------------------------------------------------------------------- -%{ - DECLARE_DEF_STRING(NOTEBOOK_NAME); -%} +MAKE_CONST_WXSTRING(NOTEBOOK_NAME); //--------------------------------------------------------------------------- %newgroup // TODO: Virtualize this class so other book controls can be derived in Python +MustHaveApp(wxBookCtrlBase); + // Common base class for wxList/Tree/Notebook -class wxBookCtrl : public wxControl +class wxBookCtrlBase : public wxControl { public: // This is an ABC, it can't be constructed... -// wxBookCtrl(wxWindow *parent, +// wxBookCtrlBase(wxWindow *parent, // wxWindowID id, // const wxPoint& pos = wxDefaultPosition, // const wxSize& size = wxDefaultSize, // long style = 0, // const wxString& name = wxPyEmptyString); -// %name(PreBookCtrl)wxBookCtrl(); +// %RenameCtor(PreBookCtrlBase, wxBookCtrlBase()); // bool Create(wxWindow *parent, // wxWindowID id, // const wxPoint& pos = wxDefaultPosition, @@ -51,6 +51,9 @@ public: // get the panel which represents the given page virtual wxWindow *GetPage(size_t n); + // get the current page or NULL if none + wxWindow* GetCurrentPage() const; + // get the currently selected page or wxNOT_FOUND if none virtual int GetSelection() const/* = 0*/; @@ -66,8 +69,9 @@ public: virtual void SetImageList(wxImageList *imageList); // as SetImageList() but we will delete the image list ourselves - %addtofunc AssignImageList "args[1].thisown = 0" + %apply SWIGTYPE *DISOWN { wxImageList *imageList }; void AssignImageList(wxImageList *imageList); + %clear wxImageList *imageList; // get pointer (may be NULL) to the associated image list wxImageList* GetImageList() const; @@ -97,14 +101,14 @@ public: // adds a new page to the control virtual bool AddPage(wxWindow *page, const wxString& text, - bool select = False, + bool select = false, int imageId = -1); // the same as AddPage(), but adds the page at the specified position virtual bool InsertPage(size_t n, wxWindow *page, const wxString& text, - bool select = False, + bool select = false, int imageId = -1)/* = 0*/; // set the currently selected page, return the index of the previously @@ -115,15 +119,18 @@ public: // cycle thru the pages - void AdvanceSelection(bool forward = True); + void AdvanceSelection(bool forward = true); + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); }; -class wxBookCtrlEvent : public wxNotifyEvent +class wxBookCtrlBaseEvent : public wxNotifyEvent { public: - wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int nSel = -1, int nOldSel = -1); // the currently selected page (-1 if none) @@ -158,21 +165,27 @@ enum { -class wxNotebook : public wxBookCtrl { +MustHaveApp(wxNotebook); + +class wxNotebook : public wxBookCtrlBase { public: - %addtofunc wxNotebook "self._setOORInfo(self)" - %addtofunc wxNotebook() "" + %pythonAppend wxNotebook "self._setOORInfo(self)" + %pythonAppend wxNotebook() "" + %typemap(out) wxNotebook*; // turn off this typemap wxNotebook(wxWindow *parent, - wxWindowID id, + wxWindowID id=-1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPyNOTEBOOK_NAME); - %name(PreNotebook)wxNotebook(); + %RenameCtor(PreNotebook, wxNotebook()); + + // Turn it back on again + %typemap(out) wxNotebook* { $result = wxPyMake_wxObject($1, $owner); } bool Create(wxWindow *parent, - wxWindowID id, + wxWindowID id=-1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, @@ -191,20 +204,22 @@ public: // hit test, returns which tab is hit and, optionally, where (icon, label) // (not implemented on all platforms) - virtual int HitTest(const wxPoint& pt, long* OUTPUT) const; + DocDeclAStr( + virtual int, HitTest(const wxPoint& pt, long* OUTPUT) const, + "HitTest(Point pt) -> (tab, where)", + "Returns the tab which is hit, and flags indicating where using +wx.NB_HITTEST flags.", ""); // implement some base class functions virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; -#ifdef __WXMSW__ - // Windows only: attempts to apply the UX theme page background to this page - void ApplyThemeBackground(wxWindow* window, const wxColour& colour); -#endif + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); }; -class wxNotebookEvent : public wxBookCtrlEvent +class wxNotebookEvent : public wxBookCtrlBaseEvent { public: wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, @@ -244,7 +259,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() @@ -277,23 +292,25 @@ enum +MustHaveApp(wxListbook); + // wxListCtrl and wxNotebook combination -class wxListbook : public wxBookCtrl +class wxListbook : public wxBookCtrlBase { public: - %addtofunc wxListbook "self._setOORInfo(self)" - %addtofunc wxListbook() "" + %pythonAppend wxListbook "self._setOORInfo(self)" + %pythonAppend wxListbook() "" wxListbook(wxWindow *parent, - wxWindowID id, + wxWindowID id=-1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxPyEmptyString); - %name(PreListbook)wxListbook(); + %RenameCtor(PreListbook, wxListbook()); bool Create(wxWindow *parent, - wxWindowID id, + wxWindowID id=-1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, @@ -302,11 +319,12 @@ public: // returns True if we have wxLB_TOP or wxLB_BOTTOM style bool IsVertical() const; + wxListView* GetListView(); }; -class wxListbookEvent : public wxBookCtrlEvent +class wxListbookEvent : public wxBookCtrlBaseEvent { public: wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, @@ -323,6 +341,69 @@ public: } +//--------------------------------------------------------------------------- + + +/* + * wxChoicebook flags + */ +enum { + wxCHB_DEFAULT, + wxCHB_TOP, + wxCHB_BOTTOM, + wxCHB_LEFT, + wxCHB_RIGHT, + wxCHB_ALIGN_MASK +}; + + +MustHaveApp(wxChoicebook); + +class wxChoicebook : public wxBookCtrlBase +{ +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); + %RenameCtor(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 wxBookCtrlBaseEvent +{ +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; @@ -330,25 +411,30 @@ public: class wxBookCtrlSizer: public wxSizer { public: - %addtofunc wxBookCtrlSizer "self._setOORInfo(self)" + %pythonAppend wxBookCtrlSizer "self._setOORInfo(self)" + + wxBookCtrlSizer( wxBookCtrlBase *nb ); - wxBookCtrlSizer( wxBookCtrl *nb ); - void RecalcSizes(); wxSize CalcMin(); - wxBookCtrl *GetControl(); + wxBookCtrlBase *GetControl(); }; class wxNotebookSizer: public wxSizer { public: - %addtofunc wxNotebookSizer "self._setOORInfo(self)" + %pythonAppend wxNotebookSizer "self._setOORInfo(self)" wxNotebookSizer( wxNotebook *nb ); - + void RecalcSizes(); wxSize CalcMin(); wxNotebook *GetNotebook(); }; + +%pythoncode { NotebookSizer = wx._deprecated(NotebookSizer, "NotebookSizer is no longer needed.") } +%pythoncode { BookCtrlSizer = wx._deprecated(BookCtrlSizer, "BookCtrlSizer is no longer needed.") } + + //---------------------------------------------------------------------------