windows-nt/Source/XPSP1/NT/shell/osshell/accessib/accwiz/accwiz.h
2020-09-26 16:20:57 +08:00

170 lines
4.8 KiB
C++

//Copyright (c) 1997-2000 Microsoft Corporation
#ifndef _INC_ACCWIZ_H
#define _INC_ACCWIZ_H
#include "schemes.h" // For SCHEMEDATALOCAL
#include "resource.h"
// Helper function
void LoadArrayFromStringTable(int nIdString, int *rgnValues, int *pnCountValues);
// Macros used to save debug info to/from the INI file
// JMC: HACK - Default to '1' for options!!!!!!!!
#define GET_SAVED_INT(xxx) xxx = GetPrivateProfileInt(__TEXT("Options"), __TEXT(#xxx), 1, __TEXT("AccWiz.ini"))
#define PUT_SAVED_INT(xxx) wsprintf(sz, __TEXT("%i"), xxx);WritePrivateProfileString(__TEXT("Options"), __TEXT(#xxx), sz, __TEXT("AccWiz.ini"))
// This class contains the general options for the whole wizard
class CAccWizOptions
{
public:
CAccWizOptions()
{
}
~CAccWizOptions()
{
}
void InitAccWizOptions()
{
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
m_bWin95 = (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
m_nMinimalFontSize = -1; // This will be set by the welcome page
///////////////////////////////////////////////
// Calculate globals that we need
HDC hDC = GetDC(NULL);
m_nLogPixelsY = GetDeviceCaps(hDC, LOGPIXELSY);
ReleaseDC(NULL, hDC);
///////////////////////////////////////////////
// Get the default char set for fonts
TCHAR szCharSet[20];
if(LoadString(g_hInstDll,IDS_FONTCHARSET, szCharSet,sizeof(szCharSet)/sizeof(TCHAR))) {
m_lfCharSet = (BYTE)_tcstoul(szCharSet,NULL,10);
} else {
m_lfCharSet = 0; // Default
}
///////////////////////////////////////////////
// Get the standard MS Sans Serif fonts
// JMC: HACK - Free these resources
int rgnStandardMSSansSerifFontSizes[] = {8, 10, 12, 14, 18, 24};
LOGFONT lf;
ZeroMemory(&lf, sizeof(lf));
lf.lfCharSet = m_lfCharSet;
LoadString(g_hInstDll, IDS_SYSTEMFONTNAME, lf.lfFaceName, ARRAYSIZE(lf.lfFaceName));
for(int i=0;i<6;i++)
{
lf.lfHeight = 0 - (int)((float)m_nLogPixelsY * (float)rgnStandardMSSansSerifFontSizes[i]/ (float)72 + (float).5);
m_rgnStdMSSansSerifFonts[i] = CreateFontIndirect(&lf);
// Create underlined version
lf.lfUnderline = 1;
m_rgnStdMSSansSerifFonts[i + 6] = CreateFontIndirect(&lf);
lf.lfUnderline = 0;
}
// Store away original non-client metrics
// Get original metrics
GetNonClientMetrics(&m_ncmOrig, &m_lfIconOrig);
// Load original Wiz Scheme settings
m_schemeOriginal.LoadOriginal();
// Copy to the Preview scheme and to the current scheme
m_schemePreview = m_schemeOriginal;
m_schemeCurrent = m_schemeOriginal;
// This is set by the welcome page, so that the second part knows to update it's check boxes.
// The second page clears this flag
m_bWelcomePageTouched = FALSE;
// this is the default windows settings (for Win2K not necessarilly for Whistler)
m_schemeWindowsDefault.SetToWindowsDefault();
#ifdef _DEBUG
m_schemeOriginal.Dump();
#endif
}
void RestoreOriginalColorsToPreview()
{
memcpy(m_schemePreview.m_rgb, m_schemeOriginal.m_rgb, sizeof(m_schemePreview.m_rgb));
}
void ApplyPreview()
{
m_schemeCurrent.ApplyChanges(m_schemePreview);
}
void ApplyOriginal()
{
m_schemeCurrent.ApplyChanges(m_schemeOriginal, &m_ncmOrig, &m_lfIconOrig);
}
void ApplyWindowsDefault();
BOOL m_bWelcomePageTouched;
int m_nLogPixelsY;
int m_nMinimalFontSize;
HFONT GetClosestMSSansSerif(int nPointSize, BOOL bUnderlined = FALSE)
{
// For Underlined fonts, add '6' the the index
int nOffset = bUnderlined?6:0;
if(nPointSize <= 8)
return m_rgnStdMSSansSerifFonts[0 + nOffset];
else if(nPointSize <= 10)
return m_rgnStdMSSansSerifFonts[1 + nOffset];
else if(nPointSize <= 12)
return m_rgnStdMSSansSerifFonts[2 + nOffset];
else if(nPointSize <= 14)
return m_rgnStdMSSansSerifFonts[3 + nOffset];
else if(nPointSize <= 18)
return m_rgnStdMSSansSerifFonts[4 + nOffset];
return m_rgnStdMSSansSerifFonts[5];
}
void ReportChanges(HWND hwndChanges)
{
m_schemeCurrent.ReportChanges(m_schemeOriginal, hwndChanges);
}
BOOL m_bWin95;
BYTE m_lfCharSet;
WIZSCHEME m_schemePreview;
WIZSCHEME m_schemeOriginal;
protected:
// Dialogs never modify these copies of the scheme
WIZSCHEME m_schemeCurrent;
WIZSCHEME m_schemeWindowsDefault;
NONCLIENTMETRICS m_ncmOrig;
LOGFONT m_lfIconOrig;
HFONT m_rgnStdMSSansSerifFonts[6 * 2]; // 0-5 are for 8, 10, 12, 14, 18, 24. 6-11 are for the same things, but underlined
friend class CWelcome2Pg; // TODO: HACK - This is only here to give CWelcome2Pg access to m_schemeCurrent
};
// This variable will be accessible to any derived wizard page.
// It contains information specific to this application
extern CAccWizOptions g_Options;
VOID WINAPI AccWiz_RunDllA(HWND hwnd, HINSTANCE hInstance, LPSTR pszCmdLine, INT nCmdShow);
VOID WINAPI AccWiz_RunDllW(HWND hwnd, HINSTANCE hInstance, LPWSTR pszCmdLine, INT nCmdShow);
#endif // _INC_ACCWIZ_H