Audacity  2.2.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
PrefsDialog Class Referenceabstract

Dialog that shows the current PrefsPanel in a tabbed divider. More...

#include <PrefsDialog.h>

Inheritance diagram for PrefsDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog > GlobalPrefsDialog

Classes

struct  PrefsNode
 

Public Types

typedef std::vector< PrefsNodeFactories
 

Public Member Functions

 PrefsDialog (wxWindow *parent, const wxString &titlePrefix=_("Preferences: "), Factories &factories=DefaultFactories())
 
virtual ~PrefsDialog ()
 
int ShowModal () override
 
void ShuttleAll (ShuttleGui &S)
 
void OnCategoryChange (wxCommandEvent &e)
 
void OnOK (wxCommandEvent &e)
 
void OnCancel (wxCommandEvent &e)
 
void OnPreview (wxCommandEvent &e)
 
void OnHelp (wxCommandEvent &e)
 
void OnTreeKeyDown (wxTreeEvent &e)
 
void SelectPageByName (const wxString &pageName)
 
int GetSelectedPage () const
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static FactoriesDefaultFactories ()
 

Protected Member Functions

virtual long GetPreferredPage ()=0
 
virtual void SavePreferredPage ()=0
 

Private Member Functions

void RecordExpansionState ()
 
PrefsPanelGetCurrentPanel ()
 

Private Attributes

wxTreebookmCategories {}
 
PrefsPanelmUniquePage {}
 
FactoriesmFactories
 
const wxString mTitlePrefix
 

Detailed Description

Dialog that shows the current PrefsPanel in a tabbed divider.

Definition at line 35 of file PrefsDialog.h.

Member Typedef Documentation

typedef std::vector<PrefsNode> PrefsDialog::Factories

Definition at line 50 of file PrefsDialog.h.

Constructor & Destructor Documentation

PrefsDialog::PrefsDialog ( wxWindow *  parent,
const wxString &  titlePrefix = _("Preferences: "),
Factories factories = DefaultFactories() 
)

Definition at line 234 of file PrefsDialog.cpp.

References _(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddWindow(), eCancelButton, eHelpButton, eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndVerticalLay(), eOkButton, ePreviewButton, gPrefs, mTitlePrefix, PrefsDialog::PrefsNode::nChildren, PrefsDialog::PrefsNode::pFactory, ShuttleGui::Prop(), safenew, ShuttleGuiBase::StartHorizontalLay(), and ShuttleGuiBase::StartVerticalLay().

235 : wxDialogWrapper(parent, wxID_ANY, wxString(_("Audacity Preferences")),
236  wxDefaultPosition,
237  wxDefaultSize,
238  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
239 , mFactories(factories)
240 , mTitlePrefix(titlePrefix)
241 {
242  wxASSERT(factories.size() > 0);
243  const bool uniquePage = (factories.size() == 1);
244 
245  ShuttleGui S(this, eIsCreating);
246 
247  S.StartVerticalLay(true);
248  {
249  wxASSERT(factories.size() > 0);
250  if (!uniquePage) {
251  mCategories = safenew wxTreebookExt(this, wxID_ANY, mTitlePrefix);
252 #if wxUSE_ACCESSIBILITY
253  // so that name can be set on a standard control
254  mCategories->GetTreeCtrl()->SetAccessible(safenew WindowAccessible(mCategories->GetTreeCtrl()));
255 #endif
256  // RJH: Prevent NVDA from reading "treeCtrl"
257  mCategories->GetTreeCtrl()->SetName(_("Category"));
258  S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true);
259  {
260  S.Prop(1);
261  S.AddWindow(mCategories, wxEXPAND);
262 
263  {
264  typedef std::pair<int, int> IntPair;
265  std::vector<IntPair> stack;
266  int iPage = 0;
267  for (Factories::const_iterator it = factories.begin(), end = factories.end();
268  it != end; ++it, ++iPage)
269  {
270  const PrefsNode &node = *it;
271  PrefsPanelFactory &factory = *node.pFactory;
272  wxWindow *const w = factory(mCategories, wxID_ANY);
273  if (stack.empty())
274  // Parameters are: AddPage(page, name, IsSelected, imageId).
275  mCategories->AddPage(w, w->GetName(), false, 0);
276  else {
277  IntPair &top = *stack.rbegin();
278  mCategories->InsertSubPage(top.first, w, w->GetName(), false, 0);
279  if (--top.second == 0) {
280  // Expand all nodes before the layout calculation
281  mCategories->ExpandNode(top.first, true);
282  stack.pop_back();
283  }
284  }
285  if (node.nChildren > 0)
286  stack.push_back(IntPair(iPage, node.nChildren));
287  }
288  }
289  }
290  S.EndHorizontalLay();
291  }
292  else {
293  // TODO: Look into getting rid of mUniquePage and instead
294  // adding into mCategories, so there is just one page in mCategories.
295  // And then hiding the treebook.
296 
297  // Unique page, don't show the factory
298  const PrefsNode &node = factories[0];
299  PrefsPanelFactory &factory = *node.pFactory;
300  mUniquePage = factory(this, wxID_ANY);
301  wxWindow * uniquePageWindow = S.Prop(1).AddWindow(mUniquePage, wxEXPAND);
302  // We're not in the wxTreebook, so add the accelerator here
303  wxAcceleratorEntry entries[1];
304 #if defined(__WXMAC__)
305  // Is there a standard shortcut on Mac?
306 #else
307  entries[0].Set(wxACCEL_NORMAL, (int) WXK_F1, wxID_HELP);
308 #endif
309  wxAcceleratorTable accel(1, entries);
310  uniquePageWindow->SetAcceleratorTable(accel);
311  }
312  }
313  S.EndVerticalLay();
314 
315  S.AddStandardButtons(eOkButton | eCancelButton | ePreviewButton | eHelpButton);
316  static_cast<wxButton*>(wxWindow::FindWindowById(wxID_OK, this))->SetDefault();
317 
319  wxWindow *const previewButton =
320  wxWindow::FindWindowById(wxID_PREVIEW, GetParent());
321  previewButton->Show(false);
322  }
323 
324 #if defined(__WXGTK__)
325  if (mCategories)
326  mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
327 #endif
328 
329 // mCategories->SetSizeHints(-1, -1, 790, 600); // 790 = 800 - (border * 2)
330  Layout();
331  Fit();
332  wxSize sz = GetSize();
333 
334  // Collapse nodes only after layout so the tree is wide enough
335  if (mCategories)
336  {
337  int iPage = 0;
338  for (Factories::const_iterator it = factories.begin(), end = factories.end();
339  it != end; ++it, ++iPage)
340  mCategories->ExpandNode(iPage, it->expanded);
341  }
342 
343  // This ASSERT was originally used to limit us to 800 x 600.
344  // However, the range of screen sizes and dpi of modern (2018) displays
345  // makes pixel dimensions an inadequate measure of usability, so
346  // now we only ASSERT that preferences will fit in the client display
347  // rectangle of the developer / tester's monitor.
348  // Use scrollers when necessary to ensure that preference pages will
349  // be fully visible.
350  wxRect screenRect(wxGetClientDisplayRect());
351  wxASSERT_MSG(sz.x <= screenRect.width && sz.y <= screenRect.height, wxT("Preferences dialog exceeds max size"));
352 
353  sz.DecTo(screenRect.GetSize());
354 
355  if( !mUniquePage ){
356  int prefWidth, prefHeight;
357  gPrefs->Read(wxT("/Prefs/Width"), &prefWidth, sz.x);
358  gPrefs->Read(wxT("/Prefs/Height"), &prefHeight, wxMax(480,sz.y));
359 
360  wxSize prefSize = wxSize(prefWidth, prefHeight);
361  prefSize.DecTo(screenRect.GetSize());
362  SetSize(prefSize);
363  InvalidateBestSize();
364  Layout();
365  }
366  SetMinSize(sz);
367 
368  // Center after all that resizing, but make sure it doesn't end up
369  // off-screen
370  CentreOnParent();
371 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
Factories & mFactories
Definition: PrefsDialog.h:87
wxTreebook * mCategories
Definition: PrefsDialog.h:85
#define safenew
Definition: Audacity.h:230
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
const wxString mTitlePrefix
Definition: PrefsDialog.h:88
virtual bool ShowsPreviewButton()
_("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
PrefsDialog::~PrefsDialog ( )
virtual

Definition at line 373 of file PrefsDialog.cpp.

374 {
375 }

Member Function Documentation

PrefsDialog::Factories & PrefsDialog::DefaultFactories ( )
static

Definition at line 155 of file PrefsDialog.cpp.

156 {
157  // To do, perhaps: create this table by registration, without including each PrefsPanel
158  // class... and thus allowing a plug-in protocol
159  static DevicePrefsFactory devicePrefsFactory;
160  static PlaybackPrefsFactory playbackPrefsFactory;
161  static RecordingPrefsFactory recordingPrefsFactory;
162 #ifdef EXPERIMENTAL_MIDI_OUT
163  static MidiIOPrefsFactory midiIOPrefsFactory;
164 #endif
165  static QualityPrefsFactory qualityPrefsFactory;
166  static GUIPrefsFactory guiPrefsFactory;
167  static TracksPrefsFactory tracksPrefsFactory;
168  static ImportExportPrefsFactory importExportPrefsFactory;
169  static ExtImportPrefsFactory extImportPrefsFactory;
170  static ProjectsPrefsFactory projectsPrefsFactory;
171 #if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
172  static LibraryPrefsFactory libraryPrefsFactory;
173 #endif
174  // static WaveformPrefsFactory waveformPrefsFactory;
175  static TracksBehaviorsPrefsFactory tracksBehaviorsPrefsFactory;
176  static SpectrumPrefsFactory spectrumPrefsFactory;
177  static DirectoriesPrefsFactory directoriesPrefsFactory;
178  static WarningsPrefsFactory warningsPrefsFactory;
179  static EffectsPrefsFactory effectsPrefsFactory;
180 #ifdef EXPERIMENTAL_THEME_PREFS
181  static ThemePrefsFactory themePrefsFactory;
182 #endif
183  // static BatchPrefsFactory batchPrefsFactory;
184  static KeyConfigPrefsFactory keyConfigPrefsFactory;
185  static MousePrefsFactory mousePrefsFactory;
186 #ifdef EXPERIMENTAL_MODULE_PREFS
187  static ModulePrefsFactory modulePrefsFactory;
188 #endif
189 
190  static PrefsNode nodes[] = {
191  &devicePrefsFactory,
192  &playbackPrefsFactory,
193  &recordingPrefsFactory,
194 #ifdef EXPERIMENTAL_MIDI_OUT
195  &midiIOPrefsFactory,
196 #endif
197  &qualityPrefsFactory,
198  &guiPrefsFactory,
199 
200  // Group other page(s)
201  PrefsNode(&tracksPrefsFactory, 2),
202  // &waveformPrefsFactory,
203  &tracksBehaviorsPrefsFactory,
204  &spectrumPrefsFactory,
205 
206  // Group one other page
207  PrefsNode(&importExportPrefsFactory, 1),
208  &extImportPrefsFactory,
209 
210  &projectsPrefsFactory,
211 #if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
212  &libraryPrefsFactory,
213 #endif
214  &directoriesPrefsFactory,
215  &warningsPrefsFactory,
216  &effectsPrefsFactory,
217 #ifdef EXPERIMENTAL_THEME_PREFS
218  &themePrefsFactory,
219 #endif
220  // &batchPrefsFactory,
221  &keyConfigPrefsFactory,
222  &mousePrefsFactory,
223 #ifdef EXPERIMENTAL_MODULE_PREFS
224  &modulePrefsFactory,
225 #endif
226  };
227 
228  static Factories factories(nodes, nodes + sizeof(nodes) / sizeof(nodes[0]));
229  return factories;
230 }
std::vector< PrefsNode > Factories
Definition: PrefsDialog.h:50
PrefsPanel * PrefsDialog::GetCurrentPanel ( )
private

Definition at line 422 of file PrefsDialog.cpp.

References mCategories, and mUniquePage.

Referenced by OnHelp(), and OnPreview().

423 {
424  if( mCategories)
425  return static_cast<PrefsPanel*>(mCategories->GetCurrentPage());
426  else
427  {
428  wxASSERT( mUniquePage );
429  return mUniquePage;
430  }
431 }
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
wxTreebook * mCategories
Definition: PrefsDialog.h:85
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45
virtual long PrefsDialog::GetPreferredPage ( )
protectedpure virtual

Implemented in GlobalPrefsDialog.

Referenced by ShowModal().

int PrefsDialog::GetSelectedPage ( ) const

Definition at line 583 of file PrefsDialog.cpp.

References mCategories.

Referenced by GlobalPrefsDialog::SavePreferredPage().

584 {
585  if (mCategories)
586  return mCategories->GetSelection();
587  else
588  return 0;
589 }
wxTreebook * mCategories
Definition: PrefsDialog.h:85
void PrefsDialog::OnCancel ( wxCommandEvent &  e)

Definition at line 399 of file PrefsDialog.cpp.

References PrefsPanel::Cancel(), gPrefs, mCategories, mUniquePage, and RecordExpansionState().

400 {
402 
403  if (mCategories) {
404  for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
405  ((PrefsPanel *)mCategories->GetPage(i))->Cancel();
406  }
407  }
408  else
409  mUniquePage->Cancel();
410 
411  // Remember modified dialog size, even if cancelling.
412  if( !mUniquePage ){
413  wxSize sz = GetSize();
414  gPrefs->Write(wxT("/Prefs/Width"), sz.x);
415  gPrefs->Write(wxT("/Prefs/Height"), sz.y);
416  }
417  gPrefs->Flush();
418 
419  EndModal(false);
420 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
void RecordExpansionState()
wxTreebook * mCategories
Definition: PrefsDialog.h:85
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45
virtual void Cancel()
void PrefsDialog::OnCategoryChange ( wxCommandEvent &  e)
void PrefsDialog::OnHelp ( wxCommandEvent &  e)

Definition at line 438 of file PrefsDialog.cpp.

References GetCurrentPanel(), PrefsPanel::HelpPageName(), mCategories, and HelpSystem::ShowHelp().

439 {
440  wxString page = GetCurrentPanel()->HelpPageName();
441  // Currently (May2017) Spectrum Settings is the only preferences
442  // we ever display in a dialog on its own without others.
443  // We do so when it is configuring spectrums for a track.
444  // Because this happens, we want to visit a different help page.
445  // So we change the page name in the case of a page on its own.
446  if( !mCategories)
447  page.Replace( "Spectrograms_Preferences", "Spectrogram_Settings" );
448  HelpSystem::ShowHelp(this, page, true);
449 }
wxTreebook * mCategories
Definition: PrefsDialog.h:85
PrefsPanel * GetCurrentPanel()
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:194
virtual wxString HelpPageName()
void PrefsDialog::OnOK ( wxCommandEvent &  e)

Definition at line 476 of file PrefsDialog.cpp.

References Theme::ApplyUpdatedImages(), PrefsPanel::Commit(), WaveformSettings::defaults(), SpectrogramSettings::defaults(), gAudacityProjects, gAudioIO, gPrefs, AudioIO::HandleDeviceChange(), AudioIO::IsBusy(), AudioIO::IsMonitoring(), ThemeBase::LoadPreferredTheme(), WaveformSettings::LoadPrefs(), SpectrogramSettings::LoadPrefs(), mCategories, mUniquePage, PrefsPanel::Preview(), RecordExpansionState(), SavePreferredPage(), AudioIO::StopStream(), and theTheme.

Referenced by AudacityProject::OnReloadPreferences(), and OnTreeKeyDown().

477 {
479 
480  // Validate all pages first
481  if (mCategories) {
482  for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
483  PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i);
484 
485  // The dialog doesn't end until all the input is valid
486  if (!panel->Validate()) {
487  mCategories->SetSelection(i);
488  return;
489  }
490  }
491  }
492  else {
493  if (!mUniquePage->Validate())
494  return;
495  }
496 
497  // flush now so toolbars will know their position.
498  gPrefs->Flush();
499  if (mCategories) {
500  // Now apply the changes
501  // Reverse order - so Track Name is updated before language change
502  // A workaround for Bug 1661
503  for (int i = (int)mCategories->GetPageCount()-1; i>= 0; i--) {
504  PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i);
505 
506  panel->Preview();
507  panel->Commit();
508  }
509  }
510  else {
511  mUniquePage->Preview();
512  mUniquePage->Commit();
513  }
514 
515  if( !mUniquePage ){
516  wxSize sz = GetSize();
517  gPrefs->Write(wxT("/Prefs/Width"), sz.x);
518  gPrefs->Write(wxT("/Prefs/Height"), sz.y);
519  }
520  gPrefs->Flush();
521 
522  // Reads preference /GUI/Theme
525 
527 
528 #if USE_PORTMIXER
529  if (gAudioIO) {
530  // We cannot have opened this dialog if gAudioIO->IsAudioTokenActive(),
531  // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in
532  // AudacityProject::GetUpdateFlags().
533  // However, we can have an invalid audio token (so IsAudioTokenActive()
534  // is false), but be monitoring.
535  // If monitoring, have to stop the stream, so HandleDeviceChange() can work.
536  // We could disable the Preferences command while monitoring, i.e.,
537  // set AudioIONotBusyFlag/AudioIOBusyFlag according to monitoring, as well.
538  // Instead allow it because unlike recording, for example, monitoring
539  // is not clearly something that should prohibit opening prefs.
540  // TODO: We *could* be smarter in this method and call HandleDeviceChange()
541  // only when the device choices actually changed. True of lots of prefs!
542  // As is, we always stop monitoring before handling the device change.
543  if (gAudioIO->IsMonitoring())
544  {
545  gAudioIO->StopStream();
546  while (gAudioIO->IsBusy())
547  wxMilliSleep(100);
548  }
550  }
551 #endif
552 
553  // LL: wxMac can't handle recreating the menus when this dialog is still active,
554  // so AudacityProject::UpdatePrefs() or any of the routines it calls must
555  // not cause AudacityProject::RebuildMenuBar() to be executed.
556  for (size_t i = 0; i < gAudacityProjects.size(); i++) {
557  gAudacityProjects[i]->UpdatePrefs();
558  }
559 
562 
563  if( IsModal() )
564  EndModal(true);
565  else
566  Destroy();
567 }
virtual void SavePreferredPage()=0
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void StopStream()
Stop recording, playback or input monitoring.
Definition: AudioIO.cpp:2562
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
void ApplyUpdatedImages() override
Definition: Theme.cpp:250
AProjectArray gAudacityProjects
Definition: Project.cpp:303
void RecordExpansionState()
static WaveformSettings & defaults()
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
wxTreebook * mCategories
Definition: PrefsDialog.h:85
virtual bool Commit()=0
void HandleDeviceChange()
update state after changing what audio devices are selected
Definition: AudioIO.cpp:1426
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
bool IsMonitoring()
Returns true if we're monitoring input (but not recording or playing actual audio) ...
Definition: AudioIO.cpp:2914
static bool LoadPreferredTheme()
Definition: Theme.cpp:237
virtual void Preview()
Definition: PrefsPanel.h:58
static SpectrogramSettings & defaults()
void PrefsDialog::OnPreview ( wxCommandEvent &  e)

