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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * STOCKOBJ.C - GDI Stock Objects
31 static 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" }; //Bitstream Vera Sans Mono
85 static LOGFONTW AnsiFixedFont
=
86 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
87 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, L
"Courier New" }; //Bitstream Vera Sans Mono
89 static LOGFONTW AnsiVarFont
=
90 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
91 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif" };
93 static LOGFONTW SystemFont
=
94 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
95 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"Courier New" }; //Bitstream Vera Sans
97 static LOGFONTW DeviceDefaultFont
=
98 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
99 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif" }; //Bitstream Vera Sans
101 static LOGFONTW SystemFixedFont
=
102 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
103 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, L
"Courier New" }; //Bitstream Vera Sans Mono
105 /* FIXME: Is this correct? */
106 static LOGFONTW DefaultGuiFont
=
107 { 11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
108 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif" }; //Bitstream Vera Sans
110 HGDIOBJ StockObjects
[NB_STOCK_OBJECTS
];
115 IntCreateStockPen( DWORD dwPenStyle
,
121 PGDIBRUSHOBJ PenObject
= PENOBJ_AllocPenWithHandle();
123 if ((dwPenStyle
& PS_STYLE_MASK
) == PS_NULL
) dwWidth
= 1;
125 PenObject
->ptPenWidth
.x
= abs(dwWidth
);
126 PenObject
->ptPenWidth
.y
= 0;
127 PenObject
->ulPenStyle
= dwPenStyle
;
128 PenObject
->BrushAttr
.lbColor
= ulColor
;
129 PenObject
->ulStyle
= ulBrushStyle
;
130 PenObject
->hbmClient
= (HANDLE
)NULL
;
131 PenObject
->dwStyleCount
= 0;
132 PenObject
->pStyle
= 0;
133 PenObject
->flAttrs
= GDIBRUSH_IS_OLDSTYLEPEN
;
135 switch (dwPenStyle
& PS_STYLE_MASK
)
138 PenObject
->flAttrs
|= GDIBRUSH_IS_NULL
;
142 PenObject
->flAttrs
|= GDIBRUSH_IS_SOLID
;
145 hPen
= PenObject
->BaseObject
.hHmgr
;
146 PENOBJ_UnlockPen(PenObject
);
151 * Creates a bunch of stock objects: brushes, pens, fonts.
154 CreateStockObjects(void)
158 DPRINT("Beginning creation of stock objects\n");
160 /* Create GDI Stock Objects from the logical structures we've defined */
162 StockObjects
[WHITE_BRUSH
] = IntGdiCreateSolidBrush(RGB(255,255,255));
163 StockObjects
[DC_BRUSH
] = IntGdiCreateSolidBrush(RGB(255,255,255));
164 StockObjects
[LTGRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(192,192,192));
165 StockObjects
[GRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(128,128,128));
166 StockObjects
[DKGRAY_BRUSH
] = IntGdiCreateSolidBrush(RGB(64,64,64));
167 StockObjects
[BLACK_BRUSH
] = IntGdiCreateSolidBrush(RGB(0,0,0));
168 StockObjects
[NULL_BRUSH
] = IntGdiCreateNullBrush();
170 StockObjects
[WHITE_PEN
] = IntCreateStockPen(WhitePen
.lopnStyle
, WhitePen
.lopnWidth
.x
, BS_SOLID
, WhitePen
.lopnColor
);
171 StockObjects
[BLACK_PEN
] = IntCreateStockPen(BlackPen
.lopnStyle
, BlackPen
.lopnWidth
.x
, BS_SOLID
, BlackPen
.lopnColor
);
172 StockObjects
[DC_PEN
] = IntCreateStockPen(BlackPen
.lopnStyle
, BlackPen
.lopnWidth
.x
, BS_SOLID
, BlackPen
.lopnColor
);
173 StockObjects
[NULL_PEN
] = IntCreateStockPen(NullPen
.lopnStyle
, NullPen
.lopnWidth
.x
, BS_SOLID
, NullPen
.lopnColor
);
175 StockObjects
[20] = NULL
; /* TODO: Unknown internal stock object */
176 StockObjects
[DEFAULT_BITMAP
] = IntGdiCreateBitmap(1, 1, 1, 1, NULL
);
178 (void) TextIntCreateFontIndirect(&OEMFixedFont
, (HFONT
*)&StockObjects
[OEM_FIXED_FONT
]);
179 (void) TextIntCreateFontIndirect(&AnsiFixedFont
, (HFONT
*)&StockObjects
[ANSI_FIXED_FONT
]);
180 (void) TextIntCreateFontIndirect(&AnsiVarFont
, (HFONT
*)&StockObjects
[ANSI_VAR_FONT
]);
181 (void) TextIntCreateFontIndirect(&SystemFont
, (HFONT
*)&StockObjects
[SYSTEM_FONT
]);
182 (void) TextIntCreateFontIndirect(&DeviceDefaultFont
, (HFONT
*)&StockObjects
[DEVICE_DEFAULT_FONT
]);
183 (void) TextIntCreateFontIndirect(&SystemFixedFont
, (HFONT
*)&StockObjects
[SYSTEM_FIXED_FONT
]);
184 (void) TextIntCreateFontIndirect(&DefaultGuiFont
, (HFONT
*)&StockObjects
[DEFAULT_GUI_FONT
]);
186 StockObjects
[DEFAULT_PALETTE
] = (HGDIOBJ
)PALETTE_Init();
188 for (Object
= 0; Object
< NB_STOCK_OBJECTS
; Object
++)
190 if (NULL
!= StockObjects
[Object
])
192 GDIOBJ_ConvertToStockObj(&StockObjects
[Object
]);
196 DPRINT("Completed creation of stock objects\n");
200 * Return stock object.
201 * \param Object - stock object id.
202 * \return Handle to the object.
205 NtGdiGetStockObject(INT Object
)
207 DPRINT("NtGdiGetStockObject index %d\n", Object
);
209 return ((Object
< 0) || (NB_STOCK_OBJECTS
<= Object
)) ? NULL
: StockObjects
[Object
];
213 IntSetSysColors(UINT nColors
, INT
*Elements
, COLORREF
*Colors
)
220 for(i
= 0; i
< nColors
; i
++)
222 if((UINT
)(*Elements
) < NUM_SYSCOLORS
)
224 gpsi
->SysColors
[*Elements
] = *Colors
;
225 IntGdiSetSolidBrushColor(gpsi
->SysColorBrushes
[*Elements
], *Colors
);
226 IntGdiSetSolidPenColor(gpsi
->SysColorPens
[*Elements
], *Colors
);
235 IntGetSysColorBrushes(HBRUSH
*Brushes
, UINT nBrushes
)
241 if(nBrushes
> NUM_SYSCOLORS
)
243 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
247 for(i
= 0; i
< nBrushes
; i
++)
249 *(Brushes
++) = gpsi
->SysColorBrushes
[i
];
256 IntGetSysColorBrush(INT Object
)
258 return ((Object
< 0) || (NUM_SYSCOLORS
<= Object
)) ? NULL
: gpsi
->SysColorBrushes
[Object
];
262 IntGetSysColorPens(HPEN
*Pens
, UINT nPens
)
268 if(nPens
> NUM_SYSCOLORS
)
270 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
274 for(i
= 0; i
< nPens
; i
++)
276 *(Pens
++) = gpsi
->SysColorPens
[i
];
283 IntGetSysColors(COLORREF
*Colors
, UINT nColors
)
290 if(nColors
> NUM_SYSCOLORS
)
292 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
296 col
= &gpsi
->SysColors
[0];
297 for(i
= 0; i
< nColors
; i
++)
299 *(Colors
++) = *(col
++);
306 IntGetSysColor(INT nIndex
)
308 return (NUM_SYSCOLORS
<= (UINT
)nIndex
) ? 0 : gpsi
->SysColors
[nIndex
];
312 CreateSysColorObjects(VOID
)
317 for(i
= 0; i
< NUM_SYSCOLORS
; i
++)
319 gpsi
->SysColors
[i
] = SysColors
[i
];
322 /* Create the syscolor brushes */
323 for(i
= 0; i
< NUM_SYSCOLORS
; i
++)
325 if(gpsi
->SysColorBrushes
[i
] == NULL
)
327 gpsi
->SysColorBrushes
[i
] = IntGdiCreateSolidBrush(SysColors
[i
]);
328 if(gpsi
->SysColorBrushes
[i
] != NULL
)
330 GDIOBJ_ConvertToStockObj((HGDIOBJ
*)&gpsi
->SysColorBrushes
[i
]);
335 /* Create the syscolor pens */
336 Pen
.lopnStyle
= PS_SOLID
;
339 for(i
= 0; i
< NUM_SYSCOLORS
; i
++)
341 if(gpsi
->SysColorPens
[i
] == NULL
)
343 Pen
.lopnColor
= SysColors
[i
];
344 gpsi
->SysColorPens
[i
] = IntCreateStockPen(Pen
.lopnStyle
, Pen
.lopnWidth
.x
, BS_SOLID
, Pen
.lopnColor
);
345 if(gpsi
->SysColorPens
[i
] != NULL
)
347 GDIOBJ_ConvertToStockObj((HGDIOBJ
*)&gpsi
->SysColorPens
[i
]);