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.

226 lines
5.6 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: uiglobals.h
  3. //
  4. // Desc: CUIGlobals is a class that packs and holds most information
  5. // relevent to a UI session. Many classes make reference to
  6. // CUIGlobals all the time.
  7. //
  8. // CPaintHelper encapsulates GDI calls, simplifying GDI operations.
  9. //
  10. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  11. //-----------------------------------------------------------------------------
  12. #ifndef __UIGLOBALS_H__
  13. #define __UIGLOBALS_H__
  14. #include "uielements.h"
  15. struct UIELEMENTINFO {
  16. UIELEMENT eElement;
  17. UIFONT eFont;
  18. UIBRUSH eBrush;
  19. UIPEN ePen;
  20. UICOLOR eText, eBk;
  21. };
  22. struct UIFONTINFO {
  23. UIFONT eFont;
  24. LPCTSTR lfFaceName;
  25. int nPointSize;
  26. BOOL bBold;
  27. HGDIOBJ hFont;
  28. };
  29. struct UIBRUSHINFO {
  30. UIBRUSH eBrush;
  31. UICOLOR eColor;
  32. HGDIOBJ hBrush;
  33. HGDIOBJ hPen;
  34. };
  35. struct UIPENINFO {
  36. UIPEN ePen;
  37. int fnPenStyle;
  38. int nWidth;
  39. UICOLOR eColor;
  40. HGDIOBJ hPen;
  41. };
  42. struct UICOLORINFO {
  43. UICOLOR eColor;
  44. COLORREF rgb;
  45. };
  46. enum UIRECTTYPE {
  47. UIR_OUTLINE,
  48. UIR_NORMAL,
  49. UIR_SOLID,
  50. };
  51. #define UIG_PARAMS_DEFINE \
  52. DWORD dwFlags, \
  53. LPCWSTR wszUserNames, \
  54. DWORD dwNumAcFor, \
  55. LPDIACTIONFORMATW lpAcFor, \
  56. LPDICOLORSET lpDIColorSet, \
  57. IUnknown FAR *lpSurface, \
  58. LPDICONFIGUREDEVICESCALLBACK lpCallback, \
  59. LPVOID pvRefData
  60. #define UIG_PARAMS_DEFINE_PASS \
  61. dwFlags, \
  62. wszUserNames, \
  63. dwNumAcFor, \
  64. lpAcFor, \
  65. lpDIColorSet, \
  66. lpSurface, \
  67. lpCallback, \
  68. pvRefData
  69. class CUIGlobals
  70. {
  71. public:
  72. CUIGlobals(UIG_PARAMS_DEFINE);
  73. ~CUIGlobals();
  74. // UI Variables/States/Etc...
  75. public:
  76. HRESULT GetInitResult() {return m_hrInit;}
  77. HINSTANCE GetInstance() {return m_hInst;}
  78. LPDIRECTINPUT8W GetDI();
  79. int GetUserNameIndex(LPCWSTR);
  80. int GetNumUserNames();
  81. LPCWSTR GetUserName(int i);
  82. // GetSurface should not be used as only IDirect3DSurface8 should be used. Instead, use GetSurface3D.
  83. IDirectDrawSurface *GetSurface(); // must release when done with returned surface (it's addref'd before returned)
  84. IDirect3DSurface8 *GetSurface3D(); // must release when done with returned surface (it's addref'd before returned)
  85. LPDICONFIGUREDEVICESCALLBACK GetCallback() {return m_lpCallback;}
  86. LPVOID GetRefData() {return m_pvRefData;}
  87. //@@BEGIN_MSINTERNAL
  88. #ifdef DDKBUILD
  89. BOOL QueryAllowEditLayout() { return m_bAllowEditLayout; }
  90. #endif
  91. //@@END_MSINTERNAL
  92. DWORD GetFlags() {return m_dwFlags;}
  93. BOOL IsFlagSet(DWORD dwFlag) {return AreFlagsSet(dwFlag);}
  94. BOOL AreFlagsSet(DWORD dwFlags) {return (m_dwFlags & dwFlags) == dwFlags;}
  95. BOOL InEditMode() {return IsFlagSet(DICD_EDIT);}
  96. const DIACTIONFORMATW &RefMasterAcFor(int i);
  97. int GetNumMasterAcFors() {return m_MasterAcForArray.GetSize();}
  98. const DICOLORSET &GetColorSet() const { return m_ColorSet; }
  99. void SetFinalResult(HRESULT);
  100. HRESULT GetFinalResult();
  101. private:
  102. HRESULT Init(UIG_PARAMS_DEFINE);
  103. void Dump();
  104. HRESULT m_hrInit;
  105. HRESULT m_hrFinalResult;
  106. BOOL InitColorsAndTablesAndObjects(LPDICOLORSET lpDIColorSet);
  107. BOOL IsValidUserIndex(int i);
  108. BOOL IsValidMasterAcForIndex(int i);
  109. HRESULT InitMasterAcForArray(const DIACTIONFORMATW *af, int n);
  110. void ClearMasterAcForArray();
  111. HINSTANCE m_hInst;
  112. LPDIRECTINPUT8W m_lpDI;
  113. DWORD m_dwFlags;
  114. LPCWSTR m_wszUserNames;
  115. CArray<DIACTIONFORMATW, DIACTIONFORMATW &> m_MasterAcForArray;
  116. BOOL m_bUseColorSet;
  117. DICOLORSET m_ColorSet;
  118. void SetTableColor(UICOLOR, COLORREF);
  119. IDirectDrawSurface *m_pSurface;
  120. IDirect3DSurface8 *m_pSurface3D;
  121. LPDICONFIGUREDEVICESCALLBACK m_lpCallback;
  122. LPVOID m_pvRefData;
  123. BOOL m_bAllowEditLayout;
  124. // UI Elements...
  125. public:
  126. UIELEMENTINFO *GetElementInfo(UIELEMENT);
  127. UIFONTINFO *GetFontInfo(UIFONT);
  128. UIBRUSHINFO *GetBrushInfo(UIBRUSH);
  129. UIPENINFO *GetPenInfo(UIPEN);
  130. UICOLORINFO *GetColorInfo(UICOLOR);
  131. HGDIOBJ GetFont(UIELEMENT);
  132. HGDIOBJ GetFont(UIFONT);
  133. HGDIOBJ GetBrush(UIELEMENT);
  134. HGDIOBJ GetBrush(UIBRUSH);
  135. HGDIOBJ GetPen(UIELEMENT);
  136. HGDIOBJ GetPen(UIBRUSH);
  137. HGDIOBJ GetPen(UIPEN);
  138. COLORREF GetBrushColor(UIELEMENT);
  139. COLORREF GetPenColor(UIELEMENT);
  140. COLORREF GetTextColor(UIELEMENT);
  141. COLORREF GetBkColor(UIELEMENT);
  142. COLORREF GetColor(UIBRUSH);
  143. COLORREF GetColor(UIPEN);
  144. COLORREF GetColor(UICOLOR);
  145. void DeleteObjects();
  146. void CreateObjects();
  147. void RecreateObjects();
  148. private:
  149. BOOL InitTables();
  150. void ClearTables();
  151. UIELEMENTINFO *m_pElement;
  152. int m_nElements;
  153. UIFONTINFO *m_pFont;
  154. int m_nFonts;
  155. UIBRUSHINFO *m_pBrush;
  156. int m_nBrushes;
  157. UIPENINFO *m_pPen;
  158. int m_nPens;
  159. UICOLORINFO *m_pColor;
  160. int m_nColors;
  161. };
  162. class CPaintHelper
  163. {
  164. public:
  165. CPaintHelper(CUIGlobals &uig, HDC hDC);
  166. ~CPaintHelper();
  167. CUIGlobals &m_uig;
  168. HDC &m_hDC;
  169. void SetElement(UIELEMENT eElement);
  170. void SetFont(UIFONT eFont);
  171. void SetBrush(UIBRUSH eBrush);
  172. void SetPen(UIPEN ePen);
  173. void SetText(UICOLOR eText, UICOLOR eBk = UIC_LAST);
  174. BOOL LineTo(SPOINT p) {return LineTo(p.x, p.y);}
  175. BOOL LineTo(int x, int y);
  176. BOOL MoveTo(SPOINT p, SPOINT *last = NULL) {return MoveTo(p.x, p.y, last);}
  177. BOOL MoveTo(int x, int y, SPOINT *last = NULL);
  178. BOOL Rectangle(SRECT r, UIRECTTYPE eType = UIR_NORMAL);
  179. BOOL Rectangle(int l, int t, int r, int b, UIRECTTYPE eType = UIR_NORMAL)
  180. {SRECT s(l,t,r,b); return Rectangle(s, eType);}
  181. private:
  182. HDC m_priv_hDC;
  183. HGDIOBJ m_hOldFont, m_hOldBrush, m_hOldPen;
  184. BOOL m_bOldFont, m_bOldBrush, m_bOldPen;
  185. COLORREF m_oldtextcolor, m_oldbkcolor;
  186. int m_oldbkmode;
  187. UIFONT m_eFont;
  188. UIBRUSH m_eBrush;
  189. UIPEN m_ePen;
  190. UICOLOR m_eText, m_eBk;
  191. };
  192. #endif //__UIGLOBALS_H__