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