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