Fixed CloseHandle() on global handles.
[wine/multimedia.git] / graphics / x11drv / pen.c
blob4c26d1e45df1f35453a20b8197eb09586722e7f4
1 /*
2 * X11DRV pen objects
4 * Copyright 1993 Alexandre Julliard
5 */
7 #include "pen.h"
8 #include "color.h"
9 #include "debug.h"
11 static const char PEN_dash[] = { 5,3 }; /* ----- ----- ----- */
12 static const char PEN_dot[] = { 1,1 }; /* -- -- -- -- -- -- */
13 static const char PEN_dashdot[] = { 4,3,2,3 }; /* ---- -- ---- -- */
14 static const char PEN_dashdotdot[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
15 static const char PEN_alternate[] = { 1,1 }; /* FIXME */
17 /***********************************************************************
18 * PEN_SelectObject
20 HPEN32 X11DRV_PEN_SelectObject( DC * dc, HPEN32 hpen, PENOBJ * pen )
22 HPEN32 prevHandle = dc->w.hPen;
23 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
25 dc->w.hPen = hpen;
26 physDev->pen.style = pen->logpen.lopnStyle & PS_STYLE_MASK;
27 physDev->pen.type = pen->logpen.lopnStyle & PS_TYPE_MASK;
28 physDev->pen.endcap = pen->logpen.lopnStyle & PS_ENDCAP_MASK;
29 physDev->pen.linejoin = pen->logpen.lopnStyle & PS_JOIN_MASK;
31 physDev->pen.width = (pen->logpen.lopnWidth.x * dc->vportExtX +
32 dc->wndExtX / 2) / dc->wndExtX;
33 if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
34 if (physDev->pen.width == 1) physDev->pen.width = 0; /* Faster */
35 physDev->pen.pixel = COLOR_ToPhysical( dc, pen->logpen.lopnColor );
36 switch(pen->logpen.lopnStyle & PS_STYLE_MASK)
38 case PS_DASH:
39 physDev->pen.dashes = (char *)PEN_dash;
40 physDev->pen.dash_len = 2;
41 break;
42 case PS_DOT:
43 physDev->pen.dashes = (char *)PEN_dot;
44 physDev->pen.dash_len = 2;
45 break;
46 case PS_DASHDOT:
47 physDev->pen.dashes = (char *)PEN_dashdot;
48 physDev->pen.dash_len = 4;
49 break;
50 case PS_DASHDOTDOT:
51 physDev->pen.dashes = (char *)PEN_dashdotdot;
52 physDev->pen.dash_len = 6;
53 break;
54 case PS_ALTERNATE:
55 /* FIXME: should be alternating _pixels_ that are set */
56 physDev->pen.dashes = (char *)PEN_alternate;
57 physDev->pen.dash_len = 2;
58 break;
59 case PS_USERSTYLE:
60 /* FIXME */
61 break;
64 return prevHandle;