Removed some direct accesses to the DC structure.
[wine/multimedia.git] / dlls / wineps / pen.c
blobb22006d64ffe1bc6f40439b702e420b148dc0305
1 /*
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
21 #include "gdi.h"
22 #include "psdrv.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
27 static char PEN_dash[] = "50 30"; /* ----- ----- ----- */
28 static char PEN_dot[] = "20"; /* -- -- -- -- -- -- */
29 static char PEN_dashdot[] = "40 30 20 30"; /* ---- -- ---- -- */
30 static char PEN_dashdotdot[] = "40 20 20 20 20 20"; /* ---- -- -- ---- */
31 static char PEN_alternate[] = "1";
33 /***********************************************************************
34 * SelectPen (WINEPS.@)
36 HPEN PSDRV_SelectPen( PSDRV_PDEVICE *physDev, HPEN hpen )
38 LOGPEN logpen;
40 if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0;
42 TRACE("hpen = %08x colour = %08lx\n", hpen, logpen.lopnColor);
44 physDev->pen.width = INTERNAL_XWSTODS(physDev->dc, logpen.lopnWidth.x);
45 if(physDev->pen.width < 0)
46 physDev->pen.width = -physDev->pen.width;
48 PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
49 physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
51 switch(physDev->pen.style) {
52 case PS_DASH:
53 physDev->pen.dash = PEN_dash;
54 break;
56 case PS_DOT:
57 physDev->pen.dash = PEN_dot;
58 break;
60 case PS_DASHDOT:
61 physDev->pen.dash = PEN_dashdot;
62 break;
64 case PS_DASHDOTDOT:
65 physDev->pen.dash = PEN_dashdotdot;
66 break;
68 case PS_ALTERNATE:
69 physDev->pen.dash = PEN_alternate;
70 break;
72 default:
73 physDev->pen.dash = NULL;
76 if ((physDev->pen.width > 1) && (physDev->pen.dash != NULL)) {
77 physDev->pen.style = PS_SOLID;
78 physDev->pen.dash = NULL;
81 physDev->pen.set = FALSE;
82 return hpen;
86 /**********************************************************************
88 * PSDRV_SetPen
91 BOOL PSDRV_SetPen(PSDRV_PDEVICE *physDev)
93 if (physDev->pen.style != PS_NULL) {
94 PSDRV_WriteSetColor(physDev, &physDev->pen.color);
96 if(!physDev->pen.set) {
97 PSDRV_WriteSetPen(physDev);
98 physDev->pen.set = TRUE;
102 return TRUE;