Source code of Windows XP (NT5)
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.

222 lines
4.7 KiB

  1. /*--------------------------------------------------------------------------
  2. ctrlgrp.h
  3. Control group switcher
  4. Copyright (C) Microsoft Corporation, 1993 - 1997
  5. All rights reserved.
  6. Authors:
  7. matth Matthew F. Hillman, Microsoft
  8. History:
  9. 10/14/93 matth Created.
  10. 26 oct 95 garykac DBCS_FILE_CHECK
  11. --------------------------------------------------------------------------*/
  12. #ifndef _CTRLGRP_H
  13. #define _CTRLGRP_H
  14. /*
  15. #if defined(_DEBUG) && defined(INLINE)
  16. #undef THIS_FILE
  17. extern char BASED_CODE CTRLGRP_H[];
  18. #define THIS_FILE CTRLGRP_H
  19. #endif
  20. */
  21. #define INLINE inline
  22. #define fTrue TRUE
  23. #define fFalse FALSE
  24. #define g_fWin4 FALSE
  25. #define g_fWinNT TRUE
  26. #define EDIT_NORMAL_WIDE L"EDIT"
  27. class RGControlInfo;
  28. class CGControlInfo
  29. {
  30. friend class RGControlInfo;
  31. friend class ControlGroup;
  32. public:
  33. CGControlInfo();
  34. CGControlInfo(const CGControlInfo & cgciCopy);
  35. ~CGControlInfo();
  36. //DeclareStdDebugMembers()
  37. HWND m_hwnd;
  38. };
  39. //DeclareGenericArrayBegin(RGControlInfo, CGControlInfo, 10)
  40. // DeclareGenericArrayAccessors(RGControlInfo, CGControlInfo)
  41. // DeclareGenericArrayConstructDestruct(RGControlInfo, CGControlInfo)
  42. // DeclareGenericArrayDebug(RGControlInfo, CGControlInfo)
  43. //DeclareGenericArrayEnd
  44. typedef CArray<CGControlInfo, CGControlInfo> tempRGControlInfo;
  45. class RGControlInfo : public tempRGControlInfo
  46. {
  47. };
  48. class ControlGroup : public CObject
  49. {
  50. public:
  51. // INITIALIZATION
  52. ControlGroup(int idGroup, int idd, void (*pfnInit)(CWnd * pwndParent));
  53. ~ControlGroup();
  54. //DeclareStdDebugMembers()
  55. public:
  56. // APIS
  57. void LoadGroup(CWnd * pwndParent, int xOffset, int yOffset);
  58. void UnloadGroup();
  59. void ShowGroup(HDWP& hdwp, BOOL fShow = fTrue, CWnd *pwndParent = NULL);
  60. void EnableGroup(BOOL fEnable);
  61. int IDGroup() const;
  62. BOOL FLoaded() const;
  63. BOOL FVisible() const;
  64. int CControls() const;
  65. void AddControl(HWND hwnd);
  66. void RemoveControl(HWND hwnd);
  67. private:
  68. static void MaskAccelerator(HWND hwnd, BOOL fMask);
  69. #ifdef WIN16
  70. void LoadWin16DialogResource(HWND hDlg, BYTE FAR *lpDlgRes, int x, int y);
  71. #else
  72. void LoadWin32DialogResource(HWND hDlg, BYTE FAR *lpDlgRes, int x, int y);
  73. #endif
  74. int m_idGroup;
  75. int m_idd;
  76. void (*m_pfnInit)(CWnd * pwndParent);
  77. RGControlInfo m_rgControls;
  78. BOOL m_fLoaded;
  79. BOOL m_fVisible;
  80. };
  81. typedef ControlGroup * PControlGroup;
  82. //DeclareGenericArrayBegin(RGPControlGroup, PControlGroup, 10)
  83. // DeclareGenericArrayAccessors(RGPControlGroup, PControlGroup)
  84. // DeclareGenericArrayDebug(RGPControlGroup, PControlGroup)
  85. // long GroupIndex(int idGroup) const;
  86. // PControlGroup PGroup(int idGroup) const;
  87. //DeclareGenericArrayEnd
  88. typedef CArray<PControlGroup, PControlGroup> tempRGPControlGroup;
  89. class RGPControlGroup : public tempRGPControlGroup
  90. {
  91. public:
  92. long GroupIndex(int idGroup) const;
  93. PControlGroup PGroup(int idGroup) const;
  94. };
  95. enum
  96. {
  97. cgsPreCreateAll, cgsCreateOnDemand, cgsCreateDestroyOnDemand
  98. };
  99. class ControlGroupSwitcher : public CObject
  100. {
  101. public:
  102. // INITIALIZATION
  103. ControlGroupSwitcher();
  104. void Create(CWnd * pwndParent, int idcAnchor, int cgsStyle);
  105. ~ControlGroupSwitcher();
  106. //DeclareStdDebugMembers();
  107. public:
  108. // APIS
  109. void AddGroup(int idGroup, int idd, void (*pfnInit)(CWnd * pwndParent));
  110. void RemoveGroup(int idGroup);
  111. void ShowGroup(int idGroup);
  112. int GetCurrentGroupID() const;
  113. void AddControlToGroup(int idGroup, HWND hwnd);
  114. void RemoveControlFromGroup(int idGroup, HWND hwnd);
  115. void EnableGroup(int idGroup, BOOL fEnable);
  116. private:
  117. void ComputeAnchorOffsets();
  118. RGPControlGroup m_rgpGroups;
  119. int m_iGroup;
  120. CWnd * m_pwndParent;
  121. int m_cgsStyle;
  122. int m_idcAnchor;
  123. int m_xOffset;
  124. int m_yOffset;
  125. };
  126. #ifdef INLINE
  127. INLINE CGControlInfo::CGControlInfo()
  128. : m_hwnd(NULL)
  129. {
  130. }
  131. INLINE CGControlInfo::CGControlInfo(const CGControlInfo & cgciCopy)
  132. : m_hwnd(cgciCopy.m_hwnd)
  133. {
  134. }
  135. INLINE CGControlInfo::~CGControlInfo()
  136. {
  137. //$ REVIEW: Don't destroy windows -- probably already gone (like in dlg)
  138. // if (m_hwnd)
  139. // ::DestroyWindow(m_hwnd);
  140. }
  141. INLINE int ControlGroup::IDGroup() const
  142. {
  143. return m_idGroup;
  144. }
  145. INLINE BOOL ControlGroup::FLoaded() const
  146. {
  147. return m_fLoaded;
  148. }
  149. INLINE BOOL ControlGroup::FVisible() const
  150. {
  151. return m_fVisible;
  152. }
  153. INLINE BOOL ControlGroup::CControls() const
  154. {
  155. Assert(FLoaded());
  156. return (int)m_rgControls.GetSize();
  157. }
  158. INLINE PControlGroup RGPControlGroup::PGroup(int idGroup) const
  159. {
  160. return GetAt(GroupIndex(idGroup));
  161. }
  162. INLINE int ControlGroupSwitcher::GetCurrentGroupID() const
  163. {
  164. return m_iGroup;
  165. }
  166. INLINE void ControlGroupSwitcher::AddControlToGroup(int idGroup, HWND hwnd)
  167. {
  168. m_rgpGroups.PGroup(idGroup)->AddControl(hwnd);
  169. }
  170. INLINE void ControlGroupSwitcher::RemoveControlFromGroup(int idGroup,
  171. HWND hwnd)
  172. {
  173. m_rgpGroups.PGroup(idGroup)->RemoveControl(hwnd);
  174. }
  175. #endif // INLINE
  176. #endif // _CTRLGRP_H