Audacity  2.2.2
GUIPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  GUIPrefs.cpp
6 
7  Brian Gunlogson
8  Joshua Haberman
9  Dominic Mazzoni
10  James Crook
11 
12 
13 *******************************************************************//*******************************************************************/
19 
20 #include "../Audacity.h"
21 #include "GUIPrefs.h"
22 
23 #include <wx/defs.h>
24 
25 #include "../AudacityApp.h"
26 #include "../Languages.h"
27 #include "../Theme.h"
28 #include "../Prefs.h"
29 #include "../ShuttleGui.h"
30 
31 #include "GUISettings.h"
32 
33 #include "../Experimental.h"
34 
35 #include "ThemePrefs.h"
36 #include "../AColor.h"
37 #include "../Internat.h"
38 
39 GUIPrefs::GUIPrefs(wxWindow * parent)
40 /* i18n-hint: refers to Audacity's user interface settings */
41 : PrefsPanel(parent, _("Interface"))
42 {
43  Populate();
44 }
45 
47 {
48 }
49 
50 void GUIPrefs::GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
51 {
52  if (pCodes) {
53  wxArrayString &codes = *pCodes;
54  codes.Clear();
55  codes.Add(wxT("36"));
56  codes.Add(wxT("48"));
57  codes.Add(wxT("60"));
58  codes.Add(wxT("72"));
59  codes.Add(wxT("84"));
60  codes.Add(wxT("96"));
61  codes.Add(wxT("120"));
62  codes.Add(wxT("145"));
63  }
64 
65  if (pChoices) {
66  wxArrayString &choices = *pChoices;
67  choices.Clear();
68  choices.Add(_("-36 dB (shallow range for high-amplitude editing)"));
69  choices.Add(_("-48 dB (PCM range of 8 bit samples)"));
70  choices.Add(_("-60 dB (PCM range of 10 bit samples)"));
71  choices.Add(_("-72 dB (PCM range of 12 bit samples)"));
72  choices.Add(_("-84 dB (PCM range of 14 bit samples)"));
73  choices.Add(_("-96 dB (PCM range of 16 bit samples)"));
74  choices.Add(_("-120 dB (approximate limit of human hearing)"));
75  choices.Add(_("-145 dB (PCM range of 24 bit samples)"));
76  }
77 }
78 
80 {
81  // First any pre-processing for constructing the GUI.
83 
84  mHtmlHelpCodes.Add(wxT("Local"));
85  mHtmlHelpCodes.Add(wxT("FromInternet"));
86 
87  mHtmlHelpChoices.Add(_("Local"));
88  mHtmlHelpChoices.Add(_("From Internet"));
89 
90  mThemeCodes.Add( wxT("classic") );
91  mThemeCodes.Add( wxT("light") );
92  mThemeCodes.Add( wxT("dark") );
93  mThemeCodes.Add( wxT("high-contrast") );
94  mThemeCodes.Add( wxT("custom") );
95 
96  /* i18n-hint: describing the "classic" or traditional appearance of older versions of Audacity */
97  mThemeChoices.Add( _("Classic") );
98  /* i18n-hint: Light meaning opposite of dark */
99  mThemeChoices.Add( _("Light") );
100  mThemeChoices.Add( _("Dark") );
101  /* i18n-hint: greater difference between foreground and background colors */
102  mThemeChoices.Add( _("High Contrast") );
103  /* i18n-hint: user defined */
104  mThemeChoices.Add( _("Custom") );
105 
107 
108 #if 0
109  // only for testing...
110  mLangCodes.Add("kg"); mLangNames.Add("Klingon");
111  mLangCodes.Add("ep"); mLangNames.Add("Esperanto");
112 #endif
113 
114  //------------------------- Main section --------------------
115  // Now construct the GUI itself.
116  // Use 'eIsCreatingFromPrefs' so that the GUI is
117  // initialised with values from gPrefs.
120  // ----------------------- End of main section --------------
121 }
122 
124 {
125  S.SetBorder(2);
126  S.StartScroller();
127 
128  S.StartStatic(_("Display"));
129  {
130  S.StartMultiColumn(2);
131  {
132 
133 #ifdef EXPERIMENTAL_DA
134  const wxString defaultTheme = wxT("dark");
135 #else
136  const wxString defaultTheme = wxT("light");
137 #endif
138  const wxString defaultRange = wxString::Format(wxT("%d"), ENV_DB_RANGE);
139 
140  S.TieChoice(_("&Language:"),
141  wxT("/Locale/Language"),
142  wxT(""),
143  mLangNames,
144  mLangCodes);
146 
147  S.TieChoice(_("Location of &Manual:"),
148  wxT("/GUI/Help"),
149  wxT("Local"),
153 
154  S.TieChoice(_("Th&eme:"),
155  wxT("/GUI/Theme"),
156  defaultTheme,
158  mThemeCodes);
160 
161  S.TieChoice(_("Meter dB &range:"),
162  ENV_DB_KEY,
163  defaultRange,
165  mRangeCodes);
167  }
168  S.EndMultiColumn();
169 // S.AddSpace(10);
170 // JKC: This is a silly preference. Kept here as a reminder that we may
171 // later want to have configurable button order.
172 // S.TieCheckBox(_("&Ergonomic order of Transport Toolbar buttons"),
173 // wxT("/GUI/ErgonomicTransportButtons"),
174 // true);
175 
176  }
177  S.EndStatic();
178 
179  S.StartStatic(_("Show"));
180  {
181  S.TieCheckBox(_("'How to Get &Help' at launch"),
182  wxT("/GUI/ShowSplashScreen"),
183  true);
184  S.TieCheckBox(_("E&xtra menus"),
185  wxT("/GUI/ShowExtraMenus"),
186  false);
187 #ifdef EXPERIMENTAL_THEME_PREFS
188  // We do not want to make this option mainstream. It's a
189  // convenience for developers.
190  S.TieCheckBox(_("Show alternative &styling (Mac vs PC)"),
191  wxT("/GUI/ShowMac"),
192  false);
193 #endif
194  }
195  S.EndStatic();
196 
197  S.StartStatic(_("Behaviors"));
198  {
199  S.TieCheckBox(_("&Beep on completion of longer activities"),
200  wxT("/GUI/BeepOnCompletion"),
201  false);
202  S.TieCheckBox(_("Re&tain labels if selection snaps to a label"),
203  wxT("/GUI/RetainLabels"),
204  false);
205  S.TieCheckBox(_("B&lend system and Audacity theme"),
206  wxT("/GUI/BlendThemes"),
207  true);
208  }
209  S.EndStatic();
210  S.EndScroller();
211 }
212 
214 {
215  ShuttleGui S(this, eIsSavingToPrefs);
217 
218  // If language has changed, we want to change it now, not on the next reboot.
219  wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
220  wxString usedLang = wxGetApp().InitLang(lang);
221  // Bug 1523: Previously didn't check no-language (=System Language)
222  if (!(lang.empty()) && (lang != usedLang)) {
223  // lang was not usable and is not system language. We got overridden.
224  gPrefs->Write(wxT("/Locale/Language"), usedLang);
225  gPrefs->Flush();
226  }
227 
228  return true;
229 }
230 
232 {
233  return "Interface_Preferences";
234 }
235 
237 {
238  wxASSERT(parent); // to justify safenew
239  return safenew GUIPrefs(parent);
240 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
#define ENV_DB_KEY
Definition: GUISettings.h:15
wxArrayString mLangCodes
Definition: GUIPrefs.h:39
PrefsPanel * Create(wxWindow *parent) override
Definition: GUIPrefs.cpp:236
GUIPrefs(wxWindow *parent)
Definition: GUIPrefs.cpp:39
void EndMultiColumn()
A PrefsPanel for general GUI preferences.
Definition: GUIPrefs.h:25
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
Definition: GUIPrefs.cpp:50
void EndScroller()
Definition: ShuttleGui.cpp:770
wxArrayString mRangeChoices
Definition: GUIPrefs.h:49
#define safenew
Definition: Audacity.h:223
#define ENV_DB_RANGE
Definition: GUISettings.h:16
wxString HelpPageName() override
Definition: GUIPrefs.cpp:231
void SetSizeHints(int minX=-1, int minY=-1)
wxString InitLang(const wxString &lang)
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:733
wxArrayString mThemeCodes
Definition: GUIPrefs.h:45
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:998
void PopulateOrExchange(ShuttleGui &S)
Definition: GUIPrefs.cpp:123
wxArrayString mThemeChoices
Definition: GUIPrefs.h:46
~GUIPrefs()
Definition: GUIPrefs.cpp:46
wxArrayString mHtmlHelpCodes
Definition: GUIPrefs.h:42
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:43
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
Definition: Languages.cpp:132
wxArrayString mLangNames
Definition: GUIPrefs.h:40
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
bool Commit() override
Definition: GUIPrefs.cpp:213
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:701
void Populate()
Definition: GUIPrefs.cpp:79
AudacityApp & wxGetApp()
void SetBorder(int Border)
Definition: ShuttleGui.h:251
wxArrayString mHtmlHelpChoices
Definition: GUIPrefs.h:43
wxArrayString mRangeCodes
Definition: GUIPrefs.h:48