Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Support for system colors |
| 3 | * |
| 4 | * Copyright David W. Metcalfe, 1993 |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 5 | * Copyright Alexandre Julliard, 1994 |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 6 | * |
| 7 | */ |
| 8 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 9 | #include <stdio.h> |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 10 | #include <stdlib.h> |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 11 | #include "gdi.h" |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 12 | #include "syscolor.h" |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 13 | #include "stddebug.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 14 | /* #define DEBUG_SYSCOLOR */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 15 | #include "debug.h" |
| 16 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 17 | struct SysColorObjects sysColorObjects = { 0, }; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 18 | |
| 19 | static char * DefSysColors[] = |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 20 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 44 | #define NUM_SYS_COLORS (COLOR_BTNHIGHLIGHT+1) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 45 | |
| 46 | static COLORREF SysColors[NUM_SYS_COLORS]; |
| 47 | |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 48 | #define MAKE_SOLID(color) \ |
| 49 | (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color)))) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 50 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 51 | /************************************************************************* |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 52 | * SYSCOLOR_SetColor |
| 53 | */ |
| 54 | static void SYSCOLOR_SetColor( int index, COLORREF color ) |
| 55 | { |
| 56 | SysColors[index] = color; |
| 57 | switch(index) |
| 58 | { |
| 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: |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 74 | DeleteObject( sysColorObjects.hbrushMenu ); |
| 75 | sysColorObjects.hbrushMenu = CreateSolidBrush( MAKE_SOLID(color) ); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 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 ); |
Alexandre Julliard | 02ed4c2 | 1996-03-02 19:34:10 +0000 | [diff] [blame] | 89 | sysColorObjects.hpenWindowText = CreatePen( PS_DOT, 1, color ); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 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: |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 102 | break; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 103 | case COLOR_HIGHLIGHT: |
Alexandre Julliard | f720725 | 1994-07-23 07:57:48 +0000 | [diff] [blame] | 104 | DeleteObject( sysColorObjects.hbrushHighlight ); |
| 105 | sysColorObjects.hbrushHighlight = CreateSolidBrush( MAKE_SOLID(color)); |
| 106 | break; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 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; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | |
| 129 | /************************************************************************* |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 130 | * SYSCOLOR_Init |
| 131 | */ |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 132 | void SYSCOLOR_Init(void) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 133 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 134 | int i, r, g, b; |
| 135 | char **p; |
| 136 | char buffer[100]; |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 137 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 138 | for (i = 0, p = DefSysColors; i < NUM_SYS_COLORS; i++, p += 2) |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 139 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 140 | GetProfileString( "colors", p[0], p[1], buffer, 100 ); |
| 141 | if (!sscanf( buffer, " %d %d %d", &r, &g, &b )) r = g = b = 0; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 142 | SYSCOLOR_SetColor( i, RGB(r,g,b) ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
| 146 | |
| 147 | /************************************************************************* |
| 148 | * GetSysColor (USER.180) |
| 149 | */ |
| 150 | |
| 151 | COLORREF GetSysColor(short nIndex) |
| 152 | { |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 153 | dprintf_syscolor(stddeb,"System Color %d = %8lx\n", |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 154 | nIndex, SysColors[nIndex]); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 155 | return SysColors[nIndex]; |
| 156 | } |
| 157 | |
| 158 | |
| 159 | /************************************************************************* |
| 160 | * SetSysColors (USER.181) |
| 161 | */ |
| 162 | |
| 163 | void SetSysColors(int nChanges, LPINT lpSysColor, COLORREF *lpColorValues) |
| 164 | { |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 165 | int i; |
| 166 | |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 167 | for (i = 0; i < nChanges; i++) |
| 168 | { |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 169 | SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] ); |
Alexandre Julliard | f0b2354 | 1993-09-29 12:21:49 +0000 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | /* Send WM_SYSCOLORCHANGE message to all windows */ |
| 173 | |
| 174 | /* ................ */ |
| 175 | |
| 176 | /* Repaint affected portions of all visible windows */ |
| 177 | |
| 178 | /* ................ */ |
| 179 | } |