2 * Support for system colors
4 * Copyright David W. Metcalfe, 1993
5 * Copyright Alexandre Julliard, 1994
15 static const char * const DefSysColors
[] =
17 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
18 "Background", "192 192 192", /* COLOR_BACKGROUND */
19 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
20 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
21 "Menu", "255 255 255", /* COLOR_MENU */
22 "Window", "255 255 255", /* COLOR_WINDOW */
23 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
24 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
25 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
26 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
27 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
28 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
29 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
30 "Hilight", "166 202 240", /* COLOR_HIGHLIGHT */
31 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
32 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
33 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
34 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
35 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
36 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
37 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
38 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
39 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
40 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
41 "InfoBackground", "255 255 192" /* COLOR_INFOBK */
44 static const char * const DefSysColors95
[] =
46 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
47 "Background", "192 192 192", /* COLOR_BACKGROUND */
48 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
49 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
50 "Menu", "192 192 192", /* COLOR_MENU */
51 "Window", "255 255 255", /* COLOR_WINDOW */
52 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
53 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
54 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
55 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
56 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
57 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
58 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
59 "Hilight", "166 202 240", /* COLOR_HIGHLIGHT */
60 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
61 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
62 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
63 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
64 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
65 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
66 "ButtonHilight", "255 255 255", /* COLOR_BTNHIGHLIGHT */
67 "3DDarkShadow", "32 32 32", /* COLOR_3DDKSHADOW */
68 "3DLight", "192 192 192", /* COLOR_3DLIGHT */
69 "InfoText", "0 0 0", /* COLOR_INFOTEXT */
70 "InfoBackground", "255 255 192" /* COLOR_INFOBK */
74 #define NUM_SYS_COLORS (COLOR_INFOBK+1)
76 static COLORREF SysColors
[NUM_SYS_COLORS
];
77 static HBRUSH32 SysColorBrushes
[NUM_SYS_COLORS
];
78 static HPEN32 SysColorPens
[NUM_SYS_COLORS
];
80 #define MAKE_SOLID(color) \
81 (PALETTEINDEX(GetNearestPaletteIndex32(STOCK_DEFAULT_PALETTE,(color))))
83 /*************************************************************************
86 static void SYSCOLOR_SetColor( int index
, COLORREF color
)
88 if (index
< 0 || index
>= NUM_SYS_COLORS
) return;
89 SysColors
[index
] = color
;
90 if (SysColorBrushes
[index
]) DeleteObject32( SysColorBrushes
[index
] );
91 SysColorBrushes
[index
] = CreateSolidBrush32( color
);
92 if (SysColorPens
[index
]) DeleteObject32( SysColorPens
[index
] );
93 SysColorPens
[index
] = CreatePen32( PS_SOLID
, 1, color
);
97 /*************************************************************************
100 void SYSCOLOR_Init(void)
103 const char * const *p
;
106 for (i
= 0, p
= TWEAK_Win95Look
? DefSysColors95
: DefSysColors
;
107 i
< NUM_SYS_COLORS
; i
++, p
+= 2)
109 GetProfileString32A( "colors", p
[0], p
[1], buffer
, 100 );
110 if (sscanf( buffer
, " %d %d %d", &r
, &g
, &b
) != 3) r
= g
= b
= 0;
111 SYSCOLOR_SetColor( i
, RGB(r
,g
,b
) );
116 /*************************************************************************
117 * GetSysColor16 (USER.180)
119 COLORREF WINAPI
GetSysColor16( INT16 nIndex
)
121 return GetSysColor32 (nIndex
);
125 /*************************************************************************
126 * GetSysColor32 (USER32.288)
128 COLORREF WINAPI
GetSysColor32( INT32 nIndex
)
130 if (nIndex
>= 0 && nIndex
< NUM_SYS_COLORS
)
131 return SysColors
[nIndex
];
137 /*************************************************************************
138 * SetSysColors16 (USER.181)
140 VOID WINAPI
SetSysColors16( INT16 nChanges
, const INT16
*lpSysColor
,
141 const COLORREF
*lpColorValues
)
145 for (i
= 0; i
< nChanges
; i
++)
147 SYSCOLOR_SetColor( lpSysColor
[i
], lpColorValues
[i
] );
150 /* Send WM_SYSCOLORCHANGE message to all windows */
152 SendMessage32A( HWND_BROADCAST
, WM_SYSCOLORCHANGE
, 0, 0 );
154 /* Repaint affected portions of all visible windows */
156 RedrawWindow32( GetDesktopWindow32(), NULL
, 0,
157 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
161 /*************************************************************************
162 * SetSysColors32 (USER32.504)
164 BOOL32 WINAPI
SetSysColors32( INT32 nChanges
, const INT32
*lpSysColor
,
165 const COLORREF
*lpColorValues
)
169 for (i
= 0; i
< nChanges
; i
++)
171 SYSCOLOR_SetColor( lpSysColor
[i
], lpColorValues
[i
] );
174 /* Send WM_SYSCOLORCHANGE message to all windows */
176 SendMessage32A( HWND_BROADCAST
, WM_SYSCOLORCHANGE
, 0, 0 );
178 /* Repaint affected portions of all visible windows */
180 RedrawWindow32( GetDesktopWindow32(), NULL
, 0,
181 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
186 /***********************************************************************
187 * GetSysColorBrush16 (USER.281)
189 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
191 return (HBRUSH16
)GetSysColorBrush32(index
);
195 /***********************************************************************
196 * GetSysColorBrush32 (USER32.289)
198 HBRUSH32 WINAPI
GetSysColorBrush32( INT32 index
)
200 if (0 <= index
&& index
< NUM_SYS_COLORS
)
201 return SysColorBrushes
[index
];
202 fprintf( stderr
, "GetSysColorBrush32: Unknown index(%d)\n", index
);
203 return GetStockObject32(LTGRAY_BRUSH
);
207 /***********************************************************************
208 * GetSysColorPen16 (Not a Windows API)
210 HPEN16 WINAPI
GetSysColorPen16( INT16 index
)
212 return (HPEN16
)GetSysColorPen32(index
);
216 /***********************************************************************
217 * GetSysColorPen32 (Not a Windows API)
219 * This function is new to the Wine lib -- it does not exist in
220 * Windows. However, it is a natural complement for GetSysColorBrush
221 * in the Win32 API and is needed quite a bit inside Wine.
223 HPEN32 WINAPI
GetSysColorPen32( INT32 index
)
225 /* We can assert here, because this function is internal to Wine */
226 assert (0 <= index
&& index
< NUM_SYS_COLORS
);
227 return SysColorPens
[index
];