Author: ekohl
Date: Thu Feb 15 23:24:38 2007
New Revision: 25809
URL:
http://svn.reactos.org/svn/reactos?rev=25809&view=rev
Log:
- Declare local functions static and get rid of prototypes by moving functions around.
- Clean up the code. No changes to the functionality.
Modified:
trunk/reactos/dll/cpl/desk/advappdlg.c
trunk/reactos/dll/cpl/desk/appearance.c
trunk/reactos/dll/cpl/desk/appearance.h
Modified: trunk/reactos/dll/cpl/desk/advappdlg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/advappdlg.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/desk/advappdlg.c (original)
+++ trunk/reactos/dll/cpl/desk/advappdlg.c Thu Feb 15 23:24:38 2007
@@ -12,193 +12,58 @@
#include "desk.h"
#include "appearance.h"
-INT_PTR CALLBACK
-AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- int iListIndex;
- GLOBALS* g;
-
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
- g = (GLOBALS*)lParam;
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
- AdvAppearanceDlg_Init(hwndDlg);
- break;
- }
- case WM_DESTROY:
- {
- AdvAppearanceDlg_CleanUp(hwndDlg);
- break;
- }
- case WM_COMMAND:
- {
- g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- switch(LOWORD(wParam))
- {
- case IDOK:
- {
- SaveCurrentValues(hwndDlg);
- EndDialog(hwndDlg, 0);
- break;
- }
- case IDCANCEL:
- {
- g->ThemeAdv = g->Theme;
- EndDialog(hwndDlg, 0);
- break;
- }
- case IDC_ADVAPPEARANCE_ELEMENT:
- {
- if(HIWORD(wParam) == CBN_SELCHANGE)
- {
- SaveCurrentValues(hwndDlg);
- iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL,
0, 0);
- g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT,
CB_GETITEMDATA, (WPARAM)iListIndex, 0);
- UpdateControls(hwndDlg, g->CurrentElement);
- break;
- }
- break;
- }
- case IDC_ADVAPPEARANCE_COLOR1_B:
- {
- GetColor(hwndDlg, g->CurrentElement, 0);
- break;
- }
- case IDC_ADVAPPEARANCE_COLOR2_B:
- {
- GetColor(hwndDlg, g->CurrentElement, 1);
- break;
- }
- case IDC_ADVAPPEARANCE_FONTCOLOR_B:
- {
- GetColor(hwndDlg, g->CurrentElement, 2);
- break;
- }
- default:
- {
- return FALSE;
- }
- }
- break;
- }
- default:
- {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-
-/* Initialize the advanced appearance dialog */
-void
-AdvAppearanceDlg_Init(HWND hwndDlg)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- int i, iElement, iListIndex, iDeskIndex = 0;
- TCHAR tstrText[80];
- LOGFONT lfFont;
- LOGFONT lfButtonFont;
- HFONT hMyFont;
- HDC hScreenDC;
-
- /* Copy the current theme values */
- g->ThemeAdv = g->Theme;
-
- /* Add the elements to the combo */
- for(iElement = 0; iElement < NUM_ELEMENTS; iElement++)
- {
- LoadString(hApplet, IDS_ELEMENT_1 + iElement, (LPTSTR)&tstrText, 79);
- iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_ADDSTRING, 0,
(LPARAM)&tstrText);
- SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETITEMDATA,
(WPARAM)iListIndex, (LPARAM)iElement);
- }
-
- /* Get the list index of the desktop element */
- for(iListIndex = 0; iListIndex < NUM_ELEMENTS; iListIndex++)
- {
- iElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA,
(WPARAM)iListIndex, 0);
- if (iElement == 0)
- {
- iDeskIndex = iListIndex;
- break;
- }
- }
- SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETCURSEL, iDeskIndex, 0);
-
- /* Set colors for the color buttons */
- g->crCOLOR_BTNFACE = g->Theme.crColor[COLOR_BTNFACE];
- g->crCOLOR_BTNTEXT = g->Theme.crColor[COLOR_BTNTEXT];
- g->crCOLOR_BTNSHADOW = g->Theme.crColor[COLOR_BTNSHADOW];
- g->crCOLOR_BTNHIGHLIGHT = g->Theme.crColor[COLOR_BTNHIGHLIGHT];
-
- /* Create font for bold button */
- lfButtonFont = g->Theme.lfFont[FONT_DIALOG];
- lfButtonFont.lfWeight = FW_BOLD;
- lfButtonFont.lfItalic = FALSE;
- hMyFont = CreateFontIndirect(&lfButtonFont);
- if (hMyFont)
- {
- if (g->hBoldFont)
- {
- DeleteObject(g->hBoldFont);
- }
- g->hBoldFont = hMyFont;
- }
-
- /* Create font for italic button */
- lfButtonFont.lfWeight = FW_REGULAR;
- lfButtonFont.lfItalic = TRUE;
- hMyFont = CreateFontIndirect(&lfButtonFont);
- if (hMyFont)
- {
- if (g->hItalicFont)
- {
- DeleteObject(g->hItalicFont);
- }
- g->hItalicFont = hMyFont;
- }
-
- /* Set the fonts for the font style buttons */
- SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, WM_SETFONT,
(WPARAM)g->hBoldFont, (LPARAM)TRUE);
- SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, WM_SETFONT,
(WPARAM)g->hItalicFont, (LPARAM)TRUE);
-
- /* Draw Bitmaps for the colorbuttons */
- InitColorButtons(hwndDlg);
-
- /* Make the UpDown control count correctly */
- SendMessage (GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD), UDM_SETRANGE, 0L, MAKELONG
(200, 1));
-
- /* Fill font selection combo */
- lfFont.lfCharSet = DEFAULT_CHARSET;
- lfFont.lfFaceName[0] = (TCHAR)0;
- lfFont.lfPitchAndFamily = 0;
- hScreenDC = GetDC(0);
- EnumFontFamiliesEx(hScreenDC, &lfFont, (FONTENUMPROC)EnumFontFamExProc,
(LPARAM)GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_C), 0);
- ReleaseDC(0, hScreenDC);
-
- /* Fill font size combo */
- TCHAR Size[4];
- for (i = 6; i <= 24; i++)
- {
- SetDlgItemInt(hwndDlg, IDC_CONVERT, i, FALSE);
- GetDlgItemText(hwndDlg, IDC_CONVERT, (LPTSTR)&Size, 3);
- SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, CB_ADDSTRING, 0,
(LPARAM)&Size);
- }
-
- /* Update the controls */
- iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0,
0);
- g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT,
CB_GETITEMDATA, (WPARAM)iListIndex, 0);
- UpdateControls(hwndDlg, g->CurrentElement);
- return;
-}
+
+
+/* Draw the current color on the color picker buttons */
+static VOID
+UpdateButtonColor(HWND hwndDlg, GLOBALS* g, INT ID, INT nButton, INT nColor)
+{
+ HDC hdcColorButton, hdcCompat;
+ RECT rect;
+ HBRUSH hbrush;
+ HWND hwndColorButton;
+ COLORREF crColor = g->ThemeAdv.crColor[nColor];
+ HGDIOBJ hgdiTmp;
+
+ if (nColor != -1)
+ {
+ /* Create a DC to draw on */
+ hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
+ hdcColorButton = GetDC(hwndColorButton);
+ hdcCompat = CreateCompatibleDC(hdcColorButton);
+ ReleaseDC(hwndColorButton, hdcColorButton);
+
+ /* Select the button image to it */
+ hgdiTmp = SelectObject(hdcCompat, g->hbmpColor[nButton]);
+
+ /* Create a brush and draw the rectangle */
+ rect.left = 2;
+ rect.top = 2;
+ rect.right = 22;
+ rect.bottom = 13;
+ hbrush = CreateSolidBrush(crColor);
+ FillRect(hdcCompat, &rect, hbrush);
+ DeleteObject(hbrush);
+
+ /* hdcCompat is not needed anymore */
+ SelectObject(hdcCompat,hgdiTmp);
+ DeleteDC(hdcCompat);
+
+ SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
(LPARAM)g->hbmpColor[nButton]);
+ EnableWindow(GetDlgItem(hwndDlg, ID), TRUE);
+ }
+ else
+ {
+ SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)NULL);
+ EnableWindow(GetDlgItem(hwndDlg, ID), FALSE);
+ }
+}
+
/* Create the basic bitmaps for the color picker buttons */
-void
-InitColorButtons(HWND hwndDlg)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+static VOID
+InitColorButtons(HWND hwndDlg, GLOBALS* g)
+{
INT i;
HDC hdcColorButton, hdcCompat;
RECT rect;
@@ -209,7 +74,7 @@
const POINT Points[3] = {{29,6},{33,6},{31,8}};
- hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
+ hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
hdcColorButton = GetDC(hwndColorButton);
for (i = 0; i <= 2; i++)
{
@@ -223,13 +88,19 @@
hgdiTemp = SelectObject(hdcCompat, g->hbmpColor[i]);
/* Draw the buttons background color */
- rect.left = 0; rect.top = 0; rect.right = 36; rect.bottom = 15;
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = 36;
+ rect.bottom = 15;
hbrush = CreateSolidBrush(g->crCOLOR_BTNFACE);
FillRect(hdcCompat, &rect, hbrush);
DeleteObject(hbrush);
/* Draw the rectangle */
- rect.left = 1; rect.top = 1; rect.right = 23; rect.bottom = 14;
+ rect.left = 1;
+ rect.top = 1;
+ rect.right = 23;
+ rect.bottom = 14;
hbrush = CreateSolidBrush(g->crCOLOR_BTNTEXT);
FillRect(hdcCompat, &rect, hbrush);
DeleteObject(hbrush);
@@ -260,52 +131,48 @@
/* FIXME: HACK, see Points definition */
Polygon(hdcCompat, Points, 3);
- /* Cleanup */
+ /* Cleanup */
SelectObject(hdcCompat,hgdiTemp);
DeleteDC(hdcCompat);
DeleteObject(hPen);
DeleteObject(hbrush);
}
+
ReleaseDC(hwndColorButton, hdcColorButton);
/* Set the images of the buttons */
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[0]);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_B, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[1]);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_B, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[2]);
- return;
-}
-
-void
-AdvAppearanceDlg_CleanUp(HWND hwndDlg)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- DeleteObject(g->hBoldFont);
- DeleteObject(g->hItalicFont);
- return;
-}
+}
+
/* This is the callback function to add the installed fonts to the font combo */
-int CALLBACK
-EnumFontFamExProc(
- ENUMLOGFONTEX *lpelfe,
- NEWTEXTMETRICEX *lpntme,
- DWORD dwFontType,
- LPARAM lParam)
+static int CALLBACK
+EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, DWORD dwFontType,
LPARAM lParam)
{
/* Don't enumerate more than 100 fonts */
- if (SendMessage((HWND)lParam, CB_GETCOUNT, 0, 0) >= 100) return(0);
+ if (SendMessage((HWND)lParam, CB_GETCOUNT, 0, 0) >= 100)
+ return 0;
/* Only add the string once */
- if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1,
(WPARAM)&(lpelfe->elfLogFont.lfFaceName)) != CB_ERR) return(2);
+ if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1,
(WPARAM)&(lpelfe->elfLogFont.lfFaceName)) != CB_ERR)
+ return 2;
+
SendMessage((HWND)lParam, CB_ADDSTRING, 0,
(WPARAM)&(lpelfe->elfLogFont.lfFaceName));
- return(1);
-}
+
+ return 1;
+}
+
/* Update all the controls with the current values for the selected screen element */
-void
-UpdateControls(HWND hwndDlg, int iElement)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+static VOID
+UpdateControls(HWND hwndDlg, GLOBALS *g)
+{
+ INT iElement;
+ HDC hdcDlg;
+
+ iElement = g->CurrentElement;
/* First enable / disable the controls */
EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E), (g_Assignment[iElement].Size
!= -1));
@@ -322,16 +189,16 @@
EnableWindow(GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC),
(g_Assignment[iElement].Font != -1));
/* Update the colors of the color buttons */
- UpdateButtonColor(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B, 0,
g_Assignment[iElement].Color1);
- UpdateButtonColor(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_B, 1,
g_Assignment[iElement].Color2);
- UpdateButtonColor(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_B, 2,
g_Assignment[iElement].FontColor);
+ UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR1_B, 0,
g_Assignment[iElement].Color1);
+ UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_COLOR2_B, 1,
g_Assignment[iElement].Color2);
+ UpdateButtonColor(hwndDlg, g, IDC_ADVAPPEARANCE_FONTCOLOR_B, 2,
g_Assignment[iElement].FontColor);
if (g_Assignment[iElement].Size != -1)
SetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E,
g->ThemeAdv.Size[g_Assignment[iElement].Size], FALSE);
else
SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_SIZE_E, TEXT(""));
- HDC hdcDlg = GetDC(hwndDlg);
+ hdcDlg = GetDC(hwndDlg);
if (g_Assignment[iElement].Font != -1)
{
LOGFONT lfFont = g->ThemeAdv.lfFont[g_Assignment[iElement].Font];
@@ -341,26 +208,30 @@
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, CB_FINDSTRINGEXACT, -1,
(WPARAM)lfFont.lfFaceName);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK,
g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfWeight == FW_BOLD?1:0, 0);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK,
g->ThemeAdv.lfFont[g_Assignment[iElement].Font].lfItalic, 0);
- } else {
+ }
+ else
+ {
SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C, NULL);
SetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, NULL);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, BM_SETCHECK, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_SETCHECK, 0, 0);
}
+
ReleaseDC(hwndDlg, hdcDlg);
- return;
-}
-
-void
-SaveCurrentValues(HWND hwndDlg)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+}
+
+
+static VOID
+SaveCurrentValues(HWND hwndDlg, GLOBALS *g)
+{
BOOL bTranslated;
HDC hdcDlg = GetDC(hwndDlg);
+
if (g_Assignment[g->CurrentElement].Size != -1)
{
g->ThemeAdv.Size[g_Assignment[g->CurrentElement].Size] = GetDlgItemInt(hwndDlg,
IDC_ADVAPPEARANCE_SIZE_E, &bTranslated, FALSE);
}
+
if (g_Assignment[g->CurrentElement].Font != -1)
{
g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfHeight =
-MulDiv(GetDlgItemInt(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, &bTranslated, FALSE),
GetDeviceCaps(hdcDlg, LOGPIXELSY), 72);
@@ -368,78 +239,40 @@
g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfItalic =
SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, BM_GETCHECK, 0, 0);
GetDlgItemText(hwndDlg, IDC_ADVAPPEARANCE_FONT_C,
g->ThemeAdv.lfFont[g_Assignment[g->CurrentElement].Font].lfFaceName, LF_FACESIZE *
sizeof(TCHAR));
}
+
ReleaseDC(hwndDlg, hdcDlg);
- return;
-}
-
-/* Draw the current color on the color picker buttons */
-void
-UpdateButtonColor(HWND hwndDlg, int ID, int nButton, int nColor)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- HDC hdcColorButton, hdcCompat;
- RECT rect;
- HBRUSH hbrush;
- HWND hwndColorButton;
- COLORREF crColor = g->ThemeAdv.crColor[nColor];
-
- if(nColor != -1)
- {
- /* Create a DC to draw on */
- hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
- hdcColorButton = GetDC(hwndColorButton);
- hdcCompat = CreateCompatibleDC(hdcColorButton);
- ReleaseDC(hwndColorButton, hdcColorButton);
-
- /* Select the button image to it */
- HGDIOBJ hgdiTmp = SelectObject(hdcCompat, g->hbmpColor[nButton]);
-
- /* Create a brush and draw the rectangle */
- rect.left = 2; rect.top = 2; rect.right = 22; rect.bottom = 13;
- hbrush = CreateSolidBrush(crColor);
- FillRect(hdcCompat, &rect, hbrush);
- DeleteObject(hbrush);
-
- /* hdcCompat is not needed anymore */
- SelectObject(hdcCompat,hgdiTmp);
- DeleteDC(hdcCompat);
-
- SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP,
(LPARAM)g->hbmpColor[nButton]);
- EnableWindow(GetDlgItem(hwndDlg, ID), TRUE);
- } else {
- SendDlgItemMessage(hwndDlg, ID, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)NULL);
- EnableWindow(GetDlgItem(hwndDlg, ID), FALSE);
- }
- return;
-}
+}
+
/* Select a color using a color picker */
-BOOL
-GetColor(HWND hwndDlg, int iElement, int nButton)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+static BOOL
+GetColor(HWND hwndDlg, GLOBALS* g, INT nButton)
+{
CHOOSECOLOR cc;
COLORREF crCustom[16] = { 0 };
COLORREF crColor;
- int ID = 0;
- int ColorIndex = 0;
+ INT ID = 0;
+ INT ColorIndex = 0;
/* Get the color index from the element index and button number */
- if (nButton == 0)
- {
- ColorIndex = g_Assignment[iElement].Color1;
- ID = IDC_ADVAPPEARANCE_COLOR1_B;
- }
- if (nButton == 1)
- {
- ColorIndex = g_Assignment[iElement].Color2;
- ID = IDC_ADVAPPEARANCE_COLOR2_B;
- }
- if (nButton == 2)
- {
- ColorIndex = g_Assignment[iElement].FontColor;
- ID = IDC_ADVAPPEARANCE_FONTCOLOR_B;
- }
+ switch (nButton)
+ {
+ case 0:
+ ColorIndex = g_Assignment[g->CurrentElement].Color1;
+ ID = IDC_ADVAPPEARANCE_COLOR1_B;
+ break;
+
+ case 1:
+ ColorIndex = g_Assignment[g->CurrentElement].Color2;
+ ID = IDC_ADVAPPEARANCE_COLOR2_B;
+ break;
+
+ case 2:
+ ColorIndex = g_Assignment[g->CurrentElement].FontColor;
+ ID = IDC_ADVAPPEARANCE_FONTCOLOR_B;
+ break;
+ }
+
crColor = g->ThemeAdv.crColor[ColorIndex];
/* Prepare cc structure */
@@ -459,9 +292,186 @@
g->ThemeAdv.crColor[ColorIndex] = cc.rgbResult;
if (crColor != cc.rgbResult)
{
- UpdateButtonColor(hwndDlg, ID, nButton, ColorIndex);
- return(TRUE);
+ UpdateButtonColor(hwndDlg, g, ID, nButton, ColorIndex);
+ return TRUE;
}
}
- return(FALSE);
-}
+
+ return FALSE;
+}
+
+
+/* Initialize the advanced appearance dialog */
+static VOID
+AdvAppearanceDlg_Init(HWND hwndDlg, GLOBALS *g)
+{
+ INT i, iElement, iListIndex, iDeskIndex = 0;
+ TCHAR tstrText[80];
+ LOGFONT lfFont;
+ LOGFONT lfButtonFont;
+ HFONT hMyFont;
+ HDC hScreenDC;
+ TCHAR Size[4];
+
+ /* Copy the current theme values */
+ g->ThemeAdv = g->Theme;
+
+ /* Add the elements to the combo */
+ for (iElement = 0; iElement < NUM_ELEMENTS; iElement++)
+ {
+ LoadString(hApplet, IDS_ELEMENT_1 + iElement, (LPTSTR)&tstrText, 79);
+ iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_ADDSTRING, 0,
(LPARAM)&tstrText);
+ SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETITEMDATA,
(WPARAM)iListIndex, (LPARAM)iElement);
+ }
+
+ /* Get the list index of the desktop element */
+ for (iListIndex = 0; iListIndex < NUM_ELEMENTS; iListIndex++)
+ {
+ iElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETITEMDATA,
(WPARAM)iListIndex, 0);
+ if (iElement == 0)
+ {
+ iDeskIndex = iListIndex;
+ break;
+ }
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_SETCURSEL, iDeskIndex, 0);
+
+ /* Set colors for the color buttons */
+ g->crCOLOR_BTNFACE = g->Theme.crColor[COLOR_BTNFACE];
+ g->crCOLOR_BTNTEXT = g->Theme.crColor[COLOR_BTNTEXT];
+ g->crCOLOR_BTNSHADOW = g->Theme.crColor[COLOR_BTNSHADOW];
+ g->crCOLOR_BTNHIGHLIGHT = g->Theme.crColor[COLOR_BTNHIGHLIGHT];
+
+ /* Create font for bold button */
+ lfButtonFont = g->Theme.lfFont[FONT_DIALOG];
+ lfButtonFont.lfWeight = FW_BOLD;
+ lfButtonFont.lfItalic = FALSE;
+ hMyFont = CreateFontIndirect(&lfButtonFont);
+ if (hMyFont)
+ {
+ if (g->hBoldFont)
+ DeleteObject(g->hBoldFont);
+
+ g->hBoldFont = hMyFont;
+ }
+
+ /* Create font for italic button */
+ lfButtonFont.lfWeight = FW_REGULAR;
+ lfButtonFont.lfItalic = TRUE;
+ hMyFont = CreateFontIndirect(&lfButtonFont);
+ if (hMyFont)
+ {
+ if (g->hItalicFont)
+ DeleteObject(g->hItalicFont);
+
+ g->hItalicFont = hMyFont;
+ }
+
+ /* Set the fonts for the font style buttons */
+ SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTBOLD, WM_SETFONT,
(WPARAM)g->hBoldFont, (LPARAM)TRUE);
+ SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTITALIC, WM_SETFONT,
(WPARAM)g->hItalicFont, (LPARAM)TRUE);
+
+ /* Draw Bitmaps for the colorbuttons */
+ InitColorButtons(hwndDlg, g);
+
+ /* Make the UpDown control count correctly */
+ SendMessage (GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_SIZE_UD), UDM_SETRANGE, 0L, MAKELONG
(200, 1));
+
+ /* Fill font selection combo */
+ lfFont.lfCharSet = DEFAULT_CHARSET;
+ lfFont.lfFaceName[0] = (TCHAR)0;
+ lfFont.lfPitchAndFamily = 0;
+ hScreenDC = GetDC(0);
+ EnumFontFamiliesEx(hScreenDC, &lfFont, (FONTENUMPROC)EnumFontFamExProc,
(LPARAM)GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_FONT_C), 0);
+ ReleaseDC(0, hScreenDC);
+
+ /* Fill font size combo */
+ for (i = 6; i <= 24; i++)
+ {
+ SetDlgItemInt(hwndDlg, IDC_CONVERT, i, FALSE);
+ GetDlgItemText(hwndDlg, IDC_CONVERT, (LPTSTR)&Size, 3);
+ SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTSIZE_E, CB_ADDSTRING, 0,
(LPARAM)&Size);
+ }
+
+ /* Update the controls */
+ iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL, 0,
0);
+ g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT,
CB_GETITEMDATA, (WPARAM)iListIndex, 0);
+ UpdateControls(hwndDlg, g);
+}
+
+
+static VOID
+AdvAppearanceDlg_CleanUp(HWND hwndDlg, GLOBALS* g)
+{
+ DeleteObject(g->hBoldFont);
+ DeleteObject(g->hItalicFont);
+}
+
+
+INT_PTR CALLBACK
+AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ INT iListIndex;
+ GLOBALS* g;
+
+ g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ g = (GLOBALS*)lParam;
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
+ AdvAppearanceDlg_Init(hwndDlg, g);
+ break;
+
+ case WM_DESTROY:
+ AdvAppearanceDlg_CleanUp(hwndDlg, g);
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDOK:
+ SaveCurrentValues(hwndDlg, g);
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case IDCANCEL:
+ g->ThemeAdv = g->Theme;
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case IDC_ADVAPPEARANCE_ELEMENT:
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ SaveCurrentValues(hwndDlg, g);
+ iListIndex = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT, CB_GETCURSEL,
0, 0);
+ g->CurrentElement = SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_ELEMENT,
CB_GETITEMDATA, (WPARAM)iListIndex, 0);
+ UpdateControls(hwndDlg, g);
+ }
+ break;
+
+ case IDC_ADVAPPEARANCE_COLOR1_B:
+ GetColor(hwndDlg, g, 0);
+ break;
+
+ case IDC_ADVAPPEARANCE_COLOR2_B:
+ GetColor(hwndDlg, g, 1);
+ break;
+
+ case IDC_ADVAPPEARANCE_FONTCOLOR_B:
+ GetColor(hwndDlg, g, 2);
+ break;
+
+ default:
+ return FALSE;
+ }
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
Modified: trunk/reactos/dll/cpl/desk/appearance.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.c?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.c (original)
+++ trunk/reactos/dll/cpl/desk/appearance.c Thu Feb 15 23:24:38 2007
@@ -95,109 +95,240 @@
/******************************************************************************/
-INT_PTR CALLBACK
-AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- INT i, index;
- GLOBALS* g = NULL;
-
- switch(uMsg)
- {
- case WM_INITDIALOG:
+static VOID
+LoadCurrentTheme(GLOBALS* g)
+{
+ INT i;
+ NONCLIENTMETRICS NonClientMetrics;
+
+ g->Theme.bHasChanged = FALSE;
+ /* FIXME: it may be custom! */
+ g->Theme.bIsCustom = FALSE;
+
+ /* Load colors */
+ for (i = 0; i <= 30; i++)
+ {
+ g->ColorList[i] = i;
+ g->Theme.crColor[i] = (COLORREF)GetSysColor(i);
+ }
+
+ /* Load sizes */
+ for (i = 0; i <= 11; i++)
+ {
+ g->Theme.Size[i] = GetSystemMetrics(g_SizeMetric[i]);
+ }
+
+ /* Load fonts */
+ NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
+ g->Theme.lfFont[FONT_CAPTION] = NonClientMetrics.lfCaptionFont;
+ g->Theme.lfFont[FONT_SMCAPTION] = NonClientMetrics.lfSmCaptionFont;
+ g->Theme.lfFont[FONT_MENU] = NonClientMetrics.lfMenuFont;
+ g->Theme.lfFont[FONT_INFO] = NonClientMetrics.lfStatusFont;
+ g->Theme.lfFont[FONT_DIALOG] = NonClientMetrics.lfMessageFont;
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT),
&g->Theme.lfFont[FONT_ICON], 0);
+}
+
+
+static VOID
+LoadThemeFromReg(GLOBALS* g, INT iPreset)
+{
+ INT i;
+ TCHAR strSizeName[20] = {TEXT("Sizes\\0")};
+ TCHAR strValueName[10];
+ HKEY hkNewSchemes, hkScheme, hkSize;
+ DWORD dwType, dwLength;
+
+ if(RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance\\New
Schemes"),
+ 0, KEY_READ, &hkNewSchemes) == ERROR_SUCCESS)
+ {
+ if(RegOpenKeyEx(hkNewSchemes, g->ThemeTemplates[iPreset].strKeyName, 0, KEY_READ,
&hkScheme) == ERROR_SUCCESS)
{
- AppearancePage_Init(hwndDlg);
- break;
+ lstrcpyn(&strSizeName[6],g->ThemeTemplates[iPreset].strSizeName, 3);
+ if(RegOpenKeyEx(hkScheme, strSizeName, 0, KEY_READ, &hkSize) == ERROR_SUCCESS)
+ {
+ dwLength = sizeof(BOOL);
+ RegQueryValueEx(hkSize, TEXT("FlatMenus"), NULL, &dwType,
(LPBYTE)&g->Theme.bFlatMenus, &dwLength);
+
+ for (i = 0; i <= 30; i++)
+ {
+ wsprintf(strValueName, TEXT("Color #%d"), i);
+ dwLength = sizeof(COLORREF);
+ RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.crColor[i], &dwLength);
+ }
+ for (i = 0; i <= 5; i++)
+ {
+ wsprintf(strValueName, TEXT("Font #%d"), i);
+ dwLength = sizeof(LOGFONT);
+ g->Theme.lfFont[i].lfFaceName[0] = 'x';
+ RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.lfFont[i], &dwLength);
+ }
+ for (i = 0; i <= 8; i++)
+ {
+ wsprintf(strValueName, TEXT("Size #%d"), i);
+ dwLength = sizeof(DWORD);
+ RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.Size[i], &dwLength);
+ }
+ RegCloseKey(hkScheme);
+ }
+ RegCloseKey(hkScheme);
}
- case WM_DESTROY:
+ RegCloseKey(hkNewSchemes);
+ }
+}
+
+
+static VOID
+ApplyTheme(GLOBALS* g)
+{
+ INT i, Result;
+ HKEY hKey;
+ DWORD dwDisposition = 0;
+ TCHAR clText[16] = {0};
+ NONCLIENTMETRICS NonClientMetrics;
+ HFONT hMyFont;
+ LOGFONT lfButtonFont;
+
+ if (!g->Theme.bHasChanged)
+ return;
+
+ g->Theme.bHasChanged = FALSE;
+
+ /* Update some globals */
+ g->crCOLOR_BTNFACE = g->Theme.crColor[COLOR_BTNFACE];
+ g->crCOLOR_BTNTEXT = g->Theme.crColor[COLOR_BTNTEXT];
+ g->crCOLOR_BTNSHADOW = g->Theme.crColor[COLOR_BTNSHADOW];
+ g->crCOLOR_BTNHIGHLIGHT = g->Theme.crColor[COLOR_BTNHIGHLIGHT];
+ lfButtonFont = g->Theme.lfFont[FONT_DIALOG];
+
+ /* Create new font for bold button */
+ lfButtonFont.lfWeight = FW_BOLD;
+ lfButtonFont.lfItalic = FALSE;
+ hMyFont = CreateFontIndirect(&lfButtonFont);
+ if (hMyFont)
+ {
+ if (g->hBoldFont)
+ DeleteObject(g->hBoldFont);
+ g->hBoldFont = hMyFont;
+ }
+
+ /* Create new font for italic button */
+ lfButtonFont.lfWeight = FW_REGULAR;
+ lfButtonFont.lfItalic = TRUE;
+ hMyFont = CreateFontIndirect(&lfButtonFont);
+ if (hMyFont)
+ {
+ if (g->hItalicFont)
+ DeleteObject(g->hItalicFont);
+ g->hItalicFont = hMyFont;
+ }
+
+ /* Apply Colors from global variable */
+ SetSysColors(30, &g->ColorList[0], &g->Theme.crColor[0]);
+
+ /* Save colors to registry */
+ Result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0,
KEY_ALL_ACCESS, &hKey);
+ if (Result != ERROR_SUCCESS)
+ {
+ /* Could not open the key, try to create it */
+ Result = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0,
NULL, 0, KEY_ALL_ACCESS, NULL,&hKey, &dwDisposition);
+ }
+
+ if (Result == ERROR_SUCCESS)
+ {
+ for (i = 0; i <= 30; i++)
{
- AppearancePage_CleanUp(hwndDlg);
- break;
+ DWORD red = GetRValue(g->Theme.crColor[i]);
+ DWORD green = GetGValue(g->Theme.crColor[i]);
+ DWORD blue = GetBValue(g->Theme.crColor[i]);
+ wsprintf(clText, TEXT("%d %d %d"), red, green, blue);
+ RegSetValueEx(hKey, g_RegColorNames[i], 0, REG_SZ, (BYTE *)clText, lstrlen( clText
)*sizeof(TCHAR) + sizeof(TCHAR));
}
- case WM_COMMAND:
- {
- g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- switch(LOWORD(wParam))
- {
- case IDC_APPEARANCE_ADVANCED:
- {
- DialogBoxParam(hApplet, (LPCTSTR)IDD_ADVAPPEARANCE,
- hwndDlg, AdvAppearanceDlgProc, (LPARAM)g);
-
- /* Was anything changed in the advanced appearance dialog? */
- if (memcmp(&g->Theme, &g->ThemeAdv, sizeof(THEME)) != 0)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- g->Theme = g->ThemeAdv;
- g->Theme.bHasChanged = TRUE;
- }
- break;
- }
- case IDC_APPEARANCE_COLORSCHEME:
- {
- if(HIWORD(wParam) == CBN_SELCHANGE)
- {
- PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
- g->Theme.bHasChanged = TRUE;
- i = SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_COLORSCHEME, CB_GETCURSEL, 0, 0);
- index = SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_COLORSCHEME, CB_GETITEMDATA,
(WPARAM)i, 0);
- LoadThemeFromReg(g, index);
- break;
- }
- break;
- }
- default:
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- case WM_NOTIFY:
- {
- g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- LPNMHDR lpnm = (LPNMHDR)lParam;
- switch(lpnm->code)
- {
- case PSN_APPLY:
- {
- if (g->Theme.bHasChanged)
- {
- ApplyTheme(g);
- }
- return(TRUE);
- break;
- }
- default:
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- default:
- {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-void
-AppearancePage_Init(HWND hwndDlg)
-{
- GLOBALS* g;
+
+ RegCloseKey(hKey);
+ }
+
+ /* Apply the fonts */
+ NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
+ NonClientMetrics.lfCaptionFont = g->Theme.lfFont[FONT_CAPTION];
+ NonClientMetrics.lfSmCaptionFont = g->Theme.lfFont[FONT_SMCAPTION];
+ NonClientMetrics.lfMenuFont = g->Theme.lfFont[FONT_MENU];
+ NonClientMetrics.lfStatusFont = g->Theme.lfFont[FONT_INFO];
+ NonClientMetrics.lfMessageFont = g->Theme.lfFont[FONT_DIALOG];
+ SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
+ SystemParametersInfo(SPI_SETICONTITLELOGFONT, sizeof(LOGFONT),
&g->Theme.lfFont[FONT_ICON], 0);
+
+ /* FIXME: Apply size metrics */
+
+ /* Save fonts and size metrics to registry */
+ Result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control
Panel\\Desktop\\WindowMetrics"), 0, KEY_ALL_ACCESS, &hKey);
+ if (Result != ERROR_SUCCESS)
+ {
+ /* Could not open the key, try to create it */
+ Result = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control
Panel\\Desktop\\WindowMetrics"), 0, NULL, 0, KEY_ALL_ACCESS, NULL,&hKey,
&dwDisposition);
+ }
+
+ if (Result == ERROR_SUCCESS)
+ {
+ RegSetValueEx(hKey, TEXT("CaptionFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_CAPTION], sizeof(LOGFONT));
+ RegSetValueEx(hKey, TEXT("SmCaptionFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_SMCAPTION], sizeof(LOGFONT));
+ RegSetValueEx(hKey, TEXT("IconFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_ICON], sizeof(LOGFONT));
+ RegSetValueEx(hKey, TEXT("MenuFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_MENU], sizeof(LOGFONT));
+ RegSetValueEx(hKey, TEXT("StatusFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_INFO], sizeof(LOGFONT));
+ RegSetValueEx(hKey, TEXT("MessageFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_DIALOG], sizeof(LOGFONT));
+
+ /* Save size metrics to registry */
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_BORDER_X]);
+ RegSetValueEx(hKey, TEXT("BorderWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_CAPTION_Y]);
+ RegSetValueEx(hKey, TEXT("CaptionWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_CAPTION_Y]);
+ RegSetValueEx(hKey, TEXT("CaptionHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SMCAPTION_Y]);
+ RegSetValueEx(hKey, TEXT("SmCaptionWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SMCAPTION_Y]);
+ RegSetValueEx(hKey, TEXT("SmCaptionHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_ICON_SPC_X]);
+ RegSetValueEx(hKey, TEXT("IconSpacing"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_ICON_SPC_Y]);
+ RegSetValueEx(hKey, TEXT("IconVerticalSpacing"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_MENU_X]);
+ RegSetValueEx(hKey, TEXT("MenuWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_MENU_Y]);
+ RegSetValueEx(hKey, TEXT("MenuHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SCROLL_X]);
+ RegSetValueEx(hKey, TEXT("ScrollWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SCROLL_Y]);
+ RegSetValueEx(hKey, TEXT("ScrollHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+ wsprintf(clText, TEXT("%d"), g->Theme.Size[SIZE_ICON_X]);
+ RegSetValueEx(hKey, TEXT("Shell Icon Sizet"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
+
+ RegCloseKey(hKey);
+ }
+}
+
+
+/* Draw the preview window, unimplemented */
+#if 0
+static VOID
+DrawPreview(HWND hwndPreview, THEME* pTheme)
+{
+}
+#endif
+
+
+static VOID
+AppearancePage_Init(HWND hwndDlg, GLOBALS *g)
+{
HKEY hkNewSchemes, hkScheme, hkSizes, hkSize;
FILETIME ftLastWriteTime;
TCHAR strSelectedStyle[4];
DWORD dwLength, dwType;
DWORD dwDisposition = 0;
- int iStyle, iSize, iTemplateIndex, iListIndex = 0;
- int Result;
-
- g = (GLOBALS*)malloc(sizeof(GLOBALS));
- // FIXME: correct handling of error (g == NULL)
-
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
+ INT iStyle, iSize, iTemplateIndex, iListIndex = 0;
+ INT Result;
+
LoadCurrentTheme(g);
/* Fill color schemes combo */
@@ -264,230 +395,91 @@
RegCloseKey(hkNewSchemes);
}
SendMessage(GetDlgItem(hwndDlg, IDC_APPEARANCE_COLORSCHEME), LB_SETCURSEL, 0, 0);
- return;
-}
-
-void
-AppearancePage_CleanUp(HWND hwndDlg)
-{
- GLOBALS* g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
- free(g);
- return;
-}
-
-void
-LoadCurrentTheme(GLOBALS* g)
-{
- int i;
- NONCLIENTMETRICS NonClientMetrics;
-
- g->Theme.bHasChanged = FALSE;
- /* FIXME: it may be custom! */
- g->Theme.bIsCustom = FALSE;
-
- /* Load colors */
- for(i = 0; i <= 30; i++)
- {
- g->ColorList[i] = i;
- g->Theme.crColor[i] = (COLORREF)GetSysColor(i);
- }
-
- /* Load sizes */
- for(i = 0; i <= 11; i++)
- {
- g->Theme.Size[i] = GetSystemMetrics(g_SizeMetric[i]);
- }
-
- /* Load fonts */
- NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
- g->Theme.lfFont[FONT_CAPTION] = NonClientMetrics.lfCaptionFont;
- g->Theme.lfFont[FONT_SMCAPTION] = NonClientMetrics.lfSmCaptionFont;
- g->Theme.lfFont[FONT_MENU] = NonClientMetrics.lfMenuFont;
- g->Theme.lfFont[FONT_INFO] = NonClientMetrics.lfStatusFont;
- g->Theme.lfFont[FONT_DIALOG] = NonClientMetrics.lfMessageFont;
- SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT),
&g->Theme.lfFont[FONT_ICON], 0);
-
- return;
-}
-
-void
-LoadThemeFromReg(GLOBALS* g, INT iPreset)
-{
- int i;
- TCHAR strSizeName[20] = {TEXT("Sizes\\0")};
- TCHAR strValueName[10];
- HKEY hkNewSchemes, hkScheme, hkSize;
- DWORD dwType, dwLength;
-
- if(RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Appearance\\New
Schemes"),
- 0, KEY_READ, &hkNewSchemes) == ERROR_SUCCESS)
- {
- if(RegOpenKeyEx(hkNewSchemes, g->ThemeTemplates[iPreset].strKeyName, 0, KEY_READ,
&hkScheme) == ERROR_SUCCESS)
- {
- lstrcpyn(&strSizeName[6],g->ThemeTemplates[iPreset].strSizeName, 3);
- if(RegOpenKeyEx(hkScheme, strSizeName, 0, KEY_READ, &hkSize) == ERROR_SUCCESS)
+}
+
+
+static VOID
+AppearancePage_CleanUp(HWND hwndDlg, GLOBALS *g)
+{
+}
+
+
+INT_PTR CALLBACK
+AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ INT i, index;
+ GLOBALS *g;
+ LPNMHDR lpnm;
+
+ g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ g = (GLOBALS*)malloc(sizeof(GLOBALS));
+ if (g == NULL)
+ return FALSE;
+
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
+ AppearancePage_Init(hwndDlg, g);
+ break;
+
+ case WM_DESTROY:
+ AppearancePage_CleanUp(hwndDlg, g);
+ free(g);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
{
- dwLength = sizeof(BOOL);
- RegQueryValueEx(hkSize, TEXT("FlatMenus"), NULL, &dwType,
(LPBYTE)&g->Theme.bFlatMenus, &dwLength);
-
- for (i = 0; i <= 30; i++)
- {
- wsprintf(strValueName, TEXT("Color #%d"), i);
- dwLength = sizeof(COLORREF);
- RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.crColor[i], &dwLength);
- }
- for (i = 0; i <= 5; i++)
- {
- wsprintf(strValueName, TEXT("Font #%d"), i);
- dwLength = sizeof(LOGFONT);
- g->Theme.lfFont[i].lfFaceName[0] = 'x';
- RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.lfFont[i], &dwLength);
- }
- for (i = 0; i <= 8; i++)
- {
- wsprintf(strValueName, TEXT("Size #%d"), i);
- dwLength = sizeof(DWORD);
- RegQueryValueEx(hkSize, strValueName, NULL, &dwType,
(LPBYTE)&g->Theme.Size[i], &dwLength);
- }
- RegCloseKey(hkScheme);
+ case IDC_APPEARANCE_ADVANCED:
+ DialogBoxParam(hApplet, (LPCTSTR)IDD_ADVAPPEARANCE,
+ hwndDlg, AdvAppearanceDlgProc, (LPARAM)g);
+
+ /* Was anything changed in the advanced appearance dialog? */
+ if (memcmp(&g->Theme, &g->ThemeAdv, sizeof(THEME)) != 0)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ g->Theme = g->ThemeAdv;
+ g->Theme.bHasChanged = TRUE;
+ }
+ break;
+
+ case IDC_APPEARANCE_COLORSCHEME:
+ if(HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+ g->Theme.bHasChanged = TRUE;
+ i = SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_COLORSCHEME, CB_GETCURSEL, 0, 0);
+ index = SendDlgItemMessage(hwndDlg, IDC_APPEARANCE_COLORSCHEME, CB_GETITEMDATA,
(WPARAM)i, 0);
+ LoadThemeFromReg(g, index);
+ }
+ break;
+
+ default:
+ return FALSE;
}
- RegCloseKey(hkScheme);
- }
- RegCloseKey(hkNewSchemes);
- }
- return;
-}
-
-void
-ApplyTheme(GLOBALS* g)
-{
- int i, Result;
- HKEY hKey;
- DWORD dwDisposition = 0;
- TCHAR clText[16] = {0};
- NONCLIENTMETRICS NonClientMetrics;
- HFONT hMyFont;
- LOGFONT lfButtonFont;
-
- if (!g->Theme.bHasChanged) return;
-
- g->Theme.bHasChanged = FALSE;
-
- /* Update some globals */
- g->crCOLOR_BTNFACE = g->Theme.crColor[COLOR_BTNFACE];
- g->crCOLOR_BTNTEXT = g->Theme.crColor[COLOR_BTNTEXT];
- g->crCOLOR_BTNSHADOW = g->Theme.crColor[COLOR_BTNSHADOW];
- g->crCOLOR_BTNHIGHLIGHT = g->Theme.crColor[COLOR_BTNHIGHLIGHT];
- lfButtonFont = g->Theme.lfFont[FONT_DIALOG];
-
- /* Create new font for bold button */
- lfButtonFont.lfWeight = FW_BOLD;
- lfButtonFont.lfItalic = FALSE;
- hMyFont = CreateFontIndirect(&lfButtonFont);
- if (hMyFont)
- {
- if (g->hBoldFont) DeleteObject(g->hBoldFont);
- g->hBoldFont = hMyFont;
- }
-
- /* Create new font for italic button */
- lfButtonFont.lfWeight = FW_REGULAR;
- lfButtonFont.lfItalic = TRUE;
- hMyFont = CreateFontIndirect(&lfButtonFont);
- if (hMyFont)
- {
- if (g->hItalicFont) DeleteObject(g->hItalicFont);
- g->hItalicFont = hMyFont;
- }
-
- /* Apply Colors from global variable */
- SetSysColors(30, &g->ColorList[0], &g->Theme.crColor[0]);
-
- /* Save colors to registry */
- Result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0,
KEY_ALL_ACCESS, &hKey);
- if (Result != ERROR_SUCCESS)
- {
- /* Could not open the key, try to create it */
- Result = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control Panel\\Colors"), 0,
NULL, 0, KEY_ALL_ACCESS, NULL,&hKey, &dwDisposition);
- }
- if (Result == ERROR_SUCCESS)
- {
- for(i = 0; i <= 30; i++)
- {
- DWORD red = GetRValue(g->Theme.crColor[i]);
- DWORD green = GetGValue(g->Theme.crColor[i]);
- DWORD blue = GetBValue(g->Theme.crColor[i]);
- wsprintf(clText, TEXT("%d %d %d"), red, green, blue);
- RegSetValueEx(hKey, g_RegColorNames[i], 0, REG_SZ, (BYTE *)clText, lstrlen( clText
)*sizeof(TCHAR) + sizeof(TCHAR));
- }
- RegCloseKey(hKey);
- }
-
- /* Apply the fonts */
- NonClientMetrics.cbSize = sizeof(NONCLIENTMETRICS);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
- NonClientMetrics.lfCaptionFont = g->Theme.lfFont[FONT_CAPTION];
- NonClientMetrics.lfSmCaptionFont = g->Theme.lfFont[FONT_SMCAPTION];
- NonClientMetrics.lfMenuFont = g->Theme.lfFont[FONT_MENU];
- NonClientMetrics.lfStatusFont = g->Theme.lfFont[FONT_INFO];
- NonClientMetrics.lfMessageFont = g->Theme.lfFont[FONT_DIALOG];
- SystemParametersInfo(SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&NonClientMetrics, 0);
- SystemParametersInfo(SPI_SETICONTITLELOGFONT, sizeof(LOGFONT),
&g->Theme.lfFont[FONT_ICON], 0);
-
- /* FIXME: Apply size metrics */
-
- /* Save fonts and size metrics to registry */
- Result = RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Control
Panel\\Desktop\\WindowMetrics"), 0, KEY_ALL_ACCESS, &hKey);
- if (Result != ERROR_SUCCESS)
- {
- /* Could not open the key, try to create it */
- Result = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Control
Panel\\Desktop\\WindowMetrics"), 0, NULL, 0, KEY_ALL_ACCESS, NULL,&hKey,
&dwDisposition);
- }
- if (Result == ERROR_SUCCESS)
- {
- RegSetValueEx(hKey, TEXT("CaptionFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_CAPTION], sizeof(LOGFONT));
- RegSetValueEx(hKey, TEXT("SmCaptionFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_SMCAPTION], sizeof(LOGFONT));
- RegSetValueEx(hKey, TEXT("IconFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_ICON], sizeof(LOGFONT));
- RegSetValueEx(hKey, TEXT("MenuFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_MENU], sizeof(LOGFONT));
- RegSetValueEx(hKey, TEXT("StatusFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_INFO], sizeof(LOGFONT));
- RegSetValueEx(hKey, TEXT("MessageFont"), 0, REG_BINARY, (BYTE
*)&g->Theme.lfFont[FONT_DIALOG], sizeof(LOGFONT));
-
- /* Save size metrics to registry */
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_BORDER_X]);
- RegSetValueEx(hKey, TEXT("BorderWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_CAPTION_Y]);
- RegSetValueEx(hKey, TEXT("CaptionWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_CAPTION_Y]);
- RegSetValueEx(hKey, TEXT("CaptionHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SMCAPTION_Y]);
- RegSetValueEx(hKey, TEXT("SmCaptionWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SMCAPTION_Y]);
- RegSetValueEx(hKey, TEXT("SmCaptionHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_ICON_SPC_X]);
- RegSetValueEx(hKey, TEXT("IconSpacing"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_ICON_SPC_Y]);
- RegSetValueEx(hKey, TEXT("IconVerticalSpacing"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_MENU_X]);
- RegSetValueEx(hKey, TEXT("MenuWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_MENU_Y]);
- RegSetValueEx(hKey, TEXT("MenuHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SCROLL_X]);
- RegSetValueEx(hKey, TEXT("ScrollWidth"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), -15 * g->Theme.Size[SIZE_SCROLL_Y]);
- RegSetValueEx(hKey, TEXT("ScrollHeight"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
- wsprintf(clText, TEXT("%d"), g->Theme.Size[SIZE_ICON_X]);
- RegSetValueEx(hKey, TEXT("Shell Icon Sizet"), 0, REG_SZ, (BYTE *)clText,
sizeof(clText));
-
- RegCloseKey(hKey);
- }
- return;
-}
-
-/* Draw the preview window, unimplemented */
-void
-DrawPreview(HWND hwndPreview, THEME* pTheme)
-{
- return;
-}
-
+ return TRUE;
+
+ case WM_NOTIFY:
+ lpnm = (LPNMHDR)lParam;
+ switch (lpnm->code)
+ {
+ case PSN_APPLY:
+ if (g->Theme.bHasChanged)
+ {
+ ApplyTheme(g);
+ }
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
Modified: trunk/reactos/dll/cpl/desk/appearance.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.h?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.h (original)
+++ trunk/reactos/dll/cpl/desk/appearance.h Thu Feb 15 23:24:38 2007
@@ -85,19 +85,6 @@
/* prototypes for appearance.c */
INT_PTR CALLBACK AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam);
-void AppearancePage_Init(HWND hwndDlg);
-void AppearancePage_CleanUp(HWND hwndDlg);
-void LoadCurrentTheme(GLOBALS* g);
-void LoadThemeFromReg(GLOBALS* g, INT iPreset);
-void ApplyTheme(GLOBALS* g);
/* prototypes for advappearancedlg.c */
INT_PTR CALLBACK AdvAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
lParam);
-void AdvAppearanceDlg_Init(HWND hwndDlg);
-void AdvAppearanceDlg_CleanUp(HWND hwndDlg);
-void UpdateControls(HWND hwndDlg, int iElement);
-void SaveCurrentValues(HWND hwndDlg);
-void InitColorButtons(HWND hwndDlg);
-void UpdateButtonColor(HWND hwndDlg, int ID, int nButton, int nColor);
-BOOL GetColor(HWND hwndDlg, int iElement, int nButton);
-int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX*, NEWTEXTMETRICEX*, DWORD, LPARAM);