2 * Support for system colors
4 * Copyright David W. Metcalfe, 1993
5 * Copyright Alexandre Julliard, 1994
14 /* #define DEBUG_SYSCOLOR */
17 struct SysColorObjects sysColorObjects
;
19 static const char * const 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 /*************************************************************************
54 static void SYSCOLOR_SetColor( int index
, COLORREF color
)
56 SysColors
[index
] = color
;
60 DeleteObject( sysColorObjects
.hbrushScrollbar
);
61 sysColorObjects
.hbrushScrollbar
= CreateSolidBrush( color
);
63 case COLOR_BACKGROUND
:
65 case COLOR_ACTIVECAPTION
:
66 DeleteObject( sysColorObjects
.hbrushActiveCaption
);
67 sysColorObjects
.hbrushActiveCaption
= CreateSolidBrush( color
);
69 case COLOR_INACTIVECAPTION
:
70 DeleteObject( sysColorObjects
.hbrushInactiveCaption
);
71 sysColorObjects
.hbrushInactiveCaption
= CreateSolidBrush( color
);
74 DeleteObject( sysColorObjects
.hbrushMenu
);
75 sysColorObjects
.hbrushMenu
= CreateSolidBrush( MAKE_SOLID(color
) );
78 DeleteObject( sysColorObjects
.hbrushWindow
);
79 sysColorObjects
.hbrushWindow
= CreateSolidBrush( color
);
81 case COLOR_WINDOWFRAME
:
82 DeleteObject( sysColorObjects
.hpenWindowFrame
);
83 sysColorObjects
.hpenWindowFrame
= CreatePen( PS_SOLID
, 1, color
);
87 case COLOR_WINDOWTEXT
:
88 DeleteObject( sysColorObjects
.hpenWindowText
);
89 sysColorObjects
.hpenWindowText
= CreatePen( PS_DOT
, 1, color
);
91 case COLOR_CAPTIONTEXT
:
93 case COLOR_ACTIVEBORDER
:
94 DeleteObject( sysColorObjects
.hbrushActiveBorder
);
95 sysColorObjects
.hbrushActiveBorder
= CreateSolidBrush( color
);
97 case COLOR_INACTIVEBORDER
:
98 DeleteObject( sysColorObjects
.hbrushInactiveBorder
);
99 sysColorObjects
.hbrushInactiveBorder
= CreateSolidBrush( color
);
101 case COLOR_APPWORKSPACE
:
103 case COLOR_HIGHLIGHT
:
104 DeleteObject( sysColorObjects
.hbrushHighlight
);
105 sysColorObjects
.hbrushHighlight
= CreateSolidBrush( MAKE_SOLID(color
));
107 case COLOR_HIGHLIGHTTEXT
:
110 DeleteObject( sysColorObjects
.hbrushBtnFace
);
111 sysColorObjects
.hbrushBtnFace
= CreateSolidBrush( color
);
113 case COLOR_BTNSHADOW
:
114 DeleteObject( sysColorObjects
.hbrushBtnShadow
);
115 sysColorObjects
.hbrushBtnShadow
= CreateSolidBrush( color
);
119 case COLOR_INACTIVECAPTIONTEXT
:
121 case COLOR_BTNHIGHLIGHT
:
122 DeleteObject( sysColorObjects
.hbrushBtnHighlight
);
123 sysColorObjects
.hbrushBtnHighlight
= CreateSolidBrush( color
);
129 /*************************************************************************
132 void SYSCOLOR_Init(void)
135 const char * const *p
;
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) (USER32.288)
151 COLORREF
GetSysColor( INT32 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
, LPINT16 lpSysColor
, COLORREF
*lpColorValues
)
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 /* ................ */