1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

ShuttleGui lets you specify whether a button is default. Use that.

This commit is contained in:
Paul Licameli 2019-11-19 11:33:37 -05:00
parent cd4266792a
commit bca0afd52e
9 changed files with 32 additions and 18 deletions

View File

@ -238,9 +238,10 @@ AboutDialog::AboutDialog(wxWindow * parent)
PopulateLicensePage( S );
}
S.EndNotebook();
wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK, _("OK"));
ok->SetDefault();
S.Prop(0).AddWindow( ok );
S.Id(wxID_OK)
.Prop(0)
.AddButton(_("OK"), wxALIGN_CENTER, true);
Fit();
this->Centre();

View File

@ -225,7 +225,7 @@ void BenchmarkDialog::MakeBenchmarkDialog()
{
S.StartHorizontalLay(wxALIGN_LEFT, false);
{
S.Id(RunID).AddButton(_("Run"))->SetDefault();
S.Id(RunID).AddButton(_("Run"), wxALIGN_CENTRE, true);
S.Id(BSaveID).AddButton(_("Save"));
/* i18n-hint verb; to empty or erase */
S.Id(ClearID).AddButton(_("Clear"));

View File

@ -364,12 +364,12 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S)
PopulateList();
mCopySelectedFilesButton =
S.Id(CopySelectedFilesButtonID).AddButton(
_("Copy Selected Files"),
wxALIGN_LEFT);
S.Id(CopySelectedFilesButtonID)
.AddButton(
_("Copy Selected Files"),
wxALIGN_LEFT, true);
mCopySelectedFilesButton->Enable(
mFileListCtrl->GetSelectedItemCount() > 0);
mCopySelectedFilesButton->SetDefault();
mCopySelectedFilesButton->SetFocus();
}
S.EndStatic();

View File

@ -135,7 +135,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
S.StartHorizontalLay(wxALIGN_RIGHT, false);
{
S.SetBorder(10);
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
S.Id(wxID_OK).AddButton(_("&OK"), wxALIGN_CENTER, true);
}
S.EndHorizontalLay();
}

View File

@ -348,7 +348,8 @@ wxCheckBox * ShuttleGuiBase::AddCheckBoxOnRight( const wxString &Prompt, bool Se
return pCheckBox;
}
wxButton * ShuttleGuiBase::AddButton(const wxString &Text, int PositionFlags)
wxButton * ShuttleGuiBase::AddButton(
const wxString &Text, int PositionFlags, bool setDefault)
{
UseUpId();
if( mShuttleMode != eIsCreating )
@ -359,10 +360,13 @@ wxButton * ShuttleGuiBase::AddButton(const wxString &Text, int PositionFlags)
mpWind->SetName(wxStripMenuCodes(Text));
miProp=0;
UpdateSizersCore(false, PositionFlags | wxALL);
if (setDefault)
pBtn->SetDefault();
return pBtn;
}
wxBitmapButton * ShuttleGuiBase::AddBitmapButton(const wxBitmap &Bitmap, int PositionFlags)
wxBitmapButton * ShuttleGuiBase::AddBitmapButton(
const wxBitmap &Bitmap, int PositionFlags, bool setDefault)
{
UseUpId();
if( mShuttleMode != eIsCreating )
@ -375,6 +379,8 @@ wxBitmapButton * ShuttleGuiBase::AddBitmapButton(const wxBitmap &Bitmap, int Pos
// wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
miProp=0;
UpdateSizersCore(false, PositionFlags | wxALL);
if (setDefault)
pBtn->SetDefault();
return pBtn;
}

View File

@ -139,10 +139,16 @@ public:
wxTreeCtrl * AddTree();
wxRadioButton * AddRadioButton( const wxString & Prompt );
wxRadioButton * AddRadioButtonToGroup( const wxString & Prompt);
// Only the last button specified as default (if more than one) will be
// Always ORs the flags with wxALL (which affects borders):
wxButton * AddButton( const wxString & Text, int PositionFlags = wxALIGN_CENTRE );
wxButton * AddButton(
const wxString & Text, int PositionFlags = wxALIGN_CENTRE,
bool setDefault = false );
// Only the last button specified as default (if more than one) will be
// Always ORs the flags with wxALL (which affects borders):
wxBitmapButton * AddBitmapButton(const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE);
wxBitmapButton * AddBitmapButton(
const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE,
bool setDefault = false );
// When PositionFlags is 0, applies wxALL (which affects borders),
// and either wxALIGN_CENTER (if bCenter) or else wxEXPAND
wxStaticText * AddVariableText(const wxString &Str, bool bCenter = false, int PositionFlags = 0);

View File

@ -140,10 +140,11 @@ void SplashDialog::Populate( ShuttleGui & S )
{
S.SetBorder( 5 );
S.Id( DontShowID).AddCheckBox( _("Don't show this again at start up"), !bShow );
wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK);
ok->SetDefault();
S.SetBorder( 5 );
S.Prop(0).AddWindow( ok, wxALIGN_RIGHT| wxALL );
S.Id(wxID_OK)
.Prop(0)
.AddButton(_("OK"), wxALIGN_RIGHT| wxALL, true);
}
S.EndVerticalLay();
}

View File

@ -533,7 +533,7 @@ ProgressResult ExportCL::Export(AudacityProject *project,
S.AddTextWindow(cmd + wxT("\n\n") + output);
S.StartHorizontalLay(wxALIGN_CENTER, false);
{
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
S.Id(wxID_OK).AddButton(_("&OK"), wxALIGN_CENTER, true);
}
dlg.GetSizer()->AddSpacer(5);
dlg.Layout();

View File

@ -189,7 +189,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
S.Prop(1).AddWindow( html, wxEXPAND );
S.Id( wxID_CANCEL ).AddButton( _("Close") )->SetDefault();
S.Id( wxID_CANCEL ).AddButton( _("Close"), wxALIGN_CENTER, true );
}
S.EndPanel();