294 missing WINAPI added.
[wine/multimedia.git] / windows / syscolor.c
blobd8db19cdda84e6fddb5fe91def2bf36d101bc564
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 "debug.h"
13 #include "gdi.h"
14 #include "tweak.h"
16 static const char * const DefSysColors[] =
18 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
19 "Background", "192 192 192", /* COLOR_BACKGROUND */
20 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
21 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
22 "Menu", "255 255 255", /* COLOR_MENU */
23 "Window", "255 255 255", /* COLOR_WINDOW */
24 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
25 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
26 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
27 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
28 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
29 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
30 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
31 "Hilight", "224 224 224", /* COLOR_HIGHLIGHT */
32 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
33 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
34 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
35 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
36 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
37 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
38 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
39 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
40 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
41 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
42 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
43 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
44 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
45 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
46 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
49 static const char * const DefSysColors95[] =
51 "Scrollbar", "223 223 223", /* COLOR_SCROLLBAR */
52 "Background", "192 192 192", /* COLOR_BACKGROUND */
53 "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */
54 "InactiveTitle", "128 128 128", /* 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", "192 192 192", /* COLOR_ACTIVEBORDER */
62 "InactiveBorder", "192 192 192", /* COLOR_INACTIVEBORDER */
63 "AppWorkspace", "128 128 128", /* COLOR_APPWORKSPACE */
64 "Hilight", "0 0 128", /* COLOR_HIGHLIGHT */
65 "HilightText", "255 255 255", /* 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", "0 0 0", /* COLOR_3DDKSHADOW */
73 "3DLight", "223 223 223", /* COLOR_3DLIGHT */
74 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
75 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
76 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
77 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
78 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
79 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
83 #define NUM_SYS_COLORS (COLOR_GRADIENTINACTIVECAPTION+1)
85 static COLORREF SysColors[NUM_SYS_COLORS];
86 static HBRUSH32 SysColorBrushes[NUM_SYS_COLORS];
87 static HPEN32 SysColorPens[NUM_SYS_COLORS];
89 #define MAKE_SOLID(color) \
90 (PALETTEINDEX(GetNearestPaletteIndex32(STOCK_DEFAULT_PALETTE,(color))))
92 /*************************************************************************
93 * SYSCOLOR_SetColor
95 static void SYSCOLOR_SetColor( int index, COLORREF color )
97 if (index < 0 || index >= NUM_SYS_COLORS) return;
98 SysColors[index] = color;
99 if (SysColorBrushes[index]) DeleteObject32( SysColorBrushes[index] );
100 SysColorBrushes[index] = CreateSolidBrush32( color );
101 if (SysColorPens[index]) DeleteObject32( SysColorPens[index] );
102 SysColorPens[index] = CreatePen32( PS_SOLID, 1, color );
106 /*************************************************************************
107 * SYSCOLOR_Init
109 void SYSCOLOR_Init(void)
111 int i, r, g, b;
112 const char * const *p;
113 char buffer[100];
115 p = (TWEAK_WineLook == WIN31_LOOK) ? DefSysColors : DefSysColors95;
116 for (i = 0; i < NUM_SYS_COLORS; i++, p += 2)
118 GetProfileString32A( "colors", p[0], p[1], buffer, 100 );
119 if (sscanf( buffer, " %d %d %d", &r, &g, &b ) != 3) r = g = b = 0;
120 SYSCOLOR_SetColor( i, RGB(r,g,b) );
125 /*************************************************************************
126 * GetSysColor16 (USER.180)
128 COLORREF WINAPI GetSysColor16( INT16 nIndex )
130 return GetSysColor32 (nIndex);
134 /*************************************************************************
135 * GetSysColor32 (USER32.289)
137 COLORREF WINAPI GetSysColor32( INT32 nIndex )
139 if (nIndex >= 0 && nIndex < NUM_SYS_COLORS)
140 return SysColors[nIndex];
141 else
142 return 0;
146 /*************************************************************************
147 * SetSysColors16 (USER.181)
149 VOID WINAPI SetSysColors16( INT16 nChanges, const INT16 *lpSysColor,
150 const COLORREF *lpColorValues )
152 int i;
154 for (i = 0; i < nChanges; i++)
156 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
159 /* Send WM_SYSCOLORCHANGE message to all windows */
161 SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
163 /* Repaint affected portions of all visible windows */
165 RedrawWindow32( GetDesktopWindow32(), NULL, 0,
166 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
170 /*************************************************************************
171 * SetSysColors32 (USER32.505)
173 BOOL32 WINAPI SetSysColors32( INT32 nChanges, const INT32 *lpSysColor,
174 const COLORREF *lpColorValues )
176 int i;
178 for (i = 0; i < nChanges; i++)
180 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
183 /* Send WM_SYSCOLORCHANGE message to all windows */
185 SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
187 /* Repaint affected portions of all visible windows */
189 RedrawWindow32( GetDesktopWindow32(), NULL, 0,
190 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
191 return TRUE;
195 /***********************************************************************
196 * GetSysColorBrush16 (USER.281)
198 HBRUSH16 WINAPI GetSysColorBrush16( INT16 index )
200 return (HBRUSH16)GetSysColorBrush32(index);
204 /***********************************************************************
205 * GetSysColorBrush32 (USER32.290)
207 HBRUSH32 WINAPI GetSysColorBrush32( INT32 index )
209 if (0 <= index && index < NUM_SYS_COLORS)
210 return SysColorBrushes[index];
211 WARN(syscolor, "Unknown index(%d)\n", index );
212 return GetStockObject32(LTGRAY_BRUSH);
216 /***********************************************************************
217 * GetSysColorPen16 (Not a Windows API)
219 HPEN16 WINAPI GetSysColorPen16( INT16 index )
221 return (HPEN16)GetSysColorPen32(index);
225 /***********************************************************************
226 * GetSysColorPen32 (Not a Windows API)
228 * This function is new to the Wine lib -- it does not exist in
229 * Windows. However, it is a natural complement for GetSysColorBrush
230 * in the Win32 API and is needed quite a bit inside Wine.
232 HPEN32 WINAPI GetSysColorPen32( INT32 index )
234 /* We can assert here, because this function is internal to Wine */
235 assert (0 <= index && index < NUM_SYS_COLORS);
236 return SysColorPens[index];