2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998 - 2004 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * STOCKOBJ.C - GDI Stock Objects
31 static const COLORREF SysColors
[] =
33 RGB(212, 208, 200), /* COLOR_SCROLLBAR */
34 RGB(58, 110, 165), /* COLOR_BACKGROUND */
35 RGB(10, 36, 106), /* COLOR_ACTIVECAPTION */
36 RGB(128, 128, 128), /* COLOR_INACTIVECAPTION */
37 RGB(212, 208, 200), /* COLOR_MENU */
38 RGB(255, 255, 255), /* COLOR_WINDOW */
39 RGB(0, 0, 0), /* COLOR_WINDOWFRAME */
40 RGB(0, 0, 0), /* COLOR_MENUTEXT */
41 RGB(0, 0, 0), /* COLOR_WINDOWTEXT */
42 RGB(255, 255, 255), /* COLOR_CAPTIONTEXT */
43 RGB(212, 208, 200), /* COLOR_ACTIVEBORDER */
44 RGB(212, 208, 200), /* COLOR_INACTIVEBORDER */
45 RGB(128, 128, 128), /* COLOR_APPWORKSPACE */
46 RGB(10, 36, 106), /* COLOR_HIGHLIGHT */
47 RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT */
48 RGB(212, 208, 200), /* COLOR_BTNFACE */
49 RGB(128, 128, 128), /* COLOR_BTNSHADOW */
50 RGB(128, 128, 128), /* COLOR_GRAYTEXT */
51 RGB(0, 0, 0), /* COLOR_BTNTEXT */
52 RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT */
53 RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT */
54 RGB(64, 64, 64), /* COLOR_3DDKSHADOW */
55 RGB(212, 208, 200), /* COLOR_3DLIGHT */
56 RGB(0, 0, 0), /* COLOR_INFOTEXT */
57 RGB(255, 255, 225), /* COLOR_INFOBK */
58 RGB(181, 181, 181), /* COLOR_UNKNOWN */
59 RGB(0, 0, 128), /* COLOR_HOTLIGHT */
60 RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION */
61 RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION */
62 RGB(49, 106, 197), /* COLOR_MENUHILIGHT */
63 RGB(236, 233, 216) /* COLOR_MENUBAR */
65 #define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
70 /* GDI stock objects */
72 static LOGPEN WhitePen
=
73 { PS_SOLID
, { 0, 0 }, RGB(255,255,255) };
75 static LOGPEN BlackPen
=
76 { PS_SOLID
, { 0, 0 }, RGB(0,0,0) };
78 static LOGPEN NullPen
=
79 { PS_NULL
, { 0, 0 }, 0 };
81 static LOGFONTW OEMFixedFont
=
82 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, OEM_CHARSET
,
83 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, L
"Courier New"
84 }; //Bitstream Vera Sans Mono
86 static LOGFONTW AnsiFixedFont
=
87 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
88 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, L
"Courier New"
89 }; //Bitstream Vera Sans Mono
91 static LOGFONTW AnsiVarFont
=
92 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
93 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"
96 static LOGFONTW SystemFont
=
97 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
98 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"Courier New"
99 }; //Bitstream Vera Sans
101 static LOGFONTW DeviceDefaultFont
=
102 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
103 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"
104 }; //Bitstream Vera Sans
106 static LOGFONTW SystemFixedFont
=
107 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
108 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, L
"Courier New"
109 }; //Bitstream Vera Sans Mono
111 /* FIXME: Is this correct? */
112 static LOGFONTW DefaultGuiFont
=
113 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
114 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"
115 }; //Bitstream Vera Sans
117 HGDIOBJ StockObjects
[NB_STOCK_OBJECTS
];
122 IntCreateStockPen(DWORD dwPenStyle
,
128 PBRUSH pbrushPen
= PEN_AllocPenWithHandle();
130 if ((dwPenStyle
& PS_STYLE_MASK
) == PS_NULL
) dwWidth
= 1;
132 pbrushPen
->ptPenWidth
.x
= abs(dwWidth
);
133 pbrushPen
->ptPenWidth
.y
= 0;
134 pbrushPen
->ulPenStyle
= dwPenStyle
;
135 pbrushPen
->BrushAttr
.lbColor
= ulColor
;
136 pbrushPen
->ulStyle
= ulBrushStyle
;
137 pbrushPen
->hbmClient
= (HANDLE
)NULL
;
138 pbrushPen
->dwStyleCount
= 0;
139 pbrushPen
->pStyle
= 0;
140 pbrushPen
->flAttrs
= GDIBRUSH_IS_OLDSTYLEPEN
;
142 switch (dwPenStyle
& PS_STYLE_MASK
)
145 pbrushPen
->flAttrs
|= GDIBRUSH_IS_NULL
;
149 pbrushPen
->flAttrs
|= GDIBRUSH_IS_SOLID
;
152 hPen
= pbrushPen
->BaseObject
.hHmgr
;
153 PEN_UnlockPen(pbrushPen
);
158 * Creates a bunch of stock objects: brushes, pens, fonts.
161 CreateStockObjects(void)
165 DPRINT("Beginning creation of stock objects\n");
167 /* Create GDI Stock Objects from the logical structures we've defined */
169 StockObjects
[WHITE_BRUSH
] = IntGdiCreateSolidBrush(RGB(255,255,255));
170 StockObjects
[DC_BRUSH
] = IntGdiCreateSolidBrush(RGB(255,255,255));
171 StockObjects
[LTGRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(192,192,192));
172 StockObjects
[GRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(128,128,128));
173 StockObjects
[DKGRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(64,64,64));
174 StockObjects
[BLACK_BRUSH
] = IntGdiCreateSolidBrush(RGB(0,0,0));
175 StockObjects
[NULL_BRUSH
] = IntGdiCreateNullBrush();
177 StockObjects
[WHITE_PEN
] = IntCreateStockPen(WhitePen
.lopnStyle
, WhitePen
.lopnWidth
.x
, BS_SOLID
, WhitePen
.lopnColor
);
178 StockObjects
[BLACK_PEN
] = IntCreateStockPen(BlackPen
.lopnStyle
, BlackPen
.lopnWidth
.x
, BS_SOLID
, BlackPen
.lopnColor
);
179 StockObjects
[DC_PEN
] = IntCreateStockPen(BlackPen
.lopnStyle
, BlackPen
.lopnWidth
.x
, BS_SOLID
, BlackPen
.lopnColor
);
180 StockObjects
[NULL_PEN
] = IntCreateStockPen(NullPen
.lopnStyle
, NullPen
.lopnWidth
.x
, BS_SOLID
, NullPen
.lopnColor
);
182 StockObjects
[20] = NULL
; /* TODO: Unknown internal stock object */
183 StockObjects
[DEFAULT_BITMAP
] = IntGdiCreateBitmap(1, 1, 1, 1, NULL
);
185 (void) TextIntCreateFontIndirect(&OEMFixedFont
, (HFONT
*)&StockObjects
[OEM_FIXED_FONT
]);
186 (void) TextIntCreateFontIndirect(&AnsiFixedFont
, (HFONT
*)&StockObjects
[ANSI_FIXED_FONT
]);
187 (void) TextIntCreateFontIndirect(&AnsiVarFont
, (HFONT
*)&StockObjects
[ANSI_VAR_FONT
]);
188 (void) TextIntCreateFontIndirect(&SystemFont
, (HFONT
*)&StockObjects
[SYSTEM_FONT
]);
189 (void) TextIntCreateFontIndirect(&DeviceDefaultFont
, (HFONT
*)&StockObjects
[DEVICE_DEFAULT_FONT
]);
190 (void) TextIntCreateFontIndirect(&SystemFixedFont
, (HFONT
*)&StockObjects
[SYSTEM_FIXED_FONT
]);
191 (void) TextIntCreateFontIndirect(&DefaultGuiFont
, (HFONT
*)&StockObjects
[DEFAULT_GUI_FONT
]);
193 StockObjects
[DEFAULT_PALETTE
] = (HGDIOBJ
)PALETTE_Init();
195 for (Object
= 0; Object
< NB_STOCK_OBJECTS
; Object
++)
197 if (NULL
!= StockObjects
[Object
])
199 GDIOBJ_ConvertToStockObj(&StockObjects
[Object
]);
203 DPRINT("Completed creation of stock objects\n");
207 * Return stock object.
208 * \param Object - stock object id.
209 * \return Handle to the object.
212 NtGdiGetStockObject(INT Object
)
214 DPRINT("NtGdiGetStockObject index %d\n", Object
);
216 return ((Object
< 0) || (NB_STOCK_OBJECTS
<= Object
)) ? NULL
: StockObjects
[Object
];
220 IntSetSysColors(UINT nColors
, INT
*Elements
, COLORREF
*Colors
)
227 for (i
= 0; i
< nColors
; i
++)
229 if ((UINT
)(*Elements
) < NUM_SYSCOLORS
)
231 gpsi
->argbSystem
[*Elements
] = *Colors
;
232 IntGdiSetSolidBrushColor(gpsi
->ahbrSystem
[*Elements
], *Colors
);
241 IntGetSysColorBrush(INT Object
)
243 return ((Object
< 0) || (NUM_SYSCOLORS
<= Object
)) ? NULL
: gpsi
->ahbrSystem
[Object
];
247 IntGetSysColor(INT nIndex
)
249 return (NUM_SYSCOLORS
<= (UINT
)nIndex
) ? 0 : gpsi
->argbSystem
[nIndex
];
253 CreateSysColorObjects(VOID
)
257 for (i
= 0; i
< NUM_SYSCOLORS
; i
++)
259 gpsi
->argbSystem
[i
] = SysColors
[i
];
262 /* Create the syscolor brushes */
263 for (i
= 0; i
< NUM_SYSCOLORS
; i
++)
265 if (gpsi
->ahbrSystem
[i
] == NULL
)
267 gpsi
->ahbrSystem
[i
] = IntGdiCreateSolidBrush(SysColors
[i
]);
268 if (gpsi
->ahbrSystem
[i
] != NULL
)
270 GDIOBJ_ConvertToStockObj((HGDIOBJ
*)&gpsi
->ahbrSystem
[i
]);