Audacity  3.0.3
PrefsDialog.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  PrefsDialog.h
6 
7  Joshua Haberman
8  James Crook
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_PREFS_DIALOG__
13 #define __AUDACITY_PREFS_DIALOG__
14 
15 #include <functional>
16 #include <vector>
17 #include "../widgets/wxPanelWrapper.h" // to inherit
18 #include "PrefsPanel.h"
19 
20 class AudacityProject;
21 class wxTreebook;
22 class wxTreeEvent;
23 class ShuttleGui;
24 
25 #ifdef __GNUC__
26 #define CONST
27 #else
28 #define CONST const
29 #endif
30 
31 class AudacityProject;
32 
33 class AUDACITY_DLL_API PrefsDialog /* not final */ : public wxDialogWrapper
34 {
35  public:
36  PrefsDialog(wxWindow * parent,
37  AudacityProject *pProject, // may be null
38  const TranslatableString &titlePrefix = XO("Preferences:"),
39  PrefsPanel::Factories &factories =
41  virtual ~PrefsDialog();
42 
43  // Defined this so a protected virtual can be invoked after the constructor
44  int ShowModal() override;
45  void ShuttleAll( ShuttleGui & S);
46 
47  void OnCategoryChange(wxCommandEvent & e);
48  void OnOK(wxCommandEvent & e);
49  void OnCancel(wxCommandEvent & e);
50  void OnPreview(wxCommandEvent & e);
51  void OnHelp(wxCommandEvent & e);
52  void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree
53 
54  void SelectPageByName(const wxString &pageName);
55 
56  // Accessor to help implementations of SavePreferredPage(),
57  // such as by saving a preference after DoModal() returns
58  int GetSelectedPage() const;
59 
60  protected:
61  // Decide which page to open first; return -1 for undecided
62  virtual long GetPreferredPage() = 0;
63 
64  // Called after OK is clicked and all pages validate
65  virtual void SavePreferredPage() = 0;
66 
67 private:
68  void RecordExpansionState();
69  PrefsPanel * GetCurrentPanel();
70  wxTreebook *mCategories{};
71  PrefsPanel *mUniquePage{};
74 
75  DECLARE_EVENT_TABLE()
76 };
77 
78 // This adds code appropriate only to the original use of PrefsDialog for
79 // global settings -- not its reuses elsewhere as in View Settings
80 class AUDACITY_DLL_API GlobalPrefsDialog final : public PrefsDialog
81 {
82 public:
87  wxWindow * parent, AudacityProject *pProject,
88  PrefsPanel::Factories &factories =
90  virtual ~GlobalPrefsDialog();
91  long GetPreferredPage() override;
92  void SavePreferredPage() override;
93 };
94 
95 class AudacityProject;
96 void AUDACITY_DLL_API DoReloadPreferences( AudacityProject &project );
97 
98 #endif
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
PrefsDialog::GetPreferredPage
virtual long GetPreferredPage()=0
PrefsPanel.h
XO
#define XO(s)
Definition: Internat.h:31
DoReloadPreferences
void AUDACITY_DLL_API DoReloadPreferences(AudacityProject &project)
Definition: PrefsDialog.cpp:846
PrefsPanel::DefaultFactories
static Factories & DefaultFactories()
Definition: PrefsPanel.cpp:104
wxDialogWrapper
Definition: wxPanelWrapper.h:81
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
PrefsDialog::mTitlePrefix
const TranslatableString mTitlePrefix
Definition: PrefsDialog.h:73
PrefsDialog
Dialog that shows the current PrefsPanel in a tabbed divider.
Definition: PrefsDialog.h:34
GlobalPrefsDialog
Definition: PrefsDialog.h:81
PrefsPanel
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
PrefsDialog::mFactories
PrefsPanel::Factories & mFactories
Definition: PrefsDialog.h:72
PrefsDialog::OnCategoryChange
void OnCategoryChange(wxCommandEvent &e)
wxTreebook
A wxTreebook is a class like wxNotebook, but not yet supported by wxWidgets 2.6.3.
PrefsDialog::SavePreferredPage
virtual void SavePreferredPage()=0
PrefsPanel::Factories
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:69
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631