kernel32: FindFirstChangeNotification needs a static IO_STATUS_BLOCK.
[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 <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wingdi.h"
26 #include "psdrv.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
30
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";
36
37 /***********************************************************************
38  *           SelectPen   (WINEPS.@)
39  */
40 HPEN PSDRV_SelectPen( PSDRV_PDEVICE *physDev, HPEN hpen )
41 {
42     LOGPEN logpen;
43
44     if (!GetObjectW( hpen, sizeof(logpen), &logpen ))
45     {
46         /* must be an extended pen */
47         EXTLOGPEN elp;
48         if (!GetObjectW( hpen, sizeof(elp), &elp ))
49         {
50             FIXME("extended pen %p not supported\n", hpen);
51             return 0;
52         }
53         logpen.lopnStyle = elp.elpPenStyle;
54         logpen.lopnWidth.x = elp.elpWidth;
55         logpen.lopnWidth.y = 0;
56         logpen.lopnColor = elp.elpColor;
57     }
58
59     TRACE("hpen = %p colour = %08lx\n", hpen, logpen.lopnColor);
60
61     physDev->pen.width = logpen.lopnWidth.x;
62     if (logpen.lopnStyle & PS_GEOMETRIC)
63     {
64         physDev->pen.width = PSDRV_XWStoDS( physDev, physDev->pen.width );
65         if(physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
66     }
67
68     PSDRV_CreateColor(physDev, &physDev->pen.color, logpen.lopnColor);
69     physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
70
71     switch(physDev->pen.style) {
72     case PS_DASH:
73         physDev->pen.dash = PEN_dash;
74         break;
75
76     case PS_DOT:
77         physDev->pen.dash = PEN_dot;
78         break;
79
80     case PS_DASHDOT:
81         physDev->pen.dash = PEN_dashdot;
82         break;
83
84     case PS_DASHDOTDOT:
85         physDev->pen.dash = PEN_dashdotdot;
86         break;
87
88     case PS_ALTERNATE:
89         physDev->pen.dash = PEN_alternate;
90         break;
91
92     default:
93         physDev->pen.dash = NULL;
94     }
95
96     if ((physDev->pen.width > 1) && (physDev->pen.dash != NULL)) {
97         physDev->pen.style = PS_SOLID;
98          physDev->pen.dash = NULL;
99     }
100
101     physDev->pen.set = FALSE;
102     return hpen;
103 }
104
105
106 /**********************************************************************
107  *
108  *      PSDRV_SetPen
109  *
110  */
111 BOOL PSDRV_SetPen(PSDRV_PDEVICE *physDev)
112 {
113     if (physDev->pen.style != PS_NULL) {
114         PSDRV_WriteSetColor(physDev, &physDev->pen.color);
115
116         if(!physDev->pen.set) {
117             PSDRV_WriteSetPen(physDev);
118             physDev->pen.set = TRUE;
119         }
120     }
121
122     return TRUE;
123 }