4 * Copyright 1993 Alexandre Julliard
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(x11drv
);
28 static const char PEN_dash
[] = { 16,8 };
29 static const char PEN_dot
[] = { 4,4 };
30 static const char PEN_dashdot
[] = { 12,8,4,8 };
31 static const char PEN_dashdotdot
[] = { 12,4,4,4,4,4 };
32 static const char PEN_alternate
[] = { 1,1 };
34 /***********************************************************************
35 * SelectPen (X11DRV.@)
37 HPEN
X11DRV_SelectPen( X11DRV_PDEVICE
*physDev
, HPEN hpen
)
41 if (!GetObjectW( hpen
, sizeof(logpen
), &logpen
))
43 /* must be an extended pen */
45 INT size
= GetObjectW( hpen
, 0, NULL
);
49 elp
= HeapAlloc( GetProcessHeap(), 0, size
);
51 GetObjectW( hpen
, size
, elp
);
52 /* FIXME: add support for user style pens */
53 logpen
.lopnStyle
= elp
->elpPenStyle
;
54 logpen
.lopnWidth
.x
= elp
->elpWidth
;
55 logpen
.lopnWidth
.y
= 0;
56 logpen
.lopnColor
= elp
->elpColor
;
58 HeapFree( GetProcessHeap(), 0, elp
);
61 physDev
->pen
.style
= logpen
.lopnStyle
& PS_STYLE_MASK
;
62 physDev
->pen
.type
= logpen
.lopnStyle
& PS_TYPE_MASK
;
63 physDev
->pen
.endcap
= logpen
.lopnStyle
& PS_ENDCAP_MASK
;
64 physDev
->pen
.linejoin
= logpen
.lopnStyle
& PS_JOIN_MASK
;
66 physDev
->pen
.width
= logpen
.lopnWidth
.x
;
67 if ((logpen
.lopnStyle
& PS_GEOMETRIC
) || (physDev
->pen
.width
> 1))
69 physDev
->pen
.width
= X11DRV_XWStoDS( physDev
, physDev
->pen
.width
);
70 if (physDev
->pen
.width
< 0) physDev
->pen
.width
= -physDev
->pen
.width
;
73 if (physDev
->pen
.width
== 1) physDev
->pen
.width
= 0; /* Faster */
74 if (hpen
== GetStockObject( DC_PEN
))
75 logpen
.lopnColor
= GetDCPenColor( physDev
->hdc
);
76 physDev
->pen
.pixel
= X11DRV_PALETTE_ToPhysical( physDev
, logpen
.lopnColor
);
77 switch(logpen
.lopnStyle
& PS_STYLE_MASK
)
80 physDev
->pen
.dashes
= (char *)PEN_dash
;
81 physDev
->pen
.dash_len
= sizeof(PEN_dash
)/sizeof(*PEN_dash
);
84 physDev
->pen
.dashes
= (char *)PEN_dot
;
85 physDev
->pen
.dash_len
= sizeof(PEN_dot
)/sizeof(*PEN_dot
);
88 physDev
->pen
.dashes
= (char *)PEN_dashdot
;
89 physDev
->pen
.dash_len
= sizeof(PEN_dashdot
)/sizeof(*PEN_dashdot
);
92 physDev
->pen
.dashes
= (char *)PEN_dashdotdot
;
93 physDev
->pen
.dash_len
= sizeof(PEN_dashdotdot
)/sizeof(*PEN_dashdotdot
);
96 physDev
->pen
.dashes
= (char *)PEN_alternate
;
97 physDev
->pen
.dash_len
= sizeof(PEN_alternate
)/sizeof(*PEN_alternate
);
100 FIXME("PS_USERSTYLE is not supported\n");
103 physDev
->pen
.dashes
= NULL
;
104 physDev
->pen
.dash_len
= 0;
111 /***********************************************************************
112 * SetDCPenColor (X11DRV.@)
114 COLORREF
X11DRV_SetDCPenColor( X11DRV_PDEVICE
*physDev
, COLORREF crColor
)
116 if (GetCurrentObject(physDev
->hdc
, OBJ_PEN
) == GetStockObject( DC_PEN
))
117 physDev
->pen
.pixel
= X11DRV_PALETTE_ToPhysical( physDev
, crColor
);