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