Removed PROCESS_GetPtr.
[wine] / objects / pen.c
1 /*
2  * GDI pen objects
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #include "pen.h"
8 #include "debug.h"
9
10
11
12 /***********************************************************************
13  *           CreatePen16    (GDI.61)
14  */
15 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
16 {
17     LOGPEN32 logpen = { style, { width, 0 }, color };
18     TRACE(gdi, "%d %d %06lx\n", style, width, color );
19     return CreatePenIndirect32( &logpen );
20 }
21
22
23 /***********************************************************************
24  *           CreatePen32    (GDI32.55)
25  */
26 HPEN32 WINAPI CreatePen32( INT32 style, INT32 width, COLORREF color )
27 {
28     LOGPEN32 logpen = { style, { width, 0 }, color };
29     TRACE(gdi, "%d %d %06lx\n", style, width, color );
30     return CreatePenIndirect32( &logpen );
31 }
32
33
34 /***********************************************************************
35  *           CreatePenIndirect16    (GDI.62)
36  */
37 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
38 {
39     PENOBJ * penPtr;
40     HPEN16 hpen;
41
42     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
43     hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
44     if (!hpen) return 0;
45     penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
46     penPtr->logpen.lopnStyle = pen->lopnStyle;
47     penPtr->logpen.lopnColor = pen->lopnColor;
48     CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
49     GDI_HEAP_UNLOCK( hpen );
50     return hpen;
51 }
52
53
54 /***********************************************************************
55  *           CreatePenIndirect32    (GDI32.56)
56  */
57 HPEN32 WINAPI CreatePenIndirect32( const LOGPEN32 * pen )
58 {
59     PENOBJ * penPtr;
60     HPEN32 hpen;
61
62     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
63     hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
64     if (!hpen) return 0;
65     penPtr = (PENOBJ *)GDI_HEAP_LOCK( hpen );
66     penPtr->logpen.lopnStyle = pen->lopnStyle;
67     penPtr->logpen.lopnWidth = pen->lopnWidth;
68     penPtr->logpen.lopnColor = pen->lopnColor;
69     GDI_HEAP_UNLOCK( hpen );
70     return hpen;
71 }
72
73 /***********************************************************************
74  *           ExtCreatePen32    (GDI32.93)
75  *
76  * FIXME: PS_USERSTYLE not handled
77  */
78
79 HPEN32 WINAPI ExtCreatePen32( DWORD style, DWORD width,
80                               const LOGBRUSH32 * brush, DWORD style_count,
81                               const DWORD *style_bits )
82 {
83     LOGPEN32 logpen;
84
85     if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
86         FIXME(gdi, "PS_USERSTYLE not handled\n");
87     if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
88         if (brush->lbHatch)
89             FIXME(gdi, "Hatches not implemented\n");
90
91     logpen.lopnStyle = style & ~PS_TYPE_MASK;
92     logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
93     logpen.lopnWidth.y = 0;
94     logpen.lopnColor = brush->lbColor;
95     return CreatePenIndirect32( &logpen );
96 }
97
98 /***********************************************************************
99  *           PEN_GetObject16
100  */
101 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
102 {
103     LOGPEN16 logpen;
104     logpen.lopnStyle = pen->logpen.lopnStyle;
105     logpen.lopnColor = pen->logpen.lopnColor;
106     CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
107     if (count > sizeof(logpen)) count = sizeof(logpen);
108     memcpy( buffer, &logpen, count );
109     return count;
110 }
111
112
113 /***********************************************************************
114  *           PEN_GetObject32
115  */
116 INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
117 {
118     if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
119     memcpy( buffer, &pen->logpen, count );
120     return count;
121 }
122