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.

240 lines
5.8 KiB

  1. //
  2. // cuischem.cpp
  3. // = UIF scheme implementation =
  4. //
  5. #include "private.h"
  6. #include "cuisys.h"
  7. //
  8. // gloval variables
  9. //
  10. static class CUIFSystemInfo *vpSysInfo = NULL;
  11. //
  12. // misc def
  13. //
  14. #define COLOR_WHITE RGB( 0xFF, 0xFF, 0xFF )
  15. #define COLOR_BLACK RGB( 0x00, 0x00, 0x00 )
  16. /*=============================================================================*/
  17. /* */
  18. /* C U I F S Y S T E M M E T R I C */
  19. /* */
  20. /*=============================================================================*/
  21. //
  22. // CUIFSystemInfo
  23. // = system info =
  24. //
  25. class CUIFSystemInfo
  26. {
  27. public:
  28. CUIFSystemInfo( void )
  29. {
  30. m_OSVerInfo.dwMajorVersion = 4;
  31. m_OSVerInfo.dwMinorVersion = 0;
  32. m_OSVerInfo.dwBuildNumber = 0;
  33. m_OSVerInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
  34. m_cBitsPixelScreen = 8;
  35. m_fHighContrast = FALSE;
  36. m_fHighContrastMenus = FALSE;
  37. }
  38. ~CUIFSystemInfo( void )
  39. {
  40. }
  41. void Initialize( void )
  42. {
  43. GetOSVersion();
  44. GetSystemMetrics();
  45. }
  46. void Update( void )
  47. {
  48. GetSystemMetrics();
  49. }
  50. __inline DWORD GetOSPlatformId( void )
  51. {
  52. return m_OSVerInfo.dwPlatformId;
  53. }
  54. __inline DWORD GetOSMajorVersion( void )
  55. {
  56. return m_OSVerInfo.dwMajorVersion;
  57. }
  58. __inline DWORD GetOSMinorVersion( void )
  59. {
  60. return m_OSVerInfo.dwMinorVersion;
  61. }
  62. __inline int GetBitsPixelScreen( void )
  63. {
  64. return m_cBitsPixelScreen;
  65. }
  66. __inline BOOL FHighContrast( void )
  67. {
  68. return m_fHighContrast;
  69. }
  70. __inline BOOL FHighContrastMenus( void )
  71. {
  72. return m_fHighContrastMenus;
  73. }
  74. protected:
  75. OSVERSIONINFO m_OSVerInfo;
  76. int m_cBitsPixelScreen;
  77. BOOL m_fHighContrast;
  78. BOOL m_fHighContrastMenus;
  79. void GetOSVersion( void )
  80. {
  81. m_OSVerInfo.dwOSVersionInfoSize = sizeof(m_OSVerInfo);
  82. GetVersionEx( &m_OSVerInfo );
  83. }
  84. void GetSystemMetrics( void )
  85. {
  86. HDC hDC = GetDC( NULL );
  87. COLORREF crBtnText;
  88. COLORREF crBtnFace;
  89. HIGHCONTRAST hicntr;
  90. // device caps
  91. m_cBitsPixelScreen = GetDeviceCaps( hDC, BITSPIXEL );
  92. // system paramater info
  93. MemSet( &hicntr, 0, sizeof(HIGHCONTRAST) );
  94. hicntr.cbSize = sizeof(HIGHCONTRAST);
  95. SystemParametersInfo( SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hicntr, 0 );
  96. m_fHighContrast = ((hicntr.dwFlags & HCF_HIGHCONTRASTON) != 0);
  97. // misc
  98. crBtnText = GetSysColor( COLOR_BTNTEXT );
  99. crBtnFace = GetSysColor( COLOR_BTNFACE );
  100. m_fHighContrastMenus = (m_fHighContrast ||
  101. ((crBtnText == COLOR_BLACK) && (crBtnFace == COLOR_WHITE)) ||
  102. ((crBtnText == COLOR_WHITE) && (crBtnFace == COLOR_BLACK)));
  103. // finished
  104. ReleaseDC( NULL, hDC );
  105. }
  106. };
  107. /*=============================================================================*/
  108. /* */
  109. /* E X P O R T E D F U N C T I O N S */
  110. /* */
  111. /*=============================================================================*/
  112. /* I N I T U I F S Y S */
  113. /*------------------------------------------------------------------------------
  114. ------------------------------------------------------------------------------*/
  115. void InitUIFSys( void )
  116. {
  117. if (vpSysInfo = new CUIFSystemInfo())
  118. vpSysInfo->Initialize();
  119. }
  120. /* D O N E U I F S Y S */
  121. /*------------------------------------------------------------------------------
  122. ------------------------------------------------------------------------------*/
  123. void DoneUIFSys( void )
  124. {
  125. if (vpSysInfo != NULL) {
  126. delete vpSysInfo;
  127. vpSysInfo = NULL;
  128. }
  129. }
  130. /* U P D A T E U I F S Y S */
  131. /*------------------------------------------------------------------------------
  132. ------------------------------------------------------------------------------*/
  133. void UpdateUIFSys( void )
  134. {
  135. if (vpSysInfo != NULL) {
  136. vpSysInfo->Update();
  137. }
  138. }
  139. /* U I F I S W I N D O W S N T */
  140. /*------------------------------------------------------------------------------
  141. ------------------------------------------------------------------------------*/
  142. BOOL UIFIsWindowsNT( void )
  143. {
  144. if (vpSysInfo != NULL) {
  145. return (vpSysInfo->GetOSPlatformId() == VER_PLATFORM_WIN32_NT);
  146. }
  147. else {
  148. return FALSE;
  149. }
  150. }
  151. /* U I F I S L O W C O L O R */
  152. /*------------------------------------------------------------------------------
  153. ------------------------------------------------------------------------------*/
  154. BOOL UIFIsLowColor( void )
  155. {
  156. if (vpSysInfo != NULL) {
  157. return (vpSysInfo->GetBitsPixelScreen() <= 8);
  158. }
  159. else {
  160. return TRUE;
  161. }
  162. }
  163. /* U I F I S H I G H C O N T R A S T */
  164. /*------------------------------------------------------------------------------
  165. ------------------------------------------------------------------------------*/
  166. BOOL UIFIsHighContrast( void )
  167. {
  168. if (vpSysInfo != NULL) {
  169. return vpSysInfo->FHighContrastMenus(); // use FHighContrastMenus, not FHighContrast
  170. }
  171. else {
  172. return FALSE;
  173. }
  174. }