]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/propgrid/property.h
adding comment about wxHAS_OPENGL_ES
[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.
508 // For example:
509 // AddPrivateChild( new wxStringProperty("Subprop 1",
510 // wxPG_LABEL,
511 // value.GetSubProp1()));
512 }
513
514 @endcode
515 */
516 wxPGProperty( const wxString& label, const wxString& name );
517
518 /**
519 Virtual destructor. It is customary for derived properties to implement this.
520 */
521 virtual ~wxPGProperty();
522
523 /**
524 This virtual function is called after m_value has been set.
525
526 @remarks
527 - If m_value was set to Null variant (ie. unspecified value), OnSetValue()
528 will not be called.
529 - m_value may be of any variant type. Typically properties internally support only
530 one variant type, and as such OnSetValue() provides a good opportunity to convert
531 supported values into internal type.
532 - Default implementation does nothing.
533 */
534 virtual void OnSetValue();
535
536 /**
537 Override this to return something else than m_value as the value.
538 */
539 virtual wxVariant DoGetValue() const;
540
541 /**
542 Implement this function in derived class to check the value.
543 Return @true if it is ok. Returning @false prevents property change events
544 from occurring.
545
546 @remarks
547 - Default implementation always returns @true.
548 */
549 virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const;
550
551 /**
552 Converts text into wxVariant value appropriate for this property.
553
554 @param variant
555 On function entry this is the old value (should not be wxNullVariant
556 in normal cases). Translated value must be assigned back to it.
557
558 @param text
559 Text to be translated into variant.
560
561 @param argFlags
562 If wxPG_FULL_VALUE is set, returns complete, storable value instead
563 of displayable one (they may be different).
564 If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of
565 composite property string value (as generated by ValueToString()
566 called with this same flag).
567
568 @return Returns @true if resulting wxVariant value was different.
569
570 @remarks Default implementation converts semicolon delimited tokens into
571 child values. Only works for properties with children.
572
573 You might want to take into account that m_value is Null variant
574 if property value is unspecified (which is usually only case if
575 you explicitly enabled that sort behavior).
576 */
577 virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const;
578
579 /**
580 Converts integer (possibly a choice selection) into wxVariant value
581 appropriate for this property.
582
583 @param variant
584 On function entry this is the old value (should not be wxNullVariant
585 in normal cases). Translated value must be assigned back to it.
586 @param number
587 Integer to be translated into variant.
588 @param argFlags
589 If wxPG_FULL_VALUE is set, returns complete, storable value instead
590 of displayable one.
591
592 @return Returns @true if resulting wxVariant value was different.
593
594 @remarks
595 - If property is not supposed to use choice or spinctrl or other editor
596 with int-based value, it is not necessary to implement this method.
597 - Default implementation simply assign given int to m_value.
598 - If property uses choice control, and displays a dialog on some choice
599 items, then it is preferred to display that dialog in IntToValue
600 instead of OnEvent.
601 - You might want to take into account that m_value is Mull variant if
602 property value is unspecified (which is usually only case if you
603 explicitly enabled that sort behavior).
604 */
605 virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const;
606
607 /**
608 Converts property value into a text representation.
609
610 @param value
611 Value to be converted.
612 @param argFlags
613 If 0 (default value), then displayed string is returned.
614 If wxPG_FULL_VALUE is set, returns complete, storable string value
615 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
616 string value that must be editable in textctrl.
617 If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
618 display as a part of string property's composite text representation.
619
620 @remarks Default implementation calls GenerateComposedValue().
621 */
622 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
623
624 /**
625 Converts string to a value, and if successful, calls SetValue() on it.
626 Default behavior is to do nothing.
627
628 @param text
629 String to get the value from.
630 @param flags
631 @todo docme
632
633 @return @true if value was changed.
634 */
635 bool SetValueFromString( const wxString& text, int flags = 0 );
636
637 /**
638 Converts integer to a value, and if succesful, calls SetValue() on it.
639 Default behavior is to do nothing.
640
641 @param value
642 Int to get the value from.
643 @param flags
644 If has wxPG_FULL_VALUE, then the value given is a actual value and not an index.
645
646 @return @true if value was changed.
647 */
648 bool SetValueFromInt( long value, int flags = 0 );
649
650 /**
651 Returns size of the custom painted image in front of property. This method
652 must be overridden to return non-default value if OnCustomPaint is to be
653 called.
654
655 @param item
656 Normally -1, but can be an index to the property's list of items.
657
658 @remarks
659 - Default behavior is to return wxSize(0,0), which means no image.
660 - Default image width or height is indicated with dimension -1.
661 - You can also return wxPG_DEFAULT_IMAGE_SIZE which equals wxSize(-1, -1).
662 */
663 virtual wxSize OnMeasureImage( int item = -1 ) const;
664
665 /**
666 Events received by editor widgets are processed here. Note that editor class
667 usually processes most events. Some, such as button press events of
668 TextCtrlAndButton class, can be handled here. Also, if custom handling
669 for regular events is desired, then that can also be done (for example,
670 wxSystemColourProperty custom handles wxEVT_COMMAND_CHOICE_SELECTED
671 to display colour picker dialog when 'custom' selection is made).
672
673 If the event causes value to be changed, SetValueInEvent() should be called
674 to set the new value.
675
676 The parameter @a event is the associated wxEvent.
677
678 @retval
679 Should return @true if any changes in value should be reported.
680
681 @remarks
682 - If property uses choice control, and displays a dialog on some choice items,
683 then it is preferred to display that dialog in IntToValue instead of OnEvent.
684 */
685 virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event );
686
687 /**
688 Called after value of a child property has been altered. Note that this function is
689 usually called at the time that value of this property, or given child property, is
690 still pending for change.
691
692 Sample pseudo-code implementation:
693
694 @code
695 void MyProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const
696 {
697 // Acquire reference to actual type of data stored in variant
698 // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros were used to create
699 // the variant class).
700 T& data = TFromVariant(thisValue);
701
702 // Copy childValue into data.
703 switch ( childIndex )
704 {
705 case 0:
706 data.SetSubProp1( childvalue.GetLong() );
707 break;
708 case 1:
709 data.SetSubProp2( childvalue.GetString() );
710 break;
711 ...
712 }
713 }
714 @endcode
715
716 @param thisValue
717 Value of this property, that should be altered.
718 @param childIndex
719 Index of child changed (you can use Item(childIndex) to get).
720 @param childValue
721 Value of the child property.
722 */
723 virtual void ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const;
724
725 /**
726 Returns pointer to an instance of used editor.
727 */
728 virtual const wxPGEditor* DoGetEditorClass() const;
729
730 /**
731 Returns pointer to the wxValidator that should be used
732 with the editor of this property (@NULL for no validator).
733 Setting validator explicitly via SetPropertyValidator
734 will override this.
735
736 In most situations, code like this should work well
737 (macros are used to maintain one actual validator instance,
738 so on the second call the function exits within the first
739 macro):
740
741 @code
742
743 wxValidator* wxMyPropertyClass::DoGetValidator () const
744 {
745 WX_PG_DOGETVALIDATOR_ENTRY()
746
747 wxMyValidator* validator = new wxMyValidator(...);
748
749 ... prepare validator...
750
751 WX_PG_DOGETVALIDATOR_EXIT(validator)
752 }
753
754 @endcode
755
756 @remarks
757 You can get common filename validator by returning
758 wxFileProperty::GetClassValidator(). wxDirProperty,
759 for example, uses it.
760 */
761 virtual wxValidator* DoGetValidator () const;
762
763 /**
764 Override to paint an image in front of the property value text or drop-down
765 list item (but only if wxPGProperty::OnMeasureImage is overridden as well).
766
767 If property's OnMeasureImage() returns size that has height != 0 but less than
768 row height ( < 0 has special meanings), wxPropertyGrid calls this method to
769 draw a custom image in a limited area in front of the editor control or
770 value text/graphics, and if control has drop-down list, then the image is
771 drawn there as well (even in the case OnMeasureImage() returned higher height
772 than row height).
773
774 NOTE: Following applies when OnMeasureImage() returns a "flexible" height (
775 using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items:
776 If rect.x is < 0, then this is a measure item call, which means that
777 dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight
778 to the height of the image of item at index paintdata.m_choiceItem. This call
779 may be done even as often as once every drop-down popup show.
780
781 @param dc
782 wxDC to paint on.
783 @param rect
784 Box reserved for custom graphics. Includes surrounding rectangle, if any.
785 If x is < 0, then this is a measure item call (see above).
786 @param paintdata
787 wxPGPaintData structure with much useful data about painted item.
788 @code
789 struct wxPGPaintData
790 {
791 // wxPropertyGrid.
792 const wxPropertyGrid* m_parent;
793
794 // Normally -1, otherwise index to drop-down list item that has to be drawn.
795 int m_choiceItem;
796
797 // Set to drawn width in OnCustomPaint (optional).
798 int m_drawnWidth;
799
800 // In a measure item call, set this to the height of item at m_choiceItem index
801 int m_drawnHeight;
802 };
803 @endcode
804
805 @remarks
806 - You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth
807 must be set to the full width drawn in pixels.
808 - Due to technical reasons, rect's height will be default even if custom height
809 was reported during measure call.
810 - Brush is guaranteed to be default background colour. It has been already used to
811 clear the background of area being painted. It can be modified.
812 - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for
813 drawing framing rectangle. It can be changed as well.
814
815 @see ValueToString()
816 */
817 virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata );
818
819 /**
820 Returns used wxPGCellRenderer instance for given property column (label=0, value=1).
821
822 Default implementation returns editor's renderer for all columns.
823 */
824 virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
825
826 /**
827 Returns which choice is currently selected. Only applies to properties
828 which have choices.
829
830 Needs to reimplemented in derived class if property value does not
831 map directly to a choice. Integer as index, bool, and string usually do.
832 */
833 virtual int GetChoiceSelection() const;
834
835 /**
836 Refresh values of child properties. Automatically called after value is set.
837 */
838 virtual void RefreshChildren();
839
840 /**
841 Special handling for attributes of this property.
842
843 If returns @false, then the attribute will be automatically stored in
844 m_attributes.
845
846 Default implementation simply returns @false.
847 */
848 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
849
850 /**
851 Returns value of an attribute.
852
853 Override if custom handling of attributes is needed.
854
855 Default implementation simply return @NULL variant.
856 */
857 virtual wxVariant DoGetAttribute( const wxString& name ) const;
858
859 /**
860 Returns instance of a new wxPGEditorDialogAdapter instance, which is
861 used when user presses the (optional) button next to the editor control;
862
863 Default implementation returns @NULL (ie. no action is generated when
864 button is pressed).
865 */
866 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
867
868 /**
869 Called whenever validation has failed with given pending value.
870
871 @remarks If you implement this in your custom property class, please
872 remember to call the baser implementation as well, since they
873 may use it to revert property into pre-change state.
874 */
875 virtual void OnValidationFailure( wxVariant& pendingValue );
876
877 /**
878 Append a new choice to property's list of choices.
879
880 @param label
881 Label for added choice.
882
883 @param value
884 Value for new choice. Do not specify if you wish this
885 to equal choice index.
886
887 @return
888 Index to added choice.
889 */
890 int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE );
891
892 /**
893 Adds a private child property.
894
895 @deprecated Use AddPrivateChild() instead.
896
897 @see AddPrivateChild()
898 */
899 wxDEPRECATED( void AddChild( wxPGProperty* prop ) );
900
901 /**
902 Adds a private child property. If you use this instead of
903 wxPropertyGridInterface::Insert() or
904 wxPropertyGridInterface::AppendIn(), then property's parental
905 type will automatically be set up to wxPG_PROP_AGGREGATE. In other
906 words, all properties of this property will become private.
907 */
908 void AddPrivateChild( wxPGProperty* prop );
909
910 /**
911 Adapts list variant into proper value using consecutive
912 ChildChanged() calls.
913 */
914 void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
915
916 /**
917 Use this member function to add independent (ie. regular) children to
918 a property.
919
920 @return Appended childProperty.
921
922 @remarks wxPropertyGrid is not automatically refreshed by this
923 function.
924
925 @see InsertChild(), AddPrivateChild()
926 */
927 wxPGProperty* AppendChild( wxPGProperty* childProperty );
928
929 /**
930 Determines, recursively, if all children are not unspecified.
931
932 @param pendingList
933 Assumes members in this wxVariant list as pending
934 replacement values.
935 */
936 bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const;
937
938 /**
939 Returns @true if children of this property are component values (for instance,
940 points size, face name, and is_underlined are component values of a font).
941 */
942 bool AreChildrenComponents() const;
943
944 /**
945 Deletes children of the property.
946 */
947 void DeleteChildren();
948
949 /**
950 Removes entry from property's wxPGChoices and editor control (if it is active).
951
952 If selected item is deleted, then the value is set to unspecified.
953 */
954 void DeleteChoice( int index );
955
956 /** Deletes all child properties. */
957 void Empty();
958
959 /**
960 Composes text from values of child properties.
961 */
962 wxString GenerateComposedValue() const;
963
964 /**
965 Returns property attribute value, null variant if not found.
966 */
967 wxVariant GetAttribute( const wxString& name ) const;
968
969 /** Returns named attribute, as string, if found. Otherwise defVal is returned.
970 */
971 wxString GetAttribute( const wxString& name, const wxString& defVal ) const;
972
973 /** Returns named attribute, as long, if found. Otherwise defVal is returned.
974 */
975 long GetAttributeAsLong( const wxString& name, long defVal ) const;
976
977 /** Returns named attribute, as double, if found. Otherwise defVal is returned.
978 */
979 double GetAttributeAsDouble( const wxString& name, double defVal ) const;
980
981 /**
982 Returns attributes as list wxVariant.
983 */
984 wxVariant GetAttributesAsList() const;
985
986 /**
987 Returns editor used for given column. @NULL for no editor.
988 */
989 const wxPGEditor* GetColumnEditor( int column ) const;
990
991 /** Returns property's base name (ie. parent's name is not added in any case) */
992 const wxString& GetBaseName() const;
993
994 /**
995 Returns wxPGCell of given column.
996 */
997 const wxPGCell& GetCell( unsigned int column ) const;
998
999 /**
1000 Returns number of child properties.
1001 */
1002 unsigned int GetChildCount() const;
1003
1004 /**
1005 Returns height of children, recursively, and
1006 by taking expanded/collapsed status into account.
1007
1008 @param lh
1009 Line height. Pass result of GetGrid()->GetRowHeight() here.
1010
1011 @param iMax
1012 Only used (internally) when finding property y-positions.
1013 */
1014 int GetChildrenHeight( int lh, int iMax = -1 ) const;
1015
1016 /**
1017 Returns read-only reference to property's list of choices.
1018 */
1019 const wxPGChoices& GetChoices() const;
1020
1021 /**
1022 Returns client data (void*) of a property.
1023 */
1024 void* GetClientData() const;
1025
1026 /** Sets managed client object of a property.
1027 */
1028 wxClientData *GetClientObject() const;
1029
1030 /**
1031 Returns property's default value. If property's value type is not
1032 a built-in one, and "DefaultValue" attribute is not defined, then
1033 this function usually returns Null variant.
1034 */
1035 wxVariant GetDefaultValue() const;
1036
1037 /** Returns property's displayed text.
1038 */
1039 wxString GetDisplayedString() const;
1040
1041 /**
1042 Returns wxPGEditor that will be used and created when
1043 property becomes selected. Returns more accurate value
1044 than DoGetEditorClass().
1045 */
1046 const wxPGEditor* GetEditorClass() const;
1047
1048 /** Returns property grid where property lies. */
1049 wxPropertyGrid* GetGrid() const;
1050
1051 /**
1052 Returns owner wxPropertyGrid, but only if one is currently on a page
1053 displaying this property.
1054 */
1055 wxPropertyGrid* GetGridIfDisplayed() const;
1056
1057 /**
1058 Returns property's help or description text.
1059
1060 @see SetHelpString()
1061 */
1062 const wxString& GetHelpString() const;
1063
1064 /**
1065 Returns position in parent's array.
1066 */
1067 unsigned int GetIndexInParent() const;
1068
1069 /** Returns property's label. */
1070 const wxString& GetLabel() const;
1071
1072 /**
1073 Returns last visible child property, recursively.
1074 */
1075 const wxPGProperty* GetLastVisibleSubItem() const;
1076
1077 /**
1078 Returns highest level non-category, non-root parent. Useful when you
1079 have nested properties with children.
1080
1081 @remarks If immediate parent is root or category, this will return the
1082 property itself.
1083 */
1084 wxPGProperty* GetMainParent() const;
1085
1086 /** Returns maximum allowed length of property's text value.
1087 */
1088 int GetMaxLength() const;
1089
1090 /** Returns property's name with all (non-category, non-root) parents. */
1091 wxString GetName() const;
1092
1093 /** Return parent of property */
1094 wxPGProperty* GetParent() const;
1095
1096 /**
1097 Returns (direct) child property with given name (or @NULL if not found).
1098 */
1099 wxPGProperty* GetPropertyByName( const wxString& name ) const;
1100
1101 /** Gets assignable version of property's validator. */
1102 wxValidator* GetValidator() const;
1103
1104 /**
1105 Returns property's value.
1106 */
1107 wxVariant GetValue() const;
1108
1109 /**
1110 Returns bitmap that appears next to value text. Only returns non-@NULL
1111 bitmap if one was set with SetValueImage().
1112 */
1113 wxBitmap* GetValueImage() const;
1114
1115 /** Returns text representation of property's value.
1116
1117 @param argFlags
1118 If 0 (default value), then displayed string is returned.
1119 If wxPG_FULL_VALUE is set, returns complete, storable string value
1120 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
1121 string value that must be editable in textctrl. If
1122 wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
1123 display as a part of string property's composite text
1124 representation.
1125
1126 @remarks In older versions, this function used to be overridden to convert
1127 property's value into a string representation. This function is
1128 now handled by ValueToString(), and overriding this function now
1129 will result in run-time assertion failure.
1130 */
1131 virtual wxString GetValueAsString( int argFlags = 0 ) const;
1132
1133 /** Synonymous to GetValueAsString().
1134
1135 @deprecated Use GetValueAsString() instead.
1136
1137 @see GetValueAsString()
1138 */
1139 wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
1140
1141 /**
1142 Returns value type used by this property.
1143 */
1144 wxString GetValueType() const;
1145
1146 /**
1147 Returns coordinate to the top y of the property. Note that the
1148 position of scrollbars is not taken into account.
1149 */
1150 int GetY() const;
1151
1152 /**
1153 Returns @true if property has even one visible child.
1154 */
1155 bool HasVisibleChildren() const;
1156
1157 /**
1158 Hides or reveals the property.
1159
1160 @param hide
1161 @true for hide, @false for reveal.
1162
1163 @param flags
1164 By default changes are applied recursively. Set this parameter wxPG_DONT_RECURSE to prevent this.
1165 */
1166 bool Hide( bool hide, int flags = wxPG_RECURSE );
1167
1168 /**
1169 Returns index of given child property. wxNOT_FOUND if
1170 given property is not child of this.
1171 */
1172 int Index( const wxPGProperty* p ) const;
1173
1174 /**
1175 Use this member function to add independent (ie. regular) children to
1176 a property.
1177
1178 @return Inserted childProperty.
1179
1180 @remarks wxPropertyGrid is not automatically refreshed by this
1181 function.
1182
1183 @see AppendChild(), AddPrivateChild()
1184 */
1185 wxPGProperty* InsertChild( int index, wxPGProperty* childProperty );
1186
1187 /**
1188 Inserts a new choice to property's list of choices.
1189
1190 @param label
1191 Text for new choice
1192
1193 @param index
1194 Insertion position. Use wxNOT_FOUND to append.
1195
1196 @param value
1197 Value for new choice. Do not specify if you wish this
1198 to equal choice index.
1199 */
1200 int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
1201
1202 /**
1203 Returns @true if this property is actually a wxPropertyCategory.
1204 */
1205 bool IsCategory() const;
1206
1207 /**
1208 Returns @true if property is enabled.
1209 */
1210 bool IsEnabled() const;
1211
1212 /**
1213 Returns @true if property has visible children.
1214 */
1215 bool IsExpanded() const;
1216
1217 /**
1218 Returns @true if this property is actually a wxRootProperty.
1219 */
1220 bool IsRoot() const;
1221
1222 /**
1223 Returns @true if candidateParent is some parent of this property.
1224 */
1225 bool IsSomeParent( wxPGProperty* candidateParent ) const;
1226
1227 /**
1228 Returns true if property has editable wxTextCtrl when selected.
1229
1230 @remarks Altough disabled properties do not displayed editor, they still
1231 return @true here as being disabled is considered a temporary
1232 condition (unlike being read-only or having limited editing enabled).
1233 */
1234 bool IsTextEditable() const;
1235
1236 /**
1237 Returns @true if property's value is considered unspecified. This
1238 usually means that value is Null variant.
1239 */
1240 bool IsValueUnspecified() const;
1241
1242 /**
1243 Returns true if all parents expanded.
1244 */
1245 bool IsVisible() const;
1246
1247 /**
1248 Returns child property at index i.
1249 */
1250 wxPGProperty* Item( unsigned int i ) const;
1251
1252 /**
1253 If property's editor is active, then update it's value.
1254 */
1255 void RefreshEditor();
1256
1257 /**
1258 Sets an attribute for this property.
1259
1260 @param name
1261 Text identifier of attribute. See @ref propgrid_property_attributes.
1262
1263 @param value
1264 Value of attribute.
1265
1266 @remarks Setting attribute's value to Null variant will simply remove it
1267 from property's set of attributes.
1268 */
1269 void SetAttribute( const wxString& name, wxVariant value );
1270
1271 /**
1272 Sets property's background colour.
1273
1274 @param colour
1275 Background colour to use.
1276
1277 @param recursively
1278 If @true, children are affected recursively, and any categories
1279 are not.
1280 */
1281 void SetBackgroundColour( const wxColour& colour,
1282 bool recursively = false );
1283
1284 /**
1285 Sets editor for a property.
1286
1287 @param editor
1288 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1289 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list).
1290
1291 For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
1292 */
1293 void SetEditor( const wxPGEditor* editor );
1294
1295 /**
1296 Sets editor for a property, by editor name.
1297 */
1298 void SetEditor( const wxString& editorName );
1299
1300 /**
1301 Sets cell information for given column.
1302 */
1303 void SetCell( int column, const wxPGCell& cell );
1304
1305 /**
1306 Sets new set of choices for property.
1307
1308 @remarks This operation clears the property value.
1309 */
1310 bool SetChoices( wxPGChoices& choices );
1311
1312 /**
1313 Sets client data (void*) of a property.
1314
1315 @remarks This untyped client data has to be deleted manually.
1316 */
1317 void SetClientData( void* clientData );
1318
1319 /** Returns client object of a property.
1320 */
1321 void SetClientObject(wxClientData* clientObject);
1322
1323 /**
1324 Sets selected choice and changes property value.
1325
1326 Tries to retain value type, although currently if it is not string,
1327 then it is forced to integer.
1328 */
1329 void SetChoiceSelection( int newValue );
1330
1331 /**
1332 Sets property's help string, which is shown, for example, in
1333 wxPropertyGridManager's description text box.
1334 */
1335 void SetHelpString( const wxString& helpString );
1336
1337 /**
1338 Sets property's label.
1339
1340 @remarks Properties under same parent may have same labels. However,
1341 property names must still remain unique.
1342 */
1343 void SetLabel( const wxString& label );
1344
1345 /**
1346 Set max length of text in text editor.
1347 */
1348 bool SetMaxLength( int maxLen );
1349
1350 /**
1351 Sets property's "is it modified?" flag. Affects children recursively.
1352 */
1353 void SetModifiedStatus( bool modified );
1354
1355 /**
1356 Sets new (base) name for property.
1357 */
1358 void SetName( const wxString& newName );
1359
1360 /**
1361 Changes what sort of parent this property is for its children.
1362
1363 @param flag
1364 Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
1365 parents), wxPG_PROP_CATEGORY (for categories), or
1366 wxPG_PROP_AGGREGATE (for derived property classes with private
1367 children).
1368
1369 @remarks You generally do not need to call this function.
1370 */
1371 void SetParentalType( int flag );
1372
1373 /**
1374 Sets property's text colour.
1375
1376 @param colour
1377 Text colour to use.
1378
1379 @param recursively
1380 If @true, children are affected recursively, and any categories
1381 are not.
1382 */
1383 void SetTextColour( const wxColour& colour,
1384 bool recursively = false );
1385
1386 /** Sets wxValidator for a property */
1387 void SetValidator( const wxValidator& validator );
1388
1389 /**
1390 Call this to set value of the property. Unlike methods in wxPropertyGrid,
1391 this does not automatically update the display.
1392
1393 @remarks
1394 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through
1395 validation process and send property change event.
1396
1397 If you need to change property value in event, based on user input, use
1398 SetValueInEvent() instead.
1399
1400 @param value
1401 The value to set.
1402 @param pList
1403 Pointer to list variant that contains child values. Used to indicate
1404 which children should be marked as modified. Usually you just use @NULL.
1405 @param flags
1406 wxPG_SETVAL_REFRESH_EDITOR is set by default, to refresh editor
1407 and redraw properties.
1408 */
1409 void SetValue( wxVariant value, wxVariant* pList = NULL,
1410 int flags = wxPG_SETVAL_REFRESH_EDITOR );
1411
1412 /**
1413 Set wxBitmap in front of the value. This bitmap may be ignored
1414 by custom cell renderers.
1415 */
1416 void SetValueImage( wxBitmap& bmp );
1417
1418 /**
1419 Call this function in OnEvent(), OnButtonClick() etc. to change the
1420 property value based on user input.
1421
1422 @remarks This method is const since it doesn't actually modify value, but posts
1423 given variant as pending value, stored in wxPropertyGrid.
1424 */
1425 void SetValueInEvent( wxVariant value ) const;
1426
1427 /**
1428 Sets property's value to unspecified (ie. Null variant).
1429 */
1430 void SetValueToUnspecified();
1431
1432 /**
1433 Call with @false in OnSetValue() to cancel value changes after all
1434 (ie. cancel @true returned by StringToValue() or IntToValue()).
1435 */
1436 void SetWasModified( bool set = true );
1437
1438 /**
1439 Updates composed values of parent non-category properties, recursively.
1440 Returns topmost property updated.
1441 */
1442 wxPGProperty* UpdateParentValues();
1443
1444 /**
1445 Returns @true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES.
1446 */
1447 bool UsesAutoUnspecified() const;
1448 };
1449
1450
1451 /**
1452 @class wxPGChoices
1453
1454 Helper class for managing choices of wxPropertyGrid properties.
1455 Each entry can have label, value, bitmap, text colour, and background
1456 colour.
1457
1458 wxPGChoices uses reference counting, similar to other wxWidgets classes.
1459 This means that assignment operator and copy constructor only copy the
1460 reference and not the actual data. Use Copy() member function to create a
1461 real copy.
1462
1463 @remarks If you do not specify value for entry, index is used.
1464
1465 @library{wxpropgrid}
1466 @category{propgrid}
1467 */
1468 class WXDLLIMPEXP_PROPGRID wxPGChoices
1469 {
1470 public:
1471 typedef long ValArrItem;
1472
1473 /**
1474 Default constructor.
1475 */
1476 wxPGChoices();
1477
1478 /**
1479 Copy constructor, uses reference counting. To create a real copy,
1480 use Copy() member function instead.
1481 */
1482 wxPGChoices( const wxPGChoices& a );
1483
1484 /** Constructor. */
1485 wxPGChoices( const wxChar** labels, const long* values = NULL );
1486
1487 /** Constructor. */
1488 wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
1489
1490 /** Constructor. */
1491 wxPGChoices( wxPGChoicesData* data );
1492
1493 /** Destructor. */
1494 ~wxPGChoices();
1495
1496 /**
1497 Adds to current. If did not have own copies, creates them now. If was empty,
1498 identical to set except that creates copies.
1499 */
1500 void Add( const wxChar** labels, const ValArrItem* values = NULL );
1501
1502 /** Version that works with wxArrayString. */
1503 void Add( const wxArrayString& arr, const ValArrItem* values = NULL );
1504
1505 /** Version that works with wxArrayString and wxArrayInt. */
1506 void Add( const wxArrayString& arr, const wxArrayInt& arrint );
1507
1508 /** Adds single item. */
1509 wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE );
1510
1511 /** Adds a single item, with bitmap. */
1512 wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap,
1513 int value = wxPG_INVALID_VALUE );
1514
1515 /** Adds a single item with full entry information. */
1516 wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry );
1517
1518 /** Adds single item, sorted. */
1519 wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE );
1520
1521 /**
1522 Assigns choices data, using reference counting. To create a real copy,
1523 use Copy() member function instead.
1524 */
1525 void Assign( const wxPGChoices& a );
1526
1527 /**
1528 Assigns data from another set of choices.
1529 */
1530 void AssignData( wxPGChoicesData* data );
1531
1532 /**
1533 Deletes all items.
1534 */
1535 void Clear();
1536
1537 /**
1538 Returns a real copy of the choices.
1539 */
1540 wxPGChoices Copy() const;
1541
1542 /**
1543 Returns labe of item.
1544 */
1545 const wxString& GetLabel( unsigned int ind ) const;
1546
1547 /**
1548 Returns number of items.
1549 */
1550 unsigned int GetCount() const;
1551
1552 /**
1553 Returns value of item;
1554 */
1555 int GetValue( unsigned int ind ) const;
1556
1557 /**
1558 Returns array of values matching the given strings. Unmatching strings
1559 result in wxPG_INVALID_VALUE entry in array.
1560 */
1561 wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const;
1562
1563 /**
1564 Returns array of indices matching given strings. Unmatching strings
1565 are added to 'unmatched', if not @NULL.
1566 */
1567 wxArrayInt GetIndicesForStrings( const wxArrayString& strings,
1568 wxArrayString* unmatched = NULL ) const;
1569
1570 /**
1571 Returns @true if item at given index has a valid value;
1572 */
1573 bool HasValue( unsigned int i ) const;
1574
1575 /**
1576 Returns index of item with given label.
1577 */
1578 int Index( const wxString& label ) const;
1579
1580 /**
1581 Returns index of item with given value.
1582 */
1583 int Index( int val ) const;
1584
1585 /**
1586 Inserts single item.
1587 */
1588 wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
1589
1590 /**
1591 Inserts a single item with full entry information.
1592 */
1593 wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index );
1594
1595 /**
1596 Returns @false if this is a constant empty set of choices,
1597 which should not be modified.
1598 */
1599 bool IsOk() const;
1600
1601 /**
1602 Returns item at given index.
1603 */
1604 const wxPGChoiceEntry& Item( unsigned int i ) const;
1605
1606 /**
1607 Returns item at given index.
1608 */
1609 wxPGChoiceEntry& Item( unsigned int i );
1610
1611 /**
1612 Removes count items starting at position nIndex.
1613 */
1614 void RemoveAt(size_t nIndex, size_t count = 1);
1615
1616 /**
1617 Sets contents from lists of strings and values.
1618 */
1619 void Set( const wxChar** labels, const long* values = NULL );
1620
1621 /**
1622 Sets contents from lists of strings and values.
1623 */
1624 void Set( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
1625
1626 /**
1627 Creates exclusive copy of current choices.
1628 */
1629 void AllocExclusive();
1630
1631 /**
1632 Returns array of choice labels.
1633 */
1634 wxArrayString GetLabels() const;
1635
1636 void operator= (const wxPGChoices& a);
1637
1638 wxPGChoiceEntry& operator[](unsigned int i);
1639 const wxPGChoiceEntry& operator[](unsigned int i) const;
1640 };
1641
1642 // -----------------------------------------------------------------------