Audacity 3.2.0
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
20class AudacityProject;
21class wxTreebook;
22class wxTreeEvent;
24class ShuttleGui;
25
26#ifdef __GNUC__
27#define CONST
28#else
29#define CONST const
30#endif
31
32class AudacityProject;
33
34class AUDACITY_DLL_API PrefsDialog /* not final */ : public wxDialogWrapper
35{
36 public:
37 PrefsDialog(wxWindow * parent,
38 AudacityProject *pProject, // may be null
39 const TranslatableString &titlePrefix = XO("Preferences:"),
40 PrefsPanel::Factories &factories =
42 virtual ~PrefsDialog();
43
44 // Defined this so a protected virtual can be invoked after the constructor
45 int ShowModal() override;
46 void ShuttleAll( ShuttleGui & S);
47
48 void OnCategoryChange(wxCommandEvent & e);
49 void OnOK(wxCommandEvent & e);
50 void OnCancel(wxCommandEvent & e);
51 void OnPreview(wxCommandEvent & e);
52 void OnHelp(wxCommandEvent & e);
53 void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree
54
55 void SelectPageByName(const wxString &pageName);
56
57 // Accessor to help implementations of SavePreferredPage(),
58 // such as by saving a preference after DoModal() returns
59 int GetSelectedPage() const;
60
61 protected:
62 // Decide which page to open first; return -1 for undecided
63 virtual long GetPreferredPage() = 0;
64
65 // Called after OK is clicked and all pages validate
66 virtual void SavePreferredPage() = 0;
67
68private:
69 void RecordExpansionState();
70 PrefsPanel * GetCurrentPanel();
71 wxTreebook *mCategories{};
72 PrefsPanel *mUniquePage{};
75
76 std::unique_ptr< SettingTransaction > mTransaction;
77
78 DECLARE_EVENT_TABLE()
79};
80
81// This adds code appropriate only to the original use of PrefsDialog for
82// global settings -- not its reuses elsewhere as in View Settings
83class AUDACITY_DLL_API GlobalPrefsDialog final : public PrefsDialog
84{
85public:
90 wxWindow * parent, AudacityProject *pProject,
91 PrefsPanel::Factories &factories =
93 virtual ~GlobalPrefsDialog();
94 long GetPreferredPage() override;
95 void SavePreferredPage() override;
96};
97
98class AudacityProject;
99void AUDACITY_DLL_API DoReloadPreferences( AudacityProject &project );
100
101#endif
XO("Cut/Copy/Paste")
void AUDACITY_DLL_API DoReloadPreferences(AudacityProject &project)
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Dialog that shows the current PrefsPanel in a tabbed divider.
Definition: PrefsDialog.h:35
const TranslatableString mTitlePrefix
Definition: PrefsDialog.h:74
void OnCategoryChange(wxCommandEvent &e)
virtual void SavePreferredPage()=0
std::unique_ptr< SettingTransaction > mTransaction
Definition: PrefsDialog.h:76
virtual long GetPreferredPage()=0
PrefsPanel::Factories & mFactories
Definition: PrefsDialog.h:73
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
static Factories & DefaultFactories()
Definition: PrefsPanel.cpp:104
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:69
Extend SettingScope with Commit() which flushes updates in a batch.
Definition: Prefs.h:144
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.
A wxTreebook is a class like wxNotebook, but not yet supported by wxWidgets 2.6.3.