{
public:
// Ctor creates an empty editor, use AddPage() to add controls to it.
- wxPreferencesEditor();
+ wxPreferencesEditor(const wxString& title = wxString());
~wxPreferencesEditor();
// Add a new page to the editor. The editor takes ownership of the page
{
public:
// This is implemented in a platform-specific way.
- static wxPreferencesEditorImpl* Create();
+ static wxPreferencesEditorImpl* Create(const wxString& title);
// These methods simply mirror the public wxPreferencesEditor ones.
virtual void AddPage(wxPreferencesPage* page) = 0;
Constructor.
Creates an empty editor, use AddPage() to add controls to it.
+
+ @param title The title overriding the default title of the top level
+ window used by the editor. It is recommended to not specify this
+ parameter to use the native convention for the preferences dialogs
+ instead.
*/
- wxPreferencesEditor();
+ wxPreferencesEditor(const wxString& title = wxString());
/**
Destructor.
return wxString(); // silence compiler warning
}
-wxPreferencesEditor::wxPreferencesEditor()
- : m_impl(wxPreferencesEditorImpl::Create())
+wxPreferencesEditor::wxPreferencesEditor(const wxString& title)
+ : m_impl(wxPreferencesEditorImpl::Create(title))
{
}
#include "wx/scopedptr.h"
#include "wx/vector.h"
+namespace
+{
+
class wxGenericPrefsDialog : public wxDialog
{
public:
- wxGenericPrefsDialog(wxWindow *parent)
- : wxDialog(parent, wxID_ANY, _("Preferences"),
+ wxGenericPrefsDialog(wxWindow *parent, const wxString& title)
+ : wxDialog(parent, wxID_ANY, title,
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX))
{
class wxGenericPreferencesEditorImplBase : public wxPreferencesEditorImpl
{
public:
+ void SetTitle(const wxString& title)
+ {
+ m_title = title;
+ }
+
virtual void AddPage(wxPreferencesPage* page)
{
m_pages.push_back(wxSharedPtr<wxPreferencesPage>(page));
protected:
wxGenericPrefsDialog *CreateDialog(wxWindow *parent)
{
- wxGenericPrefsDialog *dlg = new wxGenericPrefsDialog(parent);
+ if ( m_title.empty() )
+ m_title = _("Preferences");
+
+ wxGenericPrefsDialog *dlg = new wxGenericPrefsDialog(parent, m_title);
// TODO: Don't create all pages immediately like this, do it on demand
// when a page is selected in the notebook (as is done on OS X).
typedef wxVector< wxSharedPtr<wxPreferencesPage> > Pages;
Pages m_pages;
+private:
+ wxString m_title;
};
wxWeakRef<wxWindow> m_win;
};
+inline
+wxGenericPreferencesEditorImplBase* NewGenericImpl()
+{
+ return new wxModelessPreferencesEditorImpl;
+}
+
#else // !wxHAS_PREF_EDITOR_MODELESS
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
int m_currentPage;
};
+inline
+wxGenericPreferencesEditorImplBase* NewGenericImpl()
+{
+ return new wxModalPreferencesEditorImpl;
+}
+
#endif // !wxHAS_PREF_EDITOR_MODELESS
+} // anonymous namespace
/*static*/
-wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create()
+wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create(const wxString& title)
{
-#ifdef wxHAS_PREF_EDITOR_MODELESS
- return new wxModelessPreferencesEditorImpl();
-#else
- return new wxModalPreferencesEditorImpl();
-#endif
+ wxGenericPreferencesEditorImplBase* const impl = NewGenericImpl();
+
+ impl->SetTitle(title);
+
+ return impl;
}
#endif // !wxHAS_PREF_EDITOR_NATIVE
class wxCocoaPrefsWindow : public wxFrame
{
public:
- wxCocoaPrefsWindow()
- : wxFrame(NULL, wxID_ANY, _("Preferences"),
+ wxCocoaPrefsWindow(const wxString& title)
+ : wxFrame(NULL, wxID_ANY, title,
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)),
m_toolbarRealized(false),
class wxCocoaPreferencesEditorImpl : public wxPreferencesEditorImpl
{
public:
- wxCocoaPreferencesEditorImpl() : m_win(NULL)
+ wxCocoaPreferencesEditorImpl(const wxString& title)
+ : m_win(NULL), m_title(title)
{
}
wxCocoaPrefsWindow* GetWin()
{
if ( !m_win )
- m_win = new wxCocoaPrefsWindow();
+ {
+ if ( m_title.empty() )
+ m_title = _("Preferences");
+
+ m_win = new wxCocoaPrefsWindow(m_title);
+ }
+
return m_win;
}
wxWeakRef<wxCocoaPrefsWindow> m_win;
+
+ wxString m_title;
};
/*static*/
-wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create()
+wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create(const wxString& title)
{
- return new wxCocoaPreferencesEditorImpl();
+ return new wxCocoaPreferencesEditorImpl(title);
}
#endif // wxHAS_PREF_EDITOR_NATIVE