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
29 #include "wine/wingdi16.h"
31 #include "gdi_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
36 /* GDI logical pen object */
44 static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
45 static INT PEN_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
46 static INT PEN_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
48 static const struct gdi_obj_funcs pen_funcs =
50 PEN_SelectObject, /* pSelectObject */
51 PEN_GetObject16, /* pGetObject16 */
52 PEN_GetObject, /* pGetObjectA */
53 PEN_GetObject, /* pGetObjectW */
54 NULL, /* pUnrealizeObject */
55 GDI_FreeObject /* pDeleteObject */
59 /***********************************************************************
62 HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
66 TRACE("%d %d %06lx\n", style, width, color );
68 logpen.lopnStyle = style;
69 logpen.lopnWidth.x = width;
70 logpen.lopnWidth.y = 0;
71 logpen.lopnColor = color;
73 return CreatePenIndirect( &logpen );
77 /***********************************************************************
78 * CreatePenIndirect (GDI32.@)
80 HPEN WINAPI CreatePenIndirect( const LOGPEN * pen )
85 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, (HGDIOBJ *)&hpen,
86 &pen_funcs ))) return 0;
87 penPtr->logpen.lopnStyle = pen->lopnStyle;
88 penPtr->logpen.lopnWidth = pen->lopnWidth;
89 penPtr->logpen.lopnColor = pen->lopnColor;
90 GDI_ReleaseObj( hpen );
94 /***********************************************************************
95 * ExtCreatePen (GDI32.@)
97 * FIXME: PS_USERSTYLE not handled
100 HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
101 const LOGBRUSH * brush, DWORD style_count,
102 const DWORD *style_bits )
107 if ((style & PS_STYLE_MASK) == PS_USERSTYLE)
108 FIXME("PS_USERSTYLE not handled\n");
109 if ((style & PS_TYPE_MASK) == PS_GEOMETRIC)
110 if (brush->lbHatch && ((brush->lbStyle == BS_SOLID) || (brush->lbStyle == BS_HOLLOW)))
111 FIXME("Hatches not implemented\n");
113 if (!(penPtr = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC, (HGDIOBJ *)&hpen,
114 &pen_funcs ))) return 0;
115 penPtr->logpen.lopnStyle = style & ~PS_TYPE_MASK;
117 /* PS_USERSTYLE workaround */
118 if((penPtr->logpen.lopnStyle & PS_STYLE_MASK) == PS_USERSTYLE)
119 penPtr->logpen.lopnStyle =
120 (penPtr->logpen.lopnStyle & ~PS_STYLE_MASK) | PS_SOLID;
122 penPtr->logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
123 penPtr->logpen.lopnWidth.y = 0;
124 penPtr->logpen.lopnColor = brush->lbColor;
125 GDI_ReleaseObj( hpen );
131 /***********************************************************************
134 static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
137 DC *dc = DC_GetDCPtr( hdc );
141 if (dc->funcs->pSelectPen) handle = dc->funcs->pSelectPen( dc->physDev, handle );
142 if (handle) dc->hPen = handle;
144 GDI_ReleaseObj( hdc );
149 /***********************************************************************
152 static INT PEN_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
157 logpen.lopnStyle = pen->logpen.lopnStyle;
158 logpen.lopnColor = pen->logpen.lopnColor;
159 CONV_POINT32TO16( &pen->logpen.lopnWidth, &logpen.lopnWidth );
160 if (count > sizeof(logpen)) count = sizeof(logpen);
161 memcpy( buffer, &logpen, count );
166 /***********************************************************************
169 static INT PEN_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
174 return sizeof(pen->logpen);
176 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
177 memcpy( buffer, &pen->logpen, count );