Release 951226
[wine/gsoc-2012-control.git] / windows / syscolor.c
blob066eb247366d1e4582060e85d81b13f326c1a246
1 /*
2 * Support for system colors
4 * Copyright David W. Metcalfe, 1993
5 * Copyright Alexandre Julliard, 1994
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include "gdi.h"
12 #include "syscolor.h"
13 #include "stddebug.h"
14 /* #define DEBUG_SYSCOLOR */
15 #include "debug.h"
17 struct SysColorObjects sysColorObjects = { 0, };
19 static char * DefSysColors[] =
21 "Scrollbar", "224 224 224", /* COLOR_SCROLLBAR */
22 "Background", "192 192 192", /* COLOR_BACKGROUND */
23 "ActiveTitle", "0 64 128", /* COLOR_ACTIVECAPTION */
24 "InactiveTitle", "255 255 255", /* COLOR_INACTIVECAPTION */
25 "Menu", "0 255 255", /* COLOR_MENU */
26 "Window", "255 255 255", /* COLOR_WINDOW */
27 "WindowFrame", "0 0 0", /* COLOR_WINDOWFRAME */
28 "MenuText", "0 0 0", /* COLOR_MENUTEXT */
29 "WindowText", "0 0 0", /* COLOR_WINDOWTEXT */
30 "TitleText", "255 255 255", /* COLOR_CAPTIONTEXT */
31 "ActiveBorder", "128 128 128", /* COLOR_ACTIVEBORDER */
32 "InactiveBorder", "255 255 255", /* COLOR_INACTIVEBORDER */
33 "AppWorkspace", "255 255 232", /* COLOR_APPWORKSPACE */
34 "Hilight", "166 202 240", /* COLOR_HIGHLIGHT */
35 "HilightText", "0 0 0", /* COLOR_HIGHLIGHTTEXT */
36 "ButtonFace", "192 192 192", /* COLOR_BTNFACE */
37 "ButtonShadow", "128 128 128", /* COLOR_BTNSHADOW */
38 "GrayText", "192 192 192", /* COLOR_GRAYTEXT */
39 "ButtonText", "0 0 0", /* COLOR_BTNTEXT */
40 "InactiveTitleText", "0 0 0", /* COLOR_INACTIVECAPTIONTEXT */
41 "ButtonHilight", "255 255 255" /* COLOR_BTNHIGHLIGHT */
44 #define NUM_SYS_COLORS (COLOR_BTNHIGHLIGHT+1)
46 static COLORREF SysColors[NUM_SYS_COLORS];
48 #define MAKE_SOLID(color) \
49 (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
51 /*************************************************************************
52 * SYSCOLOR_SetColor
54 static void SYSCOLOR_SetColor( int index, COLORREF color )
56 SysColors[index] = color;
57 switch(index)
59 case COLOR_SCROLLBAR:
60 DeleteObject( sysColorObjects.hbrushScrollbar );
61 sysColorObjects.hbrushScrollbar = CreateSolidBrush( color );
62 break;
63 case COLOR_BACKGROUND:
64 break;
65 case COLOR_ACTIVECAPTION:
66 DeleteObject( sysColorObjects.hbrushActiveCaption );
67 sysColorObjects.hbrushActiveCaption = CreateSolidBrush( color );
68 break;
69 case COLOR_INACTIVECAPTION:
70 DeleteObject( sysColorObjects.hbrushInactiveCaption );
71 sysColorObjects.hbrushInactiveCaption = CreateSolidBrush( color );
72 break;
73 case COLOR_MENU:
74 DeleteObject( sysColorObjects.hbrushMenu );
75 sysColorObjects.hbrushMenu = CreateSolidBrush( MAKE_SOLID(color) );
76 break;
77 case COLOR_WINDOW:
78 DeleteObject( sysColorObjects.hbrushWindow );
79 sysColorObjects.hbrushWindow = CreateSolidBrush( color );
80 break;
81 case COLOR_WINDOWFRAME:
82 DeleteObject( sysColorObjects.hpenWindowFrame );
83 sysColorObjects.hpenWindowFrame = CreatePen( PS_SOLID, 1, color );
84 break;
85 case COLOR_MENUTEXT:
86 break;
87 case COLOR_WINDOWTEXT:
88 DeleteObject( sysColorObjects.hpenWindowText );
89 sysColorObjects.hpenWindowText = CreatePen( PS_SOLID, 1, color );
90 break;
91 case COLOR_CAPTIONTEXT:
92 break;
93 case COLOR_ACTIVEBORDER:
94 DeleteObject( sysColorObjects.hbrushActiveBorder );
95 sysColorObjects.hbrushActiveBorder = CreateSolidBrush( color );
96 break;
97 case COLOR_INACTIVEBORDER:
98 DeleteObject( sysColorObjects.hbrushInactiveBorder );
99 sysColorObjects.hbrushInactiveBorder = CreateSolidBrush( color );
100 break;
101 case COLOR_APPWORKSPACE:
102 break;
103 case COLOR_HIGHLIGHT:
104 DeleteObject( sysColorObjects.hbrushHighlight );
105 sysColorObjects.hbrushHighlight = CreateSolidBrush( MAKE_SOLID(color));
106 break;
107 case COLOR_HIGHLIGHTTEXT:
108 break;
109 case COLOR_BTNFACE:
110 DeleteObject( sysColorObjects.hbrushBtnFace );
111 sysColorObjects.hbrushBtnFace = CreateSolidBrush( color );
112 break;
113 case COLOR_BTNSHADOW:
114 DeleteObject( sysColorObjects.hbrushBtnShadow );
115 sysColorObjects.hbrushBtnShadow = CreateSolidBrush( color );
116 break;
117 case COLOR_GRAYTEXT:
118 case COLOR_BTNTEXT:
119 case COLOR_INACTIVECAPTIONTEXT:
120 break;
121 case COLOR_BTNHIGHLIGHT:
122 DeleteObject( sysColorObjects.hbrushBtnHighlight );
123 sysColorObjects.hbrushBtnHighlight = CreateSolidBrush( color );
124 break;
129 /*************************************************************************
130 * SYSCOLOR_Init
132 void SYSCOLOR_Init(void)
134 int i, r, g, b;
135 char **p;
136 char buffer[100];
138 for (i = 0, p = DefSysColors; i < NUM_SYS_COLORS; i++, p += 2)
140 GetProfileString( "colors", p[0], p[1], buffer, 100 );
141 if (!sscanf( buffer, " %d %d %d", &r, &g, &b )) r = g = b = 0;
142 SYSCOLOR_SetColor( i, RGB(r,g,b) );
147 /*************************************************************************
148 * GetSysColor (USER.180)
151 COLORREF GetSysColor(short nIndex)
153 dprintf_syscolor(stddeb,"System Color %d = %8lx\n",
154 nIndex, SysColors[nIndex]);
155 return SysColors[nIndex];
159 /*************************************************************************
160 * SetSysColors (USER.181)
163 void SetSysColors(int nChanges, LPINT lpSysColor, COLORREF *lpColorValues)
165 int i;
167 for (i = 0; i < nChanges; i++)
169 SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
172 /* Send WM_SYSCOLORCHANGE message to all windows */
174 /* ................ */
176 /* Repaint affected portions of all visible windows */
178 /* ................ */