propgridiface.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: property.h
  3. // Purpose: interface of wxPGProperty
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. // -----------------------------------------------------------------------
  8. /**
  9. @class wxPropertyGridInterface
  10. Most of the shared property manipulation interface shared by wxPropertyGrid,
  11. wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
  12. @remarks
  13. - In separate wxPropertyGrid component this class was known as
  14. wxPropertyContainerMethods.
  15. - wxPropertyGridInterface's property operation member functions all accept
  16. a special wxPGPropArg id argument, using which you can refer to properties
  17. either by their pointer (for performance) or by their name (for conveniency).
  18. @library{wxpropgrid}
  19. @category{propgrid}
  20. */
  21. class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
  22. {
  23. public:
  24. /** Destructor */
  25. virtual ~wxPropertyGridInterface() { }
  26. /**
  27. Appends property to the list. wxPropertyGrid assumes ownership of the
  28. object. Becomes child of most recently added category.
  29. @remarks
  30. - wxPropertyGrid takes the ownership of the property pointer.
  31. - If appending a category with name identical to a category already in
  32. the wxPropertyGrid, then newly created category is deleted, and most
  33. recently added category (under which properties are appended) is set
  34. to the one with same name. This allows easier adding of items to same
  35. categories in multiple passes.
  36. - Does not automatically redraw the control, so you may need to call
  37. Refresh() when calling this function after control has been shown for
  38. the first time.
  39. - This functions deselects selected property, if any. Validation
  40. failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
  41. selection is cleared even if editor had invalid value.
  42. */
  43. wxPGProperty* Append( wxPGProperty* property );
  44. /**
  45. Same as Append(), but appends under given parent property.
  46. @param id
  47. Name or pointer to parent property.
  48. @param newProperty
  49. Property to be added.
  50. */
  51. wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newProperty );
  52. /**
  53. In order to add new items into a property with private children (for
  54. instance, wxFlagsProperty), you need to call this method.
  55. After populating has been finished, you need to call EndAddChildren().
  56. @see EndAddChildren()
  57. */
  58. void BeginAddChildren( wxPGPropArg id );
  59. /**
  60. Deletes all properties.
  61. @remarks This functions deselects selected property, if any. Validation
  62. failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
  63. selection is cleared even if editor had invalid value.
  64. */
  65. virtual void Clear() = 0;
  66. /**
  67. Clears current selection, if any.
  68. @param validation
  69. If set to @false, deselecting the property will always work,
  70. even if its editor had invalid value in it.
  71. @return Returns @true if successful or if there was no selection. May
  72. fail if validation was enabled and active editor had invalid
  73. value.
  74. @remarks In wxPropertyGrid 1.4, this member function used to send
  75. wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
  76. does that.
  77. @see wxPropertyGrid::SelectProperty()
  78. */
  79. bool ClearSelection( bool validation = false);
  80. /**
  81. Resets modified status of all properties.
  82. */
  83. void ClearModifiedStatus();
  84. /**
  85. Collapses given category or property with children.
  86. @return Returns @true if actually collapsed.
  87. @remarks This function may deselect selected property, if any. Validation
  88. failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
  89. selection is cleared even if editor had invalid value.
  90. */
  91. bool Collapse( wxPGPropArg id );
  92. /**
  93. Collapses all items that can be collapsed.
  94. @remarks This functions clears selection. Validation failure option
  95. wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection
  96. is cleared even if editor had invalid value.
  97. */
  98. bool CollapseAll();
  99. /**
  100. Changes value of a property, as if by user. Use this instead of
  101. SetPropertyValue() if you need the value to run through validation
  102. process, and also send the property change event.
  103. @return Returns @true if value was successfully changed.
  104. */
  105. bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
  106. /**
  107. Removes and deletes a property and any children.
  108. @param id
  109. Pointer or name of a property.
  110. @remarks If you delete a property in a wxPropertyGrid event
  111. handler, the actual deletion is postponed until the next
  112. idle event.
  113. This functions deselects selected property, if any.
  114. Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
  115. respected, ie. selection is cleared even if editor had
  116. invalid value.
  117. */
  118. void DeleteProperty( wxPGPropArg id );
  119. /**
  120. Disables a property.
  121. @see EnableProperty(), wxPGProperty::Enable()
  122. */
  123. bool DisableProperty( wxPGPropArg id );
  124. /**
  125. Returns @true if all property grid data changes have been committed. Usually
  126. only returns @false if value in active editor has been invalidated by a
  127. wxValidator.
  128. */
  129. bool EditorValidate();
  130. /**
  131. Enables or disables property. Disabled property usually appears as
  132. having grey text.
  133. @param id
  134. Name or pointer to a property.
  135. @param enable
  136. If @false, property is disabled instead.
  137. @see wxPGProperty::Enable()
  138. */
  139. bool EnableProperty( wxPGPropArg id, bool enable = true );
  140. /**
  141. Called after population of property with fixed children has finished.
  142. @see BeginAddChildren()
  143. */
  144. void EndAddChildren( wxPGPropArg id );
  145. /**
  146. Expands given category or property with children.
  147. @return Returns @true if actually expanded.
  148. @remarks This function may deselect selected property, if any. Validation
  149. failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
  150. selection is cleared even if editor had invalid value.
  151. */
  152. bool Expand( wxPGPropArg id );
  153. /**
  154. Expands all items that can be expanded.
  155. @remarks This functions clears selection. Validation failure option
  156. wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection
  157. is cleared even if editor had invalid value.
  158. */
  159. bool ExpandAll( bool expand = true );
  160. /**
  161. Returns auto-resize proportion of the given column.
  162. @see SetColumnProportion()
  163. */
  164. int GetColumnProportion( unsigned int column ) const;
  165. /**
  166. Returns id of first child of given property.
  167. @remarks Does not return private children!
  168. */
  169. wxPGProperty* GetFirstChild( wxPGPropArg id );
  170. //@{
  171. /**
  172. Returns iterator class instance.
  173. @param flags
  174. See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
  175. iteration over everything except private child properties.
  176. @param firstProp
  177. Property to start iteration from. If @NULL, then first child of root
  178. is used.
  179. */
  180. wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT,
  181. wxPGProperty* firstProp = NULL );
  182. wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT,
  183. wxPGProperty* firstProp = NULL ) const;
  184. //@}
  185. //@{
  186. /**
  187. Returns iterator class instance.
  188. @param flags
  189. See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
  190. iteration over everything except private child properties.
  191. @param startPos
  192. Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start
  193. from the first property from the top, and wxBOTTOM means that the
  194. iteration will instead begin from bottommost valid item.
  195. */
  196. wxPropertyGridIterator GetIterator( int flags, int startPos );
  197. wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const;
  198. //@}
  199. /**
  200. Returns id of first item that matches given criteria.
  201. @param flags
  202. See @ref propgrid_iterator_flags.
  203. */
  204. wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL );
  205. /**
  206. Returns pointer to a property with given name (case-sensitive).
  207. If there is no property with such name, @NULL pointer is returned.
  208. @remarks Properties which have non-category, non-root parent
  209. cannot be accessed globally by their name. Instead, use
  210. "<property>.<subproperty>" instead of "<subproperty>".
  211. */
  212. wxPGProperty* GetProperty( const wxString& name ) const;
  213. /**
  214. Adds to 'targetArr' pointers to properties that have given flags 'flags' set.
  215. However, if @a 'inverse' is set to @true, then only properties without
  216. given flags are stored.
  217. @param targetArr
  218. @todo docme
  219. @param flags
  220. Property flags to use.
  221. @param inverse
  222. @todo docme
  223. @param iterFlags
  224. Iterator flags to use. Default is everything expect private children.
  225. See @ref propgrid_iterator_flags.
  226. */
  227. void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
  228. wxPGProperty::FlagType flags,
  229. bool inverse = false,
  230. int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const;
  231. /**
  232. Returns value of given attribute. If none found, returns wxNullVariant.
  233. */
  234. wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const;
  235. /**
  236. Returns background colour of first cell of a property.
  237. */
  238. wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const;
  239. /**
  240. Returns pointer of property's nearest parent category. If no category
  241. found, returns @NULL.
  242. */
  243. wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const;
  244. /** Returns client data (void*) of a property. */
  245. void* GetPropertyClientData( wxPGPropArg id ) const;
  246. /**
  247. Returns first property which label matches given string. @NULL if none
  248. found. Note that this operation is very slow when compared to
  249. GetPropertyByName().
  250. */
  251. wxPGProperty* GetPropertyByLabel( const wxString& label ) const;
  252. /**
  253. Returns pointer to a property with given name (case-sensitive).
  254. If there is no property with such name, @NULL pointer is returned.
  255. @remarks Properties which have non-category, non-root parent
  256. cannot be accessed globally by their name. Instead, use
  257. "<property>.<subproperty>" instead of "<subproperty>".
  258. */
  259. wxPGProperty* GetPropertyByName( const wxString& name ) const;
  260. /**
  261. Returns child property 'subname' of property 'name'. Same as
  262. calling GetPropertyByName("name.subname"), albeit slightly faster.
  263. */
  264. wxPGProperty* GetPropertyByName( const wxString& name,
  265. const wxString& subname ) const;
  266. /**
  267. Returns property's editor.
  268. */
  269. const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const;
  270. /**
  271. Returns help string associated with a property.
  272. */
  273. wxString GetPropertyHelpString( wxPGPropArg id ) const;
  274. /**
  275. Returns property's custom value image (@NULL of none).
  276. */
  277. wxBitmap* GetPropertyImage( wxPGPropArg id ) const;
  278. /** Returns label of a property. */
  279. const wxString& GetPropertyLabel( wxPGPropArg id );
  280. /** Returns property's name, by which it is globally accessible. */
  281. wxString GetPropertyName( wxPGProperty* property );
  282. /**
  283. Returns text colour of first cell of a property.
  284. */
  285. wxColour GetPropertyTextColour( wxPGPropArg id ) const;
  286. /**
  287. Returns validator of a property as a reference, which you
  288. can pass to any number of SetPropertyValidator.
  289. */
  290. wxValidator* GetPropertyValidator( wxPGPropArg id );
  291. /**
  292. Returns property's value as wxVariant.
  293. If property value is unspecified, Null variant is returned.
  294. */
  295. wxVariant GetPropertyValue( wxPGPropArg id );
  296. /** Return's property's value as wxArrayInt. */
  297. wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const;
  298. /** Returns property's value as wxArrayString. */
  299. wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const;
  300. /** Returns property's value as bool */
  301. bool GetPropertyValueAsBool( wxPGPropArg id ) const;
  302. /** Return's property's value as wxDateTime. */
  303. wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const;
  304. /** Returns property's value as double-precision floating point number. */
  305. double GetPropertyValueAsDouble( wxPGPropArg id ) const;
  306. /** Returns property's value as integer */
  307. int GetPropertyValueAsInt( wxPGPropArg id ) const;
  308. /** Returns property's value as integer */
  309. long GetPropertyValueAsLong( wxPGPropArg id ) const;
  310. /** Returns property's value as native signed 64-bit integer. */
  311. wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const;
  312. /**
  313. Returns property's value as wxString. If property does not
  314. use string value type, then its value is converted using
  315. wxPGProperty::GetValueAsString().
  316. */
  317. wxString GetPropertyValueAsString( wxPGPropArg id ) const;
  318. /** Returns property's value as unsigned integer */
  319. unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const;
  320. /** Returns property's value as native unsigned 64-bit integer. */
  321. wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const;
  322. /**
  323. Returns a wxVariant list containing wxVariant versions of all
  324. property values. Order is not guaranteed.
  325. @param listname
  326. @todo docme
  327. @param baseparent
  328. @todo docme
  329. @param flags
  330. Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
  331. category will be its own wxVariantList of wxVariant.
  332. Use wxPG_INC_ATTRIBUTES to include property attributes as well.
  333. Each attribute will be stored as list variant named
  334. "@@<propname>@@attr."
  335. */
  336. wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
  337. wxPGProperty* baseparent = NULL, long flags = 0 ) const;
  338. /**
  339. Returns list of currently selected properties.
  340. @remarks wxArrayPGProperty should be compatible with std::vector API.
  341. */
  342. const wxArrayPGProperty& GetSelectedProperties() const;
  343. /**
  344. Returns currently selected property. NULL if none.
  345. @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
  346. member function returns the focused property, that is the
  347. one which can have active editor.
  348. */
  349. wxPGProperty* GetSelection() const;
  350. /**
  351. Similar to GetIterator(), but instead returns wxPGVIterator instance,
  352. which can be useful for forward-iterating through arbitrary property
  353. containers.
  354. @param flags
  355. See @ref propgrid_iterator_flags.
  356. */
  357. virtual wxPGVIterator GetVIterator( int flags ) const;
  358. /**
  359. Hides or reveals a property.
  360. @param id
  361. @todo docme
  362. @param hide
  363. If @true, hides property, otherwise reveals it.
  364. @param flags
  365. By default changes are applied recursively. Set this parameter
  366. wxPG_DONT_RECURSE to prevent this.
  367. */
  368. bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE );
  369. /**
  370. Initializes *all* property types. Causes references to most object
  371. files in the library, so calling this may cause significant increase
  372. in executable size when linking with static library.
  373. */
  374. static void InitAllTypeHandlers();
  375. /**
  376. Inserts property to the property container.
  377. @param priorThis
  378. New property is inserted just prior to this. Available only
  379. in the first variant. There are two versions of this function
  380. to allow this parameter to be either an id or name to
  381. a property.
  382. @param newProperty
  383. Pointer to the inserted property. wxPropertyGrid will take
  384. ownership of this object.
  385. @return Returns newProperty.
  386. @remarks
  387. - wxPropertyGrid takes the ownership of the property pointer.
  388. - While Append may be faster way to add items, make note that when
  389. both types of data storage (categoric and
  390. non-categoric) are active, Insert becomes even more slow. This is
  391. especially true if current mode is non-categoric.
  392. - This functions deselects selected property, if any. Validation
  393. failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
  394. selection is cleared even if editor had invalid value.
  395. Example of use:
  396. @code
  397. // append category
  398. wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") );
  399. ...
  400. // insert into category - using second variant
  401. wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") );
  402. // insert before to first item - using first variant
  403. wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") );
  404. @endcode
  405. */
  406. wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newProperty );
  407. /**
  408. Inserts property to the property container.
  409. See the other overload for more details.
  410. @param parent
  411. New property is inserted under this category. Available only
  412. in the second variant. There are two versions of this function
  413. to allow this parameter to be either an id or name to
  414. a property.
  415. @param index
  416. Index under category. Available only in the second variant.
  417. If index is < 0, property is appended in category.
  418. @param newProperty
  419. Pointer to the inserted property. wxPropertyGrid will take
  420. ownership of this object.
  421. @return Returns newProperty.
  422. */
  423. wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newProperty );
  424. /** Returns @true if property is a category. */
  425. bool IsPropertyCategory( wxPGPropArg id ) const;
  426. /** Returns @true if property is enabled. */
  427. bool IsPropertyEnabled( wxPGPropArg id ) const;
  428. /**
  429. Returns @true if given property is expanded. Naturally, always returns
  430. @false for properties that cannot be expanded.
  431. */
  432. bool IsPropertyExpanded( wxPGPropArg id ) const;
  433. /**
  434. Returns @true if property has been modified after value set or modify
  435. flag clear by software.
  436. */
  437. bool IsPropertyModified( wxPGPropArg id ) const;
  438. /**
  439. Returns true if property is selected.
  440. */
  441. virtual bool IsPropertySelected( wxPGPropArg id ) const;
  442. /**
  443. Returns @true if property is shown (ie. HideProperty() with @true not
  444. called for it).
  445. */
  446. bool IsPropertyShown( wxPGPropArg id ) const;
  447. /**
  448. Returns @true if property value is set to unspecified.
  449. */
  450. bool IsPropertyValueUnspecified( wxPGPropArg id ) const;
  451. /**
  452. Disables (limit = @true) or enables (limit = @false) wxTextCtrl editor
  453. of a property, if it is not the sole mean to edit the value.
  454. */
  455. void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
  456. /**
  457. Initializes additional property editors (SpinCtrl etc.). Causes
  458. references to most object files in the library, so calling this may
  459. cause significant increase in executable size when linking with static
  460. library.
  461. */
  462. static void RegisterAdditionalEditors();
  463. /**
  464. Removes a property. Does not delete the property object, but
  465. instead returns it.
  466. @param id
  467. Pointer or name of a property.
  468. @remarks Removed property cannot have any children.
  469. Also, if you remove property in a wxPropertyGrid event
  470. handler, the actual removal is postponed until the next
  471. idle event.
  472. */
  473. wxPGProperty* RemoveProperty( wxPGPropArg id );
  474. /**
  475. Replaces property with id with newly created one. For example,
  476. this code replaces existing property named "Flags" with one that
  477. will have different set of items:
  478. @code
  479. pg->ReplaceProperty("Flags",
  480. wxFlagsProperty("Flags", wxPG_LABEL, newItems))
  481. @endcode
  482. @see Insert()
  483. */
  484. wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
  485. /**
  486. @anchor propgridinterface_editablestate_flags
  487. Flags for wxPropertyGridInterface::SaveEditableState() and
  488. wxPropertyGridInterface::RestoreEditableState().
  489. */
  490. enum EditableStateFlags
  491. {
  492. /** Include selected property. */
  493. SelectionState = 0x01,
  494. /** Include expanded/collapsed property information. */
  495. ExpandedState = 0x02,
  496. /** Include scrolled position. */
  497. ScrollPosState = 0x04,
  498. /** Include selected page information. Only applies to
  499. wxPropertyGridManager. */
  500. PageState = 0x08,
  501. /** Include splitter position. Stored for each page. */
  502. SplitterPosState = 0x10,
  503. /** Include description box size.
  504. Only applies to wxPropertyGridManager. */
  505. DescBoxState = 0x20,
  506. /**
  507. Include all supported user editable state information.
  508. This is usually the default value. */
  509. AllStates = SelectionState |
  510. ExpandedState |
  511. ScrollPosState |
  512. PageState |
  513. SplitterPosState |
  514. DescBoxState
  515. };
  516. /**
  517. Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState().
  518. @param src
  519. String generated by SaveEditableState.
  520. @param restoreStates
  521. Which parts to restore from source string. See @ref propgridinterface_editablestate_flags
  522. "list of editable state flags".
  523. @return Returns @false if there was problem reading the string.
  524. @remarks If some parts of state (such as scrolled or splitter position)
  525. fail to restore correctly, please make sure that you call this
  526. function after wxPropertyGrid size has been set (this may
  527. sometimes be tricky when sizers are used).
  528. */
  529. bool RestoreEditableState( const wxString& src,
  530. int restoreStates = AllStates );
  531. /**
  532. Used to acquire user-editable state (selected property, expanded
  533. properties, scrolled position, splitter positions).
  534. @param includedStates
  535. Which parts of state to include. See @ref propgridinterface_editablestate_flags
  536. "list of editable state flags".
  537. */
  538. wxString SaveEditableState( int includedStates = AllStates ) const;
  539. /**
  540. Sets strings listed in the choice dropdown of a wxBoolProperty.
  541. Defaults are "True" and "False", so changing them to, say, "Yes" and
  542. "No" may be useful in some less technical applications.
  543. */
  544. static void SetBoolChoices( const wxString& trueChoice,
  545. const wxString& falseChoice );
  546. /**
  547. Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER
  548. window style needs to be used to indicate that columns are auto-
  549. resizable.
  550. @returns Returns @false on failure.
  551. @remarks You should call this for individual pages of
  552. wxPropertyGridManager (if used).
  553. @see GetColumnProportion()
  554. */
  555. bool SetColumnProportion( unsigned int column, int proportion );
  556. /**
  557. Sets an attribute for this property.
  558. @param id
  559. @todo docme
  560. @param attrName
  561. Text identifier of attribute. See @ref propgrid_property_attributes.
  562. @param value
  563. Value of attribute.
  564. @param argFlags
  565. Optional.
  566. Use wxPG_RECURSE to set the attribute to child properties recursively.
  567. @remarks Setting attribute's value to Null variant will simply remove it
  568. from property's set of attributes.
  569. */
  570. void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName,
  571. wxVariant value, long argFlags = 0 );
  572. /**
  573. Sets property attribute for all applicapple properties.
  574. Be sure to use this method only after all properties have been
  575. added to the grid.
  576. */
  577. void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
  578. /**
  579. Sets background colour of a property.
  580. @param id
  581. Property name or pointer.
  582. @param colour
  583. New background colour.
  584. @param flags
  585. Default is wxPG_RECURSE which causes colour to be set recursively.
  586. Omit this flag to only set colour for the property in question
  587. and not any of its children.
  588. */
  589. void SetPropertyBackgroundColour( wxPGPropArg id,
  590. const wxColour& colour,
  591. int flags = wxPG_RECURSE );
  592. /**
  593. Sets text, bitmap, and colours for given column's cell.
  594. @remarks
  595. - You can set label cell by using column 0.
  596. - You can use wxPG_LABEL as text to use default text for column.
  597. */
  598. void SetPropertyCell( wxPGPropArg id,
  599. int column,
  600. const wxString& text = wxEmptyString,
  601. const wxBitmap& bitmap = wxNullBitmap,
  602. const wxColour& fgCol = wxNullColour,
  603. const wxColour& bgCol = wxNullColour );
  604. /**
  605. Sets client data (void*) of a property.
  606. @remarks
  607. This untyped client data has to be deleted manually.
  608. */
  609. void SetPropertyClientData( wxPGPropArg id, void* clientData );
  610. /**
  611. Resets text and background colours of given property.
  612. */
  613. void SetPropertyColoursToDefault( wxPGPropArg id );
  614. /**
  615. Sets editor for a property.
  616. @param id
  617. @todo docme
  618. @param editor
  619. For builtin editors, use wxPGEditor_X, where X is builtin editor's
  620. name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
  621. list).
  622. For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass().
  623. */
  624. void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor );
  625. /**
  626. Sets editor control of a property. As editor argument, use
  627. editor name string, such as "TextCtrl" or "Choice".
  628. */
  629. void SetPropertyEditor( wxPGPropArg id, const wxString& editorName );
  630. /**
  631. Sets label of a property.
  632. @remarks
  633. - Properties under same parent may have same labels. However,
  634. property names must still remain unique.
  635. */
  636. void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
  637. /**
  638. Sets name of a property.
  639. @param id
  640. Name or pointer of property which name to change.
  641. @param newName
  642. New name for property.
  643. */
  644. void SetPropertyName( wxPGPropArg id, const wxString& newName );
  645. /**
  646. Sets property (and, recursively, its children) to have read-only value.
  647. In other words, user cannot change the value in the editor, but they can
  648. still copy it.
  649. @param id
  650. Property name or pointer.
  651. @param set
  652. Use @true to enable read-only, @false to disable it.
  653. @param flags
  654. By default changes are applied recursively. Set this parameter
  655. wxPG_DONT_RECURSE to prevent this.
  656. @remarks This is mainly for use with textctrl editor. Only some other
  657. editors fully support it.
  658. */
  659. void SetPropertyReadOnly( wxPGPropArg id, bool set = true,
  660. int flags = wxPG_RECURSE );
  661. /**
  662. Sets property's value to unspecified. If it has children (it may be
  663. category), then the same thing is done to them.
  664. */
  665. void SetPropertyValueUnspecified( wxPGPropArg id );
  666. /**
  667. Sets property values from a list of wxVariants.
  668. */
  669. void SetPropertyValues( const wxVariantList& list,
  670. wxPGPropArg defaultCategory = wxNullProperty );
  671. /**
  672. Sets property values from a list of wxVariants.
  673. */
  674. void SetPropertyValues( const wxVariant& list,
  675. wxPGPropArg defaultCategory = wxNullProperty );
  676. /**
  677. Associates the help string with property.
  678. @remarks By default, text is shown either in the manager's "description"
  679. text box or in the status bar. If extra window style
  680. wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as
  681. a tooltip.
  682. */
  683. void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString );
  684. /**
  685. Set wxBitmap in front of the value.
  686. @remarks Bitmap will be scaled to a size returned by
  687. wxPropertyGrid::GetImageSize();
  688. */
  689. void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp );
  690. /**
  691. Sets max length of property's text.
  692. */
  693. bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
  694. /**
  695. Sets text colour of a property.
  696. @param id
  697. Property name or pointer.
  698. @param colour
  699. New background colour.
  700. @param flags
  701. Default is wxPG_RECURSE which causes colour to be set recursively.
  702. Omit this flag to only set colour for the property in question
  703. and not any of its children.
  704. */
  705. void SetPropertyTextColour( wxPGPropArg id,
  706. const wxColour& colour,
  707. int flags = wxPG_RECURSE );
  708. /**
  709. Sets validator of a property.
  710. */
  711. void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator );
  712. /** Sets value (integer) of a property. */
  713. void SetPropertyValue( wxPGPropArg id, long value );
  714. /** Sets value (integer) of a property. */
  715. void SetPropertyValue( wxPGPropArg id, int value );
  716. /** Sets value (floating point) of a property. */
  717. void SetPropertyValue( wxPGPropArg id, double value );
  718. /** Sets value (bool) of a property. */
  719. void SetPropertyValue( wxPGPropArg id, bool value );
  720. /** Sets value (string) of a property. */
  721. void SetPropertyValue( wxPGPropArg id, const wxString& value );
  722. /** Sets value (wxArrayString) of a property. */
  723. void SetPropertyValue( wxPGPropArg id, const wxArrayString& value );
  724. /** Sets value (wxDateTime) of a property. */
  725. void SetPropertyValue( wxPGPropArg id, const wxDateTime& value );
  726. /** Sets value (wxObject*) of a property. */
  727. void SetPropertyValue( wxPGPropArg id, wxObject* value );
  728. /** Sets value (wxObject&) of a property. */
  729. void SetPropertyValue( wxPGPropArg id, wxObject& value );
  730. /** Sets value (native 64-bit int) of a property. */
  731. void SetPropertyValue( wxPGPropArg id, wxLongLong_t value );
  732. /** Sets value (native 64-bit unsigned int) of a property. */
  733. void SetPropertyValue( wxPGPropArg id, wxULongLong_t value );
  734. /** Sets value (wxArrayInt&) of a property. */
  735. void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value );
  736. /**
  737. Sets value (wxString) of a property.
  738. @remarks This method uses wxPGProperty::SetValueFromString(), which all
  739. properties should implement. This means that there should not be
  740. a type error, and instead the string is converted to property's
  741. actual value type.
  742. */
  743. void SetPropertyValueString( wxPGPropArg id, const wxString& value );
  744. /**
  745. Sets value (wxVariant&) of a property.
  746. @remarks Use wxPropertyGrid::ChangePropertyValue() instead if you need to
  747. run through validation process and send property change event.
  748. */
  749. void SetPropertyValue( wxPGPropArg id, wxVariant value );
  750. /**
  751. Adjusts how wxPropertyGrid behaves when invalid value is entered
  752. in a property.
  753. @param vfbFlags
  754. See @ref propgrid_vfbflags for possible values.
  755. */
  756. void SetValidationFailureBehavior( int vfbFlags );
  757. /**
  758. Sorts all properties recursively.
  759. @param flags
  760. This can contain any of the following options:
  761. wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
  762. immediate children. Sorting done by wxPG_AUTO_SORT option
  763. uses this.
  764. @see SortChildren, wxPropertyGrid::SetSortFunction
  765. */
  766. void Sort( int flags = 0 );
  767. /**
  768. Sorts children of a property.
  769. @param id
  770. Name or pointer to a property.
  771. @param flags
  772. This can contain any of the following options:
  773. wxPG_RECURSE: Sorts recursively.
  774. @see Sort, wxPropertyGrid::SetSortFunction
  775. */
  776. void SortChildren( wxPGPropArg id, int flags = 0 );
  777. /**
  778. Returns editor pointer of editor with given name;
  779. */
  780. static wxPGEditor* GetEditorByName( const wxString& editorName );
  781. };