Release 980215
[wine.git] / objects / pen.c
blobca3a1912f489916b571820df3d3f26504d1ea260
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;
76 /***********************************************************************
77 * ExtCreatePen32 (GDI32.93)
79 * FIXME: PS_USERSTYLE not handled
82 HPEN32 WINAPI ExtCreatePen32( DWORD style, DWORD width,
83 const LOGBRUSH32 * brush, DWORD style_count,
84 const DWORD *style_bits )
86 LOGPEN32 logpen;
88 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
89 fprintf(stderr, "ExtCreatePen: PS_USERSTYLE not handled\n");
90 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
91 if (brush->lbHatch)
92 fprintf(stderr, "ExtCreatePen: Hatches not implemented\n");
94 logpen.lopnStyle = style & ~PS_TYPE_MASK;
95 logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
96 logpen.lopnWidth.y = 0;
97 logpen.lopnColor = brush->lbColor;
98 return CreatePenIndirect32( &logpen );
101 /***********************************************************************
102 * PEN_GetObject16
104 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
106 LOGPEN16 logpen;
107 logpen.lopnStyle = pen->logpen.lopnStyle;
108 logpen.lopnColor = pen->logpen.lopnColor;
109 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
110 if (count > sizeof(logpen)) count = sizeof(logpen);
111 memcpy( buffer, &logpen, count );
112 return count;
116 /***********************************************************************
117 * PEN_GetObject32
119 INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
121 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
122 memcpy( buffer, &pen->logpen, count );
123 return count;