PropertyPageBase.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #ifndef __PropertyPageBase_h_
  2. #define __PropertyPageBase_h_
  3. /////////////////////////////////////////////////////////////////////////////
  4. // PropertyPageBase.h | Declaration of the TCPropertyPageBase class.
  5. #pragma warning(disable: 4786)
  6. #include <vector>
  7. #include <map>
  8. #include <set>
  9. #include <comdef.h>
  10. #include <typeinfo.h>
  11. #include "..\TCLib\AdviseHolder.h"
  12. #include "InsidePropPage.h"
  13. #include "PageEntry.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Description: Provides the advanced functionality of TCPropertyPageImpl.
  16. //
  17. // TCPropertyPageBase serves as the base class of TCPropertyPageImpl. Since
  18. // that class is a template, the portions of functionality that are not
  19. // affected by the template parameters are implemented in this class to avoid
  20. // duplicated code generation. See TCPropertyPageImpl for more information.
  21. //
  22. // See Also: TCPropertyPageImpl
  23. class ATL_NO_VTABLE TCPropertyPageBase
  24. {
  25. // Group=Types
  26. public:
  27. typedef std::map<UINT, XInsidePage*> CPageMap;
  28. typedef CPageMap::iterator CPageIterator;
  29. typedef std::map<UINT, CPageMap*> CPageGroupMap;
  30. typedef CPageGroupMap::iterator CPageGroupIterator;
  31. typedef std::map<IConnectionPointContainer*, TCAdviseHolder> CAdviseMap;
  32. typedef CAdviseMap::iterator CAdviseIterator;
  33. typedef std::vector<IUnknown*> CUnkVector;
  34. typedef CUnkVector::iterator CUnkIterator;
  35. typedef std::map<IID, CUnkVector> CUnkVectorMap;
  36. // Group=Construction / Destruction
  37. public:
  38. TCPropertyPageBase();
  39. virtual ~TCPropertyPageBase();
  40. // Group=Attributes
  41. public:
  42. TCInsidePropPage* GetInsidePage(UINT idCtrl);
  43. DWORD GetInsidePageData(UINT idCtrl);
  44. LPCTSTR GetInsidePageText(UINT idCtrl);
  45. bool GetDirtyInsidePage(UINT idCtrl);
  46. void SetDirtyInsidePage(UINT idCtrl, bool bDirty);
  47. TCInsidePropPage* GetInsidePageOfGroup(UINT idGroup, DWORD dw);
  48. LPCTSTR GetInsidePageOfGroupText(UINT idGroup, DWORD dw);
  49. TCInsidePropPage* GetVisiblePageOfGroup(UINT idGroup);
  50. bool GetDirtyInsidePageOfGroup(UINT idGroup, DWORD dw);
  51. void SetDirtyInsidePageOfGroup(UINT idGroup, DWORD dw, bool bDirty);
  52. // Group=Operations
  53. public:
  54. bool ShowInsidePage(UINT idCtrl);
  55. bool HideInsidePage(UINT idCtrl);
  56. bool ShowInsidePageOfGroup(UINT idGroup, DWORD dw);
  57. bool HideInsidePageOfGroup(UINT idGroup, DWORD dw);
  58. // Group=Diagnostic Overrides
  59. protected:
  60. #ifdef _DEBUG
  61. virtual LPCSTR TypeName() = 0;
  62. #endif
  63. // Group=Overrides
  64. protected:
  65. virtual bool OnInitDialog();
  66. virtual UINT GetInsidePageTable(const XInsidePageEntry** ppTable,
  67. UINT iTable);
  68. virtual HWND GetPageWindow() = 0;
  69. virtual IUnknown* GetPageUnknown() = 0;
  70. virtual bool IsObjectKnown(IUnknown* punk) = 0;
  71. virtual void UpdateFields(DISPID dispid = DISPID_UNKNOWN) = 0;
  72. virtual void OnSetAllAdvises(ULONG cObjects, IUnknown** ppUnk);
  73. virtual void OnClearAllAdvises();
  74. // Group=Implementation
  75. protected:
  76. bool CreateInsidePage(XInsidePage* pPage, bool bOfGroup);
  77. void CreateInsidePages();
  78. void DestroyInsidePages();
  79. void DestroyInsidePageMap(CPageMap* pmap);
  80. XInsidePage* _GetInsidePage(UINT idCtrl);
  81. XInsidePage* _GetInsidePageOfGroup(UINT idGroup, DWORD dw);
  82. HRESULT SetObjects(ULONG& cObjectsDest, IUnknown**& ppUnkDest,
  83. ULONG cObjects, IUnknown** ppUnk);
  84. HRESULT SetObjectsOfInsidePages(ULONG cObjects, IUnknown** ppUnk);
  85. void SaveObjectsForInsidePages(ULONG cObjects, IUnknown** ppUnk);
  86. HRESULT SetObjectsToInsidePage(TCInsidePropPage*);
  87. HRESULT ApplyToInsidePages();
  88. void ReleaseObjectsForInsidePages();
  89. void ReleaseSupportedInterfaces();
  90. void SetAllAdvises(ULONG cObjects, IUnknown** ppUnk);
  91. IConnectionPointContainer* SetAdvises(IUnknown* punk, IUnknown* punkThis);
  92. void ClearAllAdvises();
  93. // Group=Message Handlers
  94. public:
  95. void OnInitDialogHandler(ULONG cObjects, IUnknown** ppUnk);
  96. LRESULT OnChangedHandler(UINT, WPARAM, LPARAM, BOOL&);
  97. LRESULT OnNcDestroyHandler(UINT, WPARAM, LPARAM, BOOL&);
  98. // Group=Data Members
  99. protected:
  100. // Specifies the current sub-table in the embedded property page map.
  101. UINT m_iTable;
  102. // Contains the embedded property page instance, indexed by ID.
  103. CPageMap m_mapPages;
  104. // Contains the embedded property page groups, indexed by ID.
  105. CPageGroupMap m_mapPageGroups;
  106. // Contains the *IUnknown* pointers passed to *IPropertyPage::SetObects*.
  107. CUnkVector m_vecForInsidePages;
  108. // Contains advisory connections to the objects being viewed/edited,
  109. // indexed by *IConnectionPointContainer* pointer.
  110. CAdviseMap m_mapAdvise;
  111. // Contains arrays of *IUnknown* pointers that are QI'd to the associated
  112. // *IID*.
  113. CUnkVectorMap m_mapInterfaces;
  114. // Indicates that processing is nested within the OnInitDialogHandler
  115. // method.
  116. bool m_bInitializing : 1;
  117. // Indicates that processing is nested within the UpdateFields method.
  118. bool m_bUpdating : 1;
  119. };
  120. /////////////////////////////////////////////////////////////////////////////
  121. // Group=Implementation
  122. /////////////////////////////////////////////////////////////////////////////
  123. // Description: Disconnects all advisory connections.
  124. //
  125. // This method is used by the implementation to disconnect all advisory
  126. // connections made on the set of objects being viewed/edited.
  127. //
  128. // Prior to disconnecting the advisory connections, the OnClearAllAdvises
  129. // virtual override is called to allow a derived class to disconnect any
  130. // connections specific to that class.
  131. //
  132. // See Also: TCPropertyPageBase::OnClearAllAdvises,
  133. // TCPropertyPageBase::SetAllAdvises
  134. inline void TCPropertyPageBase::ClearAllAdvises()
  135. {
  136. // Allow derived classes to clear advises
  137. OnClearAllAdvises();
  138. // Clearing the map will do automatic cleanup of advise objects
  139. m_mapAdvise.clear();
  140. }
  141. /////////////////////////////////////////////////////////////////////////////
  142. #endif //__PropertyPageBase_h_