mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 09:01:13 +02:00
Some preliminary changes to PrefsDialog, for View Settings project
This commit is contained in:
commit
d71c7ae0a9
@ -92,6 +92,7 @@ It handles initialization and termination by subclassing wxApp.
|
||||
#include "ondemand/ODManager.h"
|
||||
#include "commands/Keyboard.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "prefs/DirectoriesPrefs.h"
|
||||
|
||||
//temporarilly commented out till it is added to all projects
|
||||
//#include "Profiler.h"
|
||||
@ -1605,8 +1606,11 @@ bool AudacityApp::InitTempDir()
|
||||
// Failed
|
||||
wxMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
|
||||
|
||||
PrefsDialog dialog(NULL);
|
||||
dialog.ShowTempDirPage();
|
||||
// Only want one page of the preferences
|
||||
DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(&directoriesPrefsFactory);
|
||||
GlobalPrefsDialog dialog(NULL, factories);
|
||||
dialog.ShowModal();
|
||||
|
||||
wxMessageBox(_("Audacity is now going to exit. Please launch Audacity again to use the new temporary directory."));
|
||||
@ -2132,7 +2136,7 @@ void AudacityApp::OnMenuPreferences(wxCommandEvent & event)
|
||||
// all platforms.
|
||||
|
||||
if(gAudacityProjects.GetCount() == 0) {
|
||||
PrefsDialog dialog(NULL /* parent */ );
|
||||
GlobalPrefsDialog dialog(NULL /* parent */ );
|
||||
dialog.ShowModal();
|
||||
}
|
||||
else
|
||||
|
@ -101,7 +101,6 @@
|
||||
#include "widgets/Warning.h"
|
||||
#include "widgets/MultiDialog.h"
|
||||
|
||||
#include "prefs/PrefsDialog.h"
|
||||
#include "ondemand/ODManager.h"
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
|
@ -3586,7 +3586,7 @@ void AudacityProject::OnExportMultiple()
|
||||
|
||||
void AudacityProject::OnPreferences()
|
||||
{
|
||||
PrefsDialog dialog(this /* parent */ );
|
||||
GlobalPrefsDialog dialog(this /* parent */ );
|
||||
|
||||
if (!dialog.ShowModal()) {
|
||||
// Canceled
|
||||
|
@ -82,3 +82,8 @@ bool BatchPrefs::Apply()
|
||||
BatchPrefs::~BatchPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *BatchPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new BatchPrefs(parent);
|
||||
}
|
||||
|
@ -34,4 +34,9 @@ private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class BatchPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -373,3 +373,8 @@ bool DevicePrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *DevicePrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new DevicePrefs(parent);
|
||||
}
|
||||
|
@ -54,4 +54,10 @@ class DevicePrefs :public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class DevicePrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -242,3 +242,8 @@ bool DirectoriesPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *DirectoriesPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new DirectoriesPrefs(parent);
|
||||
}
|
||||
|
@ -38,4 +38,9 @@ class DirectoriesPrefs :public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class DirectoriesPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -165,3 +165,8 @@ bool EffectsPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *EffectsPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new EffectsPrefs(parent);
|
||||
}
|
||||
|
@ -34,4 +34,9 @@ class EffectsPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class EffectsPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -780,3 +780,8 @@ void ExtImportPrefsDropTarget::SetDataObject(wxDataObject* data)
|
||||
{
|
||||
this->m_dataObject = data;
|
||||
}
|
||||
|
||||
PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new ExtImportPrefs(parent);
|
||||
}
|
||||
|
@ -107,4 +107,10 @@ class ExtImportPrefs:public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
class ExtImportPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -158,3 +158,8 @@ bool GUIPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *GUIPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new GUIPrefs(parent);
|
||||
}
|
||||
|
@ -43,4 +43,9 @@ class GUIPrefs :public PrefsPanel
|
||||
wxArrayString mRangeChoices;
|
||||
};
|
||||
|
||||
class GUIPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -109,3 +109,8 @@ bool ImportExportPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ImportExportPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new ImportExportPrefs(parent);
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ class ImportExportPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class ImportExportPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -1211,3 +1211,8 @@ void KeyConfigPrefs::Cancel()
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new KeyConfigPrefs(parent);
|
||||
}
|
||||
|
@ -141,6 +141,12 @@ class KeyConfigPrefs:public PrefsPanel
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
class KeyConfigPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -235,3 +235,8 @@ bool LibraryPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *LibraryPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new LibraryPrefs(parent);
|
||||
}
|
||||
|
@ -46,4 +46,9 @@ class LibraryPrefs :public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class LibraryPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -284,4 +284,9 @@ bool MidiIOPrefs::Validate()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *MidiIOPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new MidiIOPrefs(parent);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -62,6 +62,11 @@ class MidiIOPrefs:public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class MidiIOPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -161,5 +161,9 @@ void ModulePrefs::SetModuleStatus( wxString fname, int iStatus ){
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
PrefsPanel *ModulePrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new ModulePrefs(parent);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,4 +50,9 @@ class ModulePrefs:public PrefsPanel
|
||||
wxArrayString mPaths;
|
||||
};
|
||||
|
||||
class ModulePrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -196,3 +196,8 @@ bool MousePrefs::Apply()
|
||||
// PopulateOrExchange(S);
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *MousePrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new MousePrefs(parent);
|
||||
}
|
||||
|
@ -38,4 +38,9 @@ class MousePrefs :public PrefsPanel
|
||||
wxListCtrl * mList;
|
||||
};
|
||||
|
||||
class MousePrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -122,3 +122,8 @@ bool PlaybackPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *PlaybackPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new PlaybackPrefs(parent);
|
||||
}
|
||||
|
@ -32,4 +32,10 @@ class PlaybackPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class PlaybackPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "../Audacity.h"
|
||||
#include "PrefsDialog.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/button.h>
|
||||
@ -41,7 +42,6 @@
|
||||
#include "../Prefs.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
||||
#include "PrefsDialog.h"
|
||||
#include "PrefsPanel.h"
|
||||
|
||||
#include "BatchPrefs.h"
|
||||
@ -81,11 +81,14 @@ class wxTreebookExt : public wxTreebook
|
||||
{
|
||||
public:
|
||||
wxTreebookExt( wxWindow *parent,
|
||||
wxWindowID id) : wxTreebook( parent, id )
|
||||
wxWindowID id, const wxString &titlePrefix)
|
||||
: wxTreebook( parent, id )
|
||||
, mTitlePrefix(titlePrefix)
|
||||
{;};
|
||||
~wxTreebookExt(){;};
|
||||
virtual int ChangeSelection(size_t n);
|
||||
virtual int SetSelection(size_t n);
|
||||
const wxString mTitlePrefix;
|
||||
};
|
||||
|
||||
|
||||
@ -100,7 +103,7 @@ int wxTreebookExt::ChangeSelection(size_t n) {
|
||||
int wxTreebookExt::SetSelection(size_t n)
|
||||
{
|
||||
int i = wxTreebook::SetSelection(n);
|
||||
wxString Temp = wxString(_("Preferences: ")) + GetPageText( n );
|
||||
wxString Temp = wxString(mTitlePrefix) + GetPageText( n );
|
||||
((wxDialog*)GetParent())->SetTitle( Temp );
|
||||
((wxDialog*)GetParent())->SetName( Temp );
|
||||
return i;
|
||||
@ -108,11 +111,84 @@ int wxTreebookExt::SetSelection(size_t n)
|
||||
|
||||
|
||||
|
||||
PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
PrefsDialog::Factories
|
||||
&PrefsDialog::DefaultFactories()
|
||||
{
|
||||
// To do, perhaps: create this table by registration, without including each PrefsPanel
|
||||
// class... and thus allowing a plug-in protocol
|
||||
static DevicePrefsFactory devicePrefsFactory;
|
||||
static PlaybackPrefsFactory playbackPrefsFactory;
|
||||
static RecordingPrefsFactory recordingPrefsFactory;
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
static MidiIOPrefsFactory midiIOPrefsFactory;
|
||||
#endif
|
||||
static QualityPrefsFactory qualityPrefsFactory;
|
||||
static GUIPrefsFactory guiPrefsFactory;
|
||||
static TracksPrefsFactory tracksPrefsFactory;
|
||||
static ImportExportPrefsFactory importExportPrefsFactory;
|
||||
static ExtImportPrefsFactory extImportPrefsFactory;
|
||||
static ProjectsPrefsFactory projectsPrefsFactory;
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
static LibraryPrefsFactory libraryPrefsFactory;
|
||||
#endif
|
||||
static SpectrumPrefsFactory spectrumPrefsFactory;
|
||||
static DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
static WarningsPrefsFactory warningsPrefsFactory;
|
||||
static EffectsPrefsFactory effectsPrefsFactory;
|
||||
#ifdef EXPERIMENTAL_THEME_PREFS
|
||||
static ThemePrefsFactory themePrefsFactory;
|
||||
#endif
|
||||
// static BatchPrefsFactory batchPrefsFactory;
|
||||
static KeyConfigPrefsFactory keyConfigPrefsFactory;
|
||||
static MousePrefsFactory mousePrefsFactory;
|
||||
#ifdef EXPERIMENTAL_MODULE_PREFS
|
||||
static ModulePrefsFactory modulePrefsFactory;
|
||||
#endif
|
||||
|
||||
static PrefsNode nodes[] = {
|
||||
&devicePrefsFactory,
|
||||
&playbackPrefsFactory,
|
||||
&recordingPrefsFactory,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
&midiIOPrefsFactory,
|
||||
#endif
|
||||
&qualityPrefsFactory,
|
||||
&guiPrefsFactory,
|
||||
&tracksPrefsFactory,
|
||||
&importExportPrefsFactory,
|
||||
&extImportPrefsFactory,
|
||||
&projectsPrefsFactory,
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
&libraryPrefsFactory,
|
||||
#endif
|
||||
&spectrumPrefsFactory,
|
||||
&directoriesPrefsFactory,
|
||||
&warningsPrefsFactory,
|
||||
&effectsPrefsFactory,
|
||||
#ifdef EXPERIMENTAL_THEME_PREFS
|
||||
&themePrefsFactory,
|
||||
#endif
|
||||
// &batchPrefsFactory,
|
||||
&keyConfigPrefsFactory,
|
||||
&mousePrefsFactory,
|
||||
#ifdef EXPERIMENTAL_MODULE_PREFS
|
||||
&modulePrefsFactory,
|
||||
#endif
|
||||
};
|
||||
|
||||
static Factories factories(nodes, nodes + sizeof(nodes) / sizeof(nodes[0]));
|
||||
return factories;
|
||||
}
|
||||
|
||||
|
||||
PrefsDialog::PrefsDialog
|
||||
(wxWindow * parent, const wxString &titlePrefix, Factories &factories)
|
||||
: wxDialog(parent, wxID_ANY, wxString(_("Audacity Preferences")),
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, mFactories(factories)
|
||||
, mTitlePrefix(titlePrefix)
|
||||
{
|
||||
ShuttleGui S(this, eIsCreating);
|
||||
|
||||
@ -120,42 +196,36 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
{
|
||||
S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true);
|
||||
{
|
||||
mCategories = new wxTreebookExt(this, wxID_ANY);
|
||||
mCategories = new wxTreebookExt(this, wxID_ANY, mTitlePrefix);
|
||||
S.Prop(1);
|
||||
S.AddWindow(mCategories, wxEXPAND);
|
||||
|
||||
wxWindow *w;
|
||||
// Parameters are: AddPage(page, name, IsSelected, imageId).
|
||||
w = new DevicePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new PlaybackPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new RecordingPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
w = new MidiIOPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#endif
|
||||
w = new QualityPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new GUIPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new TracksPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ExtImportPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new ProjectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
w = new LibraryPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#endif
|
||||
w = new SpectrumPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new DirectoriesPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new WarningsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new EffectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
|
||||
#ifdef EXPERIMENTAL_THEME_PREFS
|
||||
w = new ThemePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#endif
|
||||
|
||||
// w = new BatchPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new KeyConfigPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
w = new MousePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#ifdef EXPERIMENTAL_MODULE_PREFS
|
||||
w = new ModulePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
#endif
|
||||
{
|
||||
typedef std::pair<int, int> IntPair;
|
||||
std::vector<IntPair> stack;
|
||||
int iPage = 0;
|
||||
for (Factories::const_iterator it = factories.begin(), end = factories.end();
|
||||
it != end; ++it, ++iPage)
|
||||
{
|
||||
const PrefsNode &node = *it;
|
||||
PrefsPanelFactory &factory = *node.pFactory;
|
||||
wxWindow *const w = factory.Create(mCategories);
|
||||
if (stack.empty())
|
||||
// Parameters are: AddPage(page, name, IsSelected, imageId).
|
||||
mCategories->AddPage(w, w->GetName(), false, 0);
|
||||
else {
|
||||
IntPair &top = *stack.rbegin();
|
||||
mCategories->InsertSubPage(top.first, w, w->GetName(), false, 0);
|
||||
if (--top.second == 0) {
|
||||
// Expand all nodes before the layout calculation
|
||||
mCategories->ExpandNode(top.first, true);
|
||||
stack.pop_back();
|
||||
}
|
||||
}
|
||||
if (node.nChildren > 0)
|
||||
stack.push_back(IntPair(iPage, node.nChildren));
|
||||
}
|
||||
}
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
@ -163,23 +233,6 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
|
||||
S.AddStandardButtons(eOkButton | eCancelButton);
|
||||
|
||||
/* long is signed, size_t is unsigned. On some platforms they are different
|
||||
* lengths as well. So we must check that the stored category is both > 0
|
||||
* and within the possible range of categories, making the first check on the
|
||||
* _signed_ value to avoid issues when converting an unsigned one.
|
||||
*/
|
||||
size_t selected;
|
||||
long prefscat = gPrefs->Read(wxT("/Prefs/PrefsCategory"), 0L);
|
||||
if (prefscat > 0L )
|
||||
selected = prefscat; // only assign if number will fit
|
||||
else
|
||||
selected = 0; // use 0 if value can't be assigned
|
||||
|
||||
if (selected >= mCategories->GetPageCount())
|
||||
selected = 0; // clamp to available range of tabs
|
||||
|
||||
mCategories->SetSelection(selected);
|
||||
|
||||
#if defined(__WXGTK__)
|
||||
mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
|
||||
#endif
|
||||
@ -189,6 +242,14 @@ PrefsDialog::PrefsDialog(wxWindow * parent)
|
||||
Fit();
|
||||
wxSize sz = GetSize();
|
||||
|
||||
// Collapse nodes only after layout so the tree is wide enough
|
||||
{
|
||||
int iPage = 0;
|
||||
for (Factories::const_iterator it = factories.begin(), end = factories.end();
|
||||
it != end; ++it, ++iPage)
|
||||
mCategories->ExpandNode(iPage, it->expanded);
|
||||
}
|
||||
|
||||
// This ASSERT used to limit us to 800 x 600.
|
||||
// However, we think screens have got bigger now, and that was a bit too restrictive.
|
||||
// The impetus for increasing the limit (before we ASSERT) was that this ASSERT
|
||||
@ -219,8 +280,25 @@ PrefsDialog::~PrefsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
int PrefsDialog::ShowModal()
|
||||
{
|
||||
/* long is signed, size_t is unsigned. On some platforms they are different
|
||||
* lengths as well. So we must check that the stored category is both > 0
|
||||
* and within the possible range of categories, making the first check on the
|
||||
* _signed_ value to avoid issues when converting an unsigned one.
|
||||
*/
|
||||
long selected = GetPreferredPage();
|
||||
if (selected < 0 || size_t(selected) >= mCategories->GetPageCount())
|
||||
selected = 0; // clamp to available range of tabs
|
||||
mCategories->SetSelection(selected);
|
||||
|
||||
return wxDialog::ShowModal();
|
||||
}
|
||||
|
||||
void PrefsDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
RecordExpansionState();
|
||||
|
||||
for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
|
||||
((PrefsPanel *) mCategories->GetPage(i))->Cancel();
|
||||
}
|
||||
@ -238,6 +316,8 @@ void PrefsDialog::OnTreeKeyDown(wxTreeEvent & event)
|
||||
|
||||
void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
RecordExpansionState();
|
||||
|
||||
// Validate all pages first
|
||||
for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
|
||||
PrefsPanel *panel = (PrefsPanel *) mCategories->GetPage(i);
|
||||
@ -256,8 +336,7 @@ void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
|
||||
panel->Apply();
|
||||
}
|
||||
|
||||
gPrefs->Write(wxT("/Prefs/PrefsCategory"), (long)mCategories->GetSelection());
|
||||
gPrefs->Flush();
|
||||
SavePreferredPage();
|
||||
|
||||
#if USE_PORTMIXER
|
||||
if (gAudioIO) {
|
||||
@ -307,7 +386,39 @@ void PrefsDialog::SelectPageByName(wxString pageName)
|
||||
}
|
||||
}
|
||||
|
||||
void PrefsDialog::ShowTempDirPage()
|
||||
int PrefsDialog::GetSelectedPage() const
|
||||
{
|
||||
SelectPageByName(_("Directories"));
|
||||
return mCategories->GetSelection();
|
||||
}
|
||||
|
||||
GlobalPrefsDialog::GlobalPrefsDialog(wxWindow * parent, Factories &factories)
|
||||
: PrefsDialog(parent, _("Preferences: "), factories)
|
||||
{
|
||||
}
|
||||
|
||||
GlobalPrefsDialog::~GlobalPrefsDialog()
|
||||
{
|
||||
}
|
||||
|
||||
long GlobalPrefsDialog::GetPreferredPage()
|
||||
{
|
||||
long prefscat = gPrefs->Read(wxT("/Prefs/PrefsCategory"), 0L);
|
||||
return prefscat;
|
||||
}
|
||||
|
||||
void GlobalPrefsDialog::SavePreferredPage()
|
||||
{
|
||||
gPrefs->Write(wxT("/Prefs/PrefsCategory"), (long)GetSelectedPage());
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
void PrefsDialog::RecordExpansionState()
|
||||
{
|
||||
// Remember expansion state of the tree control
|
||||
{
|
||||
int iPage = 0;
|
||||
for (Factories::iterator it = mFactories.begin(), end = mFactories.end();
|
||||
it != end; ++it, ++iPage)
|
||||
it->expanded = mCategories->IsNodeExpanded(iPage);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef __AUDACITY_PREFS_DIALOG__
|
||||
#define __AUDACITY_PREFS_DIALOG__
|
||||
|
||||
#include <vector>
|
||||
#include <wx/button.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/dialog.h>
|
||||
@ -19,24 +20,74 @@
|
||||
#include <wx/treebook.h>
|
||||
#include <wx/window.h>
|
||||
|
||||
class PrefsPanelFactory;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CONST
|
||||
#else
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
class PrefsDialog:public wxDialog
|
||||
{
|
||||
public:
|
||||
PrefsDialog(wxWindow * parent);
|
||||
// An array of PrefsNode specifies the tree of pages in pre-order traversal.
|
||||
struct PrefsNode {
|
||||
PrefsPanelFactory * CONST pFactory;
|
||||
CONST int nChildren;
|
||||
bool expanded;
|
||||
|
||||
PrefsNode(PrefsPanelFactory *pFactory_, int nChildren_ = 0)
|
||||
: pFactory(pFactory_), nChildren(nChildren_), expanded(false)
|
||||
{}
|
||||
};
|
||||
typedef std::vector<PrefsNode> Factories;
|
||||
static Factories &DefaultFactories();
|
||||
|
||||
PrefsDialog(wxWindow * parent,
|
||||
const wxString &titlePrefix = _("Preferences: "),
|
||||
Factories &factories = DefaultFactories());
|
||||
virtual ~PrefsDialog();
|
||||
|
||||
// Defined this so a protected virtual can be invoked after the constructor
|
||||
virtual int ShowModal();
|
||||
|
||||
void OnCategoryChange(wxCommandEvent & e);
|
||||
void OnOK(wxCommandEvent & e);
|
||||
void OnCancel(wxCommandEvent & e);
|
||||
void OnTreeKeyDown(wxTreeEvent & e); // Used to dismiss the dialog when enter is pressed with focus on tree
|
||||
|
||||
void SelectPageByName(wxString pageName);
|
||||
void ShowTempDirPage();
|
||||
|
||||
private:
|
||||
// Accessor to help implementations of SavePreferredPage(),
|
||||
// such as by saving a preference after DoModal() returns
|
||||
int GetSelectedPage() const;
|
||||
|
||||
protected:
|
||||
// Decide which page to open first; return -1 for undecided
|
||||
virtual long GetPreferredPage() = 0;
|
||||
|
||||
// Called after OK is clicked and all pages validate
|
||||
virtual void SavePreferredPage() = 0;
|
||||
|
||||
private:
|
||||
void RecordExpansionState();
|
||||
wxTreebook *mCategories;
|
||||
Factories &mFactories;
|
||||
const wxString mTitlePrefix;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// This adds code appropriate only to the original use of PrefsDialog for
|
||||
// global settings -- not its reuses elsewhere as in View Settings
|
||||
class GlobalPrefsDialog : public PrefsDialog
|
||||
{
|
||||
public:
|
||||
GlobalPrefsDialog(wxWindow * parent, Factories &factories = DefaultFactories());
|
||||
virtual ~GlobalPrefsDialog();
|
||||
virtual long GetPreferredPage();
|
||||
virtual void SavePreferredPage();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -61,4 +61,10 @@ class PrefsPanel:public wxPanel
|
||||
}
|
||||
};
|
||||
|
||||
class PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -79,3 +79,8 @@ bool ProjectsPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ProjectsPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new ProjectsPrefs(parent);
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ class ProjectsPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class ProjectsPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -228,3 +228,8 @@ bool QualityPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *QualityPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new QualityPrefs(parent);
|
||||
}
|
||||
|
@ -53,4 +53,9 @@ class QualityPrefs :public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class QualityPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -202,3 +202,8 @@ bool RecordingPrefs::Apply()
|
||||
#endif
|
||||
return gPrefs->Flush();
|
||||
}
|
||||
|
||||
PrefsPanel *RecordingPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new RecordingPrefs(parent);
|
||||
}
|
||||
|
@ -32,4 +32,9 @@ class RecordingPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class RecordingPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -342,6 +342,11 @@ BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||
EVT_CHOICE(ID_WINDOW_SIZE, SpectrumPrefs::OnWindowSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new SpectrumPrefs(parent);
|
||||
}
|
||||
|
||||
SpectrogramSettings::SpectrogramSettings()
|
||||
: hFFT(0)
|
||||
, window(0)
|
||||
|
@ -124,4 +124,10 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
class SpectrumPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -205,3 +205,8 @@ bool ThemePrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ThemePrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new ThemePrefs(parent);
|
||||
}
|
||||
|
@ -41,4 +41,9 @@ class ThemePrefs :public PrefsPanel
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
class ThemePrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -165,3 +165,8 @@ bool TracksPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *TracksPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new TracksPrefs(parent);
|
||||
}
|
||||
|
@ -39,4 +39,9 @@ class TracksPrefs :public PrefsPanel
|
||||
wxArrayString mViewChoices;
|
||||
};
|
||||
|
||||
class TracksPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
@ -83,3 +83,8 @@ bool WarningsPrefs::Apply()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *WarningsPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new WarningsPrefs(parent);
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ class WarningsPrefs :public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
};
|
||||
|
||||
class WarningsPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user