use wxSizerFlags and updated CreateButtonSizer() in all generic dialogs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-10-09 21:08:45 +00:00
parent 1027cedd47
commit bd9f3519cf
10 changed files with 106 additions and 182 deletions

View File

@ -152,25 +152,16 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info)
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border());
const int defBorder = wxSizerFlags::GetDefaultBorder();
wxSizer *buttonSizer = CreateButtonSizer( wxOK , false, defBorder );
if(buttonSizer->GetChildren().GetCount() > 0 )
wxSizer *sizerBtns = CreateButtonSizer(wxOK);
if ( sizerBtns )
{
sizerTop->Add( buttonSizer, 0, wxEXPAND | wxALL, defBorder );
}
else
{
sizerTop->AddSpacer( defBorder );
delete buttonSizer;
sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border());
}
SetSizerAndFit(sizerTop);
CentreOnScreen();
wxWindow *ok = FindWindow(wxID_OK);
if (ok) ok->SetFocus();
return true;
}

View File

@ -48,20 +48,6 @@
#define wxID_LISTBOX 3000
// ---------------------------------------------------------------------------
// macros
// ---------------------------------------------------------------------------
/* Macro for avoiding #ifdefs when value have to be different depending on size of
device we display on - take it from something like wxDesktopPolicy in the future
*/
#if defined(__SMARTPHONE__)
#define wxLARGESMALL(large,small) small
#else
#define wxLARGESMALL(large,small) large
#endif
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
@ -256,6 +242,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
long styleLbox)
{
#ifdef __WXMAC__
// FIXME: why??
if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg & (~wxCANCEL) ) )
return false;
#else
@ -266,30 +253,24 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
// 1) text message
#ifdef __WXMAC__
// align text and list at least on mac
topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(15,0) );
#else
topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) );
#endif
topsizer->
Add(CreateTextSizer(message), wxSizerFlags().Expand().TripleBorder());
// 2) list box
m_listbox = CreateList(n,choices,styleLbox);
m_listbox = CreateList(n, choices, styleLbox);
if ( n > 0 )
m_listbox->SetSelection(0);
topsizer->Add( m_listbox, 1, wxEXPAND|wxLEFT|wxRIGHT, wxLARGESMALL(15,0) );
topsizer->
Add(m_listbox, wxSizerFlags().Expand().TripleBorder(wxLEFT | wxRIGHT));
// 3) buttons if any
wxSizer *buttonSizer = CreateButtonSizer( styleDlg & ButtonSizerFlags , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
wxSizer *
buttonSizer = CreateSeparatedButtonSizer(styleDlg & ButtonSizerFlags);
if ( buttonSizer )
{
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
}
else
{
topsizer->AddSpacer( wxLARGESMALL(15,0) );
delete buttonSizer;
topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder());
}
SetSizer( topsizer );

View File

@ -259,6 +259,7 @@ void wxGenericColourDialog::CreateWidgets()
const int sliderHeight = 160;
// first sliders
#if wxUSE_SLIDER
const int sliderX = singleCustomColourRect.x + singleCustomColourRect.width + sectionSpacing;
@ -271,26 +272,31 @@ void wxGenericColourDialog::CreateWidgets()
wxBoxSizer *sliderSizer = new wxBoxSizer( wxHORIZONTAL );
// 1) space for sliders
sliderSizer->Add( sliderX, sliderHeight );
sliderSizer->Add( redSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 );
sliderSizer->Add( greenSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 );
sliderSizer->Add( blueSlider, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 10 );
sliderSizer->Add(sliderX, sliderHeight );
topSizer->Add( sliderSizer, 0, wxCENTRE | wxALL, 10 );
wxSizerFlags flagsRight;
flagsRight.Align(wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL).DoubleBorder();
sliderSizer->Add(redSlider, flagsRight);
sliderSizer->Add(greenSlider,flagsRight);
sliderSizer->Add(blueSlider,flagsRight);
topSizer->Add(sliderSizer, wxSizerFlags().Centre().DoubleBorder());
#else
topSizer->Add( 1, sliderHeight, 0, wxCENTRE | wxALL, 15 );
topSizer->Add(1, sliderHeight, wxSizerFlags(1).Centre().TripleBorder());
#endif // wxUSE_SLIDER
#if wxUSE_STATLINE
// 2) static line
topSizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// then the custom button
topSizer->Add(new wxButton(this, wxID_ADD_CUSTOM,
_("Add to custom colours") ),
wxSizerFlags().DoubleHorzBorder());
// 3) buttons
wxSizer *buttonsizer = CreateButtonSizer( wxOK|wxCANCEL );
buttonsizer->Add( new wxButton(this, wxID_ADD_CUSTOM, _("Add to custom colours") ), 0, wxLEFT|wxRIGHT, 10 );
topSizer->Add( buttonsizer, 0, wxEXPAND | wxALL, 10 );
// then the standard buttons
wxSizer *buttonsizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
if ( buttonsizer )
{
topSizer->Add(buttonsizer, wxSizerFlags().Expand().DoubleBorder());
}
SetAutoLayout( true );
SetSizer( topSizer );

View File

@ -44,20 +44,6 @@ static const int ID_NEW = 1004;
static const int ID_SHOW_HIDDEN = 1005;
static const int ID_GO_HOME = 1006;
// ---------------------------------------------------------------------------
// macros
// ---------------------------------------------------------------------------
/* Macro for avoiding #ifdefs when value have to be different depending on size of
device we display on - take it from something like wxDesktopPolicy in the future
*/
#if defined(__SMARTPHONE__)
#define wxLARGESMALL(large,small) small
#else
#define wxLARGESMALL(large,small) large
#endif
//-----------------------------------------------------------------------------
// wxGenericDirDialog
//-----------------------------------------------------------------------------
@ -171,32 +157,31 @@ bool wxGenericDirDialog::Create(wxWindow* parent,
wxSize(300, 200),
dirStyle);
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) );
wxSizerFlags flagsBorder2;
flagsBorder2.DoubleBorder(wxTOP | wxLEFT | wxRIGHT);
topsizer->Add(m_dirCtrl, wxSizerFlags(flagsBorder2).Proportion(1).Expand());
#ifndef __SMARTPHONE__
// Make the an option depending on a flag?
wxCheckBox* check = new wxCheckBox( this, ID_SHOW_HIDDEN, _("Show hidden directories") );
topsizer->Add( check, 0, wxLEFT|wxRIGHT|wxTOP | wxALIGN_RIGHT, 10 );
wxCheckBox *
check = new wxCheckBox(this, ID_SHOW_HIDDEN, _("Show &hidden directories"));
topsizer->Add(check, wxSizerFlags(flagsBorder2).Right());
#endif // !__SMARTPHONE__
// 2) text ctrl
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, wxSizerFlags(flagsBorder2).Expand());
// 3) buttons if any
wxSizer *buttonSizer = CreateButtonSizer( wxOK|wxCANCEL , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
wxSizer *buttonSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
if ( buttonSizer )
{
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
}
else
{
topsizer->AddSpacer( wxLARGESMALL(10,0) );
delete buttonSizer;
topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder());
}
#ifdef __SMARTPHONE__
// overwrite menu achieved with earlier CreateButtonSizer() call
// overwrite menu set by CreateSeparatedButtonSizer() call above
SetRightMenu(wxID_ANY, _("Options"), dirMenu);
#endif

View File

@ -1116,48 +1116,50 @@ bool wxGenericFileDialog::Create( wxWindow *parent,
wxDefaultPosition, wxSize(540,200),
style2);
m_text = new wxTextCtrl(this, ID_TEXT, m_fileName,
wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER);
m_choice = new wxChoice(this, ID_CHOICE);
if (is_pda)
{
// PDAs have a different screen layout
mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 );
mainsizer->Add(m_list, wxSizerFlags(1).Expand().HorzBorder());
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
textsizer->Add( m_text, 1, wxCENTER | wxALL, 5 );
mainsizer->Add( textsizer, 0, wxEXPAND );
wxBoxSizer *textsizer = new wxBoxSizer(wxHORIZONTAL);
textsizer->Add(m_text, wxSizerFlags(1).Centre().Border());
mainsizer->Add(textsizer, wxSizerFlags().Expand());
m_check = NULL;
m_choice = new wxChoice( this, ID_CHOICE );
textsizer->Add( m_choice, 1, wxCENTER|wxALL, 5 );
textsizer->Add(m_choice, wxSizerFlags(1).Centre().Border());
wxSizer *bsizer = CreateButtonSizer( wxOK|wxCANCEL , false, 5 );
if(bsizer->GetChildren().GetCount() > 0 )
{
mainsizer->Add( bsizer, 0, wxEXPAND | wxALL, 5 );
}
else
{
delete bsizer;
}
wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL);
if ( bsizer )
mainsizer->Add(bsizer, wxSizerFlags().Expand().Border());
}
else
else // !is_pda
{
mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 );
mainsizer->Add(m_list, wxSizerFlags(1).Expand().DoubleHorzBorder());
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
textsizer->Add( m_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
textsizer->Add( new wxButton( this, wxID_OK ), 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
mainsizer->Add( textsizer, 0, wxEXPAND );
wxBoxSizer *textsizer = new wxBoxSizer(wxHORIZONTAL);
textsizer->Add(m_text, wxSizerFlags(1).Centre().
DoubleBorder(wxLEFT | wxRIGHT | wxTOP));
textsizer->Add(new wxButton(this, wxID_OK), wxSizerFlags().Centre().
DoubleBorder(wxLEFT | wxRIGHT | wxTOP));
mainsizer->Add(textsizer, wxSizerFlags().Expand());
wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
m_choice = new wxChoice( this, ID_CHOICE );
choicesizer->Add( m_choice, 1, wxCENTER|wxALL, 10 );
m_check = new wxCheckBox( this, ID_CHECK, _("Show hidden files") );
m_check->SetValue( ms_lastShowHidden );
choicesizer->Add( m_check, 0, wxCENTER|wxALL, 10 );
choicesizer->Add( new wxButton( this, wxID_CANCEL ), 0, wxCENTER | wxALL, 10 );
mainsizer->Add( choicesizer, 0, wxEXPAND );
wxSizerFlags flagsCentre;
flagsCentre.Centre().DoubleBorder();
wxBoxSizer *choicesizer = new wxBoxSizer(wxHORIZONTAL);
choicesizer->Add(m_choice, wxSizerFlags(flagsCentre).Proportion(1));
m_check = new wxCheckBox(this, ID_CHECK, _("Show &hidden files"));
m_check->SetValue(ms_lastShowHidden);
choicesizer->Add(m_check, flagsCentre);
choicesizer->Add(new wxButton(this, wxID_CANCEL), flagsCentre);
mainsizer->Add(choicesizer, wxSizerFlags().Expand());
}
SetWildcard(wildCard);

View File

@ -112,16 +112,13 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
topsizer->Add( icon_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif // wxUSE_STATTEXT
#if wxUSE_STATLINE
// 3) static line
topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif // wxUSE_STATLINE
// 4) buttons
// 3) buttons
int center_flag = wxEXPAND;
if (style & wxYES_NO) center_flag = wxALIGN_CENTRE;
topsizer->Add( CreateButtonSizer( style & (wxOK|wxCANCEL|wxYES_NO|wxYES_DEFAULT|wxNO_DEFAULT) ),
0, center_flag | wxALL, 10 );
if (style & wxYES_NO)
center_flag = wxALIGN_CENTRE;
wxSizer *sizerBtn = CreateSeparatedButtonSizer(style & ButtonSizerFlags);
if ( sizerBtn )
topsizer->Add(sizerBtn, 0, center_flag | wxALL, 10 );
SetAutoLayout( true );
SetSizer( topsizer );

View File

@ -54,20 +54,6 @@
#define wxSpinCtrl wxTextCtrl
#endif
// ---------------------------------------------------------------------------
// macros
// ---------------------------------------------------------------------------
/* Macro for avoiding #ifdefs when value have to be different depending on size of
device we display on - take it from something like wxDesktopPolicy in the future
*/
#if defined(__SMARTPHONE__)
#define wxLARGESMALL(large,small) small
#else
#define wxLARGESMALL(large,small) large
#endif
// ============================================================================
// implementation
// ============================================================================
@ -127,16 +113,11 @@ wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
topsizer->Add( inputsizer, 0, wxEXPAND | wxLEFT|wxRIGHT, 5 );
// 3) buttons if any
wxSizer *buttonSizer = CreateButtonSizer( wxOK|wxCANCEL , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
wxSizer *buttonSizer = CreateSeparatedButtonSizer(wxOK | wxCANCEL);
if ( buttonSizer )
{
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
topsizer->Add(buttonSizer, wxSizerFlags().Expand().DoubleBorder());
}
else
{
topsizer->AddSpacer( wxLARGESMALL(15,0) );
delete buttonSizer;
}
SetSizer( topsizer );
SetAutoLayout( true );

View File

@ -246,14 +246,11 @@ void wxGenericPrintDialog::Init(wxWindow * WXUNUSED(parent))
mainsizer->Add( bottomsizer, 0, wxTOP|wxLEFT|wxRIGHT, 12 );
#if wxUSE_STATLINE
// 4) static line
mainsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
// 4) buttons
// 5) buttons
mainsizer->Add( CreateButtonSizer( wxOK|wxCANCEL), 0, wxEXPAND|wxALL, 10 );
wxSizer *sizerBtn = CreateSeparatedButtonSizer( wxOK|wxCANCEL);
if ( sizerBtn )
mainsizer->Add(sizerBtn, 0, wxEXPAND|wxALL, 10 );
SetAutoLayout( true );
SetSizer( mainsizer );

View File

@ -119,15 +119,11 @@ void wxPropertySheetDialog::CreateButtons(int flags)
#endif
wxSizer *buttonSizer = CreateButtonSizer( flags & ButtonSizerFlags );
if(buttonSizer->GetChildren().GetCount() > 0 )
if( buttonSizer )
{
m_innerSizer->Add( buttonSizer, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 2);
m_innerSizer->AddSpacer(2);
}
else
{
delete buttonSizer;
}
#ifdef __POCKETPC__
// restore system option

View File

@ -51,20 +51,6 @@ const wxChar wxGetPasswordFromUserPromptStr[] = wxT("Enter Password");
static const int wxID_TEXT = 3000;
// ---------------------------------------------------------------------------
// macros
// ---------------------------------------------------------------------------
/* Macro for avoiding #ifdefs when value have to be different depending on size of
device we display on - take it from something like wxDesktopPolicy in the future
*/
#if defined(__SMARTPHONE__)
#define wxLARGESMALL(large,small) small
#else
#define wxLARGESMALL(large,small) large
#endif
// ============================================================================
// implementation
// ============================================================================
@ -96,16 +82,23 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxSizerFlags flagsBorder2;
flagsBorder2.DoubleBorder();
#if wxUSE_STATTEXT
// 1) text message
topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) );
topsizer->Add(CreateTextSizer(message), flagsBorder2);
#endif
// 2) text ctrl
m_textctrl = new wxTextCtrl(this, wxID_TEXT, value,
wxDefaultPosition, wxSize(300, wxDefaultCoord),
style & ~wxTextEntryDialogStyle);
topsizer->Add( m_textctrl, style & wxTE_MULTILINE ? 1 : 0, wxEXPAND | wxLEFT|wxRIGHT, wxLARGESMALL(15,0) );
topsizer->Add(m_textctrl,
wxSizerFlags(style & wxTE_MULTILINE ? 1 : 0).
Expand().
TripleBorder(wxLEFT | wxRIGHT));
#if wxUSE_VALIDATORS
wxTextValidator validator( wxFILTER_NONE, &m_value );
@ -113,15 +106,10 @@ wxTextEntryDialog::wxTextEntryDialog(wxWindow *parent,
#endif // wxUSE_VALIDATORS
// 3) buttons if any
wxSizer *buttonSizer = CreateButtonSizer( style & ButtonSizerFlags , true, wxLARGESMALL(10,0) );
if(buttonSizer->GetChildren().GetCount() > 0 )
wxSizer *buttonSizer = CreateSeparatedButtonSizer(style & ButtonSizerFlags);
if ( buttonSizer )
{
topsizer->Add( buttonSizer, 0, wxEXPAND | wxALL, wxLARGESMALL(10,0) );
}
else
{
topsizer->AddSpacer( wxLARGESMALL(15,0) );
delete buttonSizer;
topsizer->Add(buttonSizer, wxSizerFlags(flagsBorder2).Expand());
}
SetAutoLayout( true );