Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[wine] / dlls / wineps / pen.c
1 /*
2  *      PostScript pen handling
3  *
4  *      Copyright 1998  Huw D M Davies
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "psdrv.h"
22 #include "wine/debug.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
25
26 static char PEN_dash[]       = "50 30";     /* -----   -----   -----  */
27 static char PEN_dot[]        = "20";      /* --  --  --  --  --  -- */
28 static char PEN_dashdot[]    = "40 30 20 30";  /* ----   --   ----   --  */
29 static char PEN_dashdotdot[] = "40 20 20 20 20 20"; /* ----  --  --  ----  */
30 static char PEN_alternate[]  = "1";
31
32 /***********************************************************************
33  *           PSDRV_PEN_SelectObject
34  */
35 HPEN PSDRV_PEN_SelectObject( DC * dc, HPEN hpen )
36 {
37     LOGPEN logpen;
38     HPEN prevpen = dc->hPen;
39     PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
40
41     if (!GetObjectA( hpen, sizeof(logpen), &logpen )) return 0;
42
43     TRACE("hpen = %08x colour = %08lx\n", hpen, logpen.lopnColor);
44
45     dc->hPen = hpen;
46
47     physDev->pen.width = INTERNAL_XWSTODS(dc, logpen.lopnWidth.x);
48     if(physDev->pen.width < 0)
49         physDev->pen.width = -physDev->pen.width;
50
51     PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
52     physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
53  
54     switch(physDev->pen.style) {
55     case PS_DASH:
56         physDev->pen.dash = PEN_dash;
57         break;
58
59     case PS_DOT:
60         physDev->pen.dash = PEN_dot;
61         break;
62
63     case PS_DASHDOT:
64         physDev->pen.dash = PEN_dashdot;
65         break;
66
67     case PS_DASHDOTDOT:
68         physDev->pen.dash = PEN_dashdotdot;
69         break;
70
71     case PS_ALTERNATE:
72         physDev->pen.dash = PEN_alternate;
73         break;
74
75     default:
76         physDev->pen.dash = NULL;
77     }       
78
79     if ((physDev->pen.width > 1) && (physDev->pen.dash != NULL)) {
80         physDev->pen.style = PS_SOLID;
81          physDev->pen.dash = NULL;
82     } 
83
84     physDev->pen.set = FALSE;
85     return prevpen;
86 }
87
88
89 /**********************************************************************
90  *
91  *      PSDRV_SetPen
92  *
93  */
94 BOOL PSDRV_SetPen(DC *dc)
95 {
96     PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
97
98     if (physDev->pen.style != PS_NULL) {
99         PSDRV_WriteSetColor(dc, &physDev->pen.color);
100         
101         if(!physDev->pen.set) {
102             PSDRV_WriteSetPen(dc);
103             physDev->pen.set = TRUE;
104         }    
105     }
106
107     return TRUE;
108 }