Create GDI stock objects as normal objects instead of using magic
handle values.
This commit is contained in:
parent
e811f9c353
commit
78f9fae706
|
@ -18,9 +18,15 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
|
||||||
*/
|
*/
|
||||||
inline static BOOL is_stock_font( HFONT font )
|
inline static BOOL is_stock_font( HFONT font )
|
||||||
{
|
{
|
||||||
return (font >= FIRST_STOCK_FONT && font <= LAST_STOCK_FONT);
|
int i;
|
||||||
|
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
|
||||||
|
{
|
||||||
|
if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* ScaleFont
|
* ScaleFont
|
||||||
*
|
*
|
||||||
|
|
|
@ -101,25 +101,24 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
|
||||||
EMRSELECTOBJECT emr;
|
EMRSELECTOBJECT emr;
|
||||||
DWORD index;
|
DWORD index;
|
||||||
HBRUSH hOldBrush;
|
HBRUSH hOldBrush;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* If the object is a stock brush object, do not need to create it.
|
/* If the object is a stock brush object, do not need to create it.
|
||||||
* See definitions in wingdi.h for range of stock brushes.
|
* See definitions in wingdi.h for range of stock brushes.
|
||||||
* We do however have to handle setting the higher order bit to
|
* We do however have to handle setting the higher order bit to
|
||||||
* designate that this is a stock object.
|
* designate that this is a stock object.
|
||||||
*/
|
*/
|
||||||
if (hBrush >= FIRST_STOCK_HANDLE &&
|
for (i = WHITE_BRUSH; i <= NULL_BRUSH; i++)
|
||||||
hBrush <= FIRST_STOCK_HANDLE+HOLLOW_BRUSH )
|
|
||||||
{
|
{
|
||||||
DWORD brush_index = hBrush - FIRST_STOCK_HANDLE;
|
if (hBrush == GetStockObject(i))
|
||||||
index = brush_index | 0x80000000;
|
{
|
||||||
}
|
index = i | 0x80000000;
|
||||||
else
|
goto found;
|
||||||
{
|
}
|
||||||
index = EMFDRV_CreateBrushIndirect(dc, hBrush );
|
|
||||||
}
|
}
|
||||||
|
if (!(index = EMFDRV_CreateBrushIndirect(dc, hBrush ))) return 0;
|
||||||
|
|
||||||
if(!index) return FALSE;
|
found:
|
||||||
|
|
||||||
emr.emr.iType = EMR_SELECTOBJECT;
|
emr.emr.iType = EMR_SELECTOBJECT;
|
||||||
emr.emr.nSize = sizeof(emr);
|
emr.emr.nSize = sizeof(emr);
|
||||||
emr.ihObject = index;
|
emr.ihObject = index;
|
||||||
|
@ -180,6 +179,7 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
|
||||||
EMRSELECTOBJECT emr;
|
EMRSELECTOBJECT emr;
|
||||||
DWORD index;
|
DWORD index;
|
||||||
HFONT hOldFont;
|
HFONT hOldFont;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* If the object is a stock font object, do not need to create it.
|
/* If the object is a stock font object, do not need to create it.
|
||||||
* See definitions in wingdi.h for range of stock fonts.
|
* See definitions in wingdi.h for range of stock fonts.
|
||||||
|
@ -187,20 +187,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
|
||||||
* designate that this is a stock object.
|
* designate that this is a stock object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (hFont >= STOCK_OEM_FIXED_FONT &&
|
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
|
||||||
hFont <= STOCK_DEFAULT_GUI_FONT &&
|
|
||||||
hFont != STOCK_DEFAULT_PALETTE)
|
|
||||||
{
|
{
|
||||||
DWORD font_index = hFont - FIRST_STOCK_HANDLE;
|
if (i != DEFAULT_PALETTE && hFont == GetStockObject(i))
|
||||||
index = font_index | 0x80000000;
|
{
|
||||||
|
index = i | 0x80000000;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (!(index = EMFDRV_CreateFontIndirect(dc, hFont ))) return 0;
|
||||||
{
|
found:
|
||||||
index = EMFDRV_CreateFontIndirect(dc, hFont );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!index) return FALSE;
|
|
||||||
|
|
||||||
emr.emr.iType = EMR_SELECTOBJECT;
|
emr.emr.iType = EMR_SELECTOBJECT;
|
||||||
emr.emr.nSize = sizeof(emr);
|
emr.emr.nSize = sizeof(emr);
|
||||||
emr.ihObject = index;
|
emr.ihObject = index;
|
||||||
|
@ -241,6 +237,7 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
|
||||||
EMRSELECTOBJECT emr;
|
EMRSELECTOBJECT emr;
|
||||||
DWORD index;
|
DWORD index;
|
||||||
HPEN hOldPen;
|
HPEN hOldPen;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* If the object is a stock pen object, do not need to create it.
|
/* If the object is a stock pen object, do not need to create it.
|
||||||
* See definitions in wingdi.h for range of stock pens.
|
* See definitions in wingdi.h for range of stock pens.
|
||||||
|
@ -248,19 +245,16 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
|
||||||
* designate that this is a stock object.
|
* designate that this is a stock object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (hPen >= STOCK_WHITE_PEN &&
|
for (i = WHITE_PEN; i <= NULL_PEN; i++)
|
||||||
hPen <= STOCK_NULL_PEN )
|
|
||||||
{
|
{
|
||||||
DWORD pen_index = hPen - FIRST_STOCK_HANDLE;
|
if (hPen == GetStockObject(i))
|
||||||
index = pen_index | 0x80000000;
|
{
|
||||||
|
index = i | 0x80000000;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (!(index = EMFDRV_CreatePenIndirect(dc, hPen ))) return 0;
|
||||||
{
|
found:
|
||||||
index = EMFDRV_CreatePenIndirect(dc, hPen );
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!index) return FALSE;
|
|
||||||
|
|
||||||
emr.emr.iType = EMR_SELECTOBJECT;
|
emr.emr.iType = EMR_SELECTOBJECT;
|
||||||
emr.emr.nSize = sizeof(emr);
|
emr.emr.nSize = sizeof(emr);
|
||||||
emr.ihObject = index;
|
emr.ihObject = index;
|
||||||
|
|
|
@ -350,7 +350,12 @@ static Atom RAW_DESCENT;
|
||||||
*/
|
*/
|
||||||
inline static BOOL is_stock_font( HFONT font )
|
inline static BOOL is_stock_font( HFONT font )
|
||||||
{
|
{
|
||||||
return (font >= FIRST_STOCK_FONT && font <= LAST_STOCK_FONT);
|
int i;
|
||||||
|
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
|
||||||
|
{
|
||||||
|
if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -246,41 +246,10 @@ typedef struct tagDC_FUNCS
|
||||||
#define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
|
#define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
|
||||||
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
|
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
|
||||||
|
|
||||||
/* Last 32 bytes are reserved for stock object handles */
|
#define GDI_HEAP_SIZE 0xffe0
|
||||||
#define GDI_HEAP_SIZE 0xffe0
|
|
||||||
|
|
||||||
/* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
|
/* extra stock object: default 1x1 bitmap for memory DCs */
|
||||||
#define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
|
#define DEFAULT_BITMAP (STOCK_LAST+1)
|
||||||
|
|
||||||
/* Stock objects handles */
|
|
||||||
|
|
||||||
#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
|
|
||||||
|
|
||||||
#define STOCK_WHITE_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
|
|
||||||
#define STOCK_LTGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
|
|
||||||
#define STOCK_GRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
|
|
||||||
#define STOCK_DKGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
|
|
||||||
#define STOCK_BLACK_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
|
|
||||||
#define STOCK_NULL_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+NULL_BRUSH))
|
|
||||||
#define STOCK_HOLLOW_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
|
|
||||||
#define STOCK_WHITE_PEN ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
|
|
||||||
#define STOCK_BLACK_PEN ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
|
|
||||||
#define STOCK_NULL_PEN ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
|
|
||||||
#define STOCK_OEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
|
|
||||||
#define STOCK_ANSI_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
|
|
||||||
#define STOCK_ANSI_VAR_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
|
|
||||||
#define STOCK_SYSTEM_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
|
|
||||||
#define STOCK_DEVICE_DEFAULT_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
|
|
||||||
#define STOCK_DEFAULT_PALETTE ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
|
|
||||||
#define STOCK_SYSTEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
|
|
||||||
#define STOCK_DEFAULT_GUI_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
|
|
||||||
|
|
||||||
#define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
|
|
||||||
#define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
|
|
||||||
|
|
||||||
#define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
|
|
||||||
|
|
||||||
extern HBITMAP hPseudoStockBitmap;
|
|
||||||
|
|
||||||
/* Device <-> logical coords conversion */
|
/* Device <-> logical coords conversion */
|
||||||
|
|
||||||
|
|
|
@ -681,7 +681,7 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
|
||||||
|
|
||||||
dc->flags = DC_MEMORY;
|
dc->flags = DC_MEMORY;
|
||||||
dc->bitsPerPixel = 1;
|
dc->bitsPerPixel = 1;
|
||||||
dc->hBitmap = hPseudoStockBitmap;
|
dc->hBitmap = GetStockObject( DEFAULT_BITMAP );
|
||||||
|
|
||||||
/* Copy the driver-specific physical device info into
|
/* Copy the driver-specific physical device info into
|
||||||
* the new DC. The driver may use this read-only info
|
* the new DC. The driver may use this read-only info
|
||||||
|
|
349
objects/gdiobj.c
349
objects/gdiobj.c
|
@ -34,247 +34,116 @@ DEFAULT_DEBUG_CHANNEL(gdi);
|
||||||
* GDI stock objects
|
* GDI stock objects
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static BRUSHOBJ WhiteBrush =
|
static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
|
||||||
{
|
static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
|
||||||
{ BS_SOLID, RGB(255,255,255), 0 } /* logbrush */
|
|
||||||
};
|
|
||||||
|
|
||||||
static BRUSHOBJ LtGrayBrush =
|
/* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
|
||||||
{
|
static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
|
||||||
/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
|
|
||||||
{ BS_SOLID, RGB(192,192,192), 0 } /* logbrush */
|
|
||||||
};
|
|
||||||
|
|
||||||
static BRUSHOBJ GrayBrush =
|
|
||||||
{
|
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
|
||||||
/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
|
|
||||||
{ BS_SOLID, RGB(128,128,128), 0 } /* logbrush */
|
|
||||||
};
|
|
||||||
|
|
||||||
static BRUSHOBJ DkGrayBrush =
|
|
||||||
{
|
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
|
||||||
/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
|
/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
|
||||||
/* NB_HATCH_STYLES is an index into HatchBrushes */
|
/* NB_HATCH_STYLES is an index into HatchBrushes */
|
||||||
{ BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES } /* logbrush */
|
static const LOGBRUSH DkGrayBrush = { BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES };
|
||||||
};
|
|
||||||
|
|
||||||
static BRUSHOBJ BlackBrush =
|
static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
|
||||||
{
|
static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
|
||||||
{ BS_SOLID, RGB(0,0,0), 0 } /* logbrush */
|
|
||||||
};
|
|
||||||
|
|
||||||
static BRUSHOBJ NullBrush =
|
static const LOGFONTW OEMFixedFont =
|
||||||
{
|
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
|
||||||
{ 0, BRUSH_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
|
||||||
{ BS_NULL, 0, 0 } /* logbrush */
|
|
||||||
};
|
|
||||||
|
|
||||||
static PENOBJ WhitePen =
|
static const LOGFONTW AnsiFixedFont =
|
||||||
{
|
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, PEN_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
|
||||||
{ PS_SOLID, { 0, 0 }, RGB(255,255,255) } /* logpen */
|
|
||||||
};
|
|
||||||
|
|
||||||
static PENOBJ BlackPen =
|
static const LOGFONTW AnsiVarFont =
|
||||||
{
|
{ 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, PEN_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
||||||
{ PS_SOLID, { 0, 0 }, RGB(0,0,0) } /* logpen */
|
{'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
|
||||||
};
|
|
||||||
|
|
||||||
static PENOBJ NullPen =
|
static const LOGFONTW SystemFont =
|
||||||
{
|
{ 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, PEN_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
||||||
{ PS_NULL, { 0, 0 }, 0 } /* logpen */
|
{'S','y','s','t','e','m','\0'} };
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ OEMFixedFont =
|
static const LOGFONTW DeviceDefaultFont =
|
||||||
{
|
{ 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, {'\0'} };
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ AnsiFixedFont =
|
static const LOGFONTW SystemFixedFont =
|
||||||
{
|
{ 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ AnsiVarFont =
|
|
||||||
{
|
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
|
||||||
{'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ SystemFont =
|
|
||||||
{
|
|
||||||
{ 0, FONT_MAGIC, 1 },
|
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
|
||||||
{'S','y','s','t','e','m','\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ DeviceDefaultFont =
|
|
||||||
{
|
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, {'\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
static FONTOBJ SystemFixedFont =
|
|
||||||
{
|
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
|
||||||
0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* FIXME: Is this correct? */
|
/* FIXME: Is this correct? */
|
||||||
static FONTOBJ DefaultGuiFont =
|
static const LOGFONTW DefaultGuiFont =
|
||||||
{
|
{ -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
{ 0, FONT_MAGIC, 1 }, /* header */
|
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
||||||
{ 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
|
{'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
|
||||||
0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
|
|
||||||
{'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/* reserve one extra entry for the stock default bitmap */
|
||||||
|
/* this is what Windows does too */
|
||||||
|
#define NB_STOCK_OBJECTS (STOCK_LAST+2)
|
||||||
|
|
||||||
static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] =
|
static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
|
||||||
{
|
|
||||||
(GDIOBJHDR *) &WhiteBrush,
|
|
||||||
(GDIOBJHDR *) &LtGrayBrush,
|
|
||||||
(GDIOBJHDR *) &GrayBrush,
|
|
||||||
(GDIOBJHDR *) &DkGrayBrush,
|
|
||||||
(GDIOBJHDR *) &BlackBrush,
|
|
||||||
(GDIOBJHDR *) &NullBrush,
|
|
||||||
(GDIOBJHDR *) &WhitePen,
|
|
||||||
(GDIOBJHDR *) &BlackPen,
|
|
||||||
(GDIOBJHDR *) &NullPen,
|
|
||||||
NULL,
|
|
||||||
(GDIOBJHDR *) &OEMFixedFont,
|
|
||||||
(GDIOBJHDR *) &AnsiFixedFont,
|
|
||||||
(GDIOBJHDR *) &AnsiVarFont,
|
|
||||||
(GDIOBJHDR *) &SystemFont,
|
|
||||||
(GDIOBJHDR *) &DeviceDefaultFont,
|
|
||||||
NULL, /* DEFAULT_PALETTE created by PALETTE_Init */
|
|
||||||
(GDIOBJHDR *) &SystemFixedFont,
|
|
||||||
(GDIOBJHDR *) &DefaultGuiFont
|
|
||||||
};
|
|
||||||
|
|
||||||
HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */
|
|
||||||
|
|
||||||
static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT("GDI_level"), 3 };
|
static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT("GDI_level"), 3 };
|
||||||
static WORD GDI_HeapSel;
|
static WORD GDI_HeapSel;
|
||||||
|
|
||||||
static BOOL get_bool(char *buffer, BOOL def_value)
|
inline static BOOL get_bool(char *buffer)
|
||||||
{
|
{
|
||||||
switch(buffer[0])
|
return (buffer[0] == 'y' || buffer[0] == 'Y' ||
|
||||||
{
|
buffer[0] == 't' || buffer[0] == 'T' ||
|
||||||
case 'n':
|
buffer[0] == '1');
|
||||||
case 'N':
|
|
||||||
case 'f':
|
|
||||||
case 'F':
|
|
||||||
case '0':
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
case 'y':
|
|
||||||
case 'Y':
|
|
||||||
case 't':
|
|
||||||
case 'T':
|
|
||||||
case '1':
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return def_value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* void ReadFontInformation(
|
|
||||||
* char const *fontName,
|
|
||||||
* FONTOBJ *font,
|
|
||||||
* int defHeight,
|
|
||||||
* int defBold,
|
|
||||||
* int defItalic,
|
|
||||||
* int defUnderline,
|
|
||||||
* int defStrikeOut )
|
|
||||||
*
|
|
||||||
* ReadFontInformation() checks the Wine configuration file's Tweak.Fonts
|
|
||||||
* section for entries containing fontName.Height, fontName.Bold, etc.,
|
|
||||||
* where fontName is the name specified in the call (e.g., "System"). It
|
|
||||||
* attempts to be user friendly by accepting 'n', 'N', 'f', 'F', or '0' as
|
|
||||||
* the first character in the boolean attributes (bold, italic, and
|
|
||||||
* underline).
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
static void ReadFontInformation(
|
/******************************************************************************
|
||||||
char const *fontName,
|
* create_stock_font
|
||||||
FONTOBJ *font,
|
*/
|
||||||
int defHeight,
|
static HFONT create_stock_font( char const *fontName, const LOGFONTW *font, HKEY hkey )
|
||||||
int defBold,
|
|
||||||
int defItalic,
|
|
||||||
int defUnderline,
|
|
||||||
int defStrikeOut )
|
|
||||||
{
|
{
|
||||||
|
LOGFONTW lf;
|
||||||
char key[256];
|
char key[256];
|
||||||
char buffer[MAX_PATH];
|
char buffer[MAX_PATH];
|
||||||
HKEY hkey;
|
|
||||||
DWORD type, count;
|
DWORD type, count;
|
||||||
|
|
||||||
/* In order for the stock fonts to be independent of
|
if (!hkey) return CreateFontIndirectW( font );
|
||||||
* mapping mode, the height (& width) must be 0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* assign defaults */
|
|
||||||
font->logfont.lfHeight = defHeight;
|
|
||||||
font->logfont.lfWeight = defBold;
|
|
||||||
font->logfont.lfItalic = defItalic;
|
|
||||||
font->logfont.lfUnderline = defUnderline;
|
|
||||||
font->logfont.lfStrikeOut = defStrikeOut;
|
|
||||||
|
|
||||||
if(RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey))
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
lf = *font;
|
||||||
sprintf(key, "%s.Height", fontName);
|
sprintf(key, "%s.Height", fontName);
|
||||||
count = sizeof(buffer);
|
count = sizeof(buffer);
|
||||||
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
||||||
font->logfont.lfHeight = atoi(buffer);
|
lf.lfHeight = atoi(buffer);
|
||||||
|
|
||||||
sprintf(key, "%s.Bold", fontName);
|
sprintf(key, "%s.Bold", fontName);
|
||||||
count = sizeof(buffer);
|
count = sizeof(buffer);
|
||||||
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
||||||
font->logfont.lfWeight = get_bool(buffer, defBold) ? FW_BOLD : FW_NORMAL;
|
lf.lfWeight = get_bool(buffer) ? FW_BOLD : FW_NORMAL;
|
||||||
|
|
||||||
sprintf(key, "%s.Italic", fontName);
|
sprintf(key, "%s.Italic", fontName);
|
||||||
count = sizeof(buffer);
|
count = sizeof(buffer);
|
||||||
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
||||||
font->logfont.lfItalic = get_bool(buffer, defItalic);
|
lf.lfItalic = get_bool(buffer);
|
||||||
|
|
||||||
sprintf(key, "%s.Underline", fontName);
|
sprintf(key, "%s.Underline", fontName);
|
||||||
count = sizeof(buffer);
|
count = sizeof(buffer);
|
||||||
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
||||||
font->logfont.lfUnderline = get_bool(buffer, defUnderline);
|
lf.lfUnderline = get_bool(buffer);
|
||||||
|
|
||||||
sprintf(key, "%s.StrikeOut", fontName);
|
sprintf(key, "%s.StrikeOut", fontName);
|
||||||
count = sizeof(buffer);
|
count = sizeof(buffer);
|
||||||
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
|
||||||
font->logfont.lfStrikeOut = get_bool(buffer, defStrikeOut);
|
lf.lfStrikeOut = get_bool(buffer);
|
||||||
|
return CreateFontIndirectW( &lf );
|
||||||
RegCloseKey(hkey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_SEC(handle,text) \
|
#define TRACE_SEC(handle,text) \
|
||||||
TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
|
TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* GDI_Init
|
* GDI_Init
|
||||||
*
|
*
|
||||||
|
@ -282,30 +151,57 @@ static void ReadFontInformation(
|
||||||
*/
|
*/
|
||||||
BOOL GDI_Init(void)
|
BOOL GDI_Init(void)
|
||||||
{
|
{
|
||||||
HPALETTE16 hpalette;
|
|
||||||
HINSTANCE16 instance;
|
HINSTANCE16 instance;
|
||||||
|
HKEY hkey;
|
||||||
|
GDIOBJHDR *ptr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey))
|
||||||
|
hkey = 0;
|
||||||
|
|
||||||
/* create GDI heap */
|
/* create GDI heap */
|
||||||
if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
|
if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
|
||||||
GDI_HeapSel = instance | 7;
|
GDI_HeapSel = instance | 7;
|
||||||
|
|
||||||
/* TWEAK: Initialize font hints */
|
/* create stock objects */
|
||||||
ReadFontInformation("OEMFixed", &OEMFixedFont, 12, 0, 0, 0, 0);
|
stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
|
||||||
ReadFontInformation("AnsiFixed", &AnsiFixedFont, 12, 0, 0, 0, 0);
|
stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
|
||||||
ReadFontInformation("AnsiVar", &AnsiVarFont, 12, 0, 0, 0, 0);
|
stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
|
||||||
ReadFontInformation("System", &SystemFont, 16, 0, 0, 0, 0);
|
stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
|
||||||
ReadFontInformation("DeviceDefault", &DeviceDefaultFont, 16, 0, 0, 0, 0);
|
stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
|
||||||
ReadFontInformation("SystemFixed", &SystemFixedFont, 16, 0, 0, 0, 0);
|
stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
|
||||||
ReadFontInformation("DefaultGui", &DefaultGuiFont, -11, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
/* Create default palette */
|
stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
|
||||||
|
stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
|
||||||
|
stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
|
||||||
|
|
||||||
/* DR well *this* palette can't be moveable (?) */
|
stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
|
||||||
hpalette = PALETTE_Init();
|
stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
|
||||||
if( !hpalette ) return FALSE;
|
|
||||||
StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hpalette );
|
|
||||||
|
|
||||||
hPseudoStockBitmap = CreateBitmap( 1, 1, 1, 1, NULL );
|
stock_objects[OEM_FIXED_FONT] = create_stock_font( "OEMFixed", &OEMFixedFont, hkey );
|
||||||
|
stock_objects[ANSI_FIXED_FONT] = create_stock_font( "AnsiFixed", &AnsiFixedFont, hkey );
|
||||||
|
stock_objects[ANSI_VAR_FONT] = create_stock_font( "AnsiVar", &AnsiVarFont, hkey );
|
||||||
|
stock_objects[SYSTEM_FONT] = create_stock_font( "System", &SystemFont, hkey );
|
||||||
|
stock_objects[DEVICE_DEFAULT_FONT] = create_stock_font( "DeviceDefault", &DeviceDefaultFont, hkey );
|
||||||
|
stock_objects[SYSTEM_FIXED_FONT] = create_stock_font( "SystemFixed", &SystemFixedFont, hkey );
|
||||||
|
stock_objects[DEFAULT_GUI_FONT] = create_stock_font( "DefaultGui", &DefaultGuiFont, hkey );
|
||||||
|
|
||||||
|
|
||||||
|
/* clear the NOSYSTEM bit on all stock objects*/
|
||||||
|
for (i = 0; i < NB_STOCK_OBJECTS; i++)
|
||||||
|
{
|
||||||
|
if (!stock_objects[i])
|
||||||
|
{
|
||||||
|
if (i == 9) continue; /* there's no stock object 9 */
|
||||||
|
ERR( "could not create stock object %d\n", i );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ptr = GDI_GetObjPtr( stock_objects[i], MAGIC_DONTCARE );
|
||||||
|
ptr->wMagic &= ~OBJECT_NOSYSTEM;
|
||||||
|
GDI_ReleaseObj( stock_objects[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hkey) RegCloseKey( hkey );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,23 +311,19 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
|
||||||
{
|
{
|
||||||
GDIOBJHDR *object = ptr;
|
GDIOBJHDR *object = ptr;
|
||||||
|
|
||||||
/* can't free stock objects */
|
object->wMagic = 0; /* Mark it as invalid */
|
||||||
if (handle < FIRST_STOCK_HANDLE)
|
if (handle & 2) /* GDI heap handle */
|
||||||
{
|
{
|
||||||
object->wMagic = 0; /* Mark it as invalid */
|
LOCAL_Unlock( GDI_HeapSel, handle );
|
||||||
if (handle & 2) /* GDI heap handle */
|
LOCAL_Free( GDI_HeapSel, handle );
|
||||||
|
}
|
||||||
|
else /* large heap handle */
|
||||||
|
{
|
||||||
|
int i = (handle >> 2) - FIRST_LARGE_HANDLE;
|
||||||
|
if (i >= 0 && large_handles[i])
|
||||||
{
|
{
|
||||||
LOCAL_Unlock( GDI_HeapSel, handle );
|
HeapFree( GetProcessHeap(), 0, large_handles[i] );
|
||||||
LOCAL_Free( GDI_HeapSel, handle );
|
large_handles[i] = NULL;
|
||||||
}
|
|
||||||
else /* large heap handle */
|
|
||||||
{
|
|
||||||
int i = (handle >> 2) - FIRST_LARGE_HANDLE;
|
|
||||||
if (i >= 0 && large_handles[i])
|
|
||||||
{
|
|
||||||
HeapFree( GetProcessHeap(), 0, large_handles[i] );
|
|
||||||
large_handles[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE_SEC( handle, "leave" );
|
TRACE_SEC( handle, "leave" );
|
||||||
|
@ -453,17 +345,10 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
|
||||||
|
|
||||||
_EnterSysLevel( &GDI_level );
|
_EnterSysLevel( &GDI_level );
|
||||||
|
|
||||||
if (handle >= FIRST_STOCK_HANDLE)
|
if (handle & 2) /* GDI heap handle */
|
||||||
{
|
|
||||||
if (handle <= LAST_STOCK_HANDLE) ptr = StockObjects[handle - FIRST_STOCK_HANDLE];
|
|
||||||
if (ptr && (magic != MAGIC_DONTCARE)
|
|
||||||
&& (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
|
|
||||||
}
|
|
||||||
else if (handle & 2) /* GDI heap handle */
|
|
||||||
{
|
{
|
||||||
ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle );
|
ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle );
|
||||||
if (ptr &&
|
if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic))
|
||||||
(magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic))
|
|
||||||
{
|
{
|
||||||
LOCAL_Unlock( GDI_HeapSel, handle );
|
LOCAL_Unlock( GDI_HeapSel, handle );
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
|
@ -496,7 +381,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
|
||||||
*/
|
*/
|
||||||
void GDI_ReleaseObj( HGDIOBJ handle )
|
void GDI_ReleaseObj( HGDIOBJ handle )
|
||||||
{
|
{
|
||||||
if (handle < FIRST_STOCK_HANDLE && (handle & 2)) LOCAL_Unlock( GDI_HeapSel, handle );
|
if (handle & 2) LOCAL_Unlock( GDI_HeapSel, handle );
|
||||||
TRACE_SEC( handle, "leave" );
|
TRACE_SEC( handle, "leave" );
|
||||||
_LeaveSysLevel( &GDI_level );
|
_LeaveSysLevel( &GDI_level );
|
||||||
}
|
}
|
||||||
|
@ -530,12 +415,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
|
||||||
|
|
||||||
GDIOBJHDR * header;
|
GDIOBJHDR * header;
|
||||||
if (HIWORD(obj)) return FALSE;
|
if (HIWORD(obj)) return FALSE;
|
||||||
if ((obj >= FIRST_STOCK_HANDLE) && (obj <= LAST_STOCK_HANDLE)) {
|
|
||||||
TRACE("Preserving Stock object %04x\n", obj );
|
|
||||||
/* NOTE: No GDI_Release is necessary */
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (obj == hPseudoStockBitmap) return TRUE;
|
|
||||||
if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
|
if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
|
||||||
|
|
||||||
if (!(header->wMagic & OBJECT_NOSYSTEM)
|
if (!(header->wMagic & OBJECT_NOSYSTEM)
|
||||||
|
@ -587,8 +467,7 @@ HGDIOBJ WINAPI GetStockObject( INT obj )
|
||||||
{
|
{
|
||||||
HGDIOBJ ret;
|
HGDIOBJ ret;
|
||||||
if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
|
if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
|
||||||
if (!StockObjects[obj]) return 0;
|
ret = stock_objects[obj];
|
||||||
ret = (HGDIOBJ16)(FIRST_STOCK_HANDLE + obj);
|
|
||||||
TRACE("returning %4x\n", ret );
|
TRACE("returning %4x\n", ret );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,6 @@ static COLORREF SysColors[NUM_SYS_COLORS];
|
||||||
static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
|
static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
|
||||||
static HPEN SysColorPens[NUM_SYS_COLORS];
|
static HPEN SysColorPens[NUM_SYS_COLORS];
|
||||||
|
|
||||||
#define MAKE_SOLID(color) \
|
|
||||||
(PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* SYSCOLOR_MakeObjectSystem
|
* SYSCOLOR_MakeObjectSystem
|
||||||
|
|
Loading…
Reference in New Issue