Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.6 KiB

  1. /*
  2. * PropertySheet
  3. */
  4. #ifndef DUI_CORE_SHEET_H_INCLUDED
  5. #define DUI_CORE_SHEET_H_INCLUDED
  6. #pragma once
  7. namespace DirectUI
  8. {
  9. /*
  10. * PropertySheets are used as extensions to the unchangeable value expression used
  11. * for Specified value retrieval on Elements. They provide three main services:
  12. *
  13. * * The ability to describe conditional relationships (dependencies) on a per-class level
  14. * * Values can be overridden by setting a local value on the Element
  15. * * They can be described declaratively using a CSS-like grammar
  16. *
  17. * PropertySheets are a type of value expression (but limited). Thus, they provide
  18. * a way to change values of properties based on other property changes without hard coding
  19. * the logic within a derived class of Element (using OnPropertyChanged).
  20. *
  21. * Only properties with the "Cascade" flag may be placed in the body of a Rule. Properties
  22. * that should be marked as cascadable are those that need to be updated based on changes
  23. * of other properties, but shouldn't be assumed at compile-time what these relationships
  24. * are. Such properties include any property that drives painting code directly (color,
  25. * fonts, padding, etc.).
  26. */
  27. // Foreward declarations
  28. class Value;
  29. struct PropertyInfo;
  30. class Element;
  31. struct IClassInfo;
  32. struct DepRecs;
  33. class DeferCycle;
  34. ////////////////////////////////////////////////////////
  35. // Rule addition structures
  36. // Declaration PropertyInfo/Value tuple
  37. struct Decl
  38. {
  39. PropertyInfo* ppi; // Implicit index of Specified
  40. Value* pv;
  41. };
  42. // Single rule conditional (l-operand op r-operand): <PropertyInfo[RetrievalIndex]> <LogOp> <Value>
  43. struct Cond
  44. {
  45. PropertyInfo* ppi; // Implicit index of Retrieval index
  46. UINT nLogOp;
  47. Value* pv;
  48. };
  49. // PropertySheet Logical operations (nLogOp)
  50. #define PSLO_Equal 0
  51. #define PSLO_NotEqual 1
  52. ////////////////////////////////////////////////////////
  53. // Internal database structures
  54. // Conditional to value map
  55. struct CondMap
  56. {
  57. Cond* pConds; // NULL terminated
  58. Value* pv;
  59. UINT uSpecif;
  60. };
  61. // Dependent list, used for sheet scope and propertyinfo data (conditionals/dependencies)
  62. struct DepList
  63. {
  64. PropertyInfo** pDeps; // Implicit index of Specified
  65. UINT cDeps;
  66. };
  67. // Storage for property-specific information
  68. struct PIData : DepList
  69. {
  70. // Used for PropertyInfo[Specified] lookups. The PropertyInfo will have
  71. // a list of conditionals (sorted by specificity)
  72. CondMap* pCMaps;
  73. UINT cCMaps;
  74. };
  75. // Stored by _pDB, one record per class type
  76. struct Record
  77. {
  78. DepList ss; // Sheet scope
  79. PIData* ppid; // 0th property data
  80. };
  81. ////////////////////////////////////////////////////////
  82. // PropertySheet
  83. class PropertySheet
  84. {
  85. public:
  86. static HRESULT Create(OUT PropertySheet** ppSheet);
  87. void Destroy() { HDelete<PropertySheet>(this); }
  88. HRESULT AddRule(IClassInfo* pci, Cond* pConds, Decl* pDecls); // Conds and Decls must be NULL or NULL-terminating
  89. void MakeImmutable();
  90. Value* GetSheetValue(Element* pe, PropertyInfo* ppi);
  91. void GetSheetDependencies(Element* pe, PropertyInfo* ppi, DepRecs* pdr, DeferCycle* pdc, HRESULT* phr);
  92. void GetSheetScope(Element* pe, DepRecs* pdr, DeferCycle* pdc, HRESULT* phr);
  93. PropertySheet() { }
  94. HRESULT Initialize();
  95. virtual ~PropertySheet();
  96. private:
  97. Record* _pDB; // Array of per-class data
  98. IClassInfo** _pCIIdxMap; // Map _pDB indicies to actual IClassInfo
  99. UINT _uRuleId;
  100. DynamicArray<Cond*>* _pdaSharedCond;
  101. bool _fImmutable;
  102. };
  103. } // namespace DirectUI
  104. #endif // DUI_CORE_SHEET_H_INCLUDED