X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/94d33c49d11788ae1939e9fffb0b28fe04693f47..52f52ebc4e0be6a9899d328b08db9eb14629d219:/wxPython/src/_gbsizer.i diff --git a/wxPython/src/_gbsizer.i b/wxPython/src/_gbsizer.i index ce24f8df9d..a87e92eef4 100644 --- a/wxPython/src/_gbsizer.i +++ b/wxPython/src/_gbsizer.i @@ -65,11 +65,18 @@ public: void SetRow(int row); void SetCol(int col); - bool operator==(const wxGBPosition& p) const; - bool operator!=(const wxGBPosition& p) const; + %extend { + bool __eq__(const wxGBPosition* other) { return other ? (*self == *other) : False; } + bool __ne__(const wxGBPosition* other) { return other ? (*self != *other) : True; } + } %extend { - PyObject* asTuple() { + void Set(int row=0, int col=0) { + self->SetRow(row); + self->SetCol(col); + } + + PyObject* Get() { wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRow())); @@ -79,18 +86,18 @@ public: } } %pythoncode { - def __str__(self): return str(self.asTuple()) - def __repr__(self): return 'wxGBPosition'+str(self.asTuple()) - def __len__(self): return len(self.asTuple()) - def __getitem__(self, index): return self.asTuple()[index] + asTuple = Get + def __str__(self): return str(self.Get()) + def __repr__(self): return 'wx.GBPosition'+str(self.Get()) + def __len__(self): return len(self.Get()) + def __getitem__(self, index): return self.Get()[index] def __setitem__(self, index, val): if index == 0: self.SetRow(val) elif index == 1: self.SetCol(val) else: raise IndexError - def __nonzero__(self): return self.asTuple() != (0,0) - def __getinitargs__(self): return () - def __getstate__(self): return self.asTuple() - def __setstate__(self, state): self.Set(*state) + def __nonzero__(self): return self.Get() != (0,0) + __safe_for_unpickling__ = True + def __reduce__(self): return (wx.GBPosition, self.Get()) } %pythoncode { @@ -112,11 +119,18 @@ public: void SetRowspan(int rowspan); void SetColspan(int colspan); - bool operator==(const wxGBSpan& o) const; - bool operator!=(const wxGBSpan& o) const; + %extend { + bool __eq__(const wxGBSpan* other) { return other ? (*self == *other) : False; } + bool __ne__(const wxGBSpan* other) { return other ? (*self != *other) : True; } + } %extend { - PyObject* asTuple() { + void Set(int rowspan=1, int colspan=1) { + self->SetRowspan(rowspan); + self->SetColspan(colspan); + } + + PyObject* Get() { wxPyBeginBlockThreads(); PyObject* tup = PyTuple_New(2); PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetRowspan())); @@ -126,18 +140,18 @@ public: } } %pythoncode { - def __str__(self): return str(self.asTuple()) - def __repr__(self): return 'wxGBSpan'+str(self.asTuple()) - def __len__(self): return len(self.asTuple()) - def __getitem__(self, index): return self.asTuple()[index] + asTuple = Get + def __str__(self): return str(self.Get()) + def __repr__(self): return 'wx.GBSpan'+str(self.Get()) + def __len__(self): return len(self.Get()) + def __getitem__(self, index): return self.Get()[index] def __setitem__(self, index, val): if index == 0: self.SetRowspan(val) elif index == 1: self.SetColspan(val) else: raise IndexError - def __nonzero__(self): return self.asTuple() != (0,0) - def __getinitargs__(self): return () - def __getstate__(self): return self.asTuple() - def __setstate__(self, state): self.Set(*state) + def __nonzero__(self): return self.Get() != (0,0) + __safe_for_unpickling__ = True + def __reduce__(self): return (wx.GBSpan, self.Get()) } %pythoncode { @@ -185,30 +199,30 @@ public: // Get the grid position of the item wxGBPosition GetPos() const; - %pythoncode { def GetPosTuple(self): return self.GetPos().asTuple() } + %pythoncode { def GetPosTuple(self): return self.GetPos().Get() } // Get the row and column spanning of the item wxGBSpan GetSpan() const; - %pythoncode { def GetSpanTuple(self): return self.GetSpan().asTuple() } + %pythoncode { def GetSpanTuple(self): return self.GetSpan().Get() } // If the item is already a member of a sizer then first ensure that there // is no other item that would intersect with this one at the new - // position, then set the new position. Returns true if the change is + // position, then set the new position. Returns True if the change is // successful and after the next Layout the item will be moved. bool SetPos( const wxGBPosition& pos ); // If the item is already a member of a sizer then first ensure that there // is no other item that would intersect with this one with its new - // spanning size, then set the new spanning. Returns true if the change + // spanning size, then set the new spanning. Returns True if the change // is successful and after the next Layout the item will be resized. bool SetSpan( const wxGBSpan& span ); %nokwargs Intersects; - // Returns true if this item and the other item instersect + // Returns True if this item and the other item instersect bool Intersects(const wxGBSizerItem& other); - // Returns true if the given pos/span would intersect with this item. + // Returns True if the given pos/span would intersect with this item. bool Intersects(const wxGBPosition& pos, const wxGBSpan& span); // Get the row and column of the endpoint of this item @@ -229,8 +243,8 @@ class wxGridBagSizer : public wxFlexGridSizer public: wxGridBagSizer(int vgap = 0, int hgap = 0 ); - // The Add method returns true if the item was successfully placed at the - // given cell position, false if something was already there. + // The Add method returns True if the item was successfully placed at the + // given cell position, False if something was already there. %extend { bool Add( PyObject* item, const wxGBPosition& pos, @@ -241,7 +255,7 @@ public: wxPyUserData* data = NULL; wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False); if ( userData && (info.window || info.sizer || info.gotSize) ) data = new wxPyUserData(userData); wxPyEndBlockThreads(); @@ -254,7 +268,7 @@ public: else if (info.gotSize) return self->Add(info.size.GetWidth(), info.size.GetHeight(), pos, span, flag, border, data); - return false; + return False; } } @@ -271,9 +285,9 @@ public: wxGBPosition GetItemPosition(wxSizer *sizer); wxGBPosition GetItemPosition(size_t index); - // Set the grid position of the specified item. Returns true on success. + // Set the grid position of the specified item. Returns True on success. // If the move is not allowed (because an item is already there) then - // false is returned. + // False is returned. %nokwargs SetItemPosition; bool SetItemPosition(wxWindow *window, const wxGBPosition& pos); bool SetItemPosition(wxSizer *sizer, const wxGBPosition& pos); @@ -285,9 +299,9 @@ public: wxGBSpan GetItemSpan(wxSizer *sizer); wxGBSpan GetItemSpan(size_t index); - // Set the row/col spanning of the specified item. Returns true on + // Set the row/col spanning of the specified item. Returns True on // success. If the move is not allowed (because an item is already there) - // then false is returned. + // then False is returned. %nokwargs SetItemSpan; bool SetItemSpan(wxWindow *window, const wxGBSpan& span); bool SetItemSpan(wxSizer *sizer, const wxGBSpan& span); @@ -306,6 +320,13 @@ public: wxGBSizerItem* FindItemAtPosition(const wxGBPosition& pos); + // Return the sizer item located at the point given in pt, or NULL if + // there is no item at that point. The (x,y) coordinates in pt correspond + // to the client coordinates of the window using the sizer for + // layout. (non-recursive) + wxGBSizerItem* FindItemAtPoint(const wxPoint& pt); + + // Return the sizer item that has a matching user data (it only compares // pointer values) or NULL if not found. (non-recursive) wxGBSizerItem* FindItemWithData(const wxObject* userData); @@ -317,7 +338,7 @@ public: // Look at all items and see if any intersect (or would overlap) the given - // item. Returns true if so, false if there would be no overlap. If an + // item. Returns True if so, False if there would be no overlap. If an // excludeItem is given then it will not be checked for intersection, for // example it may be the item we are checking the position of. %nokwargs CheckForIntersection;