Allow to specify the title used by wxPreferencesEditor window.
Customize the title is useful for "Settings"-style windows which are used for editing the properties of the given object, that should be identified in the window title, as opposed to the global program preferences. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74006 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,7 +88,7 @@ class WXDLLIMPEXP_CORE wxPreferencesEditor
|
||||
{
|
||||
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
|
||||
|
@@ -29,7 +29,7 @@ class wxPreferencesEditorImpl
|
||||
{
|
||||
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;
|
||||
|
@@ -38,8 +38,13 @@ public:
|
||||
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.
|
||||
|
@@ -42,8 +42,8 @@ wxString wxStockPreferencesPage::GetName() const
|
||||
return wxString(); // silence compiler warning
|
||||
}
|
||||
|
||||
wxPreferencesEditor::wxPreferencesEditor()
|
||||
: m_impl(wxPreferencesEditorImpl::Create())
|
||||
wxPreferencesEditor::wxPreferencesEditor(const wxString& title)
|
||||
: m_impl(wxPreferencesEditorImpl::Create(title))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -34,11 +34,14 @@
|
||||
#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))
|
||||
{
|
||||
@@ -83,6 +86,11 @@ private:
|
||||
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));
|
||||
@@ -91,7 +99,10 @@ public:
|
||||
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).
|
||||
@@ -113,6 +124,8 @@ protected:
|
||||
typedef wxVector< wxSharedPtr<wxPreferencesPage> > Pages;
|
||||
Pages m_pages;
|
||||
|
||||
private:
|
||||
wxString m_title;
|
||||
};
|
||||
|
||||
|
||||
@@ -161,6 +174,12 @@ private:
|
||||
wxWeakRef<wxWindow> m_win;
|
||||
};
|
||||
|
||||
inline
|
||||
wxGenericPreferencesEditorImplBase* NewGenericImpl()
|
||||
{
|
||||
return new wxModelessPreferencesEditorImpl;
|
||||
}
|
||||
|
||||
#else // !wxHAS_PREF_EDITOR_MODELESS
|
||||
|
||||
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
|
||||
@@ -194,17 +213,24 @@ private:
|
||||
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
|
||||
|
@@ -54,8 +54,8 @@ wxBitmap wxStockPreferencesPage::GetLargeIcon() const
|
||||
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),
|
||||
@@ -191,7 +191,8 @@ private:
|
||||
class wxCocoaPreferencesEditorImpl : public wxPreferencesEditorImpl
|
||||
{
|
||||
public:
|
||||
wxCocoaPreferencesEditorImpl() : m_win(NULL)
|
||||
wxCocoaPreferencesEditorImpl(const wxString& title)
|
||||
: m_win(NULL), m_title(title)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -232,17 +233,25 @@ private:
|
||||
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
|
||||
|
Reference in New Issue
Block a user