Definition at line 433 of file PrefsDialog.cpp.

References GetCurrentPanel(), and PrefsPanel::Preview().

434 {
436 }
PrefsPanel * GetCurrentPanel()
virtual void Preview()
Definition: PrefsPanel.h:58
void PrefsDialog::OnTreeKeyDown ( wxTreeEvent &  e)

Definition at line 468 of file PrefsDialog.cpp.

References OnOK().

469 {
470  if(event.GetKeyCode() == WXK_RETURN)
471  OnOK(event);
472  else
473  event.Skip(); // Ensure standard behavior when enter is not pressed
474 }
void OnOK(wxCommandEvent &e)
void PrefsDialog::RecordExpansionState ( )
private

Definition at line 612 of file PrefsDialog.cpp.

References mCategories, and mFactories.

Referenced by OnCancel(), and OnOK().

613 {
614  // Remember expansion state of the tree control
615  if (mCategories)
616  {
617  int iPage = 0;
618  for (Factories::iterator it = mFactories.begin(), end = mFactories.end();
619  it != end; ++it, ++iPage)
620  it->expanded = mCategories->IsNodeExpanded(iPage);
621  }
622  else
623  mFactories[0].expanded = true;
624 }
Factories & mFactories
Definition: PrefsDialog.h:87
wxTreebook * mCategories
Definition: PrefsDialog.h:85
virtual void PrefsDialog::SavePreferredPage ( )
protectedpure virtual

