added CreateSeparatedButtonSizer(), changed signature and semantics of CreateButtonSizer()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41839 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-09 21:10:22 +00:00
parent bd9f3519cf
commit 25eb10d2e1
4 changed files with 89 additions and 68 deletions

View File

@@ -35,6 +35,7 @@ INCOMPATIBLE CHANGES SINCE 2.6.x
- wxGLContext class has no 1:1 coupling to a wxGLCanvas class any more. - wxGLContext class has no 1:1 coupling to a wxGLCanvas class any more.
As a consequence, the class interface changed largely. As a consequence, the class interface changed largely.
Code updates, if any are required at all, are easy to accomplish though. Code updates, if any are required at all, are easy to accomplish though.
- wxDialog::CreateButtonSizer() may return NULL now, please see the manual

View File

@@ -609,6 +609,22 @@ Sets the object of the wxSizerFlags to center itself in the area it is given.
\helpref{wxSizerFlags::Center}{wxsizerflagscenter} for people with the other dialect of english. \helpref{wxSizerFlags::Center}{wxsizerflagscenter} for people with the other dialect of english.
\membersection{wxSizerFlags::DoubleBorder}\label{wxsizerflagsdoubleborder}
\func{wxSizerFlags\& }{DoubleBorder}{\param{int }{direction = wxALL}}
Sets the border in the given \arg{direction} having twice the default border
size.
\membersection{wxSizerFlags::DoubleHorzBorder}\label{wxsizerflagsdoublehorzborder}
\func{wxSizerFlags\& }{DoubleHorzBorder}{\void}
Sets the border in left and right directions having twice the default border
size.
\membersection{wxSizerFlags::Expand}\label{wxsizerflagsexpand} \membersection{wxSizerFlags::Expand}\label{wxsizerflagsexpand}
\func{wxSizerFlags\& }{Expand}{\void} \func{wxSizerFlags\& }{Expand}{\void}
@@ -651,3 +667,12 @@ Aligns the object to the right, shortcut for \texttt{Align(wxALIGN\_RIGHT)}
\helpref{Align}{wxsizerflagsalign} \helpref{Align}{wxsizerflagsalign}
\membersection{wxSizerFlags::TripleBorder}\label{wxsizerflagstriplebleborder}
\func{wxSizerFlags\& }{TripleBorder}{\param{int }{direction = wxALL}}
Sets the border in the given \arg{direction} having thrice the default border
size.

View File

@@ -70,10 +70,18 @@ public:
wxSizer *CreateTextSizer( const wxString &message ); wxSizer *CreateTextSizer( const wxString &message );
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
// places buttons into a horizontal wxBoxSizer // returns a horizontal wxBoxSizer containing the given buttons
wxSizer *CreateButtonSizer( long flags, //
bool separated = false, // notice that the returned sizer can be NULL if no buttons are put in the
wxCoord distance = 0 ); // sizer (this mostly happens under smart phones and other atypical
// platforms which have hardware buttons replacing OK/Cancel and such)
wxSizer *CreateButtonSizer(long flags);
// returns the sizer containing CreateButtonSizer() below a separating
// static line for the platforms which use static lines for items
// separation (i.e. not Mac)
wxSizer *CreateSeparatedButtonSizer(long flags);
#if wxUSE_BUTTON #if wxUSE_BUTTON
wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags ); wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
#endif // wxUSE_BUTTON #endif // wxUSE_BUTTON

View File

@@ -279,80 +279,62 @@ Wrap(int width)
#endif // wxUSE_STATTEXT #endif // wxUSE_STATTEXT
wxSizer *wxDialogBase::CreateButtonSizer( long flags, bool separated, wxCoord distance ) wxSizer *wxDialogBase::CreateButtonSizer(long flags)
{ {
wxSizer *sizer = NULL;
#ifdef __SMARTPHONE__ #ifdef __SMARTPHONE__
wxUnusedVar(separated);
wxUnusedVar(distance);
wxDialog* dialog = (wxDialog*) this; wxDialog* dialog = (wxDialog*) this;
if (flags & wxOK){ if ( flags & wxOK )
dialog->SetLeftMenu(wxID_OK); dialog->SetLeftMenu(wxID_OK);
}
if (flags & wxCANCEL){ if ( flags & wxCANCEL )
dialog->SetRightMenu(wxID_CANCEL); dialog->SetRightMenu(wxID_CANCEL);
}
if (flags & wxYES){ if ( flags & wxYES )
dialog->SetLeftMenu(wxID_YES); dialog->SetLeftMenu(wxID_YES);
}
if (flags & wxNO){
dialog->SetLeftMenu(wxID_NO);
}
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
return sizer;
if ( flags & wxNO )
dialog->SetRightMenu(wxID_NO);
#else // !__SMARTPHONE__ #else // !__SMARTPHONE__
#ifdef __POCKETPC__
// PocketPC guidelines recommend for Ok/Cancel dialogs to use
// OK button located inside caption bar and implement Cancel functionality
// through Undo outside dialog. As native behaviour this will be default
// here but can be easily replaced with real wxButtons
// with "wince.dialog.real-ok-cancel" option set to 1
if ( ((flags & ~(wxCANCEL|wxNO_DEFAULT))== wxOK) &&
(wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel"))==0)
)
{
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
return sizer;
}
#endif // __POCKETPC__
#if wxUSE_BUTTON #if wxUSE_BUTTON
wxSizer* buttonSizer = CreateStdDialogButtonSizer( flags ); #ifdef __POCKETPC__
// PocketPC guidelines recommend for Ok/Cancel dialogs to use OK button
// Mac Human Interface Guidelines recommend not to use static lines as grouping elements // located inside caption bar and implement Cancel functionality through
#if wxUSE_STATLINE && !defined(__WXMAC__) // Undo outside dialog. As native behaviour this will be default here but
if(!separated) // can be replaced with real wxButtons by setting the option below to 1
return buttonSizer; if ( (flags & ~(wxCANCEL|wxNO_DEFAULT)) != wxOK ||
wxSystemOptions::GetOptionInt(wxT("wince.dialog.real-ok-cancel")) )
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); #endif // __POCKETPC__
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxBOTTOM, distance ); {
topsizer->Add( buttonSizer, 0, wxEXPAND ); sizer = CreateStdDialogButtonSizer(flags);
return topsizer; }
#endif // wxUSE_BUTTON
#else // !wxUSE_STATLINE
wxUnusedVar(separated);
wxUnusedVar(distance);
return buttonSizer;
#endif // wxUSE_STATLINE/!wxUSE_STATLINE
#else // !wxUSE_BUTTON
wxUnusedVar(separated);
wxUnusedVar(distance);
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
return sizer;
#endif // wxUSE_BUTTON/!wxUSE_BUTTON
#endif // __SMARTPHONE__/!__SMARTPHONE__ #endif // __SMARTPHONE__/!__SMARTPHONE__
return sizer;
}
wxSizer *wxDialogBase::CreateSeparatedButtonSizer(long flags)
{
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__)
wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
topsizer->Add(new wxStaticLine(this),
wxSizerFlags().Expand().DoubleBorder(wxBOTTOM));
topsizer->Add(sizer, wxSizerFlags().Expand());
sizer = topsizer;
#endif // wxUSE_STATLINE
return sizer;
} }
#if wxUSE_BUTTON #if wxUSE_BUTTON
@@ -365,27 +347,32 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
wxButton *yes = NULL; wxButton *yes = NULL;
wxButton *no = NULL; wxButton *no = NULL;
if (flags & wxOK){ if (flags & wxOK)
{
ok = new wxButton(this, wxID_OK); ok = new wxButton(this, wxID_OK);
sizer->AddButton(ok); sizer->AddButton(ok);
} }
if (flags & wxCANCEL){ if (flags & wxCANCEL)
{
wxButton *cancel = new wxButton(this, wxID_CANCEL); wxButton *cancel = new wxButton(this, wxID_CANCEL);
sizer->AddButton(cancel); sizer->AddButton(cancel);
} }
if (flags & wxYES){ if (flags & wxYES)
{
yes = new wxButton(this, wxID_YES); yes = new wxButton(this, wxID_YES);
sizer->AddButton(yes); sizer->AddButton(yes);
} }
if (flags & wxNO){ if (flags & wxNO)
{
no = new wxButton(this, wxID_NO); no = new wxButton(this, wxID_NO);
sizer->AddButton(no); sizer->AddButton(no);
} }
if (flags & wxHELP){ if (flags & wxHELP)
{
wxButton *help = new wxButton(this, wxID_HELP); wxButton *help = new wxButton(this, wxID_HELP);
sizer->AddButton(help); sizer->AddButton(help);
} }