Fixed Makefile up-to-date check to avoid relinking all the object
[wine/wine-kai.git] / windows / syscolor.c
blobb2222ca6e08e6856b59bdb11351240dbc9e8781f
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 "gdi.h"
16 #include "tweak.h"
18 static const char * const DefSysColors[] =
20 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
21 "Background", "192 192 192", /* COLOR_BACKGROUND */
22 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
23 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
24 "Menu", "255 255 255", /* COLOR_MENU */
25 "Window", "255 255 255", /* COLOR_WINDOW */
26 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
27 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
28 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
29 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
30 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
31 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
32 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
33 "Hilight", "224 224 224", /* COLOR_HIGHLIGHT */
34 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
35 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
36 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
37 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
38 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
39 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
40 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
41 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
42 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
43 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
44 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
45 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
46 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
47 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
48 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
51 static const char * const DefSysColors95[] =
53 "Scrollbar", "223 223 223", /* COLOR_SCROLLBAR */
54 "Background", "192 192 192", /* COLOR_BACKGROUND */
55 "ActiveTitle", "0 0 128", /* COLOR_ACTIVECAPTION */
56 "InactiveTitle", "128 128 128", /* COLOR_INACTIVECAPTION */
57 "Menu", "192 192 192", /* COLOR_MENU */
58 "Window", "255 255 255", /* COLOR_WINDOW */
59 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
60 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
61 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
62 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
63 "ActiveBorder", "192 192 192", /* COLOR_ACTIVEBORDER */
64 "InactiveBorder", "192 192 192", /* COLOR_INACTIVEBORDER */
65 "AppWorkspace", "128 128 128", /* COLOR_APPWORKSPACE */
66 "Hilight", "0 0 128", /* COLOR_HIGHLIGHT */
67 "HilightText", "255 255 255", /* COLOR_HIGHLIGHTTEXT */
68 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
69 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
70 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
71 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
72 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
73 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
74 "3DDarkShadow", "0 0 0", /* COLOR_3DDKSHADOW */
75 "3DLight", "223 223 223", /* COLOR_3DLIGHT */
76 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
77 "InfoBackground", "255 255 192", /* COLOR_INFOBK */
78 "AlternateButtonFace", "184 180 184", /* COLOR_ALTERNATEBTNFACE */
79 "HotTrackingColor", "0 0 255", /* COLOR_HOTLIGHT */
80 "GradientActiveTitle", "16 132 208", /* COLOR_GRADIENTACTIVECAPTION */
81 "GradientInactiveTitle", "184 180 184" /* COLOR_GRADIENTINACTIVECAPTION */
85 #define NUM_SYS_COLORS (COLOR_GRADIENTINACTIVECAPTION+1)
87 static COLORREF SysColors[NUM_SYS_COLORS];
88 static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
89 static HPEN SysColorPens[NUM_SYS_COLORS];
91 #define MAKE_SOLID(color) \
92 (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
94 /*************************************************************************
95 * SYSCOLOR_SetColor
97 static void SYSCOLOR_SetColor( int index, COLORREF color )
99 if (index < 0 || index >= NUM_SYS_COLORS) return;
100 SysColors[index] = color;
101 if (SysColorBrushes[index]) DeleteObject( SysColorBrushes[index] );
102 SysColorBrushes[index] = CreateSolidBrush( color );
103 if (SysColorPens[index]) DeleteObject( SysColorPens[index] );
104 SysColorPens[index] = CreatePen( PS_SOLID, 1, color );
108 /*************************************************************************
109 * SYSCOLOR_Init
111 void SYSCOLOR_Init(void)
113 int i, r, g, b;
114 const char * const *p;
115 char buffer[100];
117 p = (TWEAK_WineLook == WIN31_LOOK) ? DefSysColors : DefSysColors95;
118 for (i = 0; i < NUM_SYS_COLORS; i++, p += 2)
120 GetProfileStringA( "colors", p[0], p[1], buffer, 100 );
121 if (sscanf( buffer, " %d %d %d", &r, &g, &b ) != 3) r = g = b = 0;
122 SYSCOLOR_SetColor( i, RGB(r,g,b) );
127 /*************************************************************************
128 * GetSysColor16 (USER.180)
130 COLORREF WINAPI GetSysColor16( INT16 nIndex )
132 return GetSysColor (nIndex);
136 /*************************************************************************
137 * GetSysColor32 (USER32.289)
139 COLORREF WINAPI GetSysColor( INT nIndex )
141 if (nIndex >= 0 && nIndex < NUM_SYS_COLORS)
142 return SysColors[nIndex];
143 else
144 return 0;
148 /*************************************************************************
149 * SetSysColors16 (USER.181)
151 VOID WINAPI SetSysColors16( INT16 nChanges, const INT16 *lpSysColor,
152 const COLORREF *lpColorValues )
154 int i;
156 for (i = 0; i < nChanges; i++)
158 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
161 /* Send WM_SYSCOLORCHANGE message to all windows */
163 SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
165 /* Repaint affected portions of all visible windows */
167 RedrawWindow( GetDesktopWindow(), NULL, 0,
168 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
172 /*************************************************************************
173 * SetSysColors32 (USER32.505)
175 BOOL WINAPI SetSysColors( INT nChanges, const INT *lpSysColor,
176 const COLORREF *lpColorValues )
178 int i;
180 for (i = 0; i < nChanges; i++)
182 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
185 /* Send WM_SYSCOLORCHANGE message to all windows */
187 SendMessageA( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
189 /* Repaint affected portions of all visible windows */
191 RedrawWindow( GetDesktopWindow(), NULL, 0,
192 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
193 return TRUE;
197 /***********************************************************************
198 * GetSysColorBrush16 (USER.281)
200 HBRUSH16 WINAPI GetSysColorBrush16( INT16 index )
202 return (HBRUSH16)GetSysColorBrush(index);
206 /***********************************************************************
207 * GetSysColorBrush32 (USER32.290)
209 HBRUSH WINAPI GetSysColorBrush( INT index )
211 if (0 <= index && index < NUM_SYS_COLORS)
212 return SysColorBrushes[index];
213 WARN(syscolor, "Unknown index(%d)\n", index );
214 return GetStockObject(LTGRAY_BRUSH);
218 /***********************************************************************
219 * GetSysColorPen16 (Not a Windows API)
221 HPEN16 WINAPI GetSysColorPen16( INT16 index )
223 return (HPEN16)GetSysColorPen(index);
227 /***********************************************************************
228 * GetSysColorPen32 (Not a Windows API)
230 * This function is new to the Wine lib -- it does not exist in
231 * Windows. However, it is a natural complement for GetSysColorBrush
232 * in the Win32 API and is needed quite a bit inside Wine.
234 HPEN WINAPI GetSysColorPen( INT index )
236 /* We can assert here, because this function is internal to Wine */
237 assert (0 <= index && index < NUM_SYS_COLORS);
238 return SysColorPens[index];