clabout.c

来自「PGP8.0源码 请认真阅读您的文件包然后写出其具体功能」· C语言 代码 · 共 1,293 行 · 第 1/3 页

C
1,293
字号
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.
	
	CLabout.c - display "help about" dialog
	
	$Id: CLabout.c,v 1.75 2002/11/20 14:28:33 pbj Exp $
____________________________________________________________________________*/
#include "pgpPFLConfig.h"
#include "pgpUnicode.h"
#include "pgpUnicodeWin32.h"

#define LNABOUT 1

// project header files
#include "pgpclx.h"
#include "pgpBuild.h"

#if LNABOUT
#include "stdio.h"
#endif

// system header files
#include <shellapi.h>
#include <process.h>


#define DISPLAY_CREDITS		1
	
#define ADDWIDTH			0
#define ADDHEIGHT			0
#define NAGADDWIDTH			6
#define NAGADDHEIGHT		6
#define XINCREMENT			6
#define YINCREMENT			10
#define EDGEWIDTH			6

#define VERSIONPOSY			0.30
#define BETATEXTPOSY		0.40
#define NOLICENSEPOSY		0.38
#define NOLICENSETEXT1POSY	0.44
#define NOLICENSETEXT2POSY	0.73

#define LICENSEEPOSY		0.36
#define CORPPOSDELTAY		0.04
#define SEATSPOSDELTAY		0.06
#define EXPIREPOSDELTAY		0.06

#define LEFTCOLUMNLEFT		0.02
#define LEFTCOLUMNRIGHT		0.40
#define RIGHTCOLUMNLEFT		0.20
#define RIGHTCOLUMNRIGHT	0.50

#define FULLLENGTH			1.00

#define UPGRADEBUTTONXPOS	0.03
#define UPGRADEBUTTONYPOS	0.92

#define NAGBUTTONXPOS		0.58
#define NAGBUTTON1YPOS		0.21
#define NAGBUTTON2YPOS		0.52
#define NAGBUTTON3YPOS		0.62

#define NAGTEXTXPOS			0.05
#define NAGTEXTYPOS			0.10
#define NAGTEXTWIDTH		0.40
#define NAGTEXTHEIGHT		0.80
#define VERSIONXPOS			0.99
#define VERSIONYPOS			0.02

#define CONGRATSXPOS		0.25
#define CONGRATSYPOSMAN		0.60
#define CONGRATSYPOSAUTO	0.40

#define MINSCROLLYPOS		0.55
#define MAXSCROLLYPOS		0.85
#define SCROLLXPOS			0.79

#define TOPFADEZONE			18
#define BOTFADEZONE			18

#define TOPFADECOLOR		180
#define TOPFADECOLORRED		240
#define TOPFADECOLORBLUE	200
#define TOPFADECOLORGREEN	110

#define BOTFADECOLOR		200
#define BOTFADECOLORRED		235
#define BOTFADECOLORBLUE	210
#define BOTFADECOLORGREEN	145

#define REFRESH_TIMER		77
#if DISPLAY_CREDITS
#define REFRESH_TIME		40
#else
#define REFRESH_TIME		1000
#endif

#define	FONT_NORMAL			0
#define FONT_ITALIC			1
#define FONT_BOLD			2

#define BUTTON_X_OFFSET		12
#define BUTTON_Y_OFFSET		8

#define MAX_TEXT_LENGTH		32

typedef struct _DIALOGINFOSTRUCT {
	HWND			hWndParent;
	LPSTR			pszText;
	HBITMAP			hBitmapMain;
	COLORREF		crTextColor;
	COLORREF		crTextScrollColor;
	HPALETTE		hPaletteMain;
	BOOL			bFirstTime;
	BOOL			bRoundedButton;

	UINT			uXsize;
	UINT			uYsize;
	UINT			uXpos;
	UINT			uYpos;

	INT				iMinPos;
	INT				iMaxPos;
	INT				iScrollPos;
	INT				iTextIndex;

	HFONT			hfont;
	HFONT			hfontItalic;
	HFONT			hfontBold;
	INT				iRowHeight;
	INT				iTextXPos;

} DIALOGINFOSTRUCT, *PDIALOGINFOSTRUCT;

// external globals
extern HINSTANCE	g_hInst;

#if DISPLAY_CREDITS

// scrolling text
typedef struct {
	INT		iFont;
	CHAR	szText[MAX_TEXT_LENGTH];
} TEXTSTRUCT;

static TEXTSTRUCT	s_tsText[] = {
	{FONT_BOLD,		"Credits"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Engineering"},
	{FONT_NORMAL,	"David Allen"},
	{FONT_NORMAL,	"Bill Blanke"},
	{FONT_NORMAL,	"Jason Bobier"},
	{FONT_NORMAL,	"Jeff Cruikshank"},
	{FONT_NORMAL,	"Satya Das"},
	{FONT_NORMAL,	"Andrey Jivsov"},
	{FONT_NORMAL,	"Paul Johnson"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Engineering Management"},
	{FONT_NORMAL,	"Will Price"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Quality Engineering"},
	{FONT_NORMAL,	"Jim Agua"},
	{FONT_NORMAL,	"Sean McLean"},
	{FONT_NORMAL,	"Glen Sonnenberg"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Documentation"},
	{FONT_NORMAL,	"Scott Wilson"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Management"},
	{FONT_NORMAL,	"Steve Abbott"},
	{FONT_NORMAL,	"Jon Callas"},
	{FONT_NORMAL,	"Michael Doherty"},
	{FONT_NORMAL,	"Alex Doll"},
	{FONT_NORMAL,	"Phil Dunkelberger"},
	{FONT_NORMAL,	"Andrew Krcik"},
	{FONT_NORMAL,	"Spencer Snedecor"},
	{FONT_NORMAL,	"Stephan Somogyi"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Special Advisor"},
	{FONT_NORMAL,	"Philip Zimmermann"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Artwork"},
	{FONT_NORMAL,	"The Iconfactory"},
	{FONT_NORMAL,	""},
	{FONT_BOLD,		"Thanks"},
	{FONT_NORMAL,	"Doll Capital"},
	{FONT_NORMAL,	"Paul Ryan"},
	{FONT_NORMAL,	"Jeffrey Schiller"},
	{FONT_NORMAL,	"Stale Schumacher"},
	{FONT_NORMAL,	"Venrock Associates"},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""},
	{FONT_NORMAL,	""} };

#define NUM_TEXT_ROWS	(sizeof(s_tsText) / sizeof(TEXTSTRUCT))


//	___________________________________________________
//
//	Paint scrolling text

VOID
sPaintScrollingText (
		PDIALOGINFOSTRUCT	pdis,
		HWND				hwnd,
		HDC					hdc)
{
	HFONT		hFontOld;
	UINT		uTAOld;
	INT			iText, iYpos;
	INT			iColorRed, iColorBlue, iColorGreen;
	LPSTR		psz;
	HFONT		hfont;

	SetBkMode (hdc, TRANSPARENT);
	uTAOld = SetTextAlign (hdc, TA_CENTER);
	hFontOld = SelectObject (hdc, pdis->hfont);

	// scrolling text
	iYpos = pdis->iScrollPos;
	iText = pdis->iTextIndex;

	while (iYpos < pdis->iMaxPos)
	{
		psz = s_tsText[iText].szText;
		switch (s_tsText[iText].iFont) {
			case FONT_NORMAL :	hfont = pdis->hfont;		break;
			case FONT_ITALIC :	hfont = pdis->hfontItalic;	break;
			case FONT_BOLD :	hfont = pdis->hfontBold;	break;
		}
		SelectObject (hdc, hfont);

		iColorRed = GetRValue (pdis->crTextScrollColor);
		iColorBlue = GetBValue (pdis->crTextScrollColor);
		iColorGreen = GetGValue (pdis->crTextScrollColor);

		if (iYpos > (pdis->iMaxPos - BOTFADEZONE))
		{
			if (iYpos >= pdis->iMaxPos)
			{
				iColorRed = BOTFADECOLORRED;
				iColorBlue = BOTFADECOLORBLUE;
				iColorGreen = BOTFADECOLORGREEN;
			}
			else
			{
				iColorRed = (INT)((float)BOTFADECOLORRED + 
					(float)(iColorRed - BOTFADECOLORRED)*
					((float)(pdis->iMaxPos - iYpos) / (float)BOTFADEZONE));

				iColorBlue = (INT)((float)BOTFADECOLORBLUE + 
					(float)(iColorBlue - BOTFADECOLORBLUE)*
					((float)(pdis->iMaxPos - iYpos) / (float)BOTFADEZONE));

				iColorGreen = (INT)((float)BOTFADECOLORGREEN + 
					(float)(iColorGreen - BOTFADECOLORGREEN)*
					((float)(pdis->iMaxPos - iYpos) / (float)BOTFADEZONE));
			}
		}
		else if (iYpos < (pdis->iMinPos + TOPFADEZONE))
		{
			if (iYpos <= pdis->iMinPos)
			{
				iColorRed = TOPFADECOLORRED;
				iColorBlue = TOPFADECOLORBLUE;
				iColorGreen = TOPFADECOLORGREEN;
			}
			else
			{
				iColorRed = (INT)((float)TOPFADECOLORRED + 
					(float)(iColorRed - TOPFADECOLORRED)*
					((float)(iYpos - pdis->iMinPos) / (float)TOPFADEZONE));

				iColorBlue = (INT)((float)TOPFADECOLORBLUE + 
					(float)(iColorBlue - TOPFADECOLORBLUE)*
					((float)(iYpos - pdis->iMinPos) / (float)TOPFADEZONE));

				iColorGreen = (INT)((float)TOPFADECOLORGREEN + 
					(float)(iColorGreen - TOPFADECOLORGREEN)*
					((float)(iYpos - pdis->iMinPos) / (float)TOPFADEZONE));
			}
		}

		// draw text
		SetTextColor (hdc, RGB (iColorRed, iColorBlue, iColorGreen));
		TextOut (hdc, pdis->iTextXPos, iYpos, psz, lstrlen (psz));

		if (++iText >= NUM_TEXT_ROWS)
			iText = 0;

		iYpos += pdis->iRowHeight;
	}

	SetTextAlign (hdc, uTAOld);
	SelectObject (hdc, hFontOld);
}

#endif // DISPLAY_CREDITS

//	___________________________________________________
//
//	set the drawing rectangle based on window rect and scaling values

VOID
sSetDrawingRect (
		LPRECT	prcIn,
		double	fLeft,
		double	fTop,
		double	fRight,
		double	fBottom,
		LPRECT	prcOut)
{
	prcOut->left = (long)((prcIn->right-prcIn->left) * fLeft +
			prcIn->left +2);
	prcOut->top = (long)((prcIn->bottom-prcIn->top) * fTop +
			prcIn->top +2);
	prcOut->right = (long)((prcIn->right-prcIn->left) * fRight +
			prcIn->left +2);
	prcOut->bottom = (long)((prcIn->bottom-prcIn->top) * fBottom +
			prcIn->top +2);
}

//	___________________________________________________
//
//	Paint version info text

VOID
sPaintVersionInfo (
		PDIALOGINFOSTRUCT	pdis,
		HWND				hwnd,
		HDC					hdc,
		LPSTR				pszVersion)
{
	HFONT		hFontOld;
	CHAR		sz[256];
	RECT		rc, rcWindow;

	GetClientRect (hwnd, &rcWindow);
	SetBkMode (hdc, TRANSPARENT);
	SetTextAlign (hdc, TA_LEFT);

	SetTextColor (hdc, pdis->crTextColor);
	hFontOld = SelectObject (hdc, pdis->hfontBold);

	sSetDrawingRect (&rcWindow, 
			LEFTCOLUMNLEFT, VERSIONPOSY, 
			LEFTCOLUMNRIGHT, FULLLENGTH, 
			&rc);
	LoadString (g_hInst, IDS_VERSION, sz, sizeof(sz));
	DrawText (hdc, sz, lstrlen(sz), &rc, 
			DT_LEFT|DT_NOPREFIX);

	sSetDrawingRect (&rcWindow, 
			RIGHTCOLUMNLEFT, VERSIONPOSY, 
			RIGHTCOLUMNRIGHT, FULLLENGTH, 
			&rc);
	if (pszVersion)
		lstrcpy (sz, pszVersion);
	else
		lstrcpy (sz, PGPVERSIONSTRING);

	SelectObject (hdc, pdis->hfont);
	DrawText (hdc, sz, lstrlen(sz), &rc, 
			DT_LEFT|DT_NOPREFIX);

	SelectObject (hdc, hFontOld);
}

static void TMToSystemTime (
	struct tm*	ptm, 
	SYSTEMTIME* pst) 
{
	pst->wYear = ptm->tm_year + 1900;
	pst->wMonth = ptm->tm_mon + 1;
	pst->wDay = ptm->tm_mday;
	pst->wDayOfWeek = ptm->tm_wday;
	pst->wHour = ptm->tm_hour;
	pst->wMinute = ptm->tm_min;
	pst->wSecond = ptm->tm_sec;
	pst->wMilliseconds = 0;
}

//	___________________________________________________
//
//	Paint license info text

VOID
sPaintLicenseInfo (
		PDIALOGINFOSTRUCT	pdis,
		HWND				hwnd,
		HDC					hdc)
{
	HFONT		hFontOld;
	RECT		rc,rcWindow;
	CHAR		szString[512];
	CHAR		sz[128];
	INT			iDays;

	GetClientRect (hwnd, &rcWindow);
	SetBkMode (hdc, TRANSPARENT);
	SetTextAlign (hdc, TA_LEFT);
	szString[0] = '\0';

	SetTextColor (hdc, pdis->crTextColor);
	hFontOld = SelectObject (hdc, pdis->hfont);

#if !PGP_LICENSENUMBERS
#if PGP_BETA
	{
		time_t	timeEnd, timeNow;

		sSetDrawingRect (&rcWindow, 
				LEFTCOLUMNLEFT, BETATEXTPOSY, 
				RIGHTCOLUMNRIGHT, FULLLENGTH, 
				&rc);

		PGPlnBetaTimeOut (&timeEnd);
		time (&timeNow);

		iDays = (timeEnd-timeNow) / (60*60*24);

		if (iDays > 0)
		{
			LoadString (g_hInst, IDS_BETAEXPIRES, szString, sizeof(szString));
			wsprintf (sz, szString, iDays);
		}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?