Remove the WINEDEBUG variable from the environment of the debugger
[wine/multimedia.git] / objects / pen.c
blobf15cc44f90bda1b6215e11c4e342d2b55b9120ed
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 <stdarg.h>
24 #include <string.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "wine/wingdi16.h"
30 #include "gdi.h"
31 #include "gdi_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
36 /* GDI logical pen object */
37 typedef struct
39 GDIOBJHDR header;
40 LOGPEN logpen;
41 } PENOBJ;
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 /***********************************************************************
60 * CreatePen (GDI32.@)
62 HPEN WINAPI CreatePen( INT style, INT width, COLORREF color )
64 LOGPEN logpen;
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 )
82 PENOBJ * penPtr;
83 HPEN hpen;
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 );
91 return 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 )
104 PENOBJ * penPtr;
105 HPEN hpen;
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 );
127 return hpen;
131 /***********************************************************************
132 * PEN_SelectObject
134 static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
136 HGDIOBJ ret;
137 DC *dc = DC_GetDCPtr( hdc );
139 if (!dc) return 0;
140 ret = dc->hPen;
141 if (dc->funcs->pSelectPen) handle = dc->funcs->pSelectPen( dc->physDev, handle );
142 if (handle) dc->hPen = handle;
143 else ret = 0;
144 GDI_ReleaseObj( hdc );
145 return ret;
149 /***********************************************************************
150 * PEN_GetObject16
152 static INT PEN_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
154 PENOBJ *pen = obj;
155 LOGPEN16 logpen;
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 );
162 return count;
166 /***********************************************************************
167 * PEN_GetObject
169 static INT PEN_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer )
171 PENOBJ *pen = obj;
173 if( !buffer )
174 return sizeof(pen->logpen);
176 if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
177 memcpy( buffer, &pen->logpen, count );
178 return count;