]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: property.h | |
3 | // Purpose: interface of wxPGProperty | |
4 | // Author: wxWidgets team | |
526954c5 | 5 | // Licence: wxWindows licence |
1c4293cb VZ |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | ||
9 | #define wxNullProperty ((wxPGProperty*)NULL) | |
10 | ||
11 | ||
0ad10f30 FM |
12 | /** |
13 | @section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers | |
1c4293cb | 14 | |
0ad10f30 FM |
15 | wxPGProperty::SetAttribute() and wxPropertyGridInterface::SetPropertyAttribute() |
16 | accept one of these as attribute name argument. | |
1c4293cb | 17 | |
0ad10f30 FM |
18 | You can use strings instead of constants. |
19 | However, some of these constants are redefined to use cached strings which | |
20 | may reduce your binary size by some amount. | |
1c4293cb VZ |
21 | |
22 | @{ | |
23 | */ | |
24 | ||
25 | /** Set default value for property. | |
26 | */ | |
27 | #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue") | |
28 | ||
29 | /** Universal, int or double. Minimum value for numeric properties. | |
30 | */ | |
31 | #define wxPG_ATTR_MIN wxS("Min") | |
32 | ||
33 | /** Universal, int or double. Maximum value for numeric properties. | |
34 | */ | |
35 | #define wxPG_ATTR_MAX wxS("Max") | |
36 | ||
37 | /** Universal, string. When set, will be shown as text after the displayed | |
38 | text value. Alternatively, if third column is enabled, text will be shown | |
39 | there (for any type of property). | |
40 | */ | |
41 | #define wxPG_ATTR_UNITS wxS("Units") | |
42 | ||
534090e3 JS |
43 | /** When set, will be shown as 'greyed' text in property's value cell when |
44 | the actual displayed value is blank. | |
45 | */ | |
46 | #define wxPG_ATTR_HINT wxS("Hint") | |
47 | ||
48 | /** | |
f83dc485 | 49 | @deprecated Use "Hint" (wxPG_ATTR_HINT) instead. |
1c4293cb VZ |
50 | */ |
51 | #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") | |
52 | ||
66fb9e12 JS |
53 | /** Universal, wxArrayString. Set to enable auto-completion in any |
54 | wxTextCtrl-based property editor. | |
55 | */ | |
56 | #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") | |
57 | ||
16372f0d JS |
58 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
59 | Default value is False. | |
60 | ||
61 | When set to True, bool property will use check box instead of a | |
62 | combo box as its editor control. If you set this attribute | |
63 | for a wxFlagsProperty, it is automatically applied to child | |
64 | bool properties. | |
1c4293cb VZ |
65 | */ |
66 | #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") | |
67 | ||
16372f0d JS |
68 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
69 | Default value is False. | |
70 | ||
71 | Set to True for the bool property to cycle value on double click | |
72 | (instead of showing the popup listbox). If you set this attribute | |
73 | for a wxFlagsProperty, it is automatically applied to child | |
74 | bool properties. | |
1c4293cb VZ |
75 | */ |
76 | #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") | |
77 | ||
78 | /** wxFloatProperty (and similar) specific, int, default -1. Sets the (max) precision | |
79 | used when floating point value is rendered as text. The default -1 means infinite | |
80 | precision. | |
81 | */ | |
82 | #define wxPG_FLOAT_PRECISION wxS("Precision") | |
83 | ||
84 | /** The text will be echoed as asterisks (wxTE_PASSWORD will be passed to textctrl etc). | |
85 | */ | |
86 | #define wxPG_STRING_PASSWORD wxS("Password") | |
87 | ||
88 | /** Define base used by a wxUIntProperty. Valid constants are | |
89 | wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL | |
90 | (lowercase characters). | |
91 | */ | |
92 | #define wxPG_UINT_BASE wxS("Base") | |
93 | ||
94 | /** Define prefix rendered to wxUIntProperty. Accepted constants | |
95 | wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN. | |
96 | <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal | |
97 | numbers. | |
98 | */ | |
99 | #define wxPG_UINT_PREFIX wxS("Prefix") | |
100 | ||
101 | /** wxFileProperty/wxImageFileProperty specific, wxChar*, default is detected/varies. | |
102 | Sets the wildcard used in the triggered wxFileDialog. Format is the | |
103 | same. | |
104 | */ | |
105 | #define wxPG_FILE_WILDCARD wxS("Wildcard") | |
106 | ||
107 | /** wxFileProperty/wxImageFileProperty specific, int, default 1. | |
108 | When 0, only the file name is shown (i.e. drive and directory are hidden). | |
109 | */ | |
110 | #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath") | |
111 | ||
112 | /** Specific to wxFileProperty and derived properties, wxString, default empty. | |
113 | If set, then the filename is shown relative to the given path string. | |
114 | */ | |
115 | #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath") | |
116 | ||
117 | /** Specific to wxFileProperty and derived properties, wxString, default is empty. | |
118 | Sets the initial path of where to look for files. | |
119 | */ | |
120 | #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") | |
121 | ||
122 | /** Specific to wxFileProperty and derivatives, wxString, default is empty. | |
123 | Sets a specific title for the dir dialog. | |
124 | */ | |
125 | #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") | |
126 | ||
2d5409f9 VZ |
127 | /** Specific to wxFileProperty and derivatives, long, default is 0. |
128 | Sets a specific wxFileDialog style for the file dialog, e.g. ::wxFD_SAVE. | |
129 | ||
130 | @since 2.9.4 | |
131 | */ | |
132 | #define wxPG_FILE_DIALOG_STYLE wxS("DialogStyle") | |
133 | ||
1c4293cb VZ |
134 | /** Specific to wxDirProperty, wxString, default is empty. |
135 | Sets a specific message for the dir dialog. | |
136 | */ | |
137 | #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") | |
138 | ||
525b2912 | 139 | /** |
57ab6f23 | 140 | wxArrayStringProperty's string delimiter character. If this is a quotation |
525b2912 JS |
141 | mark or hyphen, then strings will be quoted instead (with given |
142 | character). | |
143 | ||
144 | Default delimiter is quotation mark. | |
145 | */ | |
146 | #define wxPG_ARRAY_DELIMITER wxS("Delimiter") | |
147 | ||
1c4293cb VZ |
148 | /** Sets displayed date format for wxDateProperty. |
149 | */ | |
150 | #define wxPG_DATE_FORMAT wxS("DateFormat") | |
151 | ||
152 | /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default | |
b6fd0b42 JS |
153 | is wxDP_DEFAULT | wxDP_SHOWCENTURY. Using wxDP_ALLOWNONE will enable |
154 | better unspecified value support in the editor. | |
1c4293cb VZ |
155 | */ |
156 | #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle") | |
157 | ||
158 | /** SpinCtrl editor, int or double. How much number changes when button is | |
57ab6f23 | 159 | pressed (or up/down on keyboard). |
1c4293cb VZ |
160 | */ |
161 | #define wxPG_ATTR_SPINCTRL_STEP wxS("Step") | |
162 | ||
0ad10f30 | 163 | /** SpinCtrl editor, bool. If @true, value wraps at Min/Max. |
1c4293cb VZ |
164 | */ |
165 | #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap") | |
166 | ||
18e046a7 JS |
167 | /** SpinCtrl editor, bool. If @true, value can also by changed by moving |
168 | mouse when left mouse button is being pressed. | |
169 | */ | |
170 | #define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxS("MotionSpin") | |
171 | ||
1c4293cb VZ |
172 | /** wxMultiChoiceProperty, int. If 0, no user strings allowed. If 1, user strings |
173 | appear before list strings. If 2, user strings appear after list string. | |
174 | */ | |
175 | #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode") | |
176 | ||
177 | /** wxColourProperty and its kind, int, default 1. Setting this attribute to 0 hides custom | |
178 | colour from property's list of choices. | |
179 | */ | |
180 | #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom") | |
181 | ||
6f3f3898 JS |
182 | /** |
183 | wxColourProperty and its kind: Set to True in order to support editing | |
184 | alpha colour component. | |
185 | */ | |
186 | #define wxPG_COLOUR_HAS_ALPHA wxS("HasAlpha") | |
187 | ||
1c4293cb VZ |
188 | /** @} |
189 | */ | |
190 | ||
1c4293cb | 191 | |
6cf5edea JS |
192 | /** @section propgrid_propflags wxPGProperty Flags |
193 | @{ | |
194 | */ | |
195 | ||
196 | enum wxPGPropertyFlags | |
197 | { | |
198 | ||
199 | /** Indicates bold font. | |
200 | */ | |
201 | wxPG_PROP_MODIFIED = 0x0001, | |
202 | ||
203 | /** Disables ('greyed' text and editor does not activate) property. | |
204 | */ | |
205 | wxPG_PROP_DISABLED = 0x0002, | |
206 | ||
207 | /** Hider button will hide this property. | |
208 | */ | |
209 | wxPG_PROP_HIDDEN = 0x0004, | |
210 | ||
211 | /** This property has custom paint image just in front of its value. | |
212 | If property only draws custom images into a popup list, then this | |
213 | flag should not be set. | |
214 | */ | |
215 | wxPG_PROP_CUSTOMIMAGE = 0x0008, | |
216 | ||
217 | /** Do not create text based editor for this property (but button-triggered | |
218 | dialog and choice are ok). | |
219 | */ | |
220 | wxPG_PROP_NOEDITOR = 0x0010, | |
221 | ||
222 | /** Property is collapsed, ie. it's children are hidden. | |
223 | */ | |
224 | wxPG_PROP_COLLAPSED = 0x0020, | |
225 | ||
226 | /** | |
227 | If property is selected, then indicates that validation failed for pending | |
228 | value. | |
229 | ||
57ab6f23 | 230 | If property is not selected, then indicates that the actual property |
4c51a665 DS |
231 | value has failed validation (NB: this behaviour is not currently supported, |
232 | but may be used in the future). | |
6cf5edea JS |
233 | */ |
234 | wxPG_PROP_INVALID_VALUE = 0x0040, | |
235 | ||
236 | // 0x0080, | |
237 | ||
238 | /** Switched via SetWasModified(). Temporary flag - only used when | |
239 | setting/changing property value. | |
240 | */ | |
241 | wxPG_PROP_WAS_MODIFIED = 0x0200, | |
242 | ||
243 | /** | |
244 | If set, then child properties (if any) are private, and should be | |
245 | "invisible" to the application. | |
246 | */ | |
247 | wxPG_PROP_AGGREGATE = 0x0400, | |
248 | ||
249 | /** If set, then child properties (if any) are copies and should not | |
250 | be deleted in dtor. | |
251 | */ | |
252 | wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800, | |
253 | ||
254 | /** | |
255 | Classifies this item as a non-category. | |
256 | ||
257 | Used for faster item type identification. | |
258 | */ | |
259 | wxPG_PROP_PROPERTY = 0x1000, | |
260 | ||
261 | /** | |
262 | Classifies this item as a category. | |
263 | ||
264 | Used for faster item type identification. | |
265 | */ | |
266 | wxPG_PROP_CATEGORY = 0x2000, | |
267 | ||
268 | /** Classifies this item as a property that has children, but is not aggregate | |
269 | (ie children are not private). | |
270 | */ | |
271 | wxPG_PROP_MISC_PARENT = 0x4000, | |
272 | ||
273 | /** Property is read-only. Editor is still created for wxTextCtrl-based | |
274 | property editors. For others, editor is not usually created because | |
275 | they do implement wxTE_READONLY style or equivalent. | |
276 | */ | |
277 | wxPG_PROP_READONLY = 0x8000, | |
278 | ||
279 | // | |
280 | // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS | |
281 | // | |
282 | ||
283 | /** Property's value is composed from values of child properties. | |
284 | @remarks | |
285 | This flag cannot be used with property iterators. | |
286 | */ | |
287 | wxPG_PROP_COMPOSED_VALUE = 0x00010000, | |
288 | ||
289 | /** Common value of property is selectable in editor. | |
290 | @remarks | |
291 | This flag cannot be used with property iterators. | |
292 | */ | |
293 | wxPG_PROP_USES_COMMON_VALUE = 0x00020000, | |
294 | ||
295 | /** Property can be set to unspecified value via editor. | |
296 | Currently, this applies to following properties: | |
297 | - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty: | |
298 | Clear the text field | |
299 | ||
300 | @remarks | |
301 | This flag cannot be used with property iterators. | |
6c78066f JS |
302 | |
303 | @see wxPGProperty::SetAutoUnspecified() | |
6cf5edea JS |
304 | */ |
305 | wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000, | |
306 | ||
307 | /** Indicates the bit useable by derived properties. | |
308 | */ | |
309 | wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000, | |
310 | ||
311 | /** Indicates the bit useable by derived properties. | |
312 | */ | |
313 | wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000, | |
314 | ||
315 | /** Indicates that the property is being deleted and should be ignored. | |
316 | */ | |
317 | wxPG_PROP_BEING_DELETED = 0x00200000 | |
318 | ||
319 | }; | |
320 | ||
321 | /** Topmost flag. | |
322 | */ | |
323 | #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED | |
324 | ||
325 | /** Property with children must have one of these set, otherwise iterators | |
326 | will not work correctly. | |
327 | Code should automatically take care of this, however. | |
328 | */ | |
329 | #define wxPG_PROP_PARENTAL_FLAGS \ | |
330 | ((wxPGPropertyFlags)(wxPG_PROP_AGGREGATE | \ | |
331 | wxPG_PROP_CATEGORY | \ | |
332 | wxPG_PROP_MISC_PARENT)) | |
333 | ||
334 | /** @} | |
335 | */ | |
336 | ||
0ad10f30 FM |
337 | |
338 | /** | |
339 | @class wxPGProperty | |
1c4293cb VZ |
340 | |
341 | wxPGProperty is base class for all wxPropertyGrid properties. In | |
342 | sections below we cover few related topics. | |
343 | ||
344 | @li @ref pgproperty_properties | |
345 | @li @ref pgproperty_creating | |
346 | ||
347 | @section pgproperty_properties Supplied Ready-to-use Property Classes | |
348 | ||
349 | Here is a list and short description of supplied fully-functional | |
350 | property classes. They are located in either props.h or advprops.h. | |
351 | ||
352 | @li @ref wxArrayStringProperty | |
353 | @li @ref wxBoolProperty | |
354 | @li @ref wxColourProperty | |
355 | @li @ref wxCursorProperty | |
356 | @li @ref wxDateProperty | |
357 | @li @ref wxDirProperty | |
358 | @li @ref wxEditEnumProperty | |
359 | @li @ref wxEnumProperty | |
360 | @li @ref wxFileProperty | |
361 | @li @ref wxFlagsProperty | |
362 | @li @ref wxFloatProperty | |
363 | @li @ref wxFontProperty | |
364 | @li @ref wxImageFileProperty | |
365 | @li @ref wxIntProperty | |
366 | @li @ref wxLongStringProperty | |
367 | @li @ref wxMultiChoiceProperty | |
368 | @li @ref wxPropertyCategory | |
369 | @li @ref wxStringProperty | |
370 | @li @ref wxSystemColourProperty | |
371 | @li @ref wxUIntProperty | |
372 | ||
373 | @subsection wxPropertyCategory | |
374 | ||
375 | Not an actual property per se, but a header for a group of properties. | |
e16bff8e JS |
376 | Regardless inherits from wxPGProperty, and supports displaying 'labels' |
377 | for columns other than the first one. Easiest way to set category's | |
378 | label for second column is to call wxPGProperty::SetValue() with string | |
379 | argument. | |
1c4293cb VZ |
380 | |
381 | @subsection wxStringProperty | |
382 | ||
383 | Simple string property. wxPG_STRING_PASSWORD attribute may be used | |
384 | to echo value as asterisks and use wxTE_PASSWORD for wxTextCtrl. | |
66fb9e12 JS |
385 | wxPG_ATTR_AUTOCOMPLETE attribute may be used to enable auto-completion |
386 | (use a wxArrayString value), and is also supported by any property that | |
387 | happens to use a wxTextCtrl-based editor. | |
1c4293cb | 388 | |
bb6720bb JS |
389 | @remarks wxStringProperty has a special trait: if it has value of |
390 | "<composed>", and also has child properties, then its displayed | |
391 | value becomes composition of child property values, similar as | |
392 | with wxFontProperty, for instance. | |
1c4293cb VZ |
393 | |
394 | @subsection wxIntProperty | |
395 | ||
396 | Like wxStringProperty, but converts text to a signed long integer. | |
397 | wxIntProperty seamlessly supports 64-bit integers (ie. wxLongLong). | |
a6162a3e JS |
398 | To safely convert variant to integer, use code like this: |
399 | ||
400 | @code | |
401 | wxLongLong ll; | |
402 | ll << property->GetValue(); | |
403 | ||
404 | // or | |
405 | wxLongLong ll = propertyGrid->GetPropertyValueAsLong(property); | |
406 | @endcode | |
1c4293cb VZ |
407 | |
408 | @subsection wxUIntProperty | |
409 | ||
410 | Like wxIntProperty, but displays value as unsigned int. To set | |
411 | the prefix used globally, manipulate wxPG_UINT_PREFIX string attribute. | |
412 | To set the globally used base, manipulate wxPG_UINT_BASE int | |
413 | attribute. Regardless of current prefix, understands (hex) values starting | |
414 | with both "0x" and "$". | |
a6162a3e JS |
415 | Like wxIntProperty, wxUIntProperty seamlessly supports 64-bit unsigned |
416 | integers (ie. wxULongLong). Same wxVariant safety rules apply. | |
1c4293cb VZ |
417 | |
418 | @subsection wxFloatProperty | |
419 | ||
420 | Like wxStringProperty, but converts text to a double-precision floating point. | |
421 | Default float-to-text precision is 6 decimals, but this can be changed | |
422 | by modifying wxPG_FLOAT_PRECISION attribute. | |
423 | ||
25199f98 JS |
424 | Note that when displaying the value, sign is omitted if the resulting |
425 | textual representation is effectively zero (for example, -0.0001 with | |
4c51a665 | 426 | precision of 3 will become 0.0 instead of -0.0). This behaviour is unlike |
25199f98 JS |
427 | what C standard library does, but should result in better end-user |
428 | experience in almost all cases. | |
429 | ||
1c4293cb VZ |
430 | @subsection wxBoolProperty |
431 | ||
432 | Represents a boolean value. wxChoice is used as editor control, by the | |
4c51a665 DS |
433 | default. wxPG_BOOL_USE_CHECKBOX attribute can be set to true in order to |
434 | use check box instead. | |
1c4293cb VZ |
435 | |
436 | @subsection wxLongStringProperty | |
437 | ||
438 | Like wxStringProperty, but has a button that triggers a small text editor | |
439 | dialog. Note that in long string values, tabs are represented by "\t" and | |
440 | line break by "\n". | |
441 | ||
3a89adc1 JS |
442 | To display custom dialog on button press, you can subclass |
443 | wxLongStringProperty and implement OnButtonClick, like this: | |
444 | ||
445 | @code | |
446 | virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value ) | |
447 | { | |
3a89adc1 JS |
448 | wxSize dialogSize(...size of your dialog...); |
449 | ||
450 | wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this, | |
451 | dialogSize) | |
452 | ||
453 | // Create dialog dlg at dlgPos. Use value as initial string | |
454 | // value. | |
455 | ... | |
456 | ||
457 | if ( dlg.ShowModal() == wxID_OK ) | |
458 | { | |
459 | value = dlg.GetStringValue); | |
460 | return true; | |
461 | } | |
462 | return false; | |
463 | } | |
464 | @endcode | |
465 | ||
466 | Also, if you wish not to have line breaks and tabs translated to | |
467 | escape sequences, then do following in constructor of your subclass: | |
468 | ||
469 | @code | |
470 | m_flags |= wxPG_PROP_NO_ESCAPE; | |
471 | @endcode | |
472 | ||
1c4293cb VZ |
473 | @subsection wxDirProperty |
474 | ||
475 | Like wxLongStringProperty, but the button triggers dir selector instead. | |
476 | Supported properties (all with string value): wxPG_DIR_DIALOG_MESSAGE. | |
477 | ||
478 | @subsection wxFileProperty | |
479 | ||
480 | Like wxLongStringProperty, but the button triggers file selector instead. | |
481 | Default wildcard is "All files..." but this can be changed by setting | |
482 | wxPG_FILE_WILDCARD attribute (see wxFileDialog for format details). | |
4c51a665 | 483 | Attribute wxPG_FILE_SHOW_FULL_PATH can be set to @false in order to show |
1c4293cb VZ |
484 | only the filename, not the entire path. |
485 | ||
486 | @subsection wxEnumProperty | |
487 | ||
488 | Represents a single selection from a list of choices - | |
489 | wxOwnerDrawnComboBox is used to edit the value. | |
490 | ||
491 | @subsection wxFlagsProperty | |
492 | ||
16372f0d JS |
493 | Represents a bit set that fits in a long integer. wxBoolProperty sub- |
494 | properties are created for editing individual bits. Textctrl is created to | |
57ab6f23 | 495 | manually edit the flags as a text; a continuous sequence of spaces, commas |
16372f0d JS |
496 | and semicolons are considered as a flag id separator. |
497 | ||
498 | <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty, | |
499 | you will need to use wxPGProperty::SetChoices() - otherwise they will not | |
500 | get updated properly. | |
501 | ||
502 | wxFlagsProperty supports the same attributes as wxBoolProperty. | |
1c4293cb VZ |
503 | |
504 | @subsection wxArrayStringProperty | |
505 | ||
aae9e5bd JS |
506 | Allows editing of a list of strings in wxTextCtrl and in a separate |
507 | dialog. Supports "Delimiter" attribute, which defaults to comma (','). | |
1c4293cb VZ |
508 | |
509 | @subsection wxDateProperty | |
510 | ||
57ab6f23 | 511 | wxDateTime property. Default editor is DatePickerCtrl, although TextCtrl |
1c4293cb | 512 | should work as well. wxPG_DATE_FORMAT attribute can be used to change |
57ab6f23 | 513 | string wxDateTime::Format uses (although default is recommended as it is |
8cddee2d | 514 | locale-dependent), and wxPG_DATE_PICKER_STYLE allows changing window |
1c4293cb | 515 | style given to DatePickerCtrl (default is wxDP_DEFAULT|wxDP_SHOWCENTURY). |
b6fd0b42 | 516 | Using wxDP_ALLOWNONE will enable better unspecified value support. |
1c4293cb VZ |
517 | |
518 | @subsection wxEditEnumProperty | |
519 | ||
520 | Represents a string that can be freely edited or selected from list of choices - | |
521 | custom combobox control is used to edit the value. | |
522 | ||
523 | @subsection wxMultiChoiceProperty | |
524 | ||
525 | Allows editing a multiple selection from a list of strings. This is | |
526 | property is pretty much built around concept of wxMultiChoiceDialog. | |
527 | It uses wxArrayString value. | |
528 | ||
529 | @subsection wxImageFileProperty | |
530 | ||
531 | Like wxFileProperty, but has thumbnail of the image in front of | |
532 | the filename and autogenerates wildcard from available image handlers. | |
533 | ||
534 | @subsection wxColourProperty | |
535 | ||
536 | <b>Useful alternate editor:</b> Choice. | |
537 | ||
538 | Represents wxColour. wxButton is used to trigger a colour picker dialog. | |
d61d8cff JS |
539 | There are various sub-classing opportunities with this class. See |
540 | below in wxSystemColourProperty section for details. | |
1c4293cb | 541 | |
6f3f3898 JS |
542 | Setting "HasAlpha" attribute to @true for this property allows user to |
543 | edit the alpha colour component. | |
544 | ||
1c4293cb VZ |
545 | @subsection wxFontProperty |
546 | ||
547 | Represents wxFont. Various sub-properties are used to edit individual | |
548 | subvalues. | |
549 | ||
550 | @subsection wxSystemColourProperty | |
551 | ||
552 | Represents wxColour and a system colour index. wxChoice is used to edit | |
553 | the value. Drop-down list has color images. Note that value type | |
d61d8cff JS |
554 | is wxColourPropertyValue instead of wxColour (which wxColourProperty |
555 | uses). | |
556 | ||
1c4293cb VZ |
557 | @code |
558 | class wxColourPropertyValue : public wxObject | |
559 | { | |
560 | public: | |
561 | // An integer value relating to the colour, and which exact | |
562 | // meaning depends on the property with which it is used. | |
563 | // | |
564 | // For wxSystemColourProperty: | |
565 | // Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR | |
566 | // macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM. | |
567 | wxUint32 m_type; | |
568 | ||
569 | // Resulting colour. Should be correct regardless of type. | |
570 | wxColour m_colour; | |
571 | }; | |
572 | @endcode | |
0ad10f30 | 573 | |
d61d8cff | 574 | in wxSystemColourProperty, and its derived class wxColourProperty, there |
57ab6f23 | 575 | are various sub-classing features. To set a basic list of colour |
d61d8cff JS |
576 | names, call wxPGProperty::SetChoices(). |
577 | ||
578 | @code | |
579 | // Override in derived class to customize how colours are translated | |
580 | // to strings. | |
581 | virtual wxString ColourToString( const wxColour& col, int index ) const; | |
582 | ||
583 | // Returns index of entry that triggers colour picker dialog | |
584 | // (default is last). | |
585 | virtual int GetCustomColourIndex() const; | |
586 | ||
587 | // Helper function to show the colour dialog | |
588 | bool QueryColourFromUser( wxVariant& variant ) const; | |
589 | ||
590 | // Returns colour for given choice. | |
591 | // Default function returns wxSystemSettings::GetColour(index). | |
592 | virtual wxColour GetColour( int index ) const; | |
593 | @endcode | |
1c4293cb VZ |
594 | |
595 | @subsection wxCursorProperty | |
596 | ||
597 | Represents a wxCursor. wxChoice is used to edit the value. | |
598 | Drop-down list has cursor images under some (wxMSW) platforms. | |
599 | ||
600 | ||
601 | @section pgproperty_creating Creating Custom Properties | |
602 | ||
603 | New properties can be created by subclassing wxPGProperty or one | |
604 | of the provided property classes, and (re)implementing necessary | |
605 | member functions. Below, each virtual member function has ample | |
606 | documentation about its purpose and any odd details which to keep | |
607 | in mind. | |
608 | ||
609 | Here is a very simple 'template' code: | |
610 | ||
611 | @code | |
612 | class MyProperty : public wxPGProperty | |
613 | { | |
614 | public: | |
a6ca568c JS |
615 | // Default constructor |
616 | MyProperty() { } | |
617 | ||
618 | // All arguments of this ctor must have a default value - | |
1c4293cb VZ |
619 | // use wxPG_LABEL for label and name |
620 | MyProperty( const wxString& label = wxPG_LABEL, | |
621 | const wxString& name = wxPG_LABEL, | |
622 | const wxString& value = wxEmptyString ) | |
a6ca568c | 623 | : wxPGProperty(label, name) |
1c4293cb VZ |
624 | { |
625 | // m_value is wxVariant | |
626 | m_value = value; | |
627 | } | |
628 | ||
629 | virtual ~MyProperty() { } | |
630 | ||
631 | const wxPGEditor* DoGetEditorClass() const | |
632 | { | |
633 | // Determines editor used by property. | |
634 | // You can replace 'TextCtrl' below with any of these | |
635 | // builtin-in property editor identifiers: Choice, ComboBox, | |
636 | // TextCtrlAndButton, ChoiceAndButton, CheckBox, SpinCtrl, | |
637 | // DatePickerCtrl. | |
638 | return wxPGEditor_TextCtrl; | |
639 | } | |
640 | ||
1425eca5 JS |
641 | virtual wxString ValueToString( wxVariant& value, |
642 | int argFlags ) const | |
1c4293cb | 643 | { |
1425eca5 | 644 | // TODO: Convert given property value to a string |
1c4293cb VZ |
645 | } |
646 | ||
647 | virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags ) | |
648 | { | |
649 | // TODO: Adapt string to property value. | |
650 | } | |
651 | ||
652 | protected: | |
653 | }; | |
654 | @endcode | |
655 | ||
656 | Since wxPGProperty derives from wxObject, you can use standard | |
b19b28c8 | 657 | wxDECLARE_DYNAMIC_CLASS and wxIMPLEMENT_DYNAMIC_CLASS macros. From the |
1c4293cb VZ |
658 | above example they were omitted for sake of simplicity, and besides, |
659 | they are only really needed if you need to use wxRTTI with your | |
660 | property class. | |
661 | ||
0372d42e JS |
662 | You can change the 'value type' of a property by simply assigning different |
663 | type of variant with SetValue. <b>It is mandatory to implement | |
664 | wxVariantData class for all data types used as property values.</b> | |
665 | You can use macros declared in wxPropertyGrid headers. For instance: | |
1c4293cb VZ |
666 | |
667 | @code | |
668 | // In header file: | |
0372d42e JS |
669 | // (If you need to have export declaration, use version of macros |
670 | // with _EXPORTED postfix) | |
671 | WX_PG_DECLARE_VARIANT_DATA(MyDataClass) | |
1c4293cb VZ |
672 | |
673 | // In sources file: | |
0372d42e JS |
674 | WX_PG_IMPLEMENT_VARIANT_DATA(MyDataClass) |
675 | ||
676 | // Or, if you don't have valid == operator: | |
677 | WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(MyDataClass) | |
1c4293cb VZ |
678 | @endcode |
679 | ||
680 | @library{wxpropgrid} | |
681 | @category{propgrid} | |
682 | */ | |
683 | class wxPGProperty : public wxObject | |
684 | { | |
685 | public: | |
686 | typedef wxUint32 FlagType; | |
687 | ||
bb6720bb JS |
688 | /** |
689 | Default constructor. | |
1c4293cb VZ |
690 | */ |
691 | wxPGProperty(); | |
692 | ||
bb6720bb JS |
693 | /** |
694 | Constructor. | |
1c4293cb VZ |
695 | Non-abstract property classes should have constructor of this style: |
696 | ||
697 | @code | |
698 | ||
bb6720bb | 699 | MyProperty( const wxString& label, const wxString& name, const T& value ) |
a6ca568c | 700 | : wxPGProperty(label, name) |
1c4293cb VZ |
701 | { |
702 | // Generally recommended way to set the initial value | |
703 | // (as it should work in pretty much 100% of cases). | |
704 | wxVariant variant; | |
705 | variant << value; | |
706 | SetValue(variant); | |
707 | ||
48a32cf6 JS |
708 | // If has private child properties then create them here. |
709 | // For example: | |
710 | // AddPrivateChild( new wxStringProperty("Subprop 1", | |
711 | // wxPG_LABEL, | |
712 | // value.GetSubProp1())); | |
1c4293cb VZ |
713 | } |
714 | ||
715 | @endcode | |
716 | */ | |
717 | wxPGProperty( const wxString& label, const wxString& name ); | |
718 | ||
bb6720bb JS |
719 | /** |
720 | Virtual destructor. It is customary for derived properties to implement this. | |
721 | */ | |
1c4293cb VZ |
722 | virtual ~wxPGProperty(); |
723 | ||
bb6720bb JS |
724 | /** |
725 | This virtual function is called after m_value has been set. | |
1c4293cb VZ |
726 | |
727 | @remarks | |
728 | - If m_value was set to Null variant (ie. unspecified value), OnSetValue() | |
729 | will not be called. | |
730 | - m_value may be of any variant type. Typically properties internally support only | |
731 | one variant type, and as such OnSetValue() provides a good opportunity to convert | |
732 | supported values into internal type. | |
733 | - Default implementation does nothing. | |
734 | */ | |
735 | virtual void OnSetValue(); | |
736 | ||
bb6720bb JS |
737 | /** |
738 | Override this to return something else than m_value as the value. | |
1c4293cb | 739 | */ |
0ad10f30 | 740 | virtual wxVariant DoGetValue() const; |
1c4293cb | 741 | |
bb6720bb JS |
742 | /** |
743 | Implement this function in derived class to check the value. | |
0ad10f30 | 744 | Return @true if it is ok. Returning @false prevents property change events |
1c4293cb VZ |
745 | from occurring. |
746 | ||
747 | @remarks | |
0ad10f30 | 748 | - Default implementation always returns @true. |
1c4293cb VZ |
749 | */ |
750 | virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const; | |
751 | ||
bb6720bb | 752 | /** |
9e6bebdc JS |
753 | Converts text into wxVariant value appropriate for this property. |
754 | ||
755 | @param variant | |
756 | On function entry this is the old value (should not be wxNullVariant | |
757 | in normal cases). Translated value must be assigned back to it. | |
758 | ||
759 | @param text | |
760 | Text to be translated into variant. | |
761 | ||
1c4293cb | 762 | @param argFlags |
9e6bebdc JS |
763 | If wxPG_FULL_VALUE is set, returns complete, storable value instead |
764 | of displayable one (they may be different). | |
765 | If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of | |
1425eca5 | 766 | composite property string value (as generated by ValueToString() |
9e6bebdc | 767 | called with this same flag). |
1c4293cb | 768 | |
9e6bebdc JS |
769 | @return Returns @true if resulting wxVariant value was different. |
770 | ||
771 | @remarks Default implementation converts semicolon delimited tokens into | |
772 | child values. Only works for properties with children. | |
773 | ||
774 | You might want to take into account that m_value is Null variant | |
775 | if property value is unspecified (which is usually only case if | |
4c51a665 | 776 | you explicitly enabled that sort behaviour). |
1c4293cb VZ |
777 | */ |
778 | virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const; | |
779 | ||
bb6720bb | 780 | /** |
9e6bebdc JS |
781 | Converts integer (possibly a choice selection) into wxVariant value |
782 | appropriate for this property. | |
783 | ||
784 | @param variant | |
785 | On function entry this is the old value (should not be wxNullVariant | |
786 | in normal cases). Translated value must be assigned back to it. | |
9e6bebdc JS |
787 | @param number |
788 | Integer to be translated into variant. | |
1c4293cb | 789 | @param argFlags |
9e6bebdc JS |
790 | If wxPG_FULL_VALUE is set, returns complete, storable value instead |
791 | of displayable one. | |
792 | ||
793 | @return Returns @true if resulting wxVariant value was different. | |
1c4293cb VZ |
794 | |
795 | @remarks | |
796 | - If property is not supposed to use choice or spinctrl or other editor | |
797 | with int-based value, it is not necessary to implement this method. | |
798 | - Default implementation simply assign given int to m_value. | |
9e6bebdc JS |
799 | - If property uses choice control, and displays a dialog on some choice |
800 | items, then it is preferred to display that dialog in IntToValue | |
801 | instead of OnEvent. | |
0ad10f30 | 802 | - You might want to take into account that m_value is Mull variant if |
9e6bebdc | 803 | property value is unspecified (which is usually only case if you |
4c51a665 | 804 | explicitly enabled that sort behaviour). |
1c4293cb | 805 | */ |
0ad10f30 | 806 | virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const; |
1c4293cb | 807 | |
bb6720bb | 808 | /** |
1425eca5 | 809 | Converts property value into a text representation. |
1c4293cb | 810 | |
1425eca5 JS |
811 | @param value |
812 | Value to be converted. | |
1425eca5 JS |
813 | @param argFlags |
814 | If 0 (default value), then displayed string is returned. | |
815 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
816 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
0ad10f30 FM |
817 | string value that must be editable in textctrl. |
818 | If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
819 | display as a part of string property's composite text representation. | |
1425eca5 JS |
820 | |
821 | @remarks Default implementation calls GenerateComposedValue(). | |
1c4293cb | 822 | */ |
1425eca5 | 823 | virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const; |
1c4293cb | 824 | |
bb6720bb JS |
825 | /** |
826 | Converts string to a value, and if successful, calls SetValue() on it. | |
4c51a665 | 827 | Default behaviour is to do nothing. |
0ad10f30 | 828 | |
1c4293cb | 829 | @param text |
0ad10f30 FM |
830 | String to get the value from. |
831 | @param flags | |
832 | @todo docme | |
833 | ||
834 | @return @true if value was changed. | |
1c4293cb VZ |
835 | */ |
836 | bool SetValueFromString( const wxString& text, int flags = 0 ); | |
837 | ||
bb6720bb | 838 | /** |
4c51a665 DS |
839 | Converts integer to a value, and if successful, calls SetValue() on it. |
840 | Default behaviour is to do nothing. | |
0ad10f30 | 841 | |
1c4293cb | 842 | @param value |
0ad10f30 | 843 | Int to get the value from. |
1c4293cb | 844 | @param flags |
0ad10f30 FM |
845 | If has wxPG_FULL_VALUE, then the value given is a actual value and not an index. |
846 | ||
847 | @return @true if value was changed. | |
1c4293cb VZ |
848 | */ |
849 | bool SetValueFromInt( long value, int flags = 0 ); | |
850 | ||
bb6720bb JS |
851 | /** |
852 | Returns size of the custom painted image in front of property. This method | |
1c4293cb VZ |
853 | must be overridden to return non-default value if OnCustomPaint is to be |
854 | called. | |
0ad10f30 | 855 | |
1c4293cb | 856 | @param item |
0ad10f30 FM |
857 | Normally -1, but can be an index to the property's list of items. |
858 | ||
1c4293cb | 859 | @remarks |
4c51a665 | 860 | - Default behaviour is to return wxSize(0,0), which means no image. |
1c4293cb VZ |
861 | - Default image width or height is indicated with dimension -1. |
862 | - You can also return wxPG_DEFAULT_IMAGE_SIZE which equals wxSize(-1, -1). | |
863 | */ | |
864 | virtual wxSize OnMeasureImage( int item = -1 ) const; | |
865 | ||
bb6720bb JS |
866 | /** |
867 | Events received by editor widgets are processed here. Note that editor class | |
1c4293cb VZ |
868 | usually processes most events. Some, such as button press events of |
869 | TextCtrlAndButton class, can be handled here. Also, if custom handling | |
870 | for regular events is desired, then that can also be done (for example, | |
ce7fe42e | 871 | wxSystemColourProperty custom handles @c wxEVT_CHOICE |
1c4293cb VZ |
872 | to display colour picker dialog when 'custom' selection is made). |
873 | ||
0ad10f30 FM |
874 | If the event causes value to be changed, SetValueInEvent() should be called |
875 | to set the new value. | |
876 | ||
877 | The parameter @a event is the associated wxEvent. | |
1c4293cb | 878 | |
1c4293cb | 879 | @retval |
0ad10f30 FM |
880 | Should return @true if any changes in value should be reported. |
881 | ||
1c4293cb VZ |
882 | @remarks |
883 | - If property uses choice control, and displays a dialog on some choice items, | |
884 | then it is preferred to display that dialog in IntToValue instead of OnEvent. | |
885 | */ | |
886 | virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event ); | |
887 | ||
bb6720bb | 888 | /** |
b8b1ff48 | 889 | Called after value of a child property has been altered. Must return |
57ab6f23 | 890 | new value of the whole property (after any alterations warranted by |
b8b1ff48 JS |
891 | child's new value). |
892 | ||
893 | Note that this function is usually called at the time that value of | |
894 | this property, or given child property, is still pending for change, | |
895 | and as such, result of GetValue() or m_value should not be relied | |
896 | on. | |
1c4293cb VZ |
897 | |
898 | Sample pseudo-code implementation: | |
899 | ||
900 | @code | |
b8b1ff48 JS |
901 | wxVariant MyProperty::ChildChanged( wxVariant& thisValue, |
902 | int childIndex, | |
903 | wxVariant& childValue ) const | |
1c4293cb VZ |
904 | { |
905 | // Acquire reference to actual type of data stored in variant | |
b8b1ff48 JS |
906 | // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros |
907 | // were used to create the variant class). | |
1c4293cb VZ |
908 | T& data = TFromVariant(thisValue); |
909 | ||
910 | // Copy childValue into data. | |
911 | switch ( childIndex ) | |
912 | { | |
913 | case 0: | |
914 | data.SetSubProp1( childvalue.GetLong() ); | |
915 | break; | |
916 | case 1: | |
917 | data.SetSubProp2( childvalue.GetString() ); | |
918 | break; | |
919 | ... | |
920 | } | |
b8b1ff48 JS |
921 | |
922 | // Return altered data | |
923 | return data; | |
1c4293cb VZ |
924 | } |
925 | @endcode | |
926 | ||
927 | @param thisValue | |
b8b1ff48 JS |
928 | Value of this property. Changed value should be returned (in |
929 | previous versions of wxPropertyGrid it was only necessary to | |
930 | write value back to this argument). | |
1c4293cb | 931 | @param childIndex |
b8b1ff48 JS |
932 | Index of child changed (you can use Item(childIndex) to get |
933 | child property). | |
1c4293cb | 934 | @param childValue |
b8b1ff48 JS |
935 | (Pending) value of the child property. |
936 | ||
937 | @return | |
938 | Modified value of the whole property. | |
1c4293cb | 939 | */ |
b8b1ff48 JS |
940 | virtual wxVariant ChildChanged( wxVariant& thisValue, |
941 | int childIndex, | |
942 | wxVariant& childValue ) const; | |
1c4293cb | 943 | |
bb6720bb JS |
944 | /** |
945 | Returns pointer to an instance of used editor. | |
1c4293cb VZ |
946 | */ |
947 | virtual const wxPGEditor* DoGetEditorClass() const; | |
948 | ||
bb6720bb JS |
949 | /** |
950 | Returns pointer to the wxValidator that should be used | |
0ad10f30 | 951 | with the editor of this property (@NULL for no validator). |
1c4293cb VZ |
952 | Setting validator explicitly via SetPropertyValidator |
953 | will override this. | |
954 | ||
955 | In most situations, code like this should work well | |
956 | (macros are used to maintain one actual validator instance, | |
957 | so on the second call the function exits within the first | |
958 | macro): | |
959 | ||
960 | @code | |
961 | ||
962 | wxValidator* wxMyPropertyClass::DoGetValidator () const | |
963 | { | |
964 | WX_PG_DOGETVALIDATOR_ENTRY() | |
965 | ||
966 | wxMyValidator* validator = new wxMyValidator(...); | |
967 | ||
968 | ... prepare validator... | |
969 | ||
970 | WX_PG_DOGETVALIDATOR_EXIT(validator) | |
971 | } | |
972 | ||
973 | @endcode | |
974 | ||
975 | @remarks | |
976 | You can get common filename validator by returning | |
977 | wxFileProperty::GetClassValidator(). wxDirProperty, | |
978 | for example, uses it. | |
979 | */ | |
980 | virtual wxValidator* DoGetValidator () const; | |
981 | ||
bb6720bb JS |
982 | /** |
983 | Override to paint an image in front of the property value text or drop-down | |
1c4293cb VZ |
984 | list item (but only if wxPGProperty::OnMeasureImage is overridden as well). |
985 | ||
986 | If property's OnMeasureImage() returns size that has height != 0 but less than | |
987 | row height ( < 0 has special meanings), wxPropertyGrid calls this method to | |
988 | draw a custom image in a limited area in front of the editor control or | |
989 | value text/graphics, and if control has drop-down list, then the image is | |
990 | drawn there as well (even in the case OnMeasureImage() returned higher height | |
991 | than row height). | |
992 | ||
993 | NOTE: Following applies when OnMeasureImage() returns a "flexible" height ( | |
994 | using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items: | |
995 | If rect.x is < 0, then this is a measure item call, which means that | |
996 | dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight | |
997 | to the height of the image of item at index paintdata.m_choiceItem. This call | |
998 | may be done even as often as once every drop-down popup show. | |
999 | ||
1000 | @param dc | |
1001 | wxDC to paint on. | |
1002 | @param rect | |
1003 | Box reserved for custom graphics. Includes surrounding rectangle, if any. | |
1004 | If x is < 0, then this is a measure item call (see above). | |
1005 | @param paintdata | |
e342075f JS |
1006 | wxPGPaintData structure with much useful data about painted item. |
1007 | @code | |
1008 | struct wxPGPaintData | |
1009 | { | |
1010 | // wxPropertyGrid. | |
1011 | const wxPropertyGrid* m_parent; | |
1012 | ||
1013 | // Normally -1, otherwise index to drop-down list item that has to be drawn. | |
1014 | int m_choiceItem; | |
1015 | ||
1016 | // Set to drawn width in OnCustomPaint (optional). | |
1017 | int m_drawnWidth; | |
1018 | ||
1019 | // In a measure item call, set this to the height of item at m_choiceItem index | |
939d9364 | 1020 | int m_drawnHeight; |
e342075f JS |
1021 | }; |
1022 | @endcode | |
1c4293cb VZ |
1023 | |
1024 | @remarks | |
1025 | - You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth | |
1026 | must be set to the full width drawn in pixels. | |
1027 | - Due to technical reasons, rect's height will be default even if custom height | |
1028 | was reported during measure call. | |
1029 | - Brush is guaranteed to be default background colour. It has been already used to | |
1030 | clear the background of area being painted. It can be modified. | |
1031 | - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for | |
1032 | drawing framing rectangle. It can be changed as well. | |
1033 | ||
1425eca5 | 1034 | @see ValueToString() |
1c4293cb VZ |
1035 | */ |
1036 | virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata ); | |
1037 | ||
bb6720bb JS |
1038 | /** |
1039 | Returns used wxPGCellRenderer instance for given property column (label=0, value=1). | |
1c4293cb VZ |
1040 | |
1041 | Default implementation returns editor's renderer for all columns. | |
1042 | */ | |
1043 | virtual wxPGCellRenderer* GetCellRenderer( int column ) const; | |
1044 | ||
bb6720bb JS |
1045 | /** |
1046 | Returns which choice is currently selected. Only applies to properties | |
939d9364 JS |
1047 | which have choices. |
1048 | ||
1049 | Needs to reimplemented in derived class if property value does not | |
1050 | map directly to a choice. Integer as index, bool, and string usually do. | |
1051 | */ | |
1052 | virtual int GetChoiceSelection() const; | |
1053 | ||
bb6720bb JS |
1054 | /** |
1055 | Refresh values of child properties. Automatically called after value is set. | |
1c4293cb VZ |
1056 | */ |
1057 | virtual void RefreshChildren(); | |
1058 | ||
bb6720bb | 1059 | /** |
14946ce1 JS |
1060 | Reimplement this member function to add special handling for |
1061 | attributes of this property. | |
1c4293cb | 1062 | |
14946ce1 JS |
1063 | @return Return @false to have the attribute automatically stored in |
1064 | m_attributes. Default implementation simply does that and | |
1065 | nothing else. | |
1c4293cb | 1066 | |
14946ce1 JS |
1067 | @remarks To actually set property attribute values from the |
1068 | application, use wxPGProperty::SetAttribute() instead. | |
1c4293cb VZ |
1069 | */ |
1070 | virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); | |
1071 | ||
bb6720bb JS |
1072 | /** |
1073 | Returns value of an attribute. | |
1c4293cb VZ |
1074 | |
1075 | Override if custom handling of attributes is needed. | |
1076 | ||
0ad10f30 | 1077 | Default implementation simply return @NULL variant. |
1c4293cb VZ |
1078 | */ |
1079 | virtual wxVariant DoGetAttribute( const wxString& name ) const; | |
1080 | ||
bb6720bb JS |
1081 | /** |
1082 | Returns instance of a new wxPGEditorDialogAdapter instance, which is | |
1c4293cb VZ |
1083 | used when user presses the (optional) button next to the editor control; |
1084 | ||
0ad10f30 | 1085 | Default implementation returns @NULL (ie. no action is generated when |
1c4293cb VZ |
1086 | button is pressed). |
1087 | */ | |
1088 | virtual wxPGEditorDialogAdapter* GetEditorDialog() const; | |
1089 | ||
d8812c6e JS |
1090 | /** |
1091 | Called whenever validation has failed with given pending value. | |
1092 | ||
1093 | @remarks If you implement this in your custom property class, please | |
1094 | remember to call the baser implementation as well, since they | |
1095 | may use it to revert property into pre-change state. | |
1096 | */ | |
1097 | virtual void OnValidationFailure( wxVariant& pendingValue ); | |
1098 | ||
bb6720bb JS |
1099 | /** |
1100 | Append a new choice to property's list of choices. | |
939d9364 JS |
1101 | |
1102 | @param label | |
1103 | Label for added choice. | |
1104 | ||
1105 | @param value | |
1106 | Value for new choice. Do not specify if you wish this | |
1107 | to equal choice index. | |
1108 | ||
1109 | @return | |
1110 | Index to added choice. | |
1111 | */ | |
1112 | int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE ); | |
1113 | ||
bb6720bb | 1114 | /** |
48a32cf6 | 1115 | Adds a private child property. |
2fd4a524 | 1116 | |
48a32cf6 JS |
1117 | @deprecated Use AddPrivateChild() instead. |
1118 | ||
1119 | @see AddPrivateChild() | |
1120 | */ | |
1121 | wxDEPRECATED( void AddChild( wxPGProperty* prop ) ); | |
1122 | ||
1123 | /** | |
1124 | Adds a private child property. If you use this instead of | |
1125 | wxPropertyGridInterface::Insert() or | |
1126 | wxPropertyGridInterface::AppendIn(), then property's parental | |
1127 | type will automatically be set up to wxPG_PROP_AGGREGATE. In other | |
1128 | words, all properties of this property will become private. | |
bb6720bb | 1129 | */ |
48a32cf6 | 1130 | void AddPrivateChild( wxPGProperty* prop ); |
bb6720bb JS |
1131 | |
1132 | /** | |
1133 | Adapts list variant into proper value using consecutive | |
1134 | ChildChanged() calls. | |
1135 | */ | |
1136 | void AdaptListToValue( wxVariant& list, wxVariant* value ) const; | |
1137 | ||
48a32cf6 JS |
1138 | /** |
1139 | Use this member function to add independent (ie. regular) children to | |
1140 | a property. | |
1141 | ||
1142 | @return Appended childProperty. | |
1143 | ||
1144 | @remarks wxPropertyGrid is not automatically refreshed by this | |
1145 | function. | |
1146 | ||
1147 | @see InsertChild(), AddPrivateChild() | |
1148 | */ | |
1149 | wxPGProperty* AppendChild( wxPGProperty* childProperty ); | |
1150 | ||
bb6720bb JS |
1151 | /** |
1152 | Determines, recursively, if all children are not unspecified. | |
1153 | ||
1154 | @param pendingList | |
1155 | Assumes members in this wxVariant list as pending | |
1156 | replacement values. | |
1157 | */ | |
1158 | bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const; | |
1159 | ||
1160 | /** | |
0ad10f30 | 1161 | Returns @true if children of this property are component values (for instance, |
1c4293cb VZ |
1162 | points size, face name, and is_underlined are component values of a font). |
1163 | */ | |
0ad10f30 | 1164 | bool AreChildrenComponents() const; |
1c4293cb | 1165 | |
6cf5edea | 1166 | /** |
6c78066f | 1167 | Sets or clears given property flag. Mainly for internal use. |
6cf5edea | 1168 | |
6c78066f JS |
1169 | @remarks Setting a property flag never has any side-effect, and is |
1170 | intended almost exclusively for internal use. So, for | |
1171 | example, if you want to disable a property, call | |
1172 | Enable(false) instead of setting wxPG_PROP_DISABLED flag. | |
1173 | ||
1174 | @see HasFlag(), GetFlags() | |
6cf5edea JS |
1175 | */ |
1176 | void ChangeFlag( wxPGPropertyFlags flag, bool set ); | |
1177 | ||
91c818f8 JS |
1178 | /** |
1179 | Deletes children of the property. | |
1180 | */ | |
1181 | void DeleteChildren(); | |
1182 | ||
bb6720bb JS |
1183 | /** |
1184 | Removes entry from property's wxPGChoices and editor control (if it is active). | |
1c4293cb VZ |
1185 | |
1186 | If selected item is deleted, then the value is set to unspecified. | |
1187 | */ | |
1188 | void DeleteChoice( int index ); | |
1189 | ||
9ceed261 JS |
1190 | /** |
1191 | Enables or disables the property. Disabled property usually appears | |
1192 | as having grey text. | |
1193 | ||
1194 | @param enable | |
1195 | If @false, property is disabled instead. | |
1196 | ||
1197 | @see wxPropertyGridInterface::EnableProperty() | |
1198 | */ | |
1199 | void Enable( bool enable = true ); | |
1200 | ||
1425eca5 | 1201 | /** |
c82a80e8 | 1202 | Composes text from values of child properties. |
1425eca5 | 1203 | */ |
c82a80e8 | 1204 | wxString GenerateComposedValue() const; |
1c4293cb | 1205 | |
bb6720bb JS |
1206 | /** |
1207 | Returns property attribute value, null variant if not found. | |
1208 | */ | |
1209 | wxVariant GetAttribute( const wxString& name ) const; | |
1c4293cb | 1210 | |
bb6720bb JS |
1211 | /** Returns named attribute, as string, if found. Otherwise defVal is returned. |
1212 | */ | |
1213 | wxString GetAttribute( const wxString& name, const wxString& defVal ) const; | |
1c4293cb | 1214 | |
bb6720bb | 1215 | /** Returns named attribute, as long, if found. Otherwise defVal is returned. |
939d9364 | 1216 | */ |
bb6720bb | 1217 | long GetAttributeAsLong( const wxString& name, long defVal ) const; |
1c4293cb | 1218 | |
bb6720bb | 1219 | /** Returns named attribute, as double, if found. Otherwise defVal is returned. |
1c4293cb | 1220 | */ |
bb6720bb | 1221 | double GetAttributeAsDouble( const wxString& name, double defVal ) const; |
1c4293cb | 1222 | |
bb6720bb JS |
1223 | /** |
1224 | Returns attributes as list wxVariant. | |
1225 | */ | |
1226 | wxVariant GetAttributesAsList() const; | |
1c4293cb | 1227 | |
bb6720bb | 1228 | /** |
0ad10f30 | 1229 | Returns editor used for given column. @NULL for no editor. |
1c4293cb | 1230 | */ |
0ad10f30 | 1231 | const wxPGEditor* GetColumnEditor( int column ) const; |
1c4293cb | 1232 | |
bb6720bb | 1233 | /** Returns property's base name (ie. parent's name is not added in any case) */ |
0ad10f30 | 1234 | const wxString& GetBaseName() const; |
1c4293cb | 1235 | |
bb6720bb | 1236 | /** |
d7e2b522 | 1237 | Returns wxPGCell of given column. |
58935d4a JS |
1238 | |
1239 | @remarks const version of this member function returns 'default' | |
1240 | wxPGCell object if the property itself didn't hold | |
1241 | cell data. | |
1c4293cb | 1242 | */ |
d7e2b522 | 1243 | const wxPGCell& GetCell( unsigned int column ) const; |
1c4293cb | 1244 | |
58935d4a JS |
1245 | /** |
1246 | Returns wxPGCell of given column, creating one if necessary. | |
1247 | */ | |
1248 | wxPGCell& GetCell( unsigned int column ); | |
1249 | ||
1250 | /** | |
1251 | Returns wxPGCell of given column, creating one if necessary. | |
1252 | */ | |
1253 | wxPGCell& GetOrCreateCell( unsigned int column ); | |
1254 | ||
bb6720bb JS |
1255 | /** |
1256 | Returns number of child properties. | |
1257 | */ | |
1258 | unsigned int GetChildCount() const; | |
1259 | ||
1260 | /** | |
1261 | Returns height of children, recursively, and | |
1262 | by taking expanded/collapsed status into account. | |
1263 | ||
1264 | @param lh | |
1265 | Line height. Pass result of GetGrid()->GetRowHeight() here. | |
1266 | ||
1267 | @param iMax | |
1268 | Only used (internally) when finding property y-positions. | |
1269 | */ | |
1270 | int GetChildrenHeight( int lh, int iMax = -1 ) const; | |
1271 | ||
1272 | /** | |
1273 | Returns read-only reference to property's list of choices. | |
1274 | */ | |
1275 | const wxPGChoices& GetChoices() const; | |
1276 | ||
1277 | /** | |
1278 | Returns client data (void*) of a property. | |
1279 | */ | |
1280 | void* GetClientData() const; | |
1281 | ||
1282 | /** Sets managed client object of a property. | |
1283 | */ | |
1284 | wxClientData *GetClientObject() const; | |
1285 | ||
1286 | /** | |
1287 | Returns property's default value. If property's value type is not | |
1288 | a built-in one, and "DefaultValue" attribute is not defined, then | |
1289 | this function usually returns Null variant. | |
1290 | */ | |
1291 | wxVariant GetDefaultValue() const; | |
1292 | ||
40924780 | 1293 | /** Returns property's displayed text. |
bb6720bb | 1294 | */ |
0ad10f30 | 1295 | wxString GetDisplayedString() const; |
1c4293cb | 1296 | |
bb6720bb JS |
1297 | /** |
1298 | Returns wxPGEditor that will be used and created when | |
1299 | property becomes selected. Returns more accurate value | |
1300 | than DoGetEditorClass(). | |
1301 | */ | |
1302 | const wxPGEditor* GetEditorClass() const; | |
1303 | ||
6cf5edea JS |
1304 | /** |
1305 | Returns property flags. | |
1306 | */ | |
1307 | FlagType GetFlags() const; | |
1308 | ||
1c4293cb VZ |
1309 | /** Returns property grid where property lies. */ |
1310 | wxPropertyGrid* GetGrid() const; | |
1311 | ||
bb6720bb JS |
1312 | /** |
1313 | Returns owner wxPropertyGrid, but only if one is currently on a page | |
1314 | displaying this property. | |
1315 | */ | |
1c4293cb VZ |
1316 | wxPropertyGrid* GetGridIfDisplayed() const; |
1317 | ||
bb6720bb JS |
1318 | /** |
1319 | Returns property's help or description text. | |
1320 | ||
1321 | @see SetHelpString() | |
1c4293cb | 1322 | */ |
bb6720bb | 1323 | const wxString& GetHelpString() const; |
1c4293cb | 1324 | |
bb6720bb JS |
1325 | /** |
1326 | Returns position in parent's array. | |
1327 | */ | |
1328 | unsigned int GetIndexInParent() const; | |
1c4293cb | 1329 | |
bb6720bb | 1330 | /** Returns property's label. */ |
0ad10f30 | 1331 | const wxString& GetLabel() const; |
1c4293cb | 1332 | |
bb6720bb JS |
1333 | /** |
1334 | Returns last visible child property, recursively. | |
1c4293cb | 1335 | */ |
bb6720bb | 1336 | const wxPGProperty* GetLastVisibleSubItem() const; |
1c4293cb | 1337 | |
bb6720bb JS |
1338 | /** |
1339 | Returns highest level non-category, non-root parent. Useful when you | |
17e3ad2a | 1340 | have nested properties with children. |
1c4293cb | 1341 | |
bb6720bb JS |
1342 | @remarks If immediate parent is root or category, this will return the |
1343 | property itself. | |
1344 | */ | |
1345 | wxPGProperty* GetMainParent() const; | |
1c4293cb | 1346 | |
bb6720bb | 1347 | /** Returns maximum allowed length of property's text value. |
1c4293cb | 1348 | */ |
0ad10f30 | 1349 | int GetMaxLength() const; |
1c4293cb | 1350 | |
bb6720bb JS |
1351 | /** Returns property's name with all (non-category, non-root) parents. */ |
1352 | wxString GetName() const; | |
1353 | ||
1354 | /** Return parent of property */ | |
0ad10f30 | 1355 | wxPGProperty* GetParent() const; |
bb6720bb JS |
1356 | |
1357 | /** | |
0ad10f30 | 1358 | Returns (direct) child property with given name (or @NULL if not found). |
1c4293cb | 1359 | */ |
bb6720bb JS |
1360 | wxPGProperty* GetPropertyByName( const wxString& name ) const; |
1361 | ||
1362 | /** Gets assignable version of property's validator. */ | |
1363 | wxValidator* GetValidator() const; | |
1c4293cb | 1364 | |
bb6720bb JS |
1365 | /** |
1366 | Returns property's value. | |
1367 | */ | |
0ad10f30 | 1368 | wxVariant GetValue() const; |
1c4293cb | 1369 | |
bb6720bb | 1370 | /** |
0ad10f30 | 1371 | Returns bitmap that appears next to value text. Only returns non-@NULL |
bb6720bb JS |
1372 | bitmap if one was set with SetValueImage(). |
1373 | */ | |
1374 | wxBitmap* GetValueImage() const; | |
1c4293cb | 1375 | |
1425eca5 JS |
1376 | /** Returns text representation of property's value. |
1377 | ||
1378 | @param argFlags | |
1379 | If 0 (default value), then displayed string is returned. | |
1380 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
1381 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1382 | string value that must be editable in textctrl. If | |
1383 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1384 | display as a part of string property's composite text | |
1385 | representation. | |
1386 | ||
1387 | @remarks In older versions, this function used to be overridden to convert | |
1388 | property's value into a string representation. This function is | |
1389 | now handled by ValueToString(), and overriding this function now | |
1390 | will result in run-time assertion failure. | |
1391 | */ | |
1392 | virtual wxString GetValueAsString( int argFlags = 0 ) const; | |
1393 | ||
1394 | /** Synonymous to GetValueAsString(). | |
1395 | ||
1396 | @deprecated Use GetValueAsString() instead. | |
bb6720bb JS |
1397 | |
1398 | @see GetValueAsString() | |
1399 | */ | |
1425eca5 | 1400 | wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const ); |
bb6720bb JS |
1401 | |
1402 | /** | |
1403 | Returns value type used by this property. | |
1404 | */ | |
0ad10f30 | 1405 | wxString GetValueType() const; |
1c4293cb | 1406 | |
bb6720bb JS |
1407 | /** |
1408 | Returns coordinate to the top y of the property. Note that the | |
1409 | position of scrollbars is not taken into account. | |
1c4293cb | 1410 | */ |
bb6720bb | 1411 | int GetY() const; |
1c4293cb | 1412 | |
6cf5edea JS |
1413 | /** |
1414 | Returns non-zero if property has given flag set. | |
1415 | ||
1416 | @see propgrid_propflags | |
1417 | */ | |
1418 | FlagType HasFlag( wxPGPropertyFlags flag ) const; | |
1419 | ||
bb6720bb | 1420 | /** |
0ad10f30 | 1421 | Returns @true if property has even one visible child. |
1c4293cb VZ |
1422 | */ |
1423 | bool HasVisibleChildren() const; | |
1424 | ||
bb6720bb JS |
1425 | /** |
1426 | Hides or reveals the property. | |
1427 | ||
1428 | @param hide | |
1429 | @true for hide, @false for reveal. | |
1430 | ||
1431 | @param flags | |
1432 | By default changes are applied recursively. Set this parameter wxPG_DONT_RECURSE to prevent this. | |
1433 | */ | |
1434 | bool Hide( bool hide, int flags = wxPG_RECURSE ); | |
1435 | ||
1436 | /** | |
1437 | Returns index of given child property. wxNOT_FOUND if | |
1438 | given property is not child of this. | |
1439 | */ | |
1440 | int Index( const wxPGProperty* p ) const; | |
1441 | ||
48a32cf6 JS |
1442 | /** |
1443 | Use this member function to add independent (ie. regular) children to | |
1444 | a property. | |
1445 | ||
1446 | @return Inserted childProperty. | |
1447 | ||
1448 | @remarks wxPropertyGrid is not automatically refreshed by this | |
1449 | function. | |
1450 | ||
1451 | @see AppendChild(), AddPrivateChild() | |
1452 | */ | |
1453 | wxPGProperty* InsertChild( int index, wxPGProperty* childProperty ); | |
1454 | ||
bb6720bb JS |
1455 | /** |
1456 | Inserts a new choice to property's list of choices. | |
939d9364 JS |
1457 | |
1458 | @param label | |
1459 | Text for new choice | |
1460 | ||
1461 | @param index | |
1462 | Insertion position. Use wxNOT_FOUND to append. | |
1463 | ||
1464 | @param value | |
1465 | Value for new choice. Do not specify if you wish this | |
1466 | to equal choice index. | |
1c4293cb VZ |
1467 | */ |
1468 | int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); | |
1469 | ||
bb6720bb JS |
1470 | /** |
1471 | Returns @true if this property is actually a wxPropertyCategory. | |
1c4293cb | 1472 | */ |
bb6720bb | 1473 | bool IsCategory() const; |
1c4293cb | 1474 | |
bb6720bb JS |
1475 | /** |
1476 | Returns @true if property is enabled. | |
1c4293cb | 1477 | */ |
bb6720bb | 1478 | bool IsEnabled() const; |
1c4293cb | 1479 | |
bb6720bb JS |
1480 | /** |
1481 | Returns @true if property has visible children. | |
1c4293cb | 1482 | */ |
bb6720bb | 1483 | bool IsExpanded() const; |
1c4293cb | 1484 | |
bb6720bb JS |
1485 | /** |
1486 | Returns @true if this property is actually a wxRootProperty. | |
1c4293cb | 1487 | */ |
0ad10f30 | 1488 | bool IsRoot() const; |
1c4293cb | 1489 | |
bb6720bb JS |
1490 | /** |
1491 | Returns @true if candidateParent is some parent of this property. | |
1c4293cb | 1492 | */ |
bb6720bb | 1493 | bool IsSomeParent( wxPGProperty* candidateParent ) const; |
1c4293cb | 1494 | |
bb6720bb JS |
1495 | /** |
1496 | Returns true if property has editable wxTextCtrl when selected. | |
1c4293cb | 1497 | |
57ab6f23 | 1498 | @remarks Although disabled properties do not displayed editor, they still |
bb6720bb JS |
1499 | return @true here as being disabled is considered a temporary |
1500 | condition (unlike being read-only or having limited editing enabled). | |
1c4293cb | 1501 | */ |
bb6720bb | 1502 | bool IsTextEditable() const; |
1c4293cb | 1503 | |
bb6720bb JS |
1504 | /** |
1505 | Returns @true if property's value is considered unspecified. This | |
1506 | usually means that value is Null variant. | |
1c4293cb | 1507 | */ |
bb6720bb | 1508 | bool IsValueUnspecified() const; |
1c4293cb | 1509 | |
bb6720bb JS |
1510 | /** |
1511 | Returns true if all parents expanded. | |
1c4293cb | 1512 | */ |
bb6720bb | 1513 | bool IsVisible() const; |
1c4293cb | 1514 | |
bb6720bb JS |
1515 | /** |
1516 | Returns child property at index i. | |
1c4293cb | 1517 | */ |
68bcfd2c | 1518 | wxPGProperty* Item( unsigned int i ) const; |
1c4293cb | 1519 | |
bb6720bb JS |
1520 | /** |
1521 | If property's editor is active, then update it's value. | |
1c4293cb VZ |
1522 | */ |
1523 | void RefreshEditor(); | |
1524 | ||
bb6720bb JS |
1525 | /** |
1526 | Sets an attribute for this property. | |
1527 | ||
1c4293cb | 1528 | @param name |
bb6720bb JS |
1529 | Text identifier of attribute. See @ref propgrid_property_attributes. |
1530 | ||
1c4293cb | 1531 | @param value |
bb6720bb | 1532 | Value of attribute. |
1802a91d JS |
1533 | |
1534 | @remarks Setting attribute's value to Null variant will simply remove it | |
1535 | from property's set of attributes. | |
1c4293cb VZ |
1536 | */ |
1537 | void SetAttribute( const wxString& name, wxVariant value ); | |
1538 | ||
6c78066f JS |
1539 | /** |
1540 | Set if user can change the property's value to unspecified by | |
1541 | modifying the value of the editor control (usually by clearing | |
1542 | it). Currently, this can work with following properties: | |
1543 | wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty. | |
1544 | ||
1545 | @param enable | |
4c51a665 | 1546 | Whether to enable or disable this behaviour (it is disabled by |
6c78066f JS |
1547 | default). |
1548 | */ | |
1549 | void SetAutoUnspecified( bool enable = true ); | |
1550 | ||
d7e2b522 JS |
1551 | /** |
1552 | Sets property's background colour. | |
1553 | ||
1554 | @param colour | |
1555 | Background colour to use. | |
1556 | ||
e607eac2 JS |
1557 | @param flags |
1558 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1559 | Omit this flag to only set colour for the property in question | |
1560 | and not any of its children. | |
d7e2b522 JS |
1561 | */ |
1562 | void SetBackgroundColour( const wxColour& colour, | |
e607eac2 | 1563 | int flags = wxPG_RECURSE ); |
d7e2b522 | 1564 | |
bb6720bb JS |
1565 | /** |
1566 | Sets editor for a property. | |
1c4293cb VZ |
1567 | |
1568 | @param editor | |
bb6720bb JS |
1569 | For builtin editors, use wxPGEditor_X, where X is builtin editor's |
1570 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list). | |
1c4293cb VZ |
1571 | |
1572 | For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass(). | |
1573 | */ | |
bb6720bb | 1574 | void SetEditor( const wxPGEditor* editor ); |
1c4293cb | 1575 | |
bb6720bb JS |
1576 | /** |
1577 | Sets editor for a property, by editor name. | |
1c4293cb | 1578 | */ |
bb6720bb | 1579 | void SetEditor( const wxString& editorName ); |
1c4293cb | 1580 | |
bb6720bb JS |
1581 | /** |
1582 | Sets cell information for given column. | |
1c4293cb | 1583 | */ |
d7e2b522 | 1584 | void SetCell( int column, const wxPGCell& cell ); |
1c4293cb | 1585 | |
bb6720bb | 1586 | /** |
26b22ae3 | 1587 | Sets new set of choices for the property. |
1c4293cb | 1588 | |
26b22ae3 JS |
1589 | @remarks This operation deselects the property and clears its |
1590 | value. | |
1c4293cb | 1591 | */ |
bb6720bb | 1592 | bool SetChoices( wxPGChoices& choices ); |
1c4293cb | 1593 | |
bb6720bb JS |
1594 | /** |
1595 | Sets client data (void*) of a property. | |
1c4293cb | 1596 | |
bb6720bb | 1597 | @remarks This untyped client data has to be deleted manually. |
1c4293cb | 1598 | */ |
bb6720bb | 1599 | void SetClientData( void* clientData ); |
1c4293cb | 1600 | |
bb6720bb JS |
1601 | /** Returns client object of a property. |
1602 | */ | |
1603 | void SetClientObject(wxClientData* clientObject); | |
1c4293cb | 1604 | |
bb6720bb JS |
1605 | /** |
1606 | Sets selected choice and changes property value. | |
1c4293cb | 1607 | |
bb6720bb JS |
1608 | Tries to retain value type, although currently if it is not string, |
1609 | then it is forced to integer. | |
1c4293cb | 1610 | */ |
bb6720bb | 1611 | void SetChoiceSelection( int newValue ); |
1c4293cb | 1612 | |
0ce8e27f JS |
1613 | /** Set default value of a property. Synonymous to |
1614 | ||
1615 | @code | |
1616 | SetAttribute("DefaultValue", value); | |
1617 | @endcode | |
1618 | */ | |
1619 | void SetDefaultValue( wxVariant& value ); | |
1620 | ||
6cf5edea | 1621 | /** |
6c78066f JS |
1622 | Sets or clears given property flag, recursively. This function is |
1623 | primarily intended for internal use. | |
6cf5edea | 1624 | |
6c78066f | 1625 | @see ChangeFlag() |
6cf5edea JS |
1626 | */ |
1627 | void SetFlagRecursively( wxPGPropertyFlags flag, bool set ); | |
1628 | ||
bb6720bb JS |
1629 | /** |
1630 | Sets property's help string, which is shown, for example, in | |
1631 | wxPropertyGridManager's description text box. | |
1c4293cb | 1632 | */ |
bb6720bb | 1633 | void SetHelpString( const wxString& helpString ); |
1c4293cb | 1634 | |
bb6720bb JS |
1635 | /** |
1636 | Sets property's label. | |
1c4293cb | 1637 | |
bb6720bb JS |
1638 | @remarks Properties under same parent may have same labels. However, |
1639 | property names must still remain unique. | |
258ccb95 | 1640 | */ |
0ad10f30 | 1641 | void SetLabel( const wxString& label ); |
1c4293cb | 1642 | |
bb6720bb JS |
1643 | /** |
1644 | Set max length of text in text editor. | |
1c4293cb | 1645 | */ |
bb6720bb | 1646 | bool SetMaxLength( int maxLen ); |
1c4293cb | 1647 | |
bb6720bb JS |
1648 | /** |
1649 | Sets property's "is it modified?" flag. Affects children recursively. | |
1c4293cb | 1650 | */ |
bb6720bb | 1651 | void SetModifiedStatus( bool modified ); |
1c4293cb | 1652 | |
bb6720bb JS |
1653 | /** |
1654 | Sets new (base) name for property. | |
1c4293cb | 1655 | */ |
bb6720bb | 1656 | void SetName( const wxString& newName ); |
1c4293cb | 1657 | |
2fd4a524 JS |
1658 | /** |
1659 | Changes what sort of parent this property is for its children. | |
1660 | ||
1661 | @param flag | |
1662 | Use one of the following values: wxPG_PROP_MISC_PARENT (for generic | |
1663 | parents), wxPG_PROP_CATEGORY (for categories), or | |
1664 | wxPG_PROP_AGGREGATE (for derived property classes with private | |
1665 | children). | |
1666 | ||
48a32cf6 | 1667 | @remarks You generally do not need to call this function. |
2fd4a524 JS |
1668 | */ |
1669 | void SetParentalType( int flag ); | |
1670 | ||
d7e2b522 JS |
1671 | /** |
1672 | Sets property's text colour. | |
1673 | ||
1674 | @param colour | |
1675 | Text colour to use. | |
1676 | ||
e607eac2 JS |
1677 | @param flags |
1678 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1679 | Omit this flag to only set colour for the property in question | |
1680 | and not any of its children. | |
d7e2b522 JS |
1681 | */ |
1682 | void SetTextColour( const wxColour& colour, | |
e607eac2 | 1683 | int flags = wxPG_RECURSE ); |
d7e2b522 | 1684 | |
bb6720bb JS |
1685 | /** Sets wxValidator for a property */ |
1686 | void SetValidator( const wxValidator& validator ); | |
1c4293cb | 1687 | |
bb6720bb JS |
1688 | /** |
1689 | Call this to set value of the property. Unlike methods in wxPropertyGrid, | |
1690 | this does not automatically update the display. | |
1c4293cb VZ |
1691 | |
1692 | @remarks | |
bb6720bb JS |
1693 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through |
1694 | validation process and send property change event. | |
1c4293cb | 1695 | |
bb6720bb JS |
1696 | If you need to change property value in event, based on user input, use |
1697 | SetValueInEvent() instead. | |
1c4293cb | 1698 | |
0ad10f30 FM |
1699 | @param value |
1700 | The value to set. | |
bb6720bb JS |
1701 | @param pList |
1702 | Pointer to list variant that contains child values. Used to indicate | |
0ad10f30 | 1703 | which children should be marked as modified. Usually you just use @NULL. |
bb6720bb | 1704 | @param flags |
e777bd14 JS |
1705 | wxPG_SETVAL_REFRESH_EDITOR is set by default, to refresh editor |
1706 | and redraw properties. | |
1c4293cb | 1707 | */ |
e777bd14 JS |
1708 | void SetValue( wxVariant value, wxVariant* pList = NULL, |
1709 | int flags = wxPG_SETVAL_REFRESH_EDITOR ); | |
1c4293cb | 1710 | |
bb6720bb JS |
1711 | /** |
1712 | Set wxBitmap in front of the value. This bitmap may be ignored | |
1713 | by custom cell renderers. | |
1c4293cb | 1714 | */ |
bb6720bb | 1715 | void SetValueImage( wxBitmap& bmp ); |
1c4293cb | 1716 | |
bb6720bb JS |
1717 | /** |
1718 | Call this function in OnEvent(), OnButtonClick() etc. to change the | |
1719 | property value based on user input. | |
939d9364 | 1720 | |
bb6720bb JS |
1721 | @remarks This method is const since it doesn't actually modify value, but posts |
1722 | given variant as pending value, stored in wxPropertyGrid. | |
1c4293cb | 1723 | */ |
bb6720bb | 1724 | void SetValueInEvent( wxVariant value ) const; |
1c4293cb | 1725 | |
bb6720bb JS |
1726 | /** |
1727 | Sets property's value to unspecified (ie. Null variant). | |
1c4293cb | 1728 | */ |
bb6720bb | 1729 | void SetValueToUnspecified(); |
1c4293cb | 1730 | |
bb6720bb JS |
1731 | /** |
1732 | Call with @false in OnSetValue() to cancel value changes after all | |
1733 | (ie. cancel @true returned by StringToValue() or IntToValue()). | |
1734 | */ | |
1735 | void SetWasModified( bool set = true ); | |
1c4293cb | 1736 | |
bb6720bb JS |
1737 | /** |
1738 | Updates composed values of parent non-category properties, recursively. | |
1739 | Returns topmost property updated. | |
1740 | */ | |
1741 | wxPGProperty* UpdateParentValues(); | |
1c4293cb | 1742 | |
bb6720bb | 1743 | /** |
0ad10f30 | 1744 | Returns @true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES. |
1c4293cb | 1745 | */ |
bb6720bb | 1746 | bool UsesAutoUnspecified() const; |
9e610e1c VZ |
1747 | |
1748 | protected: | |
1749 | /** Deletes all child properties. */ | |
1750 | void Empty(); | |
1c4293cb VZ |
1751 | }; |
1752 | ||
1753 | ||
aaf5f986 JS |
1754 | /** |
1755 | @class wxPGCell | |
1756 | ||
1757 | Base class for wxPropertyGrid cell information. | |
1758 | ||
1759 | @library{wxpropgrid} | |
1760 | @category{propgrid} | |
1761 | */ | |
1762 | class wxPGCell : public wxObject | |
1763 | { | |
1764 | public: | |
1765 | wxPGCell(); | |
1766 | wxPGCell(const wxPGCell& other); | |
1767 | wxPGCell( const wxString& text, | |
1768 | const wxBitmap& bitmap = wxNullBitmap, | |
1769 | const wxColour& fgCol = wxNullColour, | |
1770 | const wxColour& bgCol = wxNullColour ); | |
1771 | ||
1772 | virtual ~wxPGCell(); | |
1773 | ||
1774 | const wxPGCellData* GetData() const; | |
1775 | ||
1776 | /** | |
1777 | Returns @true if this cell has custom text stored within. | |
1778 | */ | |
1779 | bool HasText() const; | |
1780 | ||
1781 | /** | |
1782 | Merges valid data from srcCell into this. | |
1783 | */ | |
1784 | void MergeFrom( const wxPGCell& srcCell ); | |
1785 | ||
1786 | void SetText( const wxString& text ); | |
1787 | void SetBitmap( const wxBitmap& bitmap ); | |
1788 | void SetFgCol( const wxColour& col ); | |
1789 | ||
1790 | /** | |
1791 | Sets font of the cell. | |
1792 | ||
1793 | @remarks Because wxPropertyGrid does not support rows of | |
1794 | different height, it makes little sense to change | |
1795 | size of the font. Therefore it is recommended | |
1796 | to use return value of wxPropertyGrid::GetFont() | |
1797 | or wxPropertyGrid::GetCaptionFont() as a basis | |
1798 | for the font that, after modifications, is passed | |
1799 | to this member function. | |
1800 | */ | |
1801 | void SetFont( const wxFont& font ); | |
1802 | ||
1803 | void SetBgCol( const wxColour& col ); | |
1804 | ||
1805 | const wxString& GetText() const; | |
1806 | const wxBitmap& GetBitmap() const; | |
1807 | const wxColour& GetFgCol() const; | |
1808 | ||
1809 | /** | |
1810 | Returns font of the cell. If no specific font is set for this | |
1811 | cell, then the font will be invalid. | |
1812 | */ | |
1813 | const wxFont& GetFont() const; | |
1814 | ||
1815 | const wxColour& GetBgCol() const; | |
1816 | ||
1817 | wxPGCell& operator=( const wxPGCell& other ); | |
1818 | }; | |
1819 | ||
1820 | ||
0ad10f30 FM |
1821 | /** |
1822 | @class wxPGChoices | |
1c4293cb VZ |
1823 | |
1824 | Helper class for managing choices of wxPropertyGrid properties. | |
e1ef506e JS |
1825 | Each entry can have label, value, bitmap, text colour, and background |
1826 | colour. | |
16372f0d | 1827 | |
e1ef506e JS |
1828 | wxPGChoices uses reference counting, similar to other wxWidgets classes. |
1829 | This means that assignment operator and copy constructor only copy the | |
1830 | reference and not the actual data. Use Copy() member function to create a | |
1831 | real copy. | |
1832 | ||
1833 | @remarks If you do not specify value for entry, index is used. | |
1c4293cb VZ |
1834 | |
1835 | @library{wxpropgrid} | |
1836 | @category{propgrid} | |
1837 | */ | |
aaf5f986 | 1838 | class wxPGChoices |
1c4293cb VZ |
1839 | { |
1840 | public: | |
1841 | typedef long ValArrItem; | |
1842 | ||
bb6720bb JS |
1843 | /** |
1844 | Default constructor. | |
1845 | */ | |
1846 | wxPGChoices(); | |
1c4293cb | 1847 | |
e1ef506e JS |
1848 | /** |
1849 | Copy constructor, uses reference counting. To create a real copy, | |
1850 | use Copy() member function instead. | |
1851 | */ | |
bb6720bb | 1852 | wxPGChoices( const wxPGChoices& a ); |
1c4293cb VZ |
1853 | |
1854 | /** Constructor. */ | |
bb6720bb | 1855 | wxPGChoices( const wxChar** labels, const long* values = NULL ); |
1c4293cb VZ |
1856 | |
1857 | /** Constructor. */ | |
bb6720bb | 1858 | wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() ); |
1c4293cb | 1859 | |
bb6720bb JS |
1860 | /** Constructor. */ |
1861 | wxPGChoices( wxPGChoicesData* data ); | |
1c4293cb VZ |
1862 | |
1863 | /** Destructor. */ | |
bb6720bb | 1864 | ~wxPGChoices(); |
1c4293cb | 1865 | |
bb6720bb JS |
1866 | /** |
1867 | Adds to current. If did not have own copies, creates them now. If was empty, | |
1c4293cb VZ |
1868 | identical to set except that creates copies. |
1869 | */ | |
1870 | void Add( const wxChar** labels, const ValArrItem* values = NULL ); | |
1871 | ||
1c4293cb VZ |
1872 | /** Version that works with wxArrayString and wxArrayInt. */ |
1873 | void Add( const wxArrayString& arr, const wxArrayInt& arrint ); | |
1874 | ||
1875 | /** Adds single item. */ | |
1876 | wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE ); | |
1877 | ||
1878 | /** Adds a single item, with bitmap. */ | |
bb6720bb JS |
1879 | wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap, |
1880 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb VZ |
1881 | |
1882 | /** Adds a single item with full entry information. */ | |
0ad10f30 | 1883 | wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry ); |
1c4293cb | 1884 | |
bb6720bb | 1885 | /** Adds single item, sorted. */ |
1c4293cb VZ |
1886 | wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE ); |
1887 | ||
bb6720bb | 1888 | /** |
e1ef506e JS |
1889 | Assigns choices data, using reference counting. To create a real copy, |
1890 | use Copy() member function instead. | |
bb6720bb | 1891 | */ |
0ad10f30 | 1892 | void Assign( const wxPGChoices& a ); |
1c4293cb | 1893 | |
bb6720bb JS |
1894 | /** |
1895 | Assigns data from another set of choices. | |
1896 | */ | |
1c4293cb VZ |
1897 | void AssignData( wxPGChoicesData* data ); |
1898 | ||
bb6720bb JS |
1899 | /** |
1900 | Deletes all items. | |
1901 | */ | |
0ad10f30 | 1902 | void Clear(); |
1c4293cb | 1903 | |
e1ef506e JS |
1904 | /** |
1905 | Returns a real copy of the choices. | |
1906 | */ | |
1907 | wxPGChoices Copy() const; | |
1908 | ||
bb6720bb | 1909 | /** |
57ab6f23 | 1910 | Returns label of item. |
bb6720bb | 1911 | */ |
68bcfd2c | 1912 | const wxString& GetLabel( unsigned int ind ) const; |
1c4293cb | 1913 | |
bb6720bb JS |
1914 | /** |
1915 | Returns number of items. | |
1916 | */ | |
68bcfd2c | 1917 | unsigned int GetCount() const; |
1c4293cb | 1918 | |
bb6720bb JS |
1919 | /** |
1920 | Returns value of item; | |
1921 | */ | |
68bcfd2c | 1922 | int GetValue( unsigned int ind ) const; |
1c4293cb | 1923 | |
bb6720bb JS |
1924 | /** |
1925 | Returns array of values matching the given strings. Unmatching strings | |
1c4293cb VZ |
1926 | result in wxPG_INVALID_VALUE entry in array. |
1927 | */ | |
1928 | wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const; | |
1929 | ||
bb6720bb JS |
1930 | /** |
1931 | Returns array of indices matching given strings. Unmatching strings | |
0ad10f30 | 1932 | are added to 'unmatched', if not @NULL. |
1c4293cb | 1933 | */ |
bb6720bb JS |
1934 | wxArrayInt GetIndicesForStrings( const wxArrayString& strings, |
1935 | wxArrayString* unmatched = NULL ) const; | |
1c4293cb | 1936 | |
bb6720bb JS |
1937 | /** |
1938 | Returns index of item with given label. | |
1939 | */ | |
1940 | int Index( const wxString& label ) const; | |
1c4293cb | 1941 | |
bb6720bb JS |
1942 | /** |
1943 | Returns index of item with given value. | |
1944 | */ | |
1c4293cb VZ |
1945 | int Index( int val ) const; |
1946 | ||
bb6720bb JS |
1947 | /** |
1948 | Inserts single item. | |
1949 | */ | |
1c4293cb VZ |
1950 | wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); |
1951 | ||
bb6720bb JS |
1952 | /** |
1953 | Inserts a single item with full entry information. | |
1954 | */ | |
1c4293cb VZ |
1955 | wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index ); |
1956 | ||
bb6720bb | 1957 | /** |
0ad10f30 | 1958 | Returns @false if this is a constant empty set of choices, |
1c4293cb VZ |
1959 | which should not be modified. |
1960 | */ | |
0ad10f30 | 1961 | bool IsOk() const; |
1c4293cb | 1962 | |
bb6720bb JS |
1963 | /** |
1964 | Returns item at given index. | |
1965 | */ | |
0ad10f30 | 1966 | const wxPGChoiceEntry& Item( unsigned int i ) const; |
1c4293cb | 1967 | |
bb6720bb JS |
1968 | /** |
1969 | Returns item at given index. | |
1970 | */ | |
0ad10f30 | 1971 | wxPGChoiceEntry& Item( unsigned int i ); |
1c4293cb | 1972 | |
bb6720bb JS |
1973 | /** |
1974 | Removes count items starting at position nIndex. | |
1975 | */ | |
1c4293cb VZ |
1976 | void RemoveAt(size_t nIndex, size_t count = 1); |
1977 | ||
bb6720bb JS |
1978 | /** |
1979 | Sets contents from lists of strings and values. | |
1c4293cb | 1980 | */ |
bb6720bb | 1981 | void Set( const wxChar** labels, const long* values = NULL ); |
1c4293cb | 1982 | |
bb6720bb JS |
1983 | /** |
1984 | Sets contents from lists of strings and values. | |
1985 | */ | |
1986 | void Set( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() ); | |
1c4293cb | 1987 | |
bb6720bb JS |
1988 | /** |
1989 | Creates exclusive copy of current choices. | |
1990 | */ | |
2728c3bf | 1991 | void AllocExclusive(); |
1c4293cb | 1992 | |
bb6720bb JS |
1993 | /** |
1994 | Returns array of choice labels. | |
1995 | */ | |
1c4293cb VZ |
1996 | wxArrayString GetLabels() const; |
1997 | ||
0ad10f30 | 1998 | void operator= (const wxPGChoices& a); |
1c4293cb | 1999 | |
0ad10f30 FM |
2000 | wxPGChoiceEntry& operator[](unsigned int i); |
2001 | const wxPGChoiceEntry& operator[](unsigned int i) const; | |
1c4293cb VZ |
2002 | }; |
2003 | ||
2004 | // ----------------------------------------------------------------------- |