Added a filter rule for filtering make output with
[wine] / objects / pen.c
1 /*
2  * GDI pen objects
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #include "config.h"
8
9 #include <string.h>
10
11 #include "windef.h"
12 #include "wingdi.h"
13
14 #include "wine/wingdi16.h"
15 #include "pen.h"
16
17 #include "debugtools.h"
18
19 DEFAULT_DEBUG_CHANNEL(gdi);
20
21
22
23 /***********************************************************************
24  *           CreatePen    (GDI.61)
25  */
26 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
27 {
28     LOGPEN logpen;
29
30     TRACE("%d %d %06lx\n", style, width, color );
31
32     logpen.lopnStyle = style; 
33     logpen.lopnWidth.x = width;
34     logpen.lopnWidth.y = 0;
35     logpen.lopnColor = color;
36
37     return CreatePenIndirect( &logpen );
38 }
39
40
41 /***********************************************************************
42  *           CreatePen    (GDI32.@)
43  */
44 HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
45 {
46     LOGPEN logpen;
47
48     TRACE("%d %d %06lx\n", style, width, color );
49
50     logpen.lopnStyle = style; 
51     logpen.lopnWidth.x = width;
52     logpen.lopnWidth.y = 0;
53     logpen.lopnColor = color;
54
55     return CreatePenIndirect( &logpen );
56 }
57
58
59 /***********************************************************************
60  *           CreatePenIndirect    (GDI.62)
61  */
62 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
63 {
64     PENOBJ * penPtr;
65     HPEN hpen;
66
67     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
68     if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
69     penPtr->logpen.lopnStyle = pen->lopnStyle;
70     penPtr->logpen.lopnColor = pen->lopnColor;
71     CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
72     GDI_ReleaseObj( hpen );
73     return hpen;
74 }
75
76
77 /***********************************************************************
78  *           CreatePenIndirect    (GDI32.@)
79  */
80 HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
81 {
82     PENOBJ * penPtr;
83     HPEN hpen;
84
85     if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
86     penPtr->logpen.lopnStyle = pen->lopnStyle;
87     penPtr->logpen.lopnWidth = pen->lopnWidth;
88     penPtr->logpen.lopnColor = pen->lopnColor;
89     GDI_ReleaseObj( hpen );
90     return hpen;
91 }
92
93 /***********************************************************************
94  *           ExtCreatePen    (GDI32.@)
95  *
96  * FIXME: PS_USERSTYLE not handled
97  */
98
99 HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
100                               const LOGBRUSH * brush, DWORD style_count,
101                               const DWORD *style_bits )
102 {
103     PENOBJ * penPtr;
104     HPEN hpen;
105
106     if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
107         FIXME("PS_USERSTYLE not handled\n");
108     if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
109         if (brush->lbHatch)
110             FIXME("Hatches not implemented\n");
111
112     if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
113     penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK; 
114     
115     /* PS_USERSTYLE workaround */   
116     if((penPtr->logpen.lopnStyle & PS_STYLE_MASK) == PS_USERSTYLE)
117        penPtr->logpen.lopnStyle = 
118          (penPtr->logpen.lopnStyle & ~PS_STYLE_MASK) | PS_SOLID;
119
120     penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1; 
121     penPtr->logpen.lopnWidth.y = 0;
122     penPtr->logpen.lopnColor = brush->lbColor;
123     GDI_ReleaseObj( hpen );
124
125     return hpen;
126 }
127
128 /***********************************************************************
129  *           PEN_GetObject16
130  */
131 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
132 {
133     LOGPEN16 logpen;
134     logpen.lopnStyle = pen->logpen.lopnStyle;
135     logpen.lopnColor = pen->logpen.lopnColor;
136     CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
137     if (count > sizeof(logpen)) count = sizeof(logpen);
138     memcpy( buffer, &logpen, count );
139     return count;
140 }
141
142
143 /***********************************************************************
144  *           PEN_GetObject
145  */
146 INT PEN_GetObject( PENOBJ * pen, INT count, LPSTR buffer )
147 {
148     if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
149     memcpy( buffer, &pen->logpen, count );
150     return count;
151 }
152