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, wxWindowID winid)
40 /* i18n-hint: refers to Audacity's user interface settings */
41 : PrefsPanel(parent, winid, _("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);
145 
146  S.TieChoice(_("Location of &Manual:"),
147  wxT("/GUI/Help"),
148  wxT("Local"),
151 
152  S.TieChoice(_("Th&eme:"),
153  wxT("/GUI/Theme"),
154  defaultTheme,
156  mThemeCodes);
157 
158  S.TieChoice(_("Meter dB &range:"),
159  ENV_DB_KEY,
160  defaultRange,
162  mRangeCodes);
163  }
164  S.EndMultiColumn();
165 // S.AddSpace(10);
166 // JKC: This is a silly preference. Kept here as a reminder that we may
167 // later want to have configurable button order.
168 // S.TieCheckBox(_("&Ergonomic order of Transport Toolbar buttons"),
169 // wxT("/GUI/ErgonomicTransportButtons"),
170 // true);
171 
172  }
173  S.EndStatic();
174 
175  S.StartStatic(_("Options"));
176  {
177  // Start wording of options with a verb, if possible.
178  S.TieCheckBox(_("Show 'How to Get &Help' at launch"),
179  wxT("/GUI/ShowSplashScreen"),
180  true);
181  S.TieCheckBox(_("Show e&xtra menus"),
182  wxT("/GUI/ShowExtraMenus"),
183  false);
184 #ifdef EXPERIMENTAL_THEME_PREFS
185  // We do not want to make this option mainstream. It's a
186  // convenience for developers.
187  S.TieCheckBox(_("Show alternative &styling (Mac vs PC)"),
188  wxT("/GUI/ShowMac"),
189  false);
190 #endif
191  S.TieCheckBox(_("&Beep on completion of longer activities"),
192  wxT("/GUI/BeepOnCompletion"),
193  false);
194  S.TieCheckBox(_("Re&tain labels if selection snaps to a label"),
195  wxT("/GUI/RetainLabels"),
196  false);
197  S.TieCheckBox(_("B&lend system and Audacity theme"),
198  wxT("/GUI/BlendThemes"),
199  true);
200  }
201  S.EndStatic();
202 
203  S.EndScroller();
204 }
205 
207 {
208  ShuttleGui S(this, eIsSavingToPrefs);
210 
211  // If language has changed, we want to change it now, not on the next reboot.
212  wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
213  wxString usedLang = wxGetApp().InitLang(lang);
214  // Bug 1523: Previously didn't check no-language (=System Language)
215  if (!(lang.empty()) && (lang != usedLang)) {
216  // lang was not usable and is not system language. We got overridden.
217  gPrefs->Write(wxT("/Locale/Language"), usedLang);
218  gPrefs->Flush();
219  }
220 
221  return true;
222 }
223 
225 {
226  return "Interface_Preferences";
227 }
228 
229 PrefsPanel *GUIPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
230 {
231  wxASSERT(parent); // to justify safenew
232  return safenew GUIPrefs(parent, winid);
233 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
#define ENV_DB_KEY
Definition: GUISettings.h:15
wxArrayString mLangCodes
Definition: GUIPrefs.h:39
void PopulateOrExchange(ShuttleGui &S) override
Definition: GUIPrefs.cpp:123
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:828
wxArrayString mRangeChoices
Definition: GUIPrefs.h:49
#define safenew
Definition: Audacity.h:230
#define ENV_DB_RANGE
Definition: GUISettings.h:16
GUIPrefs(wxWindow *parent, wxWindowID winid)
Definition: GUIPrefs.cpp:39
wxString HelpPageName() override
Definition: GUIPrefs.cpp:224
wxString InitLang(const wxString &lang)
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
wxArrayString mThemeCodes
Definition: GUIPrefs.h:45
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
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:45
_("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
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
Definition: Languages.cpp:130
wxArrayString mLangNames
Definition: GUIPrefs.h:40
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
bool Commit() override
Definition: GUIPrefs.cpp:206
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
void Populate()
Definition: GUIPrefs.cpp:79
AudacityApp & wxGetApp()
void SetBorder(int Border)
Definition: ShuttleGui.h:286
PrefsPanel * operator()(wxWindow *parent, wxWindowID winid) override
Definition: GUIPrefs.cpp:229
wxArrayString mHtmlHelpChoices
Definition: GUIPrefs.h:43
wxArrayString mRangeCodes
Definition: GUIPrefs.h:48