]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/preferences.h
Fix for special characters in Doxygen comments.
[wxWidgets.git] / interface / wx / preferences.h
CommitLineData
2aab96f5
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: interface/wx/preferences.h
3// Purpose: wxPreferencesEditor class documentation.
4// Author: Vaclav Slavik
5// Created: 2013-02-26
6// RCS-ID: $Id$
7// Copyright: (c) 2013 Vaclav Slavik <vslavik@fastmail.fm>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11/**
12 Manage preferences dialog.
13
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.
19
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.
25
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
28 internally.
29
30 @library{wxcore}
31
32 @since 2.9.5
33 */
34class wxPreferencesEditor
35{
36public:
37 /**
38 Constructor.
39
40 Creates an empty editor, use AddPage() to add controls to it.
654c4b7b
VZ
41
42 @param title The title overriding the default title of the top level
43 window used by the editor. It is recommended to not specify this
44 parameter to use the native convention for the preferences dialogs
45 instead.
2aab96f5 46 */
654c4b7b 47 wxPreferencesEditor(const wxString& title = wxString());
2aab96f5
VS
48
49 /**
50 Destructor.
51
52 Destroying this object hides the associated preferences window if it is
53 open at the moment.
54
55 The destructor is non-virtual as this class is not supposed to be
56 derived from.
57 */
58 ~wxPreferencesEditor();
59
60 /**
61 Add a new page to the editor.
62
63 The editor takes ownership of the page and will delete it from its
64 destructor (but not sooner).
65
66 @see wxPreferencesPage, wxStockPreferencesPage
67 */
68 void AddPage(wxPreferencesPage *page);
69
70 /**
71 Show the preferences dialog or bring it to the top if it's already
72 shown.
73
74 Notice that this method may or may not block depending on the platform,
75 i.e. depending on whether the dialog is modal or not.
76
77 @param parent The window that invokes the preferences.
78 Call Dismiss() before it's destroyed.
79 */
eaa69588 80 virtual void Show(wxWindow* parent);
2aab96f5
VS
81
82 /**
83 Hide the currently shown dialog, if any.
84
615f9ff0
VZ
85 This is typically called to dismiss the dialog if the object whose
86 preferences it is editing was closed.
2aab96f5
VS
87 */
88 void Dismiss();
89
90 /**
91 Returns whether changes to values in preferences pages should be
92 applied immediately or only when the user clicks the OK button.
93
94 Currently, changes are applied immediately on OS X and GTK+.
95
96 The preprocessor macro `wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY` is defined
97 in this case as well.
98 */
99 static bool ShouldApplyChangesImmediately()
b5c96277
VZ
100
101 /**
102 Returns whether the preferences dialog is shown modally.
103
104 If this method returns false, as it currently does in wxGTK and wxOSX,
105 Show() simply makes the dialog visible and returns immediately. If it
106 returns true, as it does in wxMSW and under the other platforms, then
107 the dialog is shown modally, i.e. Show() blocks until the user
108 dismisses it.
109
110 Notice that it isn't necessary to test the return value of this method
111 to use this class normally, its interface is designed to work in both
112 cases. However it can sometimes be necessary to call it if the program
113 needs to handle modal dialogs specially, e.g. perhaps to block some
114 periodic background update operation while a modal dialog is shown.
115 */
116 static bool ShownModally();
2aab96f5
VS
117};
118
119
120/**
121 One page of preferences dialog.
122
123 This is the base class for implementation of application's preferences. Its
124 methods return various properties of the page, such as title or icon. The
125 actual page is created by CreateWindow().
126
127 @see wxStockPreferencesPage
128
129 @library{wxcore}
130
131 @since 2.9.5
132 */
133class wxPreferencesPage
134{
135public:
a150fade
RD
136 /// Constructor.
137 wxPreferencesPage();
138
2aab96f5 139 /// Destructor.
a150fade 140 virtual ~wxPreferencesPage();
2aab96f5
VS
141
142 /**
143 Return name of the page.
144
145 The name is used for notebook tab's label, icon label etc., depending
146 on the platform.
147 */
148 virtual wxString GetName() const = 0;
149
150 /**
151 Return 32x32 icon used for the page on some platforms.
152
153 Currently only used on OS X.
154
155 @note This method is only pure virtual on platforms that require it
156 (OS X). On other platforms, it has default implementation that
157 returns an invalid bitmap. The preprocessor symbol
158 `wxHAS_PREF_EDITOR_ICONS` is defined if this method must be
159 implemented.
160 */
161 virtual wxBitmap GetLargeIcon() const = 0;
162
163 /**
164 Create a window for this page.
165
166 The window will be placed into the preferences dialog in
167 platform-specific manner. Depending on the platform, this method may
168 be called before showing the preferences window, when switching to its
169 tab or even more than once. Don't make assumptions about the number of
170 times or the specific time when it is called.
171
172 The caller takes ownership of the window.
173
174 wxPanel is usually used, but doesn't have to be.
175
176 @param parent Parent window to use.
177 */
178 virtual wxWindow *CreateWindow(wxWindow *parent) = 0;
179};
180
181
182/**
183 Specialization of wxPreferencesPage useful for certain commonly used
184 preferences page.
185
186 On OS X, preferences pages named "General" and "Advanced" are commonly used
187 in apps and the OS provides stock icons for them that should be used.
188 Instead of reimplementing this behavior yourself, you can inherit from
189 wxStockPreferencesPage and get correct title and icon.
190
191 Notice that this class only implements GetName() and GetLargeIcon(), you
192 still have to provide the rest of wxPreferencesPage implementation.
193
194 @library{wxcore}
195
196 @since 2.9.5
197 */
198class wxStockPreferencesPage : public wxPreferencesPage
199{
200public:
201 /// Kinds of stock pages.
202 enum Kind
203 {
204 /// The "General" page
205 Kind_General,
206 /// The "Advanced" page
207 Kind_Advanced
208 };
209
210 /// Constructor.
a150fade 211 wxStockPreferencesPage(Kind kind);
2aab96f5
VS
212
213 /// Returns the page's kind.
a150fade 214 Kind GetKind() const;
2aab96f5
VS
215
216 /// Reimplemented to return suitable name for the page's kind.
217 virtual wxString GetName() const;
218 /// Reimplemented to return stock icon on OS X.
219 virtual wxBitmap GetLargeIcon() const;
220};