]>
Commit | Line | Data |
---|---|---|
200fed6c VS |
1 | \chapter{Property sheet classes}\label{proplist} |
2 | ||
3 | \section{Introduction}\label{proplistintro} | |
4 | ||
5 | The Property Sheet Classes help the programmer to specify complex dialogs and | |
6 | their relationship with their associated data. By specifying data as a | |
7 | wxPropertySheet containing wxProperty objects, the programmer can use | |
8 | a range of available or custom wxPropertyView classes to allow the user to | |
9 | edit this data. Classes derived from wxPropertyView act as mediators between the | |
10 | wxPropertySheet and the actual window (and associated panel items). | |
11 | ||
12 | For example, the wxPropertyListView is a kind of wxPropertyView which displays | |
13 | data in a Visual Basic-style property list (see \helpref{the next section}{proplistappearance} for | |
14 | screen shots). This is a listbox containing names and values, with | |
15 | an edit control and other optional controls via which the user edits the selected | |
16 | data item. | |
17 | ||
18 | wxPropertyFormView is another kind of wxPropertyView which mediates between | |
19 | the data and a panel or dialog box which has already been created. This makes it a contender for | |
20 | the replacement of wxForm, since programmer-controlled layout is going to be much more | |
21 | satisfactory. If automatic layout is desired, then wxPropertyListView could be used instead. | |
22 | ||
23 | The main intention of this class library was to provide property {\it list} behaviour, but | |
24 | it has been generalised as much as possible so that the concept of a property sheet and its viewers | |
25 | can reduce programming effort in a range of user interface tasks. | |
26 | ||
27 | For further details on the classes and how they are used, please see \helpref{Property classes overview}{proplistpropertyoverview}. | |
28 | ||
29 | \subsection{The appearance and behaviour of a property list view}\label{proplistappearance} | |
30 | ||
31 | The property list, as seen in an increasing number of development tools | |
32 | such as Visual Basic and Delphi, is a convenient and compact method for | |
33 | displaying and editing a number of items without the need for one | |
34 | control per item, and without the need for designing a special form. The | |
35 | controls are as follows: | |
36 | ||
37 | \begin{itemize}\itemsep=0pt | |
38 | \item A listbox showing the properties and their current values, which has double-click | |
39 | properties dependent on the nature of the current property; | |
40 | \item a text editing area at the top of the display, allowing the user to edit | |
41 | the currently selected property if appropriate; | |
42 | \item `confirm' and `cancel' buttons to confirm or cancel an edit (for the property, not the | |
43 | whole sheet); | |
44 | \item an optional list that appears when the user can make a choice from several known possible values; | |
45 | \item a small Edit button to invoke `detailed editing' (perhaps showing or hiding the above value list, or | |
46 | maybe invoking a common dialog); | |
47 | \item optional OK/Close, Cancel and Help buttons for the whole dialog. | |
48 | \end{itemize} | |
49 | ||
50 | The concept of `detailed editing' versus quick editing gives the user a choice | |
51 | of editing mode, so novice and expert behaviour can be catered for, or the user can just | |
52 | use what he feels comfortable with. | |
53 | ||
54 | Behaviour alters depending on the kind of property being edited. For example, a boolean value has | |
55 | the following behaviour: | |
56 | ||
57 | \begin{itemize}\itemsep=0pt | |
58 | \item Double-clicking on the item toggles between TRUE and FALSE. | |
59 | \item Showing the value list enables the user to select TRUE or FALSE. | |
60 | \item The user may be able to type in the word TRUE or FALSE, or the edit control | |
61 | may be read-only to disallow this since it is error-prone. | |
62 | \end{itemize} | |
63 | ||
64 | A list of strings may pop up a dialog for editing them, a simple string just allows text editing, | |
65 | double-clicking a colour property may show a colour selector, double-clicking on a filename property may | |
66 | show a file selector (in addition to being able to type in the name in the edit control), etc. | |
67 | ||
68 | Note that the `type' of property, such as string or integer, does not | |
69 | necessarily determine the behaviour of the property. The programmer has | |
70 | to be able to specify different behaviours for the same type, depending | |
71 | on the meaning of the property. For example, a colour and a filename may | |
72 | both be strings, but their editing behaviour should be different. This | |
73 | is why objects of type wxPropertyValidator need to be used, to define | |
74 | behaviour for a given class of properties or even specific property | |
75 | name. Objects of class wxPropertyView contain a list of property | |
76 | registries, which enable reuse of bunches of these validators in | |
77 | different circumstances. Or a wxProperty can be explicitly set to use a | |
78 | particular validator object. | |
79 | ||
80 | The following screen shot of the property classes test program shows the | |
81 | user editing a string, which is constrained to be one of three possible | |
82 | values. | |
83 | ||
84 | \helponly{\image{}{prop1.bmp}} | |
85 | ||
86 | The second picture shows the user having entered a integer that | |
87 | was outside the range specified to the validator. Note that in this picture, | |
88 | the value list is hidden because it is not used when editing an integer. | |
89 | ||
90 | \helponly{\image{}{prop2.bmp}} | |
91 | ||
92 | \section{Headers}\label{proplistfiles} | |
93 | ||
94 | The property class library comprises the following files: | |
95 | ||
96 | \begin{itemize}\itemsep=0pt | |
97 | \item prop.h: base property class header | |
98 | \item proplist.h: wxPropertyListView and associated classes | |
99 | \item propform.h: wxPropertyListView and associated classes | |
100 | \end{itemize} | |
101 | ||
102 | ||
103 | ||
104 | ||
105 | ||
106 | ||
107 | ||
108 | ||
109 | ||
110 | \section{Topic overviews}\label{proplistoverviews} | |
111 | ||
112 | This chapter contains a selection of topic overviews. | |
113 | ||
114 | \subsection{Property classes overview}\label{proplistpropertyoverview} | |
115 | ||
116 | The property classes help a programmer to express relationships between | |
117 | data and physical windows, in particular: | |
118 | ||
119 | \begin{itemize}\itemsep=0pt | |
120 | \item the transfer of data to and from the physical controls; | |
121 | \item the behaviour of various controls and custom windows for particular | |
122 | types of data; | |
123 | \item the validation of data, notifying the user when incorrect data is entered, | |
124 | or even better, constraining the input so only valid data can be entered. | |
125 | \end{itemize} | |
126 | ||
127 | With a consistent framework, the programmer should be able to use existing | |
128 | components and design new ones in a principled manner, to solve many data entry | |
129 | requirements. | |
130 | ||
131 | Each datum is represented in a \helpref{wxProperty}{wxproperty}, which has a name and a value. | |
132 | Various C++ types are permitted in the value of a property, and the property can store a pointer | |
133 | to the data instead of a copy of the data. A \helpref{wxPropertySheet}{wxpropertysheet} represents a number of these properties. | |
134 | ||
135 | These two classes are independent from the way in which the data is visually manipulated. To | |
136 | mediate between property sheets and windows, the abstract class \helpref{wxPropertyView}{wxpropertyview} is | |
137 | available for programmers to derive new kinds of view. One kind of view that is available is the \helpref{wxPropertyListView}{wxpropertylistview}, | |
138 | which displays the data in a Visual Basic-style list, with a small number of controls for editing | |
139 | the currently selected property. Another is \helpref{wxPropertyFormView}{wxpropertyformview} which | |
140 | mediates between an existing dialog or panel and the property sheet. | |
141 | ||
142 | The hard work of mediation is actually performed by validators, which are instances of classes | |
143 | derived from \helpref{wxPropertyValidator}{wxpropertyvalidator}. A validator is associated with | |
144 | a particular property and is responsible for | |
145 | responding to user interface events, and displaying, updating and checking the property value. | |
146 | Because a validator's behaviour depends largely on the kind of view being used, there has to be | |
147 | a separate hierarchy of validators for each class of view. So for wxPropertyListView, there is | |
148 | an abstract class \helpref{wxPropertyListValidator}{wxpropertylistvalidator} from which concrete | |
149 | classes are derived, such as \helpref{wxRealListValidator}{wxreallistvalidator} and | |
150 | \rtfsp\helpref{wxStringListValidator}{wxstringlistvalidator}. | |
151 | ||
152 | A validator can be explicitly set for a property, so there is no doubt which validator | |
153 | should be used to edit that property. However, it is also possible to define a registry | |
154 | of validators, and have the validator chosen on the basis of the {\it role} of the property. | |
155 | So a property with a ``filename" role would match the ``filename" validator, which pops | |
156 | up a file selector when the user double clicks on the property. | |
157 | ||
158 | You don't have to define your own frame or window classes: there are some predefined | |
159 | that will work with the property list view. See \helpref{Window classes}{proplistwindowclasses} for | |
160 | further details. | |
161 | ||
162 | \subsubsection{Example 1: Property list view} | |
163 | ||
164 | The following code fragment shows the essentials of creating a registry of | |
165 | standard validators, a property sheet containing some properties, and | |
166 | a property list view and dialog or frame. RegisterValidators will be | |
167 | called on program start, and PropertySheetTest is called in response to a | |
168 | menu command. | |
169 | ||
170 | Note how some properties are created with an explicit reference to | |
171 | a validator, and others are provided with a ``role'' which can be matched | |
172 | against a validator in the registry. | |
173 | ||
174 | The interface generated by this test program is shown in the section \helpref{Appearance and | |
175 | behaviour of a property list view}{proplistappearance}. | |
176 | ||
177 | \begin{verbatim} | |
178 | void RegisterValidators(void) | |
179 | { | |
180 | myListValidatorRegistry.RegisterValidator((wxString)"real", new wxRealListValidator); | |
181 | myListValidatorRegistry.RegisterValidator((wxString)"string", new wxStringListValidator); | |
182 | myListValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerListValidator); | |
183 | myListValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolListValidator); | |
184 | } | |
185 | ||
186 | void PropertyListTest(Bool useDialog) | |
187 | { | |
188 | wxPropertySheet *sheet = new wxPropertySheet; | |
189 | ||
190 | sheet->AddProperty(new wxProperty("fred", 1.0, "real")); | |
191 | sheet->AddProperty(new wxProperty("tough choice", (Bool)TRUE, "bool")); | |
192 | sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerListValidator(-50, 50))); | |
193 | sheet->AddProperty(new wxProperty("bill", 25.0, "real", new wxRealListValidator(0.0, 100.0))); | |
194 | sheet->AddProperty(new wxProperty("julian", "one", "string")); | |
195 | sheet->AddProperty(new wxProperty("bitmap", "none", "string", new wxFilenameListValidator("Select a bitmap file", "*.bmp"))); | |
196 | wxStringList *strings = new wxStringList("one", "two", "three", NULL); | |
197 | sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringListValidator(strings))); | |
198 | ||
199 | wxPropertyListView *view = | |
200 | new wxPropertyListView(NULL, | |
201 | wxPROP_BUTTON_CHECK_CROSS|wxPROP_DYNAMIC_VALUE_FIELD|wxPROP_PULLDOWN); | |
202 | ||
203 | wxDialogBox *propDialog = NULL; | |
204 | wxPropertyListFrame *propFrame = NULL; | |
205 | if (useDialog) | |
206 | { | |
207 | propDialog = new wxPropertyListDialog(view, NULL, "Property Sheet Test", TRUE, -1, -1, 400, 500); | |
208 | } | |
209 | else | |
210 | { | |
211 | propFrame = new wxPropertyListFrame(view, NULL, "Property Sheet Test", -1, -1, 400, 500); | |
212 | } | |
213 | ||
214 | view->AddRegistry(&myListValidatorRegistry); | |
215 | ||
216 | if (useDialog) | |
217 | { | |
218 | view->ShowView(sheet, propDialog); | |
219 | propDialog->Centre(wxBOTH); | |
220 | propDialog->Show(TRUE); | |
221 | } | |
222 | else | |
223 | { | |
224 | propFrame->Initialize(); | |
225 | view->ShowView(sheet, propFrame->GetPropertyPanel()); | |
226 | propFrame->Centre(wxBOTH); | |
227 | propFrame->Show(TRUE); | |
228 | } | |
229 | } | |
230 | \end{verbatim} | |
231 | ||
232 | \subsubsection{Example 2: Property form view} | |
233 | ||
234 | This example is similar to Example 1, but uses a property form view to | |
235 | edit a property sheet using a predefined dialog box. | |
236 | ||
237 | \begin{verbatim} | |
238 | void RegisterValidators(void) | |
239 | { | |
240 | myFormValidatorRegistry.RegisterValidator((wxString)"real", new wxRealFormValidator); | |
241 | myFormValidatorRegistry.RegisterValidator((wxString)"string", new wxStringFormValidator); | |
242 | myFormValidatorRegistry.RegisterValidator((wxString)"integer", new wxIntegerFormValidator); | |
243 | myFormValidatorRegistry.RegisterValidator((wxString)"bool", new wxBoolFormValidator); | |
244 | } | |
245 | ||
246 | void PropertyFormTest(Bool useDialog) | |
247 | { | |
248 | wxPropertySheet *sheet = new wxPropertySheet; | |
249 | ||
250 | sheet->AddProperty(new wxProperty("fred", 25.0, "real", new wxRealFormValidator(0.0, 100.0))); | |
251 | sheet->AddProperty(new wxProperty("tough choice", (Bool)TRUE, "bool")); | |
252 | sheet->AddProperty(new wxProperty("ian", (long)45, "integer", new wxIntegerFormValidator(-50, 50))); | |
253 | sheet->AddProperty(new wxProperty("julian", "one", "string")); | |
254 | wxStringList *strings = new wxStringList("one", "two", "three", NULL); | |
255 | sheet->AddProperty(new wxProperty("constrained", "one", "string", new wxStringFormValidator(strings))); | |
256 | ||
257 | wxPropertyFormView *view = new wxPropertyFormView(NULL); | |
258 | ||
259 | wxDialogBox *propDialog = NULL; | |
260 | wxPropertyFormFrame *propFrame = NULL; | |
261 | if (useDialog) | |
262 | { | |
263 | propDialog = new wxPropertyFormDialog(view, NULL, "Property Form Test", TRUE, -1, -1, 400, 300); | |
264 | } | |
265 | else | |
266 | { | |
267 | propFrame = new wxPropertyFormFrame(view, NULL, "Property Form Test", -1, -1, 400, 300); | |
268 | propFrame->Initialize(); | |
269 | } | |
270 | ||
271 | wxPanel *panel = propDialog ? propDialog : propFrame->GetPropertyPanel(); | |
272 | panel->SetLabelPosition(wxVERTICAL); | |
273 | ||
274 | // Add items to the panel | |
275 | ||
276 | (void) new wxButton(panel, (wxFunction)NULL, "OK", -1, -1, -1, -1, 0, "ok"); | |
277 | (void) new wxButton(panel, (wxFunction)NULL, "Cancel", -1, -1, 80, -1, 0, "cancel"); | |
278 | (void) new wxButton(panel, (wxFunction)NULL, "Update", -1, -1, 80, -1, 0, "update"); | |
279 | (void) new wxButton(panel, (wxFunction)NULL, "Revert", -1, -1, -1, -1, 0, "revert"); | |
280 | panel->NewLine(); | |
281 | ||
282 | // The name of this text item matches the "fred" property | |
283 | (void) new wxText(panel, (wxFunction)NULL, "Fred", "", -1, -1, 90, -1, 0, "fred"); | |
284 | (void) new wxCheckBox(panel, (wxFunction)NULL, "Yes or no", -1, -1, -1, -1, 0, "tough choice"); | |
285 | (void) new wxSlider(panel, (wxFunction)NULL, "Sliding scale", 0, -50, 50, 100, -1, -1, wxHORIZONTAL, "ian"); | |
286 | panel->NewLine(); | |
287 | (void) new wxListBox(panel, (wxFunction)NULL, "Constrained", wxSINGLE, -1, -1, 100, 90, 0, NULL, 0, "constrained"); | |
288 | ||
289 | view->AddRegistry(&myFormValidatorRegistry); | |
290 | ||
291 | if (useDialog) | |
292 | { | |
293 | view->ShowView(sheet, propDialog); | |
294 | view->AssociateNames(); | |
295 | view->TransferToDialog(); | |
296 | propDialog->Centre(wxBOTH); | |
297 | propDialog->Show(TRUE); | |
298 | } | |
299 | else | |
300 | { | |
301 | view->ShowView(sheet, propFrame->GetPropertyPanel()); | |
302 | view->AssociateNames(); | |
303 | view->TransferToDialog(); | |
304 | propFrame->Centre(wxBOTH); | |
305 | propFrame->Show(TRUE); | |
306 | } | |
307 | } | |
308 | \end{verbatim} | |
309 | ||
310 | \subsection{Validator classes overview}\label{proplistvalidatoroverview} | |
311 | ||
312 | Classes: \helpref{Validator classes}{proplistvalidatorclasses} | |
313 | ||
314 | The validator classes provide functionality for mediating between a wxProperty and | |
315 | the actual display. There is a separate family of validator classes for each | |
316 | class of view, since the differences in user interface for these views implies | |
317 | that little common functionality can be shared amongst validators. | |
318 | ||
319 | ||
320 | ||
321 | \subsubsection{wxPropertyValidator overview}\label{wxpropertyvalidatoroverview} | |
322 | ||
323 | Class: \helpref{wxPropertyValidator}{wxpropertyvalidator} | |
324 | ||
325 | This class is the root of all property validator classes. It contains a small | |
326 | amount of common functionality, including functions to convert between | |
327 | strings and C++ values. | |
328 | ||
329 | A validator is notionally an object which sits between a property and its displayed | |
330 | value, and checks that the value the user enters is correct, giving an error message | |
331 | if the validation fails. In fact, the validator does more than that, and is akin to | |
332 | a view class but at a finer level of detail. It is also responsible for | |
333 | loading the dialog box control with the value from the property, putting it back | |
334 | into the property, preparing special controls for editing the value, and | |
335 | may even invoke special dialogs for editing the value in a convenient way. | |
336 | ||
337 | In a property list dialog, there is quite a lot of scope for supplying custom dialogs, | |
338 | such as file or colour selectors. For a form dialog, there is less scope because | |
339 | there is no concept of `detailed editing' of a value: one control is associated with | |
340 | one property, and there is no provision for invoking further dialogs. The reader | |
341 | may like to work out how the form view could be extended to provide some of the | |
342 | functionality of the property list! | |
343 | ||
344 | Validator objects may be associated explictly with a wxProperty, or they may be | |
345 | indirectly associated by virtue of a property `kind' that matches validators having | |
346 | that kind. In the latter case, such validators are stored in a validator registry | |
347 | which is passed to the view before the dialog is shown. If the validator takes | |
348 | arguments, such as minimum and maximum values in the case of a wxIntegerListValidator, | |
349 | then the validator must be associated explicitly with the property. The validator | |
350 | will be deleted when the property is deleted. | |
351 | ||
352 | \subsubsection{wxPropertyListValidator overview}\label{wxpropertylistvalidatoroverview} | |
353 | ||
354 | Class: \helpref{wxPropertyListValidator}{wxpropertylistvalidator} | |
355 | ||
356 | This class is the abstract base class for property list view validators. | |
357 | The list view acts upon a user interface containing a list of properties, | |
358 | a text item for direct property value editing, confirm/cancel buttons for the value, | |
359 | a pulldown list for making a choice between values, and OK/Cancel/Help buttons | |
360 | for the dialog (see \helpref{property list appearance}{proplistappearance}). | |
361 | ||
362 | By overriding virtual functions, the programmer can create custom | |
363 | behaviour for different kinds of property. Custom behaviour can use just the | |
364 | available controls on the property list dialog, or the validator can | |
365 | invoke custom editors with quite different controls, which pop up in | |
366 | `detailed editing' mode. | |
367 | ||
368 | See the detailed class documentation for the members you should override | |
369 | to give your validator appropriate behaviour. | |
370 | ||
371 | \subsubsection{wxPropertyFormValidator overview}\label{wxpropertyformvalidatoroverview} | |
372 | ||
373 | This class is the abstract base class for property form view validators. | |
374 | The form view acts upon an existing dialog box or panel, where either the | |
375 | panel item names correspond to property names, or the programmer has explicitly | |
376 | associated the panel item with the property. | |
377 | ||
378 | By overriding virtual functions, the programmer determines how | |
379 | values are displayed or retrieved, and the checking that the validator does. | |
380 | ||
381 | See the detailed class documentation for the members you should override | |
382 | to give your validator appropriate behaviour. | |
383 | ||
384 | \subsection{View classes overview}\label{proplistviewoverview} | |
385 | ||
386 | Classes: \helpref{View classes}{proplistviewclasses} | |
387 | ||
388 | An instance of a view class relates a property sheet with an actual window. | |
389 | Currently, there are two classes of view: wxPropertyListView and wxPropertyFormView. | |
390 | ||
391 | \subsubsection{wxPropertyView overview}\label{wxpropertyviewoverview} | |
392 | ||
393 | Class: \helpref{wxPropertyView}{wxpropertyview} | |
394 | ||
395 | This is the abstract base class for property views. | |
396 | ||
397 | \subsubsection{wxPropertyListView overview}\label{wxpropertylistviewoverview} | |
398 | ||
399 | Class: \helpref{wxPropertyListView}{wxpropertylistview} | |
400 | ||
401 | The property list view defines the relationship between a property sheet and | |
402 | a property list dialog or panel. It manages user interface events such as | |
403 | clicking on a property, pressing return in the text edit field, and clicking | |
404 | on Confirm or Cancel. These events cause member functions of the | |
405 | class to be called, and these in turn may call member functions of | |
406 | the appropriate validator to be called, to prepare controls, check the property value, | |
407 | invoke detailed editing, etc. | |
408 | ||
409 | \subsubsection{wxPropertyFormView overview}\label{wxpropertyformviewoverview} | |
410 | ||
411 | Class: \helpref{wxPropertyFormView}{wxpropertyformview} | |
412 | ||
413 | The property form view manages the relationship between a property sheet | |
414 | and an existing dialog or panel. | |
415 | ||
416 | You must first create a panel or dialog box for the view to work on. | |
417 | The panel should contain panel items with names that correspond to | |
418 | properties in your property sheet; or you can explicitly set the | |
419 | panel item for each property. | |
420 | ||
421 | Apart from any custom panel items that you wish to control independently | |
422 | of the property-editing items, wxPropertyFormView takes over the | |
423 | processing of item events. It can also control normal dialog behaviour such | |
424 | as OK, Cancel, so you should also create some standard buttons that the property view | |
425 | can recognise. Just create the buttons with standard names and the view | |
426 | will do the rest. The following button names are recognised: | |
427 | ||
428 | \begin{itemize}\itemsep=0pt | |
429 | \item {\bf ok}: indicates the OK button. Calls wxPropertyFormView::OnOk. By default, | |
430 | checks and updates the form values, closes and deletes the frame or dialog, then deletes the view. | |
431 | \item {\bf cancel}: indicates the Cancel button. Calls wxPropertyFormView::OnCancel. By default, | |
432 | closes and deletes the frame or dialog, then deletes the view. | |
433 | \item {\bf help}: indicates the Help button. Calls wxPropertyFormView::OnHelp. This needs | |
434 | to be overridden by the application for anything interesting to happen. | |
435 | \item {\bf revert}: indicates the Revert button. Calls wxPropertyFormView::OnRevert, | |
436 | which by default transfers the wxProperty values to the panel items (in effect | |
437 | undoing any unsaved changes in the items). | |
438 | \item {\bf update}: indicates the Revert button. Calls wxPropertyFormView::OnUpdate, which | |
439 | by defaults transfers the displayed values to the wxProperty objects. | |
440 | \end{itemize} | |
441 | ||
442 | \subsection{wxPropertySheet overview}\label{wxpropertysheetoverview} | |
443 | ||
444 | Classes: \helpref{wxPropertySheet}{wxpropertysheet}, \helpref{wxProperty}{wxproperty}, \helpref{wxPropertyValue}{wxpropertyvalue} | |
445 | ||
446 | A property sheet defines zero or more properties. This is a bit like an explicit representation of | |
447 | a C++ object. wxProperty objects can have values which are pointers to C++ values, or they | |
448 | can allocate their own storage for values. | |
449 | ||
450 | Because the property sheet representation is explicit and can be manipulated by | |
451 | a program, it is a convenient form to be used for a variety of | |
452 | editing purposes. wxPropertyListView and wxPropertyFormView are two classes that | |
453 | specify the relationship between a property sheet and a user interface. You could imagine | |
454 | other uses for wxPropertySheet, for example to generate a form-like user interface without | |
455 | the need for GUI programming. Or for storing the names and values of command-line switches, with the | |
456 | option to subsequently edit these values using a wxPropertyListView. | |
457 | ||
458 | A typical use for a property sheet is to represent values of an object | |
459 | which are only implicit in the current representation of it. For | |
460 | example, in Visual Basic and similar programming environments, you can | |
461 | `edit a button', or rather, edit the button's properties. One of the | |
462 | properties you can edit is {\it width} - but there is no explicit | |
463 | representation of width in a wxWindows button; instead, you call SetSize | |
464 | and GetSize members. To translate this into a consisent, | |
465 | property-oriented scheme, we could derive a new class | |
466 | wxButtonWithProperties, which has two new functions: SetProperty and | |
467 | GetProperty. SetProperty accepts a property name and a value, and calls | |
468 | an appropriate function for the property that is being passed. | |
469 | GetProperty accepts a property name, returning a property value. So | |
470 | instead of having to use the usual arbitrary set of C++ member functions | |
471 | to set or access attributes of a window, programmer deals merely with | |
472 | SetValue/GetValue, and property names and values. | |
473 | We now have a single point at which we can modify or query an object by specifying | |
474 | names and values at run-time. (The implementation of SetProperty and GetProperty | |
475 | is probably quite messy and involves a large if-then-else statement to | |
476 | test the property name and act accordingly.) | |
477 | ||
478 | When the user invokes the property editor for a wxButtonWithProperties, the system | |
479 | creates a wxPropertySheet with `imaginary' properties such as width, height, font size | |
480 | and so on. For each property, wxButtonWithProperties::GetProperty is called, and the result is | |
481 | passed to the corresponding wxProperty. The wxPropertySheet is passed to a wxPropertyListView | |
482 | as described elsewhere, and the user edits away. When the user has finished editing, the system calls | |
483 | wxButtonWithProperties::SetProperty to transfer the wxProperty value back into the button | |
484 | by way of an appropriate call, wxWindow::SetSize in the case of width and height properties. | |
485 | ||
486 | ||
487 | ||
488 | \section{Classes by category}\label{proplistclassesbycat} | |
489 | ||
490 | A classification of property sheet classes by category. | |
491 | ||
492 | \subsection{Data classes} | |
493 | ||
494 | \begin{itemize}\itemsep=0pt | |
495 | \item \helpref{wxProperty}{wxproperty} | |
496 | \item \helpref{wxPropertyValue}{wxpropertyvalue} | |
497 | \item \helpref{wxPropertySheet}{wxpropertysheet} | |
498 | \end{itemize} | |
499 | ||
500 | ||
501 | \subsection{Validator classes}\label{proplistvalidatorclasses} | |
502 | ||
503 | Validators check that the values the user has entered for a property are | |
504 | valid. They can also define specific ways of entering data, such as a | |
505 | file selector for a filename, and they are responsible for transferring | |
506 | values between the wxProperty and the physical display. | |
507 | ||
508 | Base classes: | |
509 | ||
510 | \begin{itemize}\itemsep=0pt | |
511 | \item \helpref{wxPropertyValidator}{wxproperty} | |
512 | \item \helpref{wxPropertyListValidator}{wxpropertylistvalidator} | |
513 | \item \helpref{wxPropertyFormValidator}{wxpropertyformvalidator} | |
514 | \end{itemize} | |
515 | ||
516 | List view validators: | |
517 | ||
518 | \begin{itemize}\itemsep=0pt | |
519 | \item \helpref{wxBoolListValidator}{wxboollistvalidator} | |
520 | \item \helpref{wxFilenameListValidator}{wxfilenamelistvalidator} | |
521 | \item \helpref{wxIntegerListValidator}{wxintegerlistvalidator} | |
522 | \item \helpref{wxListOfStringsListValidator}{wxlistofstringslistvalidator} | |
523 | \item \helpref{wxRealListValidator}{wxreallistvalidator} | |
524 | \item \helpref{wxStringListValidator}{wxstringlistvalidator} | |
525 | \end{itemize} | |
526 | ||
527 | Form view validators: | |
528 | ||
529 | \begin{itemize}\itemsep=0pt | |
530 | \item \helpref{wxBoolFormValidator}{wxboolformvalidator} | |
531 | \item \helpref{wxIntegerFormValidator}{wxintegerformvalidator} | |
532 | \item \helpref{wxRealFormValidator}{wxrealformvalidator} | |
533 | \item \helpref{wxStringFormValidator}{wxstringformvalidator} | |
534 | \end{itemize} | |
535 | ||
536 | \subsection{View classes}\label{proplistviewclasses} | |
537 | ||
538 | View classes mediate between a property sheet and a physical window. | |
539 | ||
540 | \begin{itemize}\itemsep=0pt | |
541 | \item \helpref{wxPropertyView}{wxpropertyview} | |
542 | \item \helpref{wxPropertyListView}{wxpropertylistview} | |
543 | \item \helpref{wxPropertyFormView}{wxpropertyformview} | |
544 | \end{itemize} | |
545 | ||
546 | \subsection{Window classes}\label{proplistwindowclasses} | |
547 | ||
548 | The class library defines some window classes that can be used as-is with a suitable | |
549 | view class and property sheet. | |
550 | ||
551 | \begin{itemize}\itemsep=0pt | |
552 | \item \helpref{wxPropertyFormFrame}{wxpropertyformframe} | |
553 | \item \helpref{wxPropertyFormDialog}{wxpropertyformdialog} | |
554 | \item \helpref{wxPropertyFormPanel}{wxpropertyformpanel} | |
555 | \item \helpref{wxPropertyListFrame}{wxpropertylistframe} | |
556 | \item \helpref{wxPropertyListDialog}{wxpropertylistdialog} | |
557 | \item \helpref{wxPropertyListPanel}{wxpropertylistpanel} | |
558 | \end{itemize} | |
559 | ||
560 | \subsection{Registry classes} | |
561 | ||
562 | A validator registry is a list of validators that can be applied to properties in a property sheet. | |
563 | There may be one or more registries per property view. | |
564 | ||
565 | \begin{itemize}\itemsep=0pt | |
566 | \item \helpref{wxPropertyValidatorRegistry}{wxpropertyvalidatorregistry} | |
567 | \end{itemize} |