]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/preferences.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: interface/wx/preferences.h
3 // Purpose: wxPreferencesEditor class documentation.
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2013 Vaclav Slavik <vslavik@fastmail.fm>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
12 Manage preferences dialog.
14 This class encapsulates the differences -- both in appearance and
15 behaviour -- between preferences dialogs on different platforms. In
16 particular, OS X preferences look very different from the typical notebook
17 control used on other platforms, and both OS X and GTK+ preferences windows
18 are modeless unlike Windows options dialogs that are typically modal.
20 wxPreferencesEditor is able to hide the differences by hiding the creation
21 of preferences window from the API. Instead, you create an instance of
22 wxPreferencesEditor and add page descriptions in the form of
23 wxPreferencesPage using its AddPage() method. After setting up the editor
24 object, you must call Show() to present preferences to the user.
26 @note Notice that this class is not derived from wxWindow and hence
27 doesn't represent a window, even if its Show() method does create one
34 class wxPreferencesEditor
40 Creates an empty editor, use AddPage() to add controls to it.
42 wxPreferencesEditor();
47 Destroying this object hides the associated preferences window if it is
50 The destructor is non-virtual as this class is not supposed to be
53 ~wxPreferencesEditor();
56 Add a new page to the editor.
58 The editor takes ownership of the page and will delete it from its
59 destructor (but not sooner).
61 @see wxPreferencesPage, wxStockPreferencesPage
63 void AddPage(wxPreferencesPage
*page
);
66 Show the preferences dialog or bring it to the top if it's already
69 Notice that this method may or may not block depending on the platform,
70 i.e. depending on whether the dialog is modal or not.
72 @param parent The window that invokes the preferences.
73 Call Dismiss() before it's destroyed.
75 void Show(wxWindow
* parent
);
78 Hide the currently shown dialog, if any.
80 This doesn't do anything on the platforms using modal preferences
81 dialogs (e.g. Windows) but should be called to dismiss the dialog if
82 the object whose preferences it is editing was closed.
87 Returns whether changes to values in preferences pages should be
88 applied immediately or only when the user clicks the OK button.
90 Currently, changes are applied immediately on OS X and GTK+.
92 The preprocessor macro `wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY` is defined
95 static bool ShouldApplyChangesImmediately()
100 One page of preferences dialog.
102 This is the base class for implementation of application's preferences. Its
103 methods return various properties of the page, such as title or icon. The
104 actual page is created by CreateWindow().
106 @see wxStockPreferencesPage
112 class wxPreferencesPage
116 virtual ~wxPreferencesPage() {}
119 Return name of the page.
121 The name is used for notebook tab's label, icon label etc., depending
124 virtual wxString
GetName() const = 0;
127 Return 32x32 icon used for the page on some platforms.
129 Currently only used on OS X.
131 @note This method is only pure virtual on platforms that require it
132 (OS X). On other platforms, it has default implementation that
133 returns an invalid bitmap. The preprocessor symbol
134 `wxHAS_PREF_EDITOR_ICONS` is defined if this method must be
137 virtual wxBitmap
GetLargeIcon() const = 0;
140 Create a window for this page.
142 The window will be placed into the preferences dialog in
143 platform-specific manner. Depending on the platform, this method may
144 be called before showing the preferences window, when switching to its
145 tab or even more than once. Don't make assumptions about the number of
146 times or the specific time when it is called.
148 The caller takes ownership of the window.
150 wxPanel is usually used, but doesn't have to be.
152 @param parent Parent window to use.
154 virtual wxWindow
*CreateWindow(wxWindow
*parent
) = 0;
159 Specialization of wxPreferencesPage useful for certain commonly used
162 On OS X, preferences pages named "General" and "Advanced" are commonly used
163 in apps and the OS provides stock icons for them that should be used.
164 Instead of reimplementing this behavior yourself, you can inherit from
165 wxStockPreferencesPage and get correct title and icon.
167 Notice that this class only implements GetName() and GetLargeIcon(), you
168 still have to provide the rest of wxPreferencesPage implementation.
174 class wxStockPreferencesPage
: public wxPreferencesPage
177 /// Kinds of stock pages.
180 /// The "General" page
182 /// The "Advanced" page
187 wxStockPreferencesPage(Kind kind
) : m_kind(kind
) {}
189 /// Returns the page's kind.
190 Kind
GetKind() const { return m_kind
; }
192 /// Reimplemented to return suitable name for the page's kind.
193 virtual wxString
GetName() const;
194 /// Reimplemented to return stock icon on OS X.
195 virtual wxBitmap
GetLargeIcon() const;