Release 970804
[wine] / objects / pen.c
1 /*
2  * GDI pen objects
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #include "pen.h"
8 #include "metafile.h"
9 #include "color.h"
10 #include "stddebug.h"
11 #include "debug.h"
12
13
14
15 /***********************************************************************
16  *           CreatePen16    (GDI.61)
17  */
18 HPEN16 CreatePen16( INT16 style, INT16 width, COLORREF color )
19 {
20     LOGPEN32 logpen = { style, { width, 0 }, color };
21     dprintf_gdi(stddeb, "CreatePen16: %d %d %06lx\n", style, width, color );
22     return CreatePenIndirect32( &logpen );
23 }
24
25
26 /***********************************************************************
27  *           CreatePen32    (GDI32.55)
28  */
29 HPEN32 CreatePen32( INT32 style, INT32 width, COLORREF color )
30 {
31     LOGPEN32 logpen = { style, { width, 0 }, color };
32     dprintf_gdi(stddeb, "CreatePen32: %d %d %06lx\n", style, width, color );
33     return CreatePenIndirect32( &logpen );
34 }
35
36
37 /***********************************************************************
38  *           CreatePenIndirect16    (GDI.62)
39  */
40 HPEN16 CreatePenIndirect16( const LOGPEN16 * pen )
41 {
42     PENOBJ * penPtr;
43     HPEN16 hpen;
44
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_LIN_ADDR( hpen );
49     penPtr->logpen.lopnStyle = pen->lopnStyle;
50     penPtr->logpen.lopnColor = pen->lopnColor;
51     CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
52     return hpen;
53 }
54
55
56 /***********************************************************************
57  *           CreatePenIndirect32    (GDI32.56)
58  */
59 HPEN32 CreatePenIndirect32( const LOGPEN32 * pen )
60 {
61     PENOBJ * penPtr;
62     HPEN32 hpen;
63
64     if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
65     hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
66     if (!hpen) return 0;
67     penPtr = (PENOBJ *)GDI_HEAP_LIN_ADDR( hpen );
68     penPtr->logpen.lopnStyle = pen->lopnStyle;
69     penPtr->logpen.lopnWidth = pen->lopnWidth;
70     penPtr->logpen.lopnColor = pen->lopnColor;
71     return hpen;
72 }
73
74
75 /***********************************************************************
76  *           PEN_GetObject16
77  */
78 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
79 {
80     LOGPEN16 logpen;
81     logpen.lopnStyle = pen->logpen.lopnStyle;
82     logpen.lopnColor = pen->logpen.lopnColor;
83     CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
84     if (count > sizeof(logpen)) count = sizeof(logpen);
85     memcpy( buffer, &logpen, count );
86     return count;
87 }
88
89
90 /***********************************************************************
91  *           PEN_GetObject32
92  */
93 INT32 PEN_GetObject32( PENOBJ * pen, INT32 count, LPSTR buffer )
94 {
95     if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
96     memcpy( buffer, &pen->logpen, count );
97     return count;
98 }
99