More common code moved from generic dialogs to wxDialogBase::CreateButtonSizer(). New system option 'wince.dialog.real-ok-cancel'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36880 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2006-01-15 10:06:15 +00:00
parent f3078f075b
commit 897b24cf5c
10 changed files with 184 additions and 125 deletions

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dialogs.cpp // Name: life/dialogs.cpp
// Purpose: Life! dialogs // Purpose: Life! dialogs
// Author: Guillermo Rodriguez Garcia, <guille@iies.es> // Author: Guillermo Rodriguez Garcia, <guille@iies.es>
// Modified by: // Modified by:
@@ -86,7 +86,7 @@ LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent)
if (isPDA && if (isPDA &&
wxSystemSettings::GetMetric(wxSYS_SCREEN_X) < wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)) wxSystemSettings::GetMetric(wxSYS_SCREEN_X) < wxSystemSettings::GetMetric(wxSYS_SCREEN_Y))
{ {
listSize = wxSize(-1, 50); listSize = wxSize(wxDefaultCoord, 50);
screenIsHorizontal = false; screenIsHorizontal = false;
} }
@@ -128,21 +128,21 @@ LifeSamplesDialog::LifeSamplesDialog(wxWindow *parent)
sizer3->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 10 ); sizer3->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 10 );
#endif // wxUSE_STATLINE #endif // wxUSE_STATLINE
sizer3->Add( sizer2, 1, wxGROW | wxALL, 5 ); sizer3->Add( sizer2, 1, wxGROW | wxALL, 5 );
#if wxUSE_STATLINE
if (!isPDA)
sizer3->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 10 );
#endif // wxUSE_STATLINE
#if defined(__SMARTPHONE__) wxSizer *buttonSizer = CreateButtonSizer( wxOK|wxCANCEL , true, 10 );
SetLeftMenu(wxID_CANCEL); if(buttonSizer->GetChildren().GetCount() > 0 )
SetRightMenu(wxID_OK); {
#endif sizer3->Add( buttonSizer, 0, wxEXPAND | wxALL, 10 );
}
else
{
sizer3->AddSpacer( 10 );
delete buttonSizer;
}
// activate // activate
SetSizer(sizer3); SetSizer(sizer3);
#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
#if !defined(__POCKETPC__) && !defined(__SMARTPHONE__)
sizer3->Add( CreateButtonSizer(wxOK | wxCANCEL), 0, wxCENTRE | wxALL, isPDA ? 2 : 10 );
sizer3->SetSizeHints(this); sizer3->SetSizeHints(this);
sizer3->Fit(this); sizer3->Fit(this);
Centre(wxBOTH | wxCENTRE_ON_SCREEN); Centre(wxBOTH | wxCENTRE_ON_SCREEN);
@@ -199,24 +199,25 @@ LifeAboutDialog::LifeAboutDialog(wxWindow *parent)
<guille@iies.es>\n\n\ <guille@iies.es>\n\n\
Portions of the code are based in XLife;\n\ Portions of the code are based in XLife;\n\
XLife is (c) 1989 by Jon Bennett et al.")), XLife is (c) 1989 by Jon Bennett et al.")),
0, wxCENTRE | wxALL, 20 ); 0, wxCENTRE | wxRIGHT|wxLEFT|wxTOP, 20 );
#if wxUSE_STATLINE
sizer->Add( new wxStaticLine(this, wxID_ANY), 0, wxGROW | wxLEFT | wxRIGHT, 5 );
#endif // wxUSE_STATLINE
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__)) // buttons if any
sizer->Add( CreateButtonSizer(wxOK), 0, wxCENTRE | wxALL, 10 ); wxSizer *buttonSizer = CreateButtonSizer( wxOK , true, 10 );
#endif if(buttonSizer->GetChildren().GetCount() > 0 )
{
sizer->Add( buttonSizer, 0, wxEXPAND | wxALL, 10 );
}
else
{
sizer->AddSpacer( 20 );
delete buttonSizer;
}
// activate // activate
SetSizer(sizer); SetSizer(sizer);
#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
#if ! (defined(__SMARTPHONE__) || defined(__POCKETPC__))
sizer->SetSizeHints(this); sizer->SetSizeHints(this);
sizer->Fit(this); sizer->Fit(this);
Centre(wxBOTH | wxCENTRE_ON_SCREEN); Centre(wxBOTH | wxCENTRE_ON_SCREEN);
#endif #endif
} }

