X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41b78a7aaf105d6834053f1012c9936d5f8fe223..f7a50432401c62a3300b0b9faa7e99d7ffe3d4e8:/wxPython/src/_gbsizer.i diff --git a/wxPython/src/_gbsizer.i b/wxPython/src/_gbsizer.i index 865faad831..19a31686ea 100644 --- a/wxPython/src/_gbsizer.i +++ b/wxPython/src/_gbsizer.i @@ -73,20 +73,42 @@ class wxGBPosition { public: wxGBPosition(int row=0, int col=0); - + ~wxGBPosition(); + int GetRow() const; int GetCol() const; void SetRow(int row); void SetCol(int col); -// %extend { -// bool __eq__(const wxGBPosition* other) { return other ? (*self == *other) : false; } -// bool __ne__(const wxGBPosition* other) { return other ? (*self != *other) : true; } -// } - bool operator==(const wxGBPosition& other); - bool operator!=(const wxGBPosition& other); - + %extend { + KeepGIL(__eq__); + DocStr(__eq__, "Compare GBPosition for equality.", ""); + bool __eq__(PyObject* other) { + wxGBPosition temp, *obj = &temp; + if ( other == Py_None ) return false; + if ( ! wxGBPosition_helper(other, &obj) ) { + PyErr_Clear(); + return false; + } + return self->operator==(*obj); + } + + + KeepGIL(__ne__); + DocStr(__ne__, "Compare GBPosition for inequality.", ""); + bool __ne__(PyObject* other) { + wxGBPosition temp, *obj = &temp; + if ( other == Py_None ) return true; + if ( ! wxGBPosition_helper(other, &obj)) { + PyErr_Clear(); + return true; + } + return self->operator!=(*obj); + } + } + + %extend { void Set(int row=0, int col=0) { self->SetRow(row); @@ -94,7 +116,7 @@ public: } PyObject* Get() { - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow())); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetCol())); @@ -143,18 +165,41 @@ public: colspan. The default is (1,1). (Meaning that the item occupies one cell in each direction.", ""); + ~wxGBSpan(); + int GetRowspan() const; int GetColspan() const; void SetRowspan(int rowspan); void SetColspan(int colspan); + -// %extend { -// bool __eq__(const wxGBSpan* other) { return other ? (*self == *other) : false; } -// bool __ne__(const wxGBSpan* other) { return other ? (*self != *other) : true; } -// } - bool operator==(const wxGBSpan& other); - bool operator!=(const wxGBSpan& other); - + %extend { + KeepGIL(__eq__); + DocStr(__eq__, "Compare wxGBSpan for equality.", ""); + bool __eq__(PyObject* other) { + wxGBSpan temp, *obj = &temp; + if ( other == Py_None ) return false; + if ( ! wxGBSpan_helper(other, &obj) ) { + PyErr_Clear(); + return false; + } + return self->operator==(*obj); + } + + + KeepGIL(__ne__); + DocStr(__ne__, "Compare GBSpan for inequality.", ""); + bool __ne__(PyObject* other) { + wxGBSpan temp, *obj = &temp; + if ( other == Py_None ) return true; + if ( ! wxGBSpan_helper(other, &obj)) { + PyErr_Clear(); + return true; + } + return self->operator!=(*obj); + } + } + %extend { void Set(int rowspan=1, int colspan=1) { @@ -163,7 +208,7 @@ cell in each direction.", ""); } PyObject* Get() { - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRowspan())); PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetColspan())); @@ -218,19 +263,23 @@ item can be used in a Sizer. You will probably never need to create a wx.GBSizerItem directly as they are created automatically when the sizer's Add method is called.", ""); + ~wxGBSizerItem(); + + %extend { DocStr(wxGBSizerItem( wxWindow *window, const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL ), "Construct a `wx.GBSizerItem` for a window.", ""); - %name(GBSizerItemWindow) wxGBSizerItem( wxWindow *window, - const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - PyObject* userData=NULL ) + + %RenameCtor(GBSizerItemWindow, wxGBSizerItem( wxWindow *window, + const wxGBPosition& pos, + const wxGBSpan& span, + int flag, + int border, + PyObject* userData=NULL )) { wxPyUserData* data = NULL; if ( userData ) { - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); data = new wxPyUserData(userData); wxPyEndBlockThreads(blocked); } @@ -240,36 +289,38 @@ are created automatically when the sizer's Add method is called.", ""); DocStr(wxGBSizerItem( wxSizer *sizer,const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL ), "Construct a `wx.GBSizerItem` for a sizer", ""); - %name(GBSizerItemSizer) wxGBSizerItem( wxSizer *sizer, - const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - PyObject* userData=NULL ) + %disownarg( wxSizer *sizer ); + %RenameCtor(GBSizerItemSizer, wxGBSizerItem( wxSizer *sizer, + const wxGBPosition& pos, + const wxGBSpan& span, + int flag, + int border, + PyObject* userData=NULL )) { wxPyUserData* data = NULL; if ( userData ) { - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); data = new wxPyUserData(userData); wxPyEndBlockThreads(blocked); } return new wxGBSizerItem(sizer, pos, span, flag, border, data); } + %cleardisown( wxSizer *sizer ); DocStr(wxGBSizerItem( int width,int height,const wxGBPosition& pos,const wxGBSpan& span,int flag,int border,PyObject* userData=NULL), "Construct a `wx.GBSizerItem` for a spacer.", ""); - %name(GBSizerItemSpacer) wxGBSizerItem( int width, - int height, - const wxGBPosition& pos, - const wxGBSpan& span, - int flag, - int border, - PyObject* userData=NULL) + %RenameCtor(GBSizerItemSpacer, wxGBSizerItem( int width, + int height, + const wxGBPosition& pos, + const wxGBSpan& span, + int flag, + int border, + PyObject* userData=NULL)) { wxPyUserData* data = NULL; if ( userData ) { - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); data = new wxPyUserData(userData); wxPyEndBlockThreads(blocked); } @@ -342,6 +393,10 @@ is successful and after the next Layout() the item will be resized. void , SetGBSizer(wxGridBagSizer* sizer), "Set the sizer this item is a member of.", ""); + %property(EndPos, GetEndPos, doc="See `GetEndPos`"); + %property(GBSizer, GetGBSizer, SetGBSizer, doc="See `GetGBSizer` and `SetGBSizer`"); + %property(Pos, GetPos, SetPos, doc="See `GetPos` and `SetPos`"); + %property(Span, GetSpan, SetSpan, doc="See `GetSpan` and `SetSpan`"); }; @@ -359,6 +414,8 @@ positioned at, adjusted for spanning. class wxGridBagSizer : public wxFlexGridSizer { public: + %pythonAppend wxGridBagSizer "self._setOORInfo(self)" + DocCtorStr( wxGridBagSizer(int vgap = 0, int hgap = 0 ), "Constructor, with optional parameters to specify the gap between the @@ -368,7 +425,7 @@ rows and columns.", ""); %extend { DocAStr(Add, "Add(self, item, GBPosition pos, GBSpan span=DefaultSpan, int flag=0, -int border=0, userData=None)", +int border=0, userData=None) -> wx.GBSizerItem", "Adds an item to the sizer at the grid cell *pos*, optionally spanning more than one row or column as specified with *span*. The remaining @@ -377,40 +434,48 @@ args behave similarly to `wx.Sizer.Add`. Returns True if the item was successfully placed at the given cell position, False if something was already there. ", ""); - bool Add( PyObject* item, - const wxGBPosition& pos, - const wxGBSpan& span = wxDefaultSpan, - int flag = 0, - int border = 0, - PyObject* userData = NULL ) { + wxGBSizerItem* Add( PyObject* item, + const wxGBPosition& pos, + const wxGBSpan& span = wxDefaultSpan, + int flag = 0, + int border = 0, + PyObject* userData = NULL ) { wxPyUserData* data = NULL; - bool blocked = wxPyBeginBlockThreads(); + wxPyBlock_t blocked = wxPyBeginBlockThreads(); wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false); if ( userData && (info.window || info.sizer || info.gotSize) ) data = new wxPyUserData(userData); + if ( info.sizer ) + PyObject_SetAttrString(item,"thisown",Py_False); wxPyEndBlockThreads(blocked); // Now call the real Add method if a valid item type was found if ( info.window ) - return self->Add(info.window, pos, span, flag, border, data); + return (wxGBSizerItem*)self->Add(info.window, pos, span, flag, border, data); else if ( info.sizer ) - return self->Add(info.sizer, pos, span, flag, border, data); + return (wxGBSizerItem*)self->Add(info.sizer, pos, span, flag, border, data); else if (info.gotSize) - return self->Add(info.size.GetWidth(), info.size.GetHeight(), - pos, span, flag, border, data); - return false; + return (wxGBSizerItem*)self->Add(info.size.GetWidth(), info.size.GetHeight(), + pos, span, flag, border, data); + return NULL; } } - + + %disownarg( wxGBSizerItem *item ); DocDeclAStrName( - bool , Add( wxGBSizerItem *item ), - "Add(self, GBSizerItem item) -> bool", + wxGBSizerItem* , Add( wxGBSizerItem *item ), + "Add(self, GBSizerItem item) -> wx.GBSizerItem", "Add an item to the sizer using a `wx.GBSizerItem`. Returns True if the item was successfully placed at its given cell position, False if something was already there.", "", AddItem); - + %cleardisown( wxGBSizerItem *item ); + + DocDeclStr( + wxSize , GetCellSize(int row, int col) const, + "Get the size of the specified cell, including hgap and +vgap. Only valid after a Layout.", ""); DocDeclStr( wxSize , GetEmptyCellSize() const, @@ -538,7 +603,6 @@ for intersection, for example it may be the item we are checking the position of.", "", CheckForIntersectionPos); - };