Moved a bunch of routines to kernel32.dll (with the help of
[wine/multimedia.git] / objects / pen.c
blob09fcf6667059e6ec350ca1e8bc9338f94c5497a7
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 * CreatePen (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 HPEN hpen;
59 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
60 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
61 penPtr->logpen.lopnStyle = pen->lopnStyle;
62 penPtr->logpen.lopnColor = pen->lopnColor;
63 CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
64 GDI_ReleaseObj( hpen );
65 return hpen;
69 /***********************************************************************
70 * CreatePenIndirect (GDI32.56)
72 HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
74 PENOBJ * penPtr;
75 HPEN hpen;
77 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
78 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
79 penPtr->logpen.lopnStyle = pen->lopnStyle;
80 penPtr->logpen.lopnWidth = pen->lopnWidth;
81 penPtr->logpen.lopnColor = pen->lopnColor;
82 GDI_ReleaseObj( hpen );
83 return hpen;
86 /***********************************************************************
87 * ExtCreatePen (GDI32.93)
89 * FIXME: PS_USERSTYLE not handled
92 HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
93 const LOGBRUSH * brush, DWORD style_count,
94 const DWORD *style_bits )
96 PENOBJ * penPtr;
97 HPEN hpen;
99 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
100 FIXME("PS_USERSTYLE not handled\n");
101 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
102 if (brush->lbHatch)
103 FIXME("Hatches not implemented\n");
105 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
106 penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK;
108 /* PS_USERSTYLE and PS_ALTERNATE workaround */
109 if((penPtr->logpen.lopnStyle & PS_STYLE_MASK) > PS_INSIDEFRAME)
110 penPtr->logpen.lopnStyle =
111 (penPtr->logpen.lopnStyle & ~PS_STYLE_MASK) | PS_SOLID;
113 penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
114 penPtr->logpen.lopnWidth.y = 0;
115 penPtr->logpen.lopnColor = brush->lbColor;
116 GDI_ReleaseObj( hpen );
118 return hpen;
121 /***********************************************************************
122 * PEN_GetObject16
124 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
126 LOGPEN16 logpen;
127 logpen.lopnStyle = pen->logpen.lopnStyle;
128 logpen.lopnColor = pen->logpen.lopnColor;
129 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
130 if (count > sizeof(logpen)) count = sizeof(logpen);
131 memcpy( buffer, &logpen, count );
132 return count;
136 /***********************************************************************
137 * PEN_GetObject
139 INT PEN_GetObject( PENOBJ * pen, INT count, LPSTR buffer )
141 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
142 memcpy( buffer, &pen->logpen, count );
143 return count;