ReactOS  0.4.14-dev-52-g6116262
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 
16 static 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 
56 static LOGPEN WhitePen =
57  { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
58 
59 static LOGPEN BlackPen =
60  { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
61 
62 static LOGPEN NullPen =
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,
97  OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, /*DEFAULT_QUALITY*/ PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"MS Shell Dlg"
98  };
99 
101 
102 static
103 HPEN
104 FASTCALL
106  DWORD dwWidth,
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 
144 static 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;
172  wcscpy(DefaultGuiFont.lfFaceName, MingLiU);
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  {
197  OEMFixedFont.lfHeight = 18;
199  SystemFont.lfHeight = 18;
205  DefaultGuiFont.lfHeight = -12;
206  }
207  else
208  {
209  OEMFixedFont.lfHeight = 12;
211  SystemFont.lfHeight = 16;
215  if (bActiveCharSet == RUSSIAN_CHARSET)
216  {
219  }
220  else
221  {
224  }
225  DefaultGuiFont.lfHeight = -11;
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 abs(i)
Definition: fconv.c:206
static LOGFONTW OEMFixedFont
Definition: stockobj.c:65
HDC hSystemBM
Definition: stockobj.c:52
#define TRUE
Definition: types.h:120
static LOGPEN BlackPen
Definition: stockobj.c:59
BYTE lfPitchAndFamily
Definition: dimm.idl:71
HBRUSH APIENTRY IntGdiCreateSolidBrush(COLORREF crColor)
Definition: brush.cpp:279
#define VARIABLE_PITCH
Definition: wingdi.h:444
static LOGFONTW SystemFixedFont
Definition: stockobj.c:90
#define DEFAULT_QUALITY
Definition: wingdi.h:435
#define FF_DONTCARE
Definition: wingdi.h:447
#define NB_STOCK_OBJECTS
Definition: ntgdityp.h:191
long x
Definition: polytest.cpp:48
#define PS_STYLE_MASK
Definition: wingdi.h:600
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont)
Definition: freetype.c:2167
#define WHITE_PEN
Definition: wingdi.h:904
#define NULL_BRUSH
Definition: wingdi.h:900
LONG lfHeight
Definition: dimm.idl:59
BYTE lfCharSet
Definition: dimm.idl:67
static HDC
Definition: imagelist.c:92
POINT lopnWidth
Definition: wingdi.h:1841
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
#define WHITE_BRUSH
Definition: wingdi.h:901
static VOID FASTCALL CreateStockFonts(void)
Definition: stockobj.c:145
HGDIOBJ StockObjects[NB_STOCK_OBJECTS]
Definition: stockobj.c:100
#define DEFAULT_CHARSET
Definition: wingdi.h:383
#define FASTCALL
Definition: nt_native.h:50
#define PROOF_QUALITY
Definition: wingdi.h:437
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:56
PALETTE * gppalDefault
Definition: palette.c:20
static LOGPEN NullPen
Definition: stockobj.c:62
#define BR_IS_SOLID
Definition: brush.h:97
#define OEM_FIXED_FONT
Definition: wingdi.h:909
#define PS_SOLID
Definition: wingdi.h:585
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 BR_IS_OLDSTYLEPEN
Definition: brush.h:104
BOOL NTAPI GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
Definition: gdiobj.c:1452
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXED_PITCH
Definition: wingdi.h:443
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
#define DEVICE_DEFAULT_FONT
Definition: wingdi.h:907
UINT lopnStyle
Definition: wingdi.h:1840
#define NULL_PEN
Definition: wingdi.h:903
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
COLORREF lopnColor
Definition: wingdi.h:1842
smooth NULL
Definition: ftsmooth.c:416
#define SYSTEM_FONT
Definition: wingdi.h:910
#define LTGRAY_BRUSH
Definition: wingdi.h:899
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI VOID NTAPI RtlGetDefaultCodePage(_Out_ PUSHORT AnsiCodePage, _Out_ PUSHORT OemCodePage)
#define GRAY_BRUSH
Definition: wingdi.h:897
#define DEFAULT_BITMAP
Definition: ntgdityp.h:194
static LOGFONTW SystemFont
Definition: stockobj.c:80
Definition: types.h:100
#define BLACK_BRUSH
Definition: wingdi.h:895
VOID FASTCALL IntSetSysColors(UINT nColors, CONST INT *Elements, CONST COLORREF *Colors)
Definition: stockobj.c:300
BYTE FASTCALL IntCharSetFromCodePage(UINT uCodePage)
Definition: freetype.c:172
#define DEFAULT_PALETTE
Definition: wingdi.h:912
#define DEFAULT_PITCH
Definition: wingdi.h:442
static HPEN FASTCALL IntCreateStockPen(DWORD dwPenStyle, DWORD dwWidth, ULONG ulBrushStyle, ULONG ulColor)
Definition: stockobj.c:105
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD COLORREF
Definition: windef.h:285
Colors
Definition: ansiprsr.h:4
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
#define for
Definition: utility.h:88
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BR_IS_NULL
Definition: brush.h:101
#define RUSSIAN_CHARSET
Definition: wingdi.h:395
static IUnknown Object
Definition: main.c:512
VOID NTAPI IntGdiSetSolidBrushColor(_In_ HBRUSH hbr, _In_ COLORREF crColor)
Definition: brush.cpp:306
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
HGDIOBJ APIENTRY NtGdiGetStockObject(INT Object)
Definition: stockobj.c:292
static CODEPAGE_ENTRY OemCodePage
Definition: nls.c:47
#define OEM_CHARSET
Definition: wingdi.h:399
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
static LOGPEN WhitePen
Definition: stockobj.c:56
#define DKGRAY_BRUSH
Definition: wingdi.h:896
BASEOBJECT BaseObject
Definition: palette.h:36
unsigned char BYTE
Definition: mem.h:68
PBRUSH NTAPI PEN_AllocPenWithHandle(VOID)
Definition: pen.c:27
void * HGDIOBJ
Definition: windef.h:252
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
#define FLOATOBJ_SetLong(pf, l)
Definition: winddi.h:2815
static const COLORREF SysColors[]
Definition: stockobj.c:16
#define PEN_UnlockPen(pPenObj)
Definition: pen.h:17
#define FF_SWISS
Definition: wingdi.h:451
#define FW_BOLD
Definition: wingdi.h:377
#define ANSI_VAR_FONT
Definition: wingdi.h:906
unsigned short USHORT
Definition: pedump.c:61
#define BLACK_PEN
Definition: wingdi.h:902
#define NUM_SYSCOLORS
Definition: SetSysColors.c:10
#define FF_MODERN
Definition: wingdi.h:448
unsigned int UINT
Definition: ndis.h:50
#define PS_NULL
Definition: wingdi.h:590
VOID FASTCALL CreateStockObjects(void)
Definition: stockobj.c:247
static LOGFONTW AnsiFixedFont
Definition: stockobj.c:70
#define ANSI_FIXED_FONT
Definition: wingdi.h:905
#define FW_NORMAL
Definition: wingdi.h:372
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
unsigned int ULONG
Definition: retypes.h:1
#define BS_SOLID
Definition: wingdi.h:1085
#define ANSI_CHARSET
Definition: wingdi.h:382
BASEOBJECT BaseObject
Definition: brush.h:56
static LOGFONTW AnsiVarFont
Definition: stockobj.c:75
#define CLIP_STROKE_PRECIS
Definition: wingdi.h:427
#define CONST
Definition: pedump.c:81
static LOGFONTW DeviceDefaultFont
Definition: stockobj.c:85
HBRUSH NTAPI IntGdiCreateNullBrush(VOID)
Definition: brush.cpp:270
static LOGFONTW DefaultGuiFont
Definition: stockobj.c:95
static const WCHAR dwWidth[]
Definition: provider.c:59
#define APIENTRY
Definition: api.h:79
#define SYSTEM_FIXED_FONT
Definition: wingdi.h:911
HBITMAP NTAPI GreCreateBitmap(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cPlanes, _In_ ULONG cBitsPixel, _In_opt_ PVOID pvBits)
Definition: bitmaps.c:172