~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/winex11.drv/pen.c

Version: ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * X11DRV pen objects
  3  *
  4  * Copyright 1993 Alexandre Julliard
  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "config.h"
 22 
 23 #include "x11drv.h"
 24 
 25 
 26 static DWORD get_user_dashes( char *res, const DWORD *style, DWORD len )
 27 {
 28     DWORD i, pos, dashes[MAX_DASHLEN];
 29 
 30     len = min( len, MAX_DASHLEN );
 31     memcpy( dashes, style, len * sizeof(DWORD) );
 32     for (i = pos = 0; i < len; i++)
 33     {
 34         if (!dashes[i])  /* get rid of 0 entry */
 35         {
 36             if (i < len - 1)
 37             {
 38                 i++;
 39                 if (pos) dashes[pos - 1] += dashes[i];
 40                 else dashes[len - 1] += dashes[i];
 41             }
 42             else if (pos)
 43             {
 44                 dashes[0] += dashes[pos - 1];
 45                 pos--;
 46             }
 47         }
 48         else dashes[pos++] = dashes[i];
 49     }
 50     for (i = 0; i < pos; i++) res[i] = min( dashes[i], 255 );
 51     return pos;
 52 }
 53 
 54 /***********************************************************************
 55  *           SelectPen   (X11DRV.@)
 56  */
 57 HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern )
 58 {
 59     static const char PEN_dash[]          = { 16,8 };
 60     static const char PEN_dot[]           = { 4,4 };
 61     static const char PEN_dashdot[]       = { 12,8,4,8 };
 62     static const char PEN_dashdotdot[]    = { 12,4,4,4,4,4 };
 63     static const char PEN_alternate[]     = { 1,1 };
 64     static const char EXTPEN_dash[]       = { 3,1 };
 65     static const char EXTPEN_dot[]        = { 1,1 };
 66     static const char EXTPEN_dashdot[]    = { 3,1,1,1 };
 67     static const char EXTPEN_dashdotdot[] = { 3,1,1,1,1,1 };
 68     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
 69     LOGPEN logpen;
 70     int i;
 71     EXTLOGPEN *elp = NULL;
 72 
 73     if (!GetObjectW( hpen, sizeof(logpen), &logpen ))
 74     {
 75         /* must be an extended pen */
 76         INT size = GetObjectW( hpen, 0, NULL );
 77 
 78         if (!size) return 0;
 79 
 80         physDev->pen.ext = 1;
 81         elp = HeapAlloc( GetProcessHeap(), 0, size );
 82 
 83         GetObjectW( hpen, size, elp );
 84         logpen.lopnStyle = elp->elpPenStyle;
 85         logpen.lopnWidth.x = elp->elpWidth;
 86         logpen.lopnWidth.y = 0;
 87         logpen.lopnColor = elp->elpColor;
 88     }
 89     else
 90         physDev->pen.ext = 0;
 91 
 92     physDev->pen.style = logpen.lopnStyle & PS_STYLE_MASK;
 93     physDev->pen.type = logpen.lopnStyle & PS_TYPE_MASK;
 94     physDev->pen.endcap = logpen.lopnStyle & PS_ENDCAP_MASK;
 95     physDev->pen.linejoin = logpen.lopnStyle & PS_JOIN_MASK;
 96 
 97     physDev->pen.width = logpen.lopnWidth.x;
 98     if ((logpen.lopnStyle & PS_GEOMETRIC) || (physDev->pen.width >= 1))
 99     {
100         physDev->pen.width = X11DRV_XWStoDS( dev->hdc, physDev->pen.width );
101         if (physDev->pen.width < 0) physDev->pen.width = -physDev->pen.width;
102     }
103 
104     if (physDev->pen.width == 1) physDev->pen.width = 0;  /* Faster */
105     if (hpen == GetStockObject( DC_PEN ))
106         logpen.lopnColor = GetDCPenColor( dev->hdc );
107     physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, logpen.lopnColor );
108     switch(logpen.lopnStyle & PS_STYLE_MASK)
109     {
110       case PS_DASH:
111             physDev->pen.dash_len = sizeof(PEN_dash)/sizeof(*PEN_dash);
112             memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dash : PEN_dash,
113                    physDev->pen.dash_len);
114             break;
115       case PS_DOT:
116             physDev->pen.dash_len = sizeof(PEN_dot)/sizeof(*PEN_dot);
117             memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dot : PEN_dot,
118                    physDev->pen.dash_len);
119             break;
120       case PS_DASHDOT:
121             physDev->pen.dash_len = sizeof(PEN_dashdot)/sizeof(*PEN_dashdot);
122             memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdot : PEN_dashdot,
123                    physDev->pen.dash_len);
124             break;
125       case PS_DASHDOTDOT:
126             physDev->pen.dash_len = sizeof(PEN_dashdotdot)/sizeof(*PEN_dashdotdot);
127             memcpy(physDev->pen.dashes, physDev->pen.ext ? EXTPEN_dashdotdot : PEN_dashdotdot,
128                    physDev->pen.dash_len);
129             break;
130       case PS_ALTERNATE:
131             physDev->pen.dash_len = sizeof(PEN_alternate)/sizeof(*PEN_alternate);
132             memcpy(physDev->pen.dashes, PEN_alternate, physDev->pen.dash_len);
133             break;
134       case PS_USERSTYLE:
135             physDev->pen.dash_len = get_user_dashes( physDev->pen.dashes,
136                                                      elp->elpStyleEntry, elp->elpNumEntries );
137             break;
138       default:
139         physDev->pen.dash_len = 0;
140         break;
141     }
142     if(physDev->pen.ext && physDev->pen.dash_len && physDev->pen.width &&
143        (logpen.lopnStyle & PS_STYLE_MASK) != PS_USERSTYLE &&
144        (logpen.lopnStyle & PS_STYLE_MASK) != PS_ALTERNATE)
145         for(i = 0; i < physDev->pen.dash_len; i++)
146             physDev->pen.dashes[i] = min( physDev->pen.dashes[i] * physDev->pen.width, 255 );
147 
148     HeapFree( GetProcessHeap(), 0, elp );
149 
150     return hpen;
151 }
152 
153 
154 /***********************************************************************
155  *           SetDCPenColor (X11DRV.@)
156  */
157 COLORREF X11DRV_SetDCPenColor( PHYSDEV dev, COLORREF crColor )
158 {
159     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
160 
161     if (GetCurrentObject(dev->hdc, OBJ_PEN) == GetStockObject( DC_PEN ))
162         physDev->pen.pixel = X11DRV_PALETTE_ToPhysical( physDev, crColor );
163 
164     return crColor;
165 }
166 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.