diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index 63224bddb..89065d270 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -280,17 +280,16 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.StartVerticalLay(2); { - vRuler = safenew RulerPanel(this, wxID_ANY); - vRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - vRuler->ruler.SetOrientation(wxVERTICAL); - vRuler->ruler.SetRange(0.0, -dBRange); - vRuler->ruler.SetFormat(Ruler::LinearDBFormat); - vRuler->ruler.SetUnits(_("dB")); - vRuler->ruler.SetLabelEdges(true); - int w; - vRuler->ruler.GetMaxSize(&w, NULL); - vRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK - vRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); + vRuler = safenew RulerPanel( + this, wxID_ANY, wxVERTICAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ 0.0, -dBRange }, + Ruler::LinearDBFormat, + _("dB"), + RulerPanel::Options{} + .LabelEdges(true) + .TickColour( theTheme.Colour( clrGraphLabels ) ) + ); S.AddSpace(wxDefaultCoord, 1); S.Prop(1); @@ -299,7 +298,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, } S.EndVerticalLay(); - mFreqPlot = safenew FreqPlot(this); + mFreqPlot = safenew FreqPlot(this, wxID_ANY); mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT)); S.Prop(1); S.AddWindow(mFreqPlot, wxEXPAND); @@ -348,19 +347,18 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.StartHorizontalLay(wxEXPAND, 0); { - hRuler = safenew RulerPanel(this, wxID_ANY); - hRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - hRuler->ruler.SetOrientation(wxHORIZONTAL); - hRuler->ruler.SetLog(true); - hRuler->ruler.SetRange(10, 20000); - hRuler->ruler.SetFormat(Ruler::RealFormat); - hRuler->ruler.SetUnits(_("Hz")); - hRuler->ruler.SetFlip(true); - hRuler->ruler.SetLabelEdges(true); - int h; - hRuler->ruler.GetMaxSize(NULL, &h); - hRuler->SetMinSize(wxSize(wxDefaultCoord, h)); - hRuler->SetTickColour( theTheme.Colour( clrGraphLabels )); + hRuler = safenew RulerPanel( + this, wxID_ANY, wxHORIZONTAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ 10, 20000 }, + Ruler::RealFormat, + _("Hz"), + RulerPanel::Options{} + .Log(true) + .Flip(true) + .LabelEdges(true) + .TickColour( theTheme.Colour( clrGraphLabels ) ) + ); S.AddSpace(1, wxDefaultCoord); S.Prop(1); @@ -483,7 +481,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.AddSpace(5); - mProgress = safenew FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP); + mProgress = safenew FreqGauge(this, wxID_ANY); //, wxST_SIZEGRIP); S.AddWindow(mProgress, wxEXPAND); // Log-frequency axis works for spectrum plots only. @@ -1111,8 +1109,8 @@ BEGIN_EVENT_TABLE(FreqPlot, wxWindow) EVT_MOUSE_EVENTS(FreqPlot::OnMouseEvent) END_EVENT_TABLE() -FreqPlot::FreqPlot(wxWindow *parent) -: wxWindow(parent, wxID_ANY) +FreqPlot::FreqPlot(wxWindow *parent, wxWindowID winid) +: wxWindow(parent, winid) { freqWindow = (FreqWindow *) parent; } @@ -1137,8 +1135,8 @@ void FreqPlot::OnMouseEvent(wxMouseEvent & event) freqWindow->PlotMouseEvent(event); } -FreqGauge::FreqGauge(wxWindow * parent) -: wxStatusBar(parent, wxID_ANY, wxST_SIZEGRIP) +FreqGauge::FreqGauge(wxWindow * parent, wxWindowID winid) +: wxStatusBar(parent, winid, wxST_SIZEGRIP) { mRange = 0; } diff --git a/src/FreqWindow.h b/src/FreqWindow.h index c99125d1c..98ded8968 100644 --- a/src/FreqWindow.h +++ b/src/FreqWindow.h @@ -86,7 +86,7 @@ private: class FreqGauge final : public wxStatusBar { public: - FreqGauge(wxWindow * parent); + FreqGauge(wxWindow * parent, wxWindowID winid); void SetRange(int range, int bar = 12, int gap = 3); void SetValue(int value); @@ -106,7 +106,7 @@ private: class FreqPlot final : public wxWindow { public: - FreqPlot(wxWindow *parent); + FreqPlot(wxWindow *parent, wxWindowID winid); // We don't need or want to accept focus. bool AcceptsFocus() const; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 9272000ae..37e726106 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -62,13 +62,8 @@ MixerTrackSlider::MixerTrackSlider(wxWindow * parent, const wxString &name, const wxPoint & pos, const wxSize & size, - int style /*= FRAC_SLIDER*/, - bool popup /*= true*/, - bool canUseShift /*= true*/, - float stepValue /*= STEP_CONTINUOUS*/, - int orientation /*= wxHORIZONTAL*/) -: ASlider(parent, id, name, pos, size, - style, popup, canUseShift, stepValue, orientation) + const ASlider::Options &options) +: ASlider(parent, id, name, pos, size, options) { } @@ -209,8 +204,10 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, this, ID_SLIDER_GAIN, /* i18n-hint: title of the Gain slider, used to adjust the volume */ _("Gain"), - ctrlPos, ctrlSize, DB_SLIDER, true, - true, 0.0, wxVERTICAL); + ctrlPos, ctrlSize, + ASlider::Options{} + .Style( DB_SLIDER ) + .Orientation( wxVERTICAL )); mSlider_Gain->SetName(_("Gain")); this->UpdateGain(); #ifdef EXPERIMENTAL_MIDI_OUT @@ -219,8 +216,10 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, this, ID_SLIDER_VELOCITY, /* i18n-hint: title of the MIDI Velocity slider */ _("Velocity"), - ctrlPos, ctrlSize, VEL_SLIDER, true, - true, 0.0, wxVERTICAL); + ctrlPos, ctrlSize, + ASlider::Options{} + .Style( VEL_SLIDER ) + .Orientation( wxVERTICAL )); mSlider_Velocity->SetName(_("Velocity")); this->UpdateVelocity(); #endif @@ -254,7 +253,8 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, this, ID_SLIDER_PAN, /* i18n-hint: Title of the Pan slider, used to move the sound left or right */ _("Pan"), - ctrlPos, ctrlSize, PAN_SLIDER, true); + ctrlPos, ctrlSize, + ASlider::Options{}.Style( PAN_SLIDER )); mSlider_Pan->SetName(_("Pan")); this->UpdatePan(); diff --git a/src/MixerBoard.h b/src/MixerBoard.h index b1d63ab18..1f77eab3c 100644 --- a/src/MixerBoard.h +++ b/src/MixerBoard.h @@ -39,11 +39,7 @@ public: const wxString &name, const wxPoint & pos, const wxSize & size, - int style = FRAC_SLIDER, - bool popup = true, - bool canUseShift = true, - float stepValue = STEP_CONTINUOUS, - int orientation = wxHORIZONTAL); + const ASlider::Options &options = ASlider::Options{}); virtual ~MixerTrackSlider() {} void OnMouseEvent(wxMouseEvent & event); diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index 9d457a4cd..bb4c35310 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -56,17 +56,15 @@ void TimeDialog::PopulateOrExchange(ShuttleGui &S) { mTimeCtrl = safenew NumericTextCtrl( - NumericConverter::TIME, this, - wxID_ANY, + this, wxID_ANY, + NumericConverter::TIME, mFormat, mTime, mRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl::Options{} + .AutoPos(true)); mTimeCtrl->SetName(mPrompt); S.AddWindow(mTimeCtrl); - mTimeCtrl->EnableMenu(); } S.EndStatic(); } diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 3216d608b..1a2ca2941 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -793,6 +793,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * displayed is minutes, and the 's' indicates that the third number displayed is seconds. */ wxString strFormat = _("099 h 060 m 060 s"); + using Options = NumericTextCtrl::Options; S.StartStatic(_("Start Date and Time"), true); { m_pDatePickerCtrl_Start = @@ -808,13 +809,14 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.AddWindow(m_pDatePickerCtrl_Start); m_pTimeTextCtrl_Start = safenew NumericTextCtrl( - NumericConverter::TIME, this, ID_TIMETEXT_START); + this, ID_TIMETEXT_START, NumericConverter::TIME, + wxEmptyString, 0, 44100, + Options{} + .MenuEnabled(false) + .Format(strFormat) + .Value(true, wxDateTime_to_AudacityTime(m_DateTime_Start))); m_pTimeTextCtrl_Start->SetName(_("Start Time")); - m_pTimeTextCtrl_Start->SetFormatString(strFormat); - m_pTimeTextCtrl_Start-> - SetValue(wxDateTime_to_AudacityTime(m_DateTime_Start)); S.AddWindow(m_pTimeTextCtrl_Start); - m_pTimeTextCtrl_Start->EnableMenu(false); } S.EndStatic(); @@ -836,12 +838,14 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.AddWindow(m_pDatePickerCtrl_End); m_pTimeTextCtrl_End = safenew NumericTextCtrl( - NumericConverter::TIME, this, ID_TIMETEXT_END); + this, ID_TIMETEXT_END, NumericConverter::TIME, + wxEmptyString, 0, 44100, + Options{} + .MenuEnabled(false) + .Format(strFormat) + .Value(true, wxDateTime_to_AudacityTime(m_DateTime_End))); m_pTimeTextCtrl_End->SetName(_("End Time")); - m_pTimeTextCtrl_End->SetFormatString(strFormat); - m_pTimeTextCtrl_End->SetValue(wxDateTime_to_AudacityTime(m_DateTime_End)); S.AddWindow(m_pTimeTextCtrl_End); - m_pTimeTextCtrl_End->EnableMenu(false); } S.EndStatic(); @@ -856,12 +860,15 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * seconds. */ wxString strFormat1 = _("099 days 024 h 060 m 060 s"); - m_pTimeTextCtrl_Duration = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_TIMETEXT_DURATION); + m_pTimeTextCtrl_Duration = safenew NumericTextCtrl( + this, ID_TIMETEXT_DURATION, NumericConverter::TIME, + wxEmptyString, 0, 44100, + Options{} + .MenuEnabled(false) + .Format(strFormat1) + .Value(true, m_TimeSpan_Duration.GetSeconds().ToDouble())); m_pTimeTextCtrl_Duration->SetName(_("Duration")); - m_pTimeTextCtrl_Duration->SetFormatString(strFormat1); - m_pTimeTextCtrl_Duration->SetValue(m_TimeSpan_Duration.GetSeconds().ToDouble()); S.AddWindow(m_pTimeTextCtrl_Duration); - m_pTimeTextCtrl_Duration->EnableMenu(false); } S.EndStatic(); } diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index c9579efcd..026b1fd7e 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -428,7 +428,7 @@ void EffectAutoDuck::PopulateOrExchange(ShuttleGui & S) { S.AddSpace(0, 5); - mPanel = safenew EffectAutoDuckPanel(S.GetParent(), this); + mPanel = safenew EffectAutoDuckPanel(S.GetParent(), wxID_ANY, this); S.AddWindow(mPanel); S.AddSpace(0, 5); @@ -618,8 +618,9 @@ BEGIN_EVENT_TABLE(EffectAutoDuckPanel, wxPanelWrapper) EVT_MOTION(EffectAutoDuckPanel::OnMotion) END_EVENT_TABLE() -EffectAutoDuckPanel::EffectAutoDuckPanel(wxWindow *parent, EffectAutoDuck *effect) -: wxPanelWrapper(parent, wxID_ANY, wxDefaultPosition, wxSize(600, 300)) +EffectAutoDuckPanel::EffectAutoDuckPanel( + wxWindow *parent, wxWindowID winid, EffectAutoDuck *effect) +: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(600, 300)) { mParent = parent; mEffect = effect; diff --git a/src/effects/AutoDuck.h b/src/effects/AutoDuck.h index 45aede7cd..e8be652b2 100644 --- a/src/effects/AutoDuck.h +++ b/src/effects/AutoDuck.h @@ -94,7 +94,8 @@ private: class EffectAutoDuckPanel final : public wxPanelWrapper { public: - EffectAutoDuckPanel(wxWindow *parent, EffectAutoDuck *effect); + EffectAutoDuckPanel( + wxWindow *parent, wxWindowID winid, EffectAutoDuck *effect); virtual ~EffectAutoDuckPanel(); private: diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 3b77df4aa..45fcb948c 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -369,31 +369,29 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("Current Length:")); mpFromLengthCtrl = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - wxID_ANY, + NumericTextCtrl(S.GetParent(), wxID_ANY, + NumericConverter::TIME, mFormat, mFromLength, - mProjectRate); + mProjectRate, + NumericTextCtrl::Options{} + .ReadOnly(true) + .MenuEnabled(false)); mpFromLengthCtrl->SetName(_("from")); mpFromLengthCtrl->SetToolTip(_("Current length of selection.")); - mpFromLengthCtrl->SetReadOnly(true); - mpFromLengthCtrl->EnableMenu(false); S.AddWindow(mpFromLengthCtrl, wxALIGN_LEFT); S.AddPrompt(_("New Length:")); mpToLengthCtrl = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - ID_ToLength, + NumericTextCtrl(S.GetParent(), ID_ToLength, + NumericConverter::TIME, mFormat, mToLength, mProjectRate); mpToLengthCtrl->SetName(_("to")); - mpToLengthCtrl->EnableMenu(); S.AddWindow(mpToLengthCtrl, wxALIGN_LEFT); } S.EndMultiColumn(); diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index d2aea1329..2b60b19a7 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -196,7 +196,7 @@ void EffectCompressor::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxEXPAND, true); { S.SetBorder(10); - mPanel = safenew EffectCompressorPanel(S.GetParent(), + mPanel = safenew EffectCompressorPanel(S.GetParent(), wxID_ANY, mThresholdDB, mNoiseFloorDB, mRatio); @@ -644,11 +644,11 @@ BEGIN_EVENT_TABLE(EffectCompressorPanel, wxPanelWrapper) EVT_SIZE(EffectCompressorPanel::OnSize) END_EVENT_TABLE() -EffectCompressorPanel::EffectCompressorPanel(wxWindow *parent, +EffectCompressorPanel::EffectCompressorPanel(wxWindow *parent, wxWindowID winid, double & threshold, double & noiseFloor, double & ratio) -: wxPanelWrapper(parent), +: wxPanelWrapper(parent, winid), threshold(threshold), noiseFloor(noiseFloor), ratio(ratio) diff --git a/src/effects/Compressor.h b/src/effects/Compressor.h index 76f37cbaa..ee48f5f3b 100644 --- a/src/effects/Compressor.h +++ b/src/effects/Compressor.h @@ -138,7 +138,7 @@ private: class EffectCompressorPanel final : public wxPanelWrapper { public: - EffectCompressorPanel(wxWindow *parent, + EffectCompressorPanel(wxWindow *parent, wxWindowID winid, double & threshold, double & noiseFloor, double & ratio); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 232a55efa..49051e2ce 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -200,39 +200,36 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, S.AddFixedText( {} ); // spacer S.AddFixedText(_("Volume ")); + const auto options = NumericTextCtrl::Options{} + .AutoPos(true) + .MenuEnabled(false) + .ReadOnly(true); + //Foreground S.AddFixedText(_("&Foreground:"), false); if (S.GetMode() == eIsCreating) { mForegroundStartT = safenew - NumericTextCtrl(NumericConverter::TIME, this, - ID_FOREGROUNDSTART_T, + NumericTextCtrl(this, ID_FOREGROUNDSTART_T, + NumericConverter::TIME, _("hh:mm:ss + hundredths"), 0.0, mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + options); mForegroundStartT->SetName(_("Foreground start time")); - mForegroundStartT->EnableMenu(false); - mForegroundStartT->SetReadOnly(true); } S.AddWindow(mForegroundStartT); if (S.GetMode() == eIsCreating) { mForegroundEndT = safenew - NumericTextCtrl(NumericConverter::TIME, this, - ID_FOREGROUNDEND_T, + NumericTextCtrl(this, ID_FOREGROUNDEND_T, + NumericConverter::TIME, _("hh:mm:ss + hundredths"), 0.0, mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + options); mForegroundEndT->SetName(_("Foreground end time")); - mForegroundEndT->EnableMenu(false); - mForegroundEndT->SetReadOnly(true); } S.AddWindow(mForegroundEndT); @@ -245,34 +242,26 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, if (S.GetMode() == eIsCreating) { mBackgroundStartT = safenew - NumericTextCtrl(NumericConverter::TIME, this, - ID_BACKGROUNDSTART_T, + NumericTextCtrl(this, ID_BACKGROUNDSTART_T, + NumericConverter::TIME, _("hh:mm:ss + hundredths"), 0.0, mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + options); mBackgroundStartT->SetName(_("Background start time")); - mBackgroundStartT->EnableMenu(false); - mBackgroundStartT->SetReadOnly(true); } S.AddWindow(mBackgroundStartT); if (S.GetMode() == eIsCreating) { mBackgroundEndT = safenew - NumericTextCtrl(NumericConverter::TIME, this, - ID_BACKGROUNDEND_T, + NumericTextCtrl(this, ID_BACKGROUNDEND_T, + NumericConverter::TIME, _("hh:mm:ss + hundredths"), 0.0, mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + options); mBackgroundEndT->SetName(_("Background end time")); - mBackgroundEndT->EnableMenu(false); - mBackgroundEndT->SetReadOnly(true); } S.AddWindow(mBackgroundEndT); diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 99a5fba22..86a919c65 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -326,17 +326,14 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("Duration:")); mDtmfDurationT = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - ID_Duration, + NumericTextCtrl(S.GetParent(), ID_Duration, + NumericConverter::TIME, GetDurationFormat(), GetDuration(), mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl::Options{} + .AutoPos(true)); mDtmfDurationT->SetName(_("Duration")); - mDtmfDurationT->EnableMenu(); S.AddWindow(mDtmfDurationT); S.AddFixedText(_("Tone/silence ratio:"), false); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index b5e703baf..b9a5aa655 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -623,18 +623,17 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) // ------------------------------------------------------------------- S.StartVerticalLay(); { - mdBRuler = safenew RulerPanel(parent, wxID_ANY); - mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - mdBRuler->ruler.SetOrientation(wxVERTICAL); - mdBRuler->ruler.SetRange(60.0, -120.0); - mdBRuler->ruler.SetFormat(Ruler::LinearDBFormat); - mdBRuler->ruler.SetUnits(_("dB")); - mdBRuler->ruler.SetLabelEdges(true); - mdBRuler->ruler.mbTicksAtExtremes = true; - int w; - mdBRuler->ruler.GetMaxSize(&w, NULL); - mdBRuler->SetMinSize(wxSize(w, 150)); // height needed for wxGTK - mdBRuler->ruler.SetTickColour( wxColour(0,0,0) ); + mdBRuler = safenew RulerPanel( + parent, wxID_ANY, wxVERTICAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ 60.0, -120.0 }, + Ruler::LinearDBFormat, + _("dB"), + RulerPanel::Options{} + .LabelEdges(true) + .TicksAtExtremes(true) + .TickColour( { 0, 0, 0 } ) + ); S.Prop(1); S.AddSpace(0, 1); @@ -643,7 +642,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - mPanel = safenew EqualizationPanel(this, parent); + mPanel = safenew EqualizationPanel(parent, wxID_ANY, this); S.Prop(1); S.AddWindow(mPanel, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); @@ -677,20 +676,19 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) // Column 1 is empty S.AddSpace(1, 1); - mFreqRuler = safenew RulerPanel(parent, wxID_ANY); - mFreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - mFreqRuler->ruler.SetOrientation(wxHORIZONTAL); - mFreqRuler->ruler.SetLog(true); - mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq); - mFreqRuler->ruler.SetFormat(Ruler::IntFormat); - mFreqRuler->ruler.SetUnits(_("Hz")); - mFreqRuler->ruler.SetFlip(true); - mFreqRuler->ruler.SetLabelEdges(true); - mFreqRuler->ruler.mbTicksAtExtremes = true; - int h; - mFreqRuler->ruler.GetMaxSize(NULL, &h); - mFreqRuler->SetMinSize(wxSize(wxDefaultCoord, h)); - mFreqRuler->ruler.SetTickColour( wxColour(0,0,0) ); + mFreqRuler = safenew RulerPanel( + parent, wxID_ANY, wxHORIZONTAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ mLoFreq, mHiFreq }, + Ruler::IntFormat, + _("Hz"), + RulerPanel::Options{} + .Log(true) + .Flip(true) + .LabelEdges(true) + .TicksAtExtremes(true) + .TickColour( { 0, 0, 0 } ) + ); S.Prop(1); @@ -2846,8 +2844,9 @@ BEGIN_EVENT_TABLE(EqualizationPanel, wxPanelWrapper) EVT_SIZE(EqualizationPanel::OnSize) END_EVENT_TABLE() -EqualizationPanel::EqualizationPanel(EffectEqualization *effect, wxWindow *parent) -: wxPanelWrapper(parent) +EqualizationPanel::EqualizationPanel( + wxWindow *parent, wxWindowID winid, EffectEqualization *effect) +: wxPanelWrapper(parent, winid) { mParent = parent; mEffect = effect; diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index ba5d5de3b..3b4d4ac05 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -287,7 +287,8 @@ private: class EqualizationPanel final : public wxPanelWrapper { public: - EqualizationPanel(EffectEqualization *effect, wxWindow *parent); + EqualizationPanel( + wxWindow *parent, wxWindowID winid, EffectEqualization *effect); ~EqualizationPanel(); // We don't need or want to accept focus. diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index ceed54ead..3e1f380de 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -231,17 +231,14 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("Duration:")); mNoiseDurationT = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - wxID_ANY, + NumericTextCtrl(S.GetParent(), wxID_ANY, + NumericConverter::TIME, GetDurationFormat(), GetDuration(), mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl::Options{} + .AutoPos(true)); mNoiseDurationT->SetName(_("Duration")); - mNoiseDurationT->EnableMenu(); S.AddWindow(mNoiseDurationT, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL); } S.EndMultiColumn(); diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 083dc988a..b68f9c216 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -377,16 +377,15 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) S.StartVerticalLay(); { - mdBRuler = safenew RulerPanel(parent, wxID_ANY); - mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - mdBRuler->ruler.SetOrientation(wxVERTICAL); - mdBRuler->ruler.SetRange(30.0, -120.0); - mdBRuler->ruler.SetFormat(Ruler::LinearDBFormat); - mdBRuler->ruler.SetUnits(_("dB")); - mdBRuler->ruler.SetLabelEdges(true); - int w; - mdBRuler->ruler.GetMaxSize(&w, NULL); - mdBRuler->SetSize(wxSize(w, 150)); // height needed for wxGTK + mdBRuler = safenew RulerPanel( + parent, wxID_ANY, wxVERTICAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ 30.0, -120.0 }, + Ruler::LinearDBFormat, + _("dB"), + RulerPanel::Options{} + .LabelEdges(true) + ); S.SetBorder(1); S.AddSpace(1, 1); @@ -396,8 +395,10 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - mPanel = safenew EffectScienFilterPanel(this, parent); - mPanel->SetFreqRange(mLoFreq, mNyquist); + mPanel = safenew EffectScienFilterPanel( + parent, wxID_ANY, + this, mLoFreq, mNyquist + ); S.SetBorder(5); S.Prop(1); @@ -430,18 +431,17 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) S.AddSpace(1, 1); - mfreqRuler = safenew RulerPanel(parent, wxID_ANY); - mfreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes - mfreqRuler->ruler.SetOrientation(wxHORIZONTAL); - mfreqRuler->ruler.SetLog(true); - mfreqRuler->ruler.SetRange(mLoFreq, mNyquist); - mfreqRuler->ruler.SetFormat(Ruler::IntFormat); - mfreqRuler->ruler.SetUnits(wxT("")); - mfreqRuler->ruler.SetFlip(true); - mfreqRuler->ruler.SetLabelEdges(true); - int h; - mfreqRuler->ruler.GetMaxSize(NULL, &h); - mfreqRuler->SetMinSize(wxSize(-1, h)); + mfreqRuler = safenew RulerPanel( + parent, wxID_ANY, wxHORIZONTAL, + wxSize{ 100, 100 }, // Ruler can't handle small sizes + RulerPanel::Range{ mLoFreq, mNyquist }, + Ruler::IntFormat, + wxT(""), + RulerPanel::Options{} + .Log(true) + .Flip(true) + .LabelEdges(true) + ); S.Prop(1); S.AddWindow(mfreqRuler, wxEXPAND | wxALIGN_LEFT | wxRIGHT); @@ -1012,8 +1012,10 @@ BEGIN_EVENT_TABLE(EffectScienFilterPanel, wxPanelWrapper) EVT_SIZE(EffectScienFilterPanel::OnSize) END_EVENT_TABLE() -EffectScienFilterPanel::EffectScienFilterPanel(EffectScienFilter *effect, wxWindow *parent) -: wxPanelWrapper(parent, wxID_ANY, wxDefaultPosition, wxSize(400, 200)) +EffectScienFilterPanel::EffectScienFilterPanel( + wxWindow *parent, wxWindowID winid, + EffectScienFilter *effect, double lo, double hi) +: wxPanelWrapper(parent, winid, wxDefaultPosition, wxSize(400, 200)) { mEffect = effect; mParent = parent; @@ -1025,6 +1027,8 @@ EffectScienFilterPanel::EffectScienFilterPanel(EffectScienFilter *effect, wxWind mHiFreq = 0.0; mDbMin = 0.0; mDbMax = 0.0; + + SetFreqRange(lo, hi); } EffectScienFilterPanel::~EffectScienFilterPanel() diff --git a/src/effects/ScienFilter.h b/src/effects/ScienFilter.h index 1e8a89cac..7cbdc9b4b 100644 --- a/src/effects/ScienFilter.h +++ b/src/effects/ScienFilter.h @@ -139,7 +139,9 @@ private: class EffectScienFilterPanel final : public wxPanelWrapper { public: - EffectScienFilterPanel(EffectScienFilter *effect, wxWindow *parent); + EffectScienFilterPanel( + wxWindow *parent, wxWindowID winid, + EffectScienFilter *effect, double lo, double hi); virtual ~EffectScienFilterPanel(); // We don't need or want to accept focus. diff --git a/src/effects/Silence.cpp b/src/effects/Silence.cpp index 440d0e83c..831aef166 100644 --- a/src/effects/Silence.cpp +++ b/src/effects/Silence.cpp @@ -65,17 +65,14 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S) { S.AddPrompt(_("Duration:")); mDurationT = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - wxID_ANY, + NumericTextCtrl(S.GetParent(), wxID_ANY, + NumericConverter::TIME, GetDurationFormat(), GetDuration(), - mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + mProjectRate, + NumericTextCtrl::Options{} + .AutoPos(true)); mDurationT->SetName(_("Duration")); - mDurationT->EnableMenu(); S.AddWindow(mDurationT, wxALIGN_CENTER | wxALL); } S.EndHorizontalLay(); diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index 9ce54daf6..3caed1796 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -406,17 +406,14 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("Duration:")); mToneDurationT = safenew - NumericTextCtrl(NumericConverter::TIME, - S.GetParent(), - wxID_ANY, + NumericTextCtrl(S.GetParent(), wxID_ANY, + NumericConverter::TIME, GetDurationFormat(), GetDuration(), mProjectRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl::Options{} + .AutoPos(true)); mToneDurationT->SetName(_("Duration")); - mToneDurationT->EnableMenu(); S.AddWindow(mToneDurationT, wxALIGN_LEFT | wxALL); } S.EndMultiColumn(); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index ec164aa86..101b24832 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2836,17 +2836,14 @@ void VSTEffect::BuildPlain() wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - scroller, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl(scroller, ID_Duration, + NumericConverter::TIME, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + NumericTextCtrl::Options{} + .AutoPos(true)); mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 7ef28c11a..b1f3ae2fa 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1210,17 +1210,14 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) item = safenew wxStaticText(w, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - w, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl(w, ID_Duration, + NumericConverter::TIME, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + NumericTextCtrl::Options{} + .AutoPos(true)); mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index fa4da0236..7306939c3 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -1566,17 +1566,14 @@ bool LV2Effect::BuildPlain() wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); mDuration = safenew - NumericTextCtrl(NumericConverter::TIME, - w, - ID_Duration, - mHost->GetDurationFormat(), - mHost->GetDuration(), - mSampleRate, - wxDefaultPosition, - wxDefaultSize, - true); + NumericTextCtrl(w, ID_Duration, + NumericConverter::TIME, + mHost->GetDurationFormat(), + mHost->GetDuration(), + mSampleRate, + NumericTextCtrl::Options{} + .AutoPos(true)); mDuration->SetName(_("Duration")); - mDuration->EnableMenu(); sizer->Add(mDuration, 0, wxALIGN_CENTER | wxALL, 5); groupSizer->Add(sizer.release(), 0, wxALIGN_CENTER | wxALL, 5); diff --git a/src/export/Export.cpp b/src/export/Export.cpp index b1fecec08..56157ce54 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -1019,8 +1019,9 @@ BEGIN_EVENT_TABLE(ExportMixerPanel, wxPanelWrapper) EVT_MOUSE_EVENTS(ExportMixerPanel::OnMouseEvent) END_EVENT_TABLE() -ExportMixerPanel::ExportMixerPanel( MixerSpec *mixerSpec, - wxArrayString trackNames,wxWindow *parent, wxWindowID id, +ExportMixerPanel::ExportMixerPanel( wxWindow *parent, wxWindowID id, + MixerSpec *mixerSpec, + wxArrayString trackNames, const wxPoint& pos, const wxSize& size): wxPanelWrapper(parent, id, pos, size) , mMixerSpec{mixerSpec} @@ -1311,8 +1312,9 @@ ExportMixerDialog::ExportMixerDialog( const TrackList *tracks, bool selectedOnly auto uVertSizer = std::make_unique(wxVERTICAL); vertSizer = uVertSizer.get(); - wxWindow *mixerPanel = safenew ExportMixerPanel(mMixerSpec.get(), mTrackNames, this, - ID_MIXERPANEL, wxDefaultPosition, wxSize(400, -1)); + wxWindow *mixerPanel = safenew ExportMixerPanel(this, ID_MIXERPANEL, + mMixerSpec.get(), mTrackNames, + wxDefaultPosition, wxSize(400, -1)); mixerPanel->SetName(_("Mixer Panel")); vertSizer->Add(mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5); diff --git a/src/export/Export.h b/src/export/Export.h index 653c6be33..a55500180 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -233,8 +233,9 @@ private: class ExportMixerPanel final : public wxPanelWrapper { public: - ExportMixerPanel( MixerSpec *mixerSpec, wxArrayString trackNames, - wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, + ExportMixerPanel( wxWindow *parent, wxWindowID id, + MixerSpec *mixerSpec, wxArrayString trackNames, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); virtual ~ExportMixerPanel(); diff --git a/src/prefs/BatchPrefs.cpp b/src/prefs/BatchPrefs.cpp index 839afcafe..96eb74f12 100644 --- a/src/prefs/BatchPrefs.cpp +++ b/src/prefs/BatchPrefs.cpp @@ -32,8 +32,8 @@ BEGIN_EVENT_TABLE(BatchPrefs, PrefsPanel) END_EVENT_TABLE() /// Constructor -BatchPrefs::BatchPrefs(wxWindow * parent): - PrefsPanel(parent, _("Batch")) +BatchPrefs::BatchPrefs(wxWindow * parent, wxWindowID winid): + PrefsPanel(parent, winid, _("Batch")) { Populate(); } @@ -83,8 +83,8 @@ BatchPrefs::~BatchPrefs() { } -PrefsPanel *BatchPrefsFactory::Create(wxWindow *parent) +PrefsPanel *BatchPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew BatchPrefs(parent); + return safenew BatchPrefs(parent, winid); } diff --git a/src/prefs/BatchPrefs.h b/src/prefs/BatchPrefs.h index f152e471c..e2c276884 100644 --- a/src/prefs/BatchPrefs.h +++ b/src/prefs/BatchPrefs.h @@ -23,7 +23,7 @@ class ShuttleGui; class BatchPrefs final : public PrefsPanel { public: - BatchPrefs(wxWindow * parent); + BatchPrefs(wxWindow * parent, wxWindowID winid); ~BatchPrefs(); bool Commit() override; @@ -37,6 +37,6 @@ private: class BatchPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/DevicePrefs.cpp b/src/prefs/DevicePrefs.cpp index af1b230c6..b84695a98 100644 --- a/src/prefs/DevicePrefs.cpp +++ b/src/prefs/DevicePrefs.cpp @@ -52,8 +52,8 @@ BEGIN_EVENT_TABLE(DevicePrefs, PrefsPanel) EVT_CHOICE(RecordID, DevicePrefs::OnDevice) END_EVENT_TABLE() -DevicePrefs::DevicePrefs(wxWindow * parent) -: PrefsPanel(parent, _("Devices")) +DevicePrefs::DevicePrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Devices")) { Populate(); } @@ -414,8 +414,8 @@ wxString DevicePrefs::HelpPageName() return "Devices_Preferences"; } -PrefsPanel *DevicePrefsFactory::Create(wxWindow *parent) +PrefsPanel *DevicePrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew DevicePrefs(parent); + return safenew DevicePrefs(parent, winid); } diff --git a/src/prefs/DevicePrefs.h b/src/prefs/DevicePrefs.h index 7ed6a7ae4..cbabe4bf2 100644 --- a/src/prefs/DevicePrefs.h +++ b/src/prefs/DevicePrefs.h @@ -26,7 +26,7 @@ class ShuttleGui; class DevicePrefs final : public PrefsPanel { public: - DevicePrefs(wxWindow * parent); + DevicePrefs(wxWindow * parent, wxWindowID winid); virtual ~DevicePrefs(); bool Commit() override; wxString HelpPageName() override; @@ -58,7 +58,7 @@ class DevicePrefs final : public PrefsPanel class DevicePrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index 0f06204ee..e237f2672 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -48,9 +48,9 @@ BEGIN_EVENT_TABLE(DirectoriesPrefs, PrefsPanel) EVT_BUTTON(ChooseButtonID, DirectoriesPrefs::OnChooseTempDir) END_EVENT_TABLE() -DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent) +DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: Directories, also called folders, in computer file systems */ -: PrefsPanel(parent, _("Directories")), +: PrefsPanel(parent, winid, _("Directories")), mFreeSpace(NULL), mTempDir(NULL) { @@ -273,8 +273,8 @@ wxString DirectoriesPrefs::HelpPageName() return "Directories_Preferences"; } -PrefsPanel *DirectoriesPrefsFactory::Create(wxWindow *parent) +PrefsPanel *DirectoriesPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew DirectoriesPrefs(parent); + return safenew DirectoriesPrefs(parent, winid); } diff --git a/src/prefs/DirectoriesPrefs.h b/src/prefs/DirectoriesPrefs.h index 8342bacf1..5050c2044 100644 --- a/src/prefs/DirectoriesPrefs.h +++ b/src/prefs/DirectoriesPrefs.h @@ -21,7 +21,7 @@ class ShuttleGui; class DirectoriesPrefs final : public PrefsPanel { public: - DirectoriesPrefs(wxWindow * parent); + DirectoriesPrefs(wxWindow * parent, wxWindowID winid); ~DirectoriesPrefs(); bool Commit() override; bool Validate() override; @@ -42,6 +42,6 @@ class DirectoriesPrefs final : public PrefsPanel class DirectoriesPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index 7a208baf8..d8ff7ff7f 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -32,8 +32,8 @@ #include "../Experimental.h" #include "../Internat.h" -EffectsPrefs::EffectsPrefs(wxWindow * parent) -: PrefsPanel(parent, _("Effects")) +EffectsPrefs::EffectsPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Effects")) { Populate(); } @@ -176,8 +176,8 @@ wxString EffectsPrefs::HelpPageName() return "Effects_Preferences"; } -PrefsPanel *EffectsPrefsFactory::Create(wxWindow *parent) +PrefsPanel *EffectsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew EffectsPrefs(parent); + return safenew EffectsPrefs(parent, winid); } diff --git a/src/prefs/EffectsPrefs.h b/src/prefs/EffectsPrefs.h index ab6a25b88..05cd9a3df 100644 --- a/src/prefs/EffectsPrefs.h +++ b/src/prefs/EffectsPrefs.h @@ -25,7 +25,7 @@ class ShuttleGui; class EffectsPrefs final : public PrefsPanel { public: - EffectsPrefs(wxWindow * parent); + EffectsPrefs(wxWindow * parent, wxWindowID winid); ~EffectsPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -38,6 +38,6 @@ class EffectsPrefs final : public PrefsPanel class EffectsPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/ExtImportPrefs.cpp b/src/prefs/ExtImportPrefs.cpp index 324c1e2cc..a90799879 100644 --- a/src/prefs/ExtImportPrefs.cpp +++ b/src/prefs/ExtImportPrefs.cpp @@ -56,10 +56,10 @@ BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel) EVT_BUTTON(EIPMoveFilterDown,ExtImportPrefs::OnFilterMoveDown) END_EVENT_TABLE() -ExtImportPrefs::ExtImportPrefs(wxWindow * parent) +ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: Title of dialog governing "Extended", or "advanced," * audio file import options */ -: PrefsPanel(parent, _("Extended Import")), RuleTable(NULL), +: PrefsPanel(parent, winid, _("Extended Import")), RuleTable(NULL), PluginList(NULL), mCreateTable (false), mDragFocus (NULL), mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1) { @@ -811,8 +811,8 @@ void ExtImportPrefsDropTarget::OnLeave() { } -PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent) +PrefsPanel *ExtImportPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew ExtImportPrefs(parent); + return safenew ExtImportPrefs(parent, winid); } diff --git a/src/prefs/ExtImportPrefs.h b/src/prefs/ExtImportPrefs.h index 6b49e01a3..1df4fff08 100644 --- a/src/prefs/ExtImportPrefs.h +++ b/src/prefs/ExtImportPrefs.h @@ -46,7 +46,7 @@ private: class ExtImportPrefs final : public PrefsPanel { public: - ExtImportPrefs(wxWindow * parent); + ExtImportPrefs(wxWindow * parent, wxWindowID winid); ~ExtImportPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -111,6 +111,6 @@ class ExtImportPrefs final : public PrefsPanel class ExtImportPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index 891562ffa..3b56f2694 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -36,9 +36,9 @@ #include "../AColor.h" #include "../Internat.h" -GUIPrefs::GUIPrefs(wxWindow * parent) +GUIPrefs::GUIPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: refers to Audacity's user interface settings */ -: PrefsPanel(parent, _("Interface")) +: PrefsPanel(parent, winid, _("Interface")) { Populate(); } @@ -233,8 +233,8 @@ wxString GUIPrefs::HelpPageName() return "Interface_Preferences"; } -PrefsPanel *GUIPrefsFactory::Create(wxWindow *parent) +PrefsPanel *GUIPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew GUIPrefs(parent); + return safenew GUIPrefs(parent, winid); } diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index f7424c8ad..93839f347 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -25,7 +25,7 @@ class ShuttleGui; class GUIPrefs final : public PrefsPanel { public: - GUIPrefs(wxWindow * parent); + GUIPrefs(wxWindow * parent, wxWindowID winid); ~GUIPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -52,6 +52,6 @@ class GUIPrefs final : public PrefsPanel class GUIPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/ImportExportPrefs.cpp b/src/prefs/ImportExportPrefs.cpp index 8a7d7d336..65f5444fd 100644 --- a/src/prefs/ImportExportPrefs.cpp +++ b/src/prefs/ImportExportPrefs.cpp @@ -25,8 +25,8 @@ #include "ImportExportPrefs.h" #include "../Internat.h" -ImportExportPrefs::ImportExportPrefs(wxWindow * parent) -: PrefsPanel(parent, _("Import / Export")) +ImportExportPrefs::ImportExportPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Import / Export")) { Populate(); } @@ -118,8 +118,8 @@ wxString ImportExportPrefs::HelpPageName() return "Import_-_Export_Preferences"; } -PrefsPanel *ImportExportPrefsFactory::Create(wxWindow *parent) +PrefsPanel *ImportExportPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew ImportExportPrefs(parent); + return safenew ImportExportPrefs(parent, winid); } diff --git a/src/prefs/ImportExportPrefs.h b/src/prefs/ImportExportPrefs.h index 7e7079301..d6fbccee7 100644 --- a/src/prefs/ImportExportPrefs.h +++ b/src/prefs/ImportExportPrefs.h @@ -24,7 +24,7 @@ class ShuttleGui; class ImportExportPrefs final : public PrefsPanel { public: - ImportExportPrefs(wxWindow * parent); + ImportExportPrefs(wxWindow * parent, wxWindowID winid); ~ImportExportPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -37,6 +37,6 @@ class ImportExportPrefs final : public PrefsPanel class ImportExportPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index e8826ccf4..33ef631be 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -72,9 +72,10 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel) EVT_TIMER(FilterTimerID, KeyConfigPrefs::OnFilterTimer) END_EVENT_TABLE() -KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, const wxString &name) +KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid, + const wxString &name) /* i18n-hint: as in computer keyboard (not musical!) */ -: PrefsPanel(parent, _("Keyboard")), +: PrefsPanel(parent, winid, _("Keyboard")), mView(NULL), mKey(NULL), mFilter(NULL), @@ -749,9 +750,9 @@ wxString KeyConfigPrefs::HelpPageName() return "Keyboard_Preferences"; } -PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent) +PrefsPanel *KeyConfigPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - auto result = safenew KeyConfigPrefs{ parent, mName }; + auto result = safenew KeyConfigPrefs{ parent, winid, mName }; return result; } diff --git a/src/prefs/KeyConfigPrefs.h b/src/prefs/KeyConfigPrefs.h index fe49e9e3c..19f66233e 100644 --- a/src/prefs/KeyConfigPrefs.h +++ b/src/prefs/KeyConfigPrefs.h @@ -35,7 +35,7 @@ class wxStaticText; class KeyConfigPrefs final : public PrefsPanel { public: - KeyConfigPrefs(wxWindow * parent, const wxString &name); + KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const wxString &name); ~KeyConfigPrefs(); bool Commit() override; void Cancel() override; @@ -99,8 +99,8 @@ class KeyConfigPrefsFactory final : public PrefsPanelFactory public: KeyConfigPrefsFactory(const wxString &name = wxString{}) : mName{ name } {} - PrefsPanel *Create(wxWindow *parent) override; - + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; + private: wxString mName; }; diff --git a/src/prefs/LibraryPrefs.cpp b/src/prefs/LibraryPrefs.cpp index 3b61da3b1..551162437 100644 --- a/src/prefs/LibraryPrefs.cpp +++ b/src/prefs/LibraryPrefs.cpp @@ -46,9 +46,9 @@ BEGIN_EVENT_TABLE(LibraryPrefs, PrefsPanel) EVT_BUTTON(ID_FFMPEG_DOWN_BUTTON, LibraryPrefs::OnFFmpegDownButton) END_EVENT_TABLE() -LibraryPrefs::LibraryPrefs(wxWindow * parent) +LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid) /* i18-hint: refers to optional plug-in software libraries */ -: PrefsPanel(parent, _("Libraries")) +: PrefsPanel(parent, winid, _("Libraries")) { Populate(); } @@ -250,8 +250,8 @@ wxString LibraryPrefs::HelpPageName() return "Libraries_Preferences"; } -PrefsPanel *LibraryPrefsFactory::Create(wxWindow *parent) +PrefsPanel *LibraryPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew LibraryPrefs(parent); + return safenew LibraryPrefs(parent, winid); } diff --git a/src/prefs/LibraryPrefs.h b/src/prefs/LibraryPrefs.h index 2e789445b..ed903965d 100644 --- a/src/prefs/LibraryPrefs.h +++ b/src/prefs/LibraryPrefs.h @@ -25,7 +25,7 @@ class ShuttleGui; class LibraryPrefs final : public PrefsPanel { public: - LibraryPrefs(wxWindow * parent); + LibraryPrefs(wxWindow * parent, wxWindowID winid); ~LibraryPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -50,6 +50,6 @@ class LibraryPrefs final : public PrefsPanel class LibraryPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index 891b61e4b..9f337613c 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -55,9 +55,9 @@ BEGIN_EVENT_TABLE(MidiIOPrefs, PrefsPanel) // EVT_CHOICE(RecordID, MidiIOPrefs::OnDevice) END_EVENT_TABLE() -MidiIOPrefs::MidiIOPrefs(wxWindow * parent) +MidiIOPrefs::MidiIOPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: untranslatable acronym for "Musical Instrument Device Interface" */ -: PrefsPanel(parent, _("MIDI Devices")) +: PrefsPanel(parent, winid, _("MIDI Devices")) { Populate(); } @@ -296,10 +296,10 @@ wxString MidiIOPrefs::HelpPageName() return "MIDI_Devices_Preferences"; } -PrefsPanel *MidiIOPrefsFactory::Create(wxWindow *parent) +PrefsPanel *MidiIOPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew MidiIOPrefs(parent); + return safenew MidiIOPrefs(parent, winid); } #endif diff --git a/src/prefs/MidiIOPrefs.h b/src/prefs/MidiIOPrefs.h index 149231bd1..c25e6ed61 100644 --- a/src/prefs/MidiIOPrefs.h +++ b/src/prefs/MidiIOPrefs.h @@ -29,7 +29,7 @@ class ShuttleGui; class MidiIOPrefs final : public PrefsPanel { public: - MidiIOPrefs(wxWindow * parent); + MidiIOPrefs(wxWindow * parent, wxWindowID winid); virtual ~MidiIOPrefs(); bool Commit() override; bool Validate() override; @@ -66,7 +66,7 @@ class MidiIOPrefs final : public PrefsPanel class MidiIOPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index a9b908d0f..59f502609 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -29,8 +29,8 @@ with names like mnod-script-pipe that add NEW features. //////////////////////////////////////////////////////////////////////////////// /* i18n-hint: Modules are optional extensions to Audacity that add NEW features.*/ -ModulePrefs::ModulePrefs(wxWindow * parent) -: PrefsPanel(parent, _("Modules")) +ModulePrefs::ModulePrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Modules")) { Populate(); } @@ -168,8 +168,8 @@ wxString ModulePrefs::HelpPageName() return "Modules_Preferences"; } -PrefsPanel *ModulePrefsFactory::Create(wxWindow *parent) +PrefsPanel *ModulePrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew ModulePrefs(parent); + return safenew ModulePrefs(parent, winid); } diff --git a/src/prefs/ModulePrefs.h b/src/prefs/ModulePrefs.h index d72da62fe..65455b681 100644 --- a/src/prefs/ModulePrefs.h +++ b/src/prefs/ModulePrefs.h @@ -34,7 +34,7 @@ enum { class ModulePrefs final : public PrefsPanel { public: - ModulePrefs(wxWindow * parent); + ModulePrefs(wxWindow * parent, wxWindowID winid); ~ModulePrefs(); bool Commit() override; wxString HelpPageName() override; @@ -54,6 +54,6 @@ class ModulePrefs final : public PrefsPanel class ModulePrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/MousePrefs.cpp b/src/prefs/MousePrefs.cpp index 725c3206f..a4821304b 100644 --- a/src/prefs/MousePrefs.cpp +++ b/src/prefs/MousePrefs.cpp @@ -61,8 +61,8 @@ enum #endif /// Constructor -MousePrefs::MousePrefs(wxWindow * parent) -: PrefsPanel(parent, _("Mouse")) +MousePrefs::MousePrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Mouse")) { Populate(); } @@ -203,8 +203,8 @@ wxString MousePrefs::HelpPageName() return "Mouse_Preferences"; } -PrefsPanel *MousePrefsFactory::Create(wxWindow *parent) +PrefsPanel *MousePrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew MousePrefs(parent); + return safenew MousePrefs(parent, winid); } diff --git a/src/prefs/MousePrefs.h b/src/prefs/MousePrefs.h index 00088b20d..2194965c6 100644 --- a/src/prefs/MousePrefs.h +++ b/src/prefs/MousePrefs.h @@ -22,7 +22,7 @@ class ShuttleGui; class MousePrefs final : public PrefsPanel { public: - MousePrefs(wxWindow * parent); + MousePrefs(wxWindow * parent, wxWindowID winid); ~MousePrefs(); bool Commit() override; wxString HelpPageName() override; @@ -42,6 +42,6 @@ class MousePrefs final : public PrefsPanel class MousePrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/PlaybackPrefs.cpp b/src/prefs/PlaybackPrefs.cpp index 1b215d230..a336c4ecc 100644 --- a/src/prefs/PlaybackPrefs.cpp +++ b/src/prefs/PlaybackPrefs.cpp @@ -28,8 +28,8 @@ #include "../Prefs.h" #include "../Internat.h" -PlaybackPrefs::PlaybackPrefs(wxWindow * parent) -: PrefsPanel(parent, _("Playback")) +PlaybackPrefs::PlaybackPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Playback")) { Populate(); } @@ -132,9 +132,9 @@ wxString PlaybackPrefs::HelpPageName() return "Playback_Preferences"; } -PrefsPanel *PlaybackPrefsFactory::Create(wxWindow *parent) +PrefsPanel *PlaybackPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew PlaybackPrefs(parent); + return safenew PlaybackPrefs(parent, winid); } diff --git a/src/prefs/PlaybackPrefs.h b/src/prefs/PlaybackPrefs.h index e90596d31..eda0c14c2 100644 --- a/src/prefs/PlaybackPrefs.h +++ b/src/prefs/PlaybackPrefs.h @@ -23,7 +23,7 @@ class ShuttleGui; class PlaybackPrefs final : public PrefsPanel { public: - PlaybackPrefs(wxWindow * parent); + PlaybackPrefs(wxWindow * parent, wxWindowID winid); virtual ~PlaybackPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -36,7 +36,7 @@ class PlaybackPrefs final : public PrefsPanel class PlaybackPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index d7c1b9267..d550771e3 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -261,7 +261,7 @@ PrefsDialog::PrefsDialog { const PrefsNode &node = *it; PrefsPanelFactory &factory = *node.pFactory; - wxWindow *const w = factory.Create(mCategories); + wxWindow *const w = factory(mCategories, wxID_ANY); if (stack.empty()) // Parameters are: AddPage(page, name, IsSelected, imageId). mCategories->AddPage(w, w->GetName(), false, 0); @@ -289,7 +289,7 @@ PrefsDialog::PrefsDialog // Unique page, don't show the factory const PrefsNode &node = factories[0]; PrefsPanelFactory &factory = *node.pFactory; - mUniquePage = factory.Create(this); + mUniquePage = factory(this, wxID_ANY); wxWindow * uniquePageWindow = S.Prop(1).AddWindow(mUniquePage, wxEXPAND); // We're not in the wxTreebook, so add the accelerator here wxAcceleratorEntry entries[1]; diff --git a/src/prefs/PrefsPanel.h b/src/prefs/PrefsPanel.h index d5680defb..bd69fedc8 100644 --- a/src/prefs/PrefsPanel.h +++ b/src/prefs/PrefsPanel.h @@ -43,8 +43,8 @@ ThemePrefs. class PrefsPanel /* not final */ : public wxPanelWrapper { public: - PrefsPanel(wxWindow * parent, const wxString &title) - : wxPanelWrapper(parent, wxID_ANY) + PrefsPanel(wxWindow * parent, wxWindowID winid, const wxString &title) + : wxPanelWrapper(parent, winid) { SetLabel(title); // Provide visual label SetName(title); // Provide audible label @@ -71,7 +71,7 @@ class PrefsPanelFactory /* not final */ { public: // Precondition: parent != NULL - virtual PrefsPanel *Create(wxWindow *parent) = 0; + virtual PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) = 0; }; #endif diff --git a/src/prefs/ProjectsPrefs.cpp b/src/prefs/ProjectsPrefs.cpp index e38f9c7e8..f2ba4dea0 100644 --- a/src/prefs/ProjectsPrefs.cpp +++ b/src/prefs/ProjectsPrefs.cpp @@ -29,8 +29,8 @@ handling. //////////////////////////////////////////////////////////////////////////////// -ProjectsPrefs::ProjectsPrefs(wxWindow * parent) -: PrefsPanel(parent, +ProjectsPrefs::ProjectsPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, /* i18n-hint: (noun) i.e Audacity projects. */ _("Projects")) { @@ -89,8 +89,8 @@ wxString ProjectsPrefs::HelpPageName() return "Projects_Preferences"; } -PrefsPanel *ProjectsPrefsFactory::Create(wxWindow *parent) +PrefsPanel *ProjectsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew ProjectsPrefs(parent); + return safenew ProjectsPrefs(parent, winid); } diff --git a/src/prefs/ProjectsPrefs.h b/src/prefs/ProjectsPrefs.h index 3a6608f8f..9780d64cf 100644 --- a/src/prefs/ProjectsPrefs.h +++ b/src/prefs/ProjectsPrefs.h @@ -24,7 +24,7 @@ class ShuttleGui; class ProjectsPrefs final : public PrefsPanel { public: - ProjectsPrefs(wxWindow * parent); + ProjectsPrefs(wxWindow * parent, wxWindowID winid); ~ProjectsPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -37,6 +37,6 @@ class ProjectsPrefs final : public PrefsPanel class ProjectsPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp index 08d28ab4f..9331475c7 100644 --- a/src/prefs/QualityPrefs.cpp +++ b/src/prefs/QualityPrefs.cpp @@ -34,9 +34,9 @@ BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel) EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice) END_EVENT_TABLE() -QualityPrefs::QualityPrefs(wxWindow * parent) +QualityPrefs::QualityPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: meaning accuracy in reproduction of sounds */ -: PrefsPanel(parent, _("Quality")) +: PrefsPanel(parent, winid, _("Quality")) { Populate(); } @@ -240,8 +240,8 @@ wxString QualityPrefs::HelpPageName() return "Quality_Preferences"; } -PrefsPanel *QualityPrefsFactory::Create(wxWindow *parent) +PrefsPanel *QualityPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew QualityPrefs(parent); + return safenew QualityPrefs(parent, winid); } diff --git a/src/prefs/QualityPrefs.h b/src/prefs/QualityPrefs.h index 27e2d0da5..9fcf445c4 100644 --- a/src/prefs/QualityPrefs.h +++ b/src/prefs/QualityPrefs.h @@ -26,7 +26,7 @@ class ShuttleGui; class QualityPrefs final : public PrefsPanel { public: - QualityPrefs(wxWindow * parent); + QualityPrefs(wxWindow * parent, wxWindowID winid); virtual ~QualityPrefs(); bool Commit() override; @@ -57,6 +57,6 @@ class QualityPrefs final : public PrefsPanel class QualityPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/RecordingPrefs.cpp b/src/prefs/RecordingPrefs.cpp index 9ae602fc2..7bb6161ad 100644 --- a/src/prefs/RecordingPrefs.cpp +++ b/src/prefs/RecordingPrefs.cpp @@ -45,8 +45,8 @@ BEGIN_EVENT_TABLE(RecordingPrefs, PrefsPanel) EVT_CHECKBOX(UseCustomTrackNameID, RecordingPrefs::OnToggleCustomName) END_EVENT_TABLE() -RecordingPrefs::RecordingPrefs(wxWindow * parent) -: PrefsPanel(parent, _("Recording")) +RecordingPrefs::RecordingPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Recording")) { gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &mUseCustomTrackName, false); mOldNameChoice = mUseCustomTrackName; @@ -268,8 +268,8 @@ wxString RecordingPrefs::HelpPageName() return "Recording_Preferences"; } -PrefsPanel *RecordingPrefsFactory::Create(wxWindow *parent) +PrefsPanel *RecordingPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew RecordingPrefs(parent); + return safenew RecordingPrefs(parent, winid); } diff --git a/src/prefs/RecordingPrefs.h b/src/prefs/RecordingPrefs.h index f395d5f60..a64d4829a 100644 --- a/src/prefs/RecordingPrefs.h +++ b/src/prefs/RecordingPrefs.h @@ -24,7 +24,7 @@ class ShuttleGui; class RecordingPrefs final : public PrefsPanel { public: - RecordingPrefs(wxWindow * parent); + RecordingPrefs(wxWindow * parent, wxWindowID winid); virtual ~RecordingPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -44,6 +44,6 @@ class RecordingPrefs final : public PrefsPanel class RecordingPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/SpectrumPrefs.cpp b/src/prefs/SpectrumPrefs.cpp index 47078ea78..b9a04fcf2 100644 --- a/src/prefs/SpectrumPrefs.cpp +++ b/src/prefs/SpectrumPrefs.cpp @@ -33,8 +33,8 @@ #include "../Experimental.h" #include "../widgets/ErrorDialog.h" -SpectrumPrefs::SpectrumPrefs(wxWindow * parent, WaveTrack *wt) -: PrefsPanel(parent, wt ? _("Spectrogram Settings") : _("Spectrograms")) +SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt) +: PrefsPanel(parent, winid, wt ? _("Spectrogram Settings") : _("Spectrograms")) , mWt(wt) , mPopulating(false) { @@ -585,8 +585,8 @@ SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt) { } -PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent) +PrefsPanel *SpectrumPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew SpectrumPrefs(parent, mWt); + return safenew SpectrumPrefs(parent, winid, mWt); } diff --git a/src/prefs/SpectrumPrefs.h b/src/prefs/SpectrumPrefs.h index ac4c7caca..b225d70b2 100644 --- a/src/prefs/SpectrumPrefs.h +++ b/src/prefs/SpectrumPrefs.h @@ -42,7 +42,7 @@ class WaveTrack; class SpectrumPrefs final : public PrefsPanel { public: - SpectrumPrefs(wxWindow * parent, WaveTrack *wt); + SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt); virtual ~SpectrumPrefs(); void Preview() override; bool Commit() override; @@ -108,7 +108,7 @@ class SpectrumPrefsFactory final : public PrefsPanelFactory { public: explicit SpectrumPrefsFactory(WaveTrack *wt = 0); - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; private: WaveTrack *const mWt; diff --git a/src/prefs/ThemePrefs.cpp b/src/prefs/ThemePrefs.cpp index 48ff4d823..7ad59d7f1 100644 --- a/src/prefs/ThemePrefs.cpp +++ b/src/prefs/ThemePrefs.cpp @@ -56,12 +56,12 @@ BEGIN_EVENT_TABLE(ThemePrefs, PrefsPanel) EVT_BUTTON(idSaveThemeAsCode, ThemePrefs::OnSaveThemeAsCode) END_EVENT_TABLE() -ThemePrefs::ThemePrefs(wxWindow * parent) +ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: A theme is a consistent visual style across an application's graphical user interface, including choices of colors, and similarity of images such as those on button controls. Audacity can load and save alternative themes. */ -: PrefsPanel(parent, _("Theme")) +: PrefsPanel(parent, winid, _("Theme")) { Populate(); } @@ -201,8 +201,8 @@ bool ThemePrefs::Commit() return true; } -PrefsPanel *ThemePrefsFactory::Create(wxWindow *parent) +PrefsPanel *ThemePrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew ThemePrefs(parent); + return safenew ThemePrefs(parent, winid); } diff --git a/src/prefs/ThemePrefs.h b/src/prefs/ThemePrefs.h index f91152657..cefec0892 100644 --- a/src/prefs/ThemePrefs.h +++ b/src/prefs/ThemePrefs.h @@ -24,7 +24,7 @@ class ShuttleGui; class ThemePrefs final : public PrefsPanel { public: - ThemePrefs(wxWindow * parent); + ThemePrefs(wxWindow * parent, wxWindowID winid); ~ThemePrefs(void); bool Commit() override; @@ -44,6 +44,6 @@ class ThemePrefs final : public PrefsPanel class ThemePrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/TracksBehaviorsPrefs.cpp b/src/prefs/TracksBehaviorsPrefs.cpp index 62e9aff83..edc736ba9 100644 --- a/src/prefs/TracksBehaviorsPrefs.cpp +++ b/src/prefs/TracksBehaviorsPrefs.cpp @@ -22,9 +22,9 @@ #include "../Experimental.h" #include "../Internat.h" -TracksBehaviorsPrefs::TracksBehaviorsPrefs(wxWindow * parent) +TracksBehaviorsPrefs::TracksBehaviorsPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: two nouns */ -: PrefsPanel(parent, _("Tracks Behaviors")) +: PrefsPanel(parent, winid, _("Tracks Behaviors")) { Populate(); } @@ -125,8 +125,8 @@ TracksBehaviorsPrefsFactory::TracksBehaviorsPrefsFactory() { } -PrefsPanel *TracksBehaviorsPrefsFactory::Create(wxWindow *parent) +PrefsPanel *TracksBehaviorsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew TracksBehaviorsPrefs(parent); + return safenew TracksBehaviorsPrefs(parent, winid); } diff --git a/src/prefs/TracksBehaviorsPrefs.h b/src/prefs/TracksBehaviorsPrefs.h index 68b9b0ee1..85394c11a 100644 --- a/src/prefs/TracksBehaviorsPrefs.h +++ b/src/prefs/TracksBehaviorsPrefs.h @@ -21,7 +21,7 @@ class ShuttleGui; class TracksBehaviorsPrefs final : public PrefsPanel { public: - TracksBehaviorsPrefs(wxWindow * parent); + TracksBehaviorsPrefs(wxWindow * parent, wxWindowID winid); ~TracksBehaviorsPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -41,7 +41,7 @@ class TracksBehaviorsPrefsFactory final : public PrefsPanelFactory { public: explicit TracksBehaviorsPrefsFactory(); - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/TracksPrefs.cpp b/src/prefs/TracksPrefs.cpp index e51ebfc9a..7ea2c1467 100644 --- a/src/prefs/TracksPrefs.cpp +++ b/src/prefs/TracksPrefs.cpp @@ -45,11 +45,11 @@ namespace { } -TracksPrefs::TracksPrefs(wxWindow * parent) +TracksPrefs::TracksPrefs(wxWindow * parent, wxWindowID winid) /* i18n-hint: "Tracks" include audio recordings but also other collections of * data associated with a time line, such as sequences of labels, and musical * notes */ -: PrefsPanel(parent, _("Tracks")) +: PrefsPanel(parent, winid, _("Tracks")) { // Bugs 1043, 1044 // First rewrite legacy preferences @@ -239,8 +239,8 @@ wxString TracksPrefs::HelpPageName() return "Tracks_Preferences"; } -PrefsPanel *TracksPrefsFactory::Create(wxWindow *parent) +PrefsPanel *TracksPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew TracksPrefs(parent); + return safenew TracksPrefs(parent, winid); } diff --git a/src/prefs/TracksPrefs.h b/src/prefs/TracksPrefs.h index 45e7fc60d..76120e1ad 100644 --- a/src/prefs/TracksPrefs.h +++ b/src/prefs/TracksPrefs.h @@ -25,7 +25,7 @@ class ShuttleGui; class TracksPrefs final : public PrefsPanel { public: - TracksPrefs(wxWindow * parent); + TracksPrefs(wxWindow * parent, wxWindowID winid); ~TracksPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -52,6 +52,6 @@ class TracksPrefs final : public PrefsPanel class TracksPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/WarningsPrefs.cpp b/src/prefs/WarningsPrefs.cpp index 92bcb8f87..122e4718c 100644 --- a/src/prefs/WarningsPrefs.cpp +++ b/src/prefs/WarningsPrefs.cpp @@ -28,8 +28,8 @@ //////////////////////////////////////////////////////////////////////////////// -WarningsPrefs::WarningsPrefs(wxWindow * parent) -: PrefsPanel(parent, _("Warnings")) +WarningsPrefs::WarningsPrefs(wxWindow * parent, wxWindowID winid) +: PrefsPanel(parent, winid, _("Warnings")) { Populate(); } @@ -96,8 +96,8 @@ wxString WarningsPrefs::HelpPageName() return "Warnings_Preferences"; } -PrefsPanel *WarningsPrefsFactory::Create(wxWindow *parent) +PrefsPanel *WarningsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew WarningsPrefs(parent); + return safenew WarningsPrefs(parent, winid); } diff --git a/src/prefs/WarningsPrefs.h b/src/prefs/WarningsPrefs.h index 0ea36a8c4..c342eacee 100644 --- a/src/prefs/WarningsPrefs.h +++ b/src/prefs/WarningsPrefs.h @@ -24,7 +24,7 @@ class ShuttleGui; class WarningsPrefs final : public PrefsPanel { public: - WarningsPrefs(wxWindow * parent); + WarningsPrefs(wxWindow * parent, wxWindowID winid); ~WarningsPrefs(); bool Commit() override; wxString HelpPageName() override; @@ -37,6 +37,6 @@ class WarningsPrefs final : public PrefsPanel class WarningsPrefsFactory final : public PrefsPanelFactory { public: - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; }; #endif diff --git a/src/prefs/WaveformPrefs.cpp b/src/prefs/WaveformPrefs.cpp index 8513866c6..862134f4a 100644 --- a/src/prefs/WaveformPrefs.cpp +++ b/src/prefs/WaveformPrefs.cpp @@ -26,9 +26,9 @@ Paul Licameli #include "../ShuttleGui.h" #include "../WaveTrack.h" -WaveformPrefs::WaveformPrefs(wxWindow * parent, WaveTrack *wt) +WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt) /* i18n-hint: A waveform is a visual representation of vibration */ -: PrefsPanel(parent, _("Waveforms")) +: PrefsPanel(parent, winid, _("Waveforms")) , mWt(wt) , mPopulating(false) { @@ -250,8 +250,8 @@ WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt) { } -PrefsPanel *WaveformPrefsFactory::Create(wxWindow *parent) +PrefsPanel *WaveformPrefsFactory::operator () (wxWindow *parent, wxWindowID winid) { wxASSERT(parent); // to justify safenew - return safenew WaveformPrefs(parent, mWt); + return safenew WaveformPrefs(parent, winid, mWt); } diff --git a/src/prefs/WaveformPrefs.h b/src/prefs/WaveformPrefs.h index 3a561c777..ac8de1a91 100644 --- a/src/prefs/WaveformPrefs.h +++ b/src/prefs/WaveformPrefs.h @@ -23,7 +23,7 @@ class wxChoice; class WaveformPrefs final : public PrefsPanel { public: - WaveformPrefs(wxWindow * parent, WaveTrack *wt); + WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt); virtual ~WaveformPrefs(); bool Commit() override; bool ShowsPreviewButton() override; @@ -60,7 +60,7 @@ class WaveformPrefsFactory final : public PrefsPanelFactory { public: explicit WaveformPrefsFactory(WaveTrack *wt = 0); - PrefsPanel *Create(wxWindow *parent) override; + PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override; private: WaveTrack *const mWt; diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 555e6208e..271257b44 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -129,12 +129,13 @@ void ControlToolBar::Create(wxWindow * parent) // This is a convenience function that allows for button creation in // MakeButtons() with fewer arguments -AButton *ControlToolBar::MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, +AButton *ControlToolBar::MakeButton(ControlToolBar *pBar, + teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const wxChar *label) { - AButton *r = ToolBar::MakeButton(this, + AButton *r = ToolBar::MakeButton(pBar, bmpRecoloredUpLarge, bmpRecoloredDownLarge, bmpRecoloredUpHiliteLarge, bmpRecoloredHiliteLarge, eEnabledUp, eEnabledDown, eDisabled, wxWindowID(id), @@ -170,10 +171,10 @@ void ControlToolBar::Populate() SetBackgroundColour( theTheme.Colour( clrMedium ) ); MakeButtonBackgroundsLarge(); - mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled, + mPause = MakeButton(this, bmpPause, bmpPause, bmpPauseDisabled, ID_PAUSE_BUTTON, true, _("Pause")); - mPlay = MakeButton( bmpPlay, bmpPlay, bmpPlayDisabled, + mPlay = MakeButton(this, bmpPlay, bmpPlay, bmpPlayDisabled, ID_PLAY_BUTTON, true, _("Play")); MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled); MakeAlternateImages(*mPlay, 2, @@ -184,16 +185,16 @@ void ControlToolBar::Populate() bmpSeek, bmpSeek, bmpSeekDisabled); mPlay->FollowModifierKeys(); - mStop = MakeButton( bmpStop, bmpStop, bmpStopDisabled , + mStop = MakeButton(this, bmpStop, bmpStop, bmpStopDisabled , ID_STOP_BUTTON, false, _("Stop")); - mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled, + mRewind = MakeButton(this, bmpRewind, bmpRewind, bmpRewindDisabled, ID_REW_BUTTON, false, _("Skip to Start")); - mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled, + mFF = MakeButton(this, bmpFFwd, bmpFFwd, bmpFFwdDisabled, ID_FF_BUTTON, false, _("Skip to End")); - mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled, + mRecord = MakeButton(this, bmpRecord, bmpRecord, bmpRecordDisabled, ID_RECORD_BUTTON, false, _("Record")); bool bPreferNewTrack; diff --git a/src/toolbars/ControlToolBar.h b/src/toolbars/ControlToolBar.h index 0ab7088b4..897871ee1 100644 --- a/src/toolbars/ControlToolBar.h +++ b/src/toolbars/ControlToolBar.h @@ -120,7 +120,9 @@ class ControlToolBar final : public ToolBar { private: - AButton *MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, + static AButton *MakeButton( + ControlToolBar *pBar, + teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const wxChar *label); diff --git a/src/toolbars/EditToolBar.cpp b/src/toolbars/EditToolBar.cpp index 5c7f33c2e..83ae6f59b 100644 --- a/src/toolbars/EditToolBar.cpp +++ b/src/toolbars/EditToolBar.cpp @@ -98,14 +98,15 @@ void EditToolBar::AddSeparator() /// MakeButtons() with fewer arguments /// Very similar to code in ControlToolBar... AButton *EditToolBar::AddButton( + EditToolBar *pBar, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle) { - AButton *&r = mButtons[id]; + AButton *&r = pBar->mButtons[id]; - r = ToolBar::MakeButton(this, + r = ToolBar::MakeButton(pBar, bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall, eEnabledUp, eEnabledDown, eDisabled, wxWindowID(id), @@ -117,7 +118,7 @@ AButton *EditToolBar::AddButton( // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it? // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) ); - Add( r, 0, wxALIGN_CENTER ); + pBar->Add( r, 0, wxALIGN_CENTER ); return r; } @@ -129,28 +130,28 @@ void EditToolBar::Populate() /* Buttons */ // Tooltips slightly more verbose than the menu entries are. - AddButton(bmpCut, bmpCut, bmpCutDisabled, ETBCutID, + AddButton(this, bmpCut, bmpCut, bmpCutDisabled, ETBCutID, _("Cut selection")); - AddButton(bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID, + AddButton(this, bmpCopy, bmpCopy, bmpCopyDisabled, ETBCopyID, _("Copy selection")); - AddButton(bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID, + AddButton(this, bmpPaste, bmpPaste, bmpPasteDisabled, ETBPasteID, _("Paste")); - AddButton(bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID, + AddButton(this, bmpTrim, bmpTrim, bmpTrimDisabled, ETBTrimID, _("Trim audio outside selection")); - AddButton(bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID, + AddButton(this, bmpSilence, bmpSilence, bmpSilenceDisabled, ETBSilenceID, _("Silence audio selection")); AddSeparator(); - AddButton(bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID, + AddButton(this, bmpUndo, bmpUndo, bmpUndoDisabled, ETBUndoID, _("Undo")); - AddButton(bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID, + AddButton(this, bmpRedo, bmpRedo, bmpRedoDisabled, ETBRedoID, _("Redo")); AddSeparator(); #ifdef OPTION_SYNC_LOCK_BUTTON - AddButton(bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID, + AddButton(this, bmpSyncLockTracksUp, bmpSyncLockTracksDown, bmpSyncLockTracksUp, ETBSyncLockID, _("Sync-Lock Tracks"), true); AddSeparator(); @@ -158,17 +159,17 @@ void EditToolBar::Populate() // Tooltips match menu entries. // We previously had longer tooltips which were not more clear. - AddButton(bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID, + AddButton(this, bmpZoomIn, bmpZoomIn, bmpZoomInDisabled, ETBZoomInID, _("Zoom In")); - AddButton(bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID, + AddButton(this, bmpZoomOut, bmpZoomOut, bmpZoomOutDisabled, ETBZoomOutID, _("Zoom Out")); - AddButton(bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID, + AddButton(this, bmpZoomSel, bmpZoomSel, bmpZoomSelDisabled, ETBZoomSelID, _("Zoom to Selection")); - AddButton(bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID, + AddButton(this, bmpZoomFit, bmpZoomFit, bmpZoomFitDisabled, ETBZoomFitID, _("Fit to Width")); #ifdef EXPERIMENTAL_ZOOM_TOGGLE_BUTTON - AddButton(bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID, + AddButton(this, bmpZoomToggle, bmpZoomToggle, bmpZoomToggleDisabled, ETBZoomToggleID, _("Zoom Toggle")); #endif @@ -190,7 +191,7 @@ void EditToolBar::Populate() #if defined(EXPERIMENTAL_EFFECTS_RACK) AddSeparator(); - AddButton(bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID, + AddButton(this, bmpEditEffects, bmpEditEffects, bmpEditEffects, ETBEffectsID, _("Show Effects Rack"), true); #endif diff --git a/src/toolbars/EditToolBar.h b/src/toolbars/EditToolBar.h index 6718bcb27..8eba5a155 100644 --- a/src/toolbars/EditToolBar.h +++ b/src/toolbars/EditToolBar.h @@ -86,7 +86,9 @@ class EditToolBar final : public ToolBar { private: - AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, + static AButton *AddButton( + EditToolBar *pBar, + teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle = false); void AddSeparator(); diff --git a/src/toolbars/MixerToolBar.cpp b/src/toolbars/MixerToolBar.cpp index be425875c..4b377923e 100644 --- a/src/toolbars/MixerToolBar.cpp +++ b/src/toolbars/MixerToolBar.cpp @@ -78,8 +78,8 @@ void MixerToolBar::Populate() wxID_ANY, theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER); mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"), - wxDefaultPosition, wxSize(130, 25)); - mInputSlider->SetScroll(0.1f, 2.0f); + wxDefaultPosition, wxSize(130, 25), + ASlider::Options{}.Line( 0.1f ).Page( 2.0f )); mInputSlider->SetName(_("Slider Recording")); Add(mInputSlider, 0, wxALIGN_CENTER); @@ -88,8 +88,8 @@ void MixerToolBar::Populate() wxID_ANY, theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER); mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"), - wxDefaultPosition, wxSize(130, 25)); - mOutputSlider->SetScroll(0.1f, 2.0f); + wxDefaultPosition, wxSize(130, 25), + ASlider::Options{}.Line( 0.1f ).Page( 2.0f )); mOutputSlider->SetName(_("Slider Playback")); Add(mOutputSlider, 0, wxALIGN_CENTER); diff --git a/src/toolbars/ScrubbingToolBar.cpp b/src/toolbars/ScrubbingToolBar.cpp index 4340e24af..0255ac703 100644 --- a/src/toolbars/ScrubbingToolBar.cpp +++ b/src/toolbars/ScrubbingToolBar.cpp @@ -76,15 +76,16 @@ void ScrubbingToolBar::Create(wxWindow * parent) /// MakeButtons() with fewer arguments /// Very similar to code in ControlToolBar... AButton *ScrubbingToolBar::AddButton -(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, +(ScrubbingToolBar *pBar, + teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, const wxChar *label, bool toggle) { - AButton *&r = mButtons[id]; + AButton *&r = pBar->mButtons[id]; r = ToolBar::MakeButton - (this, + (pBar, bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall, eEnabledUp, eEnabledDown, eDisabled, wxWindowID(id), @@ -96,7 +97,7 @@ AButton *ScrubbingToolBar::AddButton // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it? // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) ); - Add( r, 0, wxALIGN_CENTER ); + pBar->Add( r, 0, wxALIGN_CENTER ); return r; } @@ -107,11 +108,11 @@ void ScrubbingToolBar::Populate() MakeButtonBackgroundsSmall(); /* Buttons */ - AddButton(bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID, + AddButton(this, bmpScrub, bmpScrub, bmpScrubDisabled, STBScrubID, _("Scrub"), true); - AddButton(bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID, + AddButton(this, bmpSeek, bmpSeek, bmpSeekDisabled, STBSeekID, _("Seek"), true); - AddButton(bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler, + AddButton(this, bmpToggleScrubRuler, bmpToggleScrubRuler, bmpToggleScrubRuler, STBRulerID, _("Scrub Ruler"), true); diff --git a/src/toolbars/ScrubbingToolBar.h b/src/toolbars/ScrubbingToolBar.h index 24f94c78c..5fb44bd9d 100644 --- a/src/toolbars/ScrubbingToolBar.h +++ b/src/toolbars/ScrubbingToolBar.h @@ -56,8 +56,10 @@ public: private: - AButton *AddButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, - int id, const wxChar *label, bool toggle = false); + static AButton *AddButton( + ScrubbingToolBar *pBar, + teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, + int id, const wxChar *label, bool toggle = false); void MakeButtons(); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 16f89fbf7..72b5ad5f1 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -205,10 +205,9 @@ 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); - NumericTextCtrl * pCtrl = safenew NumericTextCtrl( - NumericConverter::TIME, this, id, formatName, 0.0, mRate); + auto pCtrl = safenew NumericTextCtrl( + this, id, NumericConverter::TIME, formatName, 0.0, mRate); pCtrl->SetName(Name); - pCtrl->EnableMenu(); pSizer->Add(pCtrl, 0, wxALIGN_TOP | wxRIGHT, 5); return pCtrl; } diff --git a/src/toolbars/SpectralSelectionBar.cpp b/src/toolbars/SpectralSelectionBar.cpp index ad5666798..2c2aa7b8d 100644 --- a/src/toolbars/SpectralSelectionBar.cpp +++ b/src/toolbars/SpectralSelectionBar.cpp @@ -166,31 +166,39 @@ void SpectralSelectionBar::Populate() auto subSizer = std::make_unique(wxHORIZONTAL); mCenterCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0); - mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + this, OnCenterID, + NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0, + NumericTextCtrl::Options{} + .InvalidValue( true, SelectedRegion::UndefinedFrequency ) + ); mCenterCtrl->SetName(_("Center Frequency:")); - mCenterCtrl->EnableMenu(); subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mWidthCtrl = safenew NumericTextCtrl( - NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0); - mWidthCtrl->SetInvalidValue(-1.0); + this, OnWidthID, + NumericConverter::BANDWIDTH, bandwidthFormatName, 0.0, 44100.0, + NumericTextCtrl::Options{} + .InvalidValue( true, -1.0 ) + ); mWidthCtrl->SetName(wxString(_("Bandwidth:"))); - mWidthCtrl->EnableMenu(); subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mLowCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0); - mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + this, OnLowID, + NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0, + NumericTextCtrl::Options{} + .InvalidValue( true, SelectedRegion::UndefinedFrequency ) + ); mLowCtrl->SetName(_("Low Frequency:")); - mLowCtrl->EnableMenu(); subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mHighCtrl = safenew NumericTextCtrl( - NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0); - mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); + this, OnHighID, + NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0, + NumericTextCtrl::Options{} + .InvalidValue( true, SelectedRegion::UndefinedFrequency ) + ); mHighCtrl->SetName(wxString(_("High Frequency:"))); - mHighCtrl->EnableMenu(); subSizer->Add(mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mCenterCtrl->Show(mbCenterAndWidth); diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index 445e6d119..9de3061fc 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -155,10 +155,11 @@ void ToolsToolBar::UpdatePrefs() ToolBar::UpdatePrefs(); } -AButton * ToolsToolBar::MakeTool( teBmps eTool, +AButton * ToolsToolBar::MakeTool( + ToolsToolBar *pBar, teBmps eTool, int id, const wxChar *label) { - AButton *button = ToolBar::MakeButton(this, + AButton *button = ToolBar::MakeButton(pBar, bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall, @@ -168,7 +169,7 @@ AButton * ToolsToolBar::MakeTool( teBmps eTool, wxDefaultPosition, true, theTheme.ImageSize( bmpRecoloredUpSmall )); button->SetLabel( label ); - mToolSizer->Add( button ); + pBar->mToolSizer->Add( button ); return button; } @@ -180,12 +181,12 @@ void ToolsToolBar::Populate() Add(mToolSizer = safenew wxGridSizer(2, 3, 1, 1)); /* Tools */ - mTool[ selectTool ] = MakeTool( bmpIBeam, selectTool, _("Selection Tool") ); - mTool[ envelopeTool ] = MakeTool( bmpEnvelope, envelopeTool, _("Envelope Tool") ); - mTool[ drawTool ] = MakeTool( bmpDraw, drawTool, _("Draw Tool") ); - mTool[ zoomTool ] = MakeTool( bmpZoom, zoomTool, _("Zoom Tool") ); - mTool[ slideTool ] = MakeTool( bmpTimeShift, slideTool, _("Slide Tool") ); - mTool[ multiTool ] = MakeTool( bmpMulti, multiTool, _("Multi Tool") ); + mTool[ selectTool ] = MakeTool( this, bmpIBeam, selectTool, _("Selection Tool") ); + mTool[ envelopeTool ] = MakeTool( this, bmpEnvelope, envelopeTool, _("Envelope Tool") ); + mTool[ drawTool ] = MakeTool( this, bmpDraw, drawTool, _("Draw Tool") ); + mTool[ zoomTool ] = MakeTool( this, bmpZoom, zoomTool, _("Zoom Tool") ); + mTool[ slideTool ] = MakeTool( this, bmpTimeShift, slideTool, _("Slide Tool") ); + mTool[ multiTool ] = MakeTool( this, bmpMulti, multiTool, _("Multi Tool") ); mTool[mCurrentTool]->PushDown(); diff --git a/src/toolbars/ToolsToolBar.h b/src/toolbars/ToolsToolBar.h index 77bc116bd..3a5a2b2dc 100644 --- a/src/toolbars/ToolsToolBar.h +++ b/src/toolbars/ToolsToolBar.h @@ -70,7 +70,8 @@ class ToolsToolBar final : public ToolBar { void RegenerateTooltips() override; wxImage *MakeToolImage(wxImage *tool, wxImage *mask, int style); - AButton *MakeTool(teBmps eTool, int id, const wxChar *label); + static AButton *MakeTool( + ToolsToolBar *pBar, teBmps eTool, int id, const wxChar *label); AButton *mTool[numTools]; wxGridSizer *mToolSizer; diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index f6ad84f15..0e9b8a977 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -137,13 +137,14 @@ void TranscriptionToolBar::Create(wxWindow * parent) /// MakeButtons() with fewer arguments /// Very similar to code in ControlToolBar... AButton *TranscriptionToolBar::AddButton( + TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label) { - AButton *&r = mButtons[id]; + AButton *&r = pBar->mButtons[id]; - r = ToolBar::MakeButton(this, + r = ToolBar::MakeButton(pBar, bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall, eFore, eFore, eDisabled, wxWindowID(id), @@ -155,7 +156,7 @@ AButton *TranscriptionToolBar::AddButton( // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it? // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) ); - Add( r, 0, wxALIGN_CENTER ); + pBar->Add( r, 0, wxALIGN_CENTER ); return r; } @@ -177,7 +178,7 @@ void TranscriptionToolBar::Populate() // Very similar to code in EditToolBar MakeButtonBackgroundsSmall(); - AddButton(bmpPlay, bmpPlayDisabled, TTB_PlaySpeed, + AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed, _("Play at selected speed")); MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1); MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2); @@ -186,15 +187,18 @@ void TranscriptionToolBar::Populate() //Add a slider that controls the speed of playback. const int SliderWidth=100; mPlaySpeedSlider = safenew ASlider(this, - TTB_PlaySpeedSlider, - _("Playback Speed"), - wxDefaultPosition, - wxSize(SliderWidth,25), - SPEED_SLIDER); + TTB_PlaySpeedSlider, + _("Playback Speed"), + wxDefaultPosition, + wxSize(SliderWidth,25), + ASlider::Options{} + .Style( SPEED_SLIDER ) + // 6 steps using page up/down, and 60 using arrow keys + .Line( 0.16667f ) + .Page( 0.16667f ) + ); mPlaySpeedSlider->Set(mPlaySpeed / 100.0); mPlaySpeedSlider->SetLabel(_("Playback Speed")); - // 6 steps using page up/down, and 60 using arrow keys - mPlaySpeedSlider->SetScroll(0.16667f, 1.6667f); Add( mPlaySpeedSlider, 0, wxALIGN_CENTER ); mPlaySpeedSlider->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(TranscriptionToolBar::OnFocus), @@ -209,23 +213,23 @@ void TranscriptionToolBar::Populate() // If we need these strings translated, then search and replace // TRANSLATBLE by _ and remove this #define. #define TRANSLATABLE( x ) wxT( x ) - AddButton(bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn, + AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn, TRANSLATABLE("Adjust left selection to next onset")); - AddButton(bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn, + AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn, TRANSLATABLE("Adjust right selection to previous offset")); - AddButton(bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff, + AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff, TRANSLATABLE("Adjust left selection to next offset")); - AddButton(bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff, + AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff, TRANSLATABLE("Adjust right selection to previous onset")); - AddButton(bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound, + AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound, TRANSLATABLE("Select region of sound around cursor")); - AddButton(bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence, + AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence, TRANSLATABLE("Select region of silence around cursor")); - AddButton(bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection, + AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection, TRANSLATABLE("Automatically make labels from words")); - AddButton(bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel, + AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel, TRANSLATABLE("Add label at selection")); - AddButton(bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate, + AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate, TRANSLATABLE("Calibrate voicekey")); mSensitivitySlider = safenew ASlider(this, diff --git a/src/toolbars/TranscriptionToolBar.h b/src/toolbars/TranscriptionToolBar.h index d49a2b35f..d2ea3c661 100644 --- a/src/toolbars/TranscriptionToolBar.h +++ b/src/toolbars/TranscriptionToolBar.h @@ -122,7 +122,8 @@ class TranscriptionToolBar final : public ToolBar { private: void InitializeTranscriptionToolBar(); - AButton *AddButton( + static AButton *AddButton( + TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label); diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 071b624c2..b98e66815 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -215,9 +215,8 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id, title, wxDefaultPosition, size, - style, - false); - mSlider->SetScroll(line, page); + ASlider::Options{} + .Style( style ).Line( line ).Page( page ) ); S.AddWindow(mSlider, wxEXPAND); } S.EndVerticalLay(); @@ -1557,11 +1556,7 @@ ASlider::ASlider( wxWindow * parent, const wxString &name, const wxPoint & pos, const wxSize & size, - int style, - bool popup, - bool canUseShift, - float stepValue, - int orientation /*= wxHORIZONTAL*/) + const Options &options) : wxPanel( parent, id, pos, size, wxWANTS_CHARS ) { //wxColour Col(parent->GetBackgroundColour()); @@ -1571,23 +1566,25 @@ ASlider::ASlider( wxWindow * parent, name, wxPoint(0,0), size, - style, - canUseShift, - popup, - orientation); - mLWSlider->mStepValue = stepValue; + options.style, + options.canUseShift, + options.popup, + options.orientation); + mLWSlider->mStepValue = options.stepValue; mLWSlider->SetId( id ); SetName( name ); mSliderIsFocused = false; - mStyle = style; + mStyle = options.style; mTimer.SetOwner(this); #if wxUSE_ACCESSIBILITY SetAccessible( safenew ASliderAx( this ) ); #endif + + mLWSlider->SetScroll( options.line, options.page ); } diff --git a/src/widgets/ASlider.h b/src/widgets/ASlider.h index e2e6d1002..9cfe3c5cb 100644 --- a/src/widgets/ASlider.h +++ b/src/widgets/ASlider.h @@ -244,16 +244,35 @@ class ASlider /* not final */ : public wxPanel friend class ASliderAx; public: + struct Options { + Options() {} + + int style{ FRAC_SLIDER }; + wxOrientation orientation{ wxHORIZONTAL }; + bool popup{ true }; + bool canUseShift{ true }; + float stepValue{ STEP_CONTINUOUS }; + + float line{ 1.0 }; + float page{ 5.0 }; + + Options& Style( int s ) { style = s; return *this; } + Options& Orientation( wxOrientation o ) + { orientation = o; return *this; } + Options& Popup( bool p ) { popup = p; return *this; } + Options& CanUseShift( bool c ) { canUseShift = c; return *this; } + Options& StepValue( float v ) { stepValue = v; return *this; } + + Options& Line( float l ) { line = l; return *this; } + Options& Page( float p ) { page = p; return *this; } + }; + ASlider( wxWindow * parent, wxWindowID id, const wxString &name, const wxPoint & pos, const wxSize & size, - int style = FRAC_SLIDER, - bool popup = true, - bool canUseShift = true, - float stepValue = STEP_CONTINUOUS, - int orientation = wxHORIZONTAL); + const Options &options = Options{}); virtual ~ASlider(); bool AcceptsFocus() const override { return s_AcceptsFocus; } diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index d0aab59bb..e411a7919 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -44,16 +44,17 @@ NumericEditor::~NumericEditor() void NumericEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler) { wxASSERT(parent); // to justify safenew - auto control = safenew NumericTextCtrl(mType, parent, - wxID_ANY, - mFormat, - mOld, - mRate, - wxDefaultPosition, - wxDefaultSize, - true); - if (mType == NumericTextCtrl::FREQUENCY) - control->SetInvalidValue(SelectedRegion::UndefinedFrequency); + auto control = safenew NumericTextCtrl( + parent, wxID_ANY, + mType, + mFormat, + mOld, + mRate, + NumericTextCtrl::Options{} + .AutoPos(true) + .InvalidValue(mType == NumericTextCtrl::FREQUENCY, + SelectedRegion::UndefinedFrequency) + ); m_control = control; wxGridCellEditor::Create(parent, id, handler); @@ -174,14 +175,13 @@ void NumericRenderer::Draw(wxGrid &grid, table->GetValue(row, col).ToDouble(&value); - NumericTextCtrl tt(mType, &grid, - wxID_ANY, + NumericTextCtrl tt(&grid, wxID_ANY, + mType, ne->GetFormat(), value, ne->GetRate(), - wxPoint(10000, 10000), // create offscreen - wxDefaultSize, - true); + NumericTextCtrl::Options{}.AutoPos(true), + wxPoint(10000, 10000)); // create offscreen tstr = tt.GetString(); ne->DecRef(); @@ -231,14 +231,13 @@ wxSize NumericRenderer::GetBestSize(wxGrid &grid, if (ne) { double value; table->GetValue(row, col).ToDouble(&value); - NumericTextCtrl tt(mType, &grid, - wxID_ANY, + NumericTextCtrl tt(&grid, wxID_ANY, + mType, ne->GetFormat(), value, ne->GetRate(), - wxPoint(10000, 10000), // create offscreen - wxDefaultSize, - true); + NumericTextCtrl::Options{}.AutoPos(true), + wxPoint(10000, 10000)); // create offscreen sz = tt.GetSize(); ne->DecRef(); diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp index ab732aa16..7617e0d02 100644 --- a/src/widgets/NumericTextCtrl.cpp +++ b/src/widgets/NumericTextCtrl.cpp @@ -1239,22 +1239,21 @@ END_EVENT_TABLE() IMPLEMENT_CLASS(NumericTextCtrl, wxControl) -NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type, - wxWindow *parent, - wxWindowID id, +NumericTextCtrl::NumericTextCtrl(wxWindow *parent, wxWindowID id, + NumericConverter::Type type, const wxString &formatName, double timeValue, double sampleRate, + const Options &options, const wxPoint &pos, - const wxSize &size, - bool autoPos): + const wxSize &size): wxControl(parent, id, pos, size, wxSUNKEN_BORDER | wxWANTS_CHARS), NumericConverter(type, formatName, timeValue, sampleRate), mBackgroundBitmap{}, mDigitFont{}, mLabelFont{}, mLastField(1), - mAutoPos(autoPos) + mAutoPos(options.autoPos) , mType(type) { mAllowInvalidValue = false; @@ -1262,8 +1261,8 @@ NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type, mDigitBoxW = 10; mDigitBoxH = 16; - mReadOnly = false; - mMenuEnabled = true; + mReadOnly = options.readOnly; + mMenuEnabled = options.menuEnabled; mButtonWidth = 9; Layout(); @@ -1282,6 +1281,15 @@ NumericTextCtrl::NumericTextCtrl(NumericConverter::Type type, SetName(wxT("")); SetAccessible(safenew NumericTextCtrlAx(this)); #endif + + if (options.hasInvalidValue) + SetInvalidValue( options.invalidValue ); + + if (!options.format.empty()) + SetFormatString( options.format ); + + if (options.hasValue) + SetValue( options.value ); } NumericTextCtrl::~NumericTextCtrl() diff --git a/src/widgets/NumericTextCtrl.h b/src/widgets/NumericTextCtrl.h index 258217c05..c38cca5fb 100644 --- a/src/widgets/NumericTextCtrl.h +++ b/src/widgets/NumericTextCtrl.h @@ -145,15 +145,36 @@ class NumericTextCtrl final : public wxControl, public NumericConverter public: DECLARE_DYNAMIC_CLASS(NumericTextCtrl) - NumericTextCtrl(NumericConverter::Type type, - wxWindow *parent, - wxWindowID id, + struct Options { + bool autoPos { false }; + bool readOnly { false }; + bool menuEnabled { true }; + bool hasInvalidValue { false }; + double invalidValue { -1.0 }; + wxString format {}; + bool hasValue { false }; + double value{ -1.0 }; + + Options() {} + + Options &AutoPos (bool value) { autoPos = value; return *this; } + Options &ReadOnly (bool value) { readOnly = value; return *this; } + 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; } + Options &Value (bool has, double v) + { hasValue = has, value = v; return *this; } + }; + + NumericTextCtrl(wxWindow *parent, wxWindowID winid, + NumericConverter::Type type, const wxString &formatName = wxEmptyString, double value = 0.0, double sampleRate = 44100, + const Options &options = {}, const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - bool autoPos = false); + const wxSize &size = wxDefaultSize); virtual ~NumericTextCtrl(); diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index d84223648..c07ef628d 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -1606,10 +1606,37 @@ END_EVENT_TABLE() IMPLEMENT_CLASS(RulerPanel, wxPanelWrapper) RulerPanel::RulerPanel(wxWindow* parent, wxWindowID id, + wxOrientation orientation, + const wxSize &bounds, + const Range &range, + Ruler::RulerFormat format, + const wxString &units, + const Options &options, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/): wxPanelWrapper(parent, id, pos, size) { + ruler.SetBounds( 0, 0, bounds.x, bounds.y ); + ruler.SetOrientation(orientation); + ruler.SetRange( range.first, range.second ); + ruler.SetLog( options.log ); + ruler.SetFormat(format); + ruler.SetUnits( units ); + ruler.SetFlip( options.flip ); + ruler.SetLabelEdges( options.labelEdges ); + ruler.mbTicksAtExtremes = options.ticksAtExtremes; + if (orientation == wxVERTICAL) { + wxCoord w; + ruler.GetMaxSize(&w, NULL); + SetMinSize(wxSize(w, 150)); // height needed for wxGTK + } + else if (orientation == wxHORIZONTAL) { + wxCoord h; + ruler.GetMaxSize(NULL, &h); + SetMinSize(wxSize(wxDefaultCoord, h)); + } + if (options.hasTickColour) + ruler.SetTickColour( options.tickColour ); } RulerPanel::~RulerPanel() diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 76934757b..531a14bb8 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -245,7 +245,41 @@ class AUDACITY_DLL_API RulerPanel final : public wxPanelWrapper { DECLARE_DYNAMIC_CLASS(RulerPanel) public: + using Range = std::pair; + + struct Options { + bool log { false }; + bool flip { false }; + bool labelEdges { false }; + bool ticksAtExtremes { false }; + bool hasTickColour{ false }; + wxColour tickColour; + + Options() {} + + Options &Log( bool l ) + { log = l; return *this; } + + Options &Flip( bool f ) + { flip = f; return *this; } + + Options &LabelEdges( bool l ) + { labelEdges = l; return *this; } + + Options &TicksAtExtremes( bool t ) + { ticksAtExtremes = t; return *this; } + + Options &TickColour( const wxColour c ) + { tickColour = c; hasTickColour = true; return *this; } + }; + RulerPanel(wxWindow* parent, wxWindowID id, + wxOrientation orientation, + const wxSize &bounds, + const Range &range, + Ruler::RulerFormat format, + const wxString &units, + const Options &options = {}, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);