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.

169 lines
4.8 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #ifndef _INC_ACCWIZ_H
  3. #define _INC_ACCWIZ_H
  4. #include "schemes.h" // For SCHEMEDATALOCAL
  5. #include "resource.h"
  6. // Helper function
  7. void LoadArrayFromStringTable(int nIdString, int *rgnValues, int *pnCountValues);
  8. // Macros used to save debug info to/from the INI file
  9. // JMC: HACK - Default to '1' for options!!!!!!!!
  10. #define GET_SAVED_INT(xxx) xxx = GetPrivateProfileInt(__TEXT("Options"), __TEXT(#xxx), 1, __TEXT("AccWiz.ini"))
  11. #define PUT_SAVED_INT(xxx) wsprintf(sz, __TEXT("%i"), xxx);WritePrivateProfileString(__TEXT("Options"), __TEXT(#xxx), sz, __TEXT("AccWiz.ini"))
  12. // This class contains the general options for the whole wizard
  13. class CAccWizOptions
  14. {
  15. public:
  16. CAccWizOptions()
  17. {
  18. }
  19. ~CAccWizOptions()
  20. {
  21. }
  22. void InitAccWizOptions()
  23. {
  24. OSVERSIONINFO osvi;
  25. ZeroMemory(&osvi, sizeof(osvi));
  26. osvi.dwOSVersionInfoSize = sizeof(osvi);
  27. GetVersionEx(&osvi);
  28. m_bWin95 = (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
  29. m_nMinimalFontSize = -1; // This will be set by the welcome page
  30. ///////////////////////////////////////////////
  31. // Calculate globals that we need
  32. HDC hDC = GetDC(NULL);
  33. m_nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
  34. ReleaseDC(NULL, hDC);
  35. ///////////////////////////////////////////////
  36. // Get the default char set for fonts
  37. TCHAR szCharSet[20];
  38. if(LoadString(g_hInstDll,IDS_FONTCHARSET, szCharSet,sizeof(szCharSet)/sizeof(TCHAR))) {
  39. m_lfCharSet = (BYTE)_tcstoul(szCharSet,NULL,10);
  40. } else {
  41. m_lfCharSet = 0; // Default
  42. }
  43. ///////////////////////////////////////////////
  44. // Get the standard MS Sans Serif fonts
  45. // JMC: HACK - Free these resources
  46. int rgnStandardMSSansSerifFontSizes[] = {8, 10, 12, 14, 18, 24};
  47. LOGFONT lf;
  48. ZeroMemory(&lf, sizeof(lf));
  49. lf.lfCharSet = m_lfCharSet;
  50. LoadString(g_hInstDll, IDS_SYSTEMFONTNAME, lf.lfFaceName, ARRAYSIZE(lf.lfFaceName));
  51. for(int i=0;i<6;i++)
  52. {
  53. lf.lfHeight = 0 - (int)((float)m_nLogPixelsY * (float)rgnStandardMSSansSerifFontSizes[i]/ (float)72 + (float).5);
  54. m_rgnStdMSSansSerifFonts[i] = CreateFontIndirect(&lf);
  55. // Create underlined version
  56. lf.lfUnderline = 1;
  57. m_rgnStdMSSansSerifFonts[i + 6] = CreateFontIndirect(&lf);
  58. lf.lfUnderline = 0;
  59. }
  60. // Store away original non-client metrics
  61. // Get original metrics
  62. GetNonClientMetrics(&m_ncmOrig, &m_lfIconOrig);
  63. // Load original Wiz Scheme settings
  64. m_schemeOriginal.LoadOriginal();
  65. // Copy to the Preview scheme and to the current scheme
  66. m_schemePreview = m_schemeOriginal;
  67. m_schemeCurrent = m_schemeOriginal;
  68. // This is set by the welcome page, so that the second part knows to update it's check boxes.
  69. // The second page clears this flag
  70. m_bWelcomePageTouched = FALSE;
  71. // this is the default windows settings (for Win2K not necessarilly for Whistler)
  72. m_schemeWindowsDefault.SetToWindowsDefault();
  73. #ifdef _DEBUG
  74. m_schemeOriginal.Dump();
  75. #endif
  76. }
  77. void RestoreOriginalColorsToPreview()
  78. {
  79. memcpy(m_schemePreview.m_rgb, m_schemeOriginal.m_rgb, sizeof(m_schemePreview.m_rgb));
  80. }
  81. void ApplyPreview()
  82. {
  83. m_schemeCurrent.ApplyChanges(m_schemePreview);
  84. }
  85. void ApplyOriginal()
  86. {
  87. m_schemeCurrent.ApplyChanges(m_schemeOriginal, &m_ncmOrig, &m_lfIconOrig);
  88. }
  89. void ApplyWindowsDefault();
  90. BOOL m_bWelcomePageTouched;
  91. int m_nLogPixelsY;
  92. int m_nMinimalFontSize;
  93. HFONT GetClosestMSSansSerif(int nPointSize, BOOL bUnderlined = FALSE)
  94. {
  95. // For Underlined fonts, add '6' the the index
  96. int nOffset = bUnderlined?6:0;
  97. if(nPointSize <= 8)
  98. return m_rgnStdMSSansSerifFonts[0 + nOffset];
  99. else if(nPointSize <= 10)
  100. return m_rgnStdMSSansSerifFonts[1 + nOffset];
  101. else if(nPointSize <= 12)
  102. return m_rgnStdMSSansSerifFonts[2 + nOffset];
  103. else if(nPointSize <= 14)
  104. return m_rgnStdMSSansSerifFonts[3 + nOffset];
  105. else if(nPointSize <= 18)
  106. return m_rgnStdMSSansSerifFonts[4 + nOffset];
  107. return m_rgnStdMSSansSerifFonts[5];
  108. }
  109. void ReportChanges(HWND hwndChanges)
  110. {
  111. m_schemeCurrent.ReportChanges(m_schemeOriginal, hwndChanges);
  112. }
  113. BOOL m_bWin95;
  114. BYTE m_lfCharSet;
  115. WIZSCHEME m_schemePreview;
  116. WIZSCHEME m_schemeOriginal;
  117. protected:
  118. // Dialogs never modify these copies of the scheme
  119. WIZSCHEME m_schemeCurrent;
  120. WIZSCHEME m_schemeWindowsDefault;
  121. NONCLIENTMETRICS m_ncmOrig;
  122. LOGFONT m_lfIconOrig;
  123. HFONT m_rgnStdMSSansSerifFonts[6 * 2]; // 0-5 are for 8, 10, 12, 14, 18, 24. 6-11 are for the same things, but underlined
  124. friend class CWelcome2Pg; // TODO: HACK - This is only here to give CWelcome2Pg access to m_schemeCurrent
  125. };
  126. // This variable will be accessible to any derived wizard page.
  127. // It contains information specific to this application
  128. extern CAccWizOptions g_Options;
  129. VOID WINAPI AccWiz_RunDllA(HWND hwnd, HINSTANCE hInstance, LPSTR pszCmdLine, INT nCmdShow);
  130. VOID WINAPI AccWiz_RunDllW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, INT nCmdShow);
  131. #endif // _INC_ACCWIZ_H