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
This commit is contained in:
Vadim Zeitlin
2010-08-30 21:48:16 +00:00
parent a01d6442f4
commit b14cca2a84
3 changed files with 38 additions and 5 deletions

View File

@@ -133,9 +133,16 @@ public:
// platforms which have hardware buttons replacing OK/Cancel and such) // platforms which have hardware buttons replacing OK/Cancel and such)
wxSizer *CreateButtonSizer(long flags); 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 // returns the sizer containing CreateButtonSizer() below a separating
// static line for the platforms which use static lines for items // static line for the platforms which use static lines for items
// separation (i.e. not Mac) // separation (i.e. not Mac)
//
// this is just a combination of CreateButtonSizer() and
// CreateSeparatedSizer()
wxSizer *CreateSeparatedButtonSizer(long flags); wxSizer *CreateSeparatedButtonSizer(long flags);
#if wxUSE_BUTTON #if wxUSE_BUTTON

View File

@@ -248,9 +248,30 @@ public:
@note Just like CreateButtonSizer(), this function may return @NULL if @note Just like CreateButtonSizer(), this function may return @NULL if
no buttons were created. no buttons were created.
This is a combination of CreateButtonSizer() and
CreateSeparatedSizer().
*/ */
wxSizer* CreateSeparatedButtonSizer(long flags); 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 Creates a wxStdDialogButtonSizer with standard buttons. @a flags is a
bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY,

View File

@@ -218,12 +218,8 @@ wxSizer *wxDialogBase::CreateButtonSizer(long flags)
#endif // __SMARTPHONE__/!__SMARTPHONE__ #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 // Mac Human Interface Guidelines recommend not to use static lines as
// grouping elements // grouping elements
#if wxUSE_STATLINE && !defined(__WXMAC__) #if wxUSE_STATLINE && !defined(__WXMAC__)
@@ -237,6 +233,15 @@ wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags)
return sizer; return sizer;
} }
wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags)
{
wxSizer *sizer = CreateButtonSizer(flags);
if ( !sizer )
return NULL;
return CreateSeparatedSizer(sizer);
}
#if wxUSE_BUTTON #if wxUSE_BUTTON
wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )