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