ReactOS 0.4.15-dev-7953-g1f49173
stockobj.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for stockobj.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static HPEN FASTCALL IntCreateStockPen (DWORD dwPenStyle, DWORD dwWidth, ULONG ulBrushStyle, ULONG ulColor)
 
static VOID FASTCALL CreateStockFonts (void)
 
VOID FASTCALL CreateStockObjects (void)
 
HGDIOBJ APIENTRY NtGdiGetStockObject (INT Object)
 
VOID FASTCALL IntSetSysColors (UINT nColors, CONST INT *Elements, CONST COLORREF *Colors)
 
HGDIOBJ FASTCALL IntGetSysColorBrush (INT Object)
 
DWORD FASTCALL IntGetSysColor (INT nIndex)
 
VOID FASTCALL CreateSysColorObjects (VOID)
 

Variables

static const COLORREF SysColors []
 
HDC hSystemBM
 
static LOGPEN WhitePen
 
static LOGPEN BlackPen
 
static LOGPEN NullPen
 
static LOGFONTW OEMFixedFont
 
static LOGFONTW AnsiFixedFont
 
static LOGFONTW AnsiVarFont
 
static LOGFONTW SystemFont
 
static LOGFONTW DeviceDefaultFont
 
static LOGFONTW SystemFixedFont
 
static LOGFONTW DefaultGuiFont
 
HGDIOBJ StockObjects [NB_STOCK_OBJECTS]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file stockobj.c.

Function Documentation

◆ CreateStockFonts()

static VOID FASTCALL CreateStockFonts ( void  )
static

Definition at line 145 of file stockobj.c.

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}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
BYTE FASTCALL IntCharSetFromCodePage(UINT uCodePage)
Definition: freetype.c:172
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont)
Definition: freetype.c:1991
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static LOGFONTW SystemFont
Definition: stockobj.c:80
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 LOGFONTW OEMFixedFont
Definition: stockobj.c:65
HGDIOBJ StockObjects[NB_STOCK_OBJECTS]
Definition: stockobj.c:100
static LOGFONTW DefaultGuiFont
Definition: stockobj.c:95
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
#define FIXED_PITCH
Definition: wingdi.h:444
#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 FF_DONTCARE
Definition: wingdi.h:448
#define ANSI_VAR_FONT
Definition: wingdi.h:907
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define SYSTEM_FIXED_FONT
Definition: wingdi.h:912
#define OEM_FIXED_FONT
Definition: wingdi.h:910
#define OEM_CHARSET
Definition: wingdi.h:400
#define SYSTEM_FONT
Definition: wingdi.h:911
#define DEVICE_DEFAULT_FONT
Definition: wingdi.h:908
#define FF_SWISS
Definition: wingdi.h:452
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CreateStockObjects().

◆ CreateStockObjects()

VOID FASTCALL CreateStockObjects ( void  )

Creates a bunch of stock objects: brushes, pens, fonts.

Definition at line 247 of file stockobj.c.

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}
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
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define NULL
Definition: types.h:112
#define RGB(r, g, b)
Definition: precomp.h:71
#define for
Definition: utility.h:88
unsigned int UINT
Definition: ndis.h:50
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:192
#define DPRINT
Definition: sndvol32.h:71
static HPEN FASTCALL IntCreateStockPen(DWORD dwPenStyle, DWORD dwWidth, ULONG ulBrushStyle, ULONG ulColor)
Definition: stockobj.c:105
static LOGPEN NullPen
Definition: stockobj.c:62
static VOID FASTCALL CreateStockFonts(void)
Definition: stockobj.c:145
static LOGPEN WhitePen
Definition: stockobj.c:56
static LOGPEN BlackPen
Definition: stockobj.c:59
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
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
BOOL NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
Definition: gdiobj.c:1455
PALETTE * gppalDefault
Definition: palette.c:20
void * HGDIOBJ
Definition: windef.h:252
#define DEFAULT_PALETTE
Definition: wingdi.h:913
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#define DKGRAY_BRUSH
Definition: wingdi.h:897
#define WHITE_PEN
Definition: wingdi.h:905
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#define NULL_BRUSH
Definition: wingdi.h:901
#define BLACK_PEN
Definition: wingdi.h:903
#define NULL_PEN
Definition: wingdi.h:904
#define BLACK_BRUSH
Definition: wingdi.h:896
#define BS_SOLID
Definition: wingdi.h:1086

Referenced by DriverEntry().

◆ CreateSysColorObjects()

VOID FASTCALL CreateSysColorObjects ( VOID  )

Definition at line 329 of file stockobj.c.

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}
#define NUM_SYSCOLORS
Definition: SetSysColors.c:10
PSERVERINFO gpsi
Definition: imm.c:18
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
static const COLORREF SysColors[]
Definition: stockobj.c:16

