Commit 0dd55c44 authored by Alexandre Julliard's avatar Alexandre Julliard

Removed some direct accesses to GDI internal pen/brush/font

structures.
parent 231162ef
...@@ -5,10 +5,7 @@ ...@@ -5,10 +5,7 @@
*/ */
#include "bitmap.h" #include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "gdi.h" #include "gdi.h"
#include "pen.h"
#include "ttydrv.h" #include "ttydrv.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -23,11 +20,11 @@ extern BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap); ...@@ -23,11 +20,11 @@ extern BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap);
/*********************************************************************** /***********************************************************************
* TTYDRV_DC_BRUSH_SelectObject * TTYDRV_DC_BRUSH_SelectObject
*/ */
static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brush) static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush)
{ {
HBRUSH hPreviousBrush; HBRUSH hPreviousBrush;
TRACE("(%p, 0x%04x, %p)\n", dc, hbrush, brush); TRACE("(%p, 0x%04x)\n", dc, hbrush);
hPreviousBrush = dc->hBrush; hPreviousBrush = dc->hBrush;
dc->hBrush = hbrush; dc->hBrush = hbrush;
...@@ -38,11 +35,11 @@ static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brus ...@@ -38,11 +35,11 @@ static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush, BRUSHOBJ *brus
/*********************************************************************** /***********************************************************************
* TTYDRV_DC_FONT_SelectObject * TTYDRV_DC_FONT_SelectObject
*/ */
static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font) static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont)
{ {
HFONT hPreviousFont; HFONT hPreviousFont;
TRACE("(%p, 0x%04x, %p)\n", dc, hfont, font); TRACE("(%p, 0x%04x)\n", dc, hfont);
hPreviousFont = dc->hFont; hPreviousFont = dc->hFont;
dc->hFont = hfont; dc->hFont = hfont;
...@@ -53,11 +50,11 @@ static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font) ...@@ -53,11 +50,11 @@ static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont, FONTOBJ *font)
/*********************************************************************** /***********************************************************************
* TTYDRV_DC_PEN_SelectObject * TTYDRV_DC_PEN_SelectObject
*/ */
static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen, PENOBJ *pen) static HPEN TTYDRV_DC_PEN_SelectObject(DC *dc, HBRUSH hpen)
{ {
HPEN hPreviousPen; HPEN hPreviousPen;
TRACE("(%p, 0x%04x, %p)\n", dc, hpen, pen); TRACE("(%p, 0x%04x)\n", dc, hpen);
hPreviousPen = dc->hPen; hPreviousPen = dc->hPen;
dc->hPen = hpen; dc->hPen = hpen;
...@@ -81,13 +78,13 @@ HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle) ...@@ -81,13 +78,13 @@ HGDIOBJ TTYDRV_DC_SelectObject(DC *dc, HGDIOBJ handle)
result = TTYDRV_DC_BITMAP_SelectObject(dc, handle, (BITMAPOBJ *) ptr); result = TTYDRV_DC_BITMAP_SelectObject(dc, handle, (BITMAPOBJ *) ptr);
break; break;
case BRUSH_MAGIC: case BRUSH_MAGIC:
result = TTYDRV_DC_BRUSH_SelectObject(dc, handle, (BRUSHOBJ *) ptr); result = TTYDRV_DC_BRUSH_SelectObject(dc, handle);
break; break;
case FONT_MAGIC: case FONT_MAGIC:
result = TTYDRV_DC_FONT_SelectObject(dc, handle, (FONTOBJ *) ptr); result = TTYDRV_DC_FONT_SelectObject(dc, handle);
break; break;
case PEN_MAGIC: case PEN_MAGIC:
result = TTYDRV_DC_PEN_SelectObject(dc, handle, (PENOBJ *) ptr); result = TTYDRV_DC_PEN_SelectObject(dc, handle);
break; break;
case REGION_MAGIC: case REGION_MAGIC:
/* FIXME: Shouldn't be handled here */ /* FIXME: Shouldn't be handled here */
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
*/ */
#include "psdrv.h" #include "psdrv.h"
#include "brush.h"
#include "debugtools.h" #include "debugtools.h"
#include "gdi.h"
#include "winbase.h" #include "winbase.h"
DEFAULT_DEBUG_CHANNEL(psdrv); DEFAULT_DEBUG_CHANNEL(psdrv);
...@@ -16,35 +14,36 @@ DEFAULT_DEBUG_CHANNEL(psdrv); ...@@ -16,35 +14,36 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/*********************************************************************** /***********************************************************************
* PSDRV_BRUSH_SelectObject * PSDRV_BRUSH_SelectObject
*/ */
HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
{ {
LOGBRUSH logbrush;
HBRUSH prevbrush = dc->hBrush; HBRUSH prevbrush = dc->hBrush;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;
TRACE("hbrush = %08x\n", hbrush); TRACE("hbrush = %08x\n", hbrush);
dc->hBrush = hbrush; dc->hBrush = hbrush;
switch(brush->logbrush.lbStyle) { switch(logbrush.lbStyle) {
case BS_SOLID: case BS_SOLID:
PSDRV_CreateColor(physDev, &physDev->brush.color, PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
brush->logbrush.lbColor);
break; break;
case BS_NULL: case BS_NULL:
break; break;
case BS_HATCHED: case BS_HATCHED:
PSDRV_CreateColor(physDev, &physDev->brush.color, PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
brush->logbrush.lbColor);
break; break;
case BS_PATTERN: case BS_PATTERN:
FIXME("Unsupported brush style %d\n", brush->logbrush.lbStyle); FIXME("Unsupported brush style %d\n", logbrush.lbStyle);
break; break;
default: default:
FIXME("Unrecognized brush style %d\n", brush->logbrush.lbStyle); FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
break; break;
} }
...@@ -60,16 +59,17 @@ HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) ...@@ -60,16 +59,17 @@ HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, BRUSHOBJ * brush )
*/ */
static BOOL PSDRV_SetBrush(DC *dc) static BOOL PSDRV_SetBrush(DC *dc)
{ {
LOGBRUSH logbrush;
BOOL ret = TRUE; BOOL ret = TRUE;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->hBrush, BRUSH_MAGIC );
if(!brush) { if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n"); ERR("Can't get BRUSHOBJ\n");
return FALSE; return FALSE;
} }
switch (brush->logbrush.lbStyle) { switch (logbrush.lbStyle) {
case BS_SOLID: case BS_SOLID:
case BS_HATCHED: case BS_HATCHED:
PSDRV_WriteSetColor(dc, &physDev->brush.color); PSDRV_WriteSetColor(dc, &physDev->brush.color);
...@@ -84,7 +84,6 @@ static BOOL PSDRV_SetBrush(DC *dc) ...@@ -84,7 +84,6 @@ static BOOL PSDRV_SetBrush(DC *dc)
} }
physDev->brush.set = TRUE; physDev->brush.set = TRUE;
GDI_ReleaseObj( dc->hBrush );
return TRUE; return TRUE;
} }
...@@ -123,16 +122,17 @@ static BOOL PSDRV_Clip(DC *dc, BOOL EO) ...@@ -123,16 +122,17 @@ static BOOL PSDRV_Clip(DC *dc, BOOL EO)
*/ */
BOOL PSDRV_Brush(DC *dc, BOOL EO) BOOL PSDRV_Brush(DC *dc, BOOL EO)
{ {
LOGBRUSH logbrush;
BOOL ret = TRUE; BOOL ret = TRUE;
BRUSHOBJ *brush = (BRUSHOBJ *)GDI_GetObjPtr( dc->hBrush, BRUSH_MAGIC );
PSDRV_PDEVICE *physDev = dc->physDev; PSDRV_PDEVICE *physDev = dc->physDev;
if(!brush) { if (!GetObjectA( dc->hBrush, sizeof(logbrush), &logbrush ))
{
ERR("Can't get BRUSHOBJ\n"); ERR("Can't get BRUSHOBJ\n");
return FALSE; return FALSE;
} }
switch (brush->logbrush.lbStyle) { switch (logbrush.lbStyle) {
case BS_SOLID: case BS_SOLID:
PSDRV_SetBrush(dc); PSDRV_SetBrush(dc);
PSDRV_WriteGSave(dc); PSDRV_WriteGSave(dc);
...@@ -143,7 +143,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO) ...@@ -143,7 +143,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
case BS_HATCHED: case BS_HATCHED:
PSDRV_SetBrush(dc); PSDRV_SetBrush(dc);
switch(brush->logbrush.lbHatch) { switch(logbrush.lbHatch) {
case HS_VERTICAL: case HS_VERTICAL:
case HS_CROSS: case HS_CROSS:
PSDRV_WriteGSave(dc); PSDRV_WriteGSave(dc);
...@@ -151,7 +151,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO) ...@@ -151,7 +151,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteHatch(dc); PSDRV_WriteHatch(dc);
PSDRV_WriteStroke(dc); PSDRV_WriteStroke(dc);
PSDRV_WriteGRestore(dc); PSDRV_WriteGRestore(dc);
if(brush->logbrush.lbHatch == HS_VERTICAL) if(logbrush.lbHatch == HS_VERTICAL)
break; break;
/* else fallthrough for HS_CROSS */ /* else fallthrough for HS_CROSS */
...@@ -172,7 +172,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO) ...@@ -172,7 +172,7 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
PSDRV_WriteHatch(dc); PSDRV_WriteHatch(dc);
PSDRV_WriteStroke(dc); PSDRV_WriteStroke(dc);
PSDRV_WriteGRestore(dc); PSDRV_WriteGRestore(dc);
if(brush->logbrush.lbHatch == HS_FDIAGONAL) if(logbrush.lbHatch == HS_FDIAGONAL)
break; break;
/* else fallthrough for HS_DIAGCROSS */ /* else fallthrough for HS_DIAGCROSS */
...@@ -199,12 +199,11 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO) ...@@ -199,12 +199,11 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
{ {
BITMAP bm; BITMAP bm;
BYTE *bits; BYTE *bits;
GetObjectA(brush->logbrush.lbHatch, sizeof(BITMAP), &bm); GetObjectA(logbrush.lbHatch, sizeof(BITMAP), &bm);
TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight, TRACE("BS_PATTERN %dx%d %d bpp\n", bm.bmWidth, bm.bmHeight,
bm.bmBitsPixel); bm.bmBitsPixel);
bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight); bits = HeapAlloc(PSDRV_Heap, 0, bm.bmWidthBytes * bm.bmHeight);
GetBitmapBits(brush->logbrush.lbHatch, GetBitmapBits(logbrush.lbHatch, bm.bmWidthBytes * bm.bmHeight, bits);
bm.bmWidthBytes * bm.bmHeight, bits);
if(physDev->pi->ppd->LanguageLevel > 1) { if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dc); PSDRV_WriteGSave(dc);
...@@ -223,8 +222,6 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO) ...@@ -223,8 +222,6 @@ BOOL PSDRV_Brush(DC *dc, BOOL EO)
ret = FALSE; ret = FALSE;
break; break;
} }
GDI_ReleaseObj( dc->hBrush );
return ret; return ret;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "winspool.h" #include "winspool.h"
#include "psdrv.h" #include "psdrv.h"
#include "debugtools.h" #include "debugtools.h"
#include "gdi.h"
#include "winerror.h" #include "winerror.h"
DEFAULT_DEBUG_CHANNEL(psdrv); DEFAULT_DEBUG_CHANNEL(psdrv);
...@@ -18,34 +17,34 @@ DEFAULT_DEBUG_CHANNEL(psdrv); ...@@ -18,34 +17,34 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/*********************************************************************** /***********************************************************************
* PSDRV_FONT_SelectObject * PSDRV_FONT_SelectObject
*/ */
HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, HFONT PSDRV_FONT_SelectObject( DC * dc, HFONT hfont )
FONTOBJ *font )
{ {
LOGFONTW lf;
HFONT16 prevfont = dc->hFont; HFONT16 prevfont = dc->hFont;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
LOGFONTW *lf = &(font->logfont);
BOOL bd = FALSE, it = FALSE; BOOL bd = FALSE, it = FALSE;
AFMLISTENTRY *afmle; AFMLISTENTRY *afmle;
AFM *afm; AFM *afm;
FONTFAMILY *family; FONTFAMILY *family;
char FaceName[LF_FACESIZE]; char FaceName[LF_FACESIZE];
if (!GetObjectW( hfont, sizeof(lf), &lf )) return 0;
TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n", TRACE("FaceName = %s Height = %ld Italic = %d Weight = %ld\n",
debugstr_w(lf->lfFaceName), lf->lfHeight, lf->lfItalic, debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
lf->lfWeight); lf.lfWeight);
dc->hFont = hfont; dc->hFont = hfont;
if(lf->lfItalic) if(lf.lfItalic)
it = TRUE; it = TRUE;
if(lf->lfWeight > 550) if(lf.lfWeight > 550)
bd = TRUE; bd = TRUE;
WideCharToMultiByte(CP_ACP, 0, lf->lfFaceName, -1, WideCharToMultiByte(CP_ACP, 0, lf.lfFaceName, -1,
FaceName, sizeof(FaceName), NULL, NULL); FaceName, sizeof(FaceName), NULL, NULL);
if(FaceName[0] == '\0') { if(FaceName[0] == '\0') {
switch(lf->lfPitchAndFamily & 0xf0) { switch(lf.lfPitchAndFamily & 0xf0) {
case FF_DONTCARE: case FF_DONTCARE:
break; break;
case FF_ROMAN: case FF_ROMAN:
...@@ -65,7 +64,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, ...@@ -65,7 +64,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
} }
if(FaceName[0] == '\0') { if(FaceName[0] == '\0') {
switch(lf->lfPitchAndFamily & 0x0f) { switch(lf.lfPitchAndFamily & 0x0f) {
case VARIABLE_PITCH: case VARIABLE_PITCH:
strcpy(FaceName, "Times"); strcpy(FaceName, "Times");
break; break;
...@@ -138,7 +137,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, ...@@ -138,7 +137,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
afm = afmle->afm; afm = afmle->afm;
physDev->font.afm = afm; physDev->font.afm = afm;
physDev->font.tm.tmHeight = INTERNAL_YWSTODS(dc, lf->lfHeight); physDev->font.tm.tmHeight = INTERNAL_YWSTODS(dc, lf.lfHeight);
if(physDev->font.tm.tmHeight < 0) { if(physDev->font.tm.tmHeight < 0) {
physDev->font.tm.tmHeight *= - (afm->FullAscender - afm->Descender) / physDev->font.tm.tmHeight *= - (afm->FullAscender - afm->Descender) /
(afm->Ascender - afm->Descender); (afm->Ascender - afm->Descender);
...@@ -147,7 +146,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, ...@@ -147,7 +146,7 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
physDev->font.size = physDev->font.tm.tmHeight * 1000.0 / physDev->font.size = physDev->font.tm.tmHeight * 1000.0 /
(afm->FullAscender - afm->Descender); (afm->FullAscender - afm->Descender);
physDev->font.scale = physDev->font.size / 1000.0; physDev->font.scale = physDev->font.size / 1000.0;
physDev->font.escapement = lf->lfEscapement; physDev->font.escapement = lf.lfEscapement;
physDev->font.tm.tmAscent = afm->FullAscender * physDev->font.scale; physDev->font.tm.tmAscent = afm->FullAscender * physDev->font.scale;
physDev->font.tm.tmDescent = -afm->Descender * physDev->font.scale; physDev->font.tm.tmDescent = -afm->Descender * physDev->font.scale;
physDev->font.tm.tmInternalLeading = (afm->FullAscender - afm->Ascender) physDev->font.tm.tmInternalLeading = (afm->FullAscender - afm->Ascender)
...@@ -160,8 +159,8 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, ...@@ -160,8 +159,8 @@ HFONT16 PSDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
physDev->font.scale; physDev->font.scale;
physDev->font.tm.tmWeight = afm->Weight; physDev->font.tm.tmWeight = afm->Weight;
physDev->font.tm.tmItalic = afm->ItalicAngle != 0.0; physDev->font.tm.tmItalic = afm->ItalicAngle != 0.0;
physDev->font.tm.tmUnderlined = lf->lfUnderline; physDev->font.tm.tmUnderlined = lf.lfUnderline;
physDev->font.tm.tmStruckOut = lf->lfStrikeOut; physDev->font.tm.tmStruckOut = lf.lfStrikeOut;
physDev->font.tm.tmFirstChar = 32; physDev->font.tm.tmFirstChar = 32;
physDev->font.tm.tmLastChar = 251; physDev->font.tm.tmLastChar = 251;
physDev->font.tm.tmDefaultChar = 128; physDev->font.tm.tmDefaultChar = 128;
......
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
*/ */
#include "psdrv.h" #include "psdrv.h"
#include "font.h"
#include "pen.h"
#include "brush.h"
#include "bitmap.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(psdrv); DEFAULT_DEBUG_CHANNEL(psdrv);
...@@ -17,8 +13,7 @@ DEFAULT_DEBUG_CHANNEL(psdrv); ...@@ -17,8 +13,7 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
/*********************************************************************** /***********************************************************************
* PSDRV_BITMAP_SelectObject * PSDRV_BITMAP_SelectObject
*/ */
static HBITMAP16 PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap, static HBITMAP PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
BITMAPOBJ * bmp )
{ {
FIXME("stub\n"); FIXME("stub\n");
return 0; return 0;
...@@ -30,33 +25,32 @@ static HBITMAP16 PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap, ...@@ -30,33 +25,32 @@ static HBITMAP16 PSDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
*/ */
HGDIOBJ PSDRV_SelectObject( DC *dc, HGDIOBJ handle ) HGDIOBJ PSDRV_SelectObject( DC *dc, HGDIOBJ handle )
{ {
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0; HGDIOBJ ret = 0;
if (!ptr) return 0;
TRACE("hdc=%04x %04x\n", dc->hSelf, handle ); TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic)) switch(GetObjectType( handle ))
{ {
case PEN_MAGIC: case OBJ_PEN:
ret = PSDRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr ); ret = PSDRV_PEN_SelectObject( dc, handle );
break; break;
case BRUSH_MAGIC: case OBJ_BRUSH:
ret = PSDRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr ); ret = PSDRV_BRUSH_SelectObject( dc, handle );
break; break;
case BITMAP_MAGIC: case OBJ_BITMAP:
ret = PSDRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr ); ret = PSDRV_BITMAP_SelectObject( dc, handle );
break; break;
case FONT_MAGIC: case OBJ_FONT:
ret = PSDRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr ); ret = PSDRV_FONT_SelectObject( dc, handle );
break; break;
case REGION_MAGIC: case OBJ_REGION:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle ); ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break; break;
case 0: /* invalid handle */
break;
default: default:
ERR("Unknown object magic %04x\n", GDIMAGIC(ptr->wMagic)); ERR("Unknown object type %ld\n", GetObjectType(handle) );
break; break;
} }
GDI_ReleaseObj( handle );
return ret; return ret;
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* *
*/ */
#include "pen.h"
#include "psdrv.h" #include "psdrv.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -20,20 +19,24 @@ static char PEN_alternate[] = "1"; ...@@ -20,20 +19,24 @@ static char PEN_alternate[] = "1";
/*********************************************************************** /***********************************************************************
* PSDRV_PEN_SelectObject * PSDRV_PEN_SelectObject
*/ */
extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ) HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen )
{ {
LOGPEN logpen;
HPEN prevpen = dc->hPen; HPEN prevpen = dc->hPen;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev; PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
TRACE("hpen = %08x colour = %08lx\n", hpen, pen->logpen.lopnColor); if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0;
TRACE("hpen = %08x colour = %08lx\n", hpen, logpen.lopnColor);
dc->hPen = hpen; dc->hPen = hpen;
physDev->pen.width = INTERNAL_XWSTODS(dc, pen->logpen.lopnWidth.x); physDev->pen.width = INTERNAL_XWSTODS(dc, logpen.lopnWidth.x);
if(physDev->pen.width < 0) if(physDev->pen.width < 0)
physDev->pen.width = -physDev->pen.width; physDev->pen.width = -physDev->pen.width;
PSDRV_CreateColor(physDev, &physDev->pen.color, pen->logpen.lopnColor); PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
physDev->pen.style = pen->logpen.lopnStyle & PS_STYLE_MASK; physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
switch(physDev->pen.style) { switch(physDev->pen.style) {
case PS_DASH: case PS_DASH:
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
*/ */
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "wingdi.h"
#include "font.h" #include "gdi.h"
#include "pen.h"
#include "brush.h"
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "winspool.h" #include "winspool.h"
...@@ -293,10 +291,9 @@ extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm); ...@@ -293,10 +291,9 @@ extern BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm);
extern void PSDRV_FreeAFMList( FONTFAMILY *head ); extern void PSDRV_FreeAFMList( FONTFAMILY *head );
extern BOOL WINAPI PSDRV_Init(HINSTANCE hinst, DWORD reason, LPVOID reserved); extern BOOL WINAPI PSDRV_Init(HINSTANCE hinst, DWORD reason, LPVOID reserved);
extern HFONT16 PSDRV_FONT_SelectObject( DC *dc, HFONT16 hfont, FONTOBJ *font); extern HFONT PSDRV_FONT_SelectObject( DC *dc, HFONT hfont );
extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ); extern HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen );
extern HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, extern HBRUSH PSDRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush );
BRUSHOBJ * brush );
extern BOOL PSDRV_Brush(DC *dc, BOOL EO); extern BOOL PSDRV_Brush(DC *dc, BOOL EO);
extern BOOL PSDRV_SetFont( DC *dc ); extern BOOL PSDRV_SetFont( DC *dc );
......
...@@ -9,10 +9,7 @@ ...@@ -9,10 +9,7 @@
#include <string.h> #include <string.h>
#include "bitmap.h" #include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "enhmetafiledrv.h" #include "enhmetafiledrv.h"
#include "pen.h"
#include "debugtools.h" #include "debugtools.h"
#include "heap.h" #include "heap.h"
...@@ -33,9 +30,11 @@ static HBITMAP EMFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap ) ...@@ -33,9 +30,11 @@ static HBITMAP EMFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush ) DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
{ {
DWORD index = 0; DWORD index = 0;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC ); LOGBRUSH logbrush;
switch (brushObj->logbrush.lbStyle) { if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return 0;
switch (logbrush.lbStyle) {
case BS_SOLID: case BS_SOLID:
case BS_HATCHED: case BS_HATCHED:
case BS_NULL: case BS_NULL:
...@@ -44,7 +43,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush ) ...@@ -44,7 +43,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
emr.emr.iType = EMR_CREATEBRUSHINDIRECT; emr.emr.iType = EMR_CREATEBRUSHINDIRECT;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
emr.ihBrush = index = EMFDRV_AddHandleDC( dc ); emr.ihBrush = index = EMFDRV_AddHandleDC( dc );
emr.lb = brushObj->logbrush; emr.lb = logbrush;
if(!EMFDRV_WriteRecord( dc, &emr.emr )) if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0; index = 0;
...@@ -54,7 +53,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush ) ...@@ -54,7 +53,7 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
{ {
EMRCREATEDIBPATTERNBRUSHPT *emr; EMRCREATEDIBPATTERNBRUSHPT *emr;
DWORD bmSize, biSize, size; DWORD bmSize, biSize, size;
BITMAPINFO *info = GlobalLock16(brushObj->logbrush.lbHatch); BITMAPINFO *info = GlobalLock16(logbrush.lbHatch);
if (info->bmiHeader.biCompression) if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage; bmSize = info->bmiHeader.biSizeImage;
...@@ -62,14 +61,14 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush ) ...@@ -62,14 +61,14 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth, bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
info->bmiHeader.biHeight, info->bmiHeader.biHeight,
info->bmiHeader.biBitCount); info->bmiHeader.biBitCount);
biSize = DIB_BitmapInfoSize(info, LOWORD(brushObj->logbrush.lbColor)); biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush.lbColor));
size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize; size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize;
emr = HeapAlloc( GetProcessHeap(), 0, size ); emr = HeapAlloc( GetProcessHeap(), 0, size );
if(!emr) break; if(!emr) break;
emr->emr.iType = EMR_CREATEDIBPATTERNBRUSHPT; emr->emr.iType = EMR_CREATEDIBPATTERNBRUSHPT;
emr->emr.nSize = size; emr->emr.nSize = size;
emr->ihBrush = index = EMFDRV_AddHandleDC( dc ); emr->ihBrush = index = EMFDRV_AddHandleDC( dc );
emr->iUsage = LOWORD(brushObj->logbrush.lbColor); emr->iUsage = LOWORD(logbrush.lbColor);
emr->offBmi = sizeof(EMRCREATEDIBPATTERNBRUSHPT); emr->offBmi = sizeof(EMRCREATEDIBPATTERNBRUSHPT);
emr->cbBmi = biSize; emr->cbBmi = biSize;
emr->offBits = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize; emr->offBits = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize;
...@@ -79,19 +78,18 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush ) ...@@ -79,19 +78,18 @@ DWORD EMFDRV_CreateBrushIndirect( DC *dc, HBRUSH hBrush )
if(!EMFDRV_WriteRecord( dc, &emr->emr )) if(!EMFDRV_WriteRecord( dc, &emr->emr ))
index = 0; index = 0;
HeapFree( GetProcessHeap(), 0, emr ); HeapFree( GetProcessHeap(), 0, emr );
GlobalUnlock16(brushObj->logbrush.lbHatch); GlobalUnlock16(logbrush.lbHatch);
} }
break; break;
case BS_PATTERN: case BS_PATTERN:
FIXME("Unsupported style %x\n", FIXME("Unsupported style %x\n",
brushObj->logbrush.lbStyle); logbrush.lbStyle);
break; break;
default: default:
FIXME("Unknown style %x\n", brushObj->logbrush.lbStyle); FIXME("Unknown style %x\n", logbrush.lbStyle);
break; break;
} }
GDI_ReleaseObj( hBrush );
return index; return index;
} }
...@@ -141,13 +139,14 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush ) ...@@ -141,13 +139,14 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont ) static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
{ {
DWORD index = 0; DWORD index = 0;
FONTOBJ *fontObj = (FONTOBJ *)GDI_GetObjPtr( hFont, FONT_MAGIC );
EMREXTCREATEFONTINDIRECTW emr; EMREXTCREATEFONTINDIRECTW emr;
int i; int i;
if (!GetObjectW( hFont, sizeof(emr.elfw.elfLogFont), &emr.elfw.elfLogFont )) return 0;
emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW; emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW;
emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4; emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4;
emr.ihFont = index = EMFDRV_AddHandleDC( dc ); emr.ihFont = index = EMFDRV_AddHandleDC( dc );
memcpy( &(emr.elfw.elfLogFont), &(fontObj->logfont), sizeof(LOGFONTW) );
emr.elfw.elfFullName[0] = '\0'; emr.elfw.elfFullName[0] = '\0';
emr.elfw.elfStyle[0] = '\0'; emr.elfw.elfStyle[0] = '\0';
emr.elfw.elfVersion = 0; emr.elfw.elfVersion = 0;
...@@ -170,7 +169,6 @@ static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont ) ...@@ -170,7 +169,6 @@ static BOOL EMFDRV_CreateFontIndirect(DC *dc, HFONT hFont )
if(!EMFDRV_WriteRecord( dc, &emr.emr )) if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0; index = 0;
GDI_ReleaseObj( hFont );
return index; return index;
} }
...@@ -223,17 +221,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont ) ...@@ -223,17 +221,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen ) static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen )
{ {
EMRCREATEPEN emr; EMRCREATEPEN emr;
PENOBJ *penObj = (PENOBJ *)GDI_GetObjPtr( hPen, PEN_MAGIC );
DWORD index = 0; DWORD index = 0;
if (!GetObjectA( hPen, sizeof(emr.lopn), &emr.lopn )) return 0;
emr.emr.iType = EMR_CREATEPEN; emr.emr.iType = EMR_CREATEPEN;
emr.emr.nSize = sizeof(emr); emr.emr.nSize = sizeof(emr);
emr.ihPen = index = EMFDRV_AddHandleDC( dc ); emr.ihPen = index = EMFDRV_AddHandleDC( dc );
emr.lopn = penObj->logpen;
if(!EMFDRV_WriteRecord( dc, &emr.emr )) if(!EMFDRV_WriteRecord( dc, &emr.emr ))
index = 0; index = 0;
GDI_ReleaseObj( hPen );
return index; return index;
} }
......
...@@ -9,21 +9,18 @@ ...@@ -9,21 +9,18 @@
#include <string.h> #include <string.h>
#include "bitmap.h" #include "bitmap.h"
#include "brush.h"
#include "font.h" #include "font.h"
#include "metafiledrv.h" #include "metafiledrv.h"
#include "pen.h"
#include "debugtools.h" #include "debugtools.h"
#include "heap.h" #include "heap.h"
DEFAULT_DEBUG_CHANNEL(metafile); DEFAULT_DEBUG_CHANNEL(metafile);
DECLARE_DEBUG_CHANNEL(gdi);
/*********************************************************************** /***********************************************************************
* MFDRV_BITMAP_SelectObject * MFDRV_BITMAP_SelectObject
*/ */
static HBITMAP16 MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap, static HBITMAP MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap )
BITMAPOBJ * bmp )
{ {
return 0; return 0;
} }
...@@ -38,19 +35,21 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush ) ...@@ -38,19 +35,21 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
INT16 index = -1; INT16 index = -1;
DWORD size; DWORD size;
METARECORD *mr; METARECORD *mr;
BRUSHOBJ *brushObj = (BRUSHOBJ *)GDI_GetObjPtr( hBrush, BRUSH_MAGIC ); LOGBRUSH logbrush;
if(!brushObj) return -1;
if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return -1;
switch(brushObj->logbrush.lbStyle) {
switch(logbrush.lbStyle)
{
case BS_SOLID: case BS_SOLID:
case BS_NULL: case BS_NULL:
case BS_HATCHED: case BS_HATCHED:
{ {
LOGBRUSH16 lb16; LOGBRUSH16 lb16;
lb16.lbStyle = brushObj->logbrush.lbStyle; lb16.lbStyle = logbrush.lbStyle;
lb16.lbColor = brushObj->logbrush.lbColor; lb16.lbColor = logbrush.lbColor;
lb16.lbHatch = brushObj->logbrush.lbHatch; lb16.lbHatch = logbrush.lbHatch;
size = sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2; size = sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2;
mr = HeapAlloc( GetProcessHeap(), 0, size ); mr = HeapAlloc( GetProcessHeap(), 0, size );
mr->rdSize = size / 2; mr->rdSize = size / 2;
...@@ -65,7 +64,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush ) ...@@ -65,7 +64,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
BITMAPINFO *info; BITMAPINFO *info;
DWORD bmSize; DWORD bmSize;
GetObjectA(brushObj->logbrush.lbHatch, sizeof(bm), &bm); GetObjectA(logbrush.lbHatch, sizeof(bm), &bm);
if(bm.bmBitsPixel != 1 || bm.bmPlanes != 1) { if(bm.bmBitsPixel != 1 || bm.bmPlanes != 1) {
FIXME("Trying to store a colour pattern brush\n"); FIXME("Trying to store a colour pattern brush\n");
goto done; goto done;
...@@ -91,7 +90,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush ) ...@@ -91,7 +90,7 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
info->bmiHeader.biBitCount = 1; info->bmiHeader.biBitCount = 1;
bits = ((BYTE *)info) + sizeof(BITMAPINFO) + sizeof(RGBQUAD); bits = ((BYTE *)info) + sizeof(BITMAPINFO) + sizeof(RGBQUAD);
GetDIBits(dc->hSelf, brushObj->logbrush.lbHatch, 0, bm.bmHeight, GetDIBits(dc->hSelf, logbrush.lbHatch, 0, bm.bmHeight,
bits, info, DIB_RGB_COLORS); bits, info, DIB_RGB_COLORS);
*(DWORD *)info->bmiColors = 0; *(DWORD *)info->bmiColors = 0;
*(DWORD *)(info->bmiColors + 1) = 0xffffff; *(DWORD *)(info->bmiColors + 1) = 0xffffff;
...@@ -103,27 +102,26 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush ) ...@@ -103,27 +102,26 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
BITMAPINFO *info; BITMAPINFO *info;
DWORD bmSize, biSize; DWORD bmSize, biSize;
info = GlobalLock16((HGLOBAL16)brushObj->logbrush.lbHatch); info = GlobalLock16((HGLOBAL16)logbrush.lbHatch);
if (info->bmiHeader.biCompression) if (info->bmiHeader.biCompression)
bmSize = info->bmiHeader.biSizeImage; bmSize = info->bmiHeader.biSizeImage;
else else
bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth, bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
info->bmiHeader.biHeight, info->bmiHeader.biHeight,
info->bmiHeader.biBitCount); info->bmiHeader.biBitCount);
biSize = DIB_BitmapInfoSize(info, biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush.lbColor));
LOWORD(brushObj->logbrush.lbColor));
size = sizeof(METARECORD) + biSize + bmSize + 2; size = sizeof(METARECORD) + biSize + bmSize + 2;
mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if(!mr) goto done; if(!mr) goto done;
mr->rdFunction = META_DIBCREATEPATTERNBRUSH; mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
mr->rdSize = size / 2; mr->rdSize = size / 2;
*(mr->rdParm) = brushObj->logbrush.lbStyle; *(mr->rdParm) = logbrush.lbStyle;
*(mr->rdParm + 1) = LOWORD(brushObj->logbrush.lbColor); *(mr->rdParm + 1) = LOWORD(logbrush.lbColor);
memcpy(mr->rdParm + 2, info, biSize + bmSize); memcpy(mr->rdParm + 2, info, biSize + bmSize);
break; break;
} }
default: default:
FIXME("Unkonwn brush style %x\n", brushObj->logbrush.lbStyle); FIXME("Unkonwn brush style %x\n", logbrush.lbStyle);
return -1; return -1;
} }
index = MFDRV_AddHandleDC( dc ); index = MFDRV_AddHandleDC( dc );
...@@ -131,7 +129,6 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush ) ...@@ -131,7 +129,6 @@ INT16 MFDRV_CreateBrushIndirect(DC *dc, HBRUSH hBrush )
index = -1; index = -1;
HeapFree(GetProcessHeap(), 0, mr); HeapFree(GetProcessHeap(), 0, mr);
done: done:
GDI_ReleaseObj( hBrush );
return index; return index;
} }
...@@ -139,8 +136,7 @@ done: ...@@ -139,8 +136,7 @@ done:
/*********************************************************************** /***********************************************************************
* MFDRV_BRUSH_SelectObject * MFDRV_BRUSH_SelectObject
*/ */
static HBRUSH MFDRV_BRUSH_SelectObject( DC *dc, HBRUSH hbrush, static HBRUSH MFDRV_BRUSH_SelectObject( DC *dc, HBRUSH hbrush )
BRUSHOBJ * brush )
{ {
INT16 index; INT16 index;
METARECORD mr; METARECORD mr;
...@@ -181,12 +177,12 @@ static BOOL MFDRV_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont) ...@@ -181,12 +177,12 @@ static BOOL MFDRV_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont)
/*********************************************************************** /***********************************************************************
* MFDRV_FONT_SelectObject * MFDRV_FONT_SelectObject
*/ */
static HFONT16 MFDRV_FONT_SelectObject( DC * dc, HFONT16 hfont, static HFONT MFDRV_FONT_SelectObject( DC * dc, HFONT hfont )
FONTOBJ * font )
{ {
HFONT16 prevHandle = dc->hFont; HFONT16 prevHandle = dc->hFont;
LOGFONT16 lf16; LOGFONT16 lf16;
FONT_LogFontWTo16(&(font->logfont), &lf16);
if (!GetObject16( hfont, sizeof(lf16), &lf16 )) return 0;
if (MFDRV_CreateFontIndirect(dc, hfont, &lf16)) if (MFDRV_CreateFontIndirect(dc, hfont, &lf16))
return prevHandle; return prevHandle;
return 0; return 0;
...@@ -218,18 +214,13 @@ static BOOL MFDRV_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen) ...@@ -218,18 +214,13 @@ static BOOL MFDRV_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen)
/*********************************************************************** /***********************************************************************
* MFDRV_PEN_SelectObject * MFDRV_PEN_SelectObject
*/ */
static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ) static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen )
{ {
LOGPEN16 logpen; LOGPEN16 logpen;
HPEN prevHandle = dc->hPen; HPEN prevHandle = dc->hPen;
logpen.lopnStyle = pen->logpen.lopnStyle; if (!GetObject16( hpen, sizeof(logpen), &logpen )) return 0;
logpen.lopnWidth.x = pen->logpen.lopnWidth.x;
logpen.lopnWidth.y = pen->logpen.lopnWidth.y;
logpen.lopnColor = pen->logpen.lopnColor;
if (MFDRV_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle; if (MFDRV_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
return 0; return 0;
} }
...@@ -239,32 +230,15 @@ static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ) ...@@ -239,32 +230,15 @@ static HPEN MFDRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
*/ */
HGDIOBJ MFDRV_SelectObject( DC *dc, HGDIOBJ handle ) HGDIOBJ MFDRV_SelectObject( DC *dc, HGDIOBJ handle )
{ {
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ); TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
HGDIOBJ ret = 0;
if (!ptr) return 0; switch(GetObjectType( handle ))
TRACE_(gdi)("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic))
{ {
case PEN_MAGIC: case OBJ_PEN: return MFDRV_PEN_SelectObject( dc, handle );
ret = MFDRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr ); case OBJ_BRUSH: return MFDRV_BRUSH_SelectObject( dc, handle );
break; case OBJ_BITMAP: return MFDRV_BITMAP_SelectObject( dc, handle );
case BRUSH_MAGIC: case OBJ_FONT: return MFDRV_FONT_SelectObject( dc, handle );
ret = MFDRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr ); case OBJ_REGION: return (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
case BITMAP_MAGIC:
ret = MFDRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
break;
case FONT_MAGIC:
ret = MFDRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
break;
case REGION_MAGIC:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
} }
GDI_ReleaseObj( handle ); return 0;
return ret;
} }
...@@ -5,26 +5,22 @@ ...@@ -5,26 +5,22 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "brush.h"
#include "win16drv.h" #include "win16drv.h"
#include "heap.h" #include "heap.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(win16drv); DEFAULT_DEBUG_CHANNEL(win16drv);
HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush, HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush )
BRUSHOBJ * brush )
{ {
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev; WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HBRUSH16 prevHandle = dc->hBrush; HBRUSH16 prevHandle = dc->hBrush;
int nSize; int nSize;
LOGBRUSH16 lBrush16; LOGBRUSH16 lBrush16;
dc->hBrush = hbrush;
lBrush16.lbStyle = brush->logbrush.lbStyle;
lBrush16.lbColor = brush->logbrush.lbColor;
lBrush16.lbHatch = brush->logbrush.lbHatch;
if (!GetObject16( hbrush, sizeof(lBrush16), &lBrush16 )) return 0;
dc->hBrush = hbrush;
if ( physDev->BrushInfo ) if ( physDev->BrushInfo )
{ {
TRACE("UnRealizing BrushInfo\n"); TRACE("UnRealizing BrushInfo\n");
......
...@@ -72,17 +72,18 @@ BOOL WIN16DRV_GetTextMetrics( DC *dc, TEXTMETRICW *metrics ) ...@@ -72,17 +72,18 @@ BOOL WIN16DRV_GetTextMetrics( DC *dc, TEXTMETRICW *metrics )
return TRUE; return TRUE;
} }
HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font) HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont)
{ {
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev; WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HPEN prevHandle = dc->hFont; HPEN prevHandle = dc->hFont;
int nSize; int nSize;
dc->hFont = hfont; if (!GetObject16( hfont, sizeof(physDev->lf), &physDev->lf )) return 0;
TRACE("WIN16DRV_FONT_SelectObject %s h=%ld\n", dc->hFont = hfont;
debugstr_w(font->logfont.lfFaceName), font->logfont.lfHeight);
TRACE("WIN16DRV_FONT_SelectObject %s h=%d\n",
debugstr_a(physDev->lf.lfFaceName), physDev->lf.lfHeight);
if( physDev->FontInfo ) if( physDev->FontInfo )
{ {
...@@ -92,7 +93,6 @@ HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font) ...@@ -92,7 +93,6 @@ HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font)
physDev->FontInfo, 0); physDev->FontInfo, 0);
} }
FONT_LogFontWTo16(&font->logfont, &physDev->lf);
nSize = PRTDRV_RealizeObject (physDev->segptrPDEVICE, DRVOBJ_FONT, nSize = PRTDRV_RealizeObject (physDev->segptrPDEVICE, DRVOBJ_FONT,
&physDev->lf, 0, 0); &physDev->lf, 0, 0);
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "bitmap.h"
#include "brush.h"
#include "font.h"
#include "pen.h"
#include "win16drv.h" #include "win16drv.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -20,45 +16,22 @@ ...@@ -20,45 +16,22 @@
DEFAULT_DEBUG_CHANNEL(gdi); DEFAULT_DEBUG_CHANNEL(gdi);
extern HBITMAP WIN16DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
BITMAPOBJ * bmp );
extern HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush,
BRUSHOBJ * brush );
extern HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont,
FONTOBJ * font );
extern HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen );
/*********************************************************************** /***********************************************************************
* WIN16DRV_SelectObject * WIN16DRV_SelectObject
*/ */
HGDIOBJ WIN16DRV_SelectObject( DC *dc, HGDIOBJ handle ) HGDIOBJ WIN16DRV_SelectObject( DC *dc, HGDIOBJ handle )
{ {
GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
HGDIOBJ ret = 0;
if (!ptr) return 0;
TRACE("hdc=%04x %04x\n", dc->hSelf, handle ); TRACE("hdc=%04x %04x\n", dc->hSelf, handle );
switch(GDIMAGIC(ptr->wMagic)) switch(GetObjectType( handle ))
{ {
case PEN_MAGIC: case OBJ_PEN: return WIN16DRV_PEN_SelectObject( dc, handle );
ret = WIN16DRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr ); case OBJ_BRUSH: return WIN16DRV_BRUSH_SelectObject( dc, handle );
break; case OBJ_FONT: return WIN16DRV_FONT_SelectObject( dc, handle );
case BRUSH_MAGIC: case OBJ_REGION: return (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
ret = WIN16DRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr ); case OBJ_BITMAP:
break; FIXME("BITMAP not implemented\n");
case BITMAP_MAGIC: return 1;
FIXME("WIN16DRV_SelectObject for BITMAP not implemented\n");
ret = 1;
break;
case FONT_MAGIC:
ret = WIN16DRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
break;
case REGION_MAGIC:
ret = (HGDIOBJ)SelectClipRgn( dc->hSelf, handle );
break;
} }
GDI_ReleaseObj( handle ); return 0;
return ret;
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
* Copyright 1997 John Harvey * Copyright 1997 John Harvey
*/ */
#include "pen.h"
#include "win16drv.h" #include "win16drv.h"
#include "heap.h" #include "heap.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -14,18 +13,16 @@ DEFAULT_DEBUG_CHANNEL(win16drv); ...@@ -14,18 +13,16 @@ DEFAULT_DEBUG_CHANNEL(win16drv);
/*********************************************************************** /***********************************************************************
* PEN_SelectObject * PEN_SelectObject
*/ */
HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ) HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen )
{ {
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev; WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HPEN prevHandle = dc->hPen; HPEN prevHandle = dc->hPen;
int nSize; int nSize;
LOGPEN16 lPen16; LOGPEN16 lPen16;
if (!GetObject16( hpen, sizeof(lPen16), &lPen16 )) return 0;
dc->hPen = hpen; dc->hPen = hpen;
TRACE("In WIN16DRV_PEN_SelectObject\n");
lPen16.lopnStyle = pen->logpen.lopnStyle;
lPen16.lopnWidth.x = pen->logpen.lopnWidth.x;
lPen16.lopnWidth.y = pen->logpen.lopnWidth.y;
lPen16.lopnColor = pen->logpen.lopnColor;
if ( physDev->PenInfo ) if ( physDev->PenInfo )
{ {
......
...@@ -236,6 +236,10 @@ extern DWORD WIN16DRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, ...@@ -236,6 +236,10 @@ extern DWORD WIN16DRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
LPCSTR lpszPort, WORD fwCapability, LPCSTR lpszPort, WORD fwCapability,
LPSTR lpszOutput, LPDEVMODEA lpdm); LPSTR lpszOutput, LPDEVMODEA lpdm);
extern HBRUSH WIN16DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush );
extern HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont );
extern HPEN WIN16DRV_PEN_SelectObject( DC * dc, HPEN hpen );
/* /*
* Wine 16bit driver global variables * Wine 16bit driver global variables
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment