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