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