View File

@@ -123,6 +123,8 @@ wxWinCE:
- ::wxGetUserName() implemented. - ::wxGetUserName() implemented.
- wxDisplay enumeration support. - wxDisplay enumeration support.
- Fixed wxFileDialog breakage on WinCE due to incorrect structure size. - Fixed wxFileDialog breakage on WinCE due to incorrect structure size.
- new wxSystemOption "wince.dialog.real-ok-cancel" to switch between WinCE
guidelines with Ok-only dialogs and dialogs using wxButtons.
Unix: Unix:

View File

@@ -32,6 +32,13 @@ extern WXDLLEXPORT_DATA(const wxChar*) wxDialogNameStr;
class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
{ {
public: public:
enum
{
// all flags allowed in wxDialogBase::CreateButtonSizer()
ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT
};
wxDialogBase() { Init(); } wxDialogBase() { Init(); }
virtual ~wxDialogBase() { } virtual ~wxDialogBase() { }
@@ -56,9 +63,11 @@ public:
wxSizer *CreateTextSizer( const wxString &message ); wxSizer *CreateTextSizer( const wxString &message );
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
#if wxUSE_BUTTON
// places buttons into a horizontal wxBoxSizer // places buttons into a horizontal wxBoxSizer
wxSizer *CreateButtonSizer( long flags ); wxSizer *CreateButtonSizer( long flags,
bool separated = false,
wxCoord distance = 0 );
#if wxUSE_BUTTON
wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags ); wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
#endif // wxUSE_BUTTON #endif // wxUSE_BUTTON

View File

@@ -1381,7 +1381,11 @@ SettingsDialog::SettingsDialog(wxWindow* win)
|wxRESIZE_BORDER |wxRESIZE_BORDER
#endif #endif
); );
CreateButtons(wxOK|wxCANCEL|wxHELP); CreateButtons(wxOK|wxCANCEL
#ifndef __POCKETPC__
|wxHELP
#endif
);
wxBookCtrlBase* notebook = GetBookCtrl(); wxBookCtrlBase* notebook = GetBookCtrl();

View File

@@ -36,6 +36,9 @@
#include "wx/containr.h" #include "wx/containr.h"
#endif #endif
#include "wx/statline.h"
#include "wx/sysopt.h"
#if wxUSE_STATTEXT #if wxUSE_STATTEXT
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -273,11 +276,12 @@ wxStaticTextBase
#endif // wxUSE_STATTEXT #endif // wxUSE_STATTEXT
#if wxUSE_BUTTON wxSizer *wxDialogBase::CreateButtonSizer( long flags, bool separated, wxCoord distance )
wxSizer *wxDialogBase::CreateButtonSizer( long flags )
{ {
#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);
@@ -296,14 +300,64 @@ wxSizer *wxDialogBase::CreateButtonSizer( long flags )
} }
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
return sizer; return sizer;
#else
return CreateStdDialogButtonSizer( flags ); #else // !__SMARTPHONE__
#endif
#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
wxSizer* buttonSizer = CreateStdDialogButtonSizer( flags );
// Mac Human Interface Guidelines recommend not to use static lines as grouping elements
#if wxUSE_STATLINE && !defined(__WXMAC__)
if(!separated)
return buttonSizer;
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxBOTTOM, distance );
topsizer->Add( buttonSizer, 0, wxEXPAND );
return topsizer;
#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__
} }
#if wxUSE_BUTTON
wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags ) wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
{ {
wxStdDialogButtonSizer *sizer = new wxStdDialogButtonSizer(); wxStdDialogButtonSizer *sizer = new wxStdDialogButtonSizer();
wxButton *ok = NULL; wxButton *ok = NULL;
wxButton *yes = NULL; wxButton *yes = NULL;
wxButton *no = NULL; wxButton *no = NULL;
@@ -365,5 +419,4 @@ wxStdDialogButtonSizer *wxDialogBase::CreateStdDialogButtonSizer( long flags )
return sizer; return sizer;
} }
#endif // wxUSE_BUTTON #endif // wxUSE_BUTTON

View File

@@ -39,10 +39,7 @@
#include "wx/arrstr.h" #include "wx/arrstr.h"
#endif #endif
#if wxUSE_STATLINE #include "wx/statline.h"
#include "wx/statline.h"
#endif
#include "wx/generic/choicdgg.h" #include "wx/generic/choicdgg.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -288,25 +285,17 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
topsizer->Add( m_listbox, 1, wxEXPAND|wxLEFT|wxRIGHT, wxLARGESMALL(15,0) ); topsizer->Add( m_listbox, 1, wxEXPAND|wxLEFT|wxRIGHT, wxLARGESMALL(15,0) );
// smart phones does not support or do not waste space for wxButtons // 3) buttons if any
#ifdef __SMARTPHONE__ wxSizer *buttonSizer = CreateButtonSizer( styleDlg & ButtonSizerFlags , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
SetRightMenu(wxID_CANCEL, _("Cancel")); {
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
#else // __SMARTPHONE__/!__SMARTPHONE__ }
else
// Mac Human Interface Guidelines recommend not to use static lines as grouping elements {
#ifndef __WXMAC__ topsizer->AddSpacer( wxLARGESMALL(15,0) );
#if wxUSE_STATLINE delete buttonSizer;
// 3) static line }
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
#endif
// 4) buttons
topsizer->Add( CreateButtonSizer( styleDlg & (wxOK|wxCANCEL) ), 0, wxEXPAND | wxALL, 10 );
#endif // !__SMARTPHONE__
SetSizer( topsizer ); SetSizer( topsizer );

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: dirdlg.cpp // Name: src/generic/dirdlg.cpp
// Purpose: wxDirDialog // Purpose: wxDirDialog
// Author: Harm van der Heijden, Robert Roebling & Julian Smart // Author: Harm van der Heijden, Robert Roebling & Julian Smart
// Modified by: // Modified by:
@@ -93,7 +93,7 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
// smart phones does not support or do not waste space for wxButtons // smartphones does not support or do not waste space for wxButtons
#if defined(__SMARTPHONE__) #if defined(__SMARTPHONE__)
wxMenu *dirMenu = new wxMenu; wxMenu *dirMenu = new wxMenu;
@@ -108,8 +108,6 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
dirMenu->AppendSeparator(); dirMenu->AppendSeparator();
dirMenu->Append(wxID_CANCEL, _("Cancel")); dirMenu->Append(wxID_CANCEL, _("Cancel"));
SetRightMenu(wxID_ANY, _("Options"), dirMenu);
#else #else
// 0) 'New' and 'Home' Buttons // 0) 'New' and 'Home' Buttons
@@ -175,18 +173,23 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition ); m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition );
topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) ); topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) );
#ifndef __SMARTPHONE__ // 3) buttons if any
wxSizer *buttonSizer = CreateButtonSizer( wxOK|wxCANCEL , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
{
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
}
else
{
topsizer->AddSpacer( wxLARGESMALL(10,0) );
delete buttonSizer;
}
#if wxUSE_STATLINE #ifdef __SMARTPHONE__
// 3) Static line // overwrite menu achieved with earlier CreateButtonSizer() call
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); SetRightMenu(wxID_ANY, _("Options"), dirMenu);
#endif #endif
// 4) Buttons
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxEXPAND | wxALL, 10 );
#endif // !__SMARTPHONE__
m_input->SetFocus(); m_input->SetFocus();
SetAutoLayout( true ); SetAutoLayout( true );

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: numdlgg.cpp // Name: src/generic/numdlgg.cpp
// Purpose: wxGetNumberFromUser implementation // Purpose: wxGetNumberFromUser implementation
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
@@ -111,7 +111,7 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
#if wxUSE_STATTEXT #if wxUSE_STATTEXT
// prompt if any // prompt if any
if (!prompt.IsEmpty()) if (!prompt.empty())
inputsizer->Add( new wxStaticText( this, wxID_ANY, prompt ), 0, wxCENTER | wxLEFT, 10 ); inputsizer->Add( new wxStaticText( this, wxID_ANY, prompt ), 0, wxCENTER | wxLEFT, 10 );
#endif #endif
@@ -124,24 +124,19 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
#endif #endif
inputsizer->Add( m_spinctrl, 1, wxCENTER | wxLEFT | wxRIGHT, 10 ); inputsizer->Add( m_spinctrl, 1, wxCENTER | wxLEFT | wxRIGHT, 10 );
// add both // add both
topsizer->Add( inputsizer, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 ); topsizer->Add( inputsizer, 0, wxEXPAND | wxLEFT|wxRIGHT, 5 );
// smart phones does not support or do not waste space for wxButtons // 3) buttons if any
#ifdef __SMARTPHONE__ wxSizer *buttonSizer = CreateButtonSizer( wxOK|wxCANCEL , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
SetRightMenu(wxID_CANCEL, _("Cancel")); {
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
#else // __SMARTPHONE__/!__SMARTPHONE__ }
else
#if wxUSE_STATLINE {
// 3) static line topsizer->AddSpacer( wxLARGESMALL(15,0) );
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); delete buttonSizer;
#endif }
// 4) buttons
topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxEXPAND | wxALL, 10 );
#endif // !__SMARTPHONE__
SetSizer( topsizer ); SetSizer( topsizer );
SetAutoLayout( true ); SetAutoLayout( true );

View File

@@ -30,6 +30,7 @@
#include "wx/bookctrl.h" #include "wx/bookctrl.h"
#include "wx/generic/propdlg.h" #include "wx/generic/propdlg.h"
#include "wx/sysopt.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxPropertySheetDialog // wxPropertySheetDialog
@@ -89,19 +90,27 @@ void wxPropertySheetDialog::LayoutDialog()
// Creates the buttons, if any // Creates the buttons, if any
void wxPropertySheetDialog::CreateButtons(int flags) void wxPropertySheetDialog::CreateButtons(int flags)
{ {
#if defined(__SMARTPHONE__) #ifdef __POCKETPC__
// TODO: create a right-click menu with all the other IDs available. // keep system option status
// Perhaps that could be embedded in CreateButtonSizer() directly. const wxChar *optionName = wxT("wince.dialog.real-ok-cancel");
SetRightMenu(wxID_CANCEL); const int status = wxSystemOptions::GetOptionInt(optionName);
SetLeftMenu(wxID_OK); wxSystemOptions::SetOption(optionName,0);
wxUnusedVar(flags); #endif
#elif defined(__POCKETPC__)
// Do nothing wxSizer *buttonSizer = CreateButtonSizer( flags & ButtonSizerFlags );
wxUnusedVar(flags); if(buttonSizer->GetChildren().GetCount() > 0 )
#else {
wxSizer* sizer = CreateButtonSizer(flags); m_innerSizer->Add( buttonSizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2);
m_innerSizer->Add( sizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2); m_innerSizer->AddSpacer(2);
m_innerSizer->AddSpacer(2); }
else
{
delete buttonSizer;
}
#ifdef __POCKETPC__
// restore system option
wxSystemOptions::SetOption(optionName,status);
#endif #endif
} }

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: textdlgg.cpp // Name: src/generic/textdlgg.cpp
// Purpose: wxTextEntryDialog // Purpose: wxTextEntryDialog
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
@@ -107,25 +107,19 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
wxTextValidator validator( wxFILTER_NONE, &m_value ); wxTextValidator validator( wxFILTER_NONE, &m_value );
m_textctrl->SetValidator( validator ); m_textctrl->SetValidator( validator );
#endif #endif // wxUSE_VALIDATORS
// wxUSE_VALIDATORS
// smart phones does not support or do not waste space for wxButtons // 3) buttons if any
#ifdef __SMARTPHONE__ wxSizer *buttonSizer = CreateButtonSizer( style & ButtonSizerFlags , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
SetRightMenu(wxID_CANCEL, _("Cancel")); {
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
#else // __SMARTPHONE__/!__SMARTPHONE__ }
else
#if wxUSE_STATLINE {
// 3) static line topsizer->AddSpacer( wxLARGESMALL(15,0) );
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 ); delete buttonSizer;
#endif }
// 4) buttons
topsizer->Add( CreateButtonSizer( style ), 0, wxEXPAND | wxALL, 10 );
#endif // !__SMARTPHONE__
SetAutoLayout( true ); SetAutoLayout( true );
SetSizer( topsizer ); SetSizer( topsizer );