Implemented in GlobalPrefsDialog.

Referenced by OnOK().

void PrefsDialog::SelectPageByName ( const wxString &  pageName)

Definition at line 569 of file PrefsDialog.cpp.

References mCategories.

570 {
571  if (mCategories) {
572  size_t n = mCategories->GetPageCount();
573 
574  for (size_t i = 0; i < n; i++) {
575  if (mCategories->GetPageText(i) == pageName) {
576  mCategories->SetSelection(i);
577  return;
578  }
579  }
580  }
581 }
wxTreebook * mCategories
Definition: PrefsDialog.h:85
int PrefsDialog::ShowModal ( )
override

Definition at line 377 of file PrefsDialog.cpp.

References GetPreferredPage(), mCategories, mTitlePrefix, and mUniquePage.

Referenced by CommandManager::HandleMenuID(), AudacityApp::InitTempDir(), AudacityApp::OnMenuPreferences(), and AudacityProject::OnPreferences().

378 {
379  if (mCategories) {
380  /* long is signed, size_t is unsigned. On some platforms they are different
381  * lengths as well. So we must check that the stored category is both > 0
382  * and within the possible range of categories, making the first check on the
383  * _signed_ value to avoid issues when converting an unsigned one.
384  */
385  long selected = GetPreferredPage();
386  if (selected < 0 || size_t(selected) >= mCategories->GetPageCount())
387  selected = 0; // clamp to available range of tabs
388  mCategories->SetSelection(selected);
389  }
390  else {
391  wxString Temp = mTitlePrefix + mUniquePage->GetLabel();
392  SetTitle(Temp);
393  SetName(Temp);
394  }
395 
396  return wxDialogWrapper::ShowModal();
397 }
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
wxTreebook * mCategories
Definition: PrefsDialog.h:85
virtual long GetPreferredPage()=0
const wxString mTitlePrefix
Definition: PrefsDialog.h:88
void PrefsDialog::ShuttleAll ( ShuttleGui S)

Definition at line 451 of file PrefsDialog.cpp.

References mCategories, mUniquePage, PrefsPanel::PopulateOrExchange(), and ShuttleGuiBase::ResetId().

452 {
453  // Validate all pages first
454  if (mCategories) {
455  for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
456  S.ResetId();
457  PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i);
458  panel->PopulateOrExchange( S );
459  }
460  }
461  else
462  {
463  S.ResetId();
465  }
466 }
PrefsPanel * mUniquePage
Definition: PrefsDialog.h:86
wxTreebook * mCategories
Definition: PrefsDialog.h:85
virtual void PopulateOrExchange(ShuttleGui &WXUNUSED(S))
Definition: PrefsPanel.h:64
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45

Member Data Documentation

wxTreebook* PrefsDialog::mCategories {}
private
Factories& PrefsDialog::mFactories
private

Definition at line 87 of file PrefsDialog.h.

Referenced by RecordExpansionState().

const wxString PrefsDialog::mTitlePrefix
private

Definition at line 88 of file PrefsDialog.h.

Referenced by ShowModal().

PrefsPanel* PrefsDialog::mUniquePage {}
private

Definition at line 86 of file PrefsDialog.h.

Referenced by GetCurrentPanel(), OnCancel(), OnOK(), ShowModal(), and ShuttleAll().


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