]> git.saurik.com Git - wxWidgets.git/blame - include/wx/propgrid/property.h
Added wxPropertyGridConstIterator(const wxPropertyGridIterator&) copy ctor
[wxWidgets.git] / include / wx / propgrid / property.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/propgrid/property.h
3// Purpose: wxPGProperty and related support classes
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2008-08-23
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PROPGRID_PROPERTY_H_
13#define _WX_PROPGRID_PROPERTY_H_
14
f4bc1aa2
JS
15#if wxUSE_PROPGRID
16
1c4293cb
VZ
17#include "wx/propgrid/propgriddefs.h"
18
19// -----------------------------------------------------------------------
20
21#define wxNullProperty ((wxPGProperty*)NULL)
22
23
24/** @class wxPGPaintData
25
26 Contains information relayed to property's OnCustomPaint.
27*/
28struct wxPGPaintData
29{
30 /** wxPropertyGrid. */
31 const wxPropertyGrid* m_parent;
32
33 /**
34 Normally -1, otherwise index to drop-down list item that has to be
35 drawn.
36 */
37 int m_choiceItem;
38
39 /** Set to drawn width in OnCustomPaint (optional). */
40 int m_drawnWidth;
41
42 /**
43 In a measure item call, set this to the height of item at m_choiceItem
44 index.
45 */
46 int m_drawnHeight;
47};
48
49
1c4293cb
VZ
50#ifndef SWIG
51
52
53// space between vertical sides of a custom image
54#define wxPG_CUSTOM_IMAGE_SPACINGY 1
55
56// space between caption and selection rectangle,
57#define wxPG_CAPRECTXMARGIN 2
58
59// horizontally and vertically
60#define wxPG_CAPRECTYMARGIN 1
61
62
63/** @class wxPGCellRenderer
64
65 Base class for wxPropertyGrid cell renderers.
66*/
67class WXDLLIMPEXP_PROPGRID wxPGCellRenderer
68{
69public:
70
71 wxPGCellRenderer( unsigned int refCount = 1 )
72 : m_refCount(refCount) { }
73 virtual ~wxPGCellRenderer() { }
74
75 // Render flags
76 enum
77 {
78 Selected = 0x00010000,
79 Control = 0x00020000
80 };
81
82 virtual void Render( wxDC& dc,
83 const wxRect& rect,
84 const wxPropertyGrid* propertyGrid,
85 wxPGProperty* property,
86 int column,
87 int item,
88 int flags ) const = 0;
89
90 /** Returns size of the image in front of the editable area.
91 @remarks
92 If property is NULL, then this call is for a custom value. In that case
93 the item is index to wxPropertyGrid's custom values.
94 */
95 virtual wxSize GetImageSize( const wxPGProperty* property,
96 int column,
97 int item ) const;
98
99 /** Paints property category selection rectangle.
100 */
101 virtual void DrawCaptionSelectionRect( wxDC& dc,
102 int x, int y,
103 int w, int h ) const;
104
105 /** Utility to draw vertically centered text.
106 */
107 void DrawText( wxDC& dc,
108 const wxRect& rect,
109 int imageWidth,
110 const wxString& text ) const;
111
112 /**
113 Utility to draw editor's value, or vertically aligned text if editor is
114 NULL.
115 */
116 void DrawEditorValue( wxDC& dc, const wxRect& rect,
117 int xOffset, const wxString& text,
118 wxPGProperty* property,
119 const wxPGEditor* editor ) const;
120
121 /** Utility to render cell bitmap and set text colour plus bg brush colour.
122
123 Returns image width that, for instance, can be passed to DrawText.
124 */
125 int PreDrawCell( wxDC& dc,
126 const wxRect& rect,
127 const wxPGCell& cell,
128 int flags ) const;
129
130 void IncRef()
131 {
132 m_refCount++;
133 }
134
135 void DecRef()
136 {
137 m_refCount--;
138 if ( !m_refCount )
139 delete this;
140 }
141protected:
142
143private:
144 unsigned int m_refCount;
145};
146
147
148/** @class wxPGCell
149
150 Base class for simple wxPropertyGrid cell information.
151*/
152class WXDLLIMPEXP_PROPGRID wxPGCell
153{
154public:
155 wxPGCell();
156 wxPGCell( const wxString& text,
157 const wxBitmap& bitmap = wxNullBitmap,
158 const wxColour& fgCol = wxNullColour,
159 const wxColour& bgCol = wxNullColour );
160
161 virtual ~wxPGCell() { }
162
163 void SetText( const wxString& text ) { m_text = text; }
164 void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; }
165 void SetFgCol( const wxColour& col ) { m_fgCol = col; }
166 void SetBgCol( const wxColour& col ) { m_bgCol = col; }
167
168 const wxString& GetText() const { return m_text; }
169 const wxBitmap& GetBitmap() const { return m_bitmap; }
170 const wxColour& GetFgCol() const { return m_fgCol; }
171 const wxColour& GetBgCol() const { return m_bgCol; }
172
173protected:
174 wxString m_text;
175 wxBitmap m_bitmap;
176 wxColour m_fgCol;
177 wxColour m_bgCol;
178};
179
180
181/** @class wxPGDefaultRenderer
182
183 Default cell renderer, that can handles the common
184 scenarios.
185*/
186class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer : public wxPGCellRenderer
187{
188public:
189 virtual void Render( wxDC& dc,
190 const wxRect& rect,
191 const wxPropertyGrid* propertyGrid,
192 wxPGProperty* property,
193 int column,
194 int item,
195 int flags ) const;
196
197 virtual wxSize GetImageSize( const wxPGProperty* property,
198 int column,
199 int item ) const;
200
201protected:
202};
203
204// -----------------------------------------------------------------------
205
206/** @class wxPGAttributeStorage
207
208 wxPGAttributeStorage is somewhat optimized storage for
209 key=variant pairs (ie. a map).
210*/
211class WXDLLIMPEXP_PROPGRID wxPGAttributeStorage
212{
213public:
214 wxPGAttributeStorage();
215 ~wxPGAttributeStorage();
216
217 void Set( const wxString& name, const wxVariant& value );
68bcfd2c 218 unsigned int GetCount() const { return (unsigned int) m_map.size(); }
1c4293cb
VZ
219 wxVariant FindValue( const wxString& name ) const
220 {
221 wxPGHashMapS2P::const_iterator it = m_map.find(name);
222 if ( it != m_map.end() )
223 {
224 wxVariantData* data = (wxVariantData*) it->second;
225 data->IncRef();
226 return wxVariant(data, it->first);
227 }
228 return wxVariant();
229 }
230
231 typedef wxPGHashMapS2P::const_iterator const_iterator;
232 const_iterator StartIteration() const
233 {
234 return m_map.begin();
235 }
236 bool GetNext( const_iterator& it, wxVariant& variant ) const
237 {
238 if ( it == m_map.end() )
239 return false;
240
241 wxVariantData* data = (wxVariantData*) it->second;
242 data->IncRef();
243 variant.SetData(data);
244 variant.SetName(it->first);
245 it++;
246 return true;
247 }
248
249protected:
250 wxPGHashMapS2P m_map;
251};
252
253#endif // !SWIG
254
255// -----------------------------------------------------------------------
256
257/** @section propgrid_propflags wxPGProperty Flags
258 @{
259*/
260
261enum wxPG_PROPERTY_FLAGS
262{
263
264/** Indicates bold font.
265*/
266wxPG_PROP_MODIFIED = 0x0001,
267
268/** Disables ('greyed' text and editor does not activate) property.
269*/
270wxPG_PROP_DISABLED = 0x0002,
271
272/** Hider button will hide this property.
273*/
274wxPG_PROP_HIDDEN = 0x0004,
275
276/** This property has custom paint image just in front of its value.
277 If property only draws custom images into a popup list, then this
278 flag should not be set.
279*/
280wxPG_PROP_CUSTOMIMAGE = 0x0008,
281
282/** Do not create text based editor for this property (but button-triggered
283 dialog and choice are ok).
284*/
285wxPG_PROP_NOEDITOR = 0x0010,
286
287/** Property is collapsed, ie. it's children are hidden.
288*/
289wxPG_PROP_COLLAPSED = 0x0020,
290
291/**
292 If property is selected, then indicates that validation failed for pending
293 value.
294
295 If property is not selected, then indicates that the the actual property
296 value has failed validation (NB: this behavior is not currently supported,
297 but may be used in future).
298*/
299wxPG_PROP_INVALID_VALUE = 0x0040,
300
301// 0x0080,
302
303/** Switched via SetWasModified(). Temporary flag - only used when
304 setting/changing property value.
305*/
306wxPG_PROP_WAS_MODIFIED = 0x0200,
307
308/**
309 If set, then child properties (if any) are private, and should be
310 "invisible" to the application.
311*/
312wxPG_PROP_AGGREGATE = 0x0400,
313
314/** If set, then child properties (if any) are copies and should not
315 be deleted in dtor.
316*/
317wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800,
318
319/**
320 Classifies this item as a non-category.
321
322 Used for faster item type identification.
323*/
324wxPG_PROP_PROPERTY = 0x1000,
325
326/**
327 Classifies this item as a category.
328
329 Used for faster item type identification.
330*/
331wxPG_PROP_CATEGORY = 0x2000,
332
333/** Classifies this item as a property that has children, but is not aggregate
334 (ie children are not private).
335*/
336wxPG_PROP_MISC_PARENT = 0x4000,
337
338/** Property is read-only. Editor is still created.
339*/
340wxPG_PROP_READONLY = 0x8000,
341
342//
343// NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS
344//
345
346/** Property's value is composed from values of child properties.
347 @remarks
348 This flag cannot be used with property iterators.
349*/
350wxPG_PROP_COMPOSED_VALUE = 0x00010000,
351
352/** Common value of property is selectable in editor.
353 @remarks
354 This flag cannot be used with property iterators.
355*/
356wxPG_PROP_USES_COMMON_VALUE = 0x00020000,
357
358/** Property can be set to unspecified value via editor.
359 Currently, this applies to following properties:
360 - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty:
361 Clear the text field
362
363 @remarks
364 This flag cannot be used with property iterators.
365*/
366wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000,
367
368/** Indicates the bit useable by derived properties.
369*/
370wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000,
371
372/** Indicates the bit useable by derived properties.
373*/
374wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000
375
376};
377
378/** Topmost flag.
379*/
380#define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED
381
382/** Property with children must have one of these set, otherwise iterators
383 will not work correctly.
384 Code should automatically take care of this, however.
385*/
386#define wxPG_PROP_PARENTAL_FLAGS \
387 (wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY|wxPG_PROP_MISC_PARENT)
388
389/** @}
390*/
391
1c4293cb
VZ
392// Combination of flags that can be stored by GetFlagsAsString
393#define wxPG_STRING_STORED_FLAGS \
394 (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED)
395
396// -----------------------------------------------------------------------
397
398#ifndef SWIG
399
400/**
401 @section propgrid_property_attributes wxPropertyGrid Property Attribute
402 Identifiers.
403
404 wxPGProperty::SetAttribute() and
15cbcd00 405 wxPropertyGridInterface::SetPropertyAttribute() accept one of these as
1c4293cb
VZ
406 attribute name argument.
407
408 You can use strings instead of constants. However, some of these
409 constants are redefined to use cached strings which may reduce
410 your binary size by some amount.
411
412 @{
413*/
414
415/** Set default value for property.
416*/
417#define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue")
418
419/** Universal, int or double. Minimum value for numeric properties.
420*/
421#define wxPG_ATTR_MIN wxS("Min")
422
423/** Universal, int or double. Maximum value for numeric properties.
424*/
425#define wxPG_ATTR_MAX wxS("Max")
426
427/** Universal, string. When set, will be shown as text after the displayed
428 text value. Alternatively, if third column is enabled, text will be shown
429 there (for any type of property).
430*/
431#define wxPG_ATTR_UNITS wxS("Units")
432
433/** Universal, string. When set, will be shown in property's value cell
434 when displayed value string is empty, or value is unspecified.
435*/
436#define wxPG_ATTR_INLINE_HELP wxS("InlineHelp")
437
438/** wxBoolProperty specific, int, default 0. When 1 sets bool property to
439 use checkbox instead of choice.
440*/
441#define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox")
442
443/** wxBoolProperty specific, int, default 0. When 1 sets bool property value
444 to cycle on double click (instead of showing the popup listbox).
445*/
446#define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling")
447
448/**
449 wxFloatProperty (and similar) specific, int, default -1.
450
451 Sets the (max) precision used when floating point value is rendered as
452 text. The default -1 means infinite precision.
453*/
454#define wxPG_FLOAT_PRECISION wxS("Precision")
455
456/**
457 The text will be echoed as asterisks (wxTE_PASSWORD will be passed to
458 textctrl etc).
459*/
460#define wxPG_STRING_PASSWORD wxS("Password")
461
462/** Define base used by a wxUIntProperty. Valid constants are
463 wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL
464 (lowercase characters).
465*/
466#define wxPG_UINT_BASE wxS("Base")
467
468/** Define prefix rendered to wxUIntProperty. Accepted constants
469 wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN.
470 <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal
471 numbers.
472*/
473#define wxPG_UINT_PREFIX wxS("Prefix")
474
475/**
476 wxFileProperty/wxImageFileProperty specific, wxChar*, default is
477 detected/varies.
478 Sets the wildcard used in the triggered wxFileDialog. Format is the same.
479*/
480#define wxPG_FILE_WILDCARD wxS("Wildcard")
481
482/** wxFileProperty/wxImageFileProperty specific, int, default 1.
483 When 0, only the file name is shown (i.e. drive and directory are hidden).
484*/
485#define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath")
486
487/** Specific to wxFileProperty and derived properties, wxString, default empty.
488 If set, then the filename is shown relative to the given path string.
489*/
490#define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath")
491
492/**
493 Specific to wxFileProperty and derived properties, wxString, default is
494 empty.
495
496 Sets the initial path of where to look for files.
497*/
498#define wxPG_FILE_INITIAL_PATH wxS("InitialPath")
499
500/** Specific to wxFileProperty and derivatives, wxString, default is empty.
501 Sets a specific title for the dir dialog.
502*/
503#define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle")
504
505/** Specific to wxDirProperty, wxString, default is empty.
506 Sets a specific message for the dir dialog.
507*/
508#define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage")
509
510/** Sets displayed date format for wxDateProperty.
511*/
512#define wxPG_DATE_FORMAT wxS("DateFormat")
513
514/** Sets wxDatePickerCtrl window style used with wxDateProperty. Default
515 is wxDP_DEFAULT | wxDP_SHOWCENTURY.
516*/
517#define wxPG_DATE_PICKER_STYLE wxS("PickerStyle")
518
519/** SpinCtrl editor, int or double. How much number changes when button is
520 pressed (or up/down on keybard).
521*/
522#define wxPG_ATTR_SPINCTRL_STEP wxS("Step")
523
524/** SpinCtrl editor, bool. If true, value wraps at Min/Max.
525*/
526#define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap")
527
528/**
529 wxMultiChoiceProperty, int.
530 If 0, no user strings allowed. If 1, user strings appear before list
531 strings. If 2, user strings appear after list string.
532*/
533#define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode")
534
535/**
536 wxColourProperty and its kind, int, default 1.
537
538 Setting this attribute to 0 hides custom colour from property's list of
539 choices.
540*/
541#define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom")
542
1c4293cb
VZ
543/** @}
544*/
545
1c4293cb
VZ
546// Redefine attribute macros to use cached strings
547#undef wxPG_ATTR_MIN
548#define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin
549#undef wxPG_ATTR_MAX
550#define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax
551#undef wxPG_ATTR_UNITS
552#define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits
553#undef wxPG_ATTR_INLINE_HELP
554#define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp
555
1c4293cb
VZ
556#endif // !SWIG
557
558// -----------------------------------------------------------------------
559
939d9364 560#ifndef SWIG
1c4293cb 561
939d9364
JS
562/** @class wxPGChoiceEntry
563 Data of a single wxPGChoices choice.
1c4293cb 564*/
939d9364 565class WXDLLIMPEXP_PROPGRID wxPGChoiceEntry : public wxPGCell
1c4293cb 566{
1c4293cb 567public:
939d9364
JS
568 wxPGChoiceEntry();
569 wxPGChoiceEntry( const wxPGChoiceEntry& entry );
570 wxPGChoiceEntry( const wxString& label,
571 int value = wxPG_INVALID_VALUE )
572 : wxPGCell(), m_value(value)
573 {
574 m_text = label;
575 }
1c4293cb 576
939d9364
JS
577 wxPGChoiceEntry( const wxString& label,
578 int value,
579 const wxBitmap& bitmap,
580 const wxColour& fgCol = wxNullColour,
581 const wxColour& bgCol = wxNullColour )
582 : wxPGCell(label, bitmap, fgCol, bgCol), m_value(value)
583 {
584 }
1c4293cb 585
939d9364
JS
586 virtual ~wxPGChoiceEntry()
587 {
588 }
1c4293cb 589
939d9364 590 void SetValue( int value ) { m_value = value; }
1c4293cb 591
939d9364 592 int GetValue() const { return m_value; }
1c4293cb 593
939d9364
JS
594protected:
595 int m_value;
596};
1c4293cb 597
1c4293cb 598
939d9364 599typedef void* wxPGChoicesId;
1c4293cb 600
939d9364
JS
601class WXDLLIMPEXP_PROPGRID wxPGChoicesData
602{
603 friend class wxPGChoices;
604public:
605 // Constructor sets m_refCount to 1.
606 wxPGChoicesData();
1c4293cb 607
939d9364 608 void CopyDataFrom( wxPGChoicesData* data );
1c4293cb 609
939d9364
JS
610 // Takes ownership of 'item'
611 void Insert( int index, wxPGChoiceEntry* item )
612 {
f7a094e1 613 wxVector<wxPGChoiceEntry*>::iterator it;
939d9364
JS
614 if ( index == -1 )
615 {
616 it = m_items.end();
68bcfd2c 617 index = (int) m_items.size();
939d9364
JS
618 }
619 else
620 {
621 it = m_items.begin() + index;
622 }
1c4293cb 623
939d9364
JS
624 // Need to fix value?
625 if ( item->GetValue() == wxPG_INVALID_VALUE )
626 item->SetValue(index);
1c4293cb 627
939d9364
JS
628 m_items.insert(it, item);
629 }
1c4293cb 630
939d9364
JS
631 // Delete all entries
632 void Clear();
1c4293cb 633
68bcfd2c
JS
634 unsigned int GetCount() const
635 {
636 return (unsigned int) m_items.size();
637 }
1c4293cb 638
939d9364
JS
639 wxPGChoiceEntry* Item( unsigned int i ) const
640 {
641 wxCHECK_MSG( i < GetCount(), NULL, "invalid index" );
1c4293cb 642
f7a094e1 643 return m_items[i];
939d9364 644 }
1c4293cb 645
939d9364
JS
646 void DecRef()
647 {
648 m_refCount--;
649 wxASSERT( m_refCount >= 0 );
650 if ( m_refCount == 0 )
651 delete this;
652 }
1c4293cb 653
939d9364 654private:
f7a094e1 655 wxVector<wxPGChoiceEntry*> m_items;
1c4293cb 656
939d9364
JS
657 // So that multiple properties can use the same set
658 int m_refCount;
1c4293cb 659
939d9364
JS
660 virtual ~wxPGChoicesData();
661};
1c4293cb 662
939d9364 663#define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL)
1c4293cb 664
939d9364 665#endif // SWIG
1c4293cb 666
939d9364 667/** @class wxPGChoices
1c4293cb 668
939d9364
JS
669 Helper class for managing choices of wxPropertyGrid properties.
670 Each entry can have label, value, bitmap, text colour, and background
671 colour.
1c4293cb 672
98c04633
JS
673 @remarks If you do not specify value for entry, index is used.
674
939d9364
JS
675 @library{wxpropgrid}
676 @category{propgrid}
677*/
678class WXDLLIMPEXP_PROPGRID wxPGChoices
679{
680public:
681 typedef long ValArrItem;
1c4293cb 682
939d9364
JS
683 /** Default constructor. */
684 wxPGChoices()
685 {
686 Init();
687 }
1c4293cb 688
939d9364
JS
689 /** Copy constructor. */
690 wxPGChoices( const wxPGChoices& a )
691 {
692 if ( a.m_data != wxPGChoicesEmptyData )
693 {
694 m_data = a.m_data;
695 m_data->m_refCount++;
696 }
697 }
1c4293cb 698
98c04633
JS
699 /**
700 Constructor.
701
702 @param labels
703 Labels for choices
704
705 @param values
706 Values for choices. If NULL, indexes are used.
707 */
939d9364
JS
708 wxPGChoices( const wxChar** labels, const long* values = NULL )
709 {
710 Init();
711 Set(labels,values);
712 }
1c4293cb 713
98c04633
JS
714 /**
715 Constructor.
716
717 @param labels
718 Labels for choices
719
720 @param values
721 Values for choices. If empty, indexes are used.
722 */
939d9364
JS
723 wxPGChoices( const wxArrayString& labels,
724 const wxArrayInt& values = wxArrayInt() )
725 {
726 Init();
727 Set(labels,values);
728 }
1c4293cb 729
939d9364
JS
730 /** Simple interface constructor. */
731 wxPGChoices( wxPGChoicesData* data )
732 {
733 wxASSERT(data);
734 m_data = data;
735 data->m_refCount++;
736 }
1c4293cb 737
939d9364
JS
738 /** Destructor. */
739 ~wxPGChoices()
740 {
741 Free();
742 }
1c4293cb 743
939d9364
JS
744 /**
745 Adds to current.
1c4293cb 746
939d9364
JS
747 If did not have own copies, creates them now. If was empty, identical
748 to set except that creates copies.
98c04633
JS
749
750 @param labels
751 Labels for added choices.
752
753 @param values
754 Values for added choices. If empty, relevant entry indexes are used.
1c4293cb 755 */
939d9364 756 void Add( const wxChar** labels, const ValArrItem* values = NULL );
1c4293cb 757
939d9364
JS
758 /** Version that works with wxArrayString. */
759 void Add( const wxArrayString& arr, const ValArrItem* values = NULL );
1c4293cb 760
939d9364
JS
761 /** Version that works with wxArrayString and wxArrayInt. */
762 void Add( const wxArrayString& arr, const wxArrayInt& arrint );
1c4293cb 763
98c04633
JS
764 /**
765 Adds a single choice.
766
767 @param label
768 Label for added choice.
769
770 @param value
771 Value for added choice. If unspecified, index is used.
772 */
939d9364
JS
773 wxPGChoiceEntry& Add( const wxString& label,
774 int value = wxPG_INVALID_VALUE );
1c4293cb 775
939d9364
JS
776 /** Adds a single item, with bitmap. */
777 wxPGChoiceEntry& Add( const wxString& label,
778 const wxBitmap& bitmap,
779 int value = wxPG_INVALID_VALUE );
1c4293cb 780
939d9364
JS
781 /** Adds a single item with full entry information. */
782 wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry )
783 {
784 return Insert(entry, -1);
785 }
1c4293cb 786
939d9364
JS
787 /** Adds single item. */
788 wxPGChoiceEntry& AddAsSorted( const wxString& label,
789 int value = wxPG_INVALID_VALUE );
1c4293cb 790
939d9364
JS
791 void Assign( const wxPGChoices& a )
792 {
793 AssignData(a.m_data);
794 }
1c4293cb 795
939d9364 796 void AssignData( wxPGChoicesData* data );
1c4293cb 797
939d9364
JS
798 /** Delete all choices. */
799 void Clear()
800 {
801 if ( m_data != wxPGChoicesEmptyData )
802 m_data->Clear();
803 }
1c4293cb 804
939d9364
JS
805 void EnsureData()
806 {
807 if ( m_data == wxPGChoicesEmptyData )
808 m_data = new wxPGChoicesData();
809 }
1c4293cb 810
939d9364
JS
811 /** Gets a unsigned number identifying this list. */
812 wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; };
1c4293cb 813
68bcfd2c 814 const wxString& GetLabel( unsigned int ind ) const
939d9364
JS
815 {
816 return Item(ind).GetText();
817 }
1c4293cb 818
68bcfd2c 819 unsigned int GetCount () const
939d9364
JS
820 {
821 if ( !m_data )
822 return 0;
1c4293cb 823
939d9364
JS
824 return m_data->GetCount();
825 }
1c4293cb 826
68bcfd2c 827 int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); }
1c4293cb 828
939d9364
JS
829 /** Returns array of values matching the given strings. Unmatching strings
830 result in wxPG_INVALID_VALUE entry in array.
1c4293cb 831 */
939d9364 832 wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const;
1c4293cb 833
939d9364
JS
834 /** Returns array of indices matching given strings. Unmatching strings
835 are added to 'unmatched', if not NULL.
836 */
837 wxArrayInt GetIndicesForStrings( const wxArrayString& strings,
838 wxArrayString* unmatched = NULL ) const;
1c4293cb 839
939d9364
JS
840 int Index( const wxString& str ) const;
841 int Index( int val ) const;
1c4293cb 842
939d9364
JS
843 /** Inserts single item. */
844 wxPGChoiceEntry& Insert( const wxString& label,
845 int index,
846 int value = wxPG_INVALID_VALUE );
1c4293cb 847
939d9364
JS
848 /** Inserts a single item with full entry information. */
849 wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index );
1c4293cb 850
939d9364
JS
851 /** Returns false if this is a constant empty set of choices,
852 which should not be modified.
1c4293cb 853 */
939d9364
JS
854 bool IsOk() const
855 {
856 return ( m_data != wxPGChoicesEmptyData );
857 }
1c4293cb 858
939d9364
JS
859 const wxPGChoiceEntry& Item( unsigned int i ) const
860 {
861 wxASSERT( IsOk() );
862 return *m_data->Item(i);
863 }
1c4293cb 864
939d9364
JS
865 wxPGChoiceEntry& Item( unsigned int i )
866 {
867 wxASSERT( IsOk() );
868 return *m_data->Item(i);
869 }
1c4293cb 870
939d9364
JS
871 /** Removes count items starting at position nIndex. */
872 void RemoveAt(size_t nIndex, size_t count = 1);
1c4293cb 873
939d9364
JS
874#ifndef SWIG
875 /** Does not create copies for itself. */
876 void Set( const wxChar** labels, const long* values = NULL )
877 {
878 Free();
879 Add(labels,values);
880 }
939d9364
JS
881#endif // SWIG
882
883 /** Version that works with wxArrayString and wxArrayInt. */
884 void Set( const wxArrayString& labels,
885 const wxArrayInt& values = wxArrayInt() )
886 {
887 Free();
888 if ( &values )
889 Add(labels,values);
890 else
891 Add(labels);
892 }
893
894 // Creates exclusive copy of current choices
895 void SetExclusive()
896 {
897 if ( m_data->m_refCount != 1 )
898 {
899 wxPGChoicesData* data = new wxPGChoicesData();
900 data->CopyDataFrom(m_data);
901 Free();
902 m_data = data;
903 }
904 }
905
906 // Returns data, increases refcount.
907 wxPGChoicesData* GetData()
908 {
909 wxASSERT( m_data->m_refCount != 0xFFFFFFF );
910 m_data->m_refCount++;
911 return m_data;
912 }
1c4293cb 913
939d9364
JS
914 // Returns plain data ptr - no refcounting stuff is done.
915 wxPGChoicesData* GetDataPtr() const { return m_data; }
1c4293cb 916
939d9364
JS
917 // Changes ownership of data to you.
918 wxPGChoicesData* ExtractData()
1c4293cb 919 {
939d9364
JS
920 wxPGChoicesData* data = m_data;
921 m_data = wxPGChoicesEmptyData;
922 return data;
1c4293cb
VZ
923 }
924
939d9364 925 wxArrayString GetLabels() const;
1c4293cb 926
939d9364
JS
927#ifndef SWIG
928 void operator= (const wxPGChoices& a)
929 {
930 AssignData(a.m_data);
1c4293cb
VZ
931 }
932
939d9364 933 wxPGChoiceEntry& operator[](unsigned int i)
1c4293cb 934 {
939d9364 935 return Item(i);
1c4293cb
VZ
936 }
937
939d9364 938 const wxPGChoiceEntry& operator[](unsigned int i) const
1c4293cb 939 {
939d9364 940 return Item(i);
1c4293cb
VZ
941 }
942
939d9364
JS
943protected:
944 wxPGChoicesData* m_data;
1c4293cb 945
939d9364
JS
946 void Init();
947 void Free();
948#endif // !SWIG
949};
1c4293cb 950
939d9364 951// -----------------------------------------------------------------------
1c4293cb 952
939d9364 953/** @class wxPGProperty
1c4293cb 954
939d9364 955 wxPGProperty is base class for all wxPropertyGrid properties.
1c4293cb 956
939d9364
JS
957 NB: Full class overview is now only present in
958 interface/wx/propgrid/property.h.
1c4293cb 959
939d9364
JS
960 @library{wxpropgrid}
961 @category{propgrid}
962*/
963class WXDLLIMPEXP_PROPGRID wxPGProperty : public wxObject
964{
965 friend class wxPropertyGrid;
966 friend class wxPropertyGridInterface;
967 friend class wxPropertyGridPageState;
968 friend class wxPropertyGridPopulator;
969 friend class wxStringProperty; // Proper "<composed>" support requires this
1c4293cb 970#ifndef SWIG
939d9364 971 DECLARE_ABSTRACT_CLASS(wxPGProperty)
1c4293cb 972#endif
939d9364
JS
973public:
974 typedef wxUint32 FlagType;
1c4293cb 975
939d9364 976 /** Basic constructor.
1c4293cb 977 */
939d9364 978 wxPGProperty();
1c4293cb 979
939d9364
JS
980 /** Constructor.
981 Non-abstract property classes should have constructor of this style:
1c4293cb 982
939d9364 983 @code
1c4293cb 984
939d9364
JS
985 // If T is a class, then it should be a constant reference
986 // (e.g. const T& ) instead.
987 MyProperty( const wxString& label, const wxString& name, T value )
988 : wxPGProperty()
989 {
990 // Generally recommended way to set the initial value
991 // (as it should work in pretty much 100% of cases).
992 wxVariant variant;
993 variant << value;
994 SetValue(variant);
1c4293cb 995
2fd4a524
JS
996 // If has private child properties then create them here. Also
997 // set flag that indicates presence of private children. E.g.:
998 //
999 // SetParentalType(wxPG_PROP_AGGREGATE);
1000 //
939d9364
JS
1001 // AddChild( new wxStringProperty( "Subprop 1",
1002 // wxPG_LABEL,
1003 // value.GetSubProp1() ) );
1004 }
1c4293cb 1005
939d9364
JS
1006 @endcode
1007 */
1008 wxPGProperty( const wxString& label, const wxString& name );
1c4293cb 1009
939d9364
JS
1010 /**
1011 Virtual destructor.
1012 It is customary for derived properties to implement this.
1c4293cb 1013 */
939d9364 1014 virtual ~wxPGProperty();
1c4293cb 1015
939d9364 1016 /** This virtual function is called after m_value has been set.
1c4293cb 1017
939d9364
JS
1018 @remarks
1019 - If m_value was set to Null variant (ie. unspecified value),
1020 OnSetValue() will not be called.
1021 - m_value may be of any variant type. Typically properties internally
1022 support only one variant type, and as such OnSetValue() provides a
1023 good opportunity to convert
1024 supported values into internal type.
1025 - Default implementation does nothing.
1026 */
1027 virtual void OnSetValue();
1c4293cb 1028
939d9364
JS
1029 /** Override this to return something else than m_value as the value.
1030 */
1031 virtual wxVariant DoGetValue() const { return m_value; }
1032
1033#if !defined(SWIG) || defined(CREATE_VCW)
1034 /** Implement this function in derived class to check the value.
1035 Return true if it is ok. Returning false prevents property change events
1036 from occurring.
1c4293cb 1037
1c4293cb 1038 @remarks
939d9364 1039 - Default implementation always returns true.
1c4293cb 1040 */
939d9364
JS
1041 virtual bool ValidateValue( wxVariant& value,
1042 wxPGValidationInfo& validationInfo ) const;
1c4293cb 1043
939d9364 1044 /**
9e6bebdc
JS
1045 Converts text into wxVariant value appropriate for this property.
1046
1047 @param variant
1048 On function entry this is the old value (should not be wxNullVariant
1049 in normal cases). Translated value must be assigned back to it.
1050
1051 @param text
1052 Text to be translated into variant.
1053
939d9364
JS
1054 @param argFlags
1055 If wxPG_FULL_VALUE is set, returns complete, storable value instead
1056 of displayable one (they may be different).
1057 If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of
1425eca5 1058 composite property string value (as generated by ValueToString()
939d9364 1059 called with this same flag).
1c4293cb 1060
9e6bebdc
JS
1061 @return Returns @true if resulting wxVariant value was different.
1062
1063 @remarks Default implementation converts semicolon delimited tokens into
1064 child values. Only works for properties with children.
1065
1066 You might want to take into account that m_value is Null variant
1067 if property value is unspecified (which is usually only case if
1068 you explicitly enabled that sort behavior).
1c4293cb 1069 */
939d9364
JS
1070 virtual bool StringToValue( wxVariant& variant,
1071 const wxString& text,
1072 int argFlags = 0 ) const;
1c4293cb 1073
939d9364 1074 /**
9e6bebdc
JS
1075 Converts integer (possibly a choice selection) into wxVariant value
1076 appropriate for this property.
1c4293cb 1077
9e6bebdc
JS
1078 @param variant
1079 On function entry this is the old value (should not be wxNullVariant
1080 in normal cases). Translated value must be assigned back to it.
1081
1082 @param number
1083 Integer to be translated into variant.
1c4293cb 1084
939d9364
JS
1085 @param argFlags
1086 If wxPG_FULL_VALUE is set, returns complete, storable value instead
1087 of displayable one.
1c4293cb 1088
9e6bebdc
JS
1089 @return Returns @true if resulting wxVariant value was different.
1090
939d9364
JS
1091 @remarks
1092 - If property is not supposed to use choice or spinctrl or other editor
1093 with int-based value, it is not necessary to implement this method.
1094 - Default implementation simply assign given int to m_value.
1095 - If property uses choice control, and displays a dialog on some choice
1096 items, then it is preferred to display that dialog in IntToValue
1097 instead of OnEvent.
9e6bebdc
JS
1098 - You might want to take into account that m_value is Null variant if
1099 property value is unspecified (which is usually only case if you
1100 explicitly enabled that sort behavior).
1c4293cb 1101 */
939d9364
JS
1102 virtual bool IntToValue( wxVariant& value,
1103 int number,
1104 int argFlags = 0 ) const;
1105#endif // !defined(SWIG) || defined(CREATE_VCW)
1425eca5
JS
1106 /**
1107 Converts property value into a text representation.
1c4293cb 1108
1425eca5
JS
1109 @param value
1110 Value to be converted.
1c4293cb 1111
939d9364 1112 @param argFlags
1425eca5 1113 If 0 (default value), then displayed string is returned.
939d9364
JS
1114 If wxPG_FULL_VALUE is set, returns complete, storable string value
1115 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
1116 string value that must be editable in textctrl. If
1117 wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
1425eca5
JS
1118 display as a part of string property's composite text
1119 representation.
1c4293cb 1120
1425eca5 1121 @remarks Default implementation calls GenerateComposedValue().
1c4293cb 1122 */
1425eca5 1123 virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const;
1c4293cb 1124
939d9364
JS
1125 /** Converts string to a value, and if successful, calls SetValue() on it.
1126 Default behavior is to do nothing.
1127 @param text
1128 String to get the value from.
1129 @return
1130 true if value was changed.
1c4293cb 1131 */
f275b5db 1132 bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE );
1c4293cb 1133
939d9364
JS
1134 /** Converts integer to a value, and if succesful, calls SetValue() on it.
1135 Default behavior is to do nothing.
1136 @param value
1137 Int to get the value from.
1138 @param flags
1139 If has wxPG_FULL_VALUE, then the value given is a actual value and
1140 not an index.
1141 @return
1142 True if value was changed.
1c4293cb 1143 */
939d9364 1144 bool SetValueFromInt( long value, int flags = 0 );
1c4293cb
VZ
1145
1146 /**
939d9364 1147 Returns size of the custom painted image in front of property.
1c4293cb 1148
939d9364
JS
1149 This method must be overridden to return non-default value if
1150 OnCustomPaint is to be called.
1151 @param item
1152 Normally -1, but can be an index to the property's list of items.
1153 @remarks
1154 - Default behavior is to return wxSize(0,0), which means no image.
1155 - Default image width or height is indicated with dimension -1.
1156 - You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxSize(-1, -1).
1c4293cb 1157 */
939d9364 1158 virtual wxSize OnMeasureImage( int item = -1 ) const;
1c4293cb
VZ
1159
1160 /**
939d9364 1161 Events received by editor widgets are processed here.
1c4293cb 1162
939d9364
JS
1163 Note that editor class usually processes most events. Some, such as
1164 button press events of TextCtrlAndButton class, can be handled here.
1165 Also, if custom handling for regular events is desired, then that can
1166 also be done (for example, wxSystemColourProperty custom handles
1167 wxEVT_COMMAND_CHOICE_SELECTED to display colour picker dialog when
1168 'custom' selection is made).
1c4293cb 1169
939d9364
JS
1170 If the event causes value to be changed, SetValueInEvent()
1171 should be called to set the new value.
1c4293cb 1172
939d9364
JS
1173 @param event
1174 Associated wxEvent.
1175 @return
1176 Should return true if any changes in value should be reported.
1177 @remarks
1178 If property uses choice control, and displays a dialog on some choice
1179 items, then it is preferred to display that dialog in IntToValue
1180 instead of OnEvent.
1c4293cb 1181 */
939d9364
JS
1182 virtual bool OnEvent( wxPropertyGrid* propgrid,
1183 wxWindow* wnd_primary,
1184 wxEvent& event );
1c4293cb 1185
939d9364
JS
1186 /**
1187 Called after value of a child property has been altered.
1c4293cb 1188
939d9364
JS
1189 Note that this function is usually called at the time that value of
1190 this property, or given child property, is still pending for change.
1c4293cb 1191
939d9364 1192 Sample pseudo-code implementation:
1c4293cb 1193
939d9364
JS
1194 @code
1195 void MyProperty::ChildChanged( wxVariant& thisValue,
1196 int childIndex,
1197 wxVariant& childValue ) const
1198 {
1199 // Acquire reference to actual type of data stored in variant
1200 // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros
1201 // were used to create the variant class).
1202 T& data = TFromVariant(thisValue);
1c4293cb 1203
939d9364
JS
1204 // Copy childValue into data.
1205 switch ( childIndex )
1206 {
1207 case 0:
1208 data.SetSubProp1( childvalue.GetLong() );
1209 break;
1210 case 1:
1211 data.SetSubProp2( childvalue.GetString() );
1212 break;
1213 ...
1214 }
1215 }
1216 @endcode
1c4293cb 1217
939d9364
JS
1218 @param thisValue
1219 Value of this property, that should be altered.
1220 @param childIndex
1221 Index of child changed (you can use Item(childIndex) to get).
1222 @param childValue
1223 Value of the child property.
1c4293cb 1224 */
939d9364
JS
1225 virtual void ChildChanged( wxVariant& thisValue,
1226 int childIndex,
1227 wxVariant& childValue ) const;
1c4293cb 1228
939d9364 1229 /** Returns pointer to an instance of used editor.
1c4293cb 1230 */
939d9364 1231 virtual const wxPGEditor* DoGetEditorClass() const;
1c4293cb 1232
939d9364
JS
1233 /** Returns pointer to the wxValidator that should be used
1234 with the editor of this property (NULL for no validator).
1235 Setting validator explicitly via SetPropertyValidator
1236 will override this.
1c4293cb 1237
939d9364
JS
1238 In most situations, code like this should work well
1239 (macros are used to maintain one actual validator instance,
1240 so on the second call the function exits within the first
1241 macro):
1c4293cb 1242
939d9364 1243 @code
1c4293cb 1244
939d9364
JS
1245 wxValidator* wxMyPropertyClass::DoGetValidator () const
1246 {
1247 WX_PG_DOGETVALIDATOR_ENTRY()
1c4293cb 1248
939d9364 1249 wxMyValidator* validator = new wxMyValidator(...);
1c4293cb 1250
939d9364 1251 ... prepare validator...
1c4293cb 1252
939d9364
JS
1253 WX_PG_DOGETVALIDATOR_EXIT(validator)
1254 }
1c4293cb 1255
939d9364
JS
1256 @endcode
1257
1258 @remarks
1259 You can get common filename validator by returning
1260 wxFileProperty::GetClassValidator(). wxDirProperty,
1261 for example, uses it.
1c4293cb 1262 */
939d9364 1263 virtual wxValidator* DoGetValidator () const;
1c4293cb 1264
939d9364
JS
1265 /**
1266 Override to paint an image in front of the property value text or
1267 drop-down list item (but only if wxPGProperty::OnMeasureImage is
1268 overridden as well).
1c4293cb 1269
939d9364
JS
1270 If property's OnMeasureImage() returns size that has height != 0 but
1271 less than row height ( < 0 has special meanings), wxPropertyGrid calls
1272 this method to draw a custom image in a limited area in front of the
1273 editor control or value text/graphics, and if control has drop-down
1274 list, then the image is drawn there as well (even in the case
1275 OnMeasureImage() returned higher height than row height).
1c4293cb 1276
939d9364
JS
1277 NOTE: Following applies when OnMeasureImage() returns a "flexible"
1278 height ( using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable
1279 height items: If rect.x is < 0, then this is a measure item call, which
1280 means that dc is invalid and only thing that should be done is to set
1281 paintdata.m_drawnHeight to the height of the image of item at index
1282 paintdata.m_choiceItem. This call may be done even as often as once
1283 every drop-down popup show.
1c4293cb 1284
939d9364
JS
1285 @param dc
1286 wxDC to paint on.
1287 @param rect
1288 Box reserved for custom graphics. Includes surrounding rectangle,
1289 if any. If x is < 0, then this is a measure item call (see above).
1290 @param paintdata
1291 wxPGPaintData structure with much useful data.
1c4293cb 1292
939d9364
JS
1293 @remarks
1294 - You can actually exceed rect width, but if you do so then
1295 paintdata.m_drawnWidth must be set to the full width drawn in
1296 pixels.
1297 - Due to technical reasons, rect's height will be default even if
1298 custom height was reported during measure call.
1299 - Brush is guaranteed to be default background colour. It has been
1300 already used to clear the background of area being painted. It
1301 can be modified.
1302 - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper
1303 colour) pen for drawing framing rectangle. It can be changed as
1304 well.
1305
1425eca5 1306 @see ValueToString()
1c4293cb 1307 */
939d9364
JS
1308 virtual void OnCustomPaint( wxDC& dc,
1309 const wxRect& rect,
1310 wxPGPaintData& paintdata );
1c4293cb 1311
939d9364
JS
1312 /**
1313 Returns used wxPGCellRenderer instance for given property column
1314 (label=0, value=1).
1c4293cb 1315
939d9364 1316 Default implementation returns editor's renderer for all columns.
1c4293cb 1317 */
939d9364 1318 virtual wxPGCellRenderer* GetCellRenderer( int column ) const;
1c4293cb 1319
939d9364
JS
1320 /** Returns which choice is currently selected. Only applies to properties
1321 which have choices.
1c4293cb 1322
939d9364
JS
1323 Needs to reimplemented in derived class if property value does not
1324 map directly to a choice. Integer as index, bool, and string usually do.
1c4293cb 1325 */
939d9364 1326 virtual int GetChoiceSelection() const;
1c4293cb 1327
939d9364
JS
1328 /**
1329 Refresh values of child properties.
1c4293cb 1330
939d9364 1331 Automatically called after value is set.
1c4293cb 1332 */
939d9364 1333 virtual void RefreshChildren();
1c4293cb 1334
939d9364 1335 /** Special handling for attributes of this property.
1c4293cb 1336
939d9364
JS
1337 If returns false, then the attribute will be automatically stored in
1338 m_attributes.
1c4293cb 1339
939d9364 1340 Default implementation simply returns false.
1c4293cb 1341 */
939d9364 1342 virtual bool DoSetAttribute( const wxString& name, wxVariant& value );
1c4293cb 1343
939d9364 1344 /** Returns value of an attribute.
1c4293cb 1345
939d9364 1346 Override if custom handling of attributes is needed.
1c4293cb 1347
939d9364 1348 Default implementation simply return NULL variant.
1c4293cb 1349 */
939d9364 1350 virtual wxVariant DoGetAttribute( const wxString& name ) const;
1c4293cb 1351
939d9364
JS
1352 /** Returns instance of a new wxPGEditorDialogAdapter instance, which is
1353 used when user presses the (optional) button next to the editor control;
1c4293cb 1354
939d9364
JS
1355 Default implementation returns NULL (ie. no action is generated when
1356 button is pressed).
1c4293cb 1357 */
939d9364
JS
1358 virtual wxPGEditorDialogAdapter* GetEditorDialog() const;
1359
1360 /** Returns wxPGCell of given column, NULL if none. If valid
1361 object is returned, caller will gain its ownership.
1362 */
1363 wxPGCell* AcquireCell( unsigned int column )
1c4293cb 1364 {
939d9364
JS
1365 if ( column >= m_cells.size() )
1366 return NULL;
1367
1368 wxPGCell* cell = (wxPGCell*) m_cells[column];
1369 m_cells[column] = NULL;
1370 return cell;
1c4293cb
VZ
1371 }
1372
939d9364 1373 /** Append a new choice to property's list of choices.
1c4293cb 1374 */
939d9364
JS
1375 int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE )
1376 {
1377 return InsertChoice(label, wxNOT_FOUND, value);
1378 }
1c4293cb 1379
939d9364
JS
1380 /**
1381 Returns true if children of this property are component values (for
1382 instance, points size, face name, and is_underlined are component
1383 values of a font).
1c4293cb 1384 */
939d9364 1385 bool AreChildrenComponents() const
1c4293cb 1386 {
939d9364
JS
1387 if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) )
1388 return true;
1389
1390 return false;
1c4293cb
VZ
1391 }
1392
939d9364
JS
1393 /**
1394 Removes entry from property's wxPGChoices and editor control (if it is
1395 active).
1c4293cb 1396
939d9364 1397 If selected item is deleted, then the value is set to unspecified.
1c4293cb 1398 */
939d9364 1399 void DeleteChoice( int index );
1c4293cb
VZ
1400
1401 /**
939d9364
JS
1402 Call to enable or disable usage of common value (integer value that can
1403 be selected for properties instead of their normal values) for this
1404 property.
1c4293cb 1405
939d9364
JS
1406 Common values are disabled by the default for all properties.
1407 */
1408 void EnableCommonValue( bool enable = true )
1409 {
1410 if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE );
1411 else ClearFlag( wxPG_PROP_USES_COMMON_VALUE );
1412 }
1c4293cb 1413
1425eca5 1414 /**
c82a80e8 1415 Composes text from values of child properties.
1425eca5 1416 */
c82a80e8
JS
1417 wxString GenerateComposedValue() const
1418 {
1419 wxString s;
1420 DoGenerateComposedValue(s);
1421 return s;
1422 }
1c4293cb 1423
939d9364
JS
1424 /** Returns property's label. */
1425 const wxString& GetLabel() const { return m_label; }
1c4293cb 1426
939d9364
JS
1427 /** Returns property's name with all (non-category, non-root) parents. */
1428 wxString GetName() const;
1c4293cb 1429
939d9364
JS
1430 /**
1431 Returns property's base name (ie parent's name is not added in any
1432 case)
1433 */
1434 const wxString& GetBaseName() const { return m_name; }
1435
1436 /** Returns read-only reference to property's list of choices.
1c4293cb 1437 */
939d9364
JS
1438 const wxPGChoices& GetChoices() const
1439 {
1440 return m_choices;
1441 }
1c4293cb 1442
939d9364
JS
1443 /** Returns coordinate to the top y of the property. Note that the
1444 position of scrollbars is not taken into account.
1c4293cb 1445 */
939d9364 1446 int GetY() const;
1c4293cb 1447
939d9364 1448 wxVariant GetValue() const
1c4293cb 1449 {
939d9364 1450 return DoGetValue();
1c4293cb
VZ
1451 }
1452
939d9364
JS
1453#ifndef SWIG
1454 /** Returns reference to the internal stored value. GetValue is preferred
1455 way to get the actual value, since GetValueRef ignores DoGetValue,
1456 which may override stored value.
1457 */
1458 wxVariant& GetValueRef()
1459 {
1460 return m_value;
1461 }
1c4293cb 1462
939d9364 1463 const wxVariant& GetValueRef() const
1c4293cb 1464 {
939d9364 1465 return m_value;
1c4293cb 1466 }
939d9364 1467#endif
1c4293cb 1468
1425eca5
JS
1469 /** Returns text representation of property's value.
1470
1471 @param argFlags
1472 If 0 (default value), then displayed string is returned.
1473 If wxPG_FULL_VALUE is set, returns complete, storable string value
1474 instead of displayable. If wxPG_EDITABLE_VALUE is set, returns
1475 string value that must be editable in textctrl. If
1476 wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to
1477 display as a part of string property's composite text
1478 representation.
1479
1480 @remarks In older versions, this function used to be overridden to convert
1481 property's value into a string representation. This function is
1482 now handled by ValueToString(), and overriding this function now
1483 will result in run-time assertion failure.
1484 */
1485 virtual wxString GetValueAsString( int argFlags = 0 ) const;
1486
1487 /** Synonymous to GetValueAsString().
1488
1489 @deprecated Use GetValueAsString() instead.
1490
1491 @see GetValueAsString()
939d9364 1492 */
1425eca5 1493 wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
1c4293cb 1494
939d9364 1495 void UpdateControl( wxWindow* primary );
1c4293cb 1496
939d9364
JS
1497 /** Returns wxPGCell of given column, NULL if none. wxPGProperty
1498 will retain ownership of the cell object.
1499 */
1500 wxPGCell* GetCell( unsigned int column ) const
1c4293cb 1501 {
939d9364
JS
1502 if ( column >= m_cells.size() )
1503 return NULL;
1c4293cb 1504
939d9364 1505 return (wxPGCell*) m_cells[column];
1c4293cb
VZ
1506 }
1507
939d9364
JS
1508 /** Return number of displayed common values for this property.
1509 */
1510 int GetDisplayedCommonValueCount() const;
1511
1512 wxString GetDisplayedString() const
1c4293cb 1513 {
1425eca5 1514 return GetValueAsString(0);
1c4293cb 1515 }
1c4293cb 1516
939d9364
JS
1517 /** Returns property grid where property lies. */
1518 wxPropertyGrid* GetGrid() const;
1519
1520 /** Returns owner wxPropertyGrid, but only if one is currently on a page
1521 displaying this property. */
1522 wxPropertyGrid* GetGridIfDisplayed() const;
1523
1524 /** Returns highest level non-category, non-root parent. Useful when you
1525 have nested wxCustomProperties/wxParentProperties.
1c4293cb 1526 @remarks
939d9364
JS
1527 Thus, if immediate parent is root or category, this will return the
1528 property itself.
1c4293cb 1529 */
939d9364 1530 wxPGProperty* GetMainParent() const;
1c4293cb 1531
939d9364
JS
1532 /** Return parent of property */
1533 wxPGProperty* GetParent() const { return m_parent; }
1534
1535 /** Returns true if property has editable wxTextCtrl when selected.
1536
1537 @remarks
1538 Altough disabled properties do not displayed editor, they still
1539 return True here as being disabled is considered a temporary
1540 condition (unlike being read-only or having limited editing enabled).
1c4293cb 1541 */
939d9364
JS
1542 bool IsTextEditable() const;
1543
1544 bool IsValueUnspecified() const
1c4293cb 1545 {
939d9364 1546 return m_value.IsNull();
1c4293cb
VZ
1547 }
1548
939d9364 1549 FlagType HasFlag( FlagType flag ) const
1c4293cb 1550 {
939d9364 1551 return ( m_flags & flag );
1c4293cb
VZ
1552 }
1553
939d9364 1554 /** Returns comma-delimited string of property attributes.
1c4293cb 1555 */
939d9364 1556 const wxPGAttributeStorage& GetAttributes() const
1c4293cb 1557 {
939d9364 1558 return m_attributes;
1c4293cb
VZ
1559 }
1560
939d9364 1561 /** Returns m_attributes as list wxVariant.
1c4293cb 1562 */
939d9364 1563 wxVariant GetAttributesAsList() const;
1c4293cb 1564
939d9364
JS
1565 FlagType GetFlags() const
1566 {
1567 return m_flags;
1568 }
1c4293cb 1569
939d9364 1570 const wxPGEditor* GetEditorClass() const;
1c4293cb 1571
939d9364
JS
1572 wxString GetValueType() const
1573 {
1574 return m_value.GetType();
1575 }
1c4293cb 1576
939d9364 1577 /** Returns editor used for given column. NULL for no editor.
1c4293cb 1578 */
939d9364 1579 const wxPGEditor* GetColumnEditor( int column ) const
1c4293cb 1580 {
939d9364
JS
1581 if ( column == 1 )
1582 return GetEditorClass();
1583
1584 return NULL;
1c4293cb
VZ
1585 }
1586
939d9364
JS
1587 /** Returns common value selected for this property. -1 for none.
1588 */
1589 int GetCommonValue() const
1c4293cb 1590 {
939d9364 1591 return m_commonValue;
1c4293cb
VZ
1592 }
1593
939d9364
JS
1594 /** Returns true if property has even one visible child.
1595 */
1596 bool HasVisibleChildren() const;
1c4293cb 1597
939d9364
JS
1598 /** Inserts a new choice to property's list of choices.
1599 */
1600 int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE );
1c4293cb
VZ
1601
1602 /**
939d9364 1603 Returns true if this property is actually a wxPropertyCategory.
1c4293cb 1604 */
939d9364 1605 bool IsCategory() const { return HasFlag(wxPG_PROP_CATEGORY)?true:false; }
1c4293cb 1606
939d9364 1607 /** Returns true if this property is actually a wxRootProperty.
1c4293cb 1608 */
939d9364 1609 bool IsRoot() const { return (m_parent == NULL); }
1c4293cb 1610
939d9364
JS
1611 /** Returns true if this is a sub-property. */
1612 bool IsSubProperty() const
1613 {
1614 wxPGProperty* parent = (wxPGProperty*)m_parent;
1615 if ( parent && !parent->IsCategory() )
1616 return true;
1617 return false;
1618 }
1c4293cb 1619
939d9364 1620 /** Returns last visible sub-property, recursively.
1c4293cb 1621 */
939d9364 1622 const wxPGProperty* GetLastVisibleSubItem() const;
1c4293cb 1623
939d9364 1624 wxVariant GetDefaultValue() const;
1c4293cb 1625
939d9364
JS
1626 int GetMaxLength() const
1627 {
1628 return (int) m_maxLen;
1629 }
1c4293cb 1630
939d9364
JS
1631 /**
1632 Determines, recursively, if all children are not unspecified.
1c4293cb 1633
bb6720bb
JS
1634 @param pendingList
1635 Assumes members in this wxVariant list as pending
1636 replacement values.
939d9364
JS
1637 */
1638 bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const;
1c4293cb 1639
939d9364
JS
1640 /** Updates composed values of parent non-category properties, recursively.
1641 Returns topmost property updated.
1c4293cb 1642
939d9364
JS
1643 @remarks
1644 - Must not call SetValue() (as can be called in it).
1c4293cb 1645 */
939d9364 1646 wxPGProperty* UpdateParentValues();
1c4293cb 1647
939d9364
JS
1648 /** Returns true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES.
1649 */
bb6720bb 1650 bool UsesAutoUnspecified() const
939d9364 1651 {
bb6720bb 1652 return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED)?true:false;
1c4293cb 1653 }
939d9364
JS
1654
1655 wxBitmap* GetValueImage() const
1656 {
1657 return m_valueBitmap;
1c4293cb 1658 }
1c4293cb 1659
939d9364 1660 wxVariant GetAttribute( const wxString& name ) const;
1c4293cb 1661
939d9364
JS
1662 /**
1663 Returns named attribute, as string, if found.
1c4293cb 1664
939d9364 1665 Otherwise defVal is returned.
1c4293cb 1666 */
939d9364 1667 wxString GetAttribute( const wxString& name, const wxString& defVal ) const;
1c4293cb 1668
939d9364
JS
1669 /**
1670 Returns named attribute, as long, if found.
1c4293cb 1671
939d9364
JS
1672 Otherwise defVal is returned.
1673 */
1674 long GetAttributeAsLong( const wxString& name, long defVal ) const;
1c4293cb 1675
939d9364
JS
1676 /**
1677 Returns named attribute, as double, if found.
1c4293cb 1678
939d9364 1679 Otherwise defVal is returned.
1c4293cb 1680 */
939d9364 1681 double GetAttributeAsDouble( const wxString& name, double defVal ) const;
1c4293cb 1682
939d9364 1683 unsigned int GetDepth() const { return (unsigned int)m_depth; }
1c4293cb 1684
939d9364
JS
1685 /** Gets flags as a'|' delimited string. Note that flag names are not
1686 prepended with 'wxPG_PROP_'.
1687 @param flagsMask
1688 String will only be made to include flags combined by this parameter.
1689 */
1690 wxString GetFlagsAsString( FlagType flagsMask ) const;
1c4293cb 1691
939d9364
JS
1692 /** Returns position in parent's array. */
1693 unsigned int GetIndexInParent() const
1c4293cb 1694 {
939d9364 1695 return (unsigned int)m_arrIndex;
1c4293cb
VZ
1696 }
1697
939d9364
JS
1698 /** Hides or reveals the property.
1699 @param hide
1700 true for hide, false for reveal.
1701 @param flags
1702 By default changes are applied recursively. Set this paramter
1703 wxPG_DONT_RECURSE to prevent this.
1704 */
1705 inline bool Hide( bool hide, int flags = wxPG_RECURSE );
1c4293cb 1706
939d9364
JS
1707 bool IsExpanded() const
1708 { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); }
1c4293cb 1709
939d9364
JS
1710 /** Returns true if all parents expanded.
1711 */
1712 bool IsVisible() const;
1c4293cb 1713
939d9364 1714 bool IsEnabled() const { return !(m_flags & wxPG_PROP_DISABLED); }
1c4293cb 1715
939d9364
JS
1716 /** If property's editor is created this forces its recreation.
1717 Useful in SetAttribute etc. Returns true if actually did anything.
1718 */
1719 bool RecreateEditor();
1c4293cb 1720
939d9364
JS
1721 /** If property's editor is active, then update it's value.
1722 */
1723 void RefreshEditor();
1c4293cb 1724
939d9364
JS
1725 /** Sets an attribute for this property.
1726 @param name
1727 Text identifier of attribute. See @ref propgrid_property_attributes.
1728 @param value
1729 Value of attribute.
1730 */
1731 void SetAttribute( const wxString& name, wxVariant value );
1c4293cb 1732
939d9364 1733 void SetAttributes( const wxPGAttributeStorage& attributes );
1c4293cb 1734
939d9364
JS
1735#ifndef SWIG
1736 /** Sets editor for a property.
1c4293cb 1737
939d9364
JS
1738 @param editor
1739 For builtin editors, use wxPGEditor_X, where X is builtin editor's
1740 name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
1741 list).
1c4293cb 1742
939d9364
JS
1743 For custom editors, use pointer you received from
1744 wxPropertyGrid::RegisterEditorClass().
1745 */
1746 void SetEditor( const wxPGEditor* editor )
1747 {
1748 m_customEditor = editor;
1749 }
1750#endif
1c4293cb 1751
939d9364
JS
1752 /** Sets editor for a property.
1753 */
1754 inline void SetEditor( const wxString& editorName );
1c4293cb 1755
939d9364 1756 /** Sets cell information for given column.
1c4293cb 1757
939d9364
JS
1758 Note that the property takes ownership of given wxPGCell instance.
1759 */
1760 void SetCell( int column, wxPGCell* cellObj );
1c4293cb 1761
939d9364
JS
1762 /** Sets common value selected for this property. -1 for none.
1763 */
1764 void SetCommonValue( int commonValue )
1765 {
1766 m_commonValue = commonValue;
1767 }
1c4293cb 1768
939d9364
JS
1769 /** Sets flags from a '|' delimited string. Note that flag names are not
1770 prepended with 'wxPG_PROP_'.
1771 */
1772 void SetFlagsFromString( const wxString& str );
1c4293cb 1773
939d9364
JS
1774 /** Sets property's "is it modified?" flag. Affects children recursively.
1775 */
1776 void SetModifiedStatus( bool modified )
1777 {
1778 SetFlagRecursively(wxPG_PROP_MODIFIED, modified);
1779 }
1c4293cb 1780
939d9364
JS
1781 /** Call in OnEvent(), OnButtonClick() etc. to change the property value
1782 based on user input.
1c4293cb 1783
939d9364
JS
1784 @remarks
1785 This method is const since it doesn't actually modify value, but posts
1786 given variant as pending value, stored in wxPropertyGrid.
1787 */
1788 void SetValueInEvent( wxVariant value ) const;
1c4293cb 1789
939d9364
JS
1790 /**
1791 Call this to set value of the property.
1c4293cb 1792
939d9364
JS
1793 Unlike methods in wxPropertyGrid, this does not automatically update
1794 the display.
1c4293cb 1795
939d9364
JS
1796 @remarks
1797 Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
1798 through validation process and send property change event.
1c4293cb 1799
939d9364
JS
1800 If you need to change property value in event, based on user input, use
1801 SetValueInEvent() instead.
1c4293cb 1802
939d9364
JS
1803 @param pList
1804 Pointer to list variant that contains child values. Used to indicate
1805 which children should be marked as modified.
1806 @param flags
1807 Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR).
1808 */
1809 void SetValue( wxVariant value, wxVariant* pList = NULL, int flags = 0 );
1c4293cb 1810
939d9364
JS
1811 /** Set wxBitmap in front of the value. This bitmap may be ignored
1812 by custom cell renderers.
1813 */
1814 void SetValueImage( wxBitmap& bmp );
1c4293cb 1815
939d9364
JS
1816 /** If property has choices and they are not yet exclusive, new such copy
1817 of them will be created.
1818 */
1819 void SetChoicesExclusive()
1c4293cb 1820 {
939d9364 1821 m_choices.SetExclusive();
1c4293cb
VZ
1822 }
1823
939d9364 1824 /** Sets selected choice and changes property value.
1c4293cb 1825
939d9364
JS
1826 Tries to retain value type, although currently if it is not string,
1827 then it is forced to integer.
1828 */
1829 void SetChoiceSelection( int newValue );
1c4293cb 1830
939d9364
JS
1831 void SetExpanded( bool expanded )
1832 {
1833 if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED;
1834 else m_flags &= ~wxPG_PROP_COLLAPSED;
1835 }
1c4293cb 1836
939d9364 1837 void SetFlag( FlagType flag ) { m_flags |= flag; }
1c4293cb 1838
939d9364 1839 void SetFlagRecursively( FlagType flag, bool set );
1c4293cb 1840
939d9364
JS
1841 void SetHelpString( const wxString& helpString )
1842 {
1843 m_helpString = helpString;
1844 }
1c4293cb 1845
939d9364 1846 void SetLabel( const wxString& label ) { m_label = label; }
1c4293cb 1847
939d9364 1848 inline void SetName( const wxString& newName );
1c4293cb 1849
2fd4a524
JS
1850 /**
1851 Changes what sort of parent this property is for its children.
1852
1853 @param flag
1854 Use one of the following values: wxPG_PROP_MISC_PARENT (for generic
1855 parents), wxPG_PROP_CATEGORY (for categories), or
1856 wxPG_PROP_AGGREGATE (for derived property classes with private
1857 children).
1858
1859 @remarks You only need to call this if you use AddChild() to add
1860 child properties. Adding properties with
1861 wxPropertyGridInterface::Insert() or
1862 wxPropertyGridInterface::AppendIn() will automatically set
1863 property to use wxPG_PROP_MISC_PARENT style.
1864 */
1865 void SetParentalType( int flag )
1866 {
1867 m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS);
1868 m_flags |= flag;
1869 }
1870
939d9364
JS
1871 void SetValueToUnspecified()
1872 {
1873 wxVariant val; // Create NULL variant
1874 SetValue(val);
1875 }
1c4293cb 1876
939d9364
JS
1877#if wxUSE_VALIDATORS
1878 /** Sets wxValidator for a property*/
1879 void SetValidator( const wxValidator& validator )
1880 {
1881 m_validator = wxDynamicCast(validator.Clone(),wxValidator);
1882 }
1c4293cb 1883
939d9364
JS
1884 /** Gets assignable version of property's validator. */
1885 wxValidator* GetValidator() const
1886 {
1887 if ( m_validator )
1888 return m_validator;
1889 return DoGetValidator();
1890 }
1891#endif // #if wxUSE_VALIDATORS
1c4293cb 1892
1c4293cb 1893#ifndef SWIG
939d9364
JS
1894 /** Returns client data (void*) of a property.
1895 */
1896 void* GetClientData() const
1c4293cb 1897 {
939d9364 1898 return m_clientData;
1c4293cb
VZ
1899 }
1900
939d9364
JS
1901 /** Sets client data (void*) of a property.
1902 @remarks
1903 This untyped client data has to be deleted manually.
1904 */
1905 void SetClientData( void* clientData )
1c4293cb 1906 {
939d9364 1907 m_clientData = clientData;
1c4293cb
VZ
1908 }
1909
939d9364
JS
1910 /** Returns client object of a property.
1911 */
1912 void SetClientObject(wxClientData* clientObject)
1c4293cb 1913 {
939d9364
JS
1914 delete m_clientObject;
1915 m_clientObject = clientObject;
1c4293cb
VZ
1916 }
1917
939d9364
JS
1918 /** Sets managed client object of a property.
1919 */
1920 wxClientData *GetClientObject() const { return m_clientObject; }
1921#endif
1c4293cb 1922
939d9364 1923 /** Sets new set of choices for property.
1c4293cb 1924
939d9364
JS
1925 @remarks
1926 This operation clears the property value.
1927 */
1928 bool SetChoices( wxPGChoices& choices );
1c4293cb 1929
939d9364
JS
1930 /** Set max length of text in text editor.
1931 */
1932 inline bool SetMaxLength( int maxLen );
1c4293cb 1933
939d9364
JS
1934 /** Call with 'false' in OnSetValue to cancel value changes after all
1935 (ie. cancel 'true' returned by StringToValue() or IntToValue()).
1936 */
1937 void SetWasModified( bool set = true )
1c4293cb 1938 {
939d9364
JS
1939 if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED;
1940 else m_flags &= ~wxPG_PROP_WAS_MODIFIED;
1941 }
1c4293cb 1942
939d9364
JS
1943 const wxString& GetHelpString() const
1944 {
1945 return m_helpString;
1c4293cb
VZ
1946 }
1947
939d9364 1948 void ClearFlag( FlagType flag ) { m_flags &= ~(flag); }
1c4293cb 1949
939d9364
JS
1950 // Use, for example, to detect if item is inside collapsed section.
1951 bool IsSomeParent( wxPGProperty* candidate_parent ) const;
1c4293cb 1952
939d9364
JS
1953 /**
1954 Adapts list variant into proper value using consecutive
1955 ChildChanged-calls.
1956 */
1957 void AdaptListToValue( wxVariant& list, wxVariant* value ) const;
99774d58 1958
2fd4a524
JS
1959 /**
1960 Adds a child property. If you use this instead of
1961 wxPropertyGridInterface::Insert() or
1962 wxPropertyGridInterface::AppendIn(), then you must set up
1963 property's parental type before making the call. To do this,
1964 call property's SetParentalType() function with either
1965 wxPG_PROP_MISC_PARENT (normal, public children) or with
1966 wxPG_PROP_AGGREGATE (private children for subclassed property).
1967 For instance:
1968
1969 @code
1970 wxPGProperty* prop = new wxStringProperty(wxS("Property"));
1971 prop->SetParentalType(wxPG_PROP_MISC_PARENT);
1972 wxPGProperty* prop2 = new wxStringProperty(wxS("Property2"));
1973 prop->AddChild(prop2);
1974 @endcode
1975 */
939d9364 1976 void AddChild( wxPGProperty* prop );
1c4293cb 1977
939d9364
JS
1978 /** Returns height of children, recursively, and
1979 by taking expanded/collapsed status into account.
1c4293cb 1980
939d9364
JS
1981 iMax is used when finding property y-positions.
1982 */
1983 int GetChildrenHeight( int lh, int iMax = -1 ) const;
1c4293cb 1984
939d9364 1985 /** Returns number of child properties */
68bcfd2c
JS
1986 unsigned int GetChildCount() const
1987 {
1988 return (unsigned int) m_children.size();
1989 }
1c4293cb 1990
939d9364 1991 /** Returns sub-property at index i. */
68bcfd2c 1992 wxPGProperty* Item( unsigned int i ) const
f7a094e1 1993 { return m_children[i]; }
1c4293cb 1994
939d9364
JS
1995 /** Returns last sub-property.
1996 */
f7a094e1 1997 wxPGProperty* Last() const { return m_children.back(); }
1c4293cb 1998
f7a094e1
JS
1999 /** Returns index of given child property. */
2000 int Index( const wxPGProperty* p ) const;
1c4293cb 2001
939d9364
JS
2002 /** Deletes all sub-properties. */
2003 void Empty();
1c4293cb 2004
939d9364 2005 // Puts correct indexes to children
1b895132 2006 void FixIndicesOfChildren( unsigned int starthere = 0 );
1c4293cb 2007
939d9364
JS
2008#ifndef SWIG
2009 // Returns wxPropertyGridPageState in which this property resides.
2010 wxPropertyGridPageState* GetParentState() const { return m_parentState; }
2011#endif
1c4293cb 2012
939d9364
JS
2013 wxPGProperty* GetItemAtY( unsigned int y,
2014 unsigned int lh,
2015 unsigned int* nextItemY ) const;
1c4293cb 2016
939d9364
JS
2017 /** Returns (direct) child property with given name (or NULL if not found).
2018 */
2019 wxPGProperty* GetPropertyByName( const wxString& name ) const;
1c4293cb 2020
939d9364
JS
2021#ifdef SWIG
2022 %extend {
2023 DocStr(GetClientData,
2024 "Returns the client data object for a property", "");
2025 PyObject* GetClientData() {
2026 wxPyClientData* data = (wxPyClientData*)self->GetClientObject();
2027 if (data) {
2028 Py_INCREF(data->m_obj);
2029 return data->m_obj;
2030 } else {
2031 Py_INCREF(Py_None);
2032 return Py_None;
2033 }
1c4293cb 2034 }
1c4293cb 2035
939d9364
JS
2036 DocStr(SetClientData,
2037 "Associate the given client data.", "");
2038 void SetClientData(PyObject* clientData) {
2039 wxPyClientData* data = new wxPyClientData(clientData);
2040 self->SetClientObject(data);
2041 }
1c4293cb 2042 }
939d9364
JS
2043 %pythoncode {
2044 GetClientObject = GetClientData
2045 SetClientObject = SetClientData
1c4293cb 2046 }
939d9364 2047#endif
1c4293cb 2048
939d9364 2049#ifndef SWIG
1c4293cb 2050
939d9364 2051 static wxString* sm_wxPG_LABEL;
1c4293cb 2052
939d9364
JS
2053 /** This member is public so scripting language bindings
2054 wrapper code can access it freely.
2055 */
2056 void* m_clientData;
1c4293cb 2057
939d9364
JS
2058protected:
2059 /** Returns text for given column.
1c4293cb 2060 */
939d9364 2061 wxString GetColumnText( unsigned int col ) const;
1c4293cb 2062
939d9364
JS
2063 /** Returns (direct) child property with given name (or NULL if not found),
2064 with hint index.
1c4293cb 2065
939d9364
JS
2066 @param hintIndex
2067 Start looking for the child at this index.
1c4293cb 2068
939d9364
JS
2069 @remarks
2070 Does not support scope (ie. Parent.Child notation).
2071 */
2072 wxPGProperty* GetPropertyByNameWH( const wxString& name,
2073 unsigned int hintIndex ) const;
1c4293cb 2074
939d9364
JS
2075 /** This is used by Insert etc. */
2076 void AddChild2( wxPGProperty* prop,
2077 int index = -1,
2078 bool correct_mode = true );
1c4293cb 2079
c82a80e8
JS
2080 void DoGenerateComposedValue( wxString& text,
2081 int argFlags = wxPG_VALUE_IS_CURRENT,
2082 const wxVariantList* valueOverrides = NULL,
2083 wxPGHashMapS2S* childResults = NULL ) const;
2084
939d9364
JS
2085 void DoSetName(const wxString& str) { m_name = str; }
2086
2fd4a524
JS
2087 void InitAfterAdded( wxPropertyGridPageState* pageState,
2088 wxPropertyGrid* propgrid );
939d9364 2089
d8c74d04
JS
2090 // Removes child property with given pointer. Does not delete it.
2091 void RemoveChild( wxPGProperty* p );
2092
939d9364
JS
2093 void SetParentState( wxPropertyGridPageState* pstate )
2094 { m_parentState = pstate; }
2095
2096 // Call after fixed sub-properties added/removed after creation.
2097 // if oldSelInd >= 0 and < new max items, then selection is
2098 // moved to it.
2099 void SubPropsChanged( int oldSelInd = -1 );
1c4293cb 2100
939d9364 2101 int GetY2( int lh ) const;
1c4293cb 2102
939d9364
JS
2103 wxString m_label;
2104 wxString m_name;
2105 wxPGProperty* m_parent;
2106 wxPropertyGridPageState* m_parentState;
1c4293cb 2107
939d9364 2108 wxClientData* m_clientObject;
1c4293cb 2109
939d9364
JS
2110 // Overrides editor returned by property class
2111 const wxPGEditor* m_customEditor;
2112#if wxUSE_VALIDATORS
2113 // Editor is going to get this validator
2114 wxValidator* m_validator;
2115#endif
2116 // Show this in front of the value
2117 //
2118 // TODO: Can bitmap be implemented with wxPGCell?
2119 wxBitmap* m_valueBitmap;
1c4293cb 2120
939d9364
JS
2121 wxVariant m_value;
2122 wxPGAttributeStorage m_attributes;
f7a094e1 2123 wxArrayPGProperty m_children;
1c4293cb 2124
939d9364
JS
2125 // Extended cell information
2126 wxArrayPtrVoid m_cells;
1c4293cb 2127
939d9364
JS
2128 // Choices shown in drop-down list of editor control.
2129 wxPGChoices m_choices;
1c4293cb 2130
939d9364
JS
2131 // Help shown in statusbar or help box.
2132 wxString m_helpString;
1c4293cb 2133
939d9364
JS
2134 // Index in parent's property array.
2135 unsigned int m_arrIndex;
1c4293cb 2136
939d9364
JS
2137 // If not -1, then overrides m_value
2138 int m_commonValue;
1c4293cb 2139
939d9364 2140 FlagType m_flags;
1c4293cb 2141
939d9364
JS
2142 // Maximum length (mainly for string properties). Could be in some sort of
2143 // wxBaseStringProperty, but currently, for maximum flexibility and
2144 // compatibility, we'll stick it here. Anyway, we had 3 excess bytes to use
2145 // so short int will fit in just fine.
2146 short m_maxLen;
1c4293cb 2147
939d9364
JS
2148 // Root has 0, categories etc. at that level 1, etc.
2149 unsigned char m_depth;
1c4293cb 2150
939d9364
JS
2151 // m_depthBgCol indicates width of background colour between margin and item
2152 // (essentially this is category's depth, if none then equals m_depth).
2153 unsigned char m_depthBgCol;
1c4293cb 2154
939d9364
JS
2155 unsigned char m_bgColIndex; // Background brush index.
2156 unsigned char m_fgColIndex; // Foreground colour index.
1c4293cb 2157
939d9364
JS
2158private:
2159 // Called in constructors.
2160 void Init();
2161 void Init( const wxString& label, const wxString& name );
2162#endif // #ifndef SWIG
2163};
1c4293cb 2164
939d9364 2165// -----------------------------------------------------------------------
1c4293cb 2166
939d9364
JS
2167//
2168// Property class declaration helper macros
2169// (wxPGRootPropertyClass and wxPropertyCategory require this).
2170//
1c4293cb 2171
939d9364
JS
2172#define WX_PG_DECLARE_DOGETEDITORCLASS \
2173 virtual const wxPGEditor* DoGetEditorClass() const;
1c4293cb
VZ
2174
2175#ifndef SWIG
939d9364
JS
2176 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \
2177 public: \
2178 DECLARE_DYNAMIC_CLASS(CLASSNAME) \
2179 WX_PG_DECLARE_DOGETEDITORCLASS \
2180 private:
2181#else
2182 #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME)
2183#endif
1c4293cb 2184
939d9364
JS
2185// Implements sans constructor function. Also, first arg is class name, not
2186// property name.
2187#define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \
2188const wxPGEditor* PROPNAME::DoGetEditorClass() const \
2189{ \
2190 return wxPGEditor_##EDITOR; \
2191}
1c4293cb 2192
939d9364 2193// -----------------------------------------------------------------------
1c4293cb 2194
939d9364 2195#ifndef SWIG
1c4293cb 2196
939d9364
JS
2197/** @class wxPGRootProperty
2198 @ingroup classes
2199 Root parent property.
2200*/
2201class WXDLLIMPEXP_PROPGRID wxPGRootProperty : public wxPGProperty
2202{
2203public:
2204 WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty)
2205public:
1c4293cb 2206
939d9364
JS
2207 /** Constructor. */
2208 wxPGRootProperty();
2209 virtual ~wxPGRootProperty();
1c4293cb 2210
939d9364 2211 virtual bool StringToValue( wxVariant&, const wxString&, int ) const
1c4293cb 2212 {
939d9364 2213 return false;
1c4293cb
VZ
2214 }
2215
939d9364
JS
2216protected:
2217};
1c4293cb 2218
939d9364 2219// -----------------------------------------------------------------------
1c4293cb 2220
939d9364
JS
2221/** @class wxPropertyCategory
2222 @ingroup classes
2223 Category (caption) property.
2224*/
2225class WXDLLIMPEXP_PROPGRID wxPropertyCategory : public wxPGProperty
2226{
2227 friend class wxPropertyGrid;
2228 friend class wxPropertyGridPageState;
2229 WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory)
2230public:
1c4293cb 2231
939d9364
JS
2232 /** Default constructor is only used in special cases. */
2233 wxPropertyCategory();
2234
2235 wxPropertyCategory( const wxString& label,
2236 const wxString& name = wxPG_LABEL );
2237 ~wxPropertyCategory();
2238
2239 int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const;
1c4293cb
VZ
2240
2241protected:
1425eca5 2242 virtual wxString ValueToString( wxVariant& value, int argFlags ) const;
1c4293cb 2243
939d9364
JS
2244 void SetTextColIndex( unsigned int colInd )
2245 { m_capFgColIndex = (wxByte) colInd; }
2246 unsigned int GetTextColIndex() const
2247 { return (unsigned int) m_capFgColIndex; }
2248
2249 void CalculateTextExtent( wxWindow* wnd, const wxFont& font );
2250
2251 int m_textExtent; // pre-calculated length of text
2252 wxByte m_capFgColIndex; // caption text colour index
2253
2254private:
1c4293cb 2255 void Init();
1c4293cb
VZ
2256};
2257
939d9364 2258#endif // !SWIG
1c4293cb
VZ
2259
2260// -----------------------------------------------------------------------
2261
f4bc1aa2
JS
2262#endif // wxUSE_PROPGRID
2263
1c4293cb 2264#endif // _WX_PROPGRID_PROPERTY_H_