WinPrinterContext.st
branchjv
changeset 3457 dcc643202507
parent 3190 437b1425507e
child 3478 45ad75b68d16
equal deleted inserted replaced
3456:f97405cc78a3 3457:dcc643202507
  1094 getLogicalPixelSizeY
  1094 getLogicalPixelSizeY
  1095     ^ printerInfo printQuality ? 600
  1095     ^ printerInfo printQuality ? 600
  1096 !
  1096 !
  1097 
  1097 
  1098 numberOfColorBitsPerPixel
  1098 numberOfColorBitsPerPixel
  1099     ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel"
  1099     ^ OperatingSystem getDeviceCaps:self gcId index:12 "Bitspixel"
  1100 
  1100 
  1101     "Created: / 03-08-2006 / 09:58:18 / fm"
  1101     "Created: / 03-08-2006 / 09:58:18 / fm"
  1102     "Modified: / 10-10-2006 / 18:15:40 / cg"
  1102     "Modified: / 10-10-2006 / 18:15:40 / cg"
  1103 !
  1103 !
  1104 
  1104 
  1105 physicalOffsetX
  1105 physicalOffsetX
  1106     ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX"
  1106     ^ OperatingSystem getDeviceCaps:self gcId index:112 "PhysicalOffsetX"
  1107 
  1107 
  1108     "Created: / 01-08-2006 / 16:28:34 / fm"
  1108     "Created: / 01-08-2006 / 16:28:34 / fm"
  1109     "Modified: / 16-04-2007 / 12:52:06 / cg"
  1109     "Modified: / 16-04-2007 / 12:52:06 / cg"
  1110 !
  1110 !
  1111 
  1111 
  1112 physicalOffsetY
  1112 physicalOffsetY
  1113     ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY"
  1113     ^ OperatingSystem getDeviceCaps:self gcId index:113 "PhysicalOffsetY"
  1114 
  1114 
  1115     "Created: / 01-08-2006 / 16:28:34 / fm"
  1115     "Created: / 01-08-2006 / 16:28:34 / fm"
  1116     "Modified: / 16-04-2007 / 12:52:01 / cg"
  1116     "Modified: / 16-04-2007 / 12:52:01 / cg"
  1117 !
  1117 !
  1118 
  1118 
  1119 pixelsPerInchOfScreenHeight
  1119 pixelsPerInchOfScreenHeight
  1120     ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
  1120     ^ OperatingSystem getDeviceCaps:self gcId index:90 "Logpixelsy"
  1121 
  1121 
  1122     "Created: / 01-08-2006 / 16:29:16 / fm"
  1122     "Created: / 01-08-2006 / 16:29:16 / fm"
  1123 !
  1123 !
  1124 
  1124 
  1125 pixelsPerInchOfScreenWidth
  1125 pixelsPerInchOfScreenWidth
  1126     ^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx"
  1126     ^ OperatingSystem getDeviceCaps:self gcId index:88 "Logpixelsx"
  1127 
  1127 
  1128     "Created: / 01-08-2006 / 16:28:34 / fm"
  1128     "Created: / 01-08-2006 / 16:28:34 / fm"
  1129 !
  1129 !
  1130 
  1130 
  1131 printerHeightArea
  1131 printerHeightArea
  1132     ^ (OperatingSystem getDeviceCaps:gcId index:10)
  1132     ^ (OperatingSystem getDeviceCaps:self gcId index:10)
  1133 
  1133 
  1134     "Modified: / 10-10-2006 / 18:18:31 / cg"
  1134     "Modified: / 10-10-2006 / 18:18:31 / cg"
  1135 !
  1135 !
  1136 
  1136 
  1137 printerPhysicalHeight
  1137 printerPhysicalHeight
  1138     ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight"
  1138     ^ OperatingSystem getDeviceCaps:self gcId "deviceContext" index:111 "PhysicalHeight"
  1139 
  1139 
  1140     "Created: / 01-08-2006 / 16:14:08 / fm"
  1140     "Created: / 01-08-2006 / 16:14:08 / fm"
  1141 !
  1141 !
  1142 
  1142 
  1143 printerPhysicalWidth
  1143 printerPhysicalWidth
  1144     ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth"
  1144     ^ OperatingSystem getDeviceCaps:self gcId "deviceContext" index:110 "PhysicalWidth"
  1145 
  1145 
  1146     "Created: / 01-08-2006 / 16:14:08 / fm"
  1146     "Created: / 01-08-2006 / 16:14:08 / fm"
  1147 !
  1147 !
  1148 
  1148 
  1149 printerWidthArea
  1149 printerWidthArea
  1150     ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
  1150     ^ OperatingSystem getDeviceCaps:self gcId "deviceContext" index:8 "Horzres"
  1151 
  1151 
  1152     "Created: / 01-08-2006 / 16:14:08 / fm"
  1152     "Created: / 01-08-2006 / 16:14:08 / fm"
  1153 !
  1153 !
  1154 
  1154 
  1155 supportedImageFormats
  1155 supportedImageFormats
  1322 !WinPrinterContext methodsFor:'context stuff'!
  1322 !WinPrinterContext methodsFor:'context stuff'!
  1323 
  1323 
  1324 getPenFor:aDC
  1324 getPenFor:aDC
  1325     "set line attributes"
  1325     "set line attributes"
  1326 
  1326 
       
  1327     | lineWidthObj lineStyleObj capStyleObj joinStyleObj |
       
  1328 
       
  1329 	lineWidthObj := self lineWidth.
       
  1330 	lineStyleObj := self lineStyle.
       
  1331 	 capStyleObj := self capStyle.
       
  1332 	joinStyleObj := self joinStyle.
       
  1333 
  1327 %{  /* NOCONTEXT */
  1334 %{  /* NOCONTEXT */
  1328 
  1335 
  1329     if (__isExternalAddressLike(aDC)
  1336     if (__isExternalAddressLike(aDC)
  1330      && __isSmallInteger(__INST(lineWidth))) {
  1337      && __isSmallInteger(lineWidthObj)) {
  1331 	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1338 	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1332 	COLORREF fgColor;
  1339 	COLORREF fgColor;
  1333 	HANDLE hPen, prevPen;
  1340 	HANDLE hPen, prevPen;
  1334 	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
  1341 	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
  1335 
  1342 
  1336 	lineWidth= __intVal(__INST(lineWidth));
  1343 	lineWidth= __intVal(lineWidthObj);
  1337 
  1344 
  1338 	if (__INST(lineStyle) == @symbol(solid)) {
  1345 	if (lineStyleObj == @symbol(solid)) {
  1339 	    lineStyleInt= PS_SOLID;
  1346 	    lineStyleInt= PS_SOLID;
  1340 	} else if (__INST(lineStyle) == @symbol(dashed)) {
  1347 	} else if (lineStyleObj == @symbol(dashed)) {
  1341 	    lineStyleInt= PS_DASH;
  1348 	    lineStyleInt= PS_DASH;
  1342 	} else if (__INST(lineStyle) == @symbol(dotted)) {
  1349 	} else if (lineStyleObj == @symbol(dotted)) {
  1343 	    lineStyleInt= PS_DOT;
  1350 	    lineStyleInt= PS_DOT;
  1344 	} else if (__INST(lineStyle) == @symbol(dashDot)) {
  1351 	} else if (lineStyleObj == @symbol(dashDot)) {
  1345 	    lineStyleInt= PS_DASHDOT;
  1352 	    lineStyleInt= PS_DASHDOT;
  1346 	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
  1353 	} else if (lineStyleObj == @symbol(dashDotDot)) {
  1347 	    lineStyleInt= PS_DASHDOTDOT;
  1354 	    lineStyleInt= PS_DASHDOTDOT;
  1348 	} else
  1355 	} else
  1349 	    lineStyleInt= PS_SOLID;
  1356 	    lineStyleInt= PS_SOLID;
  1350 
  1357 
  1351 	if (__INST(capStyle) == @symbol(round)) {
  1358 	if (capStyleObj == @symbol(round)) {
  1352 	    capStyleInt= PS_ENDCAP_ROUND;
  1359 	    capStyleInt= PS_ENDCAP_ROUND;
  1353 	} else if (__INST(capStyle) == @symbol(square)) {
  1360 	} else if (capStyleObj == @symbol(square)) {
  1354 	    capStyleInt= PS_ENDCAP_SQUARE;
  1361 	    capStyleInt= PS_ENDCAP_SQUARE;
  1355 	} else if (__INST(capStyle) == @symbol(flat)) {
  1362 	} else if (capStyleObj == @symbol(flat)) {
  1356 	    capStyleInt= PS_ENDCAP_FLAT;
  1363 	    capStyleInt= PS_ENDCAP_FLAT;
  1357 	} else
  1364 	} else
  1358 	    capStyleInt= PS_ENDCAP_FLAT;
  1365 	    capStyleInt= PS_ENDCAP_FLAT;
  1359 
  1366 
  1360 	if (__INST(joinStyle) == @symbol(bevel)) {
  1367 	if (joinStyleObj == @symbol(bevel)) {
  1361 	    joinStyleInt= PS_JOIN_BEVEL;
  1368 	    joinStyleInt= PS_JOIN_BEVEL;
  1362 	} else if (__INST(joinStyle) == @symbol(miter)) {
  1369 	} else if (joinStyleObj== @symbol(miter)) {
  1363 	    joinStyleInt= PS_JOIN_MITER;
  1370 	    joinStyleInt= PS_JOIN_MITER;
  1364 	} else if (__INST(joinStyle) == @symbol(round)) {
  1371 	} else if (joinStyleObj == @symbol(round)) {
  1365 	    joinStyleInt= PS_JOIN_ROUND;
  1372 	    joinStyleInt= PS_JOIN_ROUND;
  1366 	} else
  1373 	} else
  1367 	    joinStyleInt= PS_JOIN_MITER;
  1374 	    joinStyleInt= PS_JOIN_MITER;
  1368 
  1375 
  1369 
  1376 
  1380 !
  1387 !
  1381 
  1388 
  1382 getPenForContext
  1389 getPenForContext
  1383     "set line attributes"
  1390     "set line attributes"
  1384 
  1391 
       
  1392    | gcId  lineWidthObj lineStyleObj capStyleObj joinStyleObj |
       
  1393 
       
  1394    gcId := self gcId.
       
  1395 	lineWidthObj := self lineWidth.
       
  1396 	lineStyleObj := self lineStyle.
       
  1397 	 capStyleObj := self capStyle.
       
  1398 	joinStyleObj := self joinStyle.
       
  1399 
  1385 %{  /* NOCONTEXT */
  1400 %{  /* NOCONTEXT */
  1386 
  1401 
  1387     if (__isExternalAddressLike(__INST(gcId))
  1402     if (__isExternalAddressLike(gcId)
  1388      && __isSmallInteger(__INST(lineWidth))) {
  1403      && __isSmallInteger(lineWidthObj) ) {
  1389 	HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
  1404 	HANDLE hDC = (HANDLE)(__externalAddressVal(gcId));
  1390 	COLORREF fgColor;
  1405 	COLORREF fgColor;
  1391 	HANDLE hPen;
  1406 	HANDLE hPen;
  1392 	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
  1407 	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
  1393 
  1408 
  1394 	lineWidth= __INST(lineWidth);
  1409 	lineWidth= lineWidthObj;
  1395 
  1410 
  1396 	if (__INST(lineStyle) == @symbol(solid)) {
  1411 	if (lineStyleObj == @symbol(solid)) {
  1397 	    lineStyleInt= PS_SOLID;
  1412 	    lineStyleInt= PS_SOLID;
  1398 	} else if (__INST(lineStyle) == @symbol(dashed)) {
  1413 	} else if (lineStyleObj == @symbol(dashed)) {
  1399 	    lineStyleInt= PS_DASH;
  1414 	    lineStyleInt= PS_DASH;
  1400 	} else if (__INST(lineStyle) == @symbol(dotted)) {
  1415 	} else if (lineStyleObj == @symbol(dotted)) {
  1401 	    lineStyleInt= PS_DOT;
  1416 	    lineStyleInt= PS_DOT;
  1402 	} else if (__INST(lineStyle) == @symbol(dashDot)) {
  1417 	} else if (lineStyleObj == @symbol(dashDot)) {
  1403 	    lineStyleInt= PS_DASHDOT;
  1418 	    lineStyleInt= PS_DASHDOT;
  1404 	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
  1419 	} else if (lineStyleObj == @symbol(dashDotDot)) {
  1405 	    lineStyleInt= PS_DASHDOTDOT;
  1420 	    lineStyleInt= PS_DASHDOTDOT;
  1406 	} else
  1421 	} else
  1407 	    lineStyleInt= PS_SOLID;
  1422 	    lineStyleInt= PS_SOLID;
  1408 
  1423 
  1409 	if (__INST(capStyle) == @symbol(round)) {
  1424 	if (capStyleObj == @symbol(round)) {
  1410 	    capStyleInt= PS_ENDCAP_ROUND;
  1425 	    capStyleInt= PS_ENDCAP_ROUND;
  1411 	} else if (__INST(capStyle) == @symbol(square)) {
  1426 	} else if (capStyleObj == @symbol(square)) {
  1412 	    capStyleInt= PS_ENDCAP_SQUARE;
  1427 	    capStyleInt= PS_ENDCAP_SQUARE;
  1413 	} else if (__INST(capStyle) == @symbol(flat)) {
  1428 	} else if (capStyleObj == @symbol(flat)) {
  1414 	    capStyleInt= PS_ENDCAP_FLAT;
  1429 	    capStyleInt= PS_ENDCAP_FLAT;
  1415 	} else
  1430 	} else
  1416 	    capStyleInt= PS_ENDCAP_FLAT;
  1431 	    capStyleInt= PS_ENDCAP_FLAT;
  1417 
  1432 
  1418 	if (__INST(joinStyle) == @symbol(bevel)) {
  1433 	if (joinStyleObj == @symbol(bevel)) {
  1419 	    joinStyleInt= PS_JOIN_BEVEL;
  1434 	    joinStyleInt= PS_JOIN_BEVEL;
  1420 	} else if (__INST(joinStyle) == @symbol(miter)) {
  1435 	} else if (joinStyleObj == @symbol(miter)) {
  1421 	    joinStyleInt= PS_JOIN_MITER;
  1436 	    joinStyleInt= PS_JOIN_MITER;
  1422 	} else if (__INST(joinStyle) == @symbol(round)) {
  1437 	} else if (joinStyleObj== @symbol(round)) {
  1423 	    joinStyleInt= PS_JOIN_ROUND;
  1438 	    joinStyleInt= PS_JOIN_ROUND;
  1424 	} else
  1439 	} else
  1425 	    joinStyleInt= PS_JOIN_MITER;
  1440 	    joinStyleInt= PS_JOIN_MITER;
  1426 
  1441 
  1427 
  1442 
  1649 setViewportOrg: aPoint
  1664 setViewportOrg: aPoint
  1650 
  1665 
  1651     "Sets the viewport origin (LOGICAL point (0,0)) of the device context"
  1666     "Sets the viewport origin (LOGICAL point (0,0)) of the device context"
  1652 
  1667 
  1653     ^ OperatingSystem
  1668     ^ OperatingSystem
  1654 	    setViewportOrg: gcId "deviceContext"
  1669 	    setViewportOrg: self gcId "deviceContext"
  1655 	    x: aPoint x
  1670 	    x: aPoint x
  1656 	    y: aPoint y
  1671 	    y: aPoint y
  1657 	    oldOrigin: nil
  1672 	    oldOrigin: nil
  1658 
  1673 
  1659     "Created: / 01-08-2006 / 16:14:08 / fm"
  1674     "Created: / 01-08-2006 / 16:14:08 / fm"
  1663 
  1678 
  1664 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aDC
  1679 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aDC
  1665     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
  1680     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
  1666      The angles may be floats or integer - they are given in degrees."
  1681      The angles may be floats or integer - they are given in degrees."
  1667 
  1682 
       
  1683      | lineWidthObj lineStyleObj |
       
  1684 
       
  1685      lineWidthObj := self lineWidth.
       
  1686      lineStyleObj := self lineStyle.
  1668 %{
  1687 %{
  1669     int __x, __y, w, h;
  1688     int __x, __y, w, h;
  1670     float angle1, angle2;
  1689     float angle1, angle2;
  1671     double f;
  1690     double f;
  1672 
  1691 
  1702 	COLORREF fgColor;
  1721 	COLORREF fgColor;
  1703 	OBJ lStyleSymbol;
  1722 	OBJ lStyleSymbol;
  1704 	int lStyleInt;
  1723 	int lStyleInt;
  1705 	int lw;
  1724 	int lw;
  1706 
  1725 
  1707 	lw= __intVal(__INST(lineWidth));
  1726 	lw= __intVal(lineWidthObj);
  1708 	lStyleSymbol= __INST(lineStyle);
  1727 	lStyleSymbol= lineStyleObj;
  1709 
  1728 
  1710 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1729 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1711 	    only works with lineWidth = 1  */
  1730 	    only works with lineWidth = 1  */
  1712 
  1731 
  1713 	if (lStyleSymbol == @symbol(solid)) {
  1732 	if (lStyleSymbol == @symbol(solid)) {
  1781 !
  1800 !
  1782 
  1801 
  1783 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
  1802 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
  1784     "draw a line. If the coordinates are not integers, an error is triggered."
  1803     "draw a line. If the coordinates are not integers, an error is triggered."
  1785 
  1804 
  1786 %{  /* NOCONTEXT */
  1805      | lineWidthObj lineStyleObj |
       
  1806 
       
  1807      lineWidthObj := self lineWidth.
       
  1808      lineStyleObj := self lineStyle.
       
  1809 
       
  1810 %{ 
  1787     if (__isExternalAddressLike(aDC)
  1811     if (__isExternalAddressLike(aDC)
  1788      && __bothSmallInteger(x0, y0)
  1812      && __bothSmallInteger(x0, y0)
  1789      && __bothSmallInteger(x1, y1)) {
  1813      && __bothSmallInteger(x1, y1)) {
  1790 	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1814 	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
  1791 	COLORREF fgColor;
  1815 	COLORREF fgColor;
  1798 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
  1822 /*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
  1799 		    __intVal(x0), __intVal(y0),
  1823 		    __intVal(x0), __intVal(y0),
  1800 		    __x1, __y1));
  1824 		    __x1, __y1));
  1801 */
  1825 */
  1802 
  1826 
  1803 	lw= __intVal(__INST(lineWidth));
  1827 	lw= __intVal(lineWidthObj);
  1804 	lStyleSymbol= __INST(lineStyle);
  1828 	lStyleSymbol= lineStyleObj;
  1805 
  1829 
  1806 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1830 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1807 	    only works with lineWidth = 1  */
  1831 	    only works with lineWidth = 1  */
  1808 
  1832 
  1809 	if (lStyleSymbol == @symbol(solid)) {
  1833 	if (lStyleSymbol == @symbol(solid)) {
  1862 displayPolygon:aPolygon in:aDrawableId with:aDC
  1886 displayPolygon:aPolygon in:aDrawableId with:aDC
  1863     "draw a polygon, the argument aPolygon is a Collection of individual points,
  1887     "draw a polygon, the argument aPolygon is a Collection of individual points,
  1864      which define the polygon.
  1888      which define the polygon.
  1865      If any coordinate is not integer, an error is triggered."
  1889      If any coordinate is not integer, an error is triggered."
  1866 
  1890 
  1867     |numberOfPoints|
  1891     | numberOfPoints lineWidthObj lineStyleObj |
       
  1892 
       
  1893      lineWidthObj := self lineWidth.
       
  1894      lineStyleObj := self lineStyle.
  1868 
  1895 
  1869     numberOfPoints := aPolygon size.
  1896     numberOfPoints := aPolygon size.
  1870 %{
  1897 %{
  1871     OBJ point, px, py;
  1898     OBJ point, px, py;
  1872     int i, num;
  1899     int i, num;
  1881 	int lw;
  1908 	int lw;
  1882 	COLORREF fgColor;
  1909 	COLORREF fgColor;
  1883 	OBJ lStyleSymbol;
  1910 	OBJ lStyleSymbol;
  1884 	int lStyleInt;
  1911 	int lStyleInt;
  1885 
  1912 
  1886 	lw= __intVal(__INST(lineWidth));
  1913 	lw= __intVal(lineWidthObj);
  1887 	lStyleSymbol= __INST(lineStyle);
  1914 	lStyleSymbol= lineStyleObj;
  1888 
  1915 
  1889 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1916 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1890 	    only works with lineWidth = 1  */
  1917 	    only works with lineWidth = 1  */
  1891 
  1918 
  1892 	if (lStyleSymbol == @symbol(solid)) {
  1919 	if (lStyleSymbol == @symbol(solid)) {
  1955     "Created: / 07-08-2006 / 14:46:55 / fm"
  1982     "Created: / 07-08-2006 / 14:46:55 / fm"
  1956 !
  1983 !
  1957 
  1984 
  1958 displayPolylines:arrayOfPoints
  1985 displayPolylines:arrayOfPoints
  1959 
  1986 
  1960     device displayPolylines:arrayOfPoints in:nil with:gcId
  1987     self device displayPolylines:arrayOfPoints in:nil with:self gcId
  1961 !
  1988 !
  1962 
  1989 
  1963 displayPolylines:aPolyline in:ignoredDrawableId with:aDC
  1990 displayPolylines:aPolyline in:ignoredDrawableId with:aDC
  1964     "draw a polyline, the argument aPolyline is a collection of individual points,
  1991     "draw a polyline, the argument aPolyline is a collection of individual points,
  1965      which define the lines (p1/p2 pairs); must be even in size.
  1992      which define the lines (p1/p2 pairs); must be even in size.
  1966      If any coordinate is not integer, an error is triggered."
  1993      If any coordinate is not integer, an error is triggered."
  1967 
  1994 
  1968     |numberOfPoints|
  1995     |numberOfPoints lineWidthObj lineStyleObj capStyleObj joinStyleObj |
  1969 
  1996 
  1970     numberOfPoints := aPolyline size.
  1997     numberOfPoints := aPolyline size.
  1971 
  1998 
       
  1999  	lineWidthObj := self lineWidth.
       
  2000 	lineStyleObj := self lineStyle.
       
  2001 	
  1972 %{
  2002 %{
  1973     OBJ point, px, py;
  2003     OBJ point, px, py;
  1974     int i, num;
  2004     int i, num;
  1975 
  2005 
  1976     if (__isExternalAddressLike(aDC)
  2006     if (__isExternalAddressLike(aDC)
  1982 	COLORREF fgColor;
  2012 	COLORREF fgColor;
  1983 	int lw;
  2013 	int lw;
  1984 	OBJ lStyleSymbol;
  2014 	OBJ lStyleSymbol;
  1985 	int lStyleInt;
  2015 	int lStyleInt;
  1986 
  2016 
  1987 	lw= __intVal(__INST(lineWidth));
  2017 	lw= __intVal(lineWidthObj);
  1988 	lStyleSymbol= __INST(lineStyle);
  2018 	lStyleSymbol= lineStyleObj;
  1989 
  2019 
  1990 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  2020 	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  1991 	    only works with lineWidth = 1  */
  2021 	    only works with lineWidth = 1  */
  1992 
  2022 
  1993 	if (lStyleSymbol == @symbol(solid)) {
  2023 	if (lStyleSymbol == @symbol(solid)) {
  2050 !
  2080 !
  2051 
  2081 
  2052 displayRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
  2082 displayRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
  2053     "draw a rectangle. If the coordinates are not integers, an error is triggered."
  2083     "draw a rectangle. If the coordinates are not integers, an error is triggered."
  2054 
  2084 
       
  2085     | lineWidthObj lineStyleObj |
       
  2086 
       
  2087     lineWidthObj := self lineWidth.
       
  2088 	lineStyleObj := self lineStyle.
       
  2089 
       
  2090 
  2055 %{
  2091 %{
  2056     int w, h;
  2092     int w, h;
  2057     int xL, yT;
  2093     int xL, yT;
  2058     if (__isExternalAddressLike(aDC)
  2094     if (__isExternalAddressLike(aDC)
  2059      && __bothSmallInteger(x, y)
  2095      && __bothSmallInteger(x, y)
  2072 	    HANDLE prevPen, hPen;
  2108 	    HANDLE prevPen, hPen;
  2073 	    OBJ lStyleSymbol;
  2109 	    OBJ lStyleSymbol;
  2074 	    int lStyleInt;
  2110 	    int lStyleInt;
  2075 	    int lw;
  2111 	    int lw;
  2076 
  2112 
  2077 	    lw= __intVal(__INST(lineWidth));
  2113 	    lw= __intVal(lineWidthObj);
  2078 	    lStyleSymbol= __INST(lineStyle);
  2114 	    lStyleSymbol= lineStyleObj;
  2079 
  2115 
  2080 	    /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  2116 	    /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
  2081 		only works with lineWidth = 1  */
  2117 		only works with lineWidth = 1  */
  2082 
  2118 
  2083 	    if (lStyleSymbol == @symbol(solid)) {
  2119 	    if (lStyleSymbol == @symbol(solid)) {
  2754     (aString isString not
  2790     (aString isString not
  2755     or:[aString isText]) ifTrue:[
  2791     or:[aString isText]) ifTrue:[
  2756 	^ aString displayOn:self x:x y:y
  2792 	^ aString displayOn:self x:x y:y
  2757     ].
  2793     ].
  2758 
  2794 
  2759     gcId isNil ifTrue:[
  2795     self gcId isNil ifTrue:[
  2760 	self initGC
  2796 	self initGC
  2761     ].
  2797     ].
  2762 
  2798 
  2763     fontUsed := font.
  2799     fontUsed := self font.
  2764     transformation notNil ifTrue:[
  2800     self transformation notNil ifTrue:[
  2765 	pX := transformation applyToX:x.
  2801 	pX := self transformation applyToX:x.
  2766 	pY := transformation applyToY:y.
  2802 	pY := self transformation applyToY:y.
  2767 	transformation noScale ifFalse:[
  2803 	self transformation noScale ifFalse:[
  2768 	    sz := font size.
  2804 	    sz := self font size.
  2769 	    sz isNil ifTrue:[
  2805 	    sz isNil ifTrue:[
  2770 		"/ oops - not a real font; use original font
  2806 		"/ oops - not a real font; use original font
  2771 		fontUsed := font
  2807 		fontUsed := self font.
  2772 	    ] ifFalse:[ |yS|
  2808 	    ] ifFalse:[ |yS|
  2773 		yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch.
  2809 		yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch.
  2774 		yS := self scale y / yS.
  2810 		yS := self scale y / yS.
  2775 		fontUsed := font size:(sz * yS) rounded.
  2811 		fontUsed := self font size:(sz * yS) rounded.
  2776 	    ]
  2812 	    ]
  2777 	]
  2813 	]
  2778     ] ifFalse:[
  2814     ] ifFalse:[
  2779 	pX := x.
  2815 	pX := x.
  2780 	pY := y.
  2816 	pY := y.
  2781     ].
  2817     ].
  2782     pX := pX rounded.
  2818     pX := pX rounded.
  2783     pY := pY rounded.
  2819     pY := pY rounded.
  2784 
  2820 
  2785     s := aString.
  2821     s := aString.
  2786     fontUsed := fontUsed onDevice:device.
  2822     fontUsed := fontUsed onDevice:self device.
  2787     fontsEncoding := fontUsed encoding.
  2823     fontsEncoding := fontUsed encoding.
  2788     (characterEncoding ~~ fontsEncoding) ifTrue:[
  2824     (self characterEncoding ~~ fontsEncoding) ifTrue:[
  2789 	[
  2825 	[
  2790 	    s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
  2826 	    s := CharacterEncoder encodeString:s from:self characterEncoding into:fontsEncoding.
  2791 	] on:CharacterEncoderError do:[:ex|
  2827 	] on:CharacterEncoderError do:[:ex|
  2792 	    "substitute a default value for codes that cannot be represented
  2828 	    "substitute a default value for codes that cannot be represented
  2793 	     in the new character set"
  2829 	     in the new character set"
  2794 	    ex proceedWith:ex defaultValue.
  2830 	    ex proceedWith:ex defaultValue.
  2795 	].
  2831 	].
  2798     id := fontUsed fontId.
  2834     id := fontUsed fontId.
  2799     id isNil ifTrue:[
  2835     id isNil ifTrue:[
  2800 	"hook for alien fonts"
  2836 	"hook for alien fonts"
  2801 	fontUsed displayString:s x:x y:y in:self
  2837 	fontUsed displayString:s x:x y:y in:self
  2802     ] ifFalse:[
  2838     ] ifFalse:[
  2803 	deviceFont ~~ fontUsed ifTrue:[
  2839 	self deviceFont ~~ fontUsed ifTrue:[
  2804 	    device setFont:id in:gcId.
  2840 	    self device setFont:id in:self gcId.
  2805 	    deviceFont := fontUsed
  2841 	    self deviceFont: fontUsed
  2806 	].
  2842 	].
  2807 	device displayString:s x:pX y:pY in:drawableId with:gcId
  2843 	self device displayString:s x:pX y:pY in:self drawableId with:self gcId
  2808     ]
  2844     ]
  2809 
  2845 
  2810     "Modified: 1.7.1997 / 17:08:35 / cg"
  2846     "Modified: 1.7.1997 / 17:08:35 / cg"
  2811 ! !
  2847 ! !
  2812 
  2848 
  2932     "do a bit-blt; copy bits from the rectangle defined by
  2968     "do a bit-blt; copy bits from the rectangle defined by
  2933      srcX/srcY and w/h from the sourceId drawable to the rectangle
  2969      srcX/srcY and w/h from the sourceId drawable to the rectangle
  2934      below dstX/dstY in the destId drawable. Trigger an error if any
  2970      below dstX/dstY in the destId drawable. Trigger an error if any
  2935      argument is not integer."
  2971      argument is not integer."
  2936 
  2972 
       
  2973      | function |
       
  2974 
       
  2975      function := self function.
       
  2976 
  2937 %{
  2977 %{
  2938     int     dstGcOwnerThreadID;
  2978     int     dstGcOwnerThreadID;
  2939     HWND    dstGcHWIN;
  2979     HWND    dstGcHWIN;
  2940     HBITMAP dstGcHBITMAP;
  2980     HBITMAP dstGcHBITMAP;
  2941 
  2981 
  2955 	int src_fg, src_bg, dst_fg, dst_bg;
  2995 	int src_fg, src_bg, dst_fg, dst_bg;
  2956 	char buf[5];
  2996 	char buf[5];
  2957 
  2997 
  2958 //          fun = dstGcData->bitbltrop2;
  2998 //          fun = dstGcData->bitbltrop2;
  2959 
  2999 
  2960 	aFunctionSymbol= __INST(function);
  3000 	aFunctionSymbol= function;
  2961 
  3001 
  2962 	if (aFunctionSymbol == @symbol(copy)) {
  3002 	if (aFunctionSymbol == @symbol(copy)) {
  2963 	    fun = SRCCOPY /* R2_COPYPEN */ ;
  3003 	    fun = SRCCOPY /* R2_COPYPEN */ ;
  2964 /*            bfun = BITBLT_COPY;                                          */
  3004 /*            bfun = BITBLT_COPY;                                          */
  2965 	} else if (aFunctionSymbol == @symbol(copyInverted)) {
  3005 	} else if (aFunctionSymbol == @symbol(copyInverted)) {
  3207 	     into: self id
  3247 	     into: self id
  3208 		x: x
  3248 		x: x
  3209 		y: y
  3249 		y: y
  3210 	    width: sortedImage width
  3250 	    width: sortedImage width
  3211 	   height: sortedImage height
  3251 	   height: sortedImage height
  3212 	     with: gcId.
  3252 	     with: self gcId.
  3213 !
  3253 !
  3214 
  3254 
  3215 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  3255 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
  3216 			  width:imageWidth height:imageHeight
  3256 			  width:imageWidth height:imageHeight
  3217 			      x:srcx y:srcy
  3257 			      x:srcx y:srcy
  3386 			       with:aGCId
  3426 			       with:aGCId
  3387 
  3427 
  3388     "since XPutImage may allocate huge amount of stack space
  3428     "since XPutImage may allocate huge amount of stack space
  3389      (some implementations use alloca), this must run with unlimited stack."
  3429      (some implementations use alloca), this must run with unlimited stack."
  3390 
  3430 
       
  3431     | drawableId |
       
  3432 
       
  3433     drawableId := self drawableId.
  3391 %{
  3434 %{
  3392     unsigned char fastBits[10000];
  3435     unsigned char fastBits[10000];
  3393     unsigned char *b_bits = 0;
  3436     unsigned char *b_bits = 0;
  3394     unsigned char *allocatedBits = 0;
  3437     unsigned char *allocatedBits = 0;
  3395     unsigned char *__imageBits = 0;
  3438     unsigned char *__imageBits = 0;
  3417 	  DWORD g;
  3460 	  DWORD g;
  3418 	  DWORD b;
  3461 	  DWORD b;
  3419 	} bitmap;
  3462 	} bitmap;
  3420 
  3463 
  3421 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  3464 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  3422 	HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
  3465 	HBITMAP hBitmap = _HBITMAPVAL(drawableId);
  3423 
  3466 
  3424 /*
  3467 /*
  3425 	DDPRINTF(("hDC = %x\n", hDC));
  3468 	DDPRINTF(("hDC = %x\n", hDC));
  3426 */
  3469 */
  3427 	if (__intVal(padd) != WIN32PADDING) {
  3470 	if (__intVal(padd) != WIN32PADDING) {
  3556 			       with:aGCId
  3599 			       with:aGCId
  3557 
  3600 
  3558     "since XPutImage may allocate huge amount of stack space
  3601     "since XPutImage may allocate huge amount of stack space
  3559      (some implementations use alloca), this must run with unlimited stack."
  3602      (some implementations use alloca), this must run with unlimited stack."
  3560 
  3603 
       
  3604     | drawableId |
       
  3605 
       
  3606     drawableId := self drawableId.
       
  3607 
  3561 %{
  3608 %{
  3562     unsigned char fastBits[10000];
  3609     unsigned char fastBits[10000];
  3563     unsigned char *b_bits = 0;
  3610     unsigned char *b_bits = 0;
  3564     unsigned char *allocatedBits = 0;
  3611     unsigned char *allocatedBits = 0;
  3565     unsigned char *__imageBits = 0;
  3612     unsigned char *__imageBits = 0;
  3606 	  BITMAPINFOHEADER bmiHeader;
  3653 	  BITMAPINFOHEADER bmiHeader;
  3607 	  RGBQUAD bmiColors[256];
  3654 	  RGBQUAD bmiColors[256];
  3608 	} bitmap;
  3655 	} bitmap;
  3609 
  3656 
  3610 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  3657 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  3611 	HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
  3658 	HBITMAP hBitmap = _HBITMAPVAL(drawableId);
  3612 	int col;
  3659 	int col;
  3613 /*
  3660 /*
  3614 	DDPRINTF(("hDC = %x\n", hDC));
  3661 	DDPRINTF(("hDC = %x\n", hDC));
  3615 */
  3662 */
  3616 
  3663 
  3741 
  3788 
  3742 setFunction:aFunctionSymbol in:aGCId
  3789 setFunction:aFunctionSymbol in:aGCId
  3743     "set alu function to be drawn with"
  3790     "set alu function to be drawn with"
  3744 
  3791 
  3745     Transcript showCR: aFunctionSymbol printString.
  3792     Transcript showCR: aFunctionSymbol printString.
  3746     function := aFunctionSymbol.
  3793     self function: aFunctionSymbol.
  3747 
  3794 
  3748 "/%{  /* NOCONTEXT */
  3795 "/%{  /* NOCONTEXT */
  3749 "/
  3796 "/
  3750 "/    if (__isExternalAddress(aGCId)) {
  3797 "/    if (__isExternalAddress(aGCId)) {
  3751 "/        struct gcData *gcData = _GCDATA(aGCId);
  3798 "/        struct gcData *gcData = _GCDATA(aGCId);
  3905 			       with:aGCId
  3952 			       with:aGCId
  3906 
  3953 
  3907     "since XPutImage may allocate huge amount of stack space
  3954     "since XPutImage may allocate huge amount of stack space
  3908      (some implementations use alloca), this must run with unlimited stack."
  3955      (some implementations use alloca), this must run with unlimited stack."
  3909 
  3956 
       
  3957     | drawableId |
       
  3958 
       
  3959     drawableId := self drawableId.
       
  3960 
  3910 %{
  3961 %{
  3911     unsigned char fastBits[10000];
  3962     unsigned char fastBits[10000];
  3912     unsigned char *b_bits = 0;
  3963     unsigned char *b_bits = 0;
  3913     unsigned char *allocatedBits = 0;
  3964     unsigned char *allocatedBits = 0;
  3914     unsigned char *__imageBits = 0;
  3965     unsigned char *__imageBits = 0;
  3955 	  BITMAPINFOHEADER bmiHeader;
  4006 	  BITMAPINFOHEADER bmiHeader;
  3956 	  RGBQUAD bmiColors[256];
  4007 	  RGBQUAD bmiColors[256];
  3957 	} bitmap;
  4008 	} bitmap;
  3958 
  4009 
  3959 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  4010 	HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
  3960 	HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
  4011 	HBITMAP hBitmap = _HBITMAPVAL(drawableId);
  3961 	int col;
  4012 	int col;
  3962 /*
  4013 /*
  3963 	DDPRINTF(("hDC = %x\n", hDC));
  4014 	DDPRINTF(("hDC = %x\n", hDC));
  3964 */
  4015 */
  3965 
  4016 
  4166     "return a fonts metrics info object"
  4217     "return a fonts metrics info object"
  4167 
  4218 
  4168     |rawData info|
  4219     |rawData info|
  4169 
  4220 
  4170     rawData := Array new:15.
  4221     rawData := Array new:15.
  4171     (self primFontMetricsOf:fontId hdc:gcId intoArray:rawData) isNil ifTrue:[
  4222     (self primFontMetricsOf:fontId hdc:self gcId intoArray:rawData) isNil ifTrue:[
  4172 	self primitiveFailed.
  4223 	self primitiveFailed.
  4173 	^ self
  4224 	^ self
  4174     ].
  4225     ].
  4175 
  4226 
  4176     rawData at:11 put:#'ms-ansi'.
  4227     rawData at:11 put:#'ms-ansi'.
  4695 
  4746 
  4696     "Created: / 04-08-2006 / 12:32:53 / fm"
  4747     "Created: / 04-08-2006 / 12:32:53 / fm"
  4697 !
  4748 !
  4698 
  4749 
  4699 widthOf:aString from:index1 to:index2 inFont:aFontId
  4750 widthOf:aString from:index1 to:index2 inFont:aFontId
       
  4751    | gcId |
       
  4752 
       
  4753    gcId :=self gcId.
  4700 
  4754 
  4701 %{  /* NOCONTEXT */
  4755 %{  /* NOCONTEXT */
  4702     unsigned char *cp;
  4756     unsigned char *cp;
  4703     int len, n, i1, i2, l;
  4757     int len, n, i1, i2, l;
  4704     OBJ cls;
  4758     OBJ cls;
  4705     int nInstBytes;
  4759     int nInstBytes;
  4706 
  4760 
  4707     if (__bothSmallInteger(index1, index2)
  4761     if (__bothSmallInteger(index1, index2)
  4708      && __isExternalAddress(aFontId)
  4762      && __isExternalAddress(aFontId)
  4709      && __isExternalAddressLike(__INST(gcId))
  4763      && __isExternalAddressLike(gcId)
  4710      && __isNonNilObject(aString)) {
  4764      && __isNonNilObject(aString)) {
  4711 	HGDIOBJ hFont,prevFont;
  4765 	HGDIOBJ hFont,prevFont;
  4712 	HANDLE hDC;
  4766 	HANDLE hDC;
  4713 	SIZE tsize;
  4767 	SIZE tsize;
  4714 
  4768 
  4719 	int mustFree = 0;
  4773 	int mustFree = 0;
  4720 	int i;
  4774 	int i;
  4721 #endif
  4775 #endif
  4722 
  4776 
  4723 	hFont = _HGDIOBJVal(aFontId);
  4777 	hFont = _HGDIOBJVal(aFontId);
  4724 	hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
  4778 	hDC = (HANDLE)(__externalAddressVal(gcId));
  4725 
  4779 
  4726 	prevFont = SelectObject(hDC, hFont);
  4780 	prevFont = SelectObject(hDC, hFont);
  4727 
  4781 
  4728 	i1 = __intVal(index1) - 1;
  4782 	i1 = __intVal(index1) - 1;
  4729 	cls = __qClass(aString);
  4783 	cls = __qClass(aString);
  4811 !WinPrinterContext methodsFor:'initialization & release'!
  4865 !WinPrinterContext methodsFor:'initialization & release'!
  4812 
  4866 
  4813 createDC
  4867 createDC
  4814     "Private - Create a device context for the receiver"
  4868     "Private - Create a device context for the receiver"
  4815 
  4869 
  4816     gcId := printerInfo createDC
  4870     self gcId: printerInfo createDC
  4817 
  4871 
  4818     "Created: / 27-07-2006 / 10:21:05 / fm"
  4872     "Created: / 27-07-2006 / 10:21:05 / fm"
  4819     "Modified: / 02-08-2006 / 17:30:47 / fm"
  4873     "Modified: / 02-08-2006 / 17:30:47 / fm"
  4820     "Modified: / 10-10-2006 / 18:14:28 / cg"
  4874     "Modified: / 10-10-2006 / 18:14:28 / cg"
  4821 !
  4875 !
  4822 
  4876 
  4823 deleteDC
  4877 deleteDC
  4824     "Private - Delete a device context for the receiver"
  4878     "Private - Delete a device context for the receiver"
  4825 
  4879 
  4826     OperatingSystem deletePrinterDC: gcId.
  4880     OperatingSystem deletePrinterDC: self gcId.
  4827 !
  4881 !
  4828 
  4882 
  4829 destroy
  4883 destroy
  4830     "Destroy the GC."
  4884     "Destroy the GC."
  4831 
  4885 
  4832     |id|
  4886     |id|
  4833 
  4887 
  4834     id := gcId.
  4888     id := self gcId.
  4835     id notNil ifTrue:[
  4889     id notNil ifTrue:[
  4836 	gcId := nil.
  4890 	self gcId: nil.
  4837 	self deleteDC.
  4891 	self deleteDC.
  4838     ].
  4892     ].
  4839 "/    Lobby unregister:self.
  4893 "/    Lobby unregister:self.
  4840 !
  4894 !
  4841 
  4895 
  4860 
  4914 
  4861 executor
  4915 executor
  4862     |aCopy|
  4916     |aCopy|
  4863 
  4917 
  4864     aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew.
  4918     aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew.
  4865     aCopy setDevice:device id:nil gcId:gcId.
  4919     aCopy setDevice:self device id:nil gcId:self gcId.
  4866     ^ aCopy
  4920     ^ aCopy
  4867 
  4921 
  4868     "Created: / 16-04-2007 / 12:39:02 / cg"
  4922     "Created: / 16-04-2007 / 12:39:02 / cg"
  4869 !
  4923 !
  4870 
  4924 
  4878 releaseDC
  4932 releaseDC
  4879     "Private - Delete and clear the device context of the receiver."
  4933     "Private - Delete and clear the device context of the receiver."
  4880 
  4934 
  4881     self deleteDC.
  4935     self deleteDC.
  4882 "/    device close.
  4936 "/    device close.
  4883     gcId := nil.
  4937     self gcId: nil.
  4884     self releaseDeviceFonts
  4938     self releaseDeviceFonts
  4885 !
  4939 !
  4886 
  4940 
  4887 releaseDeviceFonts
  4941 releaseDeviceFonts
  4888     deviceFonts isEmptyOrNil ifFalse:[
  4942     deviceFonts isEmptyOrNil ifFalse:[
  4907     true "self font isNil" ifTrue:[
  4961     true "self font isNil" ifTrue:[
  4908 	"if font not set yet, calculate based on default font"
  4962 	"if font not set yet, calculate based on default font"
  4909 	"/            extString := str asExternalString.
  4963 	"/            extString := str asExternalString.
  4910 	size := Win32OperatingSystem::WinPointStructure new.
  4964 	size := Win32OperatingSystem::WinPointStructure new.
  4911 	(OperatingSystem
  4965 	(OperatingSystem
  4912 	    getTextExtentPoint:gcId
  4966 	    getTextExtentPoint:self gcId
  4913 	    string:str
  4967 	    string:str
  4914 	    size:size) ifFalse:[ ^ self error ].
  4968 	    size:size) ifFalse:[ ^ self error ].
  4915 	answer := size x.
  4969 	answer := size x.
  4916 "/        Transcript showCR: 'FROM PRIM ******* ', str, '   ',  answer printString.
  4970 "/        Transcript showCR: 'FROM PRIM ******* ', str, '   ',  answer printString.
  4917 "/        Transcript showCR: 'FROM DEVICE ***** ', str, '   ',(self font widthOf:str on:self device) printString.
  4971 "/        Transcript showCR: 'FROM DEVICE ***** ', str, '   ',(self font widthOf:str on:self device) printString.
  4942 displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1
  4996 displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1
  4943     "draw a line (with current paint-color); apply transformation if nonNil"
  4997     "draw a line (with current paint-color); apply transformation if nonNil"
  4944 
  4998 
  4945     |pX0 pY0 pX1 pY1 easy fgId bgId|
  4999     |pX0 pY0 pX1 pY1 easy fgId bgId|
  4946 
  5000 
  4947     gcId isNil ifTrue:[
  5001     self gcId isNil ifTrue:[
  4948 	self initGC
  5002 	self initGC
  4949     ].
  5003     ].
  4950 
  5004 
  4951     lineStyle == #doubleDashed ifTrue:[
  5005     self lineStyle == #doubleDashed ifTrue:[
  4952 	"
  5006 	"
  4953 	 if bgPaint or paint is not a real color, we have to do it the hard way ...
  5007 	 if bgPaint or paint is not a real color, we have to do it the hard way ...
  4954 	"
  5008 	"
  4955 	easy := true.
  5009 	easy := true.
  4956 	paint isColor ifFalse:[
  5010 	self paint isColor ifFalse:[
  4957 	    easy := false
  5011 	    easy := false
  4958 	] ifTrue:[
  5012 	] ifTrue:[
  4959 	    fgId := paint colorId.
  5013 	    fgId := self paint colorId.
  4960 	    fgId isNil ifTrue:[
  5014 	    fgId isNil ifTrue:[
  4961 		easy := false
  5015 		easy := false
  4962 	    ]
  5016 	    ]
  4963 	].
  5017 	].
  4964 	bgPaint isColor ifFalse:[
  5018 	self bgPaint isColor ifFalse:[
  4965 	    easy := false
  5019 	    easy := false
  4966 	] ifTrue:[
  5020 	] ifTrue:[
  4967 	    bgId := bgPaint colorId.
  5021 	    bgId := self bgPaint colorId.
  4968 	    bgId isNil ifTrue:[
  5022 	    bgId isNil ifTrue:[
  4969 		easy := false
  5023 		easy := false
  4970 	    ]
  5024 	    ]
  4971 	].
  5025 	].
  4972 
  5026 
  4973 	easy ifTrue:[
  5027 	easy ifTrue:[
  4974 	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
  5028 	    ((self foreground ~~ self paint) or:[self background ~~ self bgPaint]) ifTrue:[
  4975 		device setForeground:fgId background:bgId in:gcId.
  5029 		self device setForeground:fgId background:bgId in:self gcId.
  4976 		foreground := paint.
  5030 		self foreground: self paint.
  4977 		background := bgPaint.
  5031 		self background: self bgPaint.
  4978 	    ].
  5032 	    ].
  4979 	] ifFalse:[
  5033 	] ifFalse:[
  4980 	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
  5034 	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
  4981 	].
  5035 	].
  4982     ].
  5036     ].
  4983 
  5037 
  4984     transformation notNil ifTrue:[
  5038     self transformation notNil ifTrue:[
  4985 	pX0 := transformation applyToX:x0.
  5039 	pX0 := self transformation applyToX:x0.
  4986 	pY0 := transformation applyToY:y0.
  5040 	pY0 := self transformation applyToY:y0.
  4987 	pX1 := transformation applyToX:x1.
  5041 	pX1 := self transformation applyToX:x1.
  4988 	pY1 := transformation applyToY:y1.
  5042 	pY1 := self transformation applyToY:y1.
  4989     ] ifFalse:[
  5043     ] ifFalse:[
  4990 	pX0 := x0.
  5044 	pX0 := x0.
  4991 	pY0 := y0.
  5045 	pY0 := y0.
  4992 	pX1 := x1.
  5046 	pX1 := x1.
  4993 	pY1 := y1
  5047 	pY1 := y1
  4996     pX0 := pX0 rounded.
  5050     pX0 := pX0 rounded.
  4997     pY0 := pY0 rounded.
  5051     pY0 := pY0 rounded.
  4998     pX1 := pX1 rounded.
  5052     pX1 := pX1 rounded.
  4999     pY1 := pY1 rounded.
  5053     pY1 := pY1 rounded.
  5000 
  5054 
  5001     device displayAdvanceLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
  5055     self device displayAdvanceLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:self drawableId with:self gcId
  5002 
  5056 
  5003     "Modified: 10.1.1997 / 17:46:32 / cg"
  5057     "Modified: 10.1.1997 / 17:46:32 / cg"
  5004 !
  5058 !
  5005 
  5059 
  5006 displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
  5060 displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
  5096 !
  5150 !
  5097 
  5151 
  5098 getPenForMyContext
  5152 getPenForMyContext
  5099     "Get a pen for my context"
  5153     "Get a pen for my context"
  5100 
  5154 
  5101     |maskOriginX maskOriginY|
  5155     |maskOriginX maskOriginY gcId lineWidthObj lineStyleObj capStyleObj joinStyleObj maskObj |
       
  5156 
  5102 
  5157 
  5103     self maskOrigin isNil ifFalse:[
  5158     self maskOrigin isNil ifFalse:[
  5104 	maskOriginX := self maskOrigin x.
  5159 	maskOriginX := self maskOrigin x.
  5105 	maskOriginY := self maskOrigin y.
  5160 	maskOriginY := self maskOrigin y.
  5106     ].
  5161     ].
       
  5162 
       
  5163     		gcId := self gcId.
       
  5164 	lineWidthObj := self lineWidth.
       
  5165 	lineStyleObj := self lineStyle.
       
  5166 	 capStyleObj := self capStyle.
       
  5167 	joinStyleObj := self joinStyle.
       
  5168          maskObj := self mask.
  5107 
  5169 
  5108 %{
  5170 %{
  5109     HPEN hPen = 0;
  5171     HPEN hPen = 0;
  5110     HPEN prevPen;
  5172     HPEN prevPen;
  5111     LOGBRUSH Brush;
  5173     LOGBRUSH Brush;
  5112     COLORREF fgColor;
  5174     COLORREF fgColor;
  5113     HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
  5175     HANDLE hDC = (HANDLE)(__externalAddressVal(gcId));
  5114     int lStyle, bkMode, hMask, maskOrgX, maskOrgY;
  5176     int lStyle, bkMode, hMask, maskOrgX, maskOrgY;
  5115     OBJ lineStyle, capStyle, joinStyle;
  5177     OBJ lineStyle, capStyle, joinStyle;
  5116     int style;
  5178     int style;
  5117     int lw;
  5179     int lw;
  5118     int BK_TRANSPARENT;
  5180     int BK_TRANSPARENT;
  5119 
  5181 
  5120     BK_TRANSPARENT = 1;
  5182     BK_TRANSPARENT = 1;
  5121 
  5183 
  5122     lw= __intVal(__INST(lineWidth));
  5184     lw= __intVal(lineWidthObj);
  5123 /*    fgColor = __intVal(__INST(foreground)) & 0xffffff;     */
  5185 /*    fgColor = __intVal(__INST(foreground)) & 0xffffff;     */
  5124 
  5186 
  5125     fgColor = GetTextColor(hDC);
  5187     fgColor = GetTextColor(hDC);
  5126     lineStyle=__INST(lineStyle);
  5188     lineStyle=lineStyleObj;
  5127     capStyle=__INST(capStyle);
  5189     capStyle=capStyleObj;
  5128     joinStyle=__INST(joinStyle);
  5190     joinStyle=joinStyleObj;
  5129     hMask= __intVal(__INST(mask));
  5191     hMask= __intVal(maskObj);
  5130     maskOrgX=__intVal(maskOriginX);
  5192     maskOrgX=__intVal(maskOriginX);
  5131     maskOrgY=__intVal(maskOriginY);
  5193     maskOrgY=__intVal(maskOriginY);
  5132 
  5194 
  5133     if (lineStyle == @symbol(solid)) {
  5195     if (lineStyle == @symbol(solid)) {
  5134 	style = PS_SOLID;
  5196 	style = PS_SOLID;
  5488 !WinPrinterContext methodsFor:'printing process'!
  5550 !WinPrinterContext methodsFor:'printing process'!
  5489 
  5551 
  5490 endPage
  5552 endPage
  5491     "Informs device that we are finished writing to a page."
  5553     "Informs device that we are finished writing to a page."
  5492 
  5554 
  5493     (OperatingSystem endPage:gcId) > 0 ifFalse:[
  5555     (OperatingSystem endPage:self gcId) > 0 ifFalse:[
  5494 	self error
  5556 	self error
  5495     ]
  5557     ]
  5496 
  5558 
  5497     "Created: / 27-07-2006 / 18:20:48 / fm"
  5559     "Created: / 27-07-2006 / 18:20:48 / fm"
  5498     "Modified: / 01-08-2006 / 16:01:34 / fm"
  5560     "Modified: / 01-08-2006 / 16:01:34 / fm"
  5504      and endPrintJob will become one entry in the print queue."
  5566      and endPrintJob will become one entry in the print queue."
  5505 
  5567 
  5506     |result|
  5568     |result|
  5507 
  5569 
  5508     self endPage.
  5570     self endPage.
  5509     result := OperatingSystem endDoc:gcId.
  5571     result := OperatingSystem endDoc:self gcId.
  5510     jobid := nil.
  5572     jobid := nil.
  5511     result >= 0 ifFalse:[ self error ]
  5573     result >= 0 ifFalse:[ self error ]
  5512 
  5574 
  5513     "Created: / 27-07-2006 / 18:21:04 / fm"
  5575     "Created: / 27-07-2006 / 18:21:04 / fm"
  5514     "Modified: / 01-08-2006 / 16:01:38 / fm"
  5576     "Modified: / 01-08-2006 / 16:01:38 / fm"
  5535 !
  5597 !
  5536 
  5598 
  5537 startPage
  5599 startPage
  5538     "Starts a page."
  5600     "Starts a page."
  5539 
  5601 
  5540     (OperatingSystem startPage:gcId) > 0 ifFalse:[
  5602     (OperatingSystem startPage:self gcId) > 0 ifFalse:[
  5541 	^ self error
  5603 	^ self error
  5542     ].
  5604     ].
  5543 
  5605 
  5544     "Created: / 27-07-2006 / 18:25:55 / fm"
  5606     "Created: / 27-07-2006 / 18:25:55 / fm"
  5545     "Modified: / 28-07-2006 / 18:19:04 / fm"
  5607     "Modified: / 28-07-2006 / 18:19:04 / fm"
  5551      drawn between startPrintJob and endPrintJob will become
  5613      drawn between startPrintJob and endPrintJob will become
  5552      one entry in the print queue."
  5614      one entry in the print queue."
  5553 
  5615 
  5554     |docInfoStruct nameAddress title fileNameAddress|
  5616     |docInfoStruct nameAddress title fileNameAddress|
  5555 
  5617 
  5556     gcId isNil ifTrue:[
  5618     self gcId isNil ifTrue:[
  5557 	self buildPrinter
  5619 	self buildPrinter
  5558     ].
  5620     ].
  5559     abort := false.
  5621     abort := false.
  5560     title := aString ? 'Smalltalk/X'.
  5622     title := aString ? 'Smalltalk/X'.
  5561     nameAddress := title asExternalBytes unprotectFromGC.
  5623     nameAddress := title asExternalBytes unprotectFromGC.
  5567 	cbSize:docInfoStruct sizeInBytes;
  5629 	cbSize:docInfoStruct sizeInBytes;
  5568 	lpszDocName:nameAddress address.
  5630 	lpszDocName:nameAddress address.
  5569     fileNameAddress isNil ifFalse:[
  5631     fileNameAddress isNil ifFalse:[
  5570 	docInfoStruct lpszOutput:fileNameAddress address
  5632 	docInfoStruct lpszOutput:fileNameAddress address
  5571     ].
  5633     ].
  5572     jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
  5634     jobid := OperatingSystem startDoc:self gcId docInfo:docInfoStruct.
  5573     jobid > 0 ifFalse:[
  5635     jobid > 0 ifFalse:[
  5574 	jobid = -1 ifTrue:[
  5636 	jobid = -1 ifTrue:[
  5575 	    abort := true.
  5637 	    abort := true.
  5576 	    ^ nil
  5638 	    ^ nil
  5577 	].
  5639 	].
  5595     ^ true
  5657     ^ true
  5596 !
  5658 !
  5597 
  5659 
  5598 isOpen
  5660 isOpen
  5599 
  5661 
  5600     ^ gcId notNil
  5662     ^ self gcId notNil
  5601 !
  5663 !
  5602 
  5664 
  5603 isPersistentInSnapshot
  5665 isPersistentInSnapshot
  5604     "return true, if resources on this device are to be made
  5666     "return true, if resources on this device are to be made
  5605      persistent in a snapshot image."
  5667      persistent in a snapshot image."
  5612     supportsColor isNil ifTrue:[supportsColor := self getSupportsColor].
  5674     supportsColor isNil ifTrue:[supportsColor := self getSupportsColor].
  5613     ^supportsColor
  5675     ^supportsColor
  5614 !
  5676 !
  5615 
  5677 
  5616 supportsGraphics
  5678 supportsGraphics
  5617     ^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4
  5679     ^(OperatingSystem getDeviceCaps: self gcId index: 2 "Technology") ~= 4
  5618 
  5680 
  5619     "Created: / 03-08-2006 / 10:07:43 / fm"
  5681     "Created: / 03-08-2006 / 10:07:43 / fm"
  5620     "Modified: / 16-04-2007 / 12:44:03 / cg"
  5682     "Modified: / 16-04-2007 / 12:44:03 / cg"
  5621 !
  5683 !
  5622 
  5684 
  5829 
  5891 
  5830     |tscale fscale yFont xFont|
  5892     |tscale fscale yFont xFont|
  5831 
  5893 
  5832     index2 < index1 ifTrue:[^ self].
  5894     index2 < index1 ifTrue:[^ self].
  5833 
  5895 
  5834     transformation isNil ifTrue:[
  5896     self transformation isNil ifTrue:[
  5835 	self initTransformation.
  5897 	self initTransformation.
  5836     ].
  5898     ].
  5837     tscale := transformation scale.
  5899     tscale := self transformation scale.
  5838     fscale := tscale / fontScale.
  5900     fscale := tscale / fontScale.
  5839 
  5901 
  5840     xFont := x * fontScale x.
  5902     xFont := x * fontScale x.
  5841     yFont := (y - font ascent) * fontScale y.    "/ MM_TEXT - Ursprung liegt oben links
  5903     yFont := (y - self font ascent) * fontScale y.    "/ MM_TEXT - Ursprung liegt oben links
  5842 
  5904 
  5843     transformation scale:fscale.
  5905     self transformation scale:fscale.
  5844 
  5906 
  5845     super displayString:aString from:index1 to:index2
  5907     super displayString:aString from:index1 to:index2
  5846 		x:xFont truncated
  5908 		x:xFont truncated
  5847 		y:yFont truncated.
  5909 		y:yFont truncated.
  5848 
  5910 
  5849     transformation scale:tscale.
  5911     self transformation scale:tscale.
  5850 !
  5912 !
  5851 
  5913 
  5852 displayString:aString x:x y:y
  5914 displayString:aString x:x y:y
  5853     |end|
  5915     |end|
  5854 
  5916 
  5973 !
  6035 !
  5974 
  6036 
  5975 initTransformation
  6037 initTransformation
  5976     |margin|
  6038     |margin|
  5977 
  6039 
  5978     transformation isNil ifTrue:[
  6040     self transformation isNil ifTrue:[
  5979 	margin := Point x:(self leftMargin) y:(self topMargin).
  6041 	margin := Point x:(self leftMargin) y:(self topMargin).
  5980 
  6042 
  5981 	transformation := WindowingTransformation scale:fontScale
  6043 	self transformation: (WindowingTransformation scale:fontScale
  5982 					    translation:(margin * fontScale).
  6044 					    translation:(margin * fontScale)).
  5983     ].
  6045     ].
  5984 !
  6046 !
  5985 
  6047 
  5986 initialize
  6048 initialize
  5987     super initialize.
  6049     super initialize.
  5998 
  6060 
  5999 displayTitleDo:aNoneArgAction
  6061 displayTitleDo:aNoneArgAction
  6000 
  6062 
  6001     |oldClip oldTrans oldFont|
  6063     |oldClip oldTrans oldFont|
  6002 
  6064 
  6003     oldClip := clipRect.
  6065     oldClip := gc clipingRectangleOrNil.
  6004     oldClip notNil ifTrue:[ self deviceClippingRectangle:nil ].
  6066     oldClip notNil ifTrue:[ self deviceClippingRectangle:nil ].
  6005 
  6067 
  6006     oldTrans := self translation.
  6068     oldTrans := self translation.
  6007     oldFont  := font.
  6069     oldFont  := self font.
  6008 
  6070 
  6009     self  font:(self titleFont).
  6071     self  font:(self titleFont).
  6010     self  translation:0.
  6072     self  translation:0.
  6011 
  6073 
  6012     aNoneArgAction value.
  6074     aNoneArgAction value.
  6030     printPageNumbers == true ifTrue:[
  6092     printPageNumbers == true ifTrue:[
  6031 	self displayTitleDo:[
  6093 	self displayTitleDo:[
  6032 	    s := pageNumberFormat bindWith:pageCounter.
  6094 	    s := pageNumberFormat bindWith:pageCounter.
  6033 
  6095 
  6034 	    self displayString:s
  6096 	    self displayString:s
  6035 			     x:(self extent x - (font widthOf:s))
  6097 			     x:(self extent x - (self font widthOf:s))
  6036 			     y:(self extent y + (font ascent)).
  6098 			     y:(self extent y + (self font ascent)).
  6037 	]
  6099 	]
  6038     ].
  6100     ].
  6039     super endPage.
  6101     super endPage.
  6040 !
  6102 !
  6041 
  6103 
  6063 ! !
  6125 ! !
  6064 
  6126 
  6065 !WinPrinterContext class methodsFor:'documentation'!
  6127 !WinPrinterContext class methodsFor:'documentation'!
  6066 
  6128 
  6067 version
  6129 version
  6068     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.44 2013-07-04 10:57:17 mb Exp $'
  6130     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.44 2013/07/04 10:57:17 mb Exp $'
  6069 !
  6131 !
  6070 
  6132 
  6071 version_CVS
  6133 version_CVS
  6072     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.44 2013-07-04 10:57:17 mb Exp $'
  6134     ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.44 2013/07/04 10:57:17 mb Exp $'
  6073 ! !
  6135 ! !
  6074 
  6136