Release 980927
[wine.git] / objects / pen.c
blobe9ee9a83c9fa6bf1c6c53e6a0f45105b7523e8af
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 "debug.h"
14 /***********************************************************************
15 * CreatePen16 (GDI.61)
17 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
19 LOGPEN32 logpen = { style, { width, 0 }, color };
20 TRACE(gdi, "%d %d %06lx\n", style, width, color );
21 return CreatePenIndirect32( &logpen );
25 /***********************************************************************
26 * CreatePen32 (GDI32.55)
28 HPEN32 WINAPI CreatePen32( INT32 style, INT32 width, COLORREF color )
30 LOGPEN32 logpen = { style, { width, 0 }, color };
31 TRACE(gdi, "%d %d %06lx\n", style, width, color );
32 return CreatePenIndirect32( &logpen );
36 /***********************************************************************
37 * CreatePenIndirect16 (GDI.62)
39 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
41 PENOBJ * penPtr;
42 HPEN16 hpen;
44 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
45 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
46 if (!hpen) return 0;
47 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
48 penPtr->logpen.lopnStyle = pen->lopnStyle;
49 penPtr->logpen.lopnColor = pen->lopnColor;
50 CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
51 GDI_HEAP_UNLOCK( hpen );
52 return hpen;
56 /***********************************************************************
57 * CreatePenIndirect32 (GDI32.56)
59 HPEN32 WINAPI CreatePenIndirect32( const LOGPEN32 * pen )
61 PENOBJ * penPtr;
62 HPEN32 hpen;
64 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
65 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
66 if (!hpen) return 0;
67 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
68 penPtr->logpen.lopnStyle = pen->lopnStyle;
69 penPtr->logpen.lopnWidth = pen->lopnWidth;
70 penPtr->logpen.lopnColor = pen->lopnColor;
71 GDI_HEAP_UNLOCK( hpen );
72 return hpen;
75 /***********************************************************************
76 * ExtCreatePen32 (GDI32.93)
78 * FIXME: PS_USERSTYLE not handled
81 HPEN32 WINAPI ExtCreatePen32( DWORD style, DWORD width,
82 const LOGBRUSH32 * brush, DWORD style_count,
83 const DWORD *style_bits )
85 LOGPEN32 logpen;
87 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
88 FIXME(gdi, "PS_USERSTYLE not handled\n");
89 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
90 if (brush->lbHatch)
91 FIXME(gdi, "Hatches not implemented\n");
93 logpen.lopnStyle = style & ~PS_TYPE_MASK;
94 logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
95 logpen.lopnWidth.y = 0;
96 logpen.lopnColor = brush->lbColor;
97 return CreatePenIndirect32( &logpen );
100 /***********************************************************************
101 * PEN_GetObject16
103 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
105 LOGPEN16 logpen;
106 logpen.lopnStyle = pen->logpen.lopnStyle;
107 logpen.lopnColor = pen->logpen.lopnColor;
108 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
109 if (count > sizeof(logpen)) count = sizeof(logpen);
110 memcpy( buffer, &logpen, count );
111 return count;
115 /***********************************************************************
116 * PEN_GetObject32
118 INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
120 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
121 memcpy( buffer, &pen->logpen, count );
122 return count;