Release 970824
[wine/multimedia.git] / objects / pen.c
blobc2c63adbbdc2737c1c6a8f33f134109d6f7994fd
1 /*
2 * GDI pen objects
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include "pen.h"
8 #include "metafile.h"
9 #include "color.h"
10 #include "stddebug.h"
11 #include "debug.h"
15 /***********************************************************************
16 * CreatePen16 (GDI.61)
18 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
20 LOGPEN32 logpen = { style, { width, 0 }, color };
21 dprintf_gdi(stddeb, "CreatePen16: %d %d %06lx\n", style, width, color );
22 return CreatePenIndirect32( &logpen );
26 /***********************************************************************
27 * CreatePen32 (GDI32.55)
29 HPEN32 WINAPI CreatePen32( INT32 style, INT32 width, COLORREF color )
31 LOGPEN32 logpen = { style, { width, 0 }, color };
32 dprintf_gdi(stddeb, "CreatePen32: %d %d %06lx\n", style, width, color );
33 return CreatePenIndirect32( &logpen );
37 /***********************************************************************
38 * CreatePenIndirect16 (GDI.62)
40 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
42 PENOBJ * penPtr;
43 HPEN16 hpen;
45 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
46 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
47 if (!hpen) return 0;
48 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
49 penPtr->logpen.lopnStyle = pen->lopnStyle;
50 penPtr->logpen.lopnColor = pen->lopnColor;
51 CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
52 GDI_HEAP_UNLOCK( hpen );
53 return hpen;
57 /***********************************************************************
58 * CreatePenIndirect32 (GDI32.56)
60 HPEN32 WINAPI CreatePenIndirect32( const LOGPEN32 * pen )
62 PENOBJ * penPtr;
63 HPEN32 hpen;
65 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
66 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
67 if (!hpen) return 0;
68 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
69 penPtr->logpen.lopnStyle = pen->lopnStyle;
70 penPtr->logpen.lopnWidth = pen->lopnWidth;
71 penPtr->logpen.lopnColor = pen->lopnColor;
72 GDI_HEAP_UNLOCK( hpen );
73 return hpen;
77 /***********************************************************************
78 * PEN_GetObject16
80 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
82 LOGPEN16 logpen;
83 logpen.lopnStyle = pen->logpen.lopnStyle;
84 logpen.lopnColor = pen->logpen.lopnColor;
85 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
86 if (count > sizeof(logpen)) count = sizeof(logpen);
87 memcpy( buffer, &logpen, count );
88 return count;
92 /***********************************************************************
93 * PEN_GetObject32
95 INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
97 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
98 memcpy( buffer, &pen->logpen, count );
99 return count;