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