WinPrinterContext.st
changeset 2342 78014f6a3c32
parent 2341 cf7b3de4f3ef
child 2343 b7ef200fbfad
equal deleted inserted replaced
2341:cf7b3de4f3ef 2342:78014f6a3c32
  1646 
  1646 
  1647 %{  /* NOCONTEXT */
  1647 %{  /* NOCONTEXT */
  1648     if (__isExternalAddressLike(aDC)
  1648     if (__isExternalAddressLike(aDC)
  1649      && __bothSmallInteger(x0, y0)
  1649      && __bothSmallInteger(x0, y0)
  1650      && __bothSmallInteger(x1, y1)) {
  1650      && __bothSmallInteger(x1, y1)) {
  1651 	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1651         HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1652 	COLORREF fgColor;
  1652         COLORREF fgColor;
  1653 	HANDLE prevPen, hPen;
  1653         HANDLE prevPen, hPen;
  1654 	int __x1 = __intVal(x1), __y1 = __intVal(y1);
  1654         int __x1 = __intVal(x1), __y1 = __intVal(y1);
  1655 	int lStyleSymbol, lStyleInt;
  1655         int lStyleSymbol, lStyleInt;
  1656 	int lw;
  1656         int lw;
  1657 
  1657 
  1658 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
  1658 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
  1659 		    __intVal(x0), __intVal(y0),
  1659                     __intVal(x0), __intVal(y0),
  1660 		    __x1, __y1));
  1660                     __x1, __y1));
  1661 */
  1661 */
  1662 
  1662 
  1663 	lw= __intVal(__INST(lineWidth));
  1663         lw= __intVal(__INST(lineWidth));
  1664 	lStyleSymbol= __INST(lineStyle);
  1664         lStyleSymbol= __INST(lineStyle);
  1665 
  1665 
  1666 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1666         /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1667 	    only works with lineWidth = 1  */
  1667             only works with lineWidth = 1  */
  1668 
  1668 
  1669 	if (lStyleSymbol == @symbol(solid)) {
  1669         if (lStyleSymbol == @symbol(solid)) {
  1670 	    lStyleInt= PS_SOLID;
  1670             lStyleInt= PS_SOLID;
  1671 	} else if (lStyleSymbol == @symbol(dashed)) {
  1671         } else if (lStyleSymbol == @symbol(dashed)) {
  1672 	    lStyleInt= PS_DASH;
  1672             lStyleInt= PS_DASH;
  1673 	} else if (lStyleSymbol == @symbol(dotted)) {
  1673         } else if (lStyleSymbol == @symbol(dotted)) {
  1674 	    lStyleInt= PS_DOT;
  1674             lStyleInt= PS_DOT;
  1675 	} else if (lStyleSymbol == @symbol(dashDot)) {
  1675         } else if (lStyleSymbol == @symbol(dashDot)) {
  1676 	    lStyleInt= PS_DASHDOT;
  1676             lStyleInt= PS_DASHDOT;
  1677 	} else if (lStyleSymbol == @symbol(dashDotDot)) {
  1677         } else if (lStyleSymbol == @symbol(dashDotDot)) {
  1678 	    lStyleInt= PS_DASHDOTDOT;
  1678             lStyleInt= PS_DASHDOTDOT;
  1679 	} else if (lStyleSymbol == @symbol(insideFrame)) {
  1679         } else if (lStyleSymbol == @symbol(insideFrame)) {
  1680 	    lStyleInt= PS_INSIDEFRAME;
  1680             lStyleInt= PS_INSIDEFRAME;
  1681 	} else
  1681         } else
  1682 	    lStyleInt= PS_SOLID;
  1682             lStyleInt= PS_SOLID;
  1683 
  1683 
  1684 	fgColor = GetTextColor(hDC);
  1684         fgColor = GetTextColor(hDC);
  1685 	hPen = CreatePen(lStyleInt, lw, fgColor);
  1685         hPen = CreatePen(lStyleInt, lw, fgColor);
  1686 
  1686 
  1687 	prevPen = SelectObject(hDC, hPen);
  1687         prevPen = SelectObject(hDC, hPen);
  1688 
  1688 
  1689 	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
  1689         MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
  1690 
  1690 
  1691 	LineTo(hDC, __x1, __y1);
  1691         LineTo(hDC, __x1, __y1);
  1692 
  1692 
  1693 	/*
  1693         /*
  1694 	 * end-point ...
  1694          * end-point ...
  1695 	 */
  1695          */
  1696 	LineTo(hDC, __x1+1, __y1);
  1696         // LineTo(hDC, __x1+1, __y1);
  1697 
  1697 
  1698 	SelectObject(hDC, prevPen);
  1698         SelectObject(hDC, prevPen);
  1699 	DeleteObject(hPen);
  1699         DeleteObject(hPen);
  1700 
  1700 
  1701 	RETURN ( self );
  1701         RETURN ( self );
  1702     }
  1702     }
  1703 %}
  1703 %}
  1704 !
  1704 !
  1705 
  1705 
  1706 displayPointX:px y:py in:ignoredDrawableId with:aDC
  1706 displayPointX:px y:py in:ignoredDrawableId with:aDC
  1920     int xL, yT;
  1920     int xL, yT;
  1921     if (__isExternalAddressLike(aDC)
  1921     if (__isExternalAddressLike(aDC)
  1922      && __bothSmallInteger(x, y)
  1922      && __bothSmallInteger(x, y)
  1923      && __bothSmallInteger(width, height)) {
  1923      && __bothSmallInteger(width, height)) {
  1924 
  1924 
  1925 	xL = __intVal(x);
  1925         xL = __intVal(x);
  1926 	yT = __intVal(y);
  1926         yT = __intVal(y);
  1927 	w = __intVal(width);
  1927         w = __intVal(width);
  1928 	h = __intVal(height);
  1928         h = __intVal(height);
  1929 
  1929 
  1930 	DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
  1930         DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
  1931 
  1931 
  1932 	if ((w >= 0) && (h >= 0)) {
  1932         if ((w >= 0) && (h >= 0)) {
  1933 	    HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1933             HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1934 	    COLORREF fgColor;
  1934             COLORREF fgColor;
  1935 	    HANDLE prevPen, hPen;
  1935             HANDLE prevPen, hPen;
  1936 	    int lStyleSymbol, lStyleInt;
  1936             int lStyleSymbol, lStyleInt;
  1937 
  1937 
  1938 	    int lw;
  1938             int lw;
  1939 
  1939 
  1940 	    lw= __intVal(__INST(lineWidth));
  1940             lw= __intVal(__INST(lineWidth));
  1941 	    lStyleSymbol= __INST(lineStyle);
  1941             lStyleSymbol= __INST(lineStyle);
  1942 
  1942 
  1943 	    /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1943             /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1944 		only works with lineWidth = 1  */
  1944                 only works with lineWidth = 1  */
  1945 
  1945 
  1946 	    if (lStyleSymbol == @symbol(solid)) {
  1946             if (lStyleSymbol == @symbol(solid)) {
  1947 		lStyleInt= PS_SOLID;
  1947                 lStyleInt= PS_SOLID;
  1948 	    } else if (lStyleSymbol == @symbol(dashed)) {
  1948             } else if (lStyleSymbol == @symbol(dashed)) {
  1949 		lStyleInt= PS_DASH;
  1949                 lStyleInt= PS_DASH;
  1950 	    } else if (lStyleSymbol == @symbol(dotted)) {
  1950             } else if (lStyleSymbol == @symbol(dotted)) {
  1951 		lStyleInt= PS_DOT;
  1951                 lStyleInt= PS_DOT;
  1952 	    } else if (lStyleSymbol == @symbol(dashDot)) {
  1952             } else if (lStyleSymbol == @symbol(dashDot)) {
  1953 		lStyleInt= PS_DASHDOT;
  1953                 lStyleInt= PS_DASHDOT;
  1954 	    } else if (lStyleSymbol == @symbol(dashDotDot)) {
  1954             } else if (lStyleSymbol == @symbol(dashDotDot)) {
  1955 		lStyleInt= PS_DASHDOTDOT;
  1955                 lStyleInt= PS_DASHDOTDOT;
  1956 	    } else if (lStyleSymbol == @symbol(insideFrame)) {
  1956             } else if (lStyleSymbol == @symbol(insideFrame)) {
  1957 		lStyleInt= PS_INSIDEFRAME;
  1957                 lStyleInt= PS_INSIDEFRAME;
  1958 	    } else
  1958             } else
  1959 		lStyleInt= PS_SOLID;
  1959                 lStyleInt= PS_SOLID;
  1960 
  1960 
  1961 	    fgColor = GetTextColor(hDC);
  1961             fgColor = GetTextColor(hDC);
  1962 	    hPen = CreatePen(lStyleInt, lw, fgColor);
  1962             hPen = CreatePen(lStyleInt, lw, fgColor);
  1963 
  1963 
  1964 	    prevPen = SelectObject(hDC, hPen);
  1964             prevPen = SelectObject(hDC, hPen);
  1965 	    MoveToEx(hDC, xL, yT, NULL);
  1965             MoveToEx(hDC, xL, yT, NULL);
  1966 	    LineTo(hDC, xL+w, yT);       // to top-right
  1966             LineTo(hDC, xL+w, yT);       // to top-right
  1967 	    LineTo(hDC, xL+w, yT+h);     // to bot-right
  1967             LineTo(hDC, xL+w, yT+h);     // to bot-right
  1968 	    MoveToEx(hDC, xL, yT, NULL); // back to top-left
  1968             MoveToEx(hDC, xL, yT, NULL); // back to top-left
  1969 	    LineTo(hDC, xL, yT+h);       // to bot-left
  1969             LineTo(hDC, xL, yT+h);       // to bot-left
  1970 	    LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
  1970             // LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
  1971 
  1971             LineTo(hDC, xL+w,   yT+h);   // move pen one pixel more
  1972 	    SelectObject(hDC, prevPen);
  1972 
  1973 	    DeleteObject(hPen);
  1973             SelectObject(hDC, prevPen);
  1974 
  1974             DeleteObject(hPen);
  1975 	}
  1975 
  1976 	RETURN ( self );
  1976         }
       
  1977         RETURN ( self );
  1977     }
  1978     }
  1978 %}.
  1979 %}.
  1979     self primitiveFailed
  1980     self primitiveFailed
  1980 
  1981 
  1981     "Created: / 28-07-2006 / 20:18:25 / fm"
  1982     "Created: / 28-07-2006 / 20:18:25 / fm"
  2438                 hBrush = CreateSolidBrush(fgColor); 
  2439                 hBrush = CreateSolidBrush(fgColor); 
  2439             }
  2440             }
  2440 
  2441 
  2441             rct.left = __intVal(x);
  2442             rct.left = __intVal(x);
  2442             rct.top  = __intVal(y);
  2443             rct.top  = __intVal(y);
  2443             rct.right  = rct.left + w + 1;
  2444             rct.right  = rct.left + w; // + 1;
  2444             rct.bottom = rct.top  + h + 1;
  2445             rct.bottom = rct.top  + h; // + 1;
  2445 
  2446 
  2446            prevBrush = SelectObject(hDC, hBrush);
  2447            prevBrush = SelectObject(hDC, hBrush);
  2447            FillRect(hDC, &rct, hBrush);
  2448            FillRect(hDC, &rct, hBrush);
  2448            SelectObject(hDC, prevBrush);
  2449            SelectObject(hDC, prevBrush);
  2449            DeleteObject(hBrush);
  2450            DeleteObject(hBrush);
  2940            height: sortedImage height
  2941            height: sortedImage height
  2941              with: gcId.
  2942              with: gcId.
  2942 !
  2943 !
  2943 
  2944 
  2944 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  2945 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  2945 			  width:imageWidth height:imageHeight
  2946                           width:imageWidth height:imageHeight
  2946 			      x:srcx y:srcy
  2947                               x:srcx y:srcy
  2947 			   into:ignoredDrawableId
  2948                            into:ignoredDrawableId
  2948 			      x:dstx y:dsty
  2949                               x:dstx y:dsty
  2949 			  width:w height:h
  2950                           width:w height:h
  2950 			   with:aGCId
  2951                            with:aGCId
  2951 
  2952 
  2952     "draw a bitImage which has depth id, width iw and height ih into
  2953     "draw a bitImage which has depth id, width iw and height ih into
  2953      the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
  2954      the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
  2954      Individual source pixels have bitsPerPixel bits, allowing to draw
  2955      Individual source pixels have bitsPerPixel bits, allowing to draw
  2955      depth and pixel-units to be different.
  2956      depth and pixel-units to be different.
  2961     "
  2962     "
  2962      sorry; I had to separate it into 2 methods, since XPutImage needs
  2963      sorry; I had to separate it into 2 methods, since XPutImage needs
  2963      an unlimited stack, and thus cannot send primitiveFailed
  2964      an unlimited stack, and thus cannot send primitiveFailed
  2964     "
  2965     "
  2965     (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  2966     (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  2966 					width:imageWidth height:imageHeight
  2967                                         width:imageWidth height:imageHeight
  2967 					     x:srcx y:srcy
  2968                                              x:srcx y:srcy
  2968 					  into:ignoredDrawableId
  2969                                           into:ignoredDrawableId
  2969 					     x:dstx y:dsty
  2970                                              x:(dstx rounded) y:(dsty rounded)
  2970 					 width:w height:h
  2971                                          width:w height:h
  2971 					  with:aGCId)
  2972                                           with:aGCId)
  2972     ifFalse:[
  2973     ifFalse:[
  2973 	"
  2974         "
  2974 	 also happens, if a segmentation violation occurs in the
  2975          also happens, if a segmentation violation occurs in the
  2975 	 XPutImage ...
  2976          XPutImage ...
  2976 	"
  2977         "
  2977 	self primitiveFailed
  2978         self primitiveFailed
  2978     ].
  2979     ].
  2979 !
  2980 !
  2980 
  2981 
  2981 drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
  2982 drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
  2982                               width:imageWidth height:imageHeight
  2983                               width:imageWidth height:imageHeight
  2999      an unlimited stack, and thus cannot send primitiveFailed
  3000      an unlimited stack, and thus cannot send primitiveFailed
  3000     "
  3001     "
  3001     (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
  3002     (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
  3002                               width:imageWidth height:imageHeight
  3003                               width:imageWidth height:imageHeight
  3003                                into:ignoredDrawableId
  3004                                into:ignoredDrawableId
  3004                                   x:dstx y:dsty
  3005                                   x:(dstx rounded) y:(dsty rounded)
  3005                               width:w height:h
  3006                               width:w height:h
  3006                                with:aGCId)
  3007                                with:aGCId)
  3007     ifFalse:[
  3008     ifFalse:[
  3008         "
  3009         "
  3009          also happens, if a segmentation violation occurs in the
  3010          also happens, if a segmentation violation occurs in the
  5209 ! !
  5210 ! !
  5210 
  5211 
  5211 !WinPrinterContext class methodsFor:'documentation'!
  5212 !WinPrinterContext class methodsFor:'documentation'!
  5212 
  5213 
  5213 version
  5214 version
  5214     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.19 2007-10-19 15:25:52 fm Exp $'
  5215     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.20 2007-10-23 05:08:45 ca Exp $'
  5215 ! !
  5216 ! !