From 9283228f861b3842f06e2228c4f7b93a48de064f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 31 Dec 2004 22:55:57 +0000 Subject: [PATCH] Added wxStdDialogButtonSizer, which is a 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 `Finalize` and the sizer will take care of the rest. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/docs/CHANGES.txt | 9 ++++++++- wxPython/src/_sizers.i | 38 +++++++++++++++++++++++++++++++++++++- wxPython/src/_toplvl.i | 6 +++--- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/wxPython/docs/CHANGES.txt b/wxPython/docs/CHANGES.txt index 8626852476..00472b4f42 100644 --- a/wxPython/docs/CHANGES.txt +++ b/wxPython/docs/CHANGES.txt @@ -143,7 +143,14 @@ SetDefaultPyEncoding will now allow you to control which encoding will be used to do those conversions. The default encoding is set to the value of `locale.getdefaultlocale()[1]` when wxPython is first imported. Please see http://www.alanwood.net/demos/charsetdiffs.html -for subtle differences between the common latin/roman encodings. +for information on the differences between the common latin/roman +encodings. + +Added wxStdDialogButtonSizer, which is a 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 `Finalize` and the sizer will take care of the rest. diff --git a/wxPython/src/_sizers.i b/wxPython/src/_sizers.i index bba510b197..157024fb7d 100644 --- a/wxPython/src/_sizers.i +++ b/wxPython/src/_sizers.i @@ -957,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` @@ -1262,4 +1262,40 @@ 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 `Finalize` 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 , Finalise(), + "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.", ""); + + wxButton* GetAffirmativeButton() const; + wxButton* GetApplyButton() const; + wxButton* GetNegativeButton() const; + wxButton* GetCancelButton() const; + wxButton* GetHelpButton() const; +}; + + //--------------------------------------------------------------------------- diff --git a/wxPython/src/_toplvl.i b/wxPython/src/_toplvl.i index f6d8e172a1..4032625afe 100644 --- a/wxPython/src/_toplvl.i +++ b/wxPython/src/_toplvl.i @@ -308,11 +308,11 @@ public: // splits text up at newlines and places the // lines into a vertical wxBoxSizer - wxSizer *CreateTextSizer( const wxString &message ); + wxSizer* CreateTextSizer( const wxString &message ); // places buttons into a horizontal wxBoxSizer - wxSizer *CreateButtonSizer( long flags ); - + wxSizer* CreateButtonSizer( long flags ); + wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags ); //void SetModal(bool flag);