2 * Support for system colors
4 * Copyright David W. Metcalfe, 1993
5 * Copyright Alexandre Julliard, 1994
15 /* #define DEBUG_SYSCOLOR */
18 struct SysColorObjects sysColorObjects;
20 static const char * const DefSysColors[] =
22 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
23 "Background", "192 192 192", /* COLOR_BACKGROUND */
24 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
25 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
26 "Menu", "255 255 255", /* COLOR_MENU */
27 "Window", "255 255 255", /* COLOR_WINDOW */
28 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
29 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
30 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
31 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
32 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
33 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
34 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
35 "Hilight", "166 202 240", /* COLOR_HIGHLIGHT */
36 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
37 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
38 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
39 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
40 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
41 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
42 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
43 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
44 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
45 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
46 "InfoBackground", "255 255 192" /* COLOR_INFOBK */
49 static const char * const DefSysColors95[] =
51 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
52 "Background", "192 192 192", /* COLOR_BACKGROUND */
53 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
54 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
55 "Menu", "192 192 192", /* COLOR_MENU */
56 "Window", "255 255 255", /* COLOR_WINDOW */
57 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
58 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
59 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
60 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
61 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
62 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
63 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
64 "Hilight", "166 202 240", /* COLOR_HIGHLIGHT */
65 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
66 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
67 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
68 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
69 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
70 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
71 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
72 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
73 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
74 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
75 "InfoBackground", "255 255 192" /* COLOR_INFOBK */
79 #define NUM_SYS_COLORS (COLOR_INFOBK+1)
81 static COLORREF SysColors[NUM_SYS_COLORS];
83 #define MAKE_SOLID(color) \
84 (PALETTEINDEX(GetNearestPaletteIndex32(STOCK_DEFAULT_PALETTE,(color))))
86 /*************************************************************************
89 static void SYSCOLOR_SetColor( int index, COLORREF color )
91 if (index < 0 || index >= NUM_SYS_COLORS) return;
92 SysColors[index] = color;
96 DeleteObject32( sysColorObjects.hbrushScrollbar );
97 sysColorObjects.hbrushScrollbar = CreateSolidBrush32( color );
99 case COLOR_BACKGROUND:
101 case COLOR_ACTIVECAPTION:
102 DeleteObject32( sysColorObjects.hbrushActiveCaption );
103 sysColorObjects.hbrushActiveCaption = CreateSolidBrush32( color );
105 case COLOR_INACTIVECAPTION:
106 DeleteObject32( sysColorObjects.hbrushInactiveCaption );
107 sysColorObjects.hbrushInactiveCaption = CreateSolidBrush32( color );
110 DeleteObject32( sysColorObjects.hbrushMenu );
111 sysColorObjects.hbrushMenu = CreateSolidBrush32( MAKE_SOLID(color) );
114 DeleteObject32( sysColorObjects.hbrushWindow );
115 sysColorObjects.hbrushWindow = CreateSolidBrush32( color );
117 case COLOR_WINDOWFRAME:
118 DeleteObject32( sysColorObjects.hpenWindowFrame );
119 sysColorObjects.hpenWindowFrame = CreatePen32( PS_SOLID, 1, color );
123 case COLOR_WINDOWTEXT:
124 DeleteObject32( sysColorObjects.hpenWindowText );
125 sysColorObjects.hpenWindowText = CreatePen32( PS_DOT, 1, color );
127 case COLOR_CAPTIONTEXT:
129 case COLOR_ACTIVEBORDER:
130 DeleteObject32( sysColorObjects.hbrushActiveBorder );
131 sysColorObjects.hbrushActiveBorder = CreateSolidBrush32( color );
133 case COLOR_INACTIVEBORDER:
134 DeleteObject32( sysColorObjects.hbrushInactiveBorder );
135 sysColorObjects.hbrushInactiveBorder = CreateSolidBrush32( color );
137 case COLOR_APPWORKSPACE:
139 case COLOR_HIGHLIGHT:
140 DeleteObject32( sysColorObjects.hbrushHighlight );
141 sysColorObjects.hbrushHighlight = CreateSolidBrush32(MAKE_SOLID(color));
143 case COLOR_HIGHLIGHTTEXT:
146 DeleteObject32( sysColorObjects.hbrushBtnFace );
147 sysColorObjects.hbrushBtnFace = CreateSolidBrush32( color );
149 case COLOR_BTNSHADOW:
150 DeleteObject32( sysColorObjects.hbrushBtnShadow );
151 sysColorObjects.hbrushBtnShadow = CreateSolidBrush32( color );
155 case COLOR_INACTIVECAPTIONTEXT:
157 case COLOR_BTNHIGHLIGHT:
158 DeleteObject32( sysColorObjects.hbrushBtnHighlight );
159 sysColorObjects.hbrushBtnHighlight = CreateSolidBrush32( color );
161 case COLOR_3DDKSHADOW:
170 /*************************************************************************
173 void SYSCOLOR_Init(void)
176 const char * const *p;
179 for (i = 0, p = TWEAK_Win95Look ? DefSysColors95 : DefSysColors;
180 i < NUM_SYS_COLORS; i++, p += 2)
182 GetProfileString32A( "colors", p[0], p[1], buffer, 100 );
183 if (sscanf( buffer, " %d %d %d", &r, &g, &b ) != 3) r = g = b = 0;
184 SYSCOLOR_SetColor( i, RGB(r,g,b) );
189 /*************************************************************************
190 * GetSysColor16 (USER.180)
192 COLORREF WINAPI GetSysColor16( INT16 nIndex )
194 return GetSysColor32 (nIndex);
198 /*************************************************************************
199 * GetSysColor32 (USER32.288)
201 COLORREF WINAPI GetSysColor32( INT32 nIndex )
203 if (nIndex >= 0 && nIndex < NUM_SYS_COLORS)
204 return SysColors[nIndex];
210 /*************************************************************************
211 * SetSysColors16 (USER.181)
213 /* FIXME -- check return type and insert comment if correct. */
214 VOID WINAPI SetSysColors16( INT16 nChanges, const INT16 *lpSysColor,
215 const COLORREF *lpColorValues )
219 for (i = 0; i < nChanges; i++)
221 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
224 /* Send WM_SYSCOLORCHANGE message to all windows */
226 SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
228 /* Repaint affected portions of all visible windows */
230 RedrawWindow32( GetDesktopWindow32(), NULL, 0,
231 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
235 /*************************************************************************
236 * SetSysColors32 (USER32.504)
238 BOOL32 WINAPI SetSysColors32( INT32 nChanges, const INT32 *lpSysColor,
239 const COLORREF *lpColorValues )
243 for (i = 0; i < nChanges; i++)
245 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
248 /* Send WM_SYSCOLORCHANGE message to all windows */
250 SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
252 /* Repaint affected portions of all visible windows */
254 RedrawWindow32( GetDesktopWindow32(), NULL, 0,
255 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );