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