Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SpectralSelectionBar Class Referencefinal

(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range. More...

#include <SpectralSelectionBar.h>

Inheritance diagram for SpectralSelectionBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 SpectralSelectionBar ()
 
virtual ~SpectralSelectionBar ()
 
void Create (wxWindow *parent) override
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void SetFrequencies (double bottom, double top)
 
void SetFrequencySelectionFormatName (const NumericFormatId &formatName)
 
void SetBandwidthSelectionFormatName (const NumericFormatId &formatName)
 
void SetListener (SpectralSelectionBarListener *l)
 
void RegenerateTooltips () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void ReCreateButtons ()
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void ValuesToControls ()
 
void SetBounds ()
 
void OnUpdate (wxCommandEvent &evt)
 
void OnCtrl (wxCommandEvent &evt)
 
void OnChoice (wxCommandEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void ModifySpectralSelection (bool done=false)
 

Private Attributes

SpectralSelectionBarListenermListener
 
bool mbCenterAndWidth
 
double mCenter
 
double mWidth
 
double mLow
 
double mHigh
 
NumericTextCtrlmCenterCtrl
 
NumericTextCtrlmWidthCtrl
 
NumericTextCtrlmLowCtrl
 
NumericTextCtrlmHighCtrl
 
wxChoice * mChoice
 
int mHeight
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range.

Definition at line 30 of file SpectralSelectionBar.h.

Constructor & Destructor Documentation

SpectralSelectionBar::SpectralSelectionBar ( )

Definition at line 93 of file SpectralSelectionBar.cpp.

94 : ToolBar(SpectralSelectionBarID, _("Spectral Selection"), wxT("SpectralSelection"))
95 , mListener(NULL), mbCenterAndWidth(true)
96 , mCenter(0.0), mWidth(0.0), mLow(0.0), mHigh(0.0)
97 , mCenterCtrl(NULL), mWidthCtrl(NULL), mLowCtrl(NULL), mHighCtrl(NULL)
98 , mChoice(NULL)
99 {
100 }
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
NumericTextCtrl * mWidthCtrl
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ToolBar(int type, const wxString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:311
NumericTextCtrl * mLowCtrl
SpectralSelectionBarListener * mListener
SpectralSelectionBar::~SpectralSelectionBar ( )
virtual

Definition at line 102 of file SpectralSelectionBar.cpp.

103 {
104  // Do nothing, sizer deletes the controls
105 }

Member Function Documentation

void SpectralSelectionBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 107 of file SpectralSelectionBar.cpp.

References ToolBar::Create(), and mHeight.

108 {
109  ToolBar::Create(parent);
110  mHeight = wxWindowBase::GetSizer()->GetSize().GetHeight();
111 }
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:442
void SpectralSelectionBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 41 of file SpectralSelectionBar.h.

41 {};
void SpectralSelectionBar::ModifySpectralSelection ( bool  done = false)
private

Definition at line 265 of file SpectralSelectionBar.cpp.

References NumericConverter::GetValue(), mbCenterAndWidth, mCenter, mCenterCtrl, mHigh, mHighCtrl, min(), mListener, mLow, mLowCtrl, mWidth, mWidthCtrl, SpectralSelectionBarListener::SSBL_GetRate(), SpectralSelectionBarListener::SSBL_ModifySpectralSelection(), and SelectedRegion::UndefinedFrequency.

Referenced by OnCtrl().

266 {
267  const double nyq = mListener->SSBL_GetRate() / 2.0;
268 
269  double bottom, top;
270  if (mbCenterAndWidth) {
273  if ((mCenter < 0 || mWidth < 0) &&
274  (mLow >= 0 || mHigh >= 0))
275  // Transition from defined spectral selection to undefined
276  bottom = top = SelectedRegion::UndefinedFrequency;
277  else if (mCenter < 0 && mWidth < 0)
278  bottom = top = SelectedRegion::UndefinedFrequency;
279  else {
280  if (mCenter < 0) {
281  mWidth = log(std::min(nyq, exp(mWidth)));
282  // Choose arbitrary center for the width
283  mCenter = sqrt(nyq);
284  }
285  else if (mWidth < 0) {
286  mCenter = std::max(1.0, std::min(nyq, mCenter));
287  // Choose arbitrary width for the center
288  const double ratio = std::min(mCenter, nyq / mCenter);
289  mWidth = log(ratio * ratio);
290  }
291  else {
292  mCenter = std::max(1.0, std::min(nyq, mCenter));
293  double ratio = std::min(mCenter, nyq / mCenter);
294  mWidth = std::min(2 * log(ratio), mWidth);
295  }
296 
297  const double ratio = exp(mWidth / 2);
298  bottom = mCenter / ratio, top = mCenter * ratio;
299  }
300  }
301  else {
302  bottom = mLowCtrl->GetValue();
303  top = mHighCtrl->GetValue();
304 
305  if (bottom >= 0)
306  bottom = std::min(nyq, bottom);
307  else
309 
310  if (top >= 0)
311  top = std::min(nyq, top);
312  else
314  // These have to be in the right order.
315  if( bottom > top ){
316  // Oops. We must fix the order.
317  if( mLowCtrl->HasFocus() )
318  top = bottom;
319  else
320  bottom = top;
321  }
322  }
323 
324 
325  mLow = bottom;
326  mHigh = top;
327  //SetBounds();
328 
329  // Notify project and track panel, which may change
330  // the values again, and call back to us in SetFrequencies()
331  mListener->SSBL_ModifySpectralSelection(bottom, top, done);
332 }
virtual double SSBL_GetRate() const =0
virtual void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done)=0
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
NumericTextCtrl * mWidthCtrl
int min(int a, int b)
NumericTextCtrl * mLowCtrl
static const int UndefinedFrequency
SpectralSelectionBarListener * mListener
void SpectralSelectionBar::OnChoice ( wxCommandEvent &  evt)
private

Definition at line 339 of file SpectralSelectionBar.cpp.

References ToolBar::GetSizer(), gPrefs, mbCenterAndWidth, mCenterCtrl, mChoice, mHeight, mHighCtrl, mLowCtrl, mWidthCtrl, preferencePath(), ToolBar::Updated(), and ValuesToControls().

340 {
341  mbCenterAndWidth = (0 == mChoice->GetSelection());
343  gPrefs->Flush();
344 
347  mLowCtrl->Show(!mbCenterAndWidth);
348  mHighCtrl->Show(!mbCenterAndWidth);
349 
351  GetSizer()->Layout(); // Required so that the layout does not mess up on Windows when changing the format.
352  wxWindowBase::GetSizer()->SetMinSize(wxSize(0, mHeight)); // so that height of toolbar does not change
353  wxWindowBase::GetSizer()->SetSizeHints(this);
354  Updated();
355 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:607
static const wxString preferencePath(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"))
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
NumericTextCtrl * mWidthCtrl
void Updated()
Definition: ToolBar.cpp:596
NumericTextCtrl * mLowCtrl
void SpectralSelectionBar::OnCtrl ( wxCommandEvent &  evt)
private

Definition at line 334 of file SpectralSelectionBar.cpp.

References ModifySpectralSelection().

335 {
336  ModifySpectralSelection(event.GetInt() != 0);
337 }
void ModifySpectralSelection(bool done=false)
void SpectralSelectionBar::OnSize ( wxSizeEvent &  evt)
private

Definition at line 258 of file SpectralSelectionBar.cpp.

259 {
260  Refresh(true);
261 
262  evt.Skip();
263 }
void SpectralSelectionBar::OnUpdate ( wxCommandEvent &  evt)
private

Definition at line 357 of file SpectralSelectionBar.cpp.

References NumericConverter::GetBuiltinName(), mbCenterAndWidth, mCenterCtrl, mHighCtrl, mListener, mLowCtrl, mWidthCtrl, ToolBar::ReCreateButtons(), SpectralSelectionBarListener::SSBL_SetBandwidthSelectionFormatName(), SpectralSelectionBarListener::SSBL_SetFrequencySelectionFormatName(), ToolBar::Updated(), and ValuesToControls().

Referenced by SetBandwidthSelectionFormatName(), SetFrequencySelectionFormatName(), and UpdatePrefs().

358 {
359  int index = evt.GetInt();
360  wxWindow *w = FindFocus();
361  bool centerFocus = (w && w == mCenterCtrl);
362  bool widthFocus = (w && w == mWidthCtrl);
363  bool lowFocus = (w && w == mLowCtrl);
364  bool highFocus = (w && w == mHighCtrl);
365 
366  evt.Skip(false);
367 
368  // Save formats before recreating the controls so they resize properly
369  wxEventType type = evt.GetEventType();
370  if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
371  NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
372  auto frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
373  mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
374  }
375  else if (mbCenterAndWidth &&
376  type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
377  auto bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
378  mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
379  }
380 
381  // ToolBar::ReCreateButtons() will get rid of our sizers and controls
382  // so reset pointers first.
383  mCenterCtrl = mWidthCtrl = NULL;
384  mLowCtrl = mHighCtrl = NULL;
385 
388 
389 
390  if (centerFocus) {
391  mCenterCtrl->SetFocus();
392  }
393  else if (widthFocus) {
394  mWidthCtrl->SetFocus();
395  }
396  else if (lowFocus) {
397  mLowCtrl->SetFocus();
398  }
399  else if (highFocus) {
400  mHighCtrl->SetFocus();
401  }
402 
403  Updated();
404 }
virtual void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId &formatName)=0
virtual void ReCreateButtons()
Definition: ToolBar.cpp:463
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
NumericTextCtrl * mWidthCtrl
virtual void SSBL_SetFrequencySelectionFormatName(const NumericFormatId &formatName)=0
void Updated()
Definition: ToolBar.cpp:596
NumericFormatId GetBuiltinName(const int index)
NumericTextCtrl * mLowCtrl
SpectralSelectionBarListener * mListener
void SpectralSelectionBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 113 of file SpectralSelectionBar.cpp.

References _(), ToolBar::Add(), NumericConverter::BANDWIDTH, ThemeBase::Colour(), NumericConverter::FREQUENCY, ToolBar::GetSizer(), gPrefs, NumericTextCtrl::Options::InvalidValue(), NumericTextCtrl::Layout(), mbCenterAndWidth, mCenterCtrl, mChoice, mHighCtrl, mListener, mLowCtrl, mWidthCtrl, OnCenterID, OnChoiceID, OnHighID, OnLowID, OnWidthID, preferencePath(), safenew, SpectralSelectionBarListener::SSBL_GetBandwidthSelectionFormatName(), SpectralSelectionBarListener::SSBL_GetFrequencySelectionFormatName(), theTheme, and SelectedRegion::UndefinedFrequency.

114 {
115  SetBackgroundColour( theTheme.Colour( clrMedium ) );
116  gPrefs->Read(preferencePath, &mbCenterAndWidth, true);
117 
118  // This will be inherited by all children:
119  SetFont(wxFont(
120 #ifdef __WXMAC__
121  12
122 #else
123  9
124 #endif
125  ,
126  wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
127 
128  /* we don't actually need a control yet, but we want to use its methods
129  * to do some look-ups, so we'll have to create one. We can't make the
130  * look-ups static because they depend on translations which are done at
131  * runtime */
132 
133  auto frequencyFormatName = mListener
135  : NumericFormatId{};
136  auto bandwidthFormatName = mListener
138  : NumericFormatId{};
139 
140  wxFlexGridSizer *mainSizer;
141  Add((mainSizer = safenew wxFlexGridSizer(1, 1, 1)), 0,wxALIGN_TOP | wxLEFT | wxTOP, 5);
142 
143  //
144  // Top row, choice box
145  //
146 
147  const wxString choices[2] = {
148  _("Center frequency and Width"),
149  _("Low and High Frequencies"),
150  };
151  mChoice = safenew wxChoice
152  (this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices,
153  0, wxDefaultValidator, _("Show"));
154  mChoice->SetSelection(mbCenterAndWidth ? 0 : 1);
155 #if wxUSE_ACCESSIBILITY
156  // so that name can be set on a standard control
157  mChoice->SetAccessible(safenew WindowAccessible(mChoice));
158 #endif
159 #ifdef __WXGTK__
160  // Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
161  // be three units high.
162  wxSize sz = mChoice->GetBestSize();
163  sz.SetHeight( sz.y-4);
164  mChoice->SetMinSize( sz );
165 #endif
166 
167  mainSizer->Add(mChoice, 0, wxALIGN_TOP | wxEXPAND |wxRIGHT, 6);
168 
169  //
170  // Bottom row, split into two columns, each with one control
171  //
172 
173  {
174  auto subSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
175 
177  this, OnCenterID,
178  NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0,
181  );
182  mCenterCtrl->SetName(_("Center Frequency"));
183  subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
184 
186  this, OnWidthID,
187  NumericConverter::BANDWIDTH, bandwidthFormatName, 0.0, 44100.0,
189  .InvalidValue( true, -1.0 )
190  );
191  mWidthCtrl->SetName(wxString(_("Bandwidth")));
192  subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
193 
195  this, OnLowID,
196  NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0,
199  );
200  mLowCtrl->SetName(_("Low Frequency"));
201  subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
202 
204  this, OnHighID,
205  NumericConverter::FREQUENCY, frequencyFormatName, 0.0, 44100.0,
208  );
209  mHighCtrl->SetName(wxString(_("High Frequency")));
210  subSizer->Add(mHighCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
211 
212  mCenterCtrl->Show(mbCenterAndWidth);
214  mLowCtrl->Show(!mbCenterAndWidth);
215  mHighCtrl->Show(!mbCenterAndWidth);
216 
217  mainSizer->Add(subSizer.release(), 0, wxALIGN_CENTER_VERTICAL, 0);
218  }
219 
220  mainSizer->Layout();
221 
222  Layout();
223 
224  SetMinSize(GetSizer()->GetMinSize());
225 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
Options & InvalidValue(bool has, double v=-1.0)
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:607
static const wxString preferencePath(wxT("/GUI/Toolbars/SpectralSelection/CenterAndWidthChoice"))
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
#define safenew
Definition: Audacity.h:230
virtual const NumericFormatId & SSBL_GetFrequencySelectionFormatName()=0
NumericTextCtrl * mWidthCtrl
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
virtual const NumericFormatId & SSBL_GetBandwidthSelectionFormatName()=0
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
bool Layout() override
NumericTextCtrl * mLowCtrl
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
static const int UndefinedFrequency
SpectralSelectionBarListener * mListener
void SpectralSelectionBar::RegenerateTooltips ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 49 of file SpectralSelectionBar.h.

Referenced by UpdatePrefs().

49 {};
void SpectralSelectionBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 40 of file SpectralSelectionBar.h.

40 {};
void SpectralSelectionBar::SetBandwidthSelectionFormatName ( const NumericFormatId formatName)

Definition at line 461 of file SpectralSelectionBar.cpp.

References NumericConverter::GetFormatIndex(), mbCenterAndWidth, mWidthCtrl, OnUpdate(), and NumericTextCtrl::SetFormatName().

Referenced by AudacityProject::SetBandwidthSelectionFormatName(), and SetListener().

462 {
463  if (mbCenterAndWidth) {
464  mWidthCtrl->SetFormatName(formatName);
465 
466  wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
467  e.SetInt(mWidthCtrl->GetFormatIndex());
468  OnUpdate(e);
469  }
470 }
NumericTextCtrl * mWidthCtrl
void OnUpdate(wxCommandEvent &evt)
void SetFormatName(const NumericFormatId &formatName)
void SpectralSelectionBar::SetBounds ( )
private
void SpectralSelectionBar::SetFrequencies ( double  bottom,
double  top 
)

Definition at line 438 of file SpectralSelectionBar.cpp.

References mCenter, mHigh, mLow, mWidth, and ValuesToControls().

Referenced by AudacityProject::TP_DisplaySelection().

439 {
440  mLow = bottom;
441  mHigh = top;
442 
443  if (bottom > 0 && top >= bottom)
444  mWidth = log(top / bottom), mCenter = sqrt(top * bottom);
445  else
446  mWidth = mCenter = -1.0;
447 
449 }
void SpectralSelectionBar::SetFrequencySelectionFormatName ( const NumericFormatId formatName)

Definition at line 451 of file SpectralSelectionBar.cpp.

References NumericConverter::GetFormatIndex(), mbCenterAndWidth, mCenterCtrl, mLowCtrl, OnUpdate(), and NumericTextCtrl::SetFormatName().

Referenced by AudacityProject::SetFrequencySelectionFormatName(), and SetListener().

452 {
453  NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
454  frequencyCtrl->SetFormatName(formatName);
455 
456  wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
457  e.SetInt(frequencyCtrl->GetFormatIndex());
458  OnUpdate(e);
459 }
NumericTextCtrl * mCenterCtrl
void OnUpdate(wxCommandEvent &evt)
void SetFormatName(const NumericFormatId &formatName)
NumericTextCtrl * mLowCtrl
void SpectralSelectionBar::SetListener ( SpectralSelectionBarListener l)
void SpectralSelectionBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 227 of file SpectralSelectionBar.cpp.

References _(), NumericConverter::GetFormatIndex(), mbCenterAndWidth, mCenterCtrl, mLowCtrl, mWidthCtrl, OnUpdate(), RegenerateTooltips(), ToolBar::SetLabel(), and ToolBar::UpdatePrefs().

228 {
229  {
230  wxCommandEvent e(EVT_FREQUENCYTEXTCTRL_UPDATED);
231  e.SetInt((mbCenterAndWidth? mCenterCtrl : mLowCtrl)->GetFormatIndex());
232  OnUpdate(e);
233  }
234 
235  if (mbCenterAndWidth)
236  {
237  wxCommandEvent e(EVT_BANDWIDTHTEXTCTRL_UPDATED);
238  e.SetInt(mWidthCtrl->GetFormatIndex());
239  OnUpdate(e);
240  }
241 
242  // Set label to pull in language change
243  SetLabel(_("Spectral Selection"));
244 
246 
247  // Give base class a chance
249 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:378
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mWidthCtrl
void OnUpdate(wxCommandEvent &evt)
void RegenerateTooltips() override
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
NumericTextCtrl * mLowCtrl
void SpectralSelectionBar::ValuesToControls ( )
private

Definition at line 406 of file SpectralSelectionBar.cpp.

References mbCenterAndWidth, mCenter, mCenterCtrl, mHigh, mHighCtrl, mLow, mLowCtrl, mWidth, mWidthCtrl, and NumericTextCtrl::SetValue().

Referenced by OnChoice(), OnUpdate(), and SetFrequencies().

407 {
408  if (mbCenterAndWidth) {
411  }
412  else {
413  //Bug 1633
414  //The controls may not be able to show mHigh, e.g.
415  //if set to Hz, and in that case we should either show invalid
416  //or 'do the best we can' and truncate.
417  //If we set bounds we instead clip to the mHigh to mLow,
418  //So no SetBounds, for now.
419  //SetBounds();
422  }
423 }
NumericTextCtrl * mCenterCtrl
NumericTextCtrl * mHighCtrl
NumericTextCtrl * mWidthCtrl
void SetValue(double newValue)
NumericTextCtrl * mLowCtrl

Member Data Documentation

bool SpectralSelectionBar::mbCenterAndWidth
private
double SpectralSelectionBar::mCenter
private
NumericTextCtrl* SpectralSelectionBar::mCenterCtrl
private
wxChoice* SpectralSelectionBar::mChoice
private

Definition at line 73 of file SpectralSelectionBar.h.

Referenced by OnChoice(), and Populate().

int SpectralSelectionBar::mHeight
private

Definition at line 75 of file SpectralSelectionBar.h.

Referenced by Create(), and OnChoice().

double SpectralSelectionBar::mHigh
private
NumericTextCtrl * SpectralSelectionBar::mHighCtrl
private
SpectralSelectionBarListener* SpectralSelectionBar::mListener
private

Definition at line 63 of file SpectralSelectionBar.h.

Referenced by ModifySpectralSelection(), OnUpdate(), Populate(), and SetListener().

double SpectralSelectionBar::mLow
private
NumericTextCtrl * SpectralSelectionBar::mLowCtrl
private
double SpectralSelectionBar::mWidth
private
NumericTextCtrl * SpectralSelectionBar::mWidthCtrl
private

The documentation for this class was generated from the following files: