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