Bug fixes.
[wine/multimedia.git] / objects / pen.c
blob9f23ea4c3d22518b09368f29c620457f083b341f
1 /*
2 * GDI pen objects
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include <string.h>
8 #include "pen.h"
9 #include "debugtools.h"
11 DEFAULT_DEBUG_CHANNEL(gdi)
15 /***********************************************************************
16 * CreatePen16 (GDI.61)
18 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
20 LOGPEN logpen;
22 TRACE("%d %d %06lx\n", style, width, color );
24 logpen.lopnStyle = style;
25 logpen.lopnWidth.x = width;
26 logpen.lopnWidth.y = 0;
27 logpen.lopnColor = color;
29 return CreatePenIndirect( &logpen );
33 /***********************************************************************
34 * CreatePen32 (GDI32.55)
36 HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
38 LOGPEN logpen;
40 TRACE("%d %d %06lx\n", style, width, color );
42 logpen.lopnStyle = style;
43 logpen.lopnWidth.x = width;
44 logpen.lopnWidth.y = 0;
45 logpen.lopnColor = color;
47 return CreatePenIndirect( &logpen );
51 /***********************************************************************
52 * CreatePenIndirect16 (GDI.62)
54 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
56 PENOBJ * penPtr;
57 HPEN16 hpen;
59 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
60 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
61 if (!hpen) return 0;
62 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
63 penPtr->logpen.lopnStyle = pen->lopnStyle;
64 penPtr->logpen.lopnColor = pen->lopnColor;
65 CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
66 GDI_HEAP_UNLOCK( hpen );
67 return hpen;
71 /***********************************************************************
72 * CreatePenIndirect32 (GDI32.56)
74 HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
76 PENOBJ * penPtr;
77 HPEN hpen;
79 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
80 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
81 if (!hpen) return 0;
82 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
83 penPtr->logpen.lopnStyle = pen->lopnStyle;
84 penPtr->logpen.lopnWidth = pen->lopnWidth;
85 penPtr->logpen.lopnColor = pen->lopnColor;
86 GDI_HEAP_UNLOCK( hpen );
87 return hpen;
90 /***********************************************************************
91 * ExtCreatePen32 (GDI32.93)
93 * FIXME: PS_USERSTYLE not handled
96 HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
97 const LOGBRUSH * brush, DWORD style_count,
98 const DWORD *style_bits )
100 PENOBJ * penPtr;
101 HPEN hpen;
103 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
104 FIXME("PS_USERSTYLE not handled\n");
105 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
106 if (brush->lbHatch)
107 FIXME("Hatches not implemented\n");
109 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
110 if (!hpen) return 0;
111 penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
112 penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK;
114 /* PS_USERSTYLE and PS_ALTERNATE workaround */
115 if((penPtr->logpen.lopnStyle & PS_STYLE_MASK) > PS_INSIDEFRAME)
116 penPtr->logpen.lopnStyle =
117 (penPtr->logpen.lopnStyle & ~PS_STYLE_MASK) | PS_SOLID;
119 penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
120 penPtr->logpen.lopnWidth.y = 0;
121 penPtr->logpen.lopnColor = brush->lbColor;
122 GDI_HEAP_UNLOCK( hpen );
124 return hpen;
127 /***********************************************************************
128 * PEN_GetObject16
130 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
132 LOGPEN16 logpen;
133 logpen.lopnStyle = pen->logpen.lopnStyle;
134 logpen.lopnColor = pen->logpen.lopnColor;
135 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
136 if (count > sizeof(logpen)) count = sizeof(logpen);
137 memcpy( buffer, &logpen, count );
138 return count;
142 /***********************************************************************
143 * PEN_GetObject32
145 INT PEN_GetObject( PENOBJ * pen, INT count, LPSTR buffer )
147 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
148 memcpy( buffer, &pen->logpen, count );
149 return count;