1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

Remove some more uses of naked wxString in the interface of ShuttleGui

This commit is contained in:
Paul Licameli 2019-12-26 15:35:56 -05:00
commit f60d8d299a
6 changed files with 38 additions and 87 deletions

View File

@ -411,7 +411,7 @@ visit our [[https://forum.audacityteam.org/|forum]].");
wxT("</center>")
);
auto pPage = S.StartNotebookPage( _("Audacity") );
auto pPage = S.StartNotebookPage( XO("Audacity") );
S.StartVerticalLay(1);
{
//v For now, change to AudacityLogoWithName via old-fashioned way, not Theme.
@ -464,7 +464,7 @@ visit our [[https://forum.audacityteam.org/|forum]].");
void AboutDialog::PopulateInformationPage( ShuttleGui & S )
{
wxString informationStr; // string to build up list of information in
S.StartNotebookPage( _("Build Information") ); // start the tab
S.StartNotebookPage( XO("Build Information") ); // start the tab
S.StartVerticalLay(2); // create the window
HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition,
wxSize(ABOUT_DIALOG_WIDTH, 264),
@ -718,7 +718,7 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S )
void AboutDialog::PopulateLicensePage( ShuttleGui & S )
{
S.StartNotebookPage( _("GPL License") );
S.StartNotebookPage( XO("GPL License") );
S.StartVerticalLay(1);
HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1,
wxDefaultPosition,

View File

@ -1047,18 +1047,20 @@ void ShuttleGuiBase::EndSimplebook()
}
wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name )
wxNotebookPage * ShuttleGuiBase::StartNotebookPage(
const TranslatableString & Name )
{
if( mShuttleMode != eIsCreating )
return NULL;
// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx);
auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent );
wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent());
pPage->SetName(Name);
const auto translated = Name.Translation();
pPage->SetName(translated);
pNotebook->AddPage(
pPage,
Name);
translated);
SetProportions( 1 );
mpParent = pPage;
@ -1068,27 +1070,6 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name )
return pPage;
}
void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage * pPage )
{
if( mShuttleMode != eIsCreating )
return;
// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx);
auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent );
// wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent());
pPage->Create( mpParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("panel"));
pPage->SetName(Name);
pNotebook->AddPage(
pPage,
Name);
SetProportions( 1 );
mpParent = pPage;
pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
// UpdateSizers();
}
void ShuttleGuiBase::EndNotebookPage()
{
if( mShuttleMode != eIsCreating )
@ -1468,9 +1449,9 @@ wxSlider * ShuttleGuiBase::DoTieSlider(
}
wxChoice * ShuttleGuiBase::DoTieChoice(
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
WrappedType &WrappedRef,
int &Selected,
const TranslatableStrings &choices )
{
HandleOptionality( Prompt );
@ -1484,17 +1465,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
{
case eIsCreating:
{
if( WrappedRef.IsString() ) {
auto str = WrappedRef.ReadAsString();
auto begin = choices.begin();
auto iter = std::find_if( begin, choices.end(),
[&str]( const TranslatableString &choice ){
return str == choice.Translation(); } );
int Selected = std::distance( begin, iter );
pChoice = AddChoice( Prompt, choices, Selected );
}
else
pChoice = AddChoice( Prompt, choices, WrappedRef.ReadAsInt() );
pChoice = AddChoice( Prompt, choices, Selected );
ShuttleGui::SetMinSize(pChoice, choices);
}
break;
@ -1506,10 +1477,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg);
pChoice = wxDynamicCast(pWnd, wxChoice);
wxASSERT( pChoice );
if( WrappedRef.IsString())
WrappedRef.WriteToAsString( pChoice->GetStringSelection());
else
WrappedRef.WriteToAsInt( pChoice->GetSelection() );
Selected = pChoice->GetSelection();
}
break;
case eIsSettingToDialog:
@ -1517,10 +1485,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice(
wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg);
pChoice = wxDynamicCast(pWnd, wxChoice);
wxASSERT( pChoice );
if( WrappedRef.IsString() )
pChoice->SetStringSelection( WrappedRef.ReadAsString() );
else
pChoice->SetSelection( WrappedRef.ReadAsInt() );
pChoice->SetSelection( Selected );
}
break;
default:
@ -1724,20 +1689,16 @@ wxSlider * ShuttleGuiBase::TieVSlider(
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
wxString &Selected,
TranslatableString &Selected,
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
}
wxChoice * ShuttleGuiBase::TieChoice(
const TranslatableString &Prompt,
int &Selected,
const TranslatableStrings &choices )
{
WrappedType WrappedRef( Selected );
return DoTieChoice( Prompt, WrappedRef, choices );
int Index = make_iterator_range( choices ).index( Selected );
auto result = TieChoice( Prompt, Index, choices );
if ( Index >= 0 && Index < choices.size() )
Selected = choices[ Index ];
else
Selected = {};
return result;
}
//-----------------------------------------------------------------------//

View File

@ -343,7 +343,6 @@ public:
wxMenuBar * AddMenuBar( );
wxMenu * AddMenu( const TranslatableString & Title );
void AddIcon( wxBitmap * pBmp);
void AddIconButton( const wxString & Command, const wxString & Params,wxBitmap * pBmp );
void AddFixedText(
const TranslatableString & Str, bool bCenter = false, int wrapWidth = 0 );
void AddConstTextBox(
@ -380,8 +379,7 @@ public:
// Use within any kind of book control:
// IDs of notebook pages cannot be chosen by the caller
wxNotebookPage * StartNotebookPage( const wxString & Name );
void StartNotebookPage( const wxString & Name, wxNotebookPage * pPage );
wxNotebookPage * StartNotebookPage( const TranslatableString & Name );
void EndNotebookPage();
@ -412,7 +410,8 @@ public:
wxCheckBox * TieCheckBoxOnRight( const TranslatableString & Prompt, bool & Var );
wxChoice * TieChoice(
const TranslatableString &Prompt, wxString &Selected, const TranslatableStrings &choices );
const TranslatableString &Prompt,
TranslatableString &Selected, const TranslatableStrings &choices );
wxChoice * TieChoice(
const TranslatableString &Prompt, int &Selected, const TranslatableStrings &choices );
@ -563,9 +562,6 @@ private:
wxTextCtrl * DoTieNumericTextBox(
const TranslatableString &Prompt, WrappedType & WrappedRef, const int nChars);
wxCheckBox * DoTieCheckBox( const TranslatableString &Prompt, WrappedType & WrappedRef );
wxChoice * DoTieChoice(
const TranslatableString &Prompt, WrappedType & WrappedRef,
const TranslatableStrings & choices );
wxSlider * DoTieSlider(
const TranslatableString &Prompt,
WrappedType & WrappedRef, const int max, const int min = 0 );

View File

@ -344,7 +344,7 @@ private:
EffectHostInterface *mHost;
bool mUseLatency;
wxString mUIType;
TranslatableString mUIType;
DECLARE_EVENT_TABLE()
};
@ -359,9 +359,13 @@ AudioUnitEffectOptionsDialog::AudioUnitEffectOptionsDialog(wxWindow * parent, Ef
mHost = host;
mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true);
mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full"));
mUIType = wxGetTranslation(mUIType);
// Expect one of three string values from the config file
wxString uiType;
mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), uiType, wxT("Full"));
// Get the localization of the string for display to the user
mUIType = TranslatableString{ uiType, {} };
ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S);
@ -410,8 +414,8 @@ void AudioUnitEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_LEFT);
{
S.TieChoice(XO("Select &interface"),
mUIType,
{ XO("Full"), XO("Generic"), XO("Basic") });
mUIType,
{ XO("Full"), XO("Generic"), XO("Basic") });
}
S.EndHorizontalLay();
}
@ -438,21 +442,11 @@ void AudioUnitEffectOptionsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
ShuttleGui S(this, eIsGettingFromDialog);
PopulateOrExchange(S);
if (mUIType == _("Full"))
{
mUIType = wxT("Full");
}
else if (mUIType == _("Generic"))
{
mUIType = wxT("Generic");
}
else if (mUIType == _("Basic"))
{
mUIType = wxT("Basic");
}
// un-translate the type
auto uiType = mUIType.MSGID().GET();
mHost->SetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency);
mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), mUIType);
mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), uiType);
EndModal(wxID_OK);
}

View File

@ -998,7 +998,7 @@ void Exporter::CreateUserPane(wxWindow *parent)
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
{
// Name of simple book page is not displayed
S.StartNotebookPage( wxEmptyString );
S.StartNotebookPage( {} );
pPlugin->OptionsCreate(S, j);
S.EndNotebookPage();
}

View File

@ -309,7 +309,7 @@ void ExportMultipleDialog::PopulateOrExchange(ShuttleGui& S)
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
{
// Name of simple book page is not displayed
S.StartNotebookPage( wxEmptyString );
S.StartNotebookPage( {} );
pPlugin->OptionsCreate(S, j);
S.EndNotebookPage();
}