1997-02-02 20:01:52 +01:00
|
|
|
/*
|
|
|
|
* GDI objects
|
|
|
|
*
|
|
|
|
* Copyright 1993 Alexandre Julliard
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "bitmap.h"
|
|
|
|
#include "brush.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "metafile.h"
|
|
|
|
#include "metafiledrv.h"
|
|
|
|
#include "pen.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_BITMAP_SelectObject
|
|
|
|
*/
|
|
|
|
static HBITMAP16 MFDRV_BITMAP_SelectObject( DC * dc, HBITMAP16 hbitmap,
|
|
|
|
BITMAPOBJ * bmp )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_BRUSH_SelectObject
|
|
|
|
*/
|
|
|
|
static HBRUSH32 MFDRV_BRUSH_SelectObject( DC * dc, HBRUSH32 hbrush,
|
|
|
|
BRUSHOBJ * brush )
|
|
|
|
{
|
|
|
|
LOGBRUSH16 logbrush = { brush->logbrush.lbStyle,
|
|
|
|
brush->logbrush.lbColor,
|
|
|
|
brush->logbrush.lbHatch };
|
|
|
|
switch (brush->logbrush.lbStyle)
|
|
|
|
{
|
|
|
|
case BS_SOLID:
|
|
|
|
case BS_HATCHED:
|
|
|
|
case BS_HOLLOW:
|
|
|
|
if (!MF_CreateBrushIndirect( dc, hbrush, &logbrush )) return 0;
|
|
|
|
break;
|
|
|
|
case BS_PATTERN:
|
|
|
|
case BS_DIBPATTERN:
|
|
|
|
if (!MF_CreatePatternBrush( dc, hbrush, &logbrush )) return 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1; /* FIXME? */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_FONT_SelectObject
|
|
|
|
*/
|
|
|
|
static HFONT16 MFDRV_FONT_SelectObject( DC * dc, HFONT16 hfont,
|
|
|
|
FONTOBJ * font )
|
|
|
|
{
|
|
|
|
HFONT16 prevHandle = dc->w.hFont;
|
|
|
|
if (MF_CreateFontIndirect(dc, hfont, &(font->logfont))) return prevHandle;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_PEN_SelectObject
|
|
|
|
*/
|
|
|
|
static HPEN32 MFDRV_PEN_SelectObject( DC * dc, HPEN32 hpen, PENOBJ * pen )
|
|
|
|
{
|
|
|
|
HPEN32 prevHandle = dc->w.hPen;
|
|
|
|
LOGPEN16 logpen = { pen->logpen.lopnStyle,
|
|
|
|
{ pen->logpen.lopnWidth.x, pen->logpen.lopnWidth.y },
|
|
|
|
pen->logpen.lopnColor };
|
|
|
|
if (MF_CreatePenIndirect( dc, hpen, &logpen )) return prevHandle;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MFDRV_SelectObject
|
|
|
|
*/
|
|
|
|
HGDIOBJ32 MFDRV_SelectObject( DC *dc, HGDIOBJ32 handle )
|
|
|
|
{
|
|
|
|
GDIOBJHDR * ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
|
1997-08-24 18:00:30 +02:00
|
|
|
HGDIOBJ32 ret = 0;
|
1997-02-02 20:01:52 +01:00
|
|
|
|
|
|
|
if (!ptr) return 0;
|
1998-03-15 21:29:56 +01:00
|
|
|
TRACE(gdi, "hdc=%04x %04x\n", dc->hSelf, handle );
|
1997-02-02 20:01:52 +01:00
|
|
|
|
|
|
|
switch(ptr->wMagic)
|
|
|
|
{
|
|
|
|
case PEN_MAGIC:
|
1997-08-24 18:00:30 +02:00
|
|
|
ret = MFDRV_PEN_SelectObject( dc, handle, (PENOBJ *)ptr );
|
|
|
|
break;
|
1997-02-02 20:01:52 +01:00
|
|
|
case BRUSH_MAGIC:
|
1997-08-24 18:00:30 +02:00
|
|
|
ret = MFDRV_BRUSH_SelectObject( dc, handle, (BRUSHOBJ *)ptr );
|
|
|
|
break;
|
1997-02-02 20:01:52 +01:00
|
|
|
case BITMAP_MAGIC:
|
1997-08-24 18:00:30 +02:00
|
|
|
ret = MFDRV_BITMAP_SelectObject( dc, handle, (BITMAPOBJ *)ptr );
|
|
|
|
break;
|
1997-02-02 20:01:52 +01:00
|
|
|
case FONT_MAGIC:
|
1997-08-24 18:00:30 +02:00
|
|
|
ret = MFDRV_FONT_SelectObject( dc, handle, (FONTOBJ *)ptr );
|
|
|
|
break;
|
1997-02-02 20:01:52 +01:00
|
|
|
case REGION_MAGIC:
|
1997-08-24 18:00:30 +02:00
|
|
|
ret = (HGDIOBJ16)SelectClipRgn16( dc->hSelf, handle );
|
|
|
|
break;
|
1997-02-02 20:01:52 +01:00
|
|
|
}
|
1997-08-24 18:00:30 +02:00
|
|
|
GDI_HEAP_UNLOCK( handle );
|
|
|
|
return ret;
|
1997-02-02 20:01:52 +01:00
|
|
|
}
|