ReactOS 0.4.16-dev-122-g325d74c
stockobj.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS win32 kernel mode subsystem
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: win32ss/gdi/ntgdi/stockobj.c
5 * PURPOSE: Stock objects functions
6 * PROGRAMMERS: Colin Finck <colin@reactos.org>
7 * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10#include <win32k.h>
11
12#define NDEBUG
13#include <debug.h>
14
15
16static const COLORREF SysColors[] =
17{
18 RGB(212, 208, 200), /* COLOR_SCROLLBAR */
19 RGB(58, 110, 165), /* COLOR_BACKGROUND */
20 RGB(10, 36, 106), /* COLOR_ACTIVECAPTION */
21 RGB(128, 128, 128), /* COLOR_INACTIVECAPTION */
22 RGB(212, 208, 200), /* COLOR_MENU */
23 RGB(255, 255, 255), /* COLOR_WINDOW */
24 RGB(0, 0, 0), /* COLOR_WINDOWFRAME */
25 RGB(0, 0, 0), /* COLOR_MENUTEXT */
26 RGB(0, 0, 0), /* COLOR_WINDOWTEXT */
27 RGB(255, 255, 255), /* COLOR_CAPTIONTEXT */
28 RGB(212, 208, 200), /* COLOR_ACTIVEBORDER */
29 RGB(212, 208, 200), /* COLOR_INACTIVEBORDER */
30 RGB(128, 128, 128), /* COLOR_APPWORKSPACE */
31 RGB(10, 36, 106), /* COLOR_HIGHLIGHT */
32 RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT */
33 RGB(212, 208, 200), /* COLOR_BTNFACE */
34 RGB(128, 128, 128), /* COLOR_BTNSHADOW */
35 RGB(128, 128, 128), /* COLOR_GRAYTEXT */
36 RGB(0, 0, 0), /* COLOR_BTNTEXT */
37 RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT */
38 RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT */
39 RGB(64, 64, 64), /* COLOR_3DDKSHADOW */
40 RGB(212, 208, 200), /* COLOR_3DLIGHT */
41 RGB(0, 0, 0), /* COLOR_INFOTEXT */
42 RGB(255, 255, 225), /* COLOR_INFOBK */
43 RGB(181, 181, 181), /* COLOR_UNKNOWN */
44 RGB(0, 0, 128), /* COLOR_HOTLIGHT */
45 RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION */
46 RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION */
47 RGB(49, 106, 197), /* COLOR_MENUHILIGHT */
48 RGB(236, 233, 216) /* COLOR_MENUBAR */
49};
50
51// System Bitmap DC
53
54/* GDI stock objects */
55
57 { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
58
60 { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
61
63 { PS_NULL, { 0, 0 }, 0 };
64
66 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
68 };
69
71 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
72 OUT_DEFAULT_PRECIS, /*CLIP_DEFAULT_PRECIS*/ CLIP_STROKE_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, FF_DONTCARE | FIXED_PITCH, L"Courier"
73 };
74
76 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
77 OUT_DEFAULT_PRECIS, /*CLIP_DEFAULT_PRECIS*/ CLIP_STROKE_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, FF_DONTCARE | VARIABLE_PITCH, L"MS Sans Serif"
78 };
79
81 { 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
83 };
84
86 { 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
88 };
89
91 { 15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
93 };
94
96 { -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
98 };
99
101
102static
103HPEN
107 ULONG ulBrushStyle,
108 ULONG ulColor)
109{
110 HPEN hPen;
111 PBRUSH pbrushPen;
112
113 pbrushPen = PEN_AllocPenWithHandle();
114 if (pbrushPen == NULL) return NULL;
115
116 if ((dwPenStyle & PS_STYLE_MASK) == PS_NULL) dwWidth = 1;
117
118 pbrushPen->iHatch = 0;
119 pbrushPen->lWidth = abs(dwWidth);
120 FLOATOBJ_SetLong(&pbrushPen->eWidth, pbrushPen->lWidth);
121 pbrushPen->ulPenStyle = dwPenStyle;
122 pbrushPen->BrushAttr.lbColor = ulColor;
123 pbrushPen->iBrushStyle = ulBrushStyle;
124 pbrushPen->hbmClient = (HANDLE)NULL;
125 pbrushPen->dwStyleCount = 0;
126 pbrushPen->pStyle = 0;
127 pbrushPen->flAttrs = BR_IS_OLDSTYLEPEN;
128
129 switch (dwPenStyle & PS_STYLE_MASK)
130 {
131 case PS_NULL:
132 pbrushPen->flAttrs |= BR_IS_NULL;
133 break;
134
135 case PS_SOLID:
136 pbrushPen->flAttrs |= BR_IS_SOLID;
137 break;
138 }
139 hPen = pbrushPen->BaseObject.hHmgr;
140 PEN_UnlockPen(pbrushPen);
141 return hPen;
142}
143
144static VOID FASTCALL
146{
147 USHORT ActiveCodePage, OemCodePage;
148 BYTE bActiveCharSet, bOemCharSet;
149 BOOL bIsCJK;
150 static const WCHAR SimSun[] = { 0x5B8B, 0x4F53, 0 };
151 static const WCHAR MingLiU[] = { 0x7D30, 0x660E, 0x9AD4, 0 };
152 static const WCHAR Batang[] = { 0xBC14, 0xD0D5, 0 };
153
154 RtlGetDefaultCodePage(&ActiveCodePage, &OemCodePage);
155 bActiveCharSet = IntCharSetFromCodePage(ActiveCodePage);
156 bOemCharSet = IntCharSetFromCodePage(OemCodePage);
157
158 if (bOemCharSet == DEFAULT_CHARSET)
159 bOemCharSet = OEM_CHARSET;
160
161 switch (ActiveCodePage)
162 {
163 case 936:
164 /* Simplified Chinese */
165 bIsCJK = TRUE;
167 break;
168
169 case 950:
170 /* Traditional Chinese */
171 bIsCJK = TRUE;
173 break;
174
175 case 932:
176 /* Japanese */
177 bIsCJK = TRUE;
178 wcscpy(DefaultGuiFont.lfFaceName, L"MS UI Gothic");
179 break;
180
181 case 949:
182 case 1361:
183 /* Korean */
184 bIsCJK = TRUE;
186 break;
187
188 default:
189 /* Otherwise */
190 bIsCJK = FALSE;
191 wcscpy(DefaultGuiFont.lfFaceName, L"MS Shell Dlg");
192 break;
193 }
194
195 if (bIsCJK)
196 {
199 SystemFont.lfHeight = 18;
206 }
207 else
208 {
211 SystemFont.lfHeight = 16;
215 if (bActiveCharSet == RUSSIAN_CHARSET)
216 {
219 }
220 else
221 {
224 }
226 }
227
228 OEMFixedFont.lfCharSet = bOemCharSet;
229 SystemFont.lfCharSet = bActiveCharSet;
230 DeviceDefaultFont.lfCharSet = bActiveCharSet;
231 SystemFixedFont.lfCharSet = bActiveCharSet;
232 DefaultGuiFont.lfCharSet = bActiveCharSet;
233
241}
242
248{
249 UINT Object;
250
251 DPRINT("Beginning creation of stock objects\n");
252
253 /* Create GDI Stock Objects from the logical structures we've defined */
254
256 StockObjects[DC_BRUSH] = IntGdiCreateSolidBrush(RGB(255,255,255));
262
267
268 StockObjects[20] = NULL; /* TODO: Unknown internal stock object */
270
272
274
276 {
277 if (NULL != StockObjects[Object])
278 {
280 }
281 }
282
283 DPRINT("Completed creation of stock objects\n");
284}
285
293{
294 DPRINT("NtGdiGetStockObject index %d\n", Object);
295
296 return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
297}
298
301{
302 UINT i;
303
304 for (i = 0; i < nColors; i++)
305 {
306 if ((UINT)(*Elements) < NUM_SYSCOLORS)
307 {
308 gpsi->argbSystem[*Elements] = *Colors;
309 IntGdiSetSolidBrushColor(gpsi->ahbrSystem[*Elements], *Colors);
310 }
311 Elements++;
312 Colors++;
313 }
314}
315
318{
319 return ((Object < 0) || (NUM_SYSCOLORS <= Object)) ? NULL : gpsi->ahbrSystem[Object];
320}
321
324{
325 return (NUM_SYSCOLORS <= (UINT)nIndex) ? 0 : gpsi->argbSystem[nIndex];
326}
327
330{
331 UINT i;
332
333 for (i = 0; i < NUM_SYSCOLORS; i++)
334 {
335 gpsi->argbSystem[i] = SysColors[i];
336 }
337
338 /* Create the syscolor brushes */
339 for (i = 0; i < NUM_SYSCOLORS; i++)
340 {
341 if (gpsi->ahbrSystem[i] == NULL)
342 {
343 gpsi->ahbrSystem[i] = IntGdiCreateSolidBrush(SysColors[i]);
344 if (gpsi->ahbrSystem[i] != NULL)
345 {
346 GDIOBJ_ConvertToStockObj((HGDIOBJ*)&gpsi->ahbrSystem[i]);
347 }
348 }
349 }
350}
351
352/* EOF */
#define NUM_SYSCOLORS
Definition: SetSysColors.c:10
Colors
Definition: ansiprsr.h:4
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172
HBRUSH APIENTRY IntGdiCreateSolidBrush(COLORREF crColor)
Definition: brush.cpp:290
HBRUSH NTAPI IntGdiCreateNullBrush(VOID)
Definition: brush.cpp:281
VOID NTAPI IntGdiSetSolidBrushColor(_In_ HBRUSH hbr, _In_ COLORREF crColor)
Definition: brush.cpp:317
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR dwWidth[]
Definition: provider.c:62
#define APIENTRY
Definition: api.h:79
PSERVERINFO gpsi
Definition: imm.c:18
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
#define RGB(r, g, b)
Definition: precomp.h:71
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE FASTCALL IntCharSetFromCodePage(UINT uCodePage)
Definition: freetype.c:472
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont)
Definition: freetype.c:2668
#define BR_IS_SOLID
Definition: brush.h:101
#define BR_IS_OLDSTYLEPEN
Definition: brush.h:108
#define BR_IS_NULL
Definition: brush.h:105
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define for
Definition: utility.h:88
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
#define FASTCALL
Definition: nt_native.h:50
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:192
#define L(x)
Definition: ntvdm.h:50
#define CONST
Definition: pedump.c:81
unsigned short USHORT
Definition: pedump.c:61
#define PEN_UnlockPen(pPenObj)
Definition: pen.h:17
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT
Definition: sndvol32.h:73
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
static HPEN FASTCALL IntCreateStockPen(DWORD dwPenStyle, DWORD dwWidth, ULONG ulBrushStyle, ULONG ulColor)
Definition: stockobj.c:105
HGDIOBJ APIENTRY NtGdiGetStockObject(INT Object)
Definition: stockobj.c:292
static LOGFONTW SystemFont
Definition: stockobj.c:80
VOID FASTCALL IntSetSysColors(UINT nColors, CONST INT *Elements, CONST COLORREF *Colors)
Definition: stockobj.c:300
static LOGFONTW AnsiFixedFont
Definition: stockobj.c:70
static LOGFONTW SystemFixedFont
Definition: stockobj.c:90
static LOGFONTW AnsiVarFont
Definition: stockobj.c:75
static LOGFONTW DeviceDefaultFont
Definition: stockobj.c:85
static LOGPEN NullPen
Definition: stockobj.c:62
static LOGFONTW OEMFixedFont
Definition: stockobj.c:65
static VOID FASTCALL CreateStockFonts(void)
Definition: stockobj.c:145
VOID FASTCALL CreateStockObjects(void)
Definition: stockobj.c:247
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
HGDIOBJ StockObjects[NB_STOCK_OBJECTS]
Definition: stockobj.c:100
static const COLORREF SysColors[]
Definition: stockobj.c:16
static LOGPEN WhitePen
Definition: stockobj.c:56
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
static LOGFONTW DefaultGuiFont
Definition: stockobj.c:95
HDC hSystemBM
Definition: stockobj.c:52
static LOGPEN BlackPen
Definition: stockobj.c:59
LONG lfHeight
Definition: dimm.idl:59
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfPitchAndFamily
Definition: dimm.idl:71
Definition: types.h:101
BASEOBJECT BaseObject
Definition: brush.h:56
BASEOBJECT BaseObject
Definition: palette.h:36
COLORREF lopnColor
Definition: wingdi.h:1847
POINT lopnWidth
Definition: wingdi.h:1846
UINT lopnStyle
Definition: wingdi.h:1845
long x
Definition: polytest.cpp:48
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
BOOL NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
Definition: gdiobj.c:1455
PALETTE * gppalDefault
Definition: palette.c:20
PBRUSH NTAPI PEN_AllocPenWithHandle(VOID)
Definition: pen.c:27
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
void * HGDIOBJ
Definition: windef.h:252
DWORD COLORREF
Definition: windef.h:300
#define FIXED_PITCH
Definition: wingdi.h:444
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define PS_NULL
Definition: wingdi.h:591
#define VARIABLE_PITCH
Definition: wingdi.h:445
#define ANSI_FIXED_FONT
Definition: wingdi.h:906
#define RUSSIAN_CHARSET
Definition: wingdi.h:396
#define FF_MODERN
Definition: wingdi.h:449
#define DEFAULT_PALETTE
Definition: wingdi.h:913
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#define DKGRAY_BRUSH
Definition: wingdi.h:897
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FW_BOLD
Definition: wingdi.h:378
#define FF_DONTCARE
Definition: wingdi.h:448
#define ANSI_VAR_FONT
Definition: wingdi.h:907
#define PS_STYLE_MASK
Definition: wingdi.h:601
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define WHITE_PEN
Definition: wingdi.h:905
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#define SYSTEM_FIXED_FONT
Definition: wingdi.h:912
#define NULL_BRUSH
Definition: wingdi.h:901
#define OEM_FIXED_FONT
Definition: wingdi.h:910
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define BLACK_PEN
Definition: wingdi.h:903
#define NULL_PEN
Definition: wingdi.h:904
#define ANSI_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:438
#define BLACK_BRUSH
Definition: wingdi.h:896
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define OEM_CHARSET
Definition: wingdi.h:400
#define FW_NORMAL
Definition: wingdi.h:373
#define SYSTEM_FONT
Definition: wingdi.h:911
#define CLIP_STROKE_PRECIS
Definition: wingdi.h:428
#define DEVICE_DEFAULT_FONT
Definition: wingdi.h:908
#define BS_SOLID
Definition: wingdi.h:1086
#define FF_SWISS
Definition: wingdi.h:452
#define PS_SOLID
Definition: wingdi.h:586
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193