2007-01-27 14:53:18 +00:00
|
|
|
/*
|
2007-01-29 23:35:31 +00:00
|
|
|
* PROJECT: ReactOS Desktop Control Panel
|
2007-01-27 14:53:18 +00:00
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2011-11-29 14:55:58 +00:00
|
|
|
* FILE: dll/cpl/desk/preview.c
|
2007-01-27 14:53:18 +00:00
|
|
|
* PURPOSE: Draws the preview control
|
2007-03-10 21:25:03 +00:00
|
|
|
* COPYRIGHT: Copyright 2006, 2007 Eric Kohl
|
2007-01-27 14:53:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "desk.h"
|
|
|
|
|
|
|
|
static const TCHAR szPreviewWndClass[] = TEXT("PreviewWndClass");
|
|
|
|
|
|
|
|
typedef struct _PREVIEW_DATA
|
|
|
|
{
|
2013-04-21 14:36:57 +00:00
|
|
|
HDC hdcPreview;
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
HWND hwndParent;
|
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
COLOR_SCHEME Scheme;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
HBRUSH hbrScrollbar;
|
2007-03-10 21:25:03 +00:00
|
|
|
HBRUSH hbrDesktop;
|
|
|
|
HBRUSH hbrWindow;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
INT cxEdge;
|
|
|
|
INT cyEdge;
|
|
|
|
|
2007-01-29 23:35:31 +00:00
|
|
|
INT cySizeFrame;
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
INT cyCaption;
|
2007-09-29 18:28:45 +00:00
|
|
|
INT cyBorder;
|
2007-01-29 23:35:31 +00:00
|
|
|
INT cyMenu;
|
|
|
|
INT cxScrollbar;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
RECT rcDesktop;
|
|
|
|
RECT rcInactiveFrame;
|
|
|
|
RECT rcInactiveCaption;
|
|
|
|
RECT rcInactiveCaptionButtons;
|
|
|
|
|
|
|
|
RECT rcActiveFrame;
|
|
|
|
RECT rcActiveCaption;
|
|
|
|
RECT rcActiveCaptionButtons;
|
|
|
|
RECT rcActiveMenuBar;
|
|
|
|
RECT rcSelectedMenuItem;
|
|
|
|
RECT rcActiveClient;
|
|
|
|
RECT rcActiveScroll;
|
|
|
|
|
|
|
|
RECT rcDialogFrame;
|
|
|
|
RECT rcDialogCaption;
|
|
|
|
RECT rcDialogCaptionButtons;
|
|
|
|
RECT rcDialogClient;
|
|
|
|
|
|
|
|
RECT rcDialogButton;
|
|
|
|
|
|
|
|
LPTSTR lpInAct;
|
|
|
|
LPTSTR lpAct;
|
|
|
|
LPTSTR lpWinTxt;
|
|
|
|
LPTSTR lpMessBox;
|
|
|
|
LPTSTR lpMessText;
|
|
|
|
LPTSTR lpButText;
|
|
|
|
|
|
|
|
HFONT hCaptionFont;
|
|
|
|
HFONT hMenuFont;
|
|
|
|
HFONT hMessageFont;
|
2010-09-10 21:57:36 +00:00
|
|
|
HFONT hClientFont;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
HMENU hMenu;
|
|
|
|
|
|
|
|
} PREVIEW_DATA, *PPREVIEW_DATA;
|
|
|
|
|
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
static VOID UpdatePreviewTheme(HWND hwnd, PPREVIEW_DATA pPreviewData, COLOR_SCHEME *scheme)
|
2007-01-27 14:53:18 +00:00
|
|
|
{
|
2010-07-04 16:40:03 +00:00
|
|
|
if (pPreviewData->hbrScrollbar != NULL)
|
|
|
|
DeleteObject(pPreviewData->hbrScrollbar);
|
2011-09-19 13:18:33 +00:00
|
|
|
pPreviewData->hbrScrollbar = CreateSolidBrush(scheme->crColor[COLOR_SCROLLBAR]);
|
2010-07-04 16:40:03 +00:00
|
|
|
if (pPreviewData->hbrDesktop != NULL)
|
|
|
|
DeleteObject(pPreviewData->hbrDesktop);
|
2010-09-19 11:54:33 +00:00
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
pPreviewData->hbrDesktop = CreateSolidBrush(scheme->crColor[COLOR_DESKTOP]);
|
2010-07-04 16:40:03 +00:00
|
|
|
if (pPreviewData->hbrWindow != NULL)
|
|
|
|
DeleteObject(pPreviewData->hbrWindow);
|
2011-09-19 13:18:33 +00:00
|
|
|
pPreviewData->hbrWindow = CreateSolidBrush(scheme->crColor[COLOR_WINDOW]);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->cxEdge = 2; /* SM_CXEDGE */
|
|
|
|
pPreviewData->cyEdge = 2; /* SM_CYEDGE */
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->cySizeFrame = scheme->ncMetrics.iBorderWidth; /* SM_CYSIZEFRAME */
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->cyCaption = scheme->ncMetrics.iCaptionHeight+1; /* SM_CYCAPTION */
|
|
|
|
pPreviewData->cyMenu = scheme->ncMetrics.iMenuHeight -1; /* SM_CYMENU */
|
|
|
|
pPreviewData->cxScrollbar = scheme->ncMetrics.iScrollWidth; /* SM_CXVSCROLL */
|
|
|
|
pPreviewData->cyBorder = scheme->ncMetrics.iBorderWidth; /* SM_CYBORDER */
|
2010-07-04 16:40:03 +00:00
|
|
|
|
|
|
|
if (pPreviewData->hCaptionFont != NULL)
|
|
|
|
DeleteObject(pPreviewData->hCaptionFont);
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->hCaptionFont = CreateFontIndirect(&scheme->ncMetrics.lfCaptionFont);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
|
|
|
if (pPreviewData->hMenuFont != NULL)
|
|
|
|
DeleteObject(pPreviewData->hMenuFont);
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->hMenuFont = CreateFontIndirect(&scheme->ncMetrics.lfMenuFont);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
|
|
|
if (pPreviewData->hMessageFont != NULL)
|
|
|
|
DeleteObject(pPreviewData->hMessageFont);
|
2013-04-21 14:36:57 +00:00
|
|
|
pPreviewData->hMessageFont = CreateFontIndirect(&scheme->ncMetrics.lfMessageFont);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
pPreviewData->Scheme = *scheme;
|
2010-07-04 16:40:03 +00:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
OnCreate(HWND hwnd, PPREVIEW_DATA pPreviewData)
|
|
|
|
{
|
2011-09-19 13:18:33 +00:00
|
|
|
COLOR_SCHEME *scheme;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
2010-09-10 21:57:36 +00:00
|
|
|
pPreviewData->hClientFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
/* Load and modify the menu */
|
|
|
|
pPreviewData->hMenu = LoadMenu(hApplet, MAKEINTRESOURCE(IDR_PREVIEW_MENU));
|
2007-03-04 18:41:47 +00:00
|
|
|
EnableMenuItem(pPreviewData->hMenu,
|
|
|
|
1, MF_BYPOSITION | MF_GRAYED);
|
2007-01-27 14:53:18 +00:00
|
|
|
HiliteMenuItem(hwnd, pPreviewData->hMenu,
|
2007-03-04 18:41:47 +00:00
|
|
|
2, MF_BYPOSITION | MF_HILITE);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
// GetMenuItemRect(hwnd, pPreviewData->hMenu,
|
2007-03-04 18:41:47 +00:00
|
|
|
// 2, &pPreviewData->rcSelectedMenuItem);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
AllocAndLoadString(&pPreviewData->lpInAct, hApplet, IDS_INACTWIN);
|
|
|
|
AllocAndLoadString(&pPreviewData->lpAct, hApplet, IDS_ACTWIN);
|
|
|
|
AllocAndLoadString(&pPreviewData->lpWinTxt, hApplet, IDS_WINTEXT);
|
|
|
|
AllocAndLoadString(&pPreviewData->lpMessBox, hApplet, IDS_MESSBOX);
|
|
|
|
AllocAndLoadString(&pPreviewData->lpMessText, hApplet, IDS_MESSTEXT);
|
|
|
|
AllocAndLoadString(&pPreviewData->lpButText, hApplet, IDS_BUTTEXT);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
scheme = &pPreviewData->Scheme;
|
|
|
|
LoadCurrentScheme(scheme);
|
2010-07-04 16:40:03 +00:00
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
UpdatePreviewTheme(hwnd, pPreviewData, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
2007-01-29 23:35:31 +00:00
|
|
|
CalculateItemSize(PPREVIEW_DATA pPreviewData)
|
2007-01-27 14:53:18 +00:00
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
/* Calculate the inactive window rectangle */
|
|
|
|
pPreviewData->rcInactiveFrame.left = pPreviewData->rcDesktop.left + 8;
|
|
|
|
pPreviewData->rcInactiveFrame.top = pPreviewData->rcDesktop.top + 8;
|
|
|
|
pPreviewData->rcInactiveFrame.right = pPreviewData->rcDesktop.right - 25;
|
|
|
|
pPreviewData->rcInactiveFrame.bottom = pPreviewData->rcDesktop.bottom - 30;
|
|
|
|
|
|
|
|
/* Calculate the inactive caption rectangle */
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcInactiveCaption.left = pPreviewData->rcInactiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
|
|
|
|
pPreviewData->rcInactiveCaption.top = pPreviewData->rcInactiveFrame.top + pPreviewData->cyEdge + pPreviewData->cySizeFrame + 1;
|
|
|
|
pPreviewData->rcInactiveCaption.right = pPreviewData->rcInactiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
|
2007-09-29 18:28:45 +00:00
|
|
|
pPreviewData->rcInactiveCaption.bottom = pPreviewData->rcInactiveCaption.top + pPreviewData->cyCaption - pPreviewData->cyBorder;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Calculate the inactive caption buttons rectangle */
|
|
|
|
pPreviewData->rcInactiveCaptionButtons.left = pPreviewData->rcInactiveCaption.right - 2 - 2 - 3 * 16;
|
|
|
|
pPreviewData->rcInactiveCaptionButtons.top = pPreviewData->rcInactiveCaption.top + 2;
|
|
|
|
pPreviewData->rcInactiveCaptionButtons.right = pPreviewData->rcInactiveCaption.right - 2;
|
|
|
|
pPreviewData->rcInactiveCaptionButtons.bottom = pPreviewData->rcInactiveCaption.bottom - 2;
|
|
|
|
|
|
|
|
/* Calculate the active window rectangle */
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcActiveFrame.left = pPreviewData->rcInactiveFrame.left + 3 + pPreviewData->cySizeFrame;
|
2007-01-27 14:53:18 +00:00
|
|
|
pPreviewData->rcActiveFrame.top = pPreviewData->rcInactiveCaption.bottom + 1;
|
|
|
|
pPreviewData->rcActiveFrame.right = pPreviewData->rcDesktop.right - 10;
|
|
|
|
pPreviewData->rcActiveFrame.bottom = pPreviewData->rcDesktop.bottom - 25;
|
|
|
|
|
|
|
|
/* Calculate the active caption rectangle */
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcActiveCaption.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
|
|
|
|
pPreviewData->rcActiveCaption.top = pPreviewData->rcActiveFrame.top + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
|
|
|
|
pPreviewData->rcActiveCaption.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
|
2007-09-29 18:28:45 +00:00
|
|
|
pPreviewData->rcActiveCaption.bottom = pPreviewData->rcActiveCaption.top + pPreviewData->cyCaption - pPreviewData->cyBorder;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Calculate the active caption buttons rectangle */
|
|
|
|
pPreviewData->rcActiveCaptionButtons.left = pPreviewData->rcActiveCaption.right - 2 - 2 - 3 * 16;
|
|
|
|
pPreviewData->rcActiveCaptionButtons.top = pPreviewData->rcActiveCaption.top + 2;
|
|
|
|
pPreviewData->rcActiveCaptionButtons.right = pPreviewData->rcActiveCaption.right - 2;
|
|
|
|
pPreviewData->rcActiveCaptionButtons.bottom = pPreviewData->rcActiveCaption.bottom - 2;
|
|
|
|
|
|
|
|
/* Calculate the active menu bar rectangle */
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcActiveMenuBar.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
|
2007-01-27 14:53:18 +00:00
|
|
|
pPreviewData->rcActiveMenuBar.top = pPreviewData->rcActiveCaption.bottom + 1;
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcActiveMenuBar.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
|
2007-01-29 23:35:31 +00:00
|
|
|
pPreviewData->rcActiveMenuBar.bottom = pPreviewData->rcActiveMenuBar.top + pPreviewData->cyMenu + 1;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Calculate the active client rectangle */
|
2007-02-19 16:12:38 +00:00
|
|
|
pPreviewData->rcActiveClient.left = pPreviewData->rcActiveFrame.left + pPreviewData->cxEdge + pPreviewData->cySizeFrame + 1;
|
|
|
|
pPreviewData->rcActiveClient.top = pPreviewData->rcActiveMenuBar.bottom;
|
|
|
|
pPreviewData->rcActiveClient.right = pPreviewData->rcActiveFrame.right - pPreviewData->cxEdge - pPreviewData->cySizeFrame - 1;
|
|
|
|
pPreviewData->rcActiveClient.bottom = pPreviewData->rcActiveFrame.bottom - pPreviewData->cyEdge - pPreviewData->cySizeFrame - 1;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Calculate the active scroll rectangle */
|
2007-01-29 23:35:31 +00:00
|
|
|
pPreviewData->rcActiveScroll.left = pPreviewData->rcActiveClient.right - 2 - pPreviewData->cxScrollbar;
|
2007-01-27 14:53:18 +00:00
|
|
|
pPreviewData->rcActiveScroll.top = pPreviewData->rcActiveClient.top + 2;
|
|
|
|
pPreviewData->rcActiveScroll.right = pPreviewData->rcActiveClient.right - 2;
|
|
|
|
pPreviewData->rcActiveScroll.bottom = pPreviewData->rcActiveClient.bottom - 2;
|
|
|
|
|
|
|
|
|
|
|
|
/* Dialog window */
|
|
|
|
pPreviewData->rcDialogFrame.left = pPreviewData->rcActiveClient.left + 4;
|
|
|
|
pPreviewData->rcDialogFrame.top = (pPreviewData->rcDesktop.bottom * 60) / 100;
|
|
|
|
pPreviewData->rcDialogFrame.right = (pPreviewData->rcDesktop.right * 65) / 100;
|
|
|
|
pPreviewData->rcDialogFrame.bottom = pPreviewData->rcDesktop.bottom - 5;
|
|
|
|
|
|
|
|
/* Calculate the dialog caption rectangle */
|
|
|
|
pPreviewData->rcDialogCaption.left = pPreviewData->rcDialogFrame.left + 3;
|
|
|
|
pPreviewData->rcDialogCaption.top = pPreviewData->rcDialogFrame.top + 3;
|
|
|
|
pPreviewData->rcDialogCaption.right = pPreviewData->rcDialogFrame.right - 3;
|
2007-01-29 23:35:31 +00:00
|
|
|
pPreviewData->rcDialogCaption.bottom = pPreviewData->rcDialogFrame.top + pPreviewData->cyCaption + 1 + 1;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Calculate the inactive caption buttons rectangle */
|
|
|
|
pPreviewData->rcDialogCaptionButtons.left = pPreviewData->rcDialogCaption.right - 2 - 16;
|
|
|
|
pPreviewData->rcDialogCaptionButtons.top = pPreviewData->rcDialogCaption.top + 2;
|
|
|
|
pPreviewData->rcDialogCaptionButtons.right = pPreviewData->rcDialogCaption.right - 2;
|
|
|
|
pPreviewData->rcDialogCaptionButtons.bottom = pPreviewData->rcDialogCaption.bottom - 2;
|
|
|
|
|
|
|
|
/* Calculate the dialog client rectangle */
|
|
|
|
pPreviewData->rcDialogClient.left = pPreviewData->rcDialogFrame.left + 3;
|
|
|
|
pPreviewData->rcDialogClient.top = pPreviewData->rcDialogCaption.bottom + 1;
|
|
|
|
pPreviewData->rcDialogClient.right = pPreviewData->rcDialogFrame.right - 3;
|
|
|
|
pPreviewData->rcDialogClient.bottom = pPreviewData->rcDialogFrame.bottom - 3;
|
|
|
|
|
|
|
|
/* Calculate the dialog button rectangle */
|
|
|
|
width = 80;
|
|
|
|
height = 28;
|
|
|
|
|
|
|
|
pPreviewData->rcDialogButton.left =
|
|
|
|
(pPreviewData->rcDialogClient.right + pPreviewData->rcDialogClient.left - width) / 2;
|
|
|
|
pPreviewData->rcDialogButton.right = pPreviewData->rcDialogButton.left + width;
|
|
|
|
pPreviewData->rcDialogButton.bottom = pPreviewData->rcDialogClient.bottom - 2;
|
|
|
|
pPreviewData->rcDialogButton.top = pPreviewData->rcDialogButton.bottom - height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-29 23:35:31 +00:00
|
|
|
static VOID
|
|
|
|
OnSize(INT cx, INT cy, PPREVIEW_DATA pPreviewData)
|
|
|
|
{
|
|
|
|
/* Get Desktop rectangle */
|
|
|
|
pPreviewData->rcDesktop.left = 0;
|
|
|
|
pPreviewData->rcDesktop.top = 0;
|
|
|
|
pPreviewData->rcDesktop.right = cx;
|
|
|
|
pPreviewData->rcDesktop.bottom = cy;
|
|
|
|
|
|
|
|
CalculateItemSize(pPreviewData);
|
|
|
|
}
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
static VOID
|
|
|
|
OnPaint(HWND hwnd, PPREVIEW_DATA pPreviewData)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HFONT hOldFont;
|
|
|
|
HDC hdc;
|
|
|
|
RECT rc;
|
2011-09-19 13:18:33 +00:00
|
|
|
COLOR_SCHEME *scheme;
|
2007-01-27 14:53:18 +00:00
|
|
|
|
2011-09-19 13:18:33 +00:00
|
|
|
scheme = &pPreviewData->Scheme;
|
2007-02-28 23:43:12 +00:00
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
hdc = BeginPaint(hwnd, &ps);
|
|
|
|
|
2016-10-26 21:14:39 +00:00
|
|
|
if (pPreviewData->hdcPreview)
|
2013-04-21 14:36:57 +00:00
|
|
|
{
|
|
|
|
BitBlt(hdc,0,0, pPreviewData->rcDesktop.right, pPreviewData->rcDesktop.bottom, pPreviewData->hdcPreview, 0,0, SRCCOPY);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
/* Desktop */
|
|
|
|
FillRect(hdc, &pPreviewData->rcDesktop, pPreviewData->hbrDesktop);
|
|
|
|
|
|
|
|
/* Inactive Window */
|
2013-04-21 14:36:57 +00:00
|
|
|
MyDrawEdge(hdc, &pPreviewData->rcInactiveFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE | MY_BF_INACTIVEBORDER, scheme);
|
2011-09-19 13:18:33 +00:00
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_INACTIVECAPTIONTEXT]);
|
2010-07-21 12:20:18 +00:00
|
|
|
MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcInactiveCaption, pPreviewData->hCaptionFont,
|
2011-09-19 13:18:33 +00:00
|
|
|
NULL, pPreviewData->lpInAct, DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
|
|
|
|
MyDrawCaptionButtons(hdc, &pPreviewData->rcInactiveCaption, TRUE, pPreviewData->cyCaption - 2, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Active Window */
|
2013-04-21 14:36:57 +00:00
|
|
|
MyDrawEdge(hdc, &pPreviewData->rcActiveFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE | MY_BF_ACTIVEBORDER, scheme);
|
2011-09-19 13:18:33 +00:00
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_CAPTIONTEXT]);
|
2010-07-04 16:40:03 +00:00
|
|
|
MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcActiveCaption, pPreviewData->hCaptionFont,
|
2011-09-19 13:18:33 +00:00
|
|
|
NULL, pPreviewData->lpAct, DC_ACTIVE | DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
|
|
|
|
MyDrawCaptionButtons(hdc, &pPreviewData->rcActiveCaption, TRUE, pPreviewData->cyCaption - 2, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
2007-02-19 16:12:38 +00:00
|
|
|
/* Draw the menu bar */
|
2010-07-04 16:40:03 +00:00
|
|
|
MyDrawMenuBarTemp(hwnd, hdc, &pPreviewData->rcActiveMenuBar,
|
|
|
|
pPreviewData->hMenu,
|
2011-09-19 13:18:33 +00:00
|
|
|
pPreviewData->hMenuFont, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Draw the client area */
|
|
|
|
CopyRect(&rc, &pPreviewData->rcActiveClient);
|
2011-09-19 13:18:33 +00:00
|
|
|
MyDrawEdge(hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_ADJUST, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
FillRect(hdc, &rc, pPreviewData->hbrWindow);
|
|
|
|
|
|
|
|
/* Draw the client text */
|
|
|
|
CopyRect(&rc, &pPreviewData->rcActiveClient);
|
|
|
|
rc.left += 4;
|
|
|
|
rc.top += 2;
|
2011-09-19 13:18:33 +00:00
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_WINDOWTEXT]);
|
2010-09-10 21:57:36 +00:00
|
|
|
hOldFont = SelectObject(hdc, pPreviewData->hClientFont);
|
2010-07-21 12:20:18 +00:00
|
|
|
DrawText(hdc, pPreviewData->lpWinTxt, -1, &rc, DT_LEFT);
|
2007-01-27 14:53:18 +00:00
|
|
|
SelectObject(hdc, hOldFont);
|
|
|
|
|
|
|
|
/* Draw the scroll bar */
|
2011-09-19 13:18:33 +00:00
|
|
|
MyDrawScrollbar(hdc, &pPreviewData->rcActiveScroll, pPreviewData->hbrScrollbar, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Dialog Window */
|
2011-09-19 13:18:33 +00:00
|
|
|
MyDrawEdge(hdc, &pPreviewData->rcDialogFrame, EDGE_RAISED, BF_RECT | BF_MIDDLE, scheme);
|
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_WINDOW]);
|
2010-07-04 16:40:03 +00:00
|
|
|
MyDrawCaptionTemp(NULL, hdc, &pPreviewData->rcDialogCaption, pPreviewData->hCaptionFont,
|
2011-09-19 13:18:33 +00:00
|
|
|
NULL, pPreviewData->lpMessBox, DC_ACTIVE | DC_GRADIENT | DC_ICON | DC_TEXT, scheme);
|
|
|
|
MyDrawCaptionButtons(hdc, &pPreviewData->rcDialogCaption, FALSE, pPreviewData->cyCaption - 2, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
|
|
|
|
/* Draw the dialog text */
|
|
|
|
CopyRect(&rc, &pPreviewData->rcDialogClient);
|
|
|
|
rc.left += 4;
|
|
|
|
rc.top += 2;
|
2013-04-21 14:36:57 +00:00
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_WINDOWTEXT]);
|
2007-01-27 14:53:18 +00:00
|
|
|
hOldFont = SelectObject(hdc, pPreviewData->hMessageFont);
|
2010-07-21 12:20:18 +00:00
|
|
|
DrawText(hdc, pPreviewData->lpMessText, -1, &rc, DT_LEFT);
|
2007-01-27 14:53:18 +00:00
|
|
|
SelectObject(hdc, hOldFont);
|
|
|
|
|
|
|
|
/* Draw Button */
|
2011-09-19 13:18:33 +00:00
|
|
|
MyDrawFrameControl(hdc, &pPreviewData->rcDialogButton, DFC_BUTTON, DFCS_BUTTONPUSH, scheme);
|
2007-01-27 14:53:18 +00:00
|
|
|
CopyRect(&rc, &pPreviewData->rcDialogButton);
|
2011-09-19 13:18:33 +00:00
|
|
|
SetTextColor(hdc, scheme->crColor[COLOR_BTNTEXT]);
|
2007-01-27 14:53:18 +00:00
|
|
|
hOldFont = SelectObject(hdc, pPreviewData->hMessageFont);
|
2010-07-21 12:20:18 +00:00
|
|
|
DrawText(hdc, pPreviewData->lpButText, -1, &rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
|
2007-01-27 14:53:18 +00:00
|
|
|
SelectObject(hdc, hOldFont);
|
|
|
|
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
OnLButtonDown(HWND hwnd, int xPos, int yPos, PPREVIEW_DATA pPreviewData)
|
|
|
|
{
|
|
|
|
UINT type = IDX_DESKTOP;
|
|
|
|
POINT pt;
|
|
|
|
|
|
|
|
pt.x = xPos;
|
|
|
|
pt.y = yPos;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcInactiveFrame, pt))
|
|
|
|
type = IDX_INACTIVE_BORDER;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcInactiveCaption, pt))
|
|
|
|
type = IDX_INACTIVE_CAPTION;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcInactiveCaptionButtons, pt))
|
|
|
|
type = IDX_CAPTION_BUTTON;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcActiveFrame, pt))
|
|
|
|
type = IDX_ACTIVE_BORDER;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcActiveCaption, pt))
|
|
|
|
type = IDX_ACTIVE_CAPTION;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcActiveCaptionButtons, pt))
|
|
|
|
type = IDX_CAPTION_BUTTON;
|
|
|
|
|
|
|
|
// if (PtInRect(&pPreviewData->rcSelectedMenuItem, pt))
|
|
|
|
// type = IDX_SELECTION;
|
|
|
|
|
2007-03-04 18:41:47 +00:00
|
|
|
if (PtInRect(&pPreviewData->rcActiveMenuBar, pt))
|
|
|
|
type = IDX_MENU;
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
if (PtInRect(&pPreviewData->rcActiveClient, pt))
|
|
|
|
type = IDX_WINDOW;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcActiveScroll, pt))
|
|
|
|
type = IDX_SCROLLBAR;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcDialogFrame, pt))
|
|
|
|
type = IDX_DIALOG;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcDialogCaption, pt))
|
|
|
|
type = IDX_ACTIVE_CAPTION;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcDialogCaptionButtons, pt))
|
|
|
|
type = IDX_CAPTION_BUTTON;
|
|
|
|
|
|
|
|
if (PtInRect(&pPreviewData->rcDialogButton, pt))
|
|
|
|
type = IDX_3D_OBJECTS;
|
|
|
|
|
2007-02-17 21:40:39 +00:00
|
|
|
SendMessage(GetParent(hwnd),
|
|
|
|
WM_COMMAND,
|
|
|
|
MAKEWPARAM(GetWindowLongPtrW(hwnd, GWLP_ID), 0),
|
|
|
|
(LPARAM)type);
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
OnDestroy(PPREVIEW_DATA pPreviewData)
|
|
|
|
{
|
|
|
|
DeleteObject(pPreviewData->hbrScrollbar);
|
|
|
|
DeleteObject(pPreviewData->hbrDesktop);
|
|
|
|
DeleteObject(pPreviewData->hbrWindow);
|
|
|
|
|
|
|
|
DeleteObject(pPreviewData->hCaptionFont);
|
|
|
|
DeleteObject(pPreviewData->hMenuFont);
|
|
|
|
DeleteObject(pPreviewData->hMessageFont);
|
|
|
|
|
|
|
|
DestroyMenu(pPreviewData->hMenu);
|
|
|
|
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpInAct);
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpAct);
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpWinTxt);
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpMessBox);
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpMessText);
|
|
|
|
LocalFree((HLOCAL)pPreviewData->lpButText);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
PreviewWndProc(HWND hwnd,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
PPREVIEW_DATA pPreviewData;
|
|
|
|
|
|
|
|
pPreviewData = (PPREVIEW_DATA)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
pPreviewData = (PPREVIEW_DATA)HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(PREVIEW_DATA));
|
|
|
|
if (!pPreviewData)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pPreviewData);
|
|
|
|
OnCreate(hwnd, pPreviewData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
|
|
|
OnSize(LOWORD(lParam), HIWORD(lParam), pPreviewData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
OnPaint(hwnd, pPreviewData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
OnLButtonDown(hwnd, LOWORD(lParam), HIWORD(lParam), pPreviewData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
OnDestroy(pPreviewData);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pPreviewData);
|
|
|
|
break;
|
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
case PVM_UPDATETHEME:
|
|
|
|
UpdatePreviewTheme(hwnd, pPreviewData, (COLOR_SCHEME *)lParam);
|
|
|
|
CalculateItemSize(pPreviewData);
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2007-01-29 23:35:31 +00:00
|
|
|
break;
|
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
case PVM_SETSIZE:
|
|
|
|
SchemeSetMetric(&pPreviewData->Scheme, wParam, lParam);
|
|
|
|
pPreviewData->cySizeFrame = pPreviewData->Scheme.ncMetrics.iBorderWidth; /* SM_CYSIZEFRAME */
|
|
|
|
pPreviewData->cyCaption = pPreviewData->Scheme.ncMetrics.iCaptionHeight+1; /* SM_CYCAPTION */
|
|
|
|
pPreviewData->cyMenu = pPreviewData->Scheme.ncMetrics.iMenuHeight -1; /* SM_CYMENU */
|
|
|
|
pPreviewData->cxScrollbar = pPreviewData->Scheme.ncMetrics.iScrollWidth; /* SM_CXVSCROLL */
|
|
|
|
pPreviewData->cyBorder = pPreviewData->Scheme.ncMetrics.iBorderWidth; /* SM_CYBORDER */
|
|
|
|
CalculateItemSize(pPreviewData);
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
break;
|
2016-10-26 21:14:39 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
case PVM_SETFONT:
|
|
|
|
{
|
|
|
|
PLOGFONTW plfFont;
|
|
|
|
HFONT* phFont;
|
2007-01-29 23:35:31 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
switch(wParam)
|
2007-01-29 23:35:31 +00:00
|
|
|
{
|
2013-04-21 14:36:57 +00:00
|
|
|
case FONT_CAPTION: phFont = &pPreviewData->hCaptionFont; break;
|
|
|
|
case FONT_MENU: phFont = &pPreviewData->hMenuFont; break;
|
|
|
|
case FONT_MESSAGE: phFont = &pPreviewData->hMessageFont; break;
|
|
|
|
default: return TRUE;
|
2007-01-29 23:35:31 +00:00
|
|
|
}
|
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
plfFont = SchemeGetFont(&pPreviewData->Scheme, wParam);
|
|
|
|
memcpy(plfFont, (PVOID)lParam, sizeof(LOGFONTW));
|
2007-01-29 23:35:31 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
DeleteObject(*phFont);
|
|
|
|
*phFont = CreateFontIndirect(plfFont);
|
2007-01-29 23:35:31 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
|
|
|
break;
|
|
|
|
}
|
2007-01-29 23:35:31 +00:00
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
case PVM_SETCOLOR:
|
|
|
|
pPreviewData->Scheme.crColor[wParam] = lParam;
|
|
|
|
switch(wParam)
|
2007-01-29 23:35:31 +00:00
|
|
|
{
|
2016-10-26 21:14:39 +00:00
|
|
|
case COLOR_SCROLLBAR:
|
2013-04-21 14:36:57 +00:00
|
|
|
DeleteObject(pPreviewData->hbrScrollbar);
|
|
|
|
pPreviewData->hbrScrollbar = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
|
|
|
|
break;
|
2016-10-26 21:14:39 +00:00
|
|
|
case COLOR_DESKTOP:
|
2013-04-21 14:36:57 +00:00
|
|
|
DeleteObject(pPreviewData->hbrDesktop);
|
|
|
|
pPreviewData->hbrDesktop = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
|
|
|
|
break;
|
2016-10-26 21:14:39 +00:00
|
|
|
case COLOR_WINDOW:
|
2013-04-21 14:36:57 +00:00
|
|
|
DeleteObject(pPreviewData->hbrWindow);
|
|
|
|
pPreviewData->hbrWindow = CreateSolidBrush(pPreviewData->Scheme.crColor[wParam]);
|
|
|
|
break;
|
2007-01-29 23:35:31 +00:00
|
|
|
}
|
2013-04-21 14:36:57 +00:00
|
|
|
|
|
|
|
CalculateItemSize(pPreviewData);
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2007-01-29 23:35:31 +00:00
|
|
|
break;
|
|
|
|
|
2013-04-21 14:36:57 +00:00
|
|
|
case PVM_GETSIZE:
|
|
|
|
return SchemeGetMetric(&pPreviewData->Scheme, wParam);
|
|
|
|
case PVM_GETFONT:
|
|
|
|
return (LRESULT)SchemeGetFont(&pPreviewData->Scheme, wParam);
|
|
|
|
case PVM_GETCOLOR:
|
|
|
|
return pPreviewData->Scheme.crColor[wParam];
|
|
|
|
|
|
|
|
case PVM_SET_HDC_PREVIEW:
|
|
|
|
pPreviewData->hdcPreview = (HDC)lParam;
|
|
|
|
InvalidateRect(hwnd, NULL, FALSE);
|
2007-03-10 21:25:03 +00:00
|
|
|
break;
|
|
|
|
|
2007-01-27 14:53:18 +00:00
|
|
|
default:
|
2010-07-04 16:40:03 +00:00
|
|
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|
2010-07-04 16:40:03 +00:00
|
|
|
return FALSE;
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
RegisterPreviewControl(IN HINSTANCE hInstance)
|
|
|
|
{
|
|
|
|
WNDCLASSEX wc = {0};
|
|
|
|
|
2016-10-26 21:14:39 +00:00
|
|
|
wc.cbSize = sizeof(wc);
|
2007-01-27 14:53:18 +00:00
|
|
|
wc.lpfnWndProc = PreviewWndProc;
|
|
|
|
wc.hInstance = hInstance;
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
2007-02-19 16:12:38 +00:00
|
|
|
wc.hbrBackground = (HBRUSH)NULL;
|
2007-01-27 14:53:18 +00:00
|
|
|
wc.lpszClassName = szPreviewWndClass;
|
|
|
|
|
|
|
|
return RegisterClassEx(&wc) != (ATOM)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
UnregisterPreviewControl(IN HINSTANCE hInstance)
|
|
|
|
{
|
2010-07-04 16:40:03 +00:00
|
|
|
UnregisterClass(szPreviewWndClass, hInstance);
|
2007-01-27 14:53:18 +00:00
|
|
|
}
|