X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..e3b71cb8839390d529b43147c2fdb8fcca94f851:/wxPython/src/_sizers.i diff --git a/wxPython/src/_sizers.i b/wxPython/src/_sizers.i index cf32cd8dd4..3bd200a57f 100644 --- a/wxPython/src/_sizers.i +++ b/wxPython/src/_sizers.i @@ -51,6 +51,8 @@ public: void SetProportion( int proportion ); int GetProportion(); + %pythoncode { SetOption = SetProportion} + %pythoncode { GetOption = GetProportion} void SetFlag( int flag ); int GetFlag(); @@ -96,8 +98,8 @@ public: struct wxPySizerItemInfo { wxPySizerItemInfo() - : window(NULL), sizer(NULL), gotSize(false), - size(wxDefaultSize), gotPos(false), pos(-1) + : window(NULL), sizer(NULL), gotSize(False), + size(wxDefaultSize), gotPos(False), pos(-1) {} wxWindow* window; @@ -128,13 +130,13 @@ static wxPySizerItemInfo wxPySizerItemTypeHelper(PyObject* item, bool checkSize, // try wxSize or (w,h) if ( checkSize && wxSize_helper(item, &sizePtr)) { info.size = *sizePtr; - info.gotSize = true; + info.gotSize = True; } // or a single int if (checkIdx && PyInt_Check(item)) { info.pos = PyInt_AsLong(item); - info.gotPos = true; + info.gotPos = True; } } } @@ -174,11 +176,11 @@ public: PyObject* userData=NULL) { wxPyUserData* data = NULL; - wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False); if ( userData && (info.window || info.sizer || info.gotSize) ) data = new wxPyUserData(userData); - wxPyEndBlockThreads(); + wxPyEndBlockThreads(blocked); // Now call the real Add method if a valid item type was found if ( info.window ) @@ -195,11 +197,11 @@ public: int border=0, PyObject* userData=NULL) { wxPyUserData* data = NULL; - wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False); if ( userData && (info.window || info.sizer || info.gotSize) ) data = new wxPyUserData(userData); - wxPyEndBlockThreads(); + wxPyEndBlockThreads(blocked); // Now call the real Insert method if a valid item type was found if ( info.window ) @@ -217,11 +219,11 @@ public: PyObject* userData=NULL) { wxPyUserData* data = NULL; - wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, true, false); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, True, False); if ( userData && (info.window || info.sizer || info.gotSize) ) data = new wxPyUserData(userData); - wxPyEndBlockThreads(); + wxPyEndBlockThreads(blocked); // Now call the real Prepend method if a valid item type was found if ( info.window ) @@ -235,9 +237,9 @@ public: bool Remove(PyObject* item) { - wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true); - wxPyEndBlockThreads(); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True); + wxPyEndBlockThreads(blocked); if ( info.window ) return self->Remove(info.window); else if ( info.sizer ) @@ -245,14 +247,29 @@ public: else if ( info.gotPos ) return self->Remove(info.pos); else - return FALSE; + return False; } - void _SetItemMinSize(PyObject* item, wxSize size) { - wxPyBeginBlockThreads(); - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true); - wxPyEndBlockThreads(); + bool Detach(PyObject* item) { + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True); + wxPyEndBlockThreads(blocked); + if ( info.window ) + return self->Detach(info.window); + else if ( info.sizer ) + return self->Detach(info.sizer); + else if ( info.gotPos ) + return self->Detach(info.pos); + else + return False; + } + + + void _SetItemMinSize(PyObject* item, const wxSize& size) { + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, True); + wxPyEndBlockThreads(blocked); if ( info.window ) self->SetItemMinSize(info.window, size); else if ( info.sizer ) @@ -269,16 +286,30 @@ public: %pythoncode { def AddMany(self, widgets): + """ + AddMany is a convenience method for adding several items + to a sizer at one time. Simply pass it a list of tuples, + where each tuple consists of the parameters that you + would normally pass to the `Add` method. + """ for childinfo in widgets: - if type(childinfo) != type(()): + if type(childinfo) != type(()) or (len(childinfo) == 2 and type(childinfo[0]) == type(1)): childinfo = (childinfo, ) self.Add(*childinfo) - # for backwards compatibility only, do not use in new code - AddWindow = AddSizer = AddSpacer = Add - PrependWindow = PrependSizer = PrependSpacer = Prepend - InsertWindow = InsertSizer = InsertSpacer = Insert - RemoveWindow = RemoveSizer = RemovePos = Remove + %# for backwards compatibility only, please do not use in new code + AddWindow = wx._deprecated(Add, "AddWindow is deprecated, use `Add` instead.") + AddSizer = wx._deprecated(Add, "AddSizer is deprecated, use `Add` instead.") + AddSpacer = wx._deprecated(Add, "AddSpacer is deprecated, use `Add` instead.") + PrependWindow = wx._deprecated(Prepend, "PrependWindow is deprecated, use `Prepend` instead.") + PrependSizer = wx._deprecated(Prepend, "PrependSizer is deprecated, use `Prepend` instead.") + PrependSpacer = wx._deprecated(Prepend, "PrependSpacer is deprecated, use `Prepend` instead.") + InsertWindow = wx._deprecated(Insert, "InsertWindow is deprecated, use `Insert` instead.") + InsertSizer = wx._deprecated(Insert, "InsertSizer is deprecated, use `Insert` instead.") + InsertSpacer = wx._deprecated(Insert, "InsertSpacer is deprecated, use `Insert` instead.") + RemoveWindow = wx._deprecated(Remove, "RemoveWindow is deprecated, use `Remove` instead.") + RemoveSizer = wx._deprecated(Remove, "RemoveSizer is deprecated, use `Remove` instead.") + RemovePos = wx._deprecated(Remove, "RemovePos is deprecated, use `Remove` instead.") def SetItemMinSize(self, item, *args): @@ -290,7 +321,7 @@ public: void SetDimension( int x, int y, int width, int height ); - void SetMinSize(wxSize size); + void SetMinSize( const wxSize &size ); wxSize GetSize(); wxPoint GetPosition(); @@ -298,11 +329,11 @@ public: %pythoncode { def GetSizeTuple(self): - return self.GetSize().asTuple() + return self.GetSize().Get() def GetPositionTuple(self): - return self.GetPosition().asTuple() + return self.GetPosition().Get() def GetMinSizeTuple(self): - return self.GetMinSize().asTuple() + return self.GetMinSize().Get() } virtual void RecalcSizes(); @@ -316,7 +347,7 @@ public: void SetSizeHints( wxWindow *window ); void SetVirtualSizeHints( wxWindow *window ); - void Clear( bool delete_windows=FALSE ); + void Clear( bool delete_windows=False ); void DeleteWindows(); @@ -333,8 +364,10 @@ public: // in the layout calculations or not. %extend { - void Show(PyObject* item, bool show = TRUE) { - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false); + void Show(PyObject* item, bool show = True) { + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, False); + wxPyEndBlockThreads(blocked); if ( info.window ) self->Show(info.window, show); else if ( info.sizer ) @@ -343,7 +376,9 @@ public: void Hide(PyObject* item) { - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, False); + wxPyEndBlockThreads(blocked); if ( info.window ) self->Hide(info.window); else if ( info.sizer ) @@ -352,13 +387,15 @@ public: bool IsShown(PyObject* item) { - wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, false); + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, False, False); + wxPyEndBlockThreads(blocked); if ( info.window ) return self->IsShown(info.window); else if ( info.sizer ) return self->IsShown(info.sizer); else - return false; + return False; } } @@ -382,7 +419,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPySizer, wxSizer); class wxPySizer : public wxSizer { public: - %addtofunc wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)" + %pythonAppend wxPySizer "self._setCallbackInfo(self, PySizer);self._setOORInfo(self)" wxPySizer(); void _setCallbackInfo(PyObject* self, PyObject* _class); @@ -394,7 +431,7 @@ public: class wxBoxSizer : public wxSizer { public: - %addtofunc wxBoxSizer "self._setOORInfo(self)" + %pythonAppend wxBoxSizer "self._setOORInfo(self)" wxBoxSizer(int orient = wxHORIZONTAL); @@ -409,7 +446,7 @@ public: class wxStaticBoxSizer : public wxBoxSizer { public: - %addtofunc wxStaticBoxSizer "self._setOORInfo(self)" + %pythonAppend wxStaticBoxSizer "self._setOORInfo(self)" wxStaticBoxSizer(wxStaticBox *box, int orient = wxHORIZONTAL); @@ -424,7 +461,7 @@ public: class wxGridSizer: public wxSizer { public: - %addtofunc wxGridSizer "self._setOORInfo(self)" + %pythonAppend wxGridSizer "self._setOORInfo(self)" wxGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ); @@ -460,7 +497,7 @@ enum wxFlexSizerGrowMode class wxFlexGridSizer: public wxGridSizer { public: - %addtofunc wxFlexGridSizer "self._setOORInfo(self)" + %pythonAppend wxFlexGridSizer "self._setOORInfo(self)" wxFlexGridSizer( int rows=1, int cols=0, int vgap=0, int hgap=0 ); @@ -483,6 +520,10 @@ public: // flexible void SetNonFlexibleGrowMode(wxFlexSizerGrowMode mode); wxFlexSizerGrowMode GetNonFlexibleGrowMode(); + + // Read-only access to the row heights and col widths arrays + const wxArrayInt& GetRowHeights() const; + const wxArrayInt& GetColWidths() const; }; //---------------------------------------------------------------------------