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