2004-12-12 01:40:39 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998 - 2004 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-12-12 01:40:39 +00:00
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* STOCKOBJ.C - GDI Stock Objects
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2008-05-29 18:51:17 +00:00
|
|
|
|
2009-06-27 23:33:57 +00:00
|
|
|
static const COLORREF SysColors[] =
|
2004-12-12 01:40:39 +00:00
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
RGB(212, 208, 200), /* COLOR_SCROLLBAR */
|
|
|
|
RGB(58, 110, 165), /* COLOR_BACKGROUND */
|
|
|
|
RGB(10, 36, 106), /* COLOR_ACTIVECAPTION */
|
|
|
|
RGB(128, 128, 128), /* COLOR_INACTIVECAPTION */
|
|
|
|
RGB(212, 208, 200), /* COLOR_MENU */
|
|
|
|
RGB(255, 255, 255), /* COLOR_WINDOW */
|
|
|
|
RGB(0, 0, 0), /* COLOR_WINDOWFRAME */
|
|
|
|
RGB(0, 0, 0), /* COLOR_MENUTEXT */
|
|
|
|
RGB(0, 0, 0), /* COLOR_WINDOWTEXT */
|
|
|
|
RGB(255, 255, 255), /* COLOR_CAPTIONTEXT */
|
|
|
|
RGB(212, 208, 200), /* COLOR_ACTIVEBORDER */
|
|
|
|
RGB(212, 208, 200), /* COLOR_INACTIVEBORDER */
|
|
|
|
RGB(128, 128, 128), /* COLOR_APPWORKSPACE */
|
|
|
|
RGB(10, 36, 106), /* COLOR_HIGHLIGHT */
|
|
|
|
RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT */
|
|
|
|
RGB(212, 208, 200), /* COLOR_BTNFACE */
|
|
|
|
RGB(128, 128, 128), /* COLOR_BTNSHADOW */
|
|
|
|
RGB(128, 128, 128), /* COLOR_GRAYTEXT */
|
|
|
|
RGB(0, 0, 0), /* COLOR_BTNTEXT */
|
|
|
|
RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT */
|
|
|
|
RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT */
|
|
|
|
RGB(64, 64, 64), /* COLOR_3DDKSHADOW */
|
|
|
|
RGB(212, 208, 200), /* COLOR_3DLIGHT */
|
|
|
|
RGB(0, 0, 0), /* COLOR_INFOTEXT */
|
|
|
|
RGB(255, 255, 225), /* COLOR_INFOBK */
|
|
|
|
RGB(181, 181, 181), /* COLOR_UNKNOWN */
|
|
|
|
RGB(0, 0, 128), /* COLOR_HOTLIGHT */
|
|
|
|
RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION */
|
|
|
|
RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION */
|
|
|
|
RGB(49, 106, 197), /* COLOR_MENUHILIGHT */
|
|
|
|
RGB(236, 233, 216) /* COLOR_MENUBAR */
|
2004-12-12 01:40:39 +00:00
|
|
|
};
|
|
|
|
#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
|
|
|
|
|
2008-05-30 04:56:10 +00:00
|
|
|
// System Bitmap DC
|
|
|
|
HDC hSystemBM;
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
/* GDI stock objects */
|
|
|
|
|
|
|
|
static LOGPEN WhitePen =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ PS_SOLID, { 0, 0 }, RGB(255,255,255) };
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGPEN BlackPen =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ PS_SOLID, { 0, 0 }, RGB(0,0,0) };
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGPEN NullPen =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ PS_NULL, { 0, 0 }, 0 };
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGFONTW OEMFixedFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier New"
|
|
|
|
}; //Bitstream Vera Sans Mono
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGFONTW AnsiFixedFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier New"
|
|
|
|
}; //Bitstream Vera Sans Mono
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2008-09-18 12:43:21 +00:00
|
|
|
static LOGFONTW AnsiVarFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif"
|
|
|
|
};
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGFONTW SystemFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Courier New"
|
|
|
|
}; //Bitstream Vera Sans
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGFONTW DeviceDefaultFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif"
|
|
|
|
}; //Bitstream Vera Sans
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
static LOGFONTW SystemFixedFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier New"
|
|
|
|
}; //Bitstream Vera Sans Mono
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2004-12-12 01:40:39 +00:00
|
|
|
/* FIXME: Is this correct? */
|
|
|
|
static LOGFONTW DefaultGuiFont =
|
2009-06-27 23:54:02 +00:00
|
|
|
{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
|
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif"
|
|
|
|
}; //Bitstream Vera Sans
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2008-11-26 20:44:41 +00:00
|
|
|
HGDIOBJ StockObjects[NB_STOCK_OBJECTS];
|
|
|
|
|
|
|
|
static
|
|
|
|
HPEN
|
|
|
|
FASTCALL
|
2009-06-27 23:54:02 +00:00
|
|
|
IntCreateStockPen(DWORD dwPenStyle,
|
|
|
|
DWORD dwWidth,
|
|
|
|
ULONG ulBrushStyle,
|
|
|
|
ULONG ulColor)
|
2008-11-26 20:44:41 +00:00
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
HPEN hPen;
|
|
|
|
PBRUSH pbrushPen = PEN_AllocPenWithHandle();
|
|
|
|
|
|
|
|
if ((dwPenStyle & PS_STYLE_MASK) == PS_NULL) dwWidth = 1;
|
|
|
|
|
|
|
|
pbrushPen->ptPenWidth.x = abs(dwWidth);
|
|
|
|
pbrushPen->ptPenWidth.y = 0;
|
|
|
|
pbrushPen->ulPenStyle = dwPenStyle;
|
|
|
|
pbrushPen->BrushAttr.lbColor = ulColor;
|
|
|
|
pbrushPen->ulStyle = ulBrushStyle;
|
|
|
|
pbrushPen->hbmClient = (HANDLE)NULL;
|
|
|
|
pbrushPen->dwStyleCount = 0;
|
|
|
|
pbrushPen->pStyle = 0;
|
|
|
|
pbrushPen->flAttrs = GDIBRUSH_IS_OLDSTYLEPEN;
|
|
|
|
|
|
|
|
switch (dwPenStyle & PS_STYLE_MASK)
|
|
|
|
{
|
|
|
|
case PS_NULL:
|
|
|
|
pbrushPen->flAttrs |= GDIBRUSH_IS_NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PS_SOLID:
|
|
|
|
pbrushPen->flAttrs |= GDIBRUSH_IS_SOLID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hPen = pbrushPen->BaseObject.hHmgr;
|
|
|
|
PEN_UnlockPen(pbrushPen);
|
|
|
|
return hPen;
|
2008-11-26 20:44:41 +00:00
|
|
|
}
|
2004-12-12 01:40:39 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Creates a bunch of stock objects: brushes, pens, fonts.
|
|
|
|
*/
|
|
|
|
VOID FASTCALL
|
|
|
|
CreateStockObjects(void)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
UINT Object;
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
DPRINT("Beginning creation of stock objects\n");
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
/* Create GDI Stock Objects from the logical structures we've defined */
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
StockObjects[WHITE_BRUSH] = IntGdiCreateSolidBrush(RGB(255,255,255));
|
|
|
|
StockObjects[DC_BRUSH] = IntGdiCreateSolidBrush(RGB(255,255,255));
|
|
|
|
StockObjects[LTGRAY_BRUSH] = IntGdiCreateSolidBrush(RGB(192,192,192));
|
|
|
|
StockObjects[GRAY_BRUSH] = IntGdiCreateSolidBrush(RGB(128,128,128));
|
|
|
|
StockObjects[DKGRAY_BRUSH] = IntGdiCreateSolidBrush(RGB(64,64,64));
|
|
|
|
StockObjects[BLACK_BRUSH] = IntGdiCreateSolidBrush(RGB(0,0,0));
|
|
|
|
StockObjects[NULL_BRUSH] = IntGdiCreateNullBrush();
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
StockObjects[WHITE_PEN] = IntCreateStockPen(WhitePen.lopnStyle, WhitePen.lopnWidth.x, BS_SOLID, WhitePen.lopnColor);
|
|
|
|
StockObjects[BLACK_PEN] = IntCreateStockPen(BlackPen.lopnStyle, BlackPen.lopnWidth.x, BS_SOLID, BlackPen.lopnColor);
|
|
|
|
StockObjects[DC_PEN] = IntCreateStockPen(BlackPen.lopnStyle, BlackPen.lopnWidth.x, BS_SOLID, BlackPen.lopnColor);
|
|
|
|
StockObjects[NULL_PEN] = IntCreateStockPen(NullPen.lopnStyle, NullPen.lopnWidth.x, BS_SOLID, NullPen.lopnColor);
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
StockObjects[20] = NULL; /* TODO: Unknown internal stock object */
|
|
|
|
StockObjects[DEFAULT_BITMAP] = IntGdiCreateBitmap(1, 1, 1, 1, NULL);
|
2008-05-10 17:39:38 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
(void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&AnsiVarFont, (HFONT*)&StockObjects[ANSI_VAR_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
|
|
|
|
(void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
StockObjects[DEFAULT_PALETTE] = (HGDIOBJ)PALETTE_Init();
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
|
2004-12-12 01:40:39 +00:00
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
if (NULL != StockObjects[Object])
|
|
|
|
{
|
|
|
|
GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
|
|
|
|
}
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
DPRINT("Completed creation of stock objects\n");
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Return stock object.
|
|
|
|
* \param Object - stock object id.
|
|
|
|
* \return Handle to the object.
|
|
|
|
*/
|
2008-11-29 22:48:58 +00:00
|
|
|
HGDIOBJ APIENTRY
|
2004-12-12 01:40:39 +00:00
|
|
|
NtGdiGetStockObject(INT Object)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
DPRINT("NtGdiGetStockObject index %d\n", Object);
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FASTCALL
|
|
|
|
IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
UINT i;
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
ASSERT(Elements);
|
|
|
|
ASSERT(Colors);
|
2004-12-12 01:40:39 +00:00
|
|
|
|
2009-06-27 23:54:02 +00:00
|
|
|
for (i = 0; i < nColors; i++)
|
2004-12-12 01:40:39 +00:00
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
if ((UINT)(*Elements) < NUM_SYSCOLORS)
|
|
|
|
{
|
|
|
|
gpsi->argbSystem[*Elements] = *Colors;
|
|
|
|
IntGdiSetSolidBrushColor(gpsi->ahbrSystem[*Elements], *Colors);
|
|
|
|
}
|
|
|
|
Elements++;
|
|
|
|
Colors++;
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
2009-06-27 23:54:02 +00:00
|
|
|
return nColors > 0;
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
|
|
|
|
2006-08-08 20:00:53 +00:00
|
|
|
HGDIOBJ FASTCALL
|
|
|
|
IntGetSysColorBrush(INT Object)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
return ((Object < 0) || (NUM_SYSCOLORS <= Object)) ? NULL : gpsi->ahbrSystem[Object];
|
2006-08-08 20:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DWORD FASTCALL
|
|
|
|
IntGetSysColor(INT nIndex)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
return (NUM_SYSCOLORS <= (UINT)nIndex) ? 0 : gpsi->argbSystem[nIndex];
|
2006-08-08 20:00:53 +00:00
|
|
|
}
|
|
|
|
|
2004-12-12 01:40:39 +00:00
|
|
|
VOID FASTCALL
|
|
|
|
CreateSysColorObjects(VOID)
|
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SYSCOLORS; i++)
|
2004-12-12 01:40:39 +00:00
|
|
|
{
|
2009-06-27 23:54:02 +00:00
|
|
|
gpsi->argbSystem[i] = SysColors[i];
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
2009-06-27 23:54:02 +00:00
|
|
|
|
|
|
|
/* Create the syscolor brushes */
|
|
|
|
for (i = 0; i < NUM_SYSCOLORS; i++)
|
|
|
|
{
|
|
|
|
if (gpsi->ahbrSystem[i] == NULL)
|
|
|
|
{
|
|
|
|
gpsi->ahbrSystem[i] = IntGdiCreateSolidBrush(SysColors[i]);
|
|
|
|
if (gpsi->ahbrSystem[i] != NULL)
|
|
|
|
{
|
|
|
|
GDIOBJ_ConvertToStockObj((HGDIOBJ*)&gpsi->ahbrSystem[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-12 01:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|