2 * PostScript pen handling
4 * Copyright 1998 Huw D M Davies
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
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
31 static const char PEN_dash[] = "50 30"; /* ----- ----- ----- */
32 static const char PEN_dot[] = "20"; /* -- -- -- -- -- -- */
33 static const char PEN_dashdot[] = "40 30 20 30"; /* ---- -- ---- -- */
34 static const char PEN_dashdotdot[] = "40 20 20 20 20 20"; /* ---- -- -- ---- */
35 static const char PEN_alternate[] = "1";
37 /***********************************************************************
38 * SelectPen (WINEPS.@)
40 HPEN PSDRV_SelectPen( PSDRV_PDEVICE *physDev, HPEN hpen )
44 if (!GetObjectW( hpen, sizeof(logpen), &logpen ))
46 /* must be an extended pen */
48 INT size = GetObjectW( hpen, 0, NULL );
52 elp = HeapAlloc( GetProcessHeap(), 0, size );
54 GetObjectW( hpen, size, elp );
55 /* FIXME: add support for user style pens */
56 logpen.lopnStyle = elp->elpPenStyle;
57 logpen.lopnWidth.x = elp->elpWidth;
58 logpen.lopnWidth.y = 0;
59 logpen.lopnColor = elp->elpColor;
61 HeapFree( GetProcessHeap(), 0, elp );
64 TRACE("hpen = %p colour = %08lx\n", hpen, logpen.lopnColor);
66 physDev->pen.width = logpen.lopnWidth.x;
67 if ((logpen.lopnStyle & PS_GEOMETRIC) || (physDev->pen.width > 1))
69 physDev->pen.width = PSDRV_XWStoDS( physDev, physDev->pen.width );
70 if(physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
73 PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
74 physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
76 switch(physDev->pen.style) {
78 physDev->pen.dash = PEN_dash;
82 physDev->pen.dash = PEN_dot;
86 physDev->pen.dash = PEN_dashdot;
90 physDev->pen.dash = PEN_dashdotdot;
94 physDev->pen.dash = PEN_alternate;
98 physDev->pen.dash = NULL;
101 if ((physDev->pen.width > 1) && (physDev->pen.dash != NULL)) {
102 physDev->pen.style = PS_SOLID;
103 physDev->pen.dash = NULL;
106 physDev->pen.set = FALSE;
111 /**********************************************************************
116 BOOL PSDRV_SetPen(PSDRV_PDEVICE *physDev)
118 if (physDev->pen.style != PS_NULL) {
119 PSDRV_WriteSetColor(physDev, &physDev->pen.color);
121 if(!physDev->pen.set) {
122 PSDRV_WriteSetPen(physDev);
123 physDev->pen.set = TRUE;