X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a72f4631fe5ab7ebeefdacf8ec9c826ea962133f..c1280d1ef6d32bd1c0ad9652b8c9bfc67393dcd3:/wxPython/src/_sizers.i diff --git a/wxPython/src/_sizers.i b/wxPython/src/_sizers.i index f0eac7a127..8fe5f1b071 100644 --- a/wxPython/src/_sizers.i +++ b/wxPython/src/_sizers.i @@ -51,8 +51,9 @@ methods are called. int border, PyObject* userData=NULL ), "Constructs a `wx.SizerItem` for tracking a window.", ""); - %name(SizerItemWindow) wxSizerItem( wxWindow *window, int proportion, int flag, - int border, PyObject* userData=NULL ) { + %RenameCtor(SizerItemWindow, wxSizerItem( wxWindow *window, int proportion, int flag, + int border, PyObject* userData=NULL )) + { wxPyUserData* data = NULL; if ( userData ) { bool blocked = wxPyBeginBlockThreads(); @@ -67,8 +68,10 @@ methods are called. wxSizerItem( int width, int height, int proportion, int flag, int border, PyObject* userData=NULL), "Constructs a `wx.SizerItem` for tracking a spacer.", ""); - %name(SizerItemSpacer) wxSizerItem( int width, int height, int proportion, int flag, - int border, PyObject* userData=NULL) { + + %RenameCtor(SizerItemSpacer, wxSizerItem( int width, int height, int proportion, int flag, + int border, PyObject* userData=NULL)) + { wxPyUserData* data = NULL; if ( userData ) { bool blocked = wxPyBeginBlockThreads(); @@ -81,9 +84,11 @@ methods are called. DocStr( wxSizerItem( wxSizer *sizer, int proportion, int flag, int border, PyObject* userData=NULL ), - "Constructs a `wx.SizerItem` for tracking a subsizer", ""); - %name(SizerItemSizer) wxSizerItem( wxSizer *sizer, int proportion, int flag, - int border, PyObject* userData=NULL ) { + "Constructs a `wx.SizerItem` for tracking a subsizer", ""); + + %RenameCtor(SizerItemSizer, wxSizerItem( wxSizer *sizer, int proportion, int flag, + int border, PyObject* userData=NULL )) + { wxPyUserData* data = NULL; if ( userData ) { bool blocked = wxPyBeginBlockThreads(); @@ -139,13 +144,17 @@ added, if needed.", ""); DocStr(SetRatio, "Set the ratio item attribute.", ""); - %name(SetRatioWH) void SetRatio( int width, int height ); - %name(SetRatioSize) void SetRatio( wxSize size ); + %Rename(SetRatioWH, void, SetRatio( int width, int height )); + %Rename(SetRatioSize, void, SetRatio( wxSize size )); void SetRatio( float ratio ); DocDeclStr( float , GetRatio(), "Set the ratio item attribute.", ""); + + DocDeclStr( + wxRect , GetRect(), + "Returns the rectangle that the sizer item should occupy", ""); DocDeclStr( @@ -378,7 +387,7 @@ public: DocAStr(Add, "Add(self, item, int proportion=0, int flag=0, int border=0, - PyObject userData=None)", + PyObject userData=None) -> wx.SizerItem", "Appends a child item to the sizer.", " @@ -477,8 +486,8 @@ public: is more complex than the *proportion* and *flag* will allow for. "); - void Add(PyObject* item, int proportion=0, int flag=0, int border=0, - PyObject* userData=NULL) { + wxSizerItem* Add(PyObject* item, int proportion=0, int flag=0, int border=0, + PyObject* userData=NULL) { wxPyUserData* data = NULL; bool blocked = wxPyBeginBlockThreads(); @@ -489,25 +498,27 @@ public: // Now call the real Add method if a valid item type was found if ( info.window ) - self->Add(info.window, proportion, flag, border, data); + return self->Add(info.window, proportion, flag, border, data); else if ( info.sizer ) - self->Add(info.sizer, proportion, flag, border, data); + return self->Add(info.sizer, proportion, flag, border, data); else if (info.gotSize) - self->Add(info.size.GetWidth(), info.size.GetHeight(), - proportion, flag, border, data); + return self->Add(info.size.GetWidth(), info.size.GetHeight(), + proportion, flag, border, data); + else + return NULL; } -// virtual void AddSpacer(int size); -// virtual void AddStretchSpacer(int prop = 1); +// virtual wxSizerItem* AddSpacer(int size); +// virtual wxSizerItem* AddStretchSpacer(int prop = 1); DocAStr(Insert, "Insert(self, int before, item, int proportion=0, int flag=0, int border=0, - PyObject userData=None)", + PyObject userData=None) -> wx.SizerItem", "Inserts a new item into the list of items managed by this sizer before the item at index *before*. See `Add` for a description of the parameters.", ""); - void Insert(int before, PyObject* item, int proportion=0, int flag=0, - int border=0, PyObject* userData=NULL) { + wxSizerItem* Insert(int before, PyObject* item, int proportion=0, int flag=0, + int border=0, PyObject* userData=NULL) { wxPyUserData* data = NULL; bool blocked = wxPyBeginBlockThreads(); @@ -518,26 +529,28 @@ the item at index *before*. See `Add` for a description of the parameters.", "" // Now call the real Insert method if a valid item type was found if ( info.window ) - self->Insert(before, info.window, proportion, flag, border, data); + return self->Insert(before, info.window, proportion, flag, border, data); else if ( info.sizer ) - self->Insert(before, info.sizer, proportion, flag, border, data); + return self->Insert(before, info.sizer, proportion, flag, border, data); else if (info.gotSize) - self->Insert(before, info.size.GetWidth(), info.size.GetHeight(), - proportion, flag, border, data); + return self->Insert(before, info.size.GetWidth(), info.size.GetHeight(), + proportion, flag, border, data); + else + return NULL; } -// virtual void InsertSpacer(size_t index, int size); -// virtual void InsertStretchSpacer(size_t index, int prop = 1); +// virtual wxSizerItem* InsertSpacer(size_t index, int size); +// virtual wxSizerItem* InsertStretchSpacer(size_t index, int prop = 1); DocAStr(Prepend, "Prepend(self, item, int proportion=0, int flag=0, int border=0, - PyObject userData=None)", + PyObject userData=None) -> wx.SizerItem", "Adds a new item to the begining of the list of sizer items managed by this sizer. See `Add` for a description of the parameters.", ""); - void Prepend(PyObject* item, int proportion=0, int flag=0, int border=0, - PyObject* userData=NULL) { + wxSizerItem* Prepend(PyObject* item, int proportion=0, int flag=0, int border=0, + PyObject* userData=NULL) { wxPyUserData* data = NULL; bool blocked = wxPyBeginBlockThreads(); @@ -548,16 +561,18 @@ this sizer. See `Add` for a description of the parameters.", ""); // Now call the real Prepend method if a valid item type was found if ( info.window ) - self->Prepend(info.window, proportion, flag, border, data); + return self->Prepend(info.window, proportion, flag, border, data); else if ( info.sizer ) - self->Prepend(info.sizer, proportion, flag, border, data); + return self->Prepend(info.sizer, proportion, flag, border, data); else if (info.gotSize) - self->Prepend(info.size.GetWidth(), info.size.GetHeight(), - proportion, flag, border, data); + return self->Prepend(info.size.GetWidth(), info.size.GetHeight(), + proportion, flag, border, data); + else + return NULL; } -// virtual void PrependSpacer(int size); -// virtual void PrependStretchSpacer(int prop = 1); +// virtual wxSizerItem* PrependSpacer(int size); +// virtual wxSizerItem* PrependStretchSpacer(int prop = 1); DocAStr(Remove, "Remove(self, item) -> bool", @@ -610,6 +625,26 @@ was found and detached.", ""); } + DocAStr(GetItem, + "GetItem(self, item) -> wx.SizerItem", + "Returns the `wx.SizerItem` which holds the *item* given. The *item* +parameter can be either a window, a sizer, or the zero-based index of +the item to be detached.", ""); + wxSizerItem* GetItem(PyObject* item) { + bool blocked = wxPyBeginBlockThreads(); + wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true); + wxPyEndBlockThreads(blocked); + if ( info.window ) + return self->GetItem(info.window); + else if ( info.sizer ) + return self->GetItem(info.sizer); + else if ( info.gotPos ) + return self->GetItem(info.pos); + else + return NULL; + } + + void _SetItemMinSize(PyObject* item, const wxSize& size) { bool blocked = wxPyBeginBlockThreads(); wxPySizerItemInfo info = wxPySizerItemTypeHelper(item, false, true); @@ -641,19 +676,19 @@ was found and detached.", ""); } DocDeclAStrName( - void , Add( wxSizerItem *item ), + wxSizerItem* , Add( wxSizerItem *item ), "AddItem(self, SizerItem item)", "Adds a `wx.SizerItem` to the sizer.", "", AddItem); DocDeclAStrName( - void , Insert( size_t index, wxSizerItem *item ), + wxSizerItem* , Insert( size_t index, wxSizerItem *item ), "InsertItem(self, int index, SizerItem item)", "Inserts a `wx.SizerItem` to the sizer at the position given by *index*.", "", InsertItem); DocDeclAStrName( - void , Prepend( wxSizerItem *item ), + wxSizerItem* , Prepend( wxSizerItem *item ), "PrependItem(self, SizerItem item)", "Prepends a `wx.SizerItem` to the sizer.", "", PrependItem); @@ -806,7 +841,7 @@ as well.", ""); // wxList& GetChildren(); %extend { DocAStr(GetChildren, - "GetChildren(sefl) -> list", + "GetChildren(self) -> list", "Returns a list of all the `wx.SizerItem` objects managed by the sizer.", ""); PyObject* GetChildren() { wxSizerItemList& list = self->GetChildren(); @@ -836,6 +871,8 @@ subsizer. Returns True if the item was found.", ""); return self->Show(info.sizer, show, recursive); else if ( info.gotPos ) return self->Show(info.pos, show); + else + return false; } DocAStr(IsShown, @@ -860,17 +897,17 @@ the item.", ""); } %pythoncode { - def Hide(self, item, recursive=false): + def Hide(self, item, recursive=False): """ A convenience method for Show(item, False, recursive). """ - return self.Show(item, false, recursive) + return self.Show(item, False, recursive) } DocDeclStr( void , ShowItems(bool show), - "Recursively call `wx.Window.Show` on all sizer items.", ""); + "Recursively call `wx.SizerItem.Show` on all sizer items.", ""); }; @@ -920,7 +957,7 @@ For example:: When `Layout` is called it first calls `CalcMin` followed by `RecalcSizes` so you can optimize a bit by saving the results of -`CalcMin` and resuing them in `RecalcSizes`. +`CalcMin` and reusing them in `RecalcSizes`. :see: `wx.SizerItem`, `wx.Sizer.GetChildren` @@ -1006,10 +1043,12 @@ public: "Constructor. It takes an associated static box and the orientation *orient* as parameters - orient can be either of ``wx.VERTICAL`` or ``wx.HORIZONTAL``.", ""); + + // TODO: wxStaticBoxSizer(int orient, wxWindow *win, const wxString& label = wxEmptyString); - DocDeclStr( - wxStaticBox *, GetStaticBox(), - "Returns the static box associated with this sizer.", ""); + DocDeclStr( + wxStaticBox *, GetStaticBox(), + "Returns the static box associated with this sizer.", ""); }; @@ -1225,4 +1264,44 @@ columns in the sizer.", ""); }; +//--------------------------------------------------------------------------- + +DocStr(wxStdDialogButtonSizer, +"A special sizer that knows how to order and position standard buttons +in order to conform to the current platform's standards. You simply +need to add each `wx.Button` to the sizer, and be sure to create the +buttons using the standard ID's. Then call `Realize` and the sizer +will take care of the rest. +", ""); + +class wxStdDialogButtonSizer: public wxBoxSizer +{ +public: + DocCtorStr( + wxStdDialogButtonSizer(), + "", ""); + + DocDeclStr( + void , AddButton(wxButton *button), + "Use this to add the buttons to this sizer. Do not use the `Add` +method in the base class.", ""); + + DocDeclStr( + void , Realize(), + "This funciton needs to be called after all the buttons have been added +to the sizer. It will reorder them and position them in a platform +specifc manner.", ""); + + void SetAffirmativeButton( wxButton *button ); + void SetNegativeButton( wxButton *button ); + void SetCancelButton( wxButton *button ); + + wxButton* GetAffirmativeButton() const; + wxButton* GetApplyButton() const; + wxButton* GetNegativeButton() const; + wxButton* GetCancelButton() const; + wxButton* GetHelpButton() const; +}; + + //---------------------------------------------------------------------------