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