Added initialisation of the pixmap_depth field in
[wine/testsucceed.git] / windows / syscolor.c
blobeade0c342ee99b13ac766ab7e2ba9d2ce6260289
1 /*
2 * Support for system colors
4 * Copyright David W. Metcalfe, 1993
5 * Copyright Alexandre Julliard, 1994
7 */
9 #include <assert.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include "winbase.h"
13 #include "winuser.h"
14 #include "debug.h"
15 #include "tweak.h"
17 static const char * const DefSysColors[] =
19 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
20 "Background", "192 192 192", /* COLOR_BACKGROUND */
21 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
22 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
23 "Menu", "255 255 255", /* COLOR_MENU */
24 "Window", "255 255 255", /* COLOR_WINDOW */
25 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
26 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
27 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
28 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
29 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
30 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
31 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
32 "Hilight", "224 224 224", /* COLOR_HIGHLIGHT */
33 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
34 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
35 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
36 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
37 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
38 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
39 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
40 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
41 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
42 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
43 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
44 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
45 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
46 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
47 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
50 static const char * const DefSysColors95[] =
52 "Scrollbar", "223 223 223", /* COLOR_SCROLLBAR */
53 "Background", "192 192 192", /* COLOR_BACKGROUND */
54 "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */
55 "InactiveTitle", "128 128 128", /* COLOR_INACTIVECAPTION */
56 "Menu", "192 192 192", /* COLOR_MENU */
57 "Window", "255 255 255", /* COLOR_WINDOW */
58 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
59 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
60 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
61 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
62 "ActiveBorder", "192 192 192", /* COLOR_ACTIVEBORDER */
63 "InactiveBorder", "192 192 192", /* COLOR_INACTIVEBORDER */
64 "AppWorkspace", "128 128 128", /* COLOR_APPWORKSPACE */
65 "Hilight", "0 0 128", /* COLOR_HIGHLIGHT */
66 "HilightText", "255 255 255", /* COLOR_HIGHLIGHTTEXT */
67 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
68 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
69 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
70 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
71 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
72 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
73 "3DDarkShadow", "0 0 0", /* COLOR_3DDKSHADOW */
74 "3DLight", "223 223 223", /* COLOR_3DLIGHT */
75 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
76 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
77 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
78 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
79 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
80 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
84 #define NUM_SYS_COLORS (COLOR_GRADIENTINACTIVECAPTION+1)
86 static COLORREF SysColors[NUM_SYS_COLORS];
87 static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
88 static HPEN SysColorPens[NUM_SYS_COLORS];
90 #define MAKE_SOLID(color) \
91 (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
93 /*************************************************************************
94 * SYSCOLOR_SetColor
96 static void SYSCOLOR_SetColor( int index, COLORREF color )
98 if (index < 0 || index >= NUM_SYS_COLORS) return;
99 SysColors[index] = color;
100 if (SysColorBrushes[index]) DeleteObject( SysColorBrushes[index] );
101 SysColorBrushes[index] = CreateSolidBrush( color );
102 if (SysColorPens[index]) DeleteObject( SysColorPens[index] );
103 SysColorPens[index] = CreatePen( PS_SOLID, 1, color );
107 /*************************************************************************
108 * SYSCOLOR_Init
110 void SYSCOLOR_Init(void)
112 int i, r, g, b;
113 const char * const *p;
114 char buffer[100];
116 p = (TWEAK_WineLook == WIN31_LOOK) ? DefSysColors : DefSysColors95;
117 for (i = 0; i < NUM_SYS_COLORS; i++, p += 2)
119 GetProfileStringA( "colors", p[0], p[1], buffer, 100 );
120 if (sscanf( buffer, " %d %d %d", &r, &g, &b ) != 3) r = g = b = 0;
121 SYSCOLOR_SetColor( i, RGB(r,g,b) );
126 /*************************************************************************
127 * GetSysColor16 (USER.180)
129 COLORREF WINAPI GetSysColor16( INT16 nIndex )
131 return GetSysColor (nIndex);
135 /*************************************************************************
136 * GetSysColor32 (USER32.289)
138 COLORREF WINAPI GetSysColor( INT nIndex )
140 if (nIndex >= 0 && nIndex < NUM_SYS_COLORS)
141 return SysColors[nIndex];
142 else
143 return 0;
147 /*************************************************************************
148 * SetSysColors16 (USER.181)
150 VOID WINAPI SetSysColors16( INT16 nChanges, const INT16 *lpSysColor,
151 const COLORREF *lpColorValues )
153 int i;
155 for (i = 0; i < nChanges; i++)
157 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
160 /* Send WM_SYSCOLORCHANGE message to all windows */
162 SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
164 /* Repaint affected portions of all visible windows */
166 RedrawWindow( GetDesktopWindow(), NULL, 0,
167 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
171 /*************************************************************************
172 * SetSysColors32 (USER32.505)
174 BOOL WINAPI SetSysColors( INT nChanges, const INT *lpSysColor,
175 const COLORREF *lpColorValues )
177 int i;
179 for (i = 0; i < nChanges; i++)
181 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
184 /* Send WM_SYSCOLORCHANGE message to all windows */
186 SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
188 /* Repaint affected portions of all visible windows */
190 RedrawWindow( GetDesktopWindow(), NULL, 0,
191 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
192 return TRUE;
196 /***********************************************************************
197 * GetSysColorBrush16 (USER.281)
199 HBRUSH16 WINAPI GetSysColorBrush16( INT16 index )
201 return (HBRUSH16)GetSysColorBrush(index);
205 /***********************************************************************
206 * GetSysColorBrush32 (USER32.290)
208 HBRUSH WINAPI GetSysColorBrush( INT index )
210 if (0 <= index && index < NUM_SYS_COLORS)
211 return SysColorBrushes[index];
212 WARN(syscolor, "Unknown index(%d)\n", index );
213 return GetStockObject(LTGRAY_BRUSH);
217 /***********************************************************************
218 * GetSysColorPen16 (Not a Windows API)
220 HPEN16 WINAPI GetSysColorPen16( INT16 index )
222 return (HPEN16)GetSysColorPen(index);
226 /***********************************************************************
227 * GetSysColorPen32 (Not a Windows API)
229 * This function is new to the Wine lib -- it does not exist in
230 * Windows. However, it is a natural complement for GetSysColorBrush
231 * in the Win32 API and is needed quite a bit inside Wine.
233 HPEN WINAPI GetSysColorPen( INT index )
235 /* We can assert here, because this function is internal to Wine */
236 assert (0 <= index && index < NUM_SYS_COLORS);
237 return SysColorPens[index];