Fix WM_NOTIFYFORMAT handling.
[wine/testsucceed.git] / objects / pen.c
blobfe5be3ce5d7cfd8896aebe5f5f326f8f5fdca54f
1 /*
2 * GDI pen objects
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <string.h>
25 #include "windef.h"
26 #include "wingdi.h"
28 #include "wine/wingdi16.h"
29 #include "pen.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
37 /***********************************************************************
38 * CreatePen (GDI.61)
40 HPEN16 WINAPI CreatePen16( INT16 style, INT16 width, COLORREF color )
42 LOGPEN logpen;
44 TRACE("%d %d %06lx\n", style, width, color );
46 logpen.lopnStyle = style;
47 logpen.lopnWidth.x = width;
48 logpen.lopnWidth.y = 0;
49 logpen.lopnColor = color;
51 return CreatePenIndirect( &logpen );
55 /***********************************************************************
56 * CreatePen (GDI32.@)
58 HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
60 LOGPEN logpen;
62 TRACE("%d %d %06lx\n", style, width, color );
64 logpen.lopnStyle = style;
65 logpen.lopnWidth.x = width;
66 logpen.lopnWidth.y = 0;
67 logpen.lopnColor = color;
69 return CreatePenIndirect( &logpen );
73 /***********************************************************************
74 * CreatePenIndirect (GDI.62)
76 HPEN16 WINAPI CreatePenIndirect16( const LOGPEN16 * pen )
78 PENOBJ * penPtr;
79 HPEN hpen;
81 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
82 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
83 penPtr->logpen.lopnStyle = pen->lopnStyle;
84 penPtr->logpen.lopnColor = pen->lopnColor;
85 CONV_POINT16TO32( &pen->lopnWidth, &penPtr->logpen.lopnWidth );
86 GDI_ReleaseObj( hpen );
87 return hpen;
91 /***********************************************************************
92 * CreatePenIndirect (GDI32.@)
94 HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
96 PENOBJ * penPtr;
97 HPEN hpen;
99 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
100 penPtr->logpen.lopnStyle = pen->lopnStyle;
101 penPtr->logpen.lopnWidth = pen->lopnWidth;
102 penPtr->logpen.lopnColor = pen->lopnColor;
103 GDI_ReleaseObj( hpen );
104 return hpen;
107 /***********************************************************************
108 * ExtCreatePen (GDI32.@)
110 * FIXME: PS_USERSTYLE not handled
113 HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
114 const LOGBRUSH * brush, DWORD style_count,
115 const DWORD *style_bits )
117 PENOBJ * penPtr;
118 HPEN hpen;
120 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
121 FIXME("PS_USERSTYLE not handled\n");
122 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
123 if (brush->lbHatch)
124 FIXME("Hatches not implemented\n");
126 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, &hpen ))) return 0;
127 penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK;
129 /* PS_USERSTYLE workaround */
130 if((penPtr->logpen.lopnStyle & PS_STYLE_MASK) == PS_USERSTYLE)
131 penPtr->logpen.lopnStyle =
132 (penPtr->logpen.lopnStyle & ~PS_STYLE_MASK) | PS_SOLID;
134 penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
135 penPtr->logpen.lopnWidth.y = 0;
136 penPtr->logpen.lopnColor = brush->lbColor;
137 GDI_ReleaseObj( hpen );
139 return hpen;
142 /***********************************************************************
143 * PEN_GetObject16
145 INT16 PEN_GetObject16( PENOBJ * pen, INT16 count, LPSTR buffer )
147 LOGPEN16 logpen;
148 logpen.lopnStyle = pen->logpen.lopnStyle;
149 logpen.lopnColor = pen->logpen.lopnColor;
150 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
151 if (count > sizeof(logpen)) count = sizeof(logpen);
152 memcpy( buffer, &logpen, count );
153 return count;
157 /***********************************************************************
158 * PEN_GetObject
160 INT PEN_GetObject( PENOBJ * pen, INT count, LPSTR buffer )
162 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
163 memcpy( buffer, &pen->logpen, count );
164 return count;