IdentInterfaceSymbol in NumericTextCtrl; don't persist translated
This commit is contained in:
parent
9015dece06
commit
0fb02a8024
|
@ -59,6 +59,7 @@ typedef enum EffectType
|
|||
EffectTypeTool,
|
||||
} EffectType;
|
||||
|
||||
using NumericFormatId = IdentInterfaceSymbol;
|
||||
class ShuttleParams;
|
||||
|
||||
/*************************************************************************************//**
|
||||
|
@ -149,7 +150,7 @@ public:
|
|||
|
||||
virtual double GetDefaultDuration() = 0;
|
||||
virtual double GetDuration() = 0;
|
||||
virtual wxString GetDurationFormat() = 0;
|
||||
virtual NumericFormatId GetDurationFormat() = 0;
|
||||
virtual void SetDuration(double seconds) = 0;
|
||||
|
||||
virtual bool Apply() = 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ class IdentInterfaceSymbol
|
|||
{
|
||||
public:
|
||||
IdentInterfaceSymbol() = default;
|
||||
|
||||
|
||||
// Allows implicit construction from a msgid re-used as an internal string
|
||||
IdentInterfaceSymbol( const wxString &msgid )
|
||||
: mInternal{ msgid }, mMsgid{ msgid }
|
||||
|
|
|
@ -98,7 +98,8 @@ LabelDialog::LabelDialog(wxWindow *parent,
|
|||
int index,
|
||||
ViewInfo &viewinfo,
|
||||
double rate,
|
||||
const wxString & format, const wxString &freqFormat)
|
||||
const NumericFormatId & format,
|
||||
const NumericFormatId &freqFormat)
|
||||
: wxDialogWrapper(parent,
|
||||
wxID_ANY,
|
||||
_("Edit Labels"),
|
||||
|
@ -528,7 +529,8 @@ void LabelDialog::FindInitialRow()
|
|||
void LabelDialog::OnUpdate(wxCommandEvent &event)
|
||||
{
|
||||
// Remember the NEW format and repopulate grid
|
||||
mFormat = event.GetString();
|
||||
mFormat = NumericConverter::LookupFormat(
|
||||
NumericConverter::TIME, event.GetString() );
|
||||
TransferDataToWindow();
|
||||
|
||||
event.Skip(false);
|
||||
|
@ -537,7 +539,8 @@ void LabelDialog::OnUpdate(wxCommandEvent &event)
|
|||
void LabelDialog::OnFreqUpdate(wxCommandEvent &event)
|
||||
{
|
||||
// Remember the NEW format and repopulate grid
|
||||
mFreqFormat = event.GetString();
|
||||
mFreqFormat = NumericConverter::LookupFormat(
|
||||
NumericConverter::FREQUENCY, event.GetString() );
|
||||
TransferDataToWindow();
|
||||
|
||||
event.Skip(false);
|
||||
|
|
|
@ -48,7 +48,8 @@ class LabelDialog final : public wxDialogWrapper
|
|||
|
||||
ViewInfo &viewinfo,
|
||||
double rate,
|
||||
const wxString & format, const wxString &freqFormat);
|
||||
const NumericFormatId & format,
|
||||
const NumericFormatId &freqFormat);
|
||||
~LabelDialog();
|
||||
|
||||
bool Show(bool show = true) override;
|
||||
|
@ -102,8 +103,7 @@ class LabelDialog final : public wxDialogWrapper
|
|||
ViewInfo *mViewInfo;
|
||||
wxArrayString mTrackNames;
|
||||
double mRate;
|
||||
wxString mFormat;
|
||||
wxString mFreqFormat;
|
||||
NumericFormatId mFormat, mFreqFormat;
|
||||
|
||||
int mInitialRow;
|
||||
|
||||
|
|
|
@ -3776,7 +3776,7 @@ void AudacityProject::OnSetLeftSelection(const CommandContext &WXUNUSED(context)
|
|||
}
|
||||
else
|
||||
{
|
||||
wxString fmt = GetSelectionFormat();
|
||||
auto fmt = GetSelectionFormat();
|
||||
TimeDialog dlg(this, _("Set Left Selection Boundary"),
|
||||
fmt, mRate, mViewInfo.selectedRegion.t0(), _("Position"));
|
||||
|
||||
|
@ -3808,7 +3808,7 @@ void AudacityProject::OnSetRightSelection(const CommandContext &WXUNUSED(context
|
|||
}
|
||||
else
|
||||
{
|
||||
wxString fmt = GetSelectionFormat();
|
||||
auto fmt = GetSelectionFormat();
|
||||
TimeDialog dlg(this, _("Set Right Selection Boundary"),
|
||||
fmt, mRate, mViewInfo.selectedRegion.t1(), _("Position"));
|
||||
|
||||
|
@ -8570,8 +8570,8 @@ void AudacityProject::OnAddLabelPlaying(const CommandContext &WXUNUSED(context)
|
|||
|
||||
void AudacityProject::DoEditLabels(LabelTrack *lt, int index)
|
||||
{
|
||||
wxString format = GetSelectionFormat(),
|
||||
freqFormat = GetFrequencySelectionFormatName();
|
||||
auto format = GetSelectionFormat();
|
||||
auto freqFormat = GetFrequencySelectionFormatName();
|
||||
|
||||
LabelDialog dlg(this, *GetTrackFactory(), GetTracks(),
|
||||
lt, index,
|
||||
|
|
|
@ -923,9 +923,15 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
|||
mRate((double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), AudioIO::GetOptimalSupportedSampleRate())),
|
||||
mDefaultFormat(QualityPrefs::SampleFormatChoice()),
|
||||
mSnapTo(gPrefs->Read(wxT("/SnapTo"), SNAP_OFF)),
|
||||
mSelectionFormat(gPrefs->Read(wxT("/SelectionFormat"), wxT(""))),
|
||||
mFrequencySelectionFormatName(gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT(""))),
|
||||
mBandwidthSelectionFormatName(gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT(""))),
|
||||
mSelectionFormat( NumericTextCtrl::LookupFormat(
|
||||
NumericConverter::TIME,
|
||||
gPrefs->Read(wxT("/SelectionFormat"), wxT("")) ) ),
|
||||
mFrequencySelectionFormatName( NumericTextCtrl::LookupFormat(
|
||||
NumericConverter::FREQUENCY,
|
||||
gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT("")) ) ),
|
||||
mBandwidthSelectionFormatName( NumericTextCtrl::LookupFormat(
|
||||
NumericConverter::BANDWIDTH,
|
||||
gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT("")) ) ),
|
||||
mUndoManager(std::make_unique<UndoManager>())
|
||||
{
|
||||
mTracks = TrackList::Create();
|
||||
|
@ -1539,16 +1545,16 @@ void AudacityProject::AS_SetSnapTo(int snap)
|
|||
RedrawProject();
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::AS_GetSelectionFormat()
|
||||
const NumericFormatId & AudacityProject::AS_GetSelectionFormat()
|
||||
{
|
||||
return GetSelectionFormat();
|
||||
}
|
||||
|
||||
void AudacityProject::AS_SetSelectionFormat(const wxString & format)
|
||||
void AudacityProject::AS_SetSelectionFormat(const NumericFormatId & format)
|
||||
{
|
||||
mSelectionFormat = format;
|
||||
|
||||
gPrefs->Write(wxT("/SelectionFormat"), mSelectionFormat);
|
||||
gPrefs->Write(wxT("/SelectionFormat"), mSelectionFormat.Internal());
|
||||
gPrefs->Flush();
|
||||
|
||||
if (SnapSelection() && GetTrackPanel())
|
||||
|
@ -1571,29 +1577,31 @@ double AudacityProject::SSBL_GetRate() const
|
|||
return rate;
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::SSBL_GetFrequencySelectionFormatName()
|
||||
const NumericFormatId & AudacityProject::SSBL_GetFrequencySelectionFormatName()
|
||||
{
|
||||
return GetFrequencySelectionFormatName();
|
||||
}
|
||||
|
||||
void AudacityProject::SSBL_SetFrequencySelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SSBL_SetFrequencySelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
mFrequencySelectionFormatName = formatName;
|
||||
|
||||
gPrefs->Write(wxT("/FrequencySelectionFormatName"), mFrequencySelectionFormatName);
|
||||
gPrefs->Write(wxT("/FrequencySelectionFormatName"),
|
||||
mFrequencySelectionFormatName.Internal());
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::SSBL_GetBandwidthSelectionFormatName()
|
||||
const NumericFormatId & AudacityProject::SSBL_GetBandwidthSelectionFormatName()
|
||||
{
|
||||
return GetBandwidthSelectionFormatName();
|
||||
}
|
||||
|
||||
void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
mBandwidthSelectionFormatName = formatName;
|
||||
|
||||
gPrefs->Write(wxT("/BandwidthSelectionFormatName"), mBandwidthSelectionFormatName);
|
||||
gPrefs->Write(wxT("/BandwidthSelectionFormatName"),
|
||||
mBandwidthSelectionFormatName.Internal());
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
|
@ -1615,12 +1623,12 @@ void AudacityProject::SSBL_ModifySpectralSelection(double &bottom, double &top,
|
|||
#endif
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::GetFrequencySelectionFormatName() const
|
||||
const NumericFormatId & AudacityProject::GetFrequencySelectionFormatName() const
|
||||
{
|
||||
return mFrequencySelectionFormatName;
|
||||
}
|
||||
|
||||
void AudacityProject::SetFrequencySelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SetFrequencySelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
SSBL_SetFrequencySelectionFormatName(formatName);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
|
@ -1630,12 +1638,12 @@ void AudacityProject::SetFrequencySelectionFormatName(const wxString & formatNam
|
|||
#endif
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::GetBandwidthSelectionFormatName() const
|
||||
const NumericFormatId & AudacityProject::GetBandwidthSelectionFormatName() const
|
||||
{
|
||||
return mBandwidthSelectionFormatName;
|
||||
}
|
||||
|
||||
void AudacityProject::SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
void AudacityProject::SetBandwidthSelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
SSBL_SetBandwidthSelectionFormatName(formatName);
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
|
@ -1645,7 +1653,7 @@ void AudacityProject::SetBandwidthSelectionFormatName(const wxString & formatNam
|
|||
#endif
|
||||
}
|
||||
|
||||
void AudacityProject::SetSelectionFormat(const wxString & format)
|
||||
void AudacityProject::SetSelectionFormat(const NumericFormatId & format)
|
||||
{
|
||||
AS_SetSelectionFormat(format);
|
||||
if (GetSelectionBar()) {
|
||||
|
@ -1653,7 +1661,7 @@ void AudacityProject::SetSelectionFormat(const wxString & format)
|
|||
}
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::GetSelectionFormat() const
|
||||
const NumericFormatId & AudacityProject::GetSelectionFormat() const
|
||||
{
|
||||
return mSelectionFormat;
|
||||
}
|
||||
|
@ -3499,13 +3507,16 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
|||
}
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("selectionformat")))
|
||||
SetSelectionFormat(value);
|
||||
SetSelectionFormat(
|
||||
NumericConverter::LookupFormat( NumericConverter::TIME, value) );
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("frequencyformat")))
|
||||
SetFrequencySelectionFormatName(value);
|
||||
SetFrequencySelectionFormatName(
|
||||
NumericConverter::LookupFormat( NumericConverter::FREQUENCY, value ) );
|
||||
|
||||
else if (!wxStrcmp(attr, wxT("bandwidthformat")))
|
||||
SetBandwidthSelectionFormatName(value);
|
||||
SetBandwidthSelectionFormatName(
|
||||
NumericConverter::LookupFormat( NumericConverter::BANDWIDTH, value ) );
|
||||
} // while
|
||||
|
||||
mViewInfo.UpdatePrefs();
|
||||
|
@ -3688,9 +3699,12 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile, bool bWantSaveCompressed)
|
|||
mViewInfo.WriteXMLAttributes(xmlFile);
|
||||
xmlFile.WriteAttr(wxT("rate"), mRate);
|
||||
xmlFile.WriteAttr(wxT("snapto"), GetSnapTo() ? wxT("on") : wxT("off"));
|
||||
xmlFile.WriteAttr(wxT("selectionformat"), GetSelectionFormat());
|
||||
xmlFile.WriteAttr(wxT("frequencyformat"), GetFrequencySelectionFormatName());
|
||||
xmlFile.WriteAttr(wxT("bandwidthformat"), GetBandwidthSelectionFormatName());
|
||||
xmlFile.WriteAttr(wxT("selectionformat"),
|
||||
GetSelectionFormat().Internal());
|
||||
xmlFile.WriteAttr(wxT("frequencyformat"),
|
||||
GetFrequencySelectionFormatName().Internal());
|
||||
xmlFile.WriteAttr(wxT("bandwidthformat"),
|
||||
GetBandwidthSelectionFormatName().Internal());
|
||||
|
||||
mTags->WriteXML(xmlFile);
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ class Track;
|
|||
class WaveClip;
|
||||
class BackgroundCell;
|
||||
|
||||
|
||||
AudacityProject *CreateNewAudacityProject();
|
||||
AUDACITY_DLL_API AudacityProject *GetActiveProject();
|
||||
void RedrawAllProjects();
|
||||
|
@ -438,16 +439,16 @@ public:
|
|||
|
||||
// Selection Format
|
||||
|
||||
void SetSelectionFormat(const wxString & format);
|
||||
const wxString & GetSelectionFormat() const;
|
||||
void SetSelectionFormat(const NumericFormatId & format);
|
||||
const NumericFormatId & GetSelectionFormat() const;
|
||||
|
||||
// Spectral Selection Formats
|
||||
|
||||
void SetFrequencySelectionFormatName(const wxString & format);
|
||||
const wxString & GetFrequencySelectionFormatName() const;
|
||||
void SetFrequencySelectionFormatName(const NumericFormatId & format);
|
||||
const NumericFormatId & GetFrequencySelectionFormatName() const;
|
||||
|
||||
void SetBandwidthSelectionFormatName(const wxString & format);
|
||||
const wxString & GetBandwidthSelectionFormatName() const;
|
||||
void SetBandwidthSelectionFormatName(const NumericFormatId & format);
|
||||
const NumericFormatId & GetBandwidthSelectionFormatName() const;
|
||||
|
||||
// Scrollbars
|
||||
|
||||
|
@ -526,19 +527,19 @@ public:
|
|||
void AS_SetRate(double rate) override;
|
||||
int AS_GetSnapTo() override;
|
||||
void AS_SetSnapTo(int snap) override;
|
||||
const wxString & AS_GetSelectionFormat() override;
|
||||
void AS_SetSelectionFormat(const wxString & format) override;
|
||||
const NumericFormatId & AS_GetSelectionFormat() override;
|
||||
void AS_SetSelectionFormat(const NumericFormatId & format) override;
|
||||
void AS_ModifySelection(double &start, double &end, bool done) override;
|
||||
|
||||
// SpectralSelectionBarListener callback methods
|
||||
|
||||
double SSBL_GetRate() const override;
|
||||
|
||||
const wxString & SSBL_GetFrequencySelectionFormatName() override;
|
||||
void SSBL_SetFrequencySelectionFormatName(const wxString & formatName) override;
|
||||
const NumericFormatId & SSBL_GetFrequencySelectionFormatName() override;
|
||||
void SSBL_SetFrequencySelectionFormatName(const NumericFormatId & formatName) override;
|
||||
|
||||
const wxString & SSBL_GetBandwidthSelectionFormatName() override;
|
||||
void SSBL_SetBandwidthSelectionFormatName(const wxString & formatName) override;
|
||||
const NumericFormatId & SSBL_GetBandwidthSelectionFormatName() override;
|
||||
void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId & formatName) override;
|
||||
|
||||
void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) override;
|
||||
|
||||
|
@ -631,9 +632,9 @@ public:
|
|||
std::shared_ptr<TrackList> mTracks;
|
||||
|
||||
int mSnapTo;
|
||||
wxString mSelectionFormat;
|
||||
wxString mFrequencySelectionFormatName;
|
||||
wxString mBandwidthSelectionFormatName;
|
||||
NumericFormatId mSelectionFormat;
|
||||
NumericFormatId mFrequencySelectionFormatName;
|
||||
NumericFormatId mBandwidthSelectionFormatName;
|
||||
|
||||
std::shared_ptr<TrackList> mLastSavedTracks;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ SnapManager::SnapManager(const TrackList *tracks,
|
|||
|
||||
mSnapTo = 0;
|
||||
mRate = 0.0;
|
||||
mFormat.Empty();
|
||||
mFormat = {};
|
||||
|
||||
// Two time points closer than this are considered the same
|
||||
mEpsilon = 1 / 44100.0;
|
||||
|
@ -71,7 +71,7 @@ void SnapManager::Reinit()
|
|||
{
|
||||
int snapTo = mProject->GetSnapTo();
|
||||
double rate = mProject->GetRate();
|
||||
wxString format = mProject->GetSelectionFormat();
|
||||
auto format = mProject->GetSelectionFormat();
|
||||
|
||||
// No need to reinit if these are still the same
|
||||
if (snapTo == mSnapTo && rate == mRate && format == mFormat)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <wx/defs.h>
|
||||
#include <wx/string.h>
|
||||
#include "widgets/NumericTextCtrl.h"
|
||||
#include "Internat.h"
|
||||
|
||||
class AudacityProject;
|
||||
class Track;
|
||||
|
@ -136,7 +137,7 @@ private:
|
|||
|
||||
int mSnapTo;
|
||||
double mRate;
|
||||
wxString mFormat;
|
||||
NumericFormatId mFormat;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@ END_EVENT_TABLE()
|
|||
|
||||
TimeDialog::TimeDialog(wxWindow *parent,
|
||||
const wxString &title,
|
||||
const wxString &format,
|
||||
const NumericFormatId &format,
|
||||
double rate,
|
||||
double time,
|
||||
const wxString &prompt)
|
||||
|
@ -100,7 +100,7 @@ const double TimeDialog::GetTimeValue()
|
|||
return mTime;
|
||||
}
|
||||
|
||||
void TimeDialog::SetFormatString(const wxString &formatString)
|
||||
void TimeDialog::SetFormatString(const NumericFormatId &formatString)
|
||||
{
|
||||
mFormat = formatString;
|
||||
TransferDataToWindow();
|
||||
|
|
|
@ -27,12 +27,12 @@ class TimeDialog final : public wxDialogWrapper
|
|||
|
||||
TimeDialog(wxWindow *parent,
|
||||
const wxString &title,
|
||||
const wxString &format,
|
||||
const NumericFormatId &format,
|
||||
double rate,
|
||||
double time,
|
||||
const wxString &prompt = _("Duration"));
|
||||
|
||||
void SetFormatString(const wxString &formatString);
|
||||
void SetFormatString(const NumericFormatId &formatString);
|
||||
void SetSampleRate(double sampleRate);
|
||||
void SetTimeValue(double newTime);
|
||||
const double GetTimeValue();
|
||||
|
@ -48,7 +48,7 @@ class TimeDialog final : public wxDialogWrapper
|
|||
private:
|
||||
|
||||
wxString mPrompt;
|
||||
wxString mFormat;
|
||||
NumericFormatId mFormat;
|
||||
double mRate;
|
||||
double mTime;
|
||||
|
||||
|
|
|
@ -793,7 +793,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
* The 'h' indicates the first number displayed is hours, the 'm' indicates the second number
|
||||
* displayed is minutes, and the 's' indicates that the third number displayed is seconds.
|
||||
*/
|
||||
wxString strFormat = _("099 h 060 m 060 s");
|
||||
auto strFormat = _("099 h 060 m 060 s");
|
||||
using Options = NumericTextCtrl::Options;
|
||||
S.StartStatic(_("Start Date and Time"), true);
|
||||
{
|
||||
|
@ -811,7 +811,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
|
||||
m_pTimeTextCtrl_Start = safenew NumericTextCtrl(
|
||||
this, ID_TIMETEXT_START, NumericConverter::TIME,
|
||||
wxEmptyString, 0, 44100,
|
||||
{}, 0, 44100,
|
||||
Options{}
|
||||
.MenuEnabled(false)
|
||||
.Format(strFormat)
|
||||
|
@ -840,7 +840,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
|
||||
m_pTimeTextCtrl_End = safenew NumericTextCtrl(
|
||||
this, ID_TIMETEXT_END, NumericConverter::TIME,
|
||||
wxEmptyString, 0, 44100,
|
||||
{}, 0, 44100,
|
||||
Options{}
|
||||
.MenuEnabled(false)
|
||||
.Format(strFormat)
|
||||
|
@ -860,10 +860,10 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
|
|||
* number displayed is minutes, and the 's' indicates that the fourth number displayed is
|
||||
* seconds.
|
||||
*/
|
||||
wxString strFormat1 = _("099 days 024 h 060 m 060 s");
|
||||
auto strFormat1 = _("099 days 024 h 060 m 060 s");
|
||||
m_pTimeTextCtrl_Duration = safenew NumericTextCtrl(
|
||||
this, ID_TIMETEXT_DURATION, NumericConverter::TIME,
|
||||
wxEmptyString, 0, 44100,
|
||||
{}, 0, 44100,
|
||||
Options{}
|
||||
.MenuEnabled(false)
|
||||
.Format(strFormat1)
|
||||
|
|
|
@ -93,7 +93,7 @@ EffectChangeSpeed::EffectChangeSpeed()
|
|||
mToVinyl = kVinyl_33AndAThird;
|
||||
mFromLength = 0.0;
|
||||
mToLength = 0.0;
|
||||
mFormat = _("hh:mm:ss + milliseconds");
|
||||
mFormat = NumericConverter::DefaultSelectionFormat();
|
||||
mbLoopDetect = false;
|
||||
|
||||
SetLinearEffectFlag(true);
|
||||
|
@ -153,7 +153,7 @@ bool EffectChangeSpeed::SetAutomationParameters(CommandParameters & parms)
|
|||
bool EffectChangeSpeed::LoadFactoryDefaults()
|
||||
{
|
||||
mFromVinyl = kVinyl_33AndAThird;
|
||||
mFormat = _("hh:mm:ss + milliseconds");
|
||||
mFormat = NumericConverter::DefaultSelectionFormat();
|
||||
|
||||
return Effect::LoadFactoryDefaults();
|
||||
}
|
||||
|
@ -188,8 +188,9 @@ bool EffectChangeSpeed::Startup()
|
|||
// Retrieve last used control values
|
||||
gPrefs->Read(base + wxT("PercentChange"), &m_PercentChange, 0);
|
||||
|
||||
// default format "4" is the same as the Selection toolbar: "hh:mm:ss + milliseconds";
|
||||
gPrefs->Read(base + wxT("TimeFormat"), &mFormat, _("hh:mm:ss + milliseconds"));
|
||||
wxString format;
|
||||
gPrefs->Read(base + wxT("TimeFormat"), &format, wxString{});
|
||||
mFormat = NumericConverter::LookupFormat( NumericConverter::TIME, format );
|
||||
|
||||
gPrefs->Read(base + wxT("VinylChoice"), &mFromVinyl, 0);
|
||||
if (mFromVinyl == kVinyl_NA)
|
||||
|
@ -197,7 +198,7 @@ bool EffectChangeSpeed::Startup()
|
|||
mFromVinyl = kVinyl_33AndAThird;
|
||||
}
|
||||
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat);
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
|
||||
|
||||
SaveUserPreset(GetCurrentSettingsGroup());
|
||||
|
@ -294,7 +295,13 @@ bool EffectChangeSpeed::Process()
|
|||
|
||||
void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat, mFormat);
|
||||
{
|
||||
wxString formatId;
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"),
|
||||
formatId, mFormat.Internal());
|
||||
mFormat = NumericConverter::LookupFormat(
|
||||
NumericConverter::TIME, formatId );
|
||||
}
|
||||
GetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl, mFromVinyl);
|
||||
|
||||
S.SetBorder(5);
|
||||
|
@ -451,7 +458,7 @@ bool EffectChangeSpeed::TransferDataFromWindow()
|
|||
}
|
||||
m_PercentChange = exactPercent;
|
||||
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat);
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("TimeFormat"), mFormat.Internal());
|
||||
SetPrivateConfig(GetCurrentSettingsGroup(), wxT("VinylChoice"), mFromVinyl);
|
||||
|
||||
return true;
|
||||
|
@ -674,7 +681,8 @@ void EffectChangeSpeed::OnTimeCtrl_ToLength(wxCommandEvent & WXUNUSED(evt))
|
|||
|
||||
void EffectChangeSpeed::OnTimeCtrlUpdate(wxCommandEvent & evt)
|
||||
{
|
||||
mFormat = evt.GetString();
|
||||
mFormat = NumericConverter::LookupFormat(
|
||||
NumericConverter::TIME, evt.GetString() );
|
||||
|
||||
mpFromLengthCtrl->SetFormatName(mFormat);
|
||||
// Update From/To Length controls (precision has changed).
|
||||
|
|
|
@ -115,7 +115,7 @@ private:
|
|||
// private effect parameters
|
||||
int mToVinyl; // to standard vinyl speed (rpm)
|
||||
double mToLength; // target length of selection
|
||||
wxString mFormat; // time control format
|
||||
NumericFormatId mFormat; // time control format
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -226,7 +226,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
|
|||
mForegroundStartT = safenew
|
||||
NumericTextCtrl(this, ID_FOREGROUNDSTART_T,
|
||||
NumericConverter::TIME,
|
||||
_("hh:mm:ss + hundredths"),
|
||||
NumericConverter::HundredthsFormat(),
|
||||
0.0,
|
||||
mProjectRate,
|
||||
options);
|
||||
|
@ -239,7 +239,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
|
|||
mForegroundEndT = safenew
|
||||
NumericTextCtrl(this, ID_FOREGROUNDEND_T,
|
||||
NumericConverter::TIME,
|
||||
_("hh:mm:ss + hundredths"),
|
||||
NumericConverter::HundredthsFormat(),
|
||||
0.0,
|
||||
mProjectRate,
|
||||
options);
|
||||
|
@ -258,7 +258,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
|
|||
mBackgroundStartT = safenew
|
||||
NumericTextCtrl(this, ID_BACKGROUNDSTART_T,
|
||||
NumericConverter::TIME,
|
||||
_("hh:mm:ss + hundredths"),
|
||||
NumericConverter::HundredthsFormat(),
|
||||
0.0,
|
||||
mProjectRate,
|
||||
options);
|
||||
|
@ -271,7 +271,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
|
|||
mBackgroundEndT = safenew
|
||||
NumericTextCtrl(this, ID_BACKGROUNDEND_T,
|
||||
NumericConverter::TIME,
|
||||
_("hh:mm:ss + hundredths"),
|
||||
NumericConverter::HundredthsFormat(),
|
||||
0.0,
|
||||
mProjectRate,
|
||||
options);
|
||||
|
|
|
@ -55,6 +55,7 @@ greater use in future.
|
|||
#include "nyquist/Nyquist.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/LinkingHtmlWindow.h"
|
||||
#include "../widgets/NumericTextCtrl.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../FileNames.h"
|
||||
#include "../commands/AudacityCommand.h"
|
||||
|
@ -757,12 +758,12 @@ double Effect::GetDuration()
|
|||
return mDuration;
|
||||
}
|
||||
|
||||
wxString Effect::GetDurationFormat()
|
||||
NumericFormatId Effect::GetDurationFormat()
|
||||
{
|
||||
return mDurationFormat;
|
||||
}
|
||||
|
||||
wxString Effect::GetSelectionFormat()
|
||||
NumericFormatId Effect::GetSelectionFormat()
|
||||
{
|
||||
return GetActiveProject()->GetSelectionFormat();
|
||||
}
|
||||
|
@ -1221,7 +1222,9 @@ bool Effect::DoEffect(wxWindow *parent,
|
|||
isSelection = true;
|
||||
}
|
||||
|
||||
mDurationFormat = isSelection ? _("hh:mm:ss + samples") : _("hh:mm:ss + milliseconds");
|
||||
mDurationFormat = isSelection
|
||||
? NumericConverter::TimeAndSampleFormat()
|
||||
: NumericConverter::DefaultSelectionFormat();
|
||||
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
mF0 = selectedRegion->f0();
|
||||
|
|
|
@ -165,8 +165,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
|
|||
|
||||
double GetDefaultDuration() override;
|
||||
double GetDuration() override;
|
||||
wxString GetDurationFormat() override;
|
||||
virtual wxString GetSelectionFormat() /* not override? */; // time format in Selection toolbar
|
||||
NumericFormatId GetDurationFormat() override;
|
||||
virtual NumericFormatId GetSelectionFormat() /* not override? */; // time format in Selection toolbar
|
||||
void SetDuration(double duration) override;
|
||||
|
||||
bool Apply() override;
|
||||
|
@ -515,7 +515,7 @@ private:
|
|||
|
||||
bool mIsSelection;
|
||||
double mDuration;
|
||||
wxString mDurationFormat;
|
||||
NumericFormatId mDurationFormat;
|
||||
|
||||
bool mIsPreview;
|
||||
|
||||
|
|
|
@ -203,8 +203,8 @@ auStaticText * SelectionBar::AddTitle( const wxString & Title, wxSizer * pSizer
|
|||
|
||||
|
||||
NumericTextCtrl * SelectionBar::AddTime( const wxString Name, int id, wxSizer * pSizer ){
|
||||
wxString formatName = mListener ? mListener->AS_GetSelectionFormat()
|
||||
: wxString(wxEmptyString);
|
||||
auto formatName = mListener ? mListener->AS_GetSelectionFormat()
|
||||
: NumericFormatId{};
|
||||
auto pCtrl = safenew NumericTextCtrl(
|
||||
this, id, NumericConverter::TIME, formatName, 0.0, mRate);
|
||||
pCtrl->SetName(Name);
|
||||
|
@ -426,8 +426,13 @@ void SelectionBar::SetListener(SelectionBarListener *l)
|
|||
void SelectionBar::RegenerateTooltips()
|
||||
{
|
||||
#if wxUSE_TOOLTIPS
|
||||
wxString formatName = mListener ? mListener->AS_GetSelectionFormat() : wxString(wxEmptyString);
|
||||
mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), formatName));
|
||||
auto formatName =
|
||||
mListener
|
||||
? mListener->AS_GetSelectionFormat()
|
||||
: NumericFormatId{};
|
||||
mSnapTo->SetToolTip(
|
||||
wxString::Format(
|
||||
_("Snap Clicks/Selections to %s"), formatName.Translation() ));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -567,11 +572,11 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||
|
||||
evt.Skip(false);
|
||||
|
||||
wxString format;
|
||||
|
||||
// Save format name before recreating the controls so they resize properly
|
||||
format = mStartTime->GetBuiltinName(index);
|
||||
mListener->AS_SetSelectionFormat(format);
|
||||
{
|
||||
auto format = mStartTime->GetBuiltinName(index);
|
||||
mListener->AS_SetSelectionFormat(format);
|
||||
}
|
||||
|
||||
RegenerateTooltips();
|
||||
|
||||
|
@ -587,7 +592,7 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||
|
||||
ValuesToControls();
|
||||
|
||||
format = mStartTime->GetBuiltinFormat(index);
|
||||
auto format = mStartTime->GetBuiltinFormat(index);
|
||||
for( i=0;i<5;i++)
|
||||
(*Ctrls[i])->SetFormatString( format );
|
||||
|
||||
|
@ -765,7 +770,7 @@ void SelectionBar::SetSnapTo(int snap)
|
|||
mSnapTo->SetSelection(snap);
|
||||
}
|
||||
|
||||
void SelectionBar::SetSelectionFormat(const wxString & format)
|
||||
void SelectionBar::SetSelectionFormat(const NumericFormatId & format)
|
||||
{
|
||||
mStartTime->SetFormatString(mStartTime->GetBuiltinFormat(format));
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class SelectionBar final : public ToolBar {
|
|||
void SetTimes(double start, double end, double audio);
|
||||
void SetField(const wxChar *msg, int fieldNum);
|
||||
void SetSnapTo(int);
|
||||
void SetSelectionFormat(const wxString & format);
|
||||
void SetSelectionFormat(const NumericFormatId & format);
|
||||
void SetRate(double rate);
|
||||
void SetListener(SelectionBarListener *l);
|
||||
void RegenerateTooltips() override;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#ifndef __AUDACITY_SELECTION_BAR_LISTENER__
|
||||
#define __AUDACITY_SELECTION_BAR_LISTENER__
|
||||
|
||||
class IdentInterfaceSymbol;
|
||||
using NumericFormatId = IdentInterfaceSymbol;
|
||||
class SelectedRegion;
|
||||
|
||||
class AUDACITY_DLL_API SelectionBarListener /* not final */ {
|
||||
|
@ -24,8 +26,8 @@ class AUDACITY_DLL_API SelectionBarListener /* not final */ {
|
|||
virtual void AS_SetRate(double rate) = 0;
|
||||
virtual int AS_GetSnapTo() = 0;
|
||||
virtual void AS_SetSnapTo(int snap) = 0;
|
||||
virtual const wxString & AS_GetSelectionFormat() = 0;
|
||||
virtual void AS_SetSelectionFormat(const wxString & format) = 0;
|
||||
virtual const NumericFormatId & AS_GetSelectionFormat() = 0;
|
||||
virtual void AS_SetSelectionFormat(const NumericFormatId & format) = 0;
|
||||
virtual void AS_ModifySelection(double &start, double &end, bool done) = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -126,12 +126,12 @@ void SpectralSelectionBar::Populate()
|
|||
* look-ups static because they depend on translations which are done at
|
||||
* runtime */
|
||||
|
||||
wxString frequencyFormatName = mListener
|
||||
auto frequencyFormatName = mListener
|
||||
? mListener->SSBL_GetFrequencySelectionFormatName()
|
||||
: wxString(wxEmptyString);
|
||||
wxString bandwidthFormatName = mListener
|
||||
: NumericFormatId{};
|
||||
auto bandwidthFormatName = mListener
|
||||
? mListener->SSBL_GetBandwidthSelectionFormatName()
|
||||
: wxString(wxEmptyString);
|
||||
: NumericFormatId{};
|
||||
|
||||
wxFlexGridSizer *mainSizer;
|
||||
Add((mainSizer = safenew wxFlexGridSizer(1, 1, 1)), 0,wxALIGN_TOP | wxLEFT | wxTOP, 5);
|
||||
|
@ -352,12 +352,12 @@ void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||
wxEventType type = evt.GetEventType();
|
||||
if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
|
||||
NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
|
||||
wxString frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
|
||||
auto frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
|
||||
mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
|
||||
}
|
||||
else if (mbCenterAndWidth &&
|
||||
type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
|
||||
wxString bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
|
||||
auto bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
|
||||
mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ void SpectralSelectionBar::SetFrequencies(double bottom, double top)
|
|||
ValuesToControls();
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetFrequencySelectionFormatName(const wxString & formatName)
|
||||
void SpectralSelectionBar::SetFrequencySelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
|
||||
frequencyCtrl->SetFormatName(formatName);
|
||||
|
@ -441,7 +441,7 @@ void SpectralSelectionBar::SetFrequencySelectionFormatName(const wxString & form
|
|||
OnUpdate(e);
|
||||
}
|
||||
|
||||
void SpectralSelectionBar::SetBandwidthSelectionFormatName(const wxString & formatName)
|
||||
void SpectralSelectionBar::SetBandwidthSelectionFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
if (mbCenterAndWidth) {
|
||||
mWidthCtrl->SetFormatName(formatName);
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
void UpdatePrefs() override;
|
||||
|
||||
void SetFrequencies(double bottom, double top);
|
||||
void SetFrequencySelectionFormatName(const wxString & formatName);
|
||||
void SetBandwidthSelectionFormatName(const wxString & formatName);
|
||||
void SetFrequencySelectionFormatName(const NumericFormatId & formatName);
|
||||
void SetBandwidthSelectionFormatName(const NumericFormatId & formatName);
|
||||
void SetListener(SpectralSelectionBarListener *l);
|
||||
|
||||
void RegenerateTooltips() override {};
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
#include "../Audacity.h"
|
||||
|
||||
class wxString;
|
||||
class IdentInterfaceSymbol;
|
||||
using NumericFormatId = IdentInterfaceSymbol;
|
||||
|
||||
class AUDACITY_DLL_API SpectralSelectionBarListener /* not final */ {
|
||||
|
||||
|
@ -24,11 +25,11 @@ class AUDACITY_DLL_API SpectralSelectionBarListener /* not final */ {
|
|||
|
||||
virtual double SSBL_GetRate() const = 0;
|
||||
|
||||
virtual const wxString & SSBL_GetFrequencySelectionFormatName() = 0;
|
||||
virtual void SSBL_SetFrequencySelectionFormatName(const wxString & formatName) = 0;
|
||||
virtual const NumericFormatId & SSBL_GetFrequencySelectionFormatName() = 0;
|
||||
virtual void SSBL_SetFrequencySelectionFormatName(const NumericFormatId & formatName) = 0;
|
||||
|
||||
virtual const wxString & SSBL_GetBandwidthSelectionFormatName() = 0;
|
||||
virtual void SSBL_SetBandwidthSelectionFormatName(const wxString & formatName) = 0;
|
||||
virtual const NumericFormatId & SSBL_GetBandwidthSelectionFormatName() = 0;
|
||||
virtual void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId & formatName) = 0;
|
||||
|
||||
virtual void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) = 0;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "../Internat.h"
|
||||
|
||||
NumericEditor::NumericEditor
|
||||
(NumericConverter::Type type, const wxString &format, double rate)
|
||||
(NumericConverter::Type type, const NumericFormatId &format, double rate)
|
||||
{
|
||||
mType = type;
|
||||
mFormat = format;
|
||||
|
@ -131,7 +131,7 @@ wxString NumericEditor::GetValue() const
|
|||
return wxString::Format(wxT("%g"), GetNumericTextControl()->GetValue());
|
||||
}
|
||||
|
||||
wxString NumericEditor::GetFormat() const
|
||||
NumericFormatId NumericEditor::GetFormat() const
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ double NumericEditor::GetRate() const
|
|||
return mRate;
|
||||
}
|
||||
|
||||
void NumericEditor::SetFormat(const wxString &format)
|
||||
void NumericEditor::SetFormat(const NumericFormatId &format)
|
||||
{
|
||||
mFormat = format;
|
||||
}
|
||||
|
@ -396,12 +396,14 @@ Grid::Grid(wxWindow *parent,
|
|||
RegisterDataType(GRID_VALUE_TIME,
|
||||
safenew NumericRenderer{ NumericConverter::TIME },
|
||||
safenew NumericEditor
|
||||
{ NumericTextCtrl::TIME, wxT("seconds"), 44100.0 });
|
||||
{ NumericTextCtrl::TIME,
|
||||
NumericConverter::SecondsFormat(), 44100.0 });
|
||||
|
||||
RegisterDataType(GRID_VALUE_FREQUENCY,
|
||||
safenew NumericRenderer{ NumericConverter::FREQUENCY },
|
||||
safenew NumericEditor
|
||||
{ NumericTextCtrl::FREQUENCY, wxT("Hz"), 44100.0 });
|
||||
{ NumericTextCtrl::FREQUENCY,
|
||||
NumericConverter::HertzFormat(), 44100.0 });
|
||||
|
||||
RegisterDataType(GRID_VALUE_CHOICE,
|
||||
safenew wxGridCellStringRenderer,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <wx/string.h>
|
||||
#include <wx/window.h>
|
||||
#include "NumericTextCtrl.h"
|
||||
#include "../Internat.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
#include <wx/access.h>
|
||||
|
@ -29,6 +30,7 @@ class GridAx;
|
|||
#endif
|
||||
|
||||
class NumericTextCtrl;
|
||||
using NumericFormatId = IdentInterfaceSymbol;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// NumericEditor
|
||||
|
@ -43,7 +45,7 @@ class NumericEditor /* not final */ : public wxGridCellEditor
|
|||
public:
|
||||
|
||||
NumericEditor
|
||||
(NumericConverter::Type type, const wxString &format, double rate);
|
||||
(NumericConverter::Type type, const NumericFormatId &format, double rate);
|
||||
|
||||
~NumericEditor();
|
||||
|
||||
|
@ -62,9 +64,9 @@ public:
|
|||
|
||||
void Reset() override;
|
||||
|
||||
wxString GetFormat() const;
|
||||
NumericFormatId GetFormat() const;
|
||||
double GetRate() const;
|
||||
void SetFormat(const wxString &format);
|
||||
void SetFormat(const NumericFormatId &format);
|
||||
void SetRate(double rate);
|
||||
|
||||
wxGridCellEditor *Clone() const override;
|
||||
|
@ -75,7 +77,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
wxString mFormat;
|
||||
NumericFormatId mFormat;
|
||||
double mRate;
|
||||
NumericConverter::Type mType;
|
||||
double mOld;
|
||||
|
|
|
@ -198,27 +198,12 @@ different formats.
|
|||
* to the user */
|
||||
struct BuiltinFormatString
|
||||
{
|
||||
wxString name;
|
||||
wxString formatStr;
|
||||
};
|
||||
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// UntranslatedBuiltinFormatString Struct
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
/** \brief struct to hold a formatting control string and its untranslated name
|
||||
* Used in an array to hold the built-in time formats that are always available
|
||||
* to the user */
|
||||
struct UntranslatedBuiltinFormatString
|
||||
{
|
||||
wxString name;
|
||||
NumericFormatId name;
|
||||
wxString formatStr;
|
||||
|
||||
BuiltinFormatString Translate() const
|
||||
{
|
||||
return { wxGetTranslation( name ), wxGetTranslation( formatStr ) };
|
||||
}
|
||||
friend inline bool operator ==
|
||||
(const BuiltinFormatString &a, const BuiltinFormatString &b)
|
||||
{ return a.name == b.name; }
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -290,16 +275,14 @@ public:
|
|||
|
||||
namespace {
|
||||
|
||||
const std::vector<BuiltinFormatString> &TimeConverterFormats() {
|
||||
|
||||
/** \brief array of formats the control knows about internally
|
||||
* array of string pairs for name of the format and the format string
|
||||
* needed to create that format output. This is used for the pop-up
|
||||
* list of formats to choose from in the control. */
|
||||
static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
||||
static const BuiltinFormatString TimeConverterFormats_[] = {
|
||||
{
|
||||
/* i18n-hint: Name of time display format that shows time in seconds */
|
||||
XO("seconds"),
|
||||
{ XO("seconds") },
|
||||
/* i18n-hint: Format string for displaying time in seconds. Change the comma
|
||||
* in the middle to the 1000s separator for your locale, and the 'seconds'
|
||||
* on the end to the word for seconds. Don't change the numbers. */
|
||||
|
@ -309,7 +292,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours, minutes
|
||||
* and seconds */
|
||||
XO("hh:mm:ss"),
|
||||
{ XO("hh:mm:ss") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes and
|
||||
* seconds. Change the 'h' to the abbreviation for hours, 'm' to the
|
||||
* abbreviation for minutes and 's' to the abbreviation for seconds. Don't
|
||||
|
@ -321,7 +304,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in days, hours,
|
||||
* minutes and seconds */
|
||||
XO("dd:hh:mm:ss"),
|
||||
{ XO("dd:hh:mm:ss") },
|
||||
/* i18n-hint: Format string for displaying time in days, hours, minutes and
|
||||
* seconds. Change the 'days' to the word for days, 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes and 's' to the
|
||||
|
@ -333,7 +316,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours,
|
||||
* minutes, seconds and hundredths of a second (1/100 second) */
|
||||
XO("hh:mm:ss + hundredths"),
|
||||
{ XO("hh:mm:ss + hundredths") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and hundredths of a second. Change the 'h' to the abbreviation for hours,
|
||||
* 'm' to the abbreviation for minutes and 's' to the abbreviation for seconds
|
||||
|
@ -345,7 +328,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours,
|
||||
* minutes, seconds and milliseconds (1/1000 second) */
|
||||
XO("hh:mm:ss + milliseconds"),
|
||||
{ XO("hh:mm:ss + milliseconds") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and milliseconds. Change the 'h' to the abbreviation for hours, 'm' to the
|
||||
* abbreviation for minutes and 's' to the abbreviation for seconds (the
|
||||
|
@ -357,7 +340,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours,
|
||||
* minutes, seconds and samples (at the current project sample rate) */
|
||||
XO("hh:mm:ss + samples"),
|
||||
{ XO("hh:mm:ss + samples") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and samples. Change the 'h' to the abbreviation for hours, 'm' to the
|
||||
* abbreviation for minutes, 's' to the abbreviation for seconds and
|
||||
|
@ -371,7 +354,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
* current project sample rate). For example the number of a sample at 1
|
||||
* second into a recording at 44.1KHz would be 44,100.
|
||||
*/
|
||||
XO("samples"),
|
||||
{ XO("samples") },
|
||||
/* i18n-hint: Format string for displaying time in samples (lots of samples).
|
||||
* Change the ',' to the 1000s separator for your locale, and translate
|
||||
* samples. If 1000s aren't a base multiple for your number system, then you
|
||||
|
@ -382,7 +365,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours, minutes,
|
||||
* seconds and frames at 24 frames per second (commonly used for films) */
|
||||
XO("hh:mm:ss + film frames (24 fps)"),
|
||||
{ XO("hh:mm:ss + film frames (24 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and frames at 24 frames per second. Change the 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
|
||||
|
@ -394,7 +377,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in frames (lots of
|
||||
* frames) at 24 frames per second (commonly used for films) */
|
||||
XO("film frames (24 fps)"),
|
||||
{ XO("film frames (24 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in frames at 24 frames per
|
||||
* second. Change the comma
|
||||
* in the middle to the 1000s separator for your locale,
|
||||
|
@ -406,7 +389,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
/* i18n-hint: Name of time display format that shows time in hours, minutes,
|
||||
* seconds and frames at NTSC TV drop-frame rate (used for American /
|
||||
* Japanese TV, and very odd) */
|
||||
XO("hh:mm:ss + NTSC drop frames"),
|
||||
{ XO("hh:mm:ss + NTSC drop frames") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and frames with NTSC drop frames. Change the 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
|
||||
|
@ -418,7 +401,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
/* i18n-hint: Name of time display format that shows time in hours, minutes,
|
||||
* seconds and frames at NTSC TV non-drop-frame rate (used for American /
|
||||
* Japanese TV, and doesn't quite match wall time */
|
||||
XO("hh:mm:ss + NTSC non-drop frames"),
|
||||
{ XO("hh:mm:ss + NTSC non-drop frames") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and frames with NTSC drop frames. Change the 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
|
||||
|
@ -430,7 +413,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in frames at NTSC
|
||||
* TV frame rate (used for American / Japanese TV */
|
||||
XO("NTSC frames"),
|
||||
{ XO("NTSC frames") },
|
||||
/* i18n-hint: Format string for displaying time in frames with NTSC frames.
|
||||
* Change the comma
|
||||
* in the middle to the 1000s separator for your locale,
|
||||
|
@ -442,7 +425,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours, minutes,
|
||||
* seconds and frames at PAL TV frame rate (used for European TV) */
|
||||
XO("hh:mm:ss + PAL frames (25 fps)"),
|
||||
{ XO("hh:mm:ss + PAL frames (25 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and frames with PAL TV frames. Change the 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
|
||||
|
@ -453,7 +436,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in frames at PAL
|
||||
* TV frame rate (used for European TV) */
|
||||
XO("PAL frames (25 fps)"),
|
||||
{ XO("PAL frames (25 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in frames with NTSC frames.
|
||||
* Change the comma
|
||||
* in the middle to the 1000s separator for your locale,
|
||||
|
@ -464,7 +447,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in hours, minutes,
|
||||
* seconds and frames at CD Audio frame rate (75 frames per second) */
|
||||
XO("hh:mm:ss + CDDA frames (75 fps)"),
|
||||
{ XO("hh:mm:ss + CDDA frames (75 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in hours, minutes, seconds
|
||||
* and frames with CD Audio frames. Change the 'h' to the abbreviation
|
||||
* for hours, 'm' to the abbreviation for minutes, 's' to the abbreviation
|
||||
|
@ -475,7 +458,7 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of time display format that shows time in frames at CD
|
||||
* Audio frame rate (75 frames per second) */
|
||||
XO("CDDA frames (75 fps)"),
|
||||
{ XO("CDDA frames (75 fps)") },
|
||||
/* i18n-hint: Format string for displaying time in frames with CD Audio
|
||||
* frames. Change the comma
|
||||
* in the middle to the 1000s separator for your locale,
|
||||
|
@ -484,70 +467,36 @@ static const UntranslatedBuiltinFormatString TimeConverterFormats_[] = {
|
|||
},
|
||||
};
|
||||
|
||||
class FormatsArray final
|
||||
: public TranslatableArray< std::vector< BuiltinFormatString > >
|
||||
{
|
||||
void Populate() override
|
||||
{
|
||||
for (auto &format : TimeConverterFormats_)
|
||||
mContents.push_back( format.Translate() );
|
||||
}
|
||||
};
|
||||
|
||||
static FormatsArray theArray;
|
||||
return theArray.Get();
|
||||
|
||||
} // end function
|
||||
|
||||
const std::vector<BuiltinFormatString> &FrequencyConverterFormats() {
|
||||
|
||||
/** \brief array of formats the control knows about internally
|
||||
* array of string pairs for name of the format and the format string
|
||||
* needed to create that format output. This is used for the pop-up
|
||||
* list of formats to choose from in the control. */
|
||||
static const UntranslatedBuiltinFormatString FrequencyConverterFormats_[] = {
|
||||
static const BuiltinFormatString FrequencyConverterFormats_[] = {
|
||||
/* i18n-hint: Name of display format that shows frequency in hertz */
|
||||
{
|
||||
XO("Hz"),
|
||||
{ XO("Hz") },
|
||||
/* i18n-hint: Format string for displaying frequency in hertz. Change
|
||||
* the decimal point for your locale. Don't change the numbers. */
|
||||
XO("0100000.0100 Hz")
|
||||
},
|
||||
|
||||
{
|
||||
XO("kHz"),
|
||||
{ XO("kHz") },
|
||||
/* i18n-hint: Format string for displaying frequency in kilohertz. Change
|
||||
* the decimal point for your locale. Don't change the numbers. */
|
||||
XO("01000.01000 kHz|0.001")
|
||||
},
|
||||
};
|
||||
|
||||
class FormatsArray final
|
||||
: public TranslatableArray< std::vector< BuiltinFormatString > >
|
||||
{
|
||||
void Populate() override
|
||||
{
|
||||
for (auto &format : FrequencyConverterFormats_)
|
||||
mContents.push_back( format.Translate() );
|
||||
}
|
||||
};
|
||||
|
||||
static FormatsArray theArray;
|
||||
return theArray.Get();
|
||||
|
||||
} // end function
|
||||
|
||||
const std::vector<BuiltinFormatString> &BandwidthConverterFormats() {
|
||||
|
||||
/** \brief array of formats the control knows about internally
|
||||
* array of string pairs for name of the format and the format string
|
||||
* needed to create that format output. This is used for the pop-up
|
||||
* list of formats to choose from in the control. */
|
||||
static const UntranslatedBuiltinFormatString BandwidthConverterFormats_[] = {
|
||||
static const BuiltinFormatString BandwidthConverterFormats_[] = {
|
||||
{
|
||||
/* i18n-hint: Name of display format that shows log of frequency
|
||||
* in octaves */
|
||||
XO("octaves"),
|
||||
{ XO("octaves") },
|
||||
/* i18n-hint: Format string for displaying log of frequency in octaves.
|
||||
* Change the decimal points for your locale. Don't change the numbers. */
|
||||
// Scale factor is 1 / ln (2)
|
||||
|
@ -557,7 +506,7 @@ static const UntranslatedBuiltinFormatString BandwidthConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of display format that shows log of frequency
|
||||
* in semitones and cents */
|
||||
XO("semitones + cents"),
|
||||
{ XO("semitones + cents") },
|
||||
/* i18n-hint: Format string for displaying log of frequency in semitones
|
||||
* and cents.
|
||||
* Change the decimal points for your locale. Don't change the numbers. */
|
||||
|
@ -568,7 +517,7 @@ static const UntranslatedBuiltinFormatString BandwidthConverterFormats_[] = {
|
|||
{
|
||||
/* i18n-hint: Name of display format that shows log of frequency
|
||||
* in decades */
|
||||
XO("decades"),
|
||||
{ XO("decades") },
|
||||
/* i18n-hint: Format string for displaying log of frequency in decades.
|
||||
* Change the decimal points for your locale. Don't change the numbers. */
|
||||
// Scale factor is 1 / ln (10)
|
||||
|
@ -576,33 +525,31 @@ static const UntranslatedBuiltinFormatString BandwidthConverterFormats_[] = {
|
|||
},
|
||||
};
|
||||
|
||||
|
||||
class FormatsArray final
|
||||
: public TranslatableArray< std::vector< BuiltinFormatString > >
|
||||
{
|
||||
void Populate() override
|
||||
{
|
||||
for (auto &format : BandwidthConverterFormats_)
|
||||
mContents.push_back( format.Translate() );
|
||||
}
|
||||
};
|
||||
|
||||
static FormatsArray theArray;
|
||||
return theArray.Get();
|
||||
|
||||
} // end function
|
||||
|
||||
const std::vector<BuiltinFormatString> &ChooseBuiltinFormatStrings
|
||||
const BuiltinFormatString *ChooseBuiltinFormatStrings
|
||||
(NumericConverter::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
case NumericConverter::TIME:
|
||||
return TimeConverterFormats();
|
||||
return TimeConverterFormats_;
|
||||
case NumericConverter::FREQUENCY:
|
||||
return FrequencyConverterFormats();
|
||||
return FrequencyConverterFormats_;
|
||||
case NumericConverter::BANDWIDTH:
|
||||
return BandwidthConverterFormats();
|
||||
return BandwidthConverterFormats_;
|
||||
}
|
||||
}
|
||||
|
||||
size_t ChooseNBuiltinFormatStrings
|
||||
(NumericConverter::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
case NumericConverter::TIME:
|
||||
return WXSIZEOF(TimeConverterFormats_);
|
||||
case NumericConverter::FREQUENCY:
|
||||
return WXSIZEOF(FrequencyConverterFormats_);
|
||||
case NumericConverter::BANDWIDTH:
|
||||
return WXSIZEOF(BandwidthConverterFormats_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -612,11 +559,42 @@ return theArray.Get();
|
|||
// NumericConverter Class
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
NumericFormatId NumericConverter::DefaultSelectionFormat()
|
||||
{ return TimeConverterFormats_[4].name; }
|
||||
NumericFormatId NumericConverter::TimeAndSampleFormat()
|
||||
{ return TimeConverterFormats_[5].name; }
|
||||
NumericFormatId NumericConverter::SecondsFormat()
|
||||
{ return TimeConverterFormats_[0].name; }
|
||||
NumericFormatId NumericConverter::HundredthsFormat()
|
||||
{ return TimeConverterFormats_[3].name; }
|
||||
|
||||
NumericFormatId NumericConverter::HertzFormat()
|
||||
{ return FrequencyConverterFormats_[0].name; }
|
||||
|
||||
NumericFormatId NumericConverter::LookupFormat( Type type, const wxString& id)
|
||||
{
|
||||
if (id.empty()) {
|
||||
if (type == TIME)
|
||||
return DefaultSelectionFormat();
|
||||
else
|
||||
return ChooseBuiltinFormatStrings(type)[0].name;
|
||||
}
|
||||
else {
|
||||
auto begin = ChooseBuiltinFormatStrings(type);
|
||||
auto end = begin + ChooseNBuiltinFormatStrings(type);
|
||||
auto iter = std::find( begin, end, BuiltinFormatString{ id, {} } );
|
||||
if (iter == end)
|
||||
iter = begin;
|
||||
return iter->name;
|
||||
}
|
||||
}
|
||||
|
||||
NumericConverter::NumericConverter(Type type,
|
||||
const wxString & formatName,
|
||||
const NumericFormatId & formatName,
|
||||
double value,
|
||||
double sampleRate)
|
||||
: mBuiltinFormatStrings( ChooseBuiltinFormatStrings( type ) )
|
||||
, mNBuiltins( ChooseNBuiltinFormatStrings( type ) )
|
||||
{
|
||||
ResetMinValue();
|
||||
ResetMaxValue();
|
||||
|
@ -629,8 +607,6 @@ NumericConverter::NumericConverter(Type type,
|
|||
if (type == NumericConverter::TIME )
|
||||
mDefaultNdx = 4; // Default to "hh:mm:ss + milliseconds".
|
||||
|
||||
mNBuiltins = mBuiltinFormatStrings.size();
|
||||
|
||||
mPrefix = wxT("");
|
||||
mValueTemplate = wxT("");
|
||||
mValueMask = wxT("");
|
||||
|
@ -992,7 +968,7 @@ void NumericConverter::ControlsToValue()
|
|||
mValue = std::max(mMinValue, std::min(mMaxValue, t));
|
||||
}
|
||||
|
||||
void NumericConverter::SetFormatName(const wxString & formatName)
|
||||
void NumericConverter::SetFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
}
|
||||
|
@ -1055,11 +1031,6 @@ double NumericConverter::GetValue()
|
|||
return mValue;
|
||||
}
|
||||
|
||||
wxString NumericConverter::GetFormatString()
|
||||
{
|
||||
return mFormatString;
|
||||
}
|
||||
|
||||
int NumericConverter::GetFormatIndex()
|
||||
{
|
||||
// int ndx = 1;
|
||||
|
@ -1081,12 +1052,12 @@ int NumericConverter::GetNumBuiltins()
|
|||
return mNBuiltins;
|
||||
}
|
||||
|
||||
wxString NumericConverter::GetBuiltinName(const int index)
|
||||
NumericFormatId NumericConverter::GetBuiltinName(const int index)
|
||||
{
|
||||
if (index >= 0 && index < GetNumBuiltins())
|
||||
return mBuiltinFormatStrings[index].name;
|
||||
|
||||
return wxEmptyString;
|
||||
return {};
|
||||
}
|
||||
|
||||
wxString NumericConverter::GetBuiltinFormat(const int index)
|
||||
|
@ -1094,20 +1065,17 @@ wxString NumericConverter::GetBuiltinFormat(const int index)
|
|||
if (index >= 0 && index < GetNumBuiltins())
|
||||
return mBuiltinFormatStrings[index].formatStr;
|
||||
|
||||
return wxEmptyString;
|
||||
return {};
|
||||
}
|
||||
|
||||
wxString NumericConverter::GetBuiltinFormat(const wxString &name)
|
||||
wxString NumericConverter::GetBuiltinFormat(const NumericFormatId &name)
|
||||
{
|
||||
int ndx = mDefaultNdx;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GetNumBuiltins(); i++) {
|
||||
if (name == GetBuiltinName(i)) {
|
||||
ndx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int ndx =
|
||||
std::find( mBuiltinFormatStrings, mBuiltinFormatStrings + mNBuiltins,
|
||||
BuiltinFormatString{ name, {} } )
|
||||
- mBuiltinFormatStrings;
|
||||
if (ndx == mNBuiltins)
|
||||
ndx = mDefaultNdx;
|
||||
|
||||
return GetBuiltinFormat(ndx);
|
||||
}
|
||||
|
@ -1241,7 +1209,7 @@ IMPLEMENT_CLASS(NumericTextCtrl, wxControl)
|
|||
|
||||
NumericTextCtrl::NumericTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
NumericConverter::Type type,
|
||||
const wxString &formatName,
|
||||
const NumericFormatId &formatName,
|
||||
double timeValue,
|
||||
double sampleRate,
|
||||
const Options &options,
|
||||
|
@ -1314,7 +1282,7 @@ void NumericTextCtrl::UpdateAutoFocus()
|
|||
}
|
||||
}
|
||||
|
||||
void NumericTextCtrl::SetFormatName(const wxString & formatName)
|
||||
void NumericTextCtrl::SetFormatName(const NumericFormatId & formatName)
|
||||
{
|
||||
SetFormatString(GetBuiltinFormat(formatName));
|
||||
}
|
||||
|
@ -1570,7 +1538,7 @@ void NumericTextCtrl::OnContext(wxContextMenuEvent &event)
|
|||
|
||||
int currentSelection = -1;
|
||||
for (i = 0; i < GetNumBuiltins(); i++) {
|
||||
menu.AppendRadioItem(ID_MENU + i, GetBuiltinName(i));
|
||||
menu.AppendRadioItem(ID_MENU + i, GetBuiltinName(i).Translation());
|
||||
if (mFormatString == GetBuiltinFormat(i)) {
|
||||
menu.Check(ID_MENU + i, true);
|
||||
currentSelection = i;
|
||||
|
@ -1606,7 +1574,7 @@ void NumericTextCtrl::OnContext(wxContextMenuEvent &event)
|
|||
|
||||
wxCommandEvent e(eventType, GetId());
|
||||
e.SetInt(i);
|
||||
e.SetString(GetBuiltinName(i));
|
||||
e.SetString(GetBuiltinName(i).Internal());
|
||||
GetParent()->GetEventHandler()->AddPendingEvent(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define __AUDACITY_TIME_TEXT_CTRL__
|
||||
|
||||
#include "../MemoryX.h"
|
||||
#include "../../include/audacity/IdentInterface.h"
|
||||
#include <vector>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/event.h>
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include <wx/textctrl.h>
|
||||
|
||||
#include "../Audacity.h"
|
||||
#include "../Internat.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
#include <wx/access.h>
|
||||
|
@ -47,6 +49,8 @@ class NumericField;
|
|||
|
||||
class DigitInfo;
|
||||
|
||||
using NumericFormatId = IdentInterfaceSymbol;
|
||||
|
||||
class NumericConverter /* not final */
|
||||
{
|
||||
public:
|
||||
|
@ -57,8 +61,16 @@ public:
|
|||
BANDWIDTH,
|
||||
};
|
||||
|
||||
static NumericFormatId DefaultSelectionFormat();
|
||||
static NumericFormatId TimeAndSampleFormat();
|
||||
static NumericFormatId SecondsFormat();
|
||||
static NumericFormatId HundredthsFormat();
|
||||
static NumericFormatId HertzFormat();
|
||||
|
||||
static NumericFormatId LookupFormat( Type type, const wxString& id);
|
||||
|
||||
NumericConverter(Type type,
|
||||
const wxString & formatName = wxEmptyString,
|
||||
const NumericFormatId & formatName = {},
|
||||
double value = 0.0f,
|
||||
double sampleRate = 1.0f /* to prevent div by 0 */);
|
||||
|
||||
|
@ -74,10 +86,12 @@ public:
|
|||
// raw value (mValue).
|
||||
virtual void ControlsToValue();
|
||||
|
||||
virtual void ParseFormatString(const wxString & format);
|
||||
private:
|
||||
void ParseFormatString(const wxString & format);
|
||||
|
||||
public:
|
||||
void PrintDebugInfo();
|
||||
void SetFormatName(const wxString & formatName);
|
||||
void SetFormatName(const NumericFormatId & formatName);
|
||||
void SetFormatString(const wxString & formatString);
|
||||
void SetSampleRate(double sampleRate);
|
||||
void SetValue(double newValue);
|
||||
|
@ -90,13 +104,12 @@ public:
|
|||
|
||||
wxString GetString();
|
||||
|
||||
wxString GetFormatString();
|
||||
int GetFormatIndex();
|
||||
|
||||
int GetNumBuiltins();
|
||||
wxString GetBuiltinName(const int index);
|
||||
NumericFormatId GetBuiltinName(const int index);
|
||||
wxString GetBuiltinFormat(const int index);
|
||||
wxString GetBuiltinFormat(const wxString & name);
|
||||
wxString GetBuiltinFormat(const NumericFormatId & name);
|
||||
|
||||
// Adjust the value by the number "steps" in the active format.
|
||||
// Increment if "dir" is 1, decrement if "dir" is -1.
|
||||
|
@ -130,8 +143,8 @@ protected:
|
|||
int mFocusedDigit;
|
||||
std::vector<DigitInfo> mDigits;
|
||||
|
||||
const std::vector<BuiltinFormatString> &mBuiltinFormatStrings;
|
||||
int mNBuiltins;
|
||||
const BuiltinFormatString *mBuiltinFormatStrings;
|
||||
const size_t mNBuiltins;
|
||||
int mDefaultNdx;
|
||||
};
|
||||
|
||||
|
@ -159,14 +172,16 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
|
|||
Options &MenuEnabled (bool value) { menuEnabled = value; return *this; }
|
||||
Options &InvalidValue (bool has, double value = -1.0)
|
||||
{ hasInvalidValue = has, invalidValue = value; return *this; }
|
||||
Options &Format (const wxString &value) { format = value; return *this; }
|
||||
// use a custom format not in the tables:
|
||||
Options &Format (const wxString &value)
|
||||
{ format = value; return *this; }
|
||||
Options &Value (bool has, double v)
|
||||
{ hasValue = has, value = v; return *this; }
|
||||
};
|
||||
|
||||
NumericTextCtrl(wxWindow *parent, wxWindowID winid,
|
||||
NumericConverter::Type type,
|
||||
const wxString &formatName = wxEmptyString,
|
||||
const NumericFormatId &formatName = {},
|
||||
double value = 0.0,
|
||||
double sampleRate = 44100,
|
||||
const Options &options = {},
|
||||
|
@ -181,7 +196,7 @@ class NumericTextCtrl final : public wxControl, public NumericConverter
|
|||
void SetSampleRate(double sampleRate);
|
||||
void SetValue(double newValue);
|
||||
void SetFormatString(const wxString & formatString);
|
||||
void SetFormatName(const wxString & formatName);
|
||||
void SetFormatName(const NumericFormatId & formatName);
|
||||
|
||||
void SetFieldFocus(int /* digit */);
|
||||
|
||||
|
|
Loading…
Reference in New Issue