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