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 /***********************************************************************
29 * SelectPen (X11DRV.@)
31 HPEN
X11DRV_SelectPen( PHYSDEV dev
, HPEN hpen
)
33 static const char PEN_dash
[] = { 16,8 };
34 static const char PEN_dot
[] = { 4,4 };
35 static const char PEN_dashdot
[] = { 12,8,4,8 };
36 static const char PEN_dashdotdot
[] = { 12,4,4,4,4,4 };
37 static const char PEN_alternate
[] = { 1,1 };
38 static const char EXTPEN_dash
[] = { 3,1 };
39 static const char EXTPEN_dot
[] = { 1,1 };
40 static const char EXTPEN_dashdot
[] = { 3,1,1,1 };
41 static const char EXTPEN_dashdotdot
[] = { 3,1,1,1,1,1 };
42 X11DRV_PDEVICE
*physDev
= get_x11drv_dev( dev
);
46 if (!GetObjectW( hpen
, sizeof(logpen
), &logpen
))
48 /* must be an extended pen */
50 INT size
= GetObjectW( hpen
, 0, NULL
);
55 elp
= HeapAlloc( GetProcessHeap(), 0, size
);
57 GetObjectW( hpen
, size
, elp
);
58 /* FIXME: add support for user style pens */
59 logpen
.lopnStyle
= elp
->elpPenStyle
;
60 logpen
.lopnWidth
.x
= elp
->elpWidth
;
61 logpen
.lopnWidth
.y
= 0;
62 logpen
.lopnColor
= elp
->elpColor
;
64 HeapFree( GetProcessHeap(), 0, elp
);
69 physDev
->pen
.style
= logpen
.lopnStyle
& PS_STYLE_MASK
;
70 physDev
->pen
.type
= logpen
.lopnStyle
& PS_TYPE_MASK
;
71 physDev
->pen
.endcap
= logpen
.lopnStyle
& PS_ENDCAP_MASK
;
72 physDev
->pen
.linejoin
= logpen
.lopnStyle
& PS_JOIN_MASK
;
74 physDev
->pen
.width
= logpen
.lopnWidth
.x
;
75 if ((logpen
.lopnStyle
& PS_GEOMETRIC
) || (physDev
->pen
.width
>= 1))
77 physDev
->pen
.width
= X11DRV_XWStoDS( dev
->hdc
, physDev
->pen
.width
);
78 if (physDev
->pen
.width
< 0) physDev
->pen
.width
= -physDev
->pen
.width
;
81 if (physDev
->pen
.width
== 1) physDev
->pen
.width
= 0; /* Faster */
82 if (hpen
== GetStockObject( DC_PEN
))
83 logpen
.lopnColor
= GetDCPenColor( dev
->hdc
);
84 physDev
->pen
.pixel
= X11DRV_PALETTE_ToPhysical( physDev
, logpen
.lopnColor
);
85 switch(logpen
.lopnStyle
& PS_STYLE_MASK
)
88 physDev
->pen
.dash_len
= sizeof(PEN_dash
)/sizeof(*PEN_dash
);
89 memcpy(physDev
->pen
.dashes
, physDev
->pen
.ext
? EXTPEN_dash
: PEN_dash
,
90 physDev
->pen
.dash_len
);
93 physDev
->pen
.dash_len
= sizeof(PEN_dot
)/sizeof(*PEN_dot
);
94 memcpy(physDev
->pen
.dashes
, physDev
->pen
.ext
? EXTPEN_dot
: PEN_dot
,
95 physDev
->pen
.dash_len
);
98 physDev
->pen
.dash_len
= sizeof(PEN_dashdot
)/sizeof(*PEN_dashdot
);
99 memcpy(physDev
->pen
.dashes
, physDev
->pen
.ext
? EXTPEN_dashdot
: PEN_dashdot
,
100 physDev
->pen
.dash_len
);
103 physDev
->pen
.dash_len
= sizeof(PEN_dashdotdot
)/sizeof(*PEN_dashdotdot
);
104 memcpy(physDev
->pen
.dashes
, physDev
->pen
.ext
? EXTPEN_dashdotdot
: PEN_dashdotdot
,
105 physDev
->pen
.dash_len
);
108 physDev
->pen
.dash_len
= sizeof(PEN_alternate
)/sizeof(*PEN_alternate
);
109 memcpy(physDev
->pen
.dashes
, PEN_alternate
, physDev
->pen
.dash_len
);
112 FIXME("PS_USERSTYLE is not supported\n");
115 physDev
->pen
.dash_len
= 0;
118 if(physDev
->pen
.ext
&& physDev
->pen
.dash_len
&&
119 (logpen
.lopnStyle
& PS_STYLE_MASK
) != PS_ALTERNATE
)
120 for(i
= 0; i
< physDev
->pen
.dash_len
; i
++)
121 physDev
->pen
.dashes
[i
] *= (physDev
->pen
.width
? physDev
->pen
.width
: 1);
127 /***********************************************************************
128 * SetDCPenColor (X11DRV.@)
130 COLORREF
X11DRV_SetDCPenColor( PHYSDEV dev
, COLORREF crColor
)
132 X11DRV_PDEVICE
*physDev
= get_x11drv_dev( dev
);
134 if (GetCurrentObject(dev
->hdc
, OBJ_PEN
) == GetStockObject( DC_PEN
))
135 physDev
->pen
.pixel
= X11DRV_PALETTE_ToPhysical( physDev
, crColor
);