Define and use wxArrayStringEx...

reducing verbosity where there were repeated calls of Add(), and defining
move construction and assignment for efficient returns from functions
This commit is contained in:
Paul Licameli 2019-02-12 16:30:22 -05:00
parent 07a42e8e19
commit 6d5bc21d50
30 changed files with 383 additions and 262 deletions

View File

@ -111,14 +111,14 @@ static const wxString FadeEnds = XO("Fade Ends");
static const wxString SelectToEnds = XO("Select to Ends");
wxArrayString MacroCommands::GetNamesOfDefaultMacros()
wxArrayStringEx MacroCommands::GetNamesOfDefaultMacros()
{
wxArrayString defaults;
defaults.Add( GetCustomTranslation( MP3Conversion ) );
defaults.Add( GetCustomTranslation( FadeEnds ) );
//Don't add this one anymore, as there is a new menu command for it.
//defaults.Add( GetCustomTranslation( SelectToEnds ) );
return defaults;
return {
GetCustomTranslation( MP3Conversion ) ,
GetCustomTranslation( FadeEnds ) ,
//Don't add this one anymore, as there is a new menu command for it.
//GetCustomTranslation( SelectToEnds ) ,
};
}
void MacroCommands::RestoreMacro(const wxString & name)

View File

@ -20,6 +20,7 @@
class Effect;
class CommandContext;
class AudacityProject;
class wxArrayStringEx;
class MacroCommandsCatalog {
public:
@ -81,7 +82,7 @@ class MacroCommands final {
// These commands do not depend on the command list.
static void MigrateLegacyChains();
static wxArrayString GetNames();
static wxArrayString GetNamesOfDefaultMacros();
static wxArrayStringEx GetNamesOfDefaultMacros();
static wxString GetCurrentParamsFor(const wxString & command);
static wxString PromptForParamsFor(const wxString & command, const wxString & params, wxWindow *parent);

View File

@ -387,12 +387,13 @@ void DependencyDialog::PopulateOrExchange(ShuttleGui& S)
{
S.StartHorizontalLay(wxALIGN_LEFT,0);
{
wxArrayString choices;
/*i18n-hint: One of the choices of what you want Audacity to do when
* Audacity finds a project depends on another file.*/
choices.Add(_("Ask me"));
choices.Add(_("Always copy all files (safest)"));
choices.Add(_("Never copy any files"));
wxArrayStringEx choices{
/*i18n-hint: One of the choices of what you want Audacity to do when
* Audacity finds a project depends on another file.*/
_("Ask me") ,
_("Always copy all files (safest)") ,
_("Never copy any files") ,
};
mFutureActionChoice =
S.Id(FutureActionChoiceID).AddChoice(
_("Whenever a project depends on other files:"),

View File

@ -206,7 +206,7 @@ bool sf_subtype_is_integer(unsigned int format)
wxArrayString sf_get_all_extensions()
{
wxArrayString exts;
wxArrayStringEx exts;
SF_FORMAT_INFO format_info;
int count, k;
@ -226,12 +226,14 @@ wxArrayString sf_get_all_extensions()
// Some other extensions that are often sound files
// but aren't included by libsndfile
exts.Add(wxT("aif")); // AIFF file with a DOS-style extension
exts.Add(wxT("ircam"));
exts.Add(wxT("snd"));
exts.Add(wxT("svx"));
exts.Add(wxT("svx8"));
exts.Add(wxT("sv16"));
exts.insert( exts.end(), {
wxT("aif") , // AIFF file with a DOS-style extension
wxT("ircam") ,
wxT("snd") ,
wxT("svx") ,
wxT("svx8") ,
wxT("sv16") ,
} );
return exts;
}

View File

@ -211,27 +211,29 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
if (!p)
return;
wxArrayString algChoices;
algChoices.Add(_("Spectrum"));
algChoices.Add(_("Standard Autocorrelation"));
algChoices.Add(_("Cuberoot Autocorrelation"));
algChoices.Add(_("Enhanced Autocorrelation"));
/* i18n-hint: This is a technical term, derived from the word
* "spectrum". Do not translate it unless you are sure you
* know the correct technical word in your language. */
algChoices.Add(_("Cepstrum"));
wxArrayStringEx algChoices{
_("Spectrum") ,
_("Standard Autocorrelation") ,
_("Cuberoot Autocorrelation") ,
_("Enhanced Autocorrelation") ,
/* i18n-hint: This is a technical term, derived from the word
* "spectrum". Do not translate it unless you are sure you
* know the correct technical word in your language. */
_("Cepstrum") ,
};
wxArrayString sizeChoices;
sizeChoices.Add(wxT("128"));
sizeChoices.Add(wxT("256"));
sizeChoices.Add(wxT("512"));
sizeChoices.Add(wxT("1024"));
sizeChoices.Add(wxT("2048"));
sizeChoices.Add(wxT("4096"));
sizeChoices.Add(wxT("8192"));
sizeChoices.Add(wxT("16384"));
sizeChoices.Add(wxT("32768"));
sizeChoices.Add(wxT("65536"));
wxArrayStringEx sizeChoices{
wxT("128") ,
wxT("256") ,
wxT("512") ,
wxT("1024") ,
wxT("2048") ,
wxT("4096") ,
wxT("8192") ,
wxT("16384") ,
wxT("32768") ,
wxT("65536") ,
};
wxArrayString funcChoices;
for (int i = 0, cnt = NumWindowFuncs(); i < cnt; i++)
@ -242,9 +244,10 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
funcChoices.push_back(wxString::Format("%s window", WindowFuncName(i) ) );
}
wxArrayString axisChoices;
axisChoices.Add(_("Linear frequency"));
axisChoices.Add(_("Log frequency"));
wxArrayStringEx axisChoices{
_("Linear frequency") ,
_("Log frequency") ,
};
mFreqFont = wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
mArrowCursor = std::make_unique<wxCursor>(wxCURSOR_ARROW);

View File

@ -656,4 +656,61 @@ OutContainer transform_container( InContainer &inContainer, Function &&fn )
inContainer.begin(), inContainer.end(), fn );
}
// Extend wxArrayString with move operations and construction and insertion from
// std::initializer_list
class wxArrayStringEx : public wxArrayString
{
public:
using wxArrayString::wxArrayString;
wxArrayStringEx() = default;
template< typename Iterator >
wxArrayStringEx( Iterator start, Iterator finish )
{
this->reserve( std::distance( start, finish ) );
while( start != finish )
this->push_back( *start++ );
}
template< typename T >
wxArrayStringEx( std::initializer_list< T > items )
{
this->reserve( this->size() + items.size() );
for ( const auto &item : items )
this->push_back( item );
}
// The move operations can take arguments of the base class wxArrayString
wxArrayStringEx( wxArrayString &&other )
{
swap( other );
}
wxArrayStringEx &operator= ( wxArrayString &&other )
{
if ( this != &other ) {
clear();
swap( other );
}
return *this;
}
using wxArrayString::insert;
template< typename T >
iterator insert( const_iterator pos, std::initializer_list< T > items )
{
const auto index = pos - ((const wxArrayString*)this)->begin();
this->wxArrayString::Insert( {}, index, items.size() );
auto result = this->begin() + index, iter = result;
for ( auto pItem = items.begin(), pEnd = items.end();
pItem != pEnd;
++pItem, ++iter
) {
*iter = *pItem;
}
return result;
}
};
#endif // __AUDACITY_MEMORY_X_H__

View File

@ -353,15 +353,13 @@ SnapResults SnapManager::Snap
return results;
}
/* static */ wxArrayString SnapManager::GetSnapLabels()
/* static */ wxArrayStringEx SnapManager::GetSnapLabels()
{
wxArrayString labels;
labels.Add(_("Off"));
labels.Add(_("Nearest"));
labels.Add(_("Prior"));
return labels;
return wxArrayStringEx{
_("Off") ,
_("Nearest") ,
_("Prior") ,
};
}
#include "AColor.h"

View File

@ -102,7 +102,7 @@ public:
double t,
bool rightEdge);
static wxArrayString GetSnapLabels();
static wxArrayStringEx GetSnapLabels();
// The two coordinates need not be ordered:
static void Draw( wxDC *dc, wxInt64 snap0, wxInt64 snap1 );

View File

@ -931,12 +931,13 @@ teThemeType ThemeBase::GetFallbackThemeType(){
teThemeType ThemeBase::ThemeTypeOfTypeName( const wxString & Name )
{
wxArrayString aThemes;
aThemes.Add( "classic" );
aThemes.Add( "dark" );
aThemes.Add( "light" );
aThemes.Add( "high-contrast" );
aThemes.Add( "custom" );
static const wxArrayStringEx aThemes{
"classic" ,
"dark" ,
"light" ,
"high-contrast" ,
"custom" ,
};
int themeIx = make_iterator_range( aThemes ).index( Name );
if( themeIx < 0 )
return GetFallbackThemeType();

View File

@ -928,11 +928,12 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
S.StartMultiColumn(1, wxEXPAND);
{
S.SetStretchyCol( 0 );
wxArrayString arrayOptions;
arrayOptions.Add(_("Do nothing"));
arrayOptions.Add(_("Exit Audacity"));
arrayOptions.Add(_("Restart system"));
arrayOptions.Add(_("Shutdown system"));
wxArrayStringEx arrayOptions{
_("Do nothing") ,
_("Exit Audacity") ,
_("Restart system") ,
_("Shutdown system") ,
};
m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[0]);
m_sTimerAfterCompleteOptionsArray.push_back(arrayOptions[1]);

View File

@ -64,6 +64,6 @@ protected:
ArrayType mContents;
};
typedef TranslatableArray<wxArrayString> TranslatableStringArray;
typedef TranslatableArray<wxArrayStringEx> TranslatableStringArray;
#endif

View File

@ -465,7 +465,7 @@ void ScreenshotCommand::CaptureEffects(
#define CAPTURE_NYQUIST_TOO
// Commented out the effects that don't have dialogs.
// Also any problematic ones,
const wxString EffectNames[] = {
CaptureCommands( context, {
#ifdef TRICKY_CAPTURE
//"Contrast...", // renamed
"ContrastAnalyser",
@ -542,9 +542,7 @@ void ScreenshotCommand::CaptureEffects(
"Silence Finder...",
"Sound Finder...",
#endif
};
wxArrayString Commands( sizeof(EffectNames)/sizeof(EffectNames[0]), EffectNames );
CaptureCommands( context, Commands );
} );
}
void ScreenshotCommand::CaptureScriptables(
@ -555,7 +553,7 @@ void ScreenshotCommand::CaptureScriptables(
(void)&FileName;//compiler food.
(void)&context;
const wxString ScriptablesNames[] = {
CaptureCommands( context, {
"SelectTime",
"SelectFrequencies",
"SelectTracks",
@ -581,16 +579,13 @@ void ScreenshotCommand::CaptureScriptables(
"Drag",
"CompareAudio",
"Screenshot",
};
wxArrayString Commands( sizeof(ScriptablesNames)/sizeof(ScriptablesNames[0]), ScriptablesNames );
CaptureCommands( context, Commands );
} );
}
void ScreenshotCommand::CaptureCommands(
const CommandContext & context, wxArrayString & Commands ){
const CommandContext & context, const wxArrayStringEx & Commands ){
AudacityProject * pProject = context.GetProject();
CommandManager * pMan = pProject->GetCommandManager();
wxString Str;

View File

@ -120,7 +120,7 @@ private:
bool CaptureToolbar(const CommandContext & Context, ToolManager *man, int type, const wxString &name);
bool CaptureDock(const CommandContext & Context, wxWindow *win, const wxString &fileName);
void CaptureCommands(const CommandContext & Context, wxArrayString &Commands );
void CaptureCommands(const CommandContext & Context, const wxArrayStringEx &Commands );
void CaptureEffects(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );
void CaptureScriptables(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );
void CapturePreferences(const CommandContext & Context, AudacityProject * pProject, const wxString &fileName );

View File

@ -3299,11 +3299,12 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event))
int curve = 0;
// Setup list of characters that aren't allowed
wxArrayString exclude;
exclude.Add( wxT("<") );
exclude.Add( wxT(">") );
exclude.Add( wxT("'") );
exclude.Add( wxT("\"") );
wxArrayStringEx exclude{
wxT("<") ,
wxT(">") ,
wxT("'") ,
wxT("\"") ,
};
// Get the first one to be renamed
long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);

View File

@ -1749,7 +1749,7 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S)
S.StartMultiColumn(2);
{
{
wxArrayString windowTypeChoices;
wxArrayStringEx windowTypeChoices;
for (int ii = 0; ii < WT_N_WINDOW_TYPES; ++ii)
windowTypeChoices.push_back(windowTypesInfo[ii].name);
S.TieChoice(_("&Window types") + wxString(wxT(":")),
@ -1758,32 +1758,34 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S)
}
{
wxArrayString windowSizeChoices;
windowSizeChoices.Add(_("8"));
windowSizeChoices.Add(_("16"));
windowSizeChoices.Add(_("32"));
windowSizeChoices.Add(_("64"));
windowSizeChoices.Add(_("128"));
windowSizeChoices.Add(_("256"));
windowSizeChoices.Add(_("512"));
windowSizeChoices.Add(_("1024"));
windowSizeChoices.Add(_("2048 (default)"));
windowSizeChoices.Add(_("4096"));
windowSizeChoices.Add(_("8192"));
windowSizeChoices.Add(_("16384"));
wxArrayStringEx windowSizeChoices{
_("8") ,
_("16") ,
_("32") ,
_("64") ,
_("128") ,
_("256") ,
_("512") ,
_("1024") ,
_("2048 (default)") ,
_("4096") ,
_("8192") ,
_("16384") ,
};
S.TieChoice(_("Window si&ze") + wxString(wxT(":")),
mTempSettings.mWindowSizeChoice,
&windowSizeChoices);
}
{
wxArrayString stepsPerWindowChoices;
stepsPerWindowChoices.Add(_("2"));
stepsPerWindowChoices.Add(_("4 (default)"));
stepsPerWindowChoices.Add(_("8"));
stepsPerWindowChoices.Add(_("16"));
stepsPerWindowChoices.Add(_("32"));
stepsPerWindowChoices.Add(_("64"));
wxArrayStringEx stepsPerWindowChoices{
_("2") ,
_("4 (default)") ,
_("8") ,
_("16") ,
_("32") ,
_("64") ,
};
S.TieChoice(_("S&teps per window") + wxString(wxT(":")),
mTempSettings.mStepsPerWindowChoice,
&stepsPerWindowChoices);
@ -1791,7 +1793,7 @@ void EffectNoiseReduction::Dialog::PopulateOrExchange(ShuttleGui & S)
S.Id(ID_CHOICE_METHOD);
{
wxArrayString methodChoices;
wxArrayStringEx methodChoices;
int nn = DM_N_METHODS;
#ifndef OLD_METHOD_AVAILABLE
--nn;

View File

@ -340,7 +340,7 @@ private:
bool mUseLatency;
wxString mUIType;
wxArrayString mUITypes;
wxArrayStringEx mUITypes;
DECLARE_EVENT_TABLE()
};

View File

@ -81,20 +81,39 @@ ExportFLACOptions::~ExportFLACOptions()
///
void ExportFLACOptions::PopulateOrExchange(ShuttleGui & S)
{
wxArrayString flacLevelNames, flacLevelLabels;
flacLevelLabels.Add(wxT("0")); flacLevelNames.Add(_("0 (fastest)"));
flacLevelLabels.Add(wxT("1")); flacLevelNames.Add(_("1"));
flacLevelLabels.Add(wxT("2")); flacLevelNames.Add(_("2"));
flacLevelLabels.Add(wxT("3")); flacLevelNames.Add(_("3"));
flacLevelLabels.Add(wxT("4")); flacLevelNames.Add(_("4"));
flacLevelLabels.Add(wxT("5")); flacLevelNames.Add(_("5"));
flacLevelLabels.Add(wxT("6")); flacLevelNames.Add(_("6"));
flacLevelLabels.Add(wxT("7")); flacLevelNames.Add(_("7"));
flacLevelLabels.Add(wxT("8")); flacLevelNames.Add(_("8 (best)"));
wxArrayStringEx flacLevelLabels{
wxT("0") ,
wxT("1") ,
wxT("2") ,
wxT("3") ,
wxT("4") ,
wxT("5") ,
wxT("6") ,
wxT("7") ,
wxT("8") ,
};
wxArrayString flacBitDepthNames, flacBitDepthLabels;
flacBitDepthLabels.Add(wxT("16")); flacBitDepthNames.Add(_("16 bit"));
flacBitDepthLabels.Add(wxT("24")); flacBitDepthNames.Add(_("24 bit"));
wxArrayStringEx flacLevelNames{
_("0 (fastest)") ,
_("1") ,
_("2") ,
_("3") ,
_("4") ,
_("5") ,
_("6") ,
_("7") ,
_("8 (best)") ,
};
wxArrayStringEx flacBitDepthLabels{
wxT("16") ,
wxT("24") ,
};
wxArrayStringEx flacBitDepthNames{
_("16 bit") ,
_("24 bit") ,
};
S.StartVerticalLay();
{

View File

@ -321,8 +321,6 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
ShuttleGui S(this, eIsCreating);
wxArrayString encodings;
wxArrayString endians;
wxArrayString chans;
int num;
int selection;
int endian;
@ -354,18 +352,20 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
}
}
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
wxArrayStringEx endians{
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
know the correct technical word. */
_("No endianness") ,
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
endians.Add(_("No endianness"));
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
endians.Add(_("Little-endian"));
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
endians.Add(_("Big-endian"));
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
know the correct technical word. */
endians.Add(_("Default endianness"));
_("Little-endian") ,
/* i18n-hint: Refers to byte-order. Don't translate this if you don't
know the correct technical word. */
_("Big-endian") ,
/* i18n-hint: Refers to byte-order. Don't translate "endianness" if you don't
know the correct technical word. */
_("Default endianness") ,
};
switch (mEncoding & (SF_FORMAT_ENDMASK))
{
@ -384,8 +384,10 @@ ImportRawDialog::ImportRawDialog(wxWindow * parent,
break;
}
chans.Add(_("1 Channel (Mono)"));
chans.Add(_("2 Channels (Stereo)"));
wxArrayStringEx chans{
_("1 Channel (Mono)") ,
_("2 Channels (Stereo)") ,
};
for (i=2; i<16; i++) {
chans.push_back(wxString::Format(_("%d Channels"), i + 1));
}

View File

@ -895,24 +895,25 @@ void OnResample(const CommandContext &context)
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxString rate;
wxArrayString rates;
wxComboBox *cb;
rate.Printf(wxT("%ld"), lrint(projectRate));
rates.Add(wxT("8000"));
rates.Add(wxT("11025"));
rates.Add(wxT("16000"));
rates.Add(wxT("22050"));
rates.Add(wxT("32000"));
rates.Add(wxT("44100"));
rates.Add(wxT("48000"));
rates.Add(wxT("88200"));
rates.Add(wxT("96000"));
rates.Add(wxT("176400"));
rates.Add(wxT("192000"));
rates.Add(wxT("352800"));
rates.Add(wxT("384000"));
wxArrayStringEx rates{
wxT("8000") ,
wxT("11025") ,
wxT("16000") ,
wxT("22050") ,
wxT("32000") ,
wxT("44100") ,
wxT("48000") ,
wxT("88200") ,
wxT("96000") ,
wxT("176400") ,
wxT("192000") ,
wxT("352800") ,
wxT("384000") ,
};
S.StartVerticalLay(true);
{

View File

@ -103,20 +103,21 @@ void EffectsPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.StartMultiColumn(2);
{
wxArrayString visualgroups;
wxArrayString prefsgroups;
wxArrayStringEx visualgroups{
_("Sorted by Effect Name") ,
_("Sorted by Publisher and Effect Name") ,
_("Sorted by Type and Effect Name") ,
_("Grouped by Publisher") ,
_("Grouped by Type") ,
};
visualgroups.Add(_("Sorted by Effect Name"));
visualgroups.Add(_("Sorted by Publisher and Effect Name"));
visualgroups.Add(_("Sorted by Type and Effect Name"));
visualgroups.Add(_("Grouped by Publisher"));
visualgroups.Add(_("Grouped by Type"));
prefsgroups.Add(wxT("sortby:name"));
prefsgroups.Add(wxT("sortby:publisher:name"));
prefsgroups.Add(wxT("sortby:type:name"));
prefsgroups.Add(wxT("groupby:publisher"));
prefsgroups.Add(wxT("groupby:type"));
wxArrayStringEx prefsgroups{
wxT("sortby:name") ,
wxT("sortby:publisher:name") ,
wxT("sortby:type:name") ,
wxT("groupby:publisher") ,
wxT("groupby:type") ,
};
wxChoice *c = S.TieChoice(_("S&ort or Group:"),
wxT("/Effects/GroupBy"),

View File

@ -47,32 +47,37 @@ GUIPrefs::~GUIPrefs()
{
}
void GUIPrefs::GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
void GUIPrefs::GetRangeChoices(
wxArrayStringEx *pChoices, wxArrayStringEx *pCodes)
{
if (pCodes) {
wxArrayString &codes = *pCodes;
codes.Clear();
codes.Add(wxT("36"));
codes.Add(wxT("48"));
codes.Add(wxT("60"));
codes.Add(wxT("72"));
codes.Add(wxT("84"));
codes.Add(wxT("96"));
codes.Add(wxT("120"));
codes.Add(wxT("145"));
auto &codes = *pCodes;
codes.clear();
codes.insert( codes.end(), {
wxT("36") ,
wxT("48") ,
wxT("60") ,
wxT("72") ,
wxT("84") ,
wxT("96") ,
wxT("120") ,
wxT("145") ,
} );
}
if (pChoices) {
wxArrayString &choices = *pChoices;
choices.Clear();
choices.Add(_("-36 dB (shallow range for high-amplitude editing)"));
choices.Add(_("-48 dB (PCM range of 8 bit samples)"));
choices.Add(_("-60 dB (PCM range of 10 bit samples)"));
choices.Add(_("-72 dB (PCM range of 12 bit samples)"));
choices.Add(_("-84 dB (PCM range of 14 bit samples)"));
choices.Add(_("-96 dB (PCM range of 16 bit samples)"));
choices.Add(_("-120 dB (approximate limit of human hearing)"));
choices.Add(_("-145 dB (PCM range of 24 bit samples)"));
auto &choices = *pChoices;
choices.clear();
choices.insert( choices.end(), {
_("-36 dB (shallow range for high-amplitude editing)") ,
_("-48 dB (PCM range of 8 bit samples)") ,
_("-60 dB (PCM range of 10 bit samples)") ,
_("-72 dB (PCM range of 12 bit samples)") ,
_("-84 dB (PCM range of 14 bit samples)") ,
_("-96 dB (PCM range of 16 bit samples)") ,
_("-120 dB (approximate limit of human hearing)") ,
_("-145 dB (PCM range of 24 bit samples)") ,
} );
}
}
@ -81,34 +86,55 @@ void GUIPrefs::Populate()
// First any pre-processing for constructing the GUI.
GetLanguages(mLangCodes, mLangNames);
mHtmlHelpCodes.Add(wxT("Local"));
mHtmlHelpCodes.Add(wxT("FromInternet"));
mHtmlHelpCodes.clear();
auto values = {
wxT("Local") ,
wxT("FromInternet") ,
};
mHtmlHelpCodes.insert( mHtmlHelpCodes.end(), values );
mHtmlHelpChoices.Add(_("Local"));
mHtmlHelpChoices.Add(_("From Internet"));
mHtmlHelpChoices.clear();
auto values2 = {
_("Local") ,
_("From Internet") ,
};
mHtmlHelpChoices.insert( mHtmlHelpChoices.end(), values2 );
mThemeCodes.Add( wxT("classic") );
mThemeCodes.Add( wxT("light") );
mThemeCodes.Add( wxT("dark") );
mThemeCodes.Add( wxT("high-contrast") );
mThemeCodes.Add( wxT("custom") );
mThemeCodes.clear();
mThemeCodes.insert( mThemeCodes.end(), {
wxT("classic") ,
wxT("light") ,
wxT("dark") ,
wxT("high-contrast") ,
wxT("custom") ,
} );
/* i18n-hint: describing the "classic" or traditional appearance of older versions of Audacity */
mThemeChoices.Add( _("Classic") );
/* i18n-hint: Light meaning opposite of dark */
mThemeChoices.Add( _("Light") );
mThemeChoices.Add( _("Dark") );
/* i18n-hint: greater difference between foreground and background colors */
mThemeChoices.Add( _("High Contrast") );
/* i18n-hint: user defined */
mThemeChoices.Add( _("Custom") );
mThemeChoices.clear();
mThemeChoices.insert( mThemeChoices.end(), {
/* i18n-hint: describing the "classic" or traditional appearance of older versions of Audacity */
_("Classic") ,
/* i18n-hint: Light meaning opposite of dark */
_("Light") ,
_("Dark") ,
/* i18n-hint: greater difference between foreground and background colors */
_("High Contrast") ,
/* i18n-hint: user defined */
_("Custom") ,
} );
GetRangeChoices(&mRangeChoices, &mRangeCodes);
#if 0
// only for testing...
mLangCodes.Add("kg"); mLangNames.Add("Klingon");
mLangCodes.Add("ep"); mLangNames.Add("Esperanto");
mLangCodes.insert( mLangCodes.end(), {
// only for testing...
"kg" ,
"ep" ,
} );
mLangNames.insert( mLangNames.end(), {
"Klingon" ,
"Esperanto" ,
} );
#endif
//------------------------- Main section --------------------

View File

@ -21,6 +21,7 @@
#include "PrefsPanel.h"
class ShuttleGui;
class wxArrayStringEx;
class GUIPrefs final : public PrefsPanel
{
@ -31,22 +32,23 @@ class GUIPrefs final : public PrefsPanel
wxString HelpPageName() override;
void PopulateOrExchange(ShuttleGui & S) override;
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes);
static void GetRangeChoices(
wxArrayStringEx *pChoices, wxArrayStringEx *pCodes);
private:
void Populate();
wxArrayString mLangCodes;
wxArrayString mLangNames;
wxArrayStringEx mLangCodes;
wxArrayStringEx mLangNames;
wxArrayString mHtmlHelpCodes;
wxArrayString mHtmlHelpChoices;
wxArrayStringEx mHtmlHelpCodes;
wxArrayStringEx mHtmlHelpChoices;
wxArrayString mThemeCodes;
wxArrayString mThemeChoices;
wxArrayStringEx mThemeCodes;
wxArrayStringEx mThemeChoices;
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
wxArrayStringEx mRangeCodes;
wxArrayStringEx mRangeChoices;
};
/// A PrefsPanelFactory that creates one GUIPrefs panel.

View File

@ -95,12 +95,13 @@ void ModulePrefs::Populate()
void ModulePrefs::PopulateOrExchange(ShuttleGui & S)
{
wxArrayString StatusChoices;
StatusChoices.Add( _("Disabled" ) );
StatusChoices.Add( _("Enabled" ) );
StatusChoices.Add( _("Ask" ) );
StatusChoices.Add( _("Failed" ) );
StatusChoices.Add( _("New" ) );
wxArrayStringEx StatusChoices{
_("Disabled" ) ,
_("Enabled" ) ,
_("Ask" ) ,
_("Failed" ) ,
_("New" ) ,
};
S.SetBorder(2);
S.StartScroller();

View File

@ -145,17 +145,19 @@ const wxArrayString &SpectrogramSettings::GetScaleNames()
{
void Populate() override
{
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
mContents.Add(_("Linear"));
mContents.Add(_("Logarithmic"));
/* i18n-hint: The name of a frequency scale in psychoacoustics */
mContents.Add(_("Mel"));
/* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
mContents.Add(_("Bark"));
/* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
mContents.Add(_("ERB"));
/* i18n-hint: Time units, that is Period = 1 / Frequency */
mContents.Add(_("Period"));
mContents.insert( mContents.end(), {
// Keep in correspondence with enum SpectrogramSettings::ScaleType:
_("Linear") ,
_("Logarithmic") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics */
_("Mel") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics, named for Heinrich Barkhausen */
_("Bark") ,
/* i18n-hint: The name of a frequency scale in psychoacoustics, abbreviates Equivalent Rectangular Bandwidth */
_("ERB") ,
/* i18n-hint: Time units, that is Period = 1 / Frequency */
_("Period") ,
} );
}
};
@ -170,12 +172,14 @@ const wxArrayString &SpectrogramSettings::GetAlgorithmNames()
{
void Populate() override
{
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
mContents.Add(_("Frequencies"));
/* i18n-hint: the Reassignment algorithm for spectrograms */
mContents.Add(_("Reassignment"));
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
mContents.Add(_("Pitch (EAC)"));
mContents.insert( mContents.end(), {
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
_("Frequencies") ,
/* i18n-hint: the Reassignment algorithm for spectrograms */
_("Reassignment") ,
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
_("Pitch (EAC)") ,
} );
}
};

View File

@ -73,7 +73,7 @@ class SpectrumPrefs final : public PrefsPanel
wxTextCtrl *mRange;
wxTextCtrl *mFrequencyGain;
wxArrayString mSizeChoices;
wxArrayStringEx mSizeChoices;
#ifdef EXPERIMENTAL_ZERO_PADDED_SPECTROGRAMS
int mZeroPaddingChoice;

View File

@ -33,8 +33,8 @@ class TracksBehaviorsPrefs final : public PrefsPanel
void Populate();
void PopulateOrExchange(ShuttleGui & S) override;
wxArrayString mSoloCodes;
wxArrayString mSoloChoices;
wxArrayStringEx mSoloCodes;
wxArrayStringEx mSoloChoices;
};
/// A PrefsPanelFactory that creates one TracksBehaviorsPrefs panel.

View File

@ -48,8 +48,8 @@ private:
wxChoice *mRangeChoice;
wxArrayString mScaleChoices;
wxArrayString mRangeCodes;
wxArrayString mRangeChoices;
wxArrayStringEx mRangeCodes;
wxArrayStringEx mRangeChoices;
WaveformSettings mTempSettings;

View File

@ -110,7 +110,7 @@ void WaveformSettings::Update()
void WaveformSettings::ConvertToEnumeratedDBRange()
{
// Assumes the codes are in ascending sequence.
wxArrayString codes;
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(NULL, &codes);
int ii = 0;
for (int nn = codes.size(); ii < nn; ++ii) {
@ -124,7 +124,7 @@ void WaveformSettings::ConvertToEnumeratedDBRange()
void WaveformSettings::ConvertToActualDBRange()
{
wxArrayString codes;
wxArrayStringEx codes;
GUIPrefs::GetRangeChoices(NULL, &codes);
long value = 0;
codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]

View File

@ -468,23 +468,24 @@ void RateMenuTable::OnRateOther(wxCommandEvent &)
dlg.SetName(dlg.GetTitle());
ShuttleGui S(&dlg, eIsCreating);
wxString rate;
wxArrayString rates;
wxComboBox *cb;
rate.Printf(wxT("%ld"), lrint(pTrack->GetRate()));
rates.Add(wxT("8000"));
rates.Add(wxT("11025"));
rates.Add(wxT("16000"));
rates.Add(wxT("22050"));
rates.Add(wxT("44100"));
rates.Add(wxT("48000"));
rates.Add(wxT("88200"));
rates.Add(wxT("96000"));
rates.Add(wxT("176400"));
rates.Add(wxT("192000"));
rates.Add(wxT("352800"));
rates.Add(wxT("384000"));
wxArrayStringEx rates{
wxT("8000") ,
wxT("11025") ,
wxT("16000") ,
wxT("22050") ,
wxT("44100") ,
wxT("48000") ,
wxT("88200") ,
wxT("96000") ,
wxT("176400") ,
wxT("192000") ,
wxT("352800") ,
wxT("384000") ,
};
S.StartVerticalLay(true);
{

View File

@ -579,12 +579,13 @@ void MeterPanel::OnPaint(wxPaintEvent & WXUNUSED(event))
if( mIsInput && !mActive )
{
destDC.SetFont( GetFont() );
wxArrayString texts;
texts.Add( _("Click to Start Monitoring") );
texts.Add( _("Click for Monitoring") );
texts.Add( _("Click to Start") );
texts.Add( _("Click") );
wxArrayStringEx texts{
_("Click to Start Monitoring") ,
_("Click for Monitoring") ,
_("Click to Start") ,
_("Click") ,
};
for( size_t i = 0, cnt = texts.size(); i < cnt; i++ )
{
@ -1999,10 +2000,11 @@ void MeterPanel::OnPreferences(wxCommandEvent & WXUNUSED(event))
if (dlg.ShowModal() == wxID_OK)
{
wxArrayString style;
style.Add(wxT("AutomaticStereo"));
style.Add(wxT("HorizontalStereo"));
style.Add(wxT("VerticalStereo"));
wxArrayStringEx style{
wxT("AutomaticStereo") ,
wxT("HorizontalStereo") ,
wxT("VerticalStereo") ,
};
int s = 0;
s = automatic->GetValue() ? 0 : s;