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