Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 1 | /* |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 2 | * X11DRV pen objects |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1993 Alexandre Julliard |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
Patrik Stridvall | ab121e7 | 1999-02-04 11:11:01 +0000 | [diff] [blame] | 21 | #include "config.h" |
| 22 | |
Patrik Stridvall | ab121e7 | 1999-02-04 11:11:01 +0000 | [diff] [blame] | 23 | #include "x11drv.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 24 | #include "wine/debug.h" |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 25 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 26 | WINE_DEFAULT_DEBUG_CHANNEL(x11drv); |
Francois Gouget | 345acc9 | 2000-12-24 20:16:25 +0000 | [diff] [blame] | 27 | |
| 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 }; |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 33 | |
| 34 | /*********************************************************************** |
Patrik Stridvall | 14c96c1 | 2002-04-03 02:37:09 +0000 | [diff] [blame] | 35 | * SelectPen (X11DRV.@) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 36 | */ |
Alexandre Julliard | e21c15e | 2002-03-28 22:22:05 +0000 | [diff] [blame] | 37 | HPEN X11DRV_SelectPen( X11DRV_PDEVICE *physDev, HPEN hpen ) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 38 | { |
Alexandre Julliard | e811f9c | 2001-08-16 19:13:52 +0000 | [diff] [blame] | 39 | LOGPEN logpen; |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 40 | |
Dmitry Timoshkov | eb893bd | 2006-01-30 18:17:07 +0100 | [diff] [blame] | 41 | if (!GetObjectW( hpen, sizeof(logpen), &logpen )) |
| 42 | { |
| 43 | /* must be an extended pen */ |
Dmitry Timoshkov | 434a60b | 2006-03-09 15:12:43 +0800 | [diff] [blame] | 44 | EXTLOGPEN *elp; |
| 45 | INT size = GetObjectW( hpen, 0, NULL ); |
| 46 | |
| 47 | if (!size) return 0; |
| 48 | |
| 49 | elp = HeapAlloc( GetProcessHeap(), 0, size ); |
| 50 | |
| 51 | GetObjectW( hpen, size, elp ); |
| 52 | /* FIXME: add support for user style pens */ |
| 53 | logpen.lopnStyle = elp->elpPenStyle; |
| 54 | logpen.lopnWidth.x = elp->elpWidth; |
Dmitry Timoshkov | eb893bd | 2006-01-30 18:17:07 +0100 | [diff] [blame] | 55 | logpen.lopnWidth.y = 0; |
Dmitry Timoshkov | 434a60b | 2006-03-09 15:12:43 +0800 | [diff] [blame] | 56 | logpen.lopnColor = elp->elpColor; |
| 57 | |
| 58 | HeapFree( GetProcessHeap(), 0, elp ); |
Dmitry Timoshkov | eb893bd | 2006-01-30 18:17:07 +0100 | [diff] [blame] | 59 | } |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 60 | |
Alexandre Julliard | e811f9c | 2001-08-16 19:13:52 +0000 | [diff] [blame] | 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; |
| 65 | |
Dmitry Timoshkov | ef4fc8f | 2006-02-01 12:30:15 +0100 | [diff] [blame] | 66 | physDev->pen.width = logpen.lopnWidth.x; |
Dmitry Timoshkov | 75e8166 | 2006-02-08 12:35:29 +0100 | [diff] [blame] | 67 | if ((logpen.lopnStyle & PS_GEOMETRIC) || (physDev->pen.width > 1)) |
Dmitry Timoshkov | ef4fc8f | 2006-02-01 12:30:15 +0100 | [diff] [blame] | 68 | { |
| 69 | physDev->pen.width = X11DRV_XWStoDS( physDev, physDev->pen.width ); |
| 70 | if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width; |
| 71 | } |
| 72 | |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 73 | if (physDev->pen.width == 1) physDev->pen.width = 0; /* Faster */ |
Ulrich Czekalla | 16ff668 | 2003-11-05 01:43:57 +0000 | [diff] [blame] | 74 | if (hpen == GetStockObject( DC_PEN )) |
Alexandre Julliard | 7342390 | 2004-01-15 06:19:35 +0000 | [diff] [blame] | 75 | logpen.lopnColor = GetDCPenColor( physDev->hdc ); |
Alexandre Julliard | e21c15e | 2002-03-28 22:22:05 +0000 | [diff] [blame] | 76 | physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor ); |
Alexandre Julliard | e811f9c | 2001-08-16 19:13:52 +0000 | [diff] [blame] | 77 | switch(logpen.lopnStyle & PS_STYLE_MASK) |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 78 | { |
| 79 | case PS_DASH: |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 80 | physDev->pen.dashes = (char *)PEN_dash; |
Francois Gouget | 5f74d67 | 2000-10-31 02:02:42 +0000 | [diff] [blame] | 81 | physDev->pen.dash_len = sizeof(PEN_dash)/sizeof(*PEN_dash); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 82 | break; |
| 83 | case PS_DOT: |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 84 | physDev->pen.dashes = (char *)PEN_dot; |
Francois Gouget | 5f74d67 | 2000-10-31 02:02:42 +0000 | [diff] [blame] | 85 | physDev->pen.dash_len = sizeof(PEN_dot)/sizeof(*PEN_dot); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 86 | break; |
| 87 | case PS_DASHDOT: |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 88 | physDev->pen.dashes = (char *)PEN_dashdot; |
Francois Gouget | 5f74d67 | 2000-10-31 02:02:42 +0000 | [diff] [blame] | 89 | physDev->pen.dash_len = sizeof(PEN_dashdot)/sizeof(*PEN_dashdot); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 90 | break; |
| 91 | case PS_DASHDOTDOT: |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 92 | physDev->pen.dashes = (char *)PEN_dashdotdot; |
Francois Gouget | 5f74d67 | 2000-10-31 02:02:42 +0000 | [diff] [blame] | 93 | physDev->pen.dash_len = sizeof(PEN_dashdotdot)/sizeof(*PEN_dashdotdot); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 94 | break; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 95 | case PS_ALTERNATE: |
Huw D M Davies | 9c68faa | 1998-11-25 12:36:03 +0000 | [diff] [blame] | 96 | physDev->pen.dashes = (char *)PEN_alternate; |
Francois Gouget | 5f74d67 | 2000-10-31 02:02:42 +0000 | [diff] [blame] | 97 | physDev->pen.dash_len = sizeof(PEN_alternate)/sizeof(*PEN_alternate); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 98 | break; |
| 99 | case PS_USERSTYLE: |
Francois Gouget | 345acc9 | 2000-12-24 20:16:25 +0000 | [diff] [blame] | 100 | FIXME("PS_USERSTYLE is not supported\n"); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 101 | break; |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 102 | } |
Alexandre Julliard | e21c15e | 2002-03-28 22:22:05 +0000 | [diff] [blame] | 103 | return hpen; |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 104 | } |
Ulrich Czekalla | 16ff668 | 2003-11-05 01:43:57 +0000 | [diff] [blame] | 105 | |
| 106 | |
| 107 | /*********************************************************************** |
| 108 | * SetDCPenColor (X11DRV.@) |
| 109 | */ |
| 110 | COLORREF X11DRV_SetDCPenColor( X11DRV_PDEVICE *physDev, COLORREF crColor ) |
| 111 | { |
| 112 | if (GetCurrentObject(physDev->hdc, OBJ_PEN) == GetStockObject( DC_PEN )) |
| 113 | physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, crColor ); |
| 114 | |
| 115 | return crColor; |
| 116 | } |