Referenced by DriverEntry().

◆ IntCreateStockPen()

static HPEN FASTCALL IntCreateStockPen ( DWORD  dwPenStyle,
DWORD  dwWidth,
ULONG  ulBrushStyle,
ULONG  ulColor 
)
static

Definition at line 105 of file stockobj.c.

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}
static const WCHAR dwWidth[]
Definition: provider.c:62
#define abs(i)
Definition: fconv.c:206
#define BR_IS_SOLID
Definition: brush.h:101
#define BR_IS_OLDSTYLEPEN
Definition: brush.h:108
#define BR_IS_NULL
Definition: brush.h:105
#define PEN_UnlockPen(pPenObj)
Definition: pen.h:17
Definition: types.h:101
BASEOBJECT BaseObject
Definition: brush.h:56
PVOID HANDLE
Definition: typedefs.h:73
PBRUSH NTAPI PEN_AllocPenWithHandle(VOID)
Definition: pen.c:27
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
#define PS_NULL
Definition: wingdi.h:591
#define PS_STYLE_MASK
Definition: wingdi.h:601
#define PS_SOLID
Definition: wingdi.h:586

Referenced by CreateStockObjects().

◆ IntGetSysColor()

◆ IntGetSysColorBrush()

◆ IntSetSysColors()

VOID FASTCALL IntSetSysColors ( UINT  nColors,
CONST INT Elements,
CONST COLORREF Colors 
)

Definition at line 300 of file stockobj.c.

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}
Colors
Definition: ansiprsr.h:4
VOID NTAPI IntGdiSetSolidBrushColor(_In_ HBRUSH hbr, _In_ COLORREF crColor)
Definition: brush.cpp:317

Referenced by NtUserSetSysColors().

◆ NtGdiGetStockObject()

HGDIOBJ APIENTRY NtGdiGetStockObject ( INT  Object)

Return stock object.

Parameters
Object- stock object id.
Returns
Handle to the object.

Definition at line 292 of file stockobj.c.

293{
294 DPRINT("NtGdiGetStockObject index %d\n", Object);
295
296 return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
297}

Variable Documentation

◆ AnsiFixedFont

LOGFONTW AnsiFixedFont
static
Initial value:
=
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
}
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define ANSI_CHARSET
Definition: wingdi.h:383
#define PROOF_QUALITY
Definition: wingdi.h:438
#define FW_NORMAL
Definition: wingdi.h:373
#define CLIP_STROKE_PRECIS
Definition: wingdi.h:428

Definition at line 70 of file stockobj.c.

Referenced by CreateStockFonts().

◆ AnsiVarFont

LOGFONTW AnsiVarFont
static
Initial value:

Definition at line 75 of file stockobj.c.

Referenced by CreateStockFonts().

◆ BlackPen

LOGPEN BlackPen
static
Initial value:
=
{ PS_SOLID, { 0, 0 }, RGB(0,0,0) }

Definition at line 59 of file stockobj.c.

Referenced by CreateStockObjects().

◆ DefaultGuiFont

LOGFONTW DefaultGuiFont
static
Initial value:
=
{ -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
}
#define DEFAULT_PITCH
Definition: wingdi.h:443
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426

Definition at line 95 of file stockobj.c.

Referenced by CreateStockFonts().

◆ DeviceDefaultFont

LOGFONTW DeviceDefaultFont
static
Initial value:
=
{ 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
}
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define FW_BOLD
Definition: wingdi.h:378

Definition at line 85 of file stockobj.c.

Referenced by CreateStockFonts().

◆ hSystemBM

HDC hSystemBM

◆ NullPen

LOGPEN NullPen
static
Initial value:
=
{ PS_NULL, { 0, 0 }, 0 }

Definition at line 62 of file stockobj.c.

Referenced by CreateStockObjects().

◆ OEMFixedFont

LOGFONTW OEMFixedFont
static
Initial value:

Definition at line 65 of file stockobj.c.

Referenced by CreateStockFonts().

◆ StockObjects

◆ SysColors

const COLORREF SysColors[]
static

Definition at line 16 of file stockobj.c.

Referenced by CreateSysColorObjects().

◆ SystemFixedFont

LOGFONTW SystemFixedFont
static
Initial value:

Definition at line 90 of file stockobj.c.

Referenced by CreateStockFonts().

◆ SystemFont

LOGFONTW SystemFont
static
Initial value:

Definition at line 80 of file stockobj.c.

Referenced by CreateStockFonts().

◆ WhitePen

LOGPEN WhitePen
static
Initial value:
=
{ PS_SOLID, { 0, 0 }, RGB(255,255,255) }

Definition at line 56 of file stockobj.c.

Referenced by CreateStockObjects().