From b14cca2a84340b5411accff8fc440fbf3cc9b723 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Aug 2010 21:48:16 +0000 Subject: [PATCH] Extract CreateSeparatedSizer() from wxDialog::CreateSeparatedButtonSizer(). Extract the code adding a separating wxStaticLine to the sizer in its own function to be able to reuse it in upcoming commits. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65448 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dialog.h | 7 +++++++ interface/wx/dialog.h | 21 +++++++++++++++++++++ src/common/dlgcmn.cpp | 15 ++++++++++----- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/include/wx/dialog.h b/include/wx/dialog.h index 7073e86214..7419b9e02a 100644 --- a/include/wx/dialog.h +++ b/include/wx/dialog.h @@ -133,9 +133,16 @@ public: // platforms which have hardware buttons replacing OK/Cancel and such) wxSizer *CreateButtonSizer(long flags); + // returns a sizer containing the given one and a static line separating it + // from the preceding elements if it's appropriate for the current platform + wxSizer *CreateSeparatedSizer(wxSizer *sizer); + // returns the sizer containing CreateButtonSizer() below a separating // static line for the platforms which use static lines for items // separation (i.e. not Mac) + // + // this is just a combination of CreateButtonSizer() and + // CreateSeparatedSizer() wxSizer *CreateSeparatedButtonSizer(long flags); #if wxUSE_BUTTON diff --git a/interface/wx/dialog.h b/interface/wx/dialog.h index 1afacb2d05..69a58d43a8 100644 --- a/interface/wx/dialog.h +++ b/interface/wx/dialog.h @@ -248,9 +248,30 @@ public: @note Just like CreateButtonSizer(), this function may return @NULL if no buttons were created. + + This is a combination of CreateButtonSizer() and + CreateSeparatedSizer(). */ wxSizer* CreateSeparatedButtonSizer(long flags); + /** + Returns the sizer containing the given one with a separating + wxStaticLine if necessarily. + + This function is useful for creating the sizer containing footer-like + contents in dialog boxes. It will add a separating static line only if + it conforms to the current platform convention (currently it is not + added under Mac where the use of static lines for grouping is + discouraged and is added elsewhere). + + @since 2.9.2 + + @param sizer The sizer to wrap, must be non-@NULL. + @return The sizer wrapping the input one or possibly the input sizer + itself if no wrapping is necessary. + */ + wxSizer *CreateSeparatedSizer(wxSizer *sizer); + /** Creates a wxStdDialogButtonSizer with standard buttons. @a flags is a bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index 8d127fa5e2..a335b7efaa 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -218,12 +218,8 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags) #endif // __SMARTPHONE__/!__SMARTPHONE__ } -wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags) +wxSizer *wxDialogBase::CreateSeparatedSizer(wxSizer *sizer) { - wxSizer *sizer = CreateButtonSizer(flags); - if ( !sizer ) - return NULL; - // Mac Human Interface Guidelines recommend not to use static lines as // grouping elements #if wxUSE_STATLINE && !defined(__WXMAC__) @@ -237,6 +233,15 @@ wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags) return sizer; } +wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags) +{ + wxSizer *sizer = CreateButtonSizer(flags); + if ( !sizer ) + return NULL; + + return CreateSeparatedSizer(sizer); +} + #if wxUSE_BUTTON wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) -- 2.45.2