propgridiface.h 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/propgrid/propgridiface.h
  3. // Purpose: wxPropertyGridInterface class
  4. // Author: Jaakko Salli
  5. // Modified by:
  6. // Created: 2008-08-24
  7. // Copyright: (c) Jaakko Salli
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef __WX_PROPGRID_PROPGRIDIFACE_H__
  11. #define __WX_PROPGRID_PROPGRIDIFACE_H__
  12. #include "wx/defs.h"
  13. #if wxUSE_PROPGRID
  14. #include "wx/propgrid/property.h"
  15. #include "wx/propgrid/propgridpagestate.h"
  16. // -----------------------------------------------------------------------
  17. /** @section wxPGPropArgCls
  18. Most property grid functions have this type as their argument, as it can
  19. convey a property by either a pointer or name.
  20. */
  21. class WXDLLIMPEXP_PROPGRID wxPGPropArgCls
  22. {
  23. public:
  24. wxPGPropArgCls( const wxPGProperty* property )
  25. {
  26. m_ptr.property = (wxPGProperty*) property;
  27. m_flags = IsProperty;
  28. }
  29. wxPGPropArgCls( const wxString& str )
  30. {
  31. m_ptr.stringName = &str;
  32. m_flags = IsWxString;
  33. }
  34. wxPGPropArgCls( const wxPGPropArgCls& id )
  35. {
  36. m_ptr = id.m_ptr;
  37. m_flags = id.m_flags;
  38. }
  39. // This is only needed for wxPython bindings
  40. wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) )
  41. {
  42. m_ptr.stringName = str;
  43. m_flags = IsWxString | OwnsWxString;
  44. }
  45. ~wxPGPropArgCls()
  46. {
  47. if ( m_flags & OwnsWxString )
  48. delete m_ptr.stringName;
  49. }
  50. wxPGProperty* GetPtr() const
  51. {
  52. wxCHECK( m_flags == IsProperty, NULL );
  53. return m_ptr.property;
  54. }
  55. wxPGPropArgCls( const char* str )
  56. {
  57. m_ptr.charName = str;
  58. m_flags = IsCharPtr;
  59. }
  60. wxPGPropArgCls( const wchar_t* str )
  61. {
  62. m_ptr.wcharName = str;
  63. m_flags = IsWCharPtr;
  64. }
  65. /** This constructor is required for NULL. */
  66. wxPGPropArgCls( int )
  67. {
  68. m_ptr.property = NULL;
  69. m_flags = IsProperty;
  70. }
  71. wxPGProperty* GetPtr( wxPropertyGridInterface* iface ) const;
  72. wxPGProperty* GetPtr( const wxPropertyGridInterface* iface ) const
  73. {
  74. return GetPtr((wxPropertyGridInterface*)iface);
  75. }
  76. wxPGProperty* GetPtr0() const { return m_ptr.property; }
  77. bool HasName() const { return (m_flags != IsProperty); }
  78. const wxString& GetName() const { return *m_ptr.stringName; }
  79. private:
  80. enum
  81. {
  82. IsProperty = 0x00,
  83. IsWxString = 0x01,
  84. IsCharPtr = 0x02,
  85. IsWCharPtr = 0x04,
  86. OwnsWxString = 0x10
  87. };
  88. union
  89. {
  90. wxPGProperty* property;
  91. const char* charName;
  92. const wchar_t* wcharName;
  93. const wxString* stringName;
  94. } m_ptr;
  95. unsigned char m_flags;
  96. };
  97. typedef const wxPGPropArgCls& wxPGPropArg;
  98. // -----------------------------------------------------------------------
  99. WXDLLIMPEXP_PROPGRID
  100. void wxPGTypeOperationFailed( const wxPGProperty* p,
  101. const wxString& typestr,
  102. const wxString& op );
  103. WXDLLIMPEXP_PROPGRID
  104. void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr );
  105. // -----------------------------------------------------------------------
  106. // Helper macro that does necessary preparations when calling
  107. // some wxPGProperty's member function.
  108. #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \
  109. PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
  110. if ( !p ) return;
  111. #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \
  112. PROPERTY *p = (PROPERTY*)id.GetPtr(this); \
  113. if ( !p ) return RETVAL;
  114. #define wxPG_PROP_ARG_CALL_PROLOG() \
  115. wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty)
  116. #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \
  117. wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL)
  118. #define wxPG_PROP_ID_CONST_CALL_PROLOG() \
  119. wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty)
  120. #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \
  121. wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL)
  122. // -----------------------------------------------------------------------
  123. /** @class wxPropertyGridInterface
  124. Most of the shared property manipulation interface shared by wxPropertyGrid,
  125. wxPropertyGridPage, and wxPropertyGridManager is defined in this class.
  126. @remarks
  127. - In separate wxPropertyGrid component this class was known as
  128. wxPropertyContainerMethods.
  129. @library{wxpropgrid}
  130. @category{propgrid}
  131. */
  132. class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface
  133. {
  134. public:
  135. /** Destructor */
  136. virtual ~wxPropertyGridInterface() { }
  137. /**
  138. Appends property to the list.
  139. wxPropertyGrid assumes ownership of the object.
  140. Becomes child of most recently added category.
  141. @remarks
  142. - wxPropertyGrid takes the ownership of the property pointer.
  143. - If appending a category with name identical to a category already in
  144. the wxPropertyGrid, then newly created category is deleted, and most
  145. recently added category (under which properties are appended) is set
  146. to the one with same name. This allows easier adding of items to same
  147. categories in multiple passes.
  148. - Does not automatically redraw the control, so you may need to call
  149. Refresh when calling this function after control has been shown for
  150. the first time.
  151. */
  152. wxPGProperty* Append( wxPGProperty* property );
  153. wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty );
  154. /**
  155. In order to add new items into a property with fixed children (for
  156. instance, wxFlagsProperty), you need to call this method. After
  157. populating has been finished, you need to call EndAddChildren.
  158. */
  159. void BeginAddChildren( wxPGPropArg id );
  160. /** Deletes all properties.
  161. */
  162. virtual void Clear() = 0;
  163. /**
  164. Clears current selection, if any.
  165. @param validation
  166. If set to @false, deselecting the property will always work,
  167. even if its editor had invalid value in it.
  168. @return Returns @true if successful or if there was no selection. May
  169. fail if validation was enabled and active editor had invalid
  170. value.
  171. @remarks In wxPropertyGrid 1.4, this member function used to send
  172. wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
  173. does that.
  174. */
  175. bool ClearSelection( bool validation = false );
  176. /** Resets modified status of all properties.
  177. */
  178. void ClearModifiedStatus();
  179. /** Collapses given category or property with children.
  180. Returns true if actually collapses.
  181. */
  182. bool Collapse( wxPGPropArg id );
  183. /** Collapses all items that can be collapsed.
  184. @return
  185. Return false if failed (may fail if editor value cannot be validated).
  186. */
  187. bool CollapseAll() { return ExpandAll(false); }
  188. /**
  189. Changes value of a property, as if from an editor.
  190. Use this instead of SetPropertyValue() if you need the value to run
  191. through validation process, and also send the property change event.
  192. @return
  193. Returns true if value was successfully changed.
  194. */
  195. bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
  196. /**
  197. Removes and deletes a property and any children.
  198. @param id
  199. Pointer or name of a property.
  200. @remarks If you delete a property in a wxPropertyGrid event
  201. handler, the actual deletion is postponed until the next
  202. idle event.
  203. This functions deselects selected property, if any.
  204. Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not
  205. respected, ie. selection is cleared even if editor had
  206. invalid value.
  207. */
  208. void DeleteProperty( wxPGPropArg id );
  209. /**
  210. Removes a property. Does not delete the property object, but
  211. instead returns it.
  212. @param id
  213. Pointer or name of a property.
  214. @remarks Removed property cannot have any children.
  215. Also, if you remove property in a wxPropertyGrid event
  216. handler, the actual removal is postponed until the next
  217. idle event.
  218. */
  219. wxPGProperty* RemoveProperty( wxPGPropArg id );
  220. /**
  221. Disables a property.
  222. @see EnableProperty(), wxPGProperty::Enable()
  223. */
  224. bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
  225. /**
  226. Returns true if all property grid data changes have been committed.
  227. Usually only returns false if value in active editor has been
  228. invalidated by a wxValidator.
  229. */
  230. bool EditorValidate();
  231. /**
  232. Enables or disables property, depending on whether enable is true or
  233. false. Disabled property usually appears as having grey text.
  234. @param id
  235. Name or pointer to a property.
  236. @param enable
  237. If @false, property is disabled instead.
  238. @see wxPGProperty::Enable()
  239. */
  240. bool EnableProperty( wxPGPropArg id, bool enable = true );
  241. /** Called after population of property with fixed children has finished.
  242. */
  243. void EndAddChildren( wxPGPropArg id );
  244. /** Expands given category or property with children.
  245. Returns true if actually expands.
  246. */
  247. bool Expand( wxPGPropArg id );
  248. /** Expands all items that can be expanded.
  249. */
  250. bool ExpandAll( bool expand = true );
  251. /** Returns id of first child of given property.
  252. @remarks
  253. Does not return sub-properties!
  254. */
  255. wxPGProperty* GetFirstChild( wxPGPropArg id )
  256. {
  257. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
  258. if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) )
  259. return wxNullProperty;
  260. return p->Item(0);
  261. }
  262. //@{
  263. /** Returns iterator class instance.
  264. @param flags
  265. See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes
  266. iteration over everything except private child properties.
  267. @param firstProp
  268. Property to start iteration from. If NULL, then first child of root
  269. is used.
  270. @param startPos
  271. Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start
  272. from the first property from the top, and wxBOTTOM means that the
  273. iteration will instead begin from bottommost valid item.
  274. */
  275. wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT,
  276. wxPGProperty* firstProp = NULL )
  277. {
  278. return wxPropertyGridIterator( m_pState, flags, firstProp );
  279. }
  280. wxPropertyGridConstIterator
  281. GetIterator( int flags = wxPG_ITERATE_DEFAULT,
  282. wxPGProperty* firstProp = NULL ) const
  283. {
  284. return wxPropertyGridConstIterator( m_pState, flags, firstProp );
  285. }
  286. wxPropertyGridIterator GetIterator( int flags, int startPos )
  287. {
  288. return wxPropertyGridIterator( m_pState, flags, startPos );
  289. }
  290. wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const
  291. {
  292. return wxPropertyGridConstIterator( m_pState, flags, startPos );
  293. }
  294. //@}
  295. /** Returns id of first item, whether it is a category or property.
  296. @param flags
  297. @link iteratorflags List of iterator flags@endlink
  298. */
  299. wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL )
  300. {
  301. wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 );
  302. return *it;
  303. }
  304. const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const
  305. {
  306. return ((wxPropertyGridInterface*)this)->GetFirst(flags);
  307. }
  308. /**
  309. Returns pointer to a property with given name (case-sensitive).
  310. If there is no property with such name, @NULL pointer is returned.
  311. @remarks Properties which have non-category, non-root parent
  312. cannot be accessed globally by their name. Instead, use
  313. "<property>.<subproperty>" instead of "<subproperty>".
  314. */
  315. wxPGProperty* GetProperty( const wxString& name ) const
  316. {
  317. return GetPropertyByName(name);
  318. }
  319. /** Returns map-like storage of property's attributes.
  320. @remarks
  321. Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set,
  322. then builtin-attributes are not included in the storage.
  323. */
  324. const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const
  325. {
  326. // If 'id' refers to invalid property, then we will return dummy
  327. // attributes (ie. root property's attributes, which contents should
  328. // should always be empty and of no consequence).
  329. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState->DoGetRoot()->GetAttributes());
  330. return p->GetAttributes();
  331. }
  332. /** Adds to 'targetArr' pointers to properties that have given
  333. flags 'flags' set. However, if 'inverse' is set to true, then
  334. only properties without given flags are stored.
  335. @param flags
  336. Property flags to use.
  337. @param iterFlags
  338. Iterator flags to use. Default is everything expect private children.
  339. */
  340. void GetPropertiesWithFlag( wxArrayPGProperty* targetArr,
  341. wxPGProperty::FlagType flags,
  342. bool inverse = false,
  343. int iterFlags = wxPG_ITERATE_PROPERTIES |
  344. wxPG_ITERATE_HIDDEN |
  345. wxPG_ITERATE_CATEGORIES) const;
  346. /** Returns value of given attribute. If none found, returns NULL-variant.
  347. */
  348. wxVariant GetPropertyAttribute( wxPGPropArg id,
  349. const wxString& attrName ) const
  350. {
  351. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant)
  352. return p->GetAttribute(attrName);
  353. }
  354. /** Returns pointer of property's nearest parent category. If no category
  355. found, returns NULL.
  356. */
  357. wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const
  358. {
  359. wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL)
  360. return m_pState->GetPropertyCategory(p);
  361. }
  362. /** Returns client data (void*) of a property. */
  363. void* GetPropertyClientData( wxPGPropArg id ) const
  364. {
  365. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
  366. return p->GetClientData();
  367. }
  368. /**
  369. Returns first property which label matches given string.
  370. NULL if none found. Note that this operation is extremely slow when
  371. compared to GetPropertyByName().
  372. */
  373. wxPGProperty* GetPropertyByLabel( const wxString& label ) const;
  374. /** Returns property with given name. NULL if none found.
  375. */
  376. wxPGProperty* GetPropertyByName( const wxString& name ) const;
  377. /** Returns child property 'subname' of property 'name'. Same as
  378. calling GetPropertyByName("name.subname"), albeit slightly faster.
  379. */
  380. wxPGProperty* GetPropertyByName( const wxString& name,
  381. const wxString& subname ) const;
  382. /** Returns property's editor. */
  383. const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const
  384. {
  385. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
  386. return p->GetEditorClass();
  387. }
  388. /** Returns help string associated with a property. */
  389. wxString GetPropertyHelpString( wxPGPropArg id ) const
  390. {
  391. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
  392. return p->GetHelpString();
  393. }
  394. /** Returns property's custom value image (NULL of none). */
  395. wxBitmap* GetPropertyImage( wxPGPropArg id ) const
  396. {
  397. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
  398. return p->GetValueImage();
  399. }
  400. /** Returns label of a property. */
  401. const wxString& GetPropertyLabel( wxPGPropArg id )
  402. {
  403. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString)
  404. return p->GetLabel();
  405. }
  406. /** Returns name of a property, by which it is globally accessible. */
  407. wxString GetPropertyName( wxPGProperty* property )
  408. {
  409. return property->GetName();
  410. }
  411. /** Returns parent item of a property. */
  412. wxPGProperty* GetPropertyParent( wxPGPropArg id )
  413. {
  414. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
  415. return p->GetParent();
  416. }
  417. #if wxUSE_VALIDATORS
  418. /** Returns validator of a property as a reference, which you
  419. can pass to any number of SetPropertyValidator.
  420. */
  421. wxValidator* GetPropertyValidator( wxPGPropArg id )
  422. {
  423. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL)
  424. return p->GetValidator();
  425. }
  426. #endif
  427. /** Returns value as wxVariant. To get wxObject pointer from it,
  428. you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro.
  429. If property value is unspecified, Null variant is returned.
  430. */
  431. wxVariant GetPropertyValue( wxPGPropArg id )
  432. {
  433. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant())
  434. return p->GetValue();
  435. }
  436. wxString GetPropertyValueAsString( wxPGPropArg id ) const;
  437. long GetPropertyValueAsLong( wxPGPropArg id ) const;
  438. unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const
  439. {
  440. return (unsigned long) GetPropertyValueAsLong(id);
  441. }
  442. int GetPropertyValueAsInt( wxPGPropArg id ) const
  443. { return (int)GetPropertyValueAsLong(id); }
  444. bool GetPropertyValueAsBool( wxPGPropArg id ) const;
  445. double GetPropertyValueAsDouble( wxPGPropArg id ) const;
  446. #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \
  447. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
  448. wxString typeName(wxS(TYPENAME)); \
  449. wxVariant value = p->GetValue(); \
  450. if ( value.GetType() != typeName ) \
  451. { \
  452. wxPGGetFailed(p, typeName); \
  453. return DEFVAL; \
  454. }
  455. #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \
  456. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \
  457. wxVariant value = p->GetValue(); \
  458. if ( value.GetType() != wxS(TYPENAME) ) \
  459. return DEFVAL; \
  460. wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const
  461. {
  462. wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring",
  463. wxArrayString())
  464. return value.GetArrayString();
  465. }
  466. #ifdef wxLongLong_t
  467. wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const
  468. {
  469. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
  470. return p->GetValue().GetLongLong().GetValue();
  471. }
  472. wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const
  473. {
  474. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0)
  475. return p->GetValue().GetULongLong().GetValue();
  476. }
  477. #endif
  478. wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const
  479. {
  480. wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt",
  481. wxArrayInt())
  482. wxArrayInt arr;
  483. arr << value;
  484. return arr;
  485. }
  486. #if wxUSE_DATETIME
  487. wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const
  488. {
  489. wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime",
  490. wxDateTime())
  491. return value.GetDateTime();
  492. }
  493. #endif
  494. /** Returns a wxVariant list containing wxVariant versions of all
  495. property values. Order is not guaranteed.
  496. @param flags
  497. Use wxPG_KEEP_STRUCTURE to retain category structure; each sub
  498. category will be its own wxVariantList of wxVariant.
  499. Use wxPG_INC_ATTRIBUTES to include property attributes as well.
  500. Each attribute will be stored as list variant named
  501. "@@<propname>@@attr."
  502. @remarks
  503. */
  504. wxVariant GetPropertyValues( const wxString& listname = wxEmptyString,
  505. wxPGProperty* baseparent = NULL, long flags = 0 ) const
  506. {
  507. return m_pState->DoGetPropertyValues(listname, baseparent, flags);
  508. }
  509. /**
  510. Returns currently selected property. NULL if none.
  511. @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this
  512. member function returns the focused property, that is the
  513. one which can have active editor.
  514. */
  515. wxPGProperty* GetSelection() const;
  516. /**
  517. Returns list of currently selected properties.
  518. @remarks wxArrayPGProperty should be compatible with std::vector API.
  519. */
  520. const wxArrayPGProperty& GetSelectedProperties() const
  521. {
  522. return m_pState->m_selection;
  523. }
  524. wxPropertyGridPageState* GetState() const { return m_pState; }
  525. /** Similar to GetIterator(), but instead returns wxPGVIterator instance,
  526. which can be useful for forward-iterating through arbitrary property
  527. containers.
  528. @param flags
  529. See @ref propgrid_iterator_flags.
  530. */
  531. virtual wxPGVIterator GetVIterator( int flags ) const;
  532. /** Hides or reveals a property.
  533. @param hide
  534. If true, hides property, otherwise reveals it.
  535. @param flags
  536. By default changes are applied recursively. Set this paramter
  537. wxPG_DONT_RECURSE to prevent this.
  538. */
  539. bool HideProperty( wxPGPropArg id,
  540. bool hide = true,
  541. int flags = wxPG_RECURSE );
  542. #if wxPG_INCLUDE_ADVPROPS
  543. /** Initializes *all* property types. Causes references to most object
  544. files in the library, so calling this may cause significant increase
  545. in executable size when linking with static library.
  546. */
  547. static void InitAllTypeHandlers();
  548. #else
  549. static void InitAllTypeHandlers() { }
  550. #endif
  551. //@{
  552. /** Inserts property to the property container.
  553. @param priorThis
  554. New property is inserted just prior to this. Available only
  555. in the first variant. There are two versions of this function
  556. to allow this parameter to be either an id or name to
  557. a property.
  558. @param newproperty
  559. Pointer to the inserted property. wxPropertyGrid will take
  560. ownership of this object.
  561. @param parent
  562. New property is inserted under this category. Available only
  563. in the second variant. There are two versions of this function
  564. to allow this parameter to be either an id or name to
  565. a property.
  566. @param index
  567. Index under category. Available only in the second variant.
  568. If index is < 0, property is appended in category.
  569. @return
  570. Returns id for the property,
  571. @remarks
  572. - wxPropertyGrid takes the ownership of the property pointer.
  573. - While Append may be faster way to add items, make note that when
  574. both types of data storage (categoric and
  575. non-categoric) are active, Insert becomes even more slow. This is
  576. especially true if current mode is non-categoric.
  577. Example of use:
  578. @code
  579. // append category
  580. wxPGProperty* my_cat_id = propertygrid->Append(
  581. new wxPropertyCategory("My Category") );
  582. ...
  583. // insert into category - using second variant
  584. wxPGProperty* my_item_id_1 = propertygrid->Insert(
  585. my_cat_id, 0, new wxStringProperty("My String 1") );
  586. // insert before to first item - using first variant
  587. wxPGProperty* my_item_id_2 = propertygrid->Insert(
  588. my_item_id, new wxStringProperty("My String 2") );
  589. @endcode
  590. */
  591. wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty );
  592. wxPGProperty* Insert( wxPGPropArg parent,
  593. int index,
  594. wxPGProperty* newproperty );
  595. //@}
  596. /** Returns true if property is a category. */
  597. bool IsPropertyCategory( wxPGPropArg id ) const
  598. {
  599. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  600. return p->IsCategory();
  601. }
  602. /** Returns true if property is enabled. */
  603. bool IsPropertyEnabled( wxPGPropArg id ) const
  604. {
  605. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  606. return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false;
  607. }
  608. /**
  609. Returns true if given property is expanded.
  610. Naturally, always returns false for properties that cannot be expanded.
  611. */
  612. bool IsPropertyExpanded( wxPGPropArg id ) const;
  613. /**
  614. Returns true if property has been modified after value set or modify
  615. flag clear by software.
  616. */
  617. bool IsPropertyModified( wxPGPropArg id ) const
  618. {
  619. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  620. return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false );
  621. }
  622. /**
  623. Returns true if property is selected.
  624. */
  625. bool IsPropertySelected( wxPGPropArg id ) const
  626. {
  627. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  628. return m_pState->DoIsPropertySelected(p);
  629. }
  630. /**
  631. Returns true if property is shown (ie hideproperty with true not
  632. called for it).
  633. */
  634. bool IsPropertyShown( wxPGPropArg id ) const
  635. {
  636. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  637. return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false;
  638. }
  639. /** Returns true if property value is set to unspecified.
  640. */
  641. bool IsPropertyValueUnspecified( wxPGPropArg id ) const
  642. {
  643. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
  644. return p->IsValueUnspecified();
  645. }
  646. /**
  647. Disables (limit = true) or enables (limit = false) wxTextCtrl editor of
  648. a property, if it is not the sole mean to edit the value.
  649. */
  650. void LimitPropertyEditing( wxPGPropArg id, bool limit = true );
  651. /** If state is shown in it's grid, refresh it now.
  652. */
  653. virtual void RefreshGrid( wxPropertyGridPageState* state = NULL );
  654. #if wxPG_INCLUDE_ADVPROPS
  655. /**
  656. Initializes additional property editors (SpinCtrl etc.). Causes
  657. references to most object files in the library, so calling this may
  658. cause significant increase in executable size when linking with static
  659. library.
  660. */
  661. static void RegisterAdditionalEditors();
  662. #else
  663. static void RegisterAdditionalEditors() { }
  664. #endif
  665. /** Replaces property with id with newly created property. For example,
  666. this code replaces existing property named "Flags" with one that
  667. will have different set of items:
  668. @code
  669. pg->ReplaceProperty("Flags",
  670. wxFlagsProperty("Flags", wxPG_LABEL, newItems))
  671. @endcode
  672. For more info, see wxPropertyGrid::Insert.
  673. */
  674. wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property );
  675. /** @anchor propgridinterface_editablestate_flags
  676. Flags for wxPropertyGridInterface::SaveEditableState() and
  677. wxPropertyGridInterface::RestoreEditableState().
  678. */
  679. enum EditableStateFlags
  680. {
  681. /** Include selected property. */
  682. SelectionState = 0x01,
  683. /** Include expanded/collapsed property information. */
  684. ExpandedState = 0x02,
  685. /** Include scrolled position. */
  686. ScrollPosState = 0x04,
  687. /** Include selected page information.
  688. Only applies to wxPropertyGridManager. */
  689. PageState = 0x08,
  690. /** Include splitter position. Stored for each page. */
  691. SplitterPosState = 0x10,
  692. /** Include description box size.
  693. Only applies to wxPropertyGridManager. */
  694. DescBoxState = 0x20,
  695. /**
  696. Include all supported user editable state information.
  697. This is usually the default value. */
  698. AllStates = SelectionState |
  699. ExpandedState |
  700. ScrollPosState |
  701. PageState |
  702. SplitterPosState |
  703. DescBoxState
  704. };
  705. /**
  706. Restores user-editable state.
  707. See also wxPropertyGridInterface::SaveEditableState().
  708. @param src
  709. String generated by SaveEditableState.
  710. @param restoreStates
  711. Which parts to restore from source string. See @ref
  712. propgridinterface_editablestate_flags "list of editable state
  713. flags".
  714. @return
  715. False if there was problem reading the string.
  716. @remarks
  717. If some parts of state (such as scrolled or splitter position) fail to
  718. restore correctly, please make sure that you call this function after
  719. wxPropertyGrid size has been set (this may sometimes be tricky when
  720. sizers are used).
  721. */
  722. bool RestoreEditableState( const wxString& src,
  723. int restoreStates = AllStates );
  724. /**
  725. Used to acquire user-editable state (selected property, expanded
  726. properties, scrolled position, splitter positions).
  727. @param includedStates
  728. Which parts of state to include. See @ref
  729. propgridinterface_editablestate_flags "list of editable state flags".
  730. */
  731. wxString SaveEditableState( int includedStates = AllStates ) const;
  732. /**
  733. Lets user set the strings listed in the choice dropdown of a
  734. wxBoolProperty. Defaults are "True" and "False", so changing them to,
  735. say, "Yes" and "No" may be useful in some less technical applications.
  736. */
  737. static void SetBoolChoices( const wxString& trueChoice,
  738. const wxString& falseChoice );
  739. /**
  740. Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER
  741. window style needs to be used to indicate that columns are auto-
  742. resizable.
  743. @returns Returns @false on failure.
  744. @remarks You should call this for individual pages of
  745. wxPropertyGridManager (if used).
  746. @see GetColumnProportion()
  747. */
  748. bool SetColumnProportion( unsigned int column, int proportion );
  749. /**
  750. Returns auto-resize proportion of the given column.
  751. @see SetColumnProportion()
  752. */
  753. int GetColumnProportion( unsigned int column ) const
  754. {
  755. return m_pState->DoGetColumnProportion(column);
  756. }
  757. /** Sets an attribute for this property.
  758. @param name
  759. Text identifier of attribute. See @ref propgrid_property_attributes.
  760. @param value
  761. Value of attribute.
  762. @param argFlags
  763. Optional. Use wxPG_RECURSE to set the attribute to child properties
  764. recursively.
  765. */
  766. void SetPropertyAttribute( wxPGPropArg id,
  767. const wxString& attrName,
  768. wxVariant value,
  769. long argFlags = 0 )
  770. {
  771. DoSetPropertyAttribute(id,attrName,value,argFlags);
  772. }
  773. /** Sets property attribute for all applicapple properties.
  774. Be sure to use this method only after all properties have been
  775. added to the grid.
  776. */
  777. void SetPropertyAttributeAll( const wxString& attrName, wxVariant value );
  778. /**
  779. Sets background colour of a property.
  780. @param id
  781. Property name or pointer.
  782. @param colour
  783. New background colour.
  784. @param flags
  785. Default is wxPG_RECURSE which causes colour to be set recursively.
  786. Omit this flag to only set colour for the property in question
  787. and not any of its children.
  788. */
  789. void SetPropertyBackgroundColour( wxPGPropArg id,
  790. const wxColour& colour,
  791. int flags = wxPG_RECURSE );
  792. /** Resets text and background colours of given property.
  793. */
  794. void SetPropertyColoursToDefault( wxPGPropArg id );
  795. /**
  796. Sets text colour of a property.
  797. @param id
  798. Property name or pointer.
  799. @param colour
  800. New background colour.
  801. @param flags
  802. Default is wxPG_RECURSE which causes colour to be set recursively.
  803. Omit this flag to only set colour for the property in question
  804. and not any of its children.
  805. */
  806. void SetPropertyTextColour( wxPGPropArg id,
  807. const wxColour& col,
  808. int flags = wxPG_RECURSE );
  809. /**
  810. Returns background colour of first cell of a property.
  811. */
  812. wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const
  813. {
  814. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
  815. return p->GetCell(0).GetBgCol();
  816. }
  817. /**
  818. Returns text colour of first cell of a property.
  819. */
  820. wxColour GetPropertyTextColour( wxPGPropArg id ) const
  821. {
  822. wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour())
  823. return p->GetCell(0).GetFgCol();
  824. }
  825. /** Sets text, bitmap, and colours for given column's cell.
  826. @remarks
  827. - You can set label cell by setting column to 0.
  828. - You can use wxPG_LABEL as text to use default text for column.
  829. */
  830. void SetPropertyCell( wxPGPropArg id,
  831. int column,
  832. const wxString& text = wxEmptyString,
  833. const wxBitmap& bitmap = wxNullBitmap,
  834. const wxColour& fgCol = wxNullColour,
  835. const wxColour& bgCol = wxNullColour );
  836. /** Sets client data (void*) of a property.
  837. @remarks
  838. This untyped client data has to be deleted manually.
  839. */
  840. void SetPropertyClientData( wxPGPropArg id, void* clientData )
  841. {
  842. wxPG_PROP_ARG_CALL_PROLOG()
  843. p->SetClientData(clientData);
  844. }
  845. /** Sets editor for a property.
  846. @param editor
  847. For builtin editors, use wxPGEditor_X, where X is builtin editor's
  848. name (TextCtrl, Choice, etc. see wxPGEditor documentation for full
  849. list).
  850. For custom editors, use pointer you received from
  851. wxPropertyGrid::RegisterEditorClass().
  852. */
  853. void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor )
  854. {
  855. wxPG_PROP_ARG_CALL_PROLOG()
  856. wxCHECK_RET( editor, wxT("unknown/NULL editor") );
  857. p->SetEditor(editor);
  858. RefreshProperty(p);
  859. }
  860. /** Sets editor control of a property. As editor argument, use
  861. editor name string, such as "TextCtrl" or "Choice".
  862. */
  863. void SetPropertyEditor( wxPGPropArg id, const wxString& editorName )
  864. {
  865. SetPropertyEditor(id,GetEditorByName(editorName));
  866. }
  867. /** Sets label of a property.
  868. */
  869. void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel );
  870. /**
  871. Sets name of a property.
  872. @param id
  873. Name or pointer of property which name to change.
  874. @param newName
  875. New name for property.
  876. */
  877. void SetPropertyName( wxPGPropArg id, const wxString& newName )
  878. {
  879. wxPG_PROP_ARG_CALL_PROLOG()
  880. m_pState->DoSetPropertyName( p, newName );
  881. }
  882. /**
  883. Sets property (and, recursively, its children) to have read-only value.
  884. In other words, user cannot change the value in the editor, but they
  885. can still copy it.
  886. @remarks
  887. This is mainly for use with textctrl editor. Not all other editors fully
  888. support it.
  889. @param flags
  890. By default changes are applied recursively. Set this paramter
  891. wxPG_DONT_RECURSE to prevent this.
  892. */
  893. void SetPropertyReadOnly( wxPGPropArg id,
  894. bool set = true,
  895. int flags = wxPG_RECURSE )
  896. {
  897. wxPG_PROP_ARG_CALL_PROLOG()
  898. if ( flags & wxPG_RECURSE )
  899. p->SetFlagRecursively(wxPG_PROP_READONLY, set);
  900. else
  901. p->ChangeFlag(wxPG_PROP_READONLY, set);
  902. }
  903. /** Sets property's value to unspecified.
  904. If it has children (it may be category), then the same thing is done to
  905. them.
  906. */
  907. void SetPropertyValueUnspecified( wxPGPropArg id )
  908. {
  909. wxPG_PROP_ARG_CALL_PROLOG()
  910. p->SetValueToUnspecified();
  911. }
  912. /**
  913. Sets property values from a list of wxVariants.
  914. */
  915. void SetPropertyValues( const wxVariantList& list,
  916. wxPGPropArg defaultCategory = wxNullProperty )
  917. {
  918. wxPGProperty *p;
  919. if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this);
  920. else p = defaultCategory.GetPtr0();
  921. m_pState->DoSetPropertyValues(list, p);
  922. }
  923. /**
  924. Sets property values from a list of wxVariants.
  925. */
  926. void SetPropertyValues( const wxVariant& list,
  927. wxPGPropArg defaultCategory = wxNullProperty )
  928. {
  929. SetPropertyValues(list.GetList(),defaultCategory);
  930. }
  931. /** Associates the help string with property.
  932. @remarks
  933. By default, text is shown either in the manager's "description"
  934. text box or in the status bar. If extra window style
  935. wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a
  936. tooltip.
  937. */
  938. void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString )
  939. {
  940. wxPG_PROP_ARG_CALL_PROLOG()
  941. p->SetHelpString(helpString);
  942. }
  943. /** Set wxBitmap in front of the value.
  944. @remarks
  945. - Bitmap will be scaled to a size returned by
  946. wxPropertyGrid::GetImageSize();
  947. */
  948. void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp )
  949. {
  950. wxPG_PROP_ARG_CALL_PROLOG()
  951. p->SetValueImage(bmp);
  952. RefreshProperty(p);
  953. }
  954. /** Sets max length of property's text.
  955. */
  956. bool SetPropertyMaxLength( wxPGPropArg id, int maxLen );
  957. #if wxUSE_VALIDATORS
  958. /** Sets validator of a property.
  959. */
  960. void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator )
  961. {
  962. wxPG_PROP_ARG_CALL_PROLOG()
  963. p->SetValidator(validator);
  964. }
  965. #endif
  966. /** Sets value (long integer) of a property.
  967. */
  968. void SetPropertyValue( wxPGPropArg id, long value )
  969. {
  970. wxVariant v(value);
  971. SetPropVal( id, v );
  972. }
  973. /** Sets value (integer) of a property.
  974. */
  975. void SetPropertyValue( wxPGPropArg id, int value )
  976. {
  977. wxVariant v((long)value);
  978. SetPropVal( id, v );
  979. }
  980. /** Sets value (floating point) of a property.
  981. */
  982. void SetPropertyValue( wxPGPropArg id, double value )
  983. {
  984. wxVariant v(value);
  985. SetPropVal( id, v );
  986. }
  987. /** Sets value (bool) of a property.
  988. */
  989. void SetPropertyValue( wxPGPropArg id, bool value )
  990. {
  991. wxVariant v(value);
  992. SetPropVal( id, v );
  993. }
  994. void SetPropertyValue( wxPGPropArg id, const wchar_t* value )
  995. {
  996. SetPropertyValueString( id, wxString(value) );
  997. }
  998. void SetPropertyValue( wxPGPropArg id, const char* value )
  999. {
  1000. SetPropertyValueString( id, wxString(value) );
  1001. }
  1002. void SetPropertyValue( wxPGPropArg id, const wxString& value )
  1003. {
  1004. SetPropertyValueString( id, value );
  1005. }
  1006. /** Sets value (wxArrayString) of a property.
  1007. */
  1008. void SetPropertyValue( wxPGPropArg id, const wxArrayString& value )
  1009. {
  1010. wxVariant v(value);
  1011. SetPropVal( id, v );
  1012. }
  1013. #if wxUSE_DATETIME
  1014. void SetPropertyValue( wxPGPropArg id, const wxDateTime& value )
  1015. {
  1016. wxVariant v(value);
  1017. SetPropVal( id, v );
  1018. }
  1019. #endif
  1020. /** Sets value (wxObject*) of a property.
  1021. */
  1022. void SetPropertyValue( wxPGPropArg id, wxObject* value )
  1023. {
  1024. wxVariant v(value);
  1025. SetPropVal( id, v );
  1026. }
  1027. void SetPropertyValue( wxPGPropArg id, wxObject& value )
  1028. {
  1029. wxVariant v(&value);
  1030. SetPropVal( id, v );
  1031. }
  1032. #ifdef wxLongLong_t
  1033. /** Sets value (wxLongLong&) of a property.
  1034. */
  1035. void SetPropertyValue( wxPGPropArg id, wxLongLong_t value )
  1036. {
  1037. wxVariant v = WXVARIANT(wxLongLong(value));
  1038. SetPropVal( id, v );
  1039. }
  1040. /** Sets value (wxULongLong&) of a property.
  1041. */
  1042. void SetPropertyValue( wxPGPropArg id, wxULongLong_t value )
  1043. {
  1044. wxVariant v = WXVARIANT(wxULongLong(value));
  1045. SetPropVal( id, v );
  1046. }
  1047. #endif
  1048. /** Sets value (wxArrayInt&) of a property.
  1049. */
  1050. void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value )
  1051. {
  1052. wxVariant v = WXVARIANT(value);
  1053. SetPropVal( id, v );
  1054. }
  1055. /** Sets value (wxString) of a property.
  1056. @remarks
  1057. This method uses wxPGProperty::SetValueFromString, which all properties
  1058. should implement. This means that there should not be a type error,
  1059. and instead the string is converted to property's actual value type.
  1060. */
  1061. void SetPropertyValueString( wxPGPropArg id, const wxString& value );
  1062. /** Sets value (wxVariant&) of a property.
  1063. @remarks
  1064. Use wxPropertyGrid::ChangePropertyValue() instead if you need to run
  1065. through validation process and send property change event.
  1066. */
  1067. void SetPropertyValue( wxPGPropArg id, wxVariant value )
  1068. {
  1069. SetPropVal( id, value );
  1070. }
  1071. /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but
  1072. accepts reference. */
  1073. void SetPropVal( wxPGPropArg id, wxVariant& value );
  1074. /** Adjusts how wxPropertyGrid behaves when invalid value is entered
  1075. in a property.
  1076. @param vfbFlags
  1077. See @link vfbflags list of valid flags values@endlink
  1078. */
  1079. void SetValidationFailureBehavior( int vfbFlags );
  1080. /**
  1081. Sorts all properties recursively.
  1082. @param flags
  1083. This can contain any of the following options:
  1084. wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their
  1085. immediate children. Sorting done by wxPG_AUTO_SORT option
  1086. uses this.
  1087. @see SortChildren, wxPropertyGrid::SetSortFunction
  1088. */
  1089. void Sort( int flags = 0 );
  1090. /**
  1091. Sorts children of a property.
  1092. @param id
  1093. Name or pointer to a property.
  1094. @param flags
  1095. This can contain any of the following options:
  1096. wxPG_RECURSE: Sorts recursively.
  1097. @see Sort, wxPropertyGrid::SetSortFunction
  1098. */
  1099. void SortChildren( wxPGPropArg id, int flags = 0 )
  1100. {
  1101. wxPG_PROP_ARG_CALL_PROLOG()
  1102. m_pState->DoSortChildren(p, flags);
  1103. }
  1104. // GetPropertyByName With nice assertion error message.
  1105. wxPGProperty* GetPropertyByNameA( const wxString& name ) const;
  1106. static wxPGEditor* GetEditorByName( const wxString& editorName );
  1107. // NOTE: This function reselects the property and may cause
  1108. // excess flicker, so to just call Refresh() on a rect
  1109. // of single property, call DrawItem() instead.
  1110. virtual void RefreshProperty( wxPGProperty* p ) = 0;
  1111. protected:
  1112. bool DoClearSelection( bool validation = false,
  1113. int selFlags = 0 );
  1114. /**
  1115. In derived class, implement to set editable state component with
  1116. given name to given value.
  1117. */
  1118. virtual bool SetEditableStateItem( const wxString& name, wxVariant value )
  1119. {
  1120. wxUnusedVar(name);
  1121. wxUnusedVar(value);
  1122. return false;
  1123. }
  1124. /**
  1125. In derived class, implement to return editable state component with
  1126. given name.
  1127. */
  1128. virtual wxVariant GetEditableStateItem( const wxString& name ) const
  1129. {
  1130. wxUnusedVar(name);
  1131. return wxNullVariant;
  1132. }
  1133. // Returns page state data for given (sub) page (-1 means current page).
  1134. virtual wxPropertyGridPageState* GetPageState( int pageIndex ) const
  1135. {
  1136. if ( pageIndex <= 0 )
  1137. return m_pState;
  1138. return NULL;
  1139. }
  1140. virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; }
  1141. // Default call's m_pState's BaseGetPropertyByName
  1142. virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const;
  1143. // Deriving classes must set this (it must be only or current page).
  1144. wxPropertyGridPageState* m_pState;
  1145. // Intermediate version needed due to wxVariant copying inefficiency
  1146. void DoSetPropertyAttribute( wxPGPropArg id,
  1147. const wxString& name,
  1148. wxVariant& value, long argFlags );
  1149. // Empty string object to return from member functions returning const
  1150. // wxString&.
  1151. wxString m_emptyString;
  1152. private:
  1153. // Cannot be GetGrid() due to ambiguity issues.
  1154. wxPropertyGrid* GetPropertyGrid()
  1155. {
  1156. if ( !m_pState )
  1157. return NULL;
  1158. return m_pState->GetGrid();
  1159. }
  1160. // Cannot be GetGrid() due to ambiguity issues.
  1161. const wxPropertyGrid* GetPropertyGrid() const
  1162. {
  1163. if ( !m_pState )
  1164. return NULL;
  1165. return m_pState->GetGrid();
  1166. }
  1167. friend class wxPropertyGrid;
  1168. friend class wxPropertyGridManager;
  1169. };
  1170. #endif // wxUSE_PROPGRID
  1171. #endif // __WX_PROPGRID_PROPGRIDIFACE_H__