1//--------------------------------------------------------------------------- 2// This file is generated by wxPython's SIP generator. Do not edit by hand. 3// 4// Copyright: (c) 2018 by Total Control Software 5// License: wxWindows License 6// 7// This file will be included by _propgrid.sip 8// 9//--------------------------------------------------------------------------- 10 11//--------------------------------------------------------------------------- 12 13class wxPGPropArgCls 14{ 15 %Docstring 16 PGPropArgCls(property) 17 PGPropArgCls(str) 18 PGPropArgCls(id) 19 20 Most property grid functions have this type as their argument, as it 21 can convey a property by either a pointer or name. 22 %End 23 %TypeHeaderCode 24 #include <wx/propgrid/propgridiface.h> 25 %End 26 27public: 28 wxPGPropArgCls( 29 const wxPGProperty * property 30 ); 31 32 wxPGPropArgCls(const wxString& str) /NoDerived/; 33 %MethodCode 34 PyErr_Clear(); 35 sipCpp = _wxPGPropArgCls_ctor(str); 36 %End 37 %TypeCode 38 wxPGPropArgCls* _wxPGPropArgCls_ctor(const wxString* str) 39 { 40 wxString* name = new wxString(*str); 41 return new wxPGPropArgCls(name, true); 42 } 43 %End 44 45 wxPGPropArgCls( 46 const wxPGPropArgCls & id 47 ); 48 49 ~wxPGPropArgCls(); 50 51 wxPGProperty * GetPtr() const; 52 %Docstring 53 GetPtr() -> PGProperty 54 GetPtr(iface) -> PGProperty 55 %End 56 57 wxPGProperty * GetPtr( 58 const wxPropertyGridInterface * iface 59 ) const; 60 61 wxPGProperty * GetPtr0() const; 62 %Docstring 63 GetPtr0() -> PGProperty 64 %End 65 66 bool HasName() const; 67 %Docstring 68 HasName() -> bool 69 %End 70 71 const wxString & GetName() const; 72 %Docstring 73 GetName() -> String 74 %End 75 76 public: 77 78 79 %Property(name=Name, get=GetName) 80 %Property(name=Ptr, get=GetPtr) 81 %Property(name=Ptr0, get=GetPtr0) 82 %ConvertToTypeCode 83 // Code to test a PyObject for compatibility with wxPGPropArgCls 84 if (!sipIsErr) { 85 if (sipCanConvertToType(sipPy, sipType_wxPGPropArgCls, SIP_NO_CONVERTORS)) 86 return TRUE; 87 if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) 88 return TRUE; 89 if (sipPy == Py_None) 90 return TRUE; 91 if (sipCanConvertToType(sipPy, sipType_wxPGProperty, SIP_NO_CONVERTORS)) 92 return TRUE; 93 return FALSE; 94 } 95 96 // Code to convert a compatible PyObject to a wxPGPropArgCls 97 if (PyBytes_Check(sipPy) || PyUnicode_Check(sipPy)) { 98 wxString* name = new wxString(Py2wxString(sipPy)); 99 *sipCppPtr = new wxPGPropArgCls(name, true); 100 return sipGetState(sipTransferObj); 101 } 102 else if (sipCanConvertToType(sipPy, sipType_wxPGProperty, SIP_NO_CONVERTORS)) { 103 int state = 0; 104 wxPGProperty* prop = reinterpret_cast<wxPGProperty*>( 105 sipConvertToType(sipPy, sipType_wxPGProperty, sipTransferObj, SIP_NO_CONVERTORS, &state, sipIsErr)); 106 *sipCppPtr = new wxPGPropArgCls(prop); 107 sipReleaseType(prop, sipType_wxPGProperty, state); 108 return sipGetState(sipTransferObj); 109 } 110 else if (sipPy == Py_None) { 111 *sipCppPtr = new wxPGPropArgCls(static_cast< wxPGProperty * >(NULL)); 112 return sipGetState(sipTransferObj); 113 } 114 else { 115 // It's already a wxPGPropArgCls, just fetch the pointer and return 116 *sipCppPtr = reinterpret_cast<wxPGPropArgCls*>(sipConvertToType( 117 sipPy, sipType_wxPGPropArgCls, sipTransferObj, 118 SIP_NO_CONVERTORS, 0, sipIsErr)); 119 return 0; // not a new instance 120 } 121 %End 122}; // end of class wxPGPropArgCls 123 124 125class wxPropertyGridInterface /Abstract/ 126{ 127 %Docstring 128 Most of the shared property manipulation interface shared by 129 wxPropertyGrid, wxPropertyGridPage, and wxPropertyGridManager is 130 defined in this class. 131 %End 132 %TypeHeaderCode 133 #include <wx/propgrid/propgridiface.h> 134 %End 135 136public: 137 enum EditableStateFlags 138 { 139 SelectionState, 140 ExpandedState, 141 ScrollPosState, 142 PageState, 143 SplitterPosState, 144 DescBoxState, 145 AllStates 146 }; 147 148 virtual 149 ~wxPropertyGridInterface(); 150 151 wxPropertyGridIterator GetIterator( 152 int flags = wxPG_ITERATE_DEFAULT, 153 wxPGProperty * firstProp = NULL 154 ); 155 %Docstring 156 GetIterator(flags=PG_ITERATE_DEFAULT, firstProp=None) -> PropertyGridIterator 157 GetIterator(flags, startPos) -> PropertyGridIterator 158 159 Returns iterator class instance. 160 %End 161 162 wxPropertyGridIterator GetIterator( 163 int flags, 164 int startPos 165 ); 166 167 wxPGProperty * Append( 168 wxPGProperty * property /Transfer/ 169 ); 170 %Docstring 171 Append(property) -> PGProperty 172 173 Appends property to the list. 174 %End 175 176 wxPGProperty * AppendIn( 177 const wxPGPropArgCls & id, 178 wxPGProperty * newProperty /Transfer/ 179 ); 180 %Docstring 181 AppendIn(id, newProperty) -> PGProperty 182 183 Same as Append(), but appends under given parent property. 184 %End 185 186 void BeginAddChildren( 187 const wxPGPropArgCls & id 188 ); 189 %Docstring 190 BeginAddChildren(id) 191 192 In order to add new items into a property with private children (for 193 instance, wxFlagsProperty), you need to call this method. 194 %End 195 196 virtual 197 void Clear() = 0; 198 %Docstring 199 Clear() 200 201 Deletes all properties. 202 %End 203 204 bool ClearSelection( 205 bool validation = false 206 ); 207 %Docstring 208 ClearSelection(validation=False) -> bool 209 210 Clears current selection, if any. 211 %End 212 213 void ClearModifiedStatus(); 214 %Docstring 215 ClearModifiedStatus() 216 217 Resets modified status of all properties. 218 %End 219 220 bool Collapse( 221 const wxPGPropArgCls & id 222 ); 223 %Docstring 224 Collapse(id) -> bool 225 226 Collapses given category or property with children. 227 %End 228 229 bool CollapseAll(); 230 %Docstring 231 CollapseAll() -> bool 232 233 Collapses all items that can be collapsed. 234 %End 235 236 bool ChangePropertyValue( 237 const wxPGPropArgCls & id, 238 wxPGVariant newValue 239 ); 240 %Docstring 241 ChangePropertyValue(id, newValue) -> bool 242 243 Changes value of a property, as if by user. 244 %End 245 246 void DeleteProperty( 247 const wxPGPropArgCls & id 248 ); 249 %Docstring 250 DeleteProperty(id) 251 252 Removes and deletes a property and any children. 253 %End 254 255 bool DisableProperty( 256 const wxPGPropArgCls & id 257 ); 258 %Docstring 259 DisableProperty(id) -> bool 260 261 Disables a property. 262 %End 263 264 bool EditorValidate(); 265 %Docstring 266 EditorValidate() -> bool 267 268 Returns true if all property grid data changes have been committed. 269 %End 270 271 bool EnableProperty( 272 const wxPGPropArgCls & id, 273 bool enable = true 274 ); 275 %Docstring 276 EnableProperty(id, enable=True) -> bool 277 278 Enables or disables property. 279 %End 280 281 void EndAddChildren( 282 const wxPGPropArgCls & id 283 ); 284 %Docstring 285 EndAddChildren(id) 286 287 Called after population of property with fixed children has finished. 288 %End 289 290 bool Expand( 291 const wxPGPropArgCls & id 292 ); 293 %Docstring 294 Expand(id) -> bool 295 296 Expands given category or property with children. 297 %End 298 299 bool ExpandAll( 300 bool expand = true 301 ); 302 %Docstring 303 ExpandAll(expand=True) -> bool 304 305 Expands all items that can be expanded. 306 %End 307 308 int GetColumnProportion( 309 unsigned int column 310 ) const; 311 %Docstring 312 GetColumnProportion(column) -> int 313 314 Returns auto-resize proportion of the given column. 315 %End 316 317 wxPGProperty * GetFirstChild( 318 const wxPGPropArgCls & id 319 ); 320 %Docstring 321 GetFirstChild(id) -> PGProperty 322 323 Returns id of first child of given property. 324 %End 325 326 wxPGProperty * GetFirst( 327 int flags = wxPG_ITERATE_ALL 328 ); 329 %Docstring 330 GetFirst(flags=PG_ITERATE_ALL) -> PGProperty 331 332 Returns id of first item that matches given criteria. 333 %End 334 335 wxPGProperty * GetProperty( 336 const wxString & name 337 ) const; 338 %Docstring 339 GetProperty(name) -> PGProperty 340 341 Returns pointer to a property with given name (case-sensitive). 342 %End 343 344 void GetPropertiesWithFlag( 345 wxArrayPGProperty * targetArr, 346 wxPGProperty::FlagType flags, 347 bool inverse = false, 348 int iterFlags = wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES 349 ) const; 350 %Docstring 351 GetPropertiesWithFlag(targetArr, flags, inverse=False, iterFlags=PG_ITERATE_PROPERTIES|PG_ITERATE_HIDDEN|PG_ITERATE_CATEGORIES) 352 353 Adds to 'targetArr' pointers to properties that have given flags 354 'flags' set. 355 %End 356 357 wxPGVariant GetPropertyAttribute( 358 const wxPGPropArgCls & id, 359 const wxString & attrName 360 ) const; 361 %Docstring 362 GetPropertyAttribute(id, attrName) -> PGVariant 363 364 Returns value of given attribute. 365 %End 366 367 wxColour GetPropertyBackgroundColour( 368 const wxPGPropArgCls & id 369 ) const; 370 %Docstring 371 GetPropertyBackgroundColour(id) -> wx.Colour 372 373 Returns background colour of first cell of a property. 374 %End 375 376 wxPropertyCategory * GetPropertyCategory( 377 const wxPGPropArgCls & id 378 ) const; 379 %Docstring 380 GetPropertyCategory(id) -> PropertyCategory 381 382 Returns pointer of property's nearest parent category. 383 %End 384 385 wxPGProperty * GetPropertyByLabel( 386 const wxString & label 387 ) const; 388 %Docstring 389 GetPropertyByLabel(label) -> PGProperty 390 391 Returns first property which label matches given string. 392 %End 393 394 wxPGProperty * GetPropertyByName( 395 const wxString & name 396 ) const; 397 %Docstring 398 GetPropertyByName(name) -> PGProperty 399 GetPropertyByName(name, subname) -> PGProperty 400 401 Returns pointer to a property with given name (case-sensitive). 402 %End 403 404 wxPGProperty * GetPropertyByName( 405 const wxString & name, 406 const wxString & subname 407 ) const; 408 409 const wxPGEditor * GetPropertyEditor( 410 const wxPGPropArgCls & id 411 ) const; 412 %Docstring 413 GetPropertyEditor(id) -> PGEditor 414 415 Returns property's editor. 416 %End 417 418 wxString GetPropertyHelpString( 419 const wxPGPropArgCls & id 420 ) const; 421 %Docstring 422 GetPropertyHelpString(id) -> String 423 424 Returns help string associated with a property. 425 %End 426 427 wxBitmap * GetPropertyImage( 428 const wxPGPropArgCls & id 429 ) const; 430 %Docstring 431 GetPropertyImage(id) -> wx.Bitmap 432 433 Returns property's custom value image (NULL of none). 434 %End 435 436 const wxString & GetPropertyLabel( 437 const wxPGPropArgCls & id 438 ); 439 %Docstring 440 GetPropertyLabel(id) -> String 441 442 Returns label of a property. 443 %End 444 445 wxString GetPropertyName( 446 wxPGProperty * property 447 ); 448 %Docstring 449 GetPropertyName(property) -> String 450 451 Returns property's name, by which it is globally accessible. 452 %End 453 454 wxColour GetPropertyTextColour( 455 const wxPGPropArgCls & id 456 ) const; 457 %Docstring 458 GetPropertyTextColour(id) -> wx.Colour 459 460 Returns text colour of first cell of a property. 461 %End 462 463 wxValidator * GetPropertyValidator( 464 const wxPGPropArgCls & id 465 ); 466 %Docstring 467 GetPropertyValidator(id) -> wx.Validator 468 469 Returns validator of a property as a reference, which you can pass to 470 any number of SetPropertyValidator. 471 %End 472 473 wxPGVariant GetPropertyValue( 474 const wxPGPropArgCls & id 475 ); 476 %Docstring 477 GetPropertyValue(id) -> PGVariant 478 479 Returns property's value as wxVariant. 480 %End 481 482 wxArrayInt GetPropertyValueAsArrayInt( 483 const wxPGPropArgCls & id 484 ) const; 485 %Docstring 486 GetPropertyValueAsArrayInt(id) -> ArrayInt 487 488 Return's property's value as wxArrayInt. 489 %End 490 491 wxArrayString GetPropertyValueAsArrayString( 492 const wxPGPropArgCls & id 493 ) const; 494 %Docstring 495 GetPropertyValueAsArrayString(id) -> ArrayString 496 497 Returns property's value as wxArrayString. 498 %End 499 500 bool GetPropertyValueAsBool( 501 const wxPGPropArgCls & id 502 ) const; 503 %Docstring 504 GetPropertyValueAsBool(id) -> bool 505 506 Returns property's value as bool. 507 %End 508 509 wxDateTime GetPropertyValueAsDateTime( 510 const wxPGPropArgCls & id 511 ) const; 512 %Docstring 513 GetPropertyValueAsDateTime(id) -> wx.DateTime 514 515 Return's property's value as wxDateTime. 516 %End 517 518 double GetPropertyValueAsDouble( 519 const wxPGPropArgCls & id 520 ) const; 521 %Docstring 522 GetPropertyValueAsDouble(id) -> double 523 524 Returns property's value as double-precision floating point number. 525 %End 526 527 int GetPropertyValueAsInt( 528 const wxPGPropArgCls & id 529 ) const; 530 %Docstring 531 GetPropertyValueAsInt(id) -> int 532 533 Returns property's value as integer. 534 %End 535 536 long GetPropertyValueAsLong( 537 const wxPGPropArgCls & id 538 ) const; 539 %Docstring 540 GetPropertyValueAsLong(id) -> long 541 542 Returns property's value as integer. 543 %End 544 545 wxLongLong_t GetPropertyValueAsLongLong( 546 const wxPGPropArgCls & id 547 ) const; 548 %Docstring 549 GetPropertyValueAsLongLong(id) -> LongLong_t 550 551 Returns property's value as native signed 64-bit integer. 552 %End 553 554 wxString GetPropertyValueAsString( 555 const wxPGPropArgCls & id 556 ) const; 557 %Docstring 558 GetPropertyValueAsString(id) -> String 559 560 Returns property's value as wxString. 561 %End 562 563 unsigned long GetPropertyValueAsULong( 564 const wxPGPropArgCls & id 565 ) const; 566 %Docstring 567 GetPropertyValueAsULong(id) -> unsignedlong 568 569 Returns property's value as unsigned integer. 570 %End 571 572 wxULongLong_t GetPropertyValueAsULongLong( 573 const wxPGPropArgCls & id 574 ) const; 575 %Docstring 576 GetPropertyValueAsULongLong(id) -> ULongLong_t 577 578 Returns property's value as native unsigned 64-bit integer. 579 %End 580 581 const wxArrayPGProperty & GetSelectedProperties() const; 582 %Docstring 583 GetSelectedProperties() -> ArrayPGProperty 584 585 Returns list of currently selected properties. 586 %End 587 588 wxPGProperty * GetSelection() const; 589 %Docstring 590 GetSelection() -> PGProperty 591 592 Returns currently selected property. 593 %End 594 595 virtual 596 wxPGVIterator GetVIterator( 597 int flags 598 ) const; 599 %Docstring 600 GetVIterator(flags) -> PGVIterator 601 602 Similar to GetIterator(), but instead returns wxPGVIterator instance, 603 which can be useful for forward-iterating through arbitrary property 604 containers. 605 %End 606 607 bool HideProperty( 608 const wxPGPropArgCls & id, 609 bool hide = true, 610 int flags = wxPG_RECURSE 611 ); 612 %Docstring 613 HideProperty(id, hide=True, flags=PG_RECURSE) -> bool 614 615 Hides or reveals a property. 616 %End 617 618 wxPGProperty * Insert( 619 const wxPGPropArgCls & priorThis, 620 wxPGProperty * newProperty /Transfer/ 621 ); 622 %Docstring 623 Insert(priorThis, newProperty) -> PGProperty 624 Insert(parent, index, newProperty) -> PGProperty 625 626 Inserts property to the property container. 627 %End 628 629 wxPGProperty * Insert( 630 const wxPGPropArgCls & parent, 631 int index, 632 wxPGProperty * newProperty /Transfer/ 633 ); 634 635 bool IsPropertyCategory( 636 const wxPGPropArgCls & id 637 ) const; 638 %Docstring 639 IsPropertyCategory(id) -> bool 640 641 Returns true if property is a category. 642 %End 643 644 bool IsPropertyEnabled( 645 const wxPGPropArgCls & id 646 ) const; 647 %Docstring 648 IsPropertyEnabled(id) -> bool 649 650 Returns true if property is enabled. 651 %End 652 653 bool IsPropertyExpanded( 654 const wxPGPropArgCls & id 655 ) const; 656 %Docstring 657 IsPropertyExpanded(id) -> bool 658 659 Returns true if given property is expanded. 660 %End 661 662 bool IsPropertyModified( 663 const wxPGPropArgCls & id 664 ) const; 665 %Docstring 666 IsPropertyModified(id) -> bool 667 668 Returns true if property has been modified after value set or modify 669 flag clear by software. 670 %End 671 672 bool IsPropertySelected( 673 const wxPGPropArgCls & id 674 ) const; 675 %Docstring 676 IsPropertySelected(id) -> bool 677 678 Returns true if property is selected. 679 %End 680 681 bool IsPropertyShown( 682 const wxPGPropArgCls & id 683 ) const; 684 %Docstring 685 IsPropertyShown(id) -> bool 686 687 Returns true if property is shown (ie. 688 %End 689 690 bool IsPropertyValueUnspecified( 691 const wxPGPropArgCls & id 692 ) const; 693 %Docstring 694 IsPropertyValueUnspecified(id) -> bool 695 696 Returns true if property value is set to unspecified. 697 %End 698 699 void LimitPropertyEditing( 700 const wxPGPropArgCls & id, 701 bool limit = true 702 ); 703 %Docstring 704 LimitPropertyEditing(id, limit=True) 705 706 Disables (limit = true) or enables (limit = false) wxTextCtrl editor 707 of a property, if it is not the sole mean to edit the value. 708 %End 709 710 wxPGProperty * RemoveProperty( 711 const wxPGPropArgCls & id 712 ); 713 %Docstring 714 RemoveProperty(id) -> PGProperty 715 716 Removes a property. 717 %End 718 719 wxPGProperty * ReplaceProperty( 720 const wxPGPropArgCls & id, 721 wxPGProperty * property 722 ); 723 %Docstring 724 ReplaceProperty(id, property) -> PGProperty 725 726 Replaces property with id with newly created one. 727 %End 728 729 bool RestoreEditableState( 730 const wxString & src, 731 int restoreStates = AllStates 732 ); 733 %Docstring 734 RestoreEditableState(src, restoreStates=AllStates) -> bool 735 736 Restores user-editable state. 737 %End 738 739 wxString SaveEditableState( 740 int includedStates = AllStates 741 ) const; 742 %Docstring 743 SaveEditableState(includedStates=AllStates) -> String 744 745 Used to acquire user-editable state (selected property, expanded 746 properties, scrolled position, splitter positions). 747 %End 748 749 bool SetColumnProportion( 750 unsigned int column, 751 int proportion 752 ); 753 %Docstring 754 SetColumnProportion(column, proportion) -> bool 755 756 Set proportion of a auto-stretchable column. 757 %End 758 759 void SetPropertyAttribute( 760 const wxPGPropArgCls & id, 761 const wxString & attrName, 762 wxPGVariant value, 763 long argFlags = 0 764 ); 765 %Docstring 766 SetPropertyAttribute(id, attrName, value, argFlags=0) 767 768 Sets an attribute for this property. 769 %End 770 771 void SetPropertyAttributeAll( 772 const wxString & attrName, 773 wxPGVariant value 774 ); 775 %Docstring 776 SetPropertyAttributeAll(attrName, value) 777 778 Sets property attribute for all applicapple properties. 779 %End 780 781 void SetPropertyBackgroundColour( 782 const wxPGPropArgCls & id, 783 const wxColour & colour, 784 int flags = wxPG_RECURSE 785 ); 786 %Docstring 787 SetPropertyBackgroundColour(id, colour, flags=PG_RECURSE) 788 789 Sets background colour of a property. 790 %End 791 792 void SetPropertyCell( 793 const wxPGPropArgCls & id, 794 int column, 795 const wxString & text = wxEmptyString, 796 const wxBitmap & bitmap = wxNullBitmap, 797 const wxColour & fgCol = wxNullColour, 798 const wxColour & bgCol = wxNullColour 799 ); 800 %Docstring 801 SetPropertyCell(id, column, text=wx.EmptyString, bitmap=wx.NullBitmap, fgCol=wx.NullColour, bgCol=wx.NullColour) 802 803 Sets text, bitmap, and colours for given column's cell. 804 %End 805 806 void SetPropertyColoursToDefault( 807 const wxPGPropArgCls & id 808 ); 809 %Docstring 810 SetPropertyColoursToDefault(id) 811 812 Resets text and background colours of given property. 813 %End 814 815 void SetPropertyEditor( 816 const wxPGPropArgCls & id, 817 const wxPGEditor * editor 818 ); 819 %Docstring 820 SetPropertyEditor(id, editor) 821 SetPropertyEditor(id, editorName) 822 823 Sets editor for a property. 824 %End 825 826 void SetPropertyEditor( 827 const wxPGPropArgCls & id, 828 const wxString & editorName 829 ); 830 831 void SetPropertyLabel( 832 const wxPGPropArgCls & id, 833 const wxString & newproplabel 834 ); 835 %Docstring 836 SetPropertyLabel(id, newproplabel) 837 838 Sets label of a property. 839 %End 840 841 void SetPropertyName( 842 const wxPGPropArgCls & id, 843 const wxString & newName 844 ); 845 %Docstring 846 SetPropertyName(id, newName) 847 848 Sets name of a property. 849 %End 850 851 void SetPropertyReadOnly( 852 const wxPGPropArgCls & id, 853 bool set = true, 854 int flags = wxPG_RECURSE 855 ); 856 %Docstring 857 SetPropertyReadOnly(id, set=True, flags=PG_RECURSE) 858 859 Sets property (and, recursively, its children) to have read-only 860 value. 861 %End 862 863 void SetPropertyValueUnspecified( 864 const wxPGPropArgCls & id 865 ); 866 %Docstring 867 SetPropertyValueUnspecified(id) 868 869 Sets property's value to unspecified. 870 %End 871 872 void SetPropertyHelpString( 873 const wxPGPropArgCls & id, 874 const wxString & helpString 875 ); 876 %Docstring 877 SetPropertyHelpString(id, helpString) 878 879 Associates the help string with property. 880 %End 881 882 void SetPropertyImage( 883 const wxPGPropArgCls & id, 884 wxBitmap & bmp 885 ); 886 %Docstring 887 SetPropertyImage(id, bmp) 888 889 Set wxBitmap in front of the value. 890 %End 891 892 bool SetPropertyMaxLength( 893 const wxPGPropArgCls & id, 894 int maxLen 895 ); 896 %Docstring 897 SetPropertyMaxLength(id, maxLen) -> bool 898 899 Sets max length of property's text. 900 %End 901 902 void SetPropertyTextColour( 903 const wxPGPropArgCls & id, 904 const wxColour & colour, 905 int flags = wxPG_RECURSE 906 ); 907 %Docstring 908 SetPropertyTextColour(id, colour, flags=PG_RECURSE) 909 910 Sets text colour of a property. 911 %End 912 913 void SetPropertyValidator( 914 const wxPGPropArgCls & id, 915 const wxValidator & validator 916 ); 917 %Docstring 918 SetPropertyValidator(id, validator) 919 920 Sets validator of a property. 921 %End 922 923 void SetPropertyValue( 924 const wxPGPropArgCls & id, 925 double value /Constrained/ 926 ); 927 %Docstring 928 SetPropertyValue(id, value) 929 SetPropertyValue(id, value) 930 SetPropertyValue(id, value) 931 SetPropertyValue(id, value) 932 SetPropertyValue(id, value) 933 SetPropertyValue(id, value) 934 SetPropertyValue(id, value) 935 SetPropertyValue(id, value) 936 SetPropertyValue(id, value) 937 938 Sets value (floating point) of a property. 939 %End 940 941 void SetPropertyValue( 942 const wxPGPropArgCls & id, 943 bool value /Constrained/ 944 ); 945 946 void SetPropertyValue( 947 const wxPGPropArgCls & id, 948 const wxString & value 949 ); 950 951 void SetPropertyValue( 952 const wxPGPropArgCls & id, 953 const wxArrayString & value 954 ); 955 956 void SetPropertyValue( 957 const wxPGPropArgCls & id, 958 const wxDateTime & value 959 ); 960 961 void SetPropertyValue( 962 const wxPGPropArgCls & id, 963 wxObject & value 964 ); 965 966 void SetPropertyValue( 967 const wxPGPropArgCls & id, 968 const wxArrayInt & value 969 ); 970 971 void SetPropertyValue( 972 const wxPGPropArgCls & id, 973 wxPGVariant value 974 ); 975 976 void SetPropertyValue( 977 const wxPGPropArgCls & id, 978 long value 979 ); 980 981 void SetPropertyValueString( 982 const wxPGPropArgCls & id, 983 const wxString & value 984 ); 985 %Docstring 986 SetPropertyValueString(id, value) 987 988 Sets value (wxString) of a property. 989 %End 990 991 void SetValidationFailureBehavior( 992 int vfbFlags 993 ); 994 %Docstring 995 SetValidationFailureBehavior(vfbFlags) 996 997 Adjusts how wxPropertyGrid behaves when invalid value is entered in a 998 property. 999 %End 1000 1001 void Sort( 1002 int flags = 0 1003 ); 1004 %Docstring 1005 Sort(flags=0) 1006 1007 Sorts all properties recursively. 1008 %End 1009 1010 void SortChildren( 1011 const wxPGPropArgCls & id, 1012 int flags = 0 1013 ); 1014 %Docstring 1015 SortChildren(id, flags=0) 1016 1017 Sorts children of a property. 1018 %End 1019 1020 static 1021 void InitAllTypeHandlers(); 1022 %Docstring 1023 InitAllTypeHandlers() 1024 1025 Initializes all property types. 1026 %End 1027 1028 static 1029 void RegisterAdditionalEditors(); 1030 %Docstring 1031 RegisterAdditionalEditors() 1032 1033 Initializes additional property editors (SpinCtrl etc.). 1034 %End 1035 1036 static 1037 void SetBoolChoices( 1038 const wxString & trueChoice, 1039 const wxString & falseChoice 1040 ); 1041 %Docstring 1042 SetBoolChoices(trueChoice, falseChoice) 1043 1044 Sets strings listed in the choice dropdown of a wxBoolProperty. 1045 %End 1046 1047 static 1048 wxPGEditor * GetEditorByName( 1049 const wxString & editorName 1050 ); 1051 %Docstring 1052 GetEditorByName(editorName) -> PGEditor 1053 1054 Returns editor pointer of editor with given name;. 1055 %End 1056 1057}; // end of class wxPropertyGridInterface 1058 1059 1060%Extract(id=pycode_propgrid) 1061def _PropertyGridInterface_MapType(self, class_, factory): 1062 """ 1063 Registers Python type/class to property mapping. 1064 1065 :param `factory`: Property builder function/class. 1066 """ 1067 global _type2property 1068 if _type2property is None: 1069 raise AssertionError("call only after a propertygrid or " 1070 "manager instance constructed") 1071 _type2property[class_] = factory 1072PropertyGridInterface.MapType = _PropertyGridInterface_MapType 1073del _PropertyGridInterface_MapType 1074%End 1075 1076%Extract(id=pycode_propgrid) 1077def _PropertyGridInterface_DoDefaultTypeMappings(self): 1078 """ 1079 Add built-in properties to the map. 1080 """ 1081 import sys 1082 global _type2property 1083 if _type2property is not None: 1084 return 1085 _type2property = dict() 1086 1087 _type2property[str] = StringProperty 1088 if sys.version_info.major < 2: 1089 _type2property[unicode] = StringProperty 1090 _type2property[int] = IntProperty 1091 _type2property[float] = FloatProperty 1092 _type2property[bool] = BoolProperty 1093 _type2property[list] = ArrayStringProperty 1094 _type2property[tuple] = ArrayStringProperty 1095 _type2property[wx.Font] = FontProperty 1096 _type2property[wx.Colour] = ColourProperty 1097 #_type2property[wx.Size] = SizeProperty 1098 #_type2property[wx.Point] = PointProperty 1099 #_type2property[wx.FontData] = FontDataProperty 1100PropertyGridInterface.DoDefaultTypeMappings = _PropertyGridInterface_DoDefaultTypeMappings 1101del _PropertyGridInterface_DoDefaultTypeMappings 1102%End 1103 1104%Extract(id=pycode_propgrid) 1105def _PropertyGridInterface_DoDefaultValueTypeMappings(self): 1106 """ 1107 Map pg value type ids to getter methods. 1108 """ 1109 global _vt2getter 1110 if _vt2getter is not None: 1111 return 1112 _vt2getter = dict() 1113PropertyGridInterface.DoDefaultValueTypeMappings = _PropertyGridInterface_DoDefaultValueTypeMappings 1114del _PropertyGridInterface_DoDefaultValueTypeMappings 1115%End 1116 1117%Extract(id=pycode_propgrid) 1118def _PropertyGridInterface_GetPropertyValues(self, dict_=None, as_strings=False, inc_attributes=False): 1119 """ 1120 Returns all property values in the grid. 1121 1122 :param `dict_`: A to fill with the property values. If not given, 1123 then a new one is created. The dict_ can be an object as well, 1124 in which case it's __dict__ is used. 1125 :param `as_strings`: if True, then string representations of values 1126 are fetched instead of native types. Useful for config and such. 1127 :param `inc_attributes`: if True, then property attributes are added 1128 in the form of "@<propname>@<attr>". 1129 :returns: A dictionary with values. It is always a dictionary, 1130 so if dict_ was and object with __dict__ attribute, then that 1131 attribute is returned. 1132 """ 1133 if dict_ is None: 1134 dict_ = {} 1135 elif hasattr(dict_,'__dict__'): 1136 dict_ = dict_.__dict__ 1137 1138 getter = self.GetPropertyValue if not as_strings else self.GetPropertyValueAsString 1139 1140 it = self.GetVIterator(PG_ITERATE_PROPERTIES) 1141 while not it.AtEnd(): 1142 p = it.GetProperty() 1143 name = p.GetName() 1144 dict_[name] = getter(p) 1145 1146 if inc_attributes: 1147 attrs = p.GetAttributes() 1148 if attrs and len(attrs): 1149 dict_['@%s@attr'%name] = attrs 1150 1151 it.Next() 1152 1153 return dict_ 1154PropertyGridInterface.GetPropertyValues = _PropertyGridInterface_GetPropertyValues 1155del _PropertyGridInterface_GetPropertyValues 1156%End 1157 1158%Extract(id=pycode_propgrid) 1159def _PropertyGridInterface_SetPropertyValues(self, dict_, autofill=False): 1160 """ 1161 Sets property values from a dictionary. 1162 1163 :param `dict_`: the source of the property values to set, which can be 1164 either a dictionary or an object with a __dict__ attribute. 1165 :param `autofill`: If true, keys with not relevant properties are 1166 auto-created. For more info, see :method:`AutoFill`. 1167 1168 :note: 1169 * Keys starting with underscore are ignored. 1170 * Attributes can be set with entries named like "@<propname>@<attr>". 1171 """ 1172 if dict_ is None: 1173 dict_ = {} 1174 elif hasattr(dict_,'__dict__'): 1175 dict_ = dict_.__dict__ 1176 attr_dicts = [] 1177 1178 def set_sub_obj(k0, dict_): 1179 for k,v in dict_.items(): 1180 if k[0] != '_': 1181 if k.endswith('@attr'): 1182 attr_dicts.append((k[1:-5],v)) 1183 else: 1184 try: 1185 self.SetPropertyValue(k,v) 1186 except: 1187 try: 1188 if autofill: 1189 self._AutoFillOne(k0,k,v) 1190 continue 1191 except: 1192 if isinstance(v,dict): 1193 set_sub_obj(k,v) 1194 elif hasattr(v,'__dict__'): 1195 set_sub_obj(k,v.__dict__) 1196 1197 for k,v in attr_dicts: 1198 p = self.GetPropertyByName(k) 1199 if not p: 1200 raise AssertionError("No such property: '%s'"%k) 1201 for an,av in v.items(): 1202 p.SetAttribute(an, av) 1203 1204 1205 cur_page = False 1206 is_manager = isinstance(self, PropertyGridManager) 1207 1208 try: 1209 set_sub_obj(self.GetGrid().GetRoot(), dict_) 1210 except: 1211 import traceback 1212 traceback.print_exc() 1213 1214 self.Refresh() 1215PropertyGridInterface.SetPropertyValues = _PropertyGridInterface_SetPropertyValues 1216del _PropertyGridInterface_SetPropertyValues 1217%End 1218 1219%Extract(id=pycode_propgrid) 1220def _PropertyGridInterface__AutoFillMany(self,cat,dict_): 1221 for k,v in dict_.items(): 1222 self._AutoFillOne(cat,k,v) 1223PropertyGridInterface._AutoFillMany = _PropertyGridInterface__AutoFillMany 1224del _PropertyGridInterface__AutoFillMany 1225%End 1226 1227%Extract(id=pycode_propgrid) 1228def _PropertyGridInterface__AutoFillOne(self,cat,k,v): 1229 global _type2property 1230 factory = _type2property.get(v.__class__,None) 1231 if factory: 1232 self.AppendIn(cat, factory(k,k,v)) 1233 elif hasattr(v,'__dict__'): 1234 cat2 = self.AppendIn(cat, PropertyCategory(k)) 1235 self._AutoFillMany(cat2, v.__dict__) 1236 elif isinstance(v, dict): 1237 cat2 = self.AppendIn(cat, PropertyCategory(k)) 1238 self._AutoFillMany(cat2, v) 1239 elif not k.startswith('_'): 1240 raise AssertionError("member '%s' is of unregistered type/" 1241 "class '%s'"%(k,v.__class__)) 1242PropertyGridInterface._AutoFillOne = _PropertyGridInterface__AutoFillOne 1243del _PropertyGridInterface__AutoFillOne 1244%End 1245 1246%Extract(id=pycode_propgrid) 1247def _PropertyGridInterface_AutoFill(self, obj, parent=None): 1248 """ 1249 "Clears properties and re-fills to match members and values of 1250 the given object or dictionary obj. 1251 """ 1252 self.edited_objects[parent] = obj 1253 1254 cur_page = False 1255 is_manager = isinstance(self, PropertyGridManager) 1256 1257 if not parent: 1258 if is_manager: 1259 page = self.GetCurrentPage() 1260 page.Clear() 1261 parent = page.GetRoot() 1262 else: 1263 self.Clear() 1264 parent = self.GetGrid().GetRoot() 1265 else: 1266 it = self.GetIterator(PG_ITERATE_PROPERTIES, parent) 1267 it.Next() # Skip the parent 1268 while not it.AtEnd(): 1269 p = it.GetProperty() 1270 if not p.IsSomeParent(parent): 1271 break 1272 1273 self.DeleteProperty(p) 1274 1275 name = p.GetName() 1276 it.Next() 1277 1278 if not is_manager or page == self.GetCurrentPage(): 1279 self.Freeze() 1280 cur_page = True 1281 1282 try: 1283 self._AutoFillMany(parent,obj.__dict__) 1284 except: 1285 import traceback 1286 traceback.print_exc() 1287 1288 if cur_page: 1289 self.Thaw() 1290PropertyGridInterface.AutoFill = _PropertyGridInterface_AutoFill 1291del _PropertyGridInterface_AutoFill 1292%End 1293 1294%Extract(id=pycode_propgrid) 1295def _PropertyGridInterface_RegisterEditor(self, editor, editorName=None): 1296 """ 1297 Register a new editor, either an instance or a class. 1298 """ 1299 if not isinstance(editor, PGEditor): 1300 editor = editor() 1301 if not editorName: 1302 editorName = editor.__class__.__name__ 1303 try: 1304 self._editor_instances.append(editor) 1305 except: 1306 self._editor_instances = [editor] 1307 return PropertyGrid.DoRegisterEditorClass(editor, editorName) 1308PropertyGridInterface.RegisterEditor = _PropertyGridInterface_RegisterEditor 1309del _PropertyGridInterface_RegisterEditor 1310%End 1311 1312%Extract(id=pycode_propgrid) 1313def _PropertyGridInterface_GetPropertyClientData(self, p): 1314 if isinstance(p, str): 1315 p = self.GetPropertyByName(p) 1316 return p.GetClientData() 1317PropertyGridInterface.GetPropertyClientData = _PropertyGridInterface_GetPropertyClientData 1318del _PropertyGridInterface_GetPropertyClientData 1319%End 1320 1321%Extract(id=pycode_propgrid) 1322def _PropertyGridInterface_SetPropertyClientData(self, p, data): 1323 if isinstance(p, str): 1324 p = self.GetPropertyByName(p) 1325 return p.SetClientData(data) 1326PropertyGridInterface.SetPropertyClientData = _PropertyGridInterface_SetPropertyClientData 1327del _PropertyGridInterface_SetPropertyClientData 1328%End 1329 1330%Extract(id=pycode_propgrid) 1331def _PropertyGridInterface_GetPyIterator(self, flags=PG_ITERATE_DEFAULT, firstProperty=None): 1332 """ 1333 Returns a pythonic property iterator for a single :ref:`PropertyGrid` 1334 or page in :ref:`PropertyGridManager`. Arguments are same as for 1335 :ref:`GetIterator`. 1336 1337 The following example demonstrates iterating absolutely all items in 1338 a single grid:: 1339 1340 iterator = propGrid.GetPyIterator(wx.propgrid.PG_ITERATE_ALL) 1341 for prop in iterator: 1342 print(prop) 1343 1344 :see: `wx.propgrid.PropertyGridInterface.Properties` 1345 `wx.propgrid.PropertyGridInterface.Items` 1346 """ 1347 it = self.GetIterator(flags, firstProperty) 1348 while not it.AtEnd(): 1349 yield it.GetProperty() 1350 it.Next() 1351PropertyGridInterface.GetPyIterator = _PropertyGridInterface_GetPyIterator 1352del _PropertyGridInterface_GetPyIterator 1353%End 1354 1355%Extract(id=pycode_propgrid) 1356def _PropertyGridInterface_GetPyVIterator(self, flags=PG_ITERATE_DEFAULT): 1357 """ 1358 Similar to :ref:`GetVIterator` but returns a pythonic iterator. 1359 """ 1360 it = self.GetVIterator(flags) 1361 while not it.AtEnd(): 1362 yield it.GetProperty() 1363 it.Next() 1364PropertyGridInterface.GetPyVIterator = _PropertyGridInterface_GetPyVIterator 1365del _PropertyGridInterface_GetPyVIterator 1366%End 1367 1368%Extract(id=pycode_propgrid) 1369def _PropertyGridInterface__Properties(self): 1370 """ 1371 This attribute is a pythonic iterator over all properties in 1372 this `PropertyGrid` property container. It will only skip 1373 categories and private child properties. Usage is simple:: 1374 1375 for prop in propGrid.Properties: 1376 print(prop) 1377 1378 :see: `wx.propgrid.PropertyGridInterface.Items` 1379 `wx.propgrid.PropertyGridInterface.GetPyIterator` 1380 """ 1381 it = self.GetIterator(PG_ITERATE_NORMAL) 1382 while not it.AtEnd(): 1383 yield it.GetProperty() 1384 it.Next() 1385PropertyGridInterface._Properties = _PropertyGridInterface__Properties 1386del _PropertyGridInterface__Properties 1387%End 1388 1389%Extract(id=pycode_propgrid) 1390PropertyGridInterface.Properties = property(PropertyGridInterface._Properties) 1391%End 1392 1393%Extract(id=pycode_propgrid) 1394def _PropertyGridInterface__Items(self): 1395 """ 1396 This attribute is a pythonic iterator over all items in this 1397 `PropertyGrid` property container, excluding only private child 1398 properties. Usage is simple:: 1399 1400 for prop in propGrid.Items: 1401 print(prop) 1402 1403 :see: `wx.propgrid.PropertyGridInterface.Properties` 1404 `wx.propgrid.PropertyGridInterface.GetPyVIterator` 1405 """ 1406 it = self.GetVIterator(PG_ITERATE_NORMAL | PG_ITERATE_CATEGORIES) 1407 while not it.AtEnd(): 1408 yield it.GetProperty() 1409 it.Next() 1410PropertyGridInterface._Items = _PropertyGridInterface__Items 1411del _PropertyGridInterface__Items 1412%End 1413 1414%Extract(id=pycode_propgrid) 1415PropertyGridInterface.Items = property(PropertyGridInterface._Items) 1416%End 1417 1418%Extract(id=pycode_propgrid) 1419_type2property = None 1420_vt2getter = None 1421 1422%End 1423 1424%Extract(id=pycode_propgrid) 1425PropertyGridInterface.GetValues = PropertyGridInterface.GetPropertyValues 1426PropertyGridInterface.SetValues = PropertyGridInterface.SetPropertyValues 1427 1428%End 1429 1430class wxArrayPGProperty 1431{ 1432public: 1433 SIP_SSIZE_T __len__(); 1434 %MethodCode 1435 sipRes = sipCpp->GetCount(); 1436 %End 1437 1438 wxPGProperty* __getitem__(long index); 1439 %MethodCode 1440 if (0 > index) 1441 index += sipCpp->GetCount(); 1442 1443 if ((index < sipCpp->GetCount()) && (0 <= index)) { 1444 sipRes = sipCpp->Item(index); 1445 } 1446 else { 1447 wxPyErr_SetString(PyExc_IndexError, "sequence index out of range"); 1448 sipError = sipErrorFail; 1449 } 1450 %End 1451 1452 int __contains__(wxPGProperty* obj); 1453 %MethodCode 1454 int idx = sipCpp->Index(obj, false); 1455 sipRes = idx != wxNOT_FOUND; 1456 %End 1457 1458 void append(wxPGProperty* obj); 1459 %MethodCode 1460 sipCpp->Add(obj); 1461 %End 1462 1463 // TODO: add support for index(value, [start, [stop]]) 1464 int index(wxPGProperty* obj); 1465 %MethodCode 1466 int idx = sipCpp->Index(obj, false); 1467 if (idx == wxNOT_FOUND) { 1468 sipError = sipErrorFail; 1469 wxPyErr_SetString(PyExc_ValueError, 1470 "sequence.index(x): x not in sequence"); 1471 } 1472 sipRes = idx; 1473 %End 1474}; 1475 1476%Extract(id=pycode_propgrid) 1477def _ArrayPGProperty___repr__(self): 1478 return "ArrayPGProperty: " + repr(list(self)) 1479ArrayPGProperty.__repr__ = _ArrayPGProperty___repr__ 1480del _ArrayPGProperty___repr__ 1481%End 1482 1483 1484 1485//--------------------------------------------------------------------------- 1486 1487