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