propgridpagestate.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: property.h
  3. // Purpose: interface of wxPGProperty
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @section propgrid_hittestresult wxPropertyGridHitTestResult
  9. A return value from wxPropertyGrid::HitTest(),
  10. contains all you need to know about an arbitrary location on the grid.
  11. */
  12. struct wxPropertyGridHitTestResult
  13. {
  14. public:
  15. wxPGProperty* GetProperty() const { return property; }
  16. /** Column. -1 for margin. */
  17. int column;
  18. /** Index of splitter hit, -1 for none. */
  19. int splitter;
  20. /** If splitter hit, offset to that */
  21. int splitterHitOffset;
  22. private:
  23. /** Property. NULL if empty space below properties was hit */
  24. wxPGProperty* property;
  25. };
  26. // -----------------------------------------------------------------------
  27. #define wxPG_IT_CHILDREN(A) (A<<16)
  28. /** @section propgrid_iterator_flags wxPropertyGridIterator Flags
  29. @{
  30. NOTES: At lower 16-bits, there are flags to check if item will be included. At higher
  31. 16-bits, there are same flags, but to instead check if children will be included.
  32. */
  33. enum wxPG_ITERATOR_FLAGS
  34. {
  35. /** Iterate through 'normal' property items (does not include children of aggregate or hidden items by default).
  36. */
  37. wxPG_ITERATE_PROPERTIES = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
  38. wxPG_PROP_COLLAPSED|((wxPG_PROP_MISC_PARENT|wxPG_PROP_CATEGORY)<<16)),
  39. /** Iterate children of collapsed parents, and individual items that are hidden.
  40. */
  41. wxPG_ITERATE_HIDDEN = (wxPG_PROP_HIDDEN|wxPG_IT_CHILDREN(wxPG_PROP_COLLAPSED)),
  42. /** Iterate children of parent that is an aggregate property (ie. has fixed children).
  43. */
  44. wxPG_ITERATE_FIXED_CHILDREN = (wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)|wxPG_ITERATE_PROPERTIES),
  45. /** Iterate categories. Note that even without this flag, children of categories
  46. are still iterated through.
  47. */
  48. wxPG_ITERATE_CATEGORIES = (wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_CATEGORY)|wxPG_PROP_COLLAPSED),
  49. wxPG_ITERATE_ALL_PARENTS = (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY),
  50. wxPG_ITERATE_ALL_PARENTS_RECURSIVELY = (wxPG_ITERATE_ALL_PARENTS|wxPG_IT_CHILDREN(wxPG_ITERATE_ALL_PARENTS)),
  51. wxPG_ITERATOR_FLAGS_ALL = (wxPG_PROP_PROPERTY|wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE| \
  52. wxPG_PROP_HIDDEN|wxPG_PROP_CATEGORY|wxPG_PROP_COLLAPSED),
  53. wxPG_ITERATOR_MASK_OP_ITEM = wxPG_ITERATOR_FLAGS_ALL,
  54. wxPG_ITERATOR_MASK_OP_PARENT = wxPG_ITERATOR_FLAGS_ALL, // (wxPG_PROP_MISC_PARENT|wxPG_PROP_AGGREGATE|wxPG_PROP_CATEGORY)
  55. /** Combines all flags needed to iterate through visible properties
  56. (ie. hidden properties and children of collapsed parents are skipped).
  57. */
  58. wxPG_ITERATE_VISIBLE = (wxPG_ITERATE_PROPERTIES|wxPG_PROP_CATEGORY|wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)),
  59. /** Iterate all items.
  60. */
  61. wxPG_ITERATE_ALL = (wxPG_ITERATE_VISIBLE|wxPG_ITERATE_HIDDEN),
  62. /** Iterate through individual properties (ie. categories and children of
  63. aggregate properties are skipped).
  64. */
  65. wxPG_ITERATE_NORMAL = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN),
  66. /** Default iterator flags.
  67. */
  68. wxPG_ITERATE_DEFAULT = wxPG_ITERATE_NORMAL
  69. };
  70. /** @}
  71. */
  72. /**
  73. @section propgrid_iterator_class wxPropertyGridIterator
  74. Preferable way to iterate through contents of wxPropertyGrid,
  75. wxPropertyGridManager, and wxPropertyGridPage.
  76. See wxPropertyGridInterface::GetIterator() for more information about usage.
  77. @library{wxpropgrid}
  78. @category{propgrid}
  79. */
  80. class wxPropertyGridIterator : public wxPropertyGridIteratorBase
  81. {
  82. public:
  83. void Assign( const wxPropertyGridIteratorBase& it );
  84. bool AtEnd() const { return m_property == NULL; }
  85. /**
  86. Get current property.
  87. */
  88. wxPGProperty* GetProperty() const { return m_property; }
  89. /**
  90. Iterate to the next property.
  91. */
  92. void Next( bool iterateChildren = true );
  93. /**
  94. Iterate to the previous property.
  95. */
  96. void Prev();
  97. protected:
  98. };
  99. // -----------------------------------------------------------------------
  100. /**
  101. @section propgrid_viterator_class wxPGVIterator
  102. Abstract implementation of a simple iterator. Can only be used
  103. to iterate in forward order, and only through the entire container.
  104. Used to have functions dealing with all properties work with both
  105. wxPropertyGrid and wxPropertyGridManager.
  106. */
  107. class wxPGVIterator
  108. {
  109. public:
  110. wxPGVIterator() { m_pIt = NULL; }
  111. wxPGVIterator( wxPGVIteratorBase* obj ) { m_pIt = obj; }
  112. ~wxPGVIterator() { UnRef(); }
  113. void UnRef() { if (m_pIt) m_pIt->DecRef(); }
  114. wxPGVIterator( const wxPGVIterator& it )
  115. {
  116. m_pIt = it.m_pIt;
  117. m_pIt->IncRef();
  118. }
  119. const wxPGVIterator& operator=( const wxPGVIterator& it )
  120. {
  121. UnRef();
  122. m_pIt = it.m_pIt;
  123. m_pIt->IncRef();
  124. return *this;
  125. }
  126. void Next() { m_pIt->Next(); }
  127. bool AtEnd() const { return m_pIt->m_it.AtEnd(); }
  128. wxPGProperty* GetProperty() const { return m_pIt->m_it.GetProperty(); }
  129. protected:
  130. wxPGVIteratorBase* m_pIt;
  131. };