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:
|
public:
|
||||||
// Ctor creates an empty editor, use AddPage() to add controls to it.
|
// Ctor creates an empty editor, use AddPage() to add controls to it.
|
||||||
wxPreferencesEditor();
|
wxPreferencesEditor(const wxString& title = wxString());
|
||||||
~wxPreferencesEditor();
|
~wxPreferencesEditor();
|
||||||
|
|
||||||
// Add a new page to the editor. The editor takes ownership of the page
|
// Add a new page to the editor. The editor takes ownership of the page
|
||||||
|
@@ -29,7 +29,7 @@ class wxPreferencesEditorImpl
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// This is implemented in a platform-specific way.
|
// 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.
|
// These methods simply mirror the public wxPreferencesEditor ones.
|
||||||
virtual void AddPage(wxPreferencesPage* page) = 0;
|
virtual void AddPage(wxPreferencesPage* page) = 0;
|
||||||
|
@@ -38,8 +38,13 @@ public:
|
|||||||
Constructor.
|
Constructor.
|
||||||
|
|
||||||
Creates an empty editor, use AddPage() to add controls to it.
|
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.
|
Destructor.
|
||||||
|
@@ -42,8 +42,8 @@ wxString wxStockPreferencesPage::GetName() const
|
|||||||
return wxString(); // silence compiler warning
|
return wxString(); // silence compiler warning
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPreferencesEditor::wxPreferencesEditor()
|
wxPreferencesEditor::wxPreferencesEditor(const wxString& title)
|
||||||
: m_impl(wxPreferencesEditorImpl::Create())
|
: m_impl(wxPreferencesEditorImpl::Create(title))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,11 +34,14 @@
|
|||||||
#include "wx/scopedptr.h"
|
#include "wx/scopedptr.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
class wxGenericPrefsDialog : public wxDialog
|
class wxGenericPrefsDialog : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGenericPrefsDialog(wxWindow *parent)
|
wxGenericPrefsDialog(wxWindow *parent, const wxString& title)
|
||||||
: wxDialog(parent, wxID_ANY, _("Preferences"),
|
: wxDialog(parent, wxID_ANY, title,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX))
|
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX))
|
||||||
{
|
{
|
||||||
@@ -83,6 +86,11 @@ private:
|
|||||||
class wxGenericPreferencesEditorImplBase : public wxPreferencesEditorImpl
|
class wxGenericPreferencesEditorImplBase : public wxPreferencesEditorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
void SetTitle(const wxString& title)
|
||||||
|
{
|
||||||
|
m_title = title;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void AddPage(wxPreferencesPage* page)
|
virtual void AddPage(wxPreferencesPage* page)
|
||||||
{
|
{
|
||||||
m_pages.push_back(wxSharedPtr<wxPreferencesPage>(page));
|
m_pages.push_back(wxSharedPtr<wxPreferencesPage>(page));
|
||||||
@@ -91,7 +99,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
wxGenericPrefsDialog *CreateDialog(wxWindow *parent)
|
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
|
// 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).
|
// when a page is selected in the notebook (as is done on OS X).
|
||||||
@@ -113,6 +124,8 @@ protected:
|
|||||||
typedef wxVector< wxSharedPtr<wxPreferencesPage> > Pages;
|
typedef wxVector< wxSharedPtr<wxPreferencesPage> > Pages;
|
||||||
Pages m_pages;
|
Pages m_pages;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -161,6 +174,12 @@ private:
|
|||||||
wxWeakRef<wxWindow> m_win;
|
wxWeakRef<wxWindow> m_win;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline
|
||||||
|
wxGenericPreferencesEditorImplBase* NewGenericImpl()
|
||||||
|
{
|
||||||
|
return new wxModelessPreferencesEditorImpl;
|
||||||
|
}
|
||||||
|
|
||||||
#else // !wxHAS_PREF_EDITOR_MODELESS
|
#else // !wxHAS_PREF_EDITOR_MODELESS
|
||||||
|
|
||||||
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
|
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
|
||||||
@@ -194,17 +213,24 @@ private:
|
|||||||
int m_currentPage;
|
int m_currentPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline
|
||||||
|
wxGenericPreferencesEditorImplBase* NewGenericImpl()
|
||||||
|
{
|
||||||
|
return new wxModalPreferencesEditorImpl;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !wxHAS_PREF_EDITOR_MODELESS
|
#endif // !wxHAS_PREF_EDITOR_MODELESS
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create()
|
wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create(const wxString& title)
|
||||||
{
|
{
|
||||||
#ifdef wxHAS_PREF_EDITOR_MODELESS
|
wxGenericPreferencesEditorImplBase* const impl = NewGenericImpl();
|
||||||
return new wxModelessPreferencesEditorImpl();
|
|
||||||
#else
|
impl->SetTitle(title);
|
||||||
return new wxModalPreferencesEditorImpl();
|
|
||||||
#endif
|
return impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !wxHAS_PREF_EDITOR_NATIVE
|
#endif // !wxHAS_PREF_EDITOR_NATIVE
|
||||||
|
@@ -54,8 +54,8 @@ wxBitmap wxStockPreferencesPage::GetLargeIcon() const
|
|||||||
class wxCocoaPrefsWindow : public wxFrame
|
class wxCocoaPrefsWindow : public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxCocoaPrefsWindow()
|
wxCocoaPrefsWindow(const wxString& title)
|
||||||
: wxFrame(NULL, wxID_ANY, _("Preferences"),
|
: wxFrame(NULL, wxID_ANY, title,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)),
|
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)),
|
||||||
m_toolbarRealized(false),
|
m_toolbarRealized(false),
|
||||||
@@ -191,7 +191,8 @@ private:
|
|||||||
class wxCocoaPreferencesEditorImpl : public wxPreferencesEditorImpl
|
class wxCocoaPreferencesEditorImpl : public wxPreferencesEditorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxCocoaPreferencesEditorImpl() : m_win(NULL)
|
wxCocoaPreferencesEditorImpl(const wxString& title)
|
||||||
|
: m_win(NULL), m_title(title)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,17 +233,25 @@ private:
|
|||||||
wxCocoaPrefsWindow* GetWin()
|
wxCocoaPrefsWindow* GetWin()
|
||||||
{
|
{
|
||||||
if ( !m_win )
|
if ( !m_win )
|
||||||
m_win = new wxCocoaPrefsWindow();
|
{
|
||||||
|
if ( m_title.empty() )
|
||||||
|
m_title = _("Preferences");
|
||||||
|
|
||||||
|
m_win = new wxCocoaPrefsWindow(m_title);
|
||||||
|
}
|
||||||
|
|
||||||
return m_win;
|
return m_win;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWeakRef<wxCocoaPrefsWindow> m_win;
|
wxWeakRef<wxCocoaPrefsWindow> m_win;
|
||||||
|
|
||||||
|
wxString m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*static*/
|
/*static*/
|
||||||
wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create()
|
wxPreferencesEditorImpl* wxPreferencesEditorImpl::Create(const wxString& title)
|
||||||
{
|
{
|
||||||
return new wxCocoaPreferencesEditorImpl();
|
return new wxCocoaPreferencesEditorImpl(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxHAS_PREF_EDITOR_NATIVE
|
#endif // wxHAS_PREF_EDITOR_NATIVE
|
||||||
|
Reference in New Issue
Block a user