--- a/WinPrinterContext.st Fri Jan 11 16:09:06 2013 +0100
+++ b/WinPrinterContext.st Fri Jan 11 16:09:26 2013 +0100
@@ -64,6 +64,10 @@
#define Processor WIN_Processor
#undef Message
#define Message WIN_Message
+#undef String
+#define String WIN_String
+#undef Character
+#define Character WIN_Character
#include <stdio.h>
#include <errno.h>
@@ -167,9 +171,19 @@
# undef Message
# define Message __DEF_Message
# endif
+# ifdef __DEF_String
+# undef String
+# define String __DEF_String
+# endif
+# ifdef __DEF_Character
+# undef Character
+# define Character __DEF_Character
+# endif
#undef INT
-#define INT int
+#define INT STX_INT
+#undef UINT
+#define UINT STX_UINT
/*
* some defines - tired of typing ...
@@ -196,6 +210,7 @@
#endif
typedef int (*intf)(int);
+typedef INT (*INTF)(INT);
%}
! !
@@ -273,7 +288,7 @@
gc := WinPrinterGraphicContext fromPrinterInfo:printerInfo.
gc notNil ifTrue:[
- gc startPrintJob
+ gc startPrintJob
].
^ gc
! !
@@ -298,19 +313,19 @@
!
getPrinterInformationString: printerNameString
- " Answer the printer information string from the WIN.INI file
- for the printer named printerNameString. If no name is specified,
- answer the information for the default printer. "
+ " Answer the printer information string from the WIN.INI file
+ for the printer named printerNameString. If no name is specified,
+ answer the information for the default printer. "
| printerInfo result |
printerInfo := ( String new: 80 ).
- result := OperatingSystem primGetProfileString: 'windows'
- keyName: 'device'
- default: ( printerNameString isNil ifTrue: [ '' ] ifFalse: [ printerNameString ] )
- returnedString: printerInfo
- size: printerInfo size.
+ result := OperatingSystem primGetProfileString: 'windows'
+ keyName: 'device'
+ default: ( printerNameString isNil ifTrue: [ '' ] ifFalse: [ printerNameString ] )
+ returnedString: printerInfo
+ size: printerInfo size.
^result > 0
- ifTrue: [printerInfo copyFrom: 1 to: result]
- ifFalse: ['']
+ ifTrue: [printerInfo copyFrom: 1 to: result]
+ ifFalse: ['']
!
named: aName
@@ -385,7 +400,7 @@
computeScaleForPrinter:aPrinter
^ Point x:(aPrinter pixelsPerInchOfScreenWidth / Screen current horizontalPixelPerInch)
- y:(aPrinter pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch)
+ y:(aPrinter pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch)
!
testPrintingDo:anOneArgBlock
@@ -479,27 +494,27 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Hatch Circles'.
- arrayOfPointsAndRadiusWithContextArray
- do:[:pointsAndRadiusWithContextArray |
- | point radius color hatch|
- point := (pointsAndRadiusWithContextArray at:1).
- radius := (pointsAndRadiusWithContextArray at:2).
- color := (pointsAndRadiusWithContextArray at:3).
- hatch := (pointsAndRadiusWithContextArray at:4).
- printer foreground: color;
- hatch: hatch.
- printer fillCircle:point
- radius:radius.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Hatch Circles'.
+ arrayOfPointsAndRadiusWithContextArray
+ do:[:pointsAndRadiusWithContextArray |
+ | point radius color hatch|
+ point := (pointsAndRadiusWithContextArray at:1).
+ radius := (pointsAndRadiusWithContextArray at:2).
+ color := (pointsAndRadiusWithContextArray at:3).
+ hatch := (pointsAndRadiusWithContextArray at:4).
+ printer foreground: color;
+ hatch: hatch.
+ printer fillCircle:point
+ radius:radius.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillHatchCircles:
- (Array with: (Array with: 800@800 with: 600 with:Color red with: #diagonalCross)
- with: (Array with: 1500@1500 with: 1000 with:Color blue with: #vertical)
- with: (Array with: 4000@2500 with: 2000 with:Color gray with: #bDiagonal))
+ (Array with: (Array with: 800@800 with: 600 with:Color red with: #diagonalCross)
+ with: (Array with: 1500@1500 with: 1000 with:Color blue with: #vertical)
+ with: (Array with: 4000@2500 with: 2000 with:Color gray with: #bDiagonal))
"
"Created: / 07-08-2006 / 11:46:52 / fm"
@@ -516,38 +531,38 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Hatch Polygons'.
- polygonsWithContextArray
- do:[:polygonWithContextArray |
- |aPolygon color hatch|
- aPolygon := polygonWithContextArray at: 1.
- color := (polygonWithContextArray at: 2).
- hatch := (polygonWithContextArray at: 3).
- printer foreground: color;
- hatch: hatch.
- aPolygon displayFilledOn: printer.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Hatch Polygons'.
+ polygonsWithContextArray
+ do:[:polygonWithContextArray |
+ |aPolygon color hatch|
+ aPolygon := polygonWithContextArray at: 1.
+ color := (polygonWithContextArray at: 2).
+ hatch := (polygonWithContextArray at: 3).
+ printer foreground: color;
+ hatch: hatch.
+ aPolygon displayFilledOn: printer.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillHatchPolygons:
- (Array with: (Array with: (Polygon vertices:(
- Array
- with:100@100
- with:600@1000
- with:3500@4000
- with:100@4000
- with:100@100))
- with: Color red
- with: #cross)
- with: (Array with: (Polygon vertices:(
- Array
- with:1000@1000
- with:1000@2000
- with:2000@1000))
- with: Color blue
- with: #none)
+ (Array with: (Array with: (Polygon vertices:(
+ Array
+ with:100@100
+ with:600@1000
+ with:3500@4000
+ with:100@4000
+ with:100@100))
+ with: Color red
+ with: #cross)
+ with: (Array with: (Polygon vertices:(
+ Array
+ with:1000@1000
+ with:1000@2000
+ with:2000@1000))
+ with: Color blue
+ with: #none)
)
"
@@ -566,29 +581,29 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Hatch Rectangles'.
- printer foreground:Color blue background:Color white.
- rectanglesWithHatch
- do:[:rectangleWithHatch |
- |rectangle hatch|
- rectangle := rectangleWithHatch at: 1.
- hatch := rectangleWithHatch at: 2.
- printer hatch: hatch.
- printer fillRectangleX: rectangle origin x
- y: rectangle origin y
- width: rectangle width
- height: rectangle height.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Hatch Rectangles'.
+ printer foreground:Color blue background:Color white.
+ rectanglesWithHatch
+ do:[:rectangleWithHatch |
+ |rectangle hatch|
+ rectangle := rectangleWithHatch at: 1.
+ hatch := rectangleWithHatch at: 2.
+ printer hatch: hatch.
+ printer fillRectangleX: rectangle origin x
+ y: rectangle origin y
+ width: rectangle width
+ height: rectangle height.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillHatchRectangles:
- (Array with: (Array with: (Rectangle left:20 top:20 width:400 height:600) with: #horizontal)
- with: (Array with: (Rectangle left:500 top:700 width:600 height:400) with: #vertical)
- with: (Array with: (Rectangle left:800 top:1000 width:1600 height:2000) with: #cross)
- with: (Array with: (Rectangle left:1040 top:1240 width:3000 height:3000) with: #bDiagonal)
- )
+ (Array with: (Array with: (Rectangle left:20 top:20 width:400 height:600) with: #horizontal)
+ with: (Array with: (Rectangle left:500 top:700 width:600 height:400) with: #vertical)
+ with: (Array with: (Rectangle left:800 top:1000 width:1600 height:2000) with: #cross)
+ with: (Array with: (Rectangle left:1040 top:1240 width:3000 height:3000) with: #bDiagonal)
+ )
"
"Created: / 07-08-2006 / 11:40:48 / fm"
@@ -703,12 +718,12 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer
- print: aString
- font: aFont
- title: aTitle
- wordWrap: wordWrap
- marginsRect: nil
+ printer
+ print: aString
+ font: aFont
+ title: aTitle
+ wordWrap: wordWrap
+ marginsRect: nil
] forkAt: 3
"
@@ -808,10 +823,10 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Image'.
- printer background:Color white.
- (anImage magnifiedBy:factor) displayOn:printer x:0 y:0.
- printer endPrintJob.
+ printer startPrintJob: 'Image'.
+ printer background:Color white.
+ (anImage magnifiedBy:factor) displayOn:printer x:0 y:0.
+ printer endPrintJob.
] forkAt: 3
"
@@ -1013,21 +1028,21 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Strings with Position'.
- printer foreground:Color black background:Color white.
- stringAndPositionsArray
- do:[:pairOfPointsAndPosition |
- printer displayString:(pairOfPointsAndPosition at: 1)
- x:(pairOfPointsAndPosition at: 2) x
- y:(pairOfPointsAndPosition at: 2) y
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Strings with Position'.
+ printer foreground:Color black background:Color white.
+ stringAndPositionsArray
+ do:[:pairOfPointsAndPosition |
+ printer displayString:(pairOfPointsAndPosition at: 1)
+ x:(pairOfPointsAndPosition at: 2) x
+ y:(pairOfPointsAndPosition at: 2) y
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printStrings:
- (Array with: (Array with:'Testing printing with standard method' with:10@10)
- with: (Array with:'Another test string to print' with:80@200))
+ (Array with: (Array with:'Testing printing with standard method' with:10@10)
+ with: (Array with:'Another test string to print' with:80@200))
"
"Created: / 07-08-2006 / 12:09:48 / fm"
@@ -1318,7 +1333,7 @@
HANDLE hPen, prevPen;
int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
- lineWidth= __INST(lineWidth);
+ lineWidth= __intVal(__INST(lineWidth));
if (__INST(lineStyle) == @symbol(solid)) {
lineStyleInt= PS_SOLID;
@@ -1422,10 +1437,10 @@
hatch
- "The hatch style will define a hatched brush between these patterns:
-
- #none
- #horizontal ----- HS_HORIZONTAL = 0
+ "The hatch style will define a hatched brush between these patterns:
+
+ #none
+ #horizontal ----- HS_HORIZONTAL = 0
#vertical ||||| HS_VERTICAL = 1
#fDiagonal \\\\\ HS_FDIAGONAL = 2
#bDiagonal ///// HS_BDIAGONAL = 3
@@ -1439,10 +1454,10 @@
hatch: aSymbol
- "The hatch style will define a hatched brush between these patterns:
-
- #none
- #horizontal ----- HS_HORIZONTAL = 0
+ "The hatch style will define a hatched brush between these patterns:
+
+ #none
+ #horizontal ----- HS_HORIZONTAL = 0
#vertical ||||| HS_VERTICAL = 1
#fDiagonal \\\\\ HS_FDIAGONAL = 2
#bDiagonal ///// HS_BDIAGONAL = 3
@@ -1469,7 +1484,7 @@
platformName
"used by #fillRoundRectangleX ...."
- ^ Smalltalk platformName asUppercase
+ ^ Smalltalk platformName asUppercase
!
setBitmapMask:aBitmapId in:aDC
@@ -1685,7 +1700,8 @@
HANDLE prevPen, hPen;
double xB, yB, xE, yE, xR, yR;
COLORREF fgColor;
- int lStyleSymbol, lStyleInt;
+ OBJ lStyleSymbol;
+ int lStyleInt;
int lw;
lw= __intVal(__INST(lineWidth));
@@ -1771,53 +1787,54 @@
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(x0, y0)
&& __bothSmallInteger(x1, y1)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fgColor;
- HANDLE prevPen, hPen;
- int __x1 = __intVal(x1), __y1 = __intVal(y1);
- int lStyleSymbol, lStyleInt;
- int lw;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fgColor;
+ HANDLE prevPen, hPen;
+ int __x1 = __intVal(x1), __y1 = __intVal(y1);
+ OBJ lStyleSymbol;
+ int lStyleInt;
+ int lw;
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n",
- __intVal(x0), __intVal(y0),
- __x1, __y1));
+ __intVal(x0), __intVal(y0),
+ __x1, __y1));
*/
- lw= __intVal(__INST(lineWidth));
- lStyleSymbol= __INST(lineStyle);
-
- /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
- only works with lineWidth = 1 */
-
- if (lStyleSymbol == @symbol(solid)) {
- lStyleInt= PS_SOLID;
- } else if (lStyleSymbol == @symbol(dashed)) {
- lStyleInt= PS_DASH;
- } else if (lStyleSymbol == @symbol(dotted)) {
- lStyleInt= PS_DOT;
- } else if (lStyleSymbol == @symbol(dashDot)) {
- lStyleInt= PS_DASHDOT;
- } else if (lStyleSymbol == @symbol(dashDotDot)) {
- lStyleInt= PS_DASHDOTDOT;
- } else if (lStyleSymbol == @symbol(insideFrame)) {
- lStyleInt= PS_INSIDEFRAME;
- } else
- lStyleInt= PS_SOLID;
-
- fgColor = GetTextColor(hDC);
- hPen = CreatePen(lStyleInt, lw, fgColor);
- prevPen = SelectObject(hDC, hPen);
- MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
- LineTo(hDC, __x1, __y1);
- /*
- * end-point ...
- */
- // LineTo(hDC, __x1+1, __y1);
-
- SelectObject(hDC, prevPen);
- DeleteObject(hPen);
-
- RETURN ( self );
+ lw= __intVal(__INST(lineWidth));
+ lStyleSymbol= __INST(lineStyle);
+
+ /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
+ only works with lineWidth = 1 */
+
+ if (lStyleSymbol == @symbol(solid)) {
+ lStyleInt= PS_SOLID;
+ } else if (lStyleSymbol == @symbol(dashed)) {
+ lStyleInt= PS_DASH;
+ } else if (lStyleSymbol == @symbol(dotted)) {
+ lStyleInt= PS_DOT;
+ } else if (lStyleSymbol == @symbol(dashDot)) {
+ lStyleInt= PS_DASHDOT;
+ } else if (lStyleSymbol == @symbol(dashDotDot)) {
+ lStyleInt= PS_DASHDOTDOT;
+ } else if (lStyleSymbol == @symbol(insideFrame)) {
+ lStyleInt= PS_INSIDEFRAME;
+ } else
+ lStyleInt= PS_SOLID;
+
+ fgColor = GetTextColor(hDC);
+ hPen = CreatePen(lStyleInt, lw, fgColor);
+ prevPen = SelectObject(hDC, hPen);
+ MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
+ LineTo(hDC, __x1, __y1);
+ /*
+ * end-point ...
+ */
+ // LineTo(hDC, __x1+1, __y1);
+
+ SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+
+ RETURN ( self );
}
%}
!
@@ -1863,7 +1880,8 @@
HANDLE prevPen, hPen;
int lw;
COLORREF fgColor;
- int lStyleSymbol, lStyleInt;
+ OBJ lStyleSymbol;
+ int lStyleInt;
lw= __intVal(__INST(lineWidth));
lStyleSymbol= __INST(lineStyle);
@@ -1963,8 +1981,8 @@
HANDLE prevPen, hPen;
COLORREF fgColor;
int lw;
- int lStyleSymbol, lStyleInt;
-
+ OBJ lStyleSymbol;
+ int lStyleInt;
lw= __intVal(__INST(lineWidth));
lStyleSymbol= __INST(lineStyle);
@@ -2041,59 +2059,59 @@
&& __bothSmallInteger(x, y)
&& __bothSmallInteger(width, height)) {
- xL = __intVal(x);
- yT = __intVal(y);
- w = __intVal(width);
- h = __intVal(height);
-
- DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
-
- if ((w >= 0) && (h >= 0)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fgColor;
- HANDLE prevPen, hPen;
- int lStyleSymbol, lStyleInt;
-
- int lw;
-
- lw= __intVal(__INST(lineWidth));
- lStyleSymbol= __INST(lineStyle);
-
- /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
- only works with lineWidth = 1 */
-
- if (lStyleSymbol == @symbol(solid)) {
- lStyleInt= PS_SOLID;
- } else if (lStyleSymbol == @symbol(dashed)) {
- lStyleInt= PS_DASH;
- } else if (lStyleSymbol == @symbol(dotted)) {
- lStyleInt= PS_DOT;
- } else if (lStyleSymbol == @symbol(dashDot)) {
- lStyleInt= PS_DASHDOT;
- } else if (lStyleSymbol == @symbol(dashDotDot)) {
- lStyleInt= PS_DASHDOTDOT;
- } else if (lStyleSymbol == @symbol(insideFrame)) {
- lStyleInt= PS_INSIDEFRAME;
- } else
- lStyleInt= PS_SOLID;
-
- fgColor = GetTextColor(hDC);
- hPen = CreatePen(lStyleInt, lw, fgColor);
-
- prevPen = SelectObject(hDC, hPen);
- MoveToEx(hDC, xL, yT, NULL);
- LineTo(hDC, xL+w, yT); // to top-right
- LineTo(hDC, xL+w, yT+h); // to bot-right
- MoveToEx(hDC, xL, yT, NULL); // back to top-left
- LineTo(hDC, xL, yT+h); // to bot-left
- // LineTo(hDC, xL+w+1, yT+h); // move pen one pixel more
- LineTo(hDC, xL+w, yT+h); // move pen one pixel more
-
- SelectObject(hDC, prevPen);
- DeleteObject(hPen);
-
- }
- RETURN ( self );
+ xL = __intVal(x);
+ yT = __intVal(y);
+ w = __intVal(width);
+ h = __intVal(height);
+
+ DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
+
+ if ((w >= 0) && (h >= 0)) {
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fgColor;
+ HANDLE prevPen, hPen;
+ OBJ lStyleSymbol;
+ int lStyleInt;
+ int lw;
+
+ lw= __intVal(__INST(lineWidth));
+ lStyleSymbol= __INST(lineStyle);
+
+ /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
+ only works with lineWidth = 1 */
+
+ if (lStyleSymbol == @symbol(solid)) {
+ lStyleInt= PS_SOLID;
+ } else if (lStyleSymbol == @symbol(dashed)) {
+ lStyleInt= PS_DASH;
+ } else if (lStyleSymbol == @symbol(dotted)) {
+ lStyleInt= PS_DOT;
+ } else if (lStyleSymbol == @symbol(dashDot)) {
+ lStyleInt= PS_DASHDOT;
+ } else if (lStyleSymbol == @symbol(dashDotDot)) {
+ lStyleInt= PS_DASHDOTDOT;
+ } else if (lStyleSymbol == @symbol(insideFrame)) {
+ lStyleInt= PS_INSIDEFRAME;
+ } else
+ lStyleInt= PS_SOLID;
+
+ fgColor = GetTextColor(hDC);
+ hPen = CreatePen(lStyleInt, lw, fgColor);
+
+ prevPen = SelectObject(hDC, hPen);
+ MoveToEx(hDC, xL, yT, NULL);
+ LineTo(hDC, xL+w, yT); // to top-right
+ LineTo(hDC, xL+w, yT+h); // to bot-right
+ MoveToEx(hDC, xL, yT, NULL); // back to top-left
+ LineTo(hDC, xL, yT+h); // to bot-left
+ // LineTo(hDC, xL+w+1, yT+h); // move pen one pixel more
+ LineTo(hDC, xL+w, yT+h); // move pen one pixel more
+
+ SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+
+ }
+ RETURN ( self );
}
%}.
self primitiveFailed
@@ -2111,11 +2129,11 @@
hC := hCorn.
self scale = 1 ifTrue:[
- wHalf := wC // 2.
- hHalf := hC // 2.
+ wHalf := wC // 2.
+ hHalf := hC // 2.
] ifFalse:[
- wHalf := wC / 2.
- hHalf := hC / 2.
+ wHalf := wC / 2.
+ hHalf := hC / 2.
].
"top left arc"
@@ -2138,7 +2156,7 @@
"bottom line"
self displayLineFromX:(left + wHalf-1) y:bottom
- toX:(right - wHalf ) y:bottom.
+ toX:(right - wHalf ) y:bottom.
"right line"
self displayLineFromX:right y:(top + hHalf) toX:right y:(bottom - hHalf).
@@ -2183,85 +2201,85 @@
&& __bothSmallInteger(index1, index2)
&& __bothSmallInteger(x, y))
{
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- int pX, pY;
- COLORREF fgColor;
-
- pX = __intVal(x);
- pY = __intVal(y);
-
- if (opaque == true) {
- SetBkMode(hDC, OPAQUE);
- } else {
- SetBkMode(hDC, TRANSPARENT);
- }
- fgColor = GetTextColor(hDC);
- SetTextColor(hDC, fgColor);
- SetBkColor(hDC, 0xFFFFFFFF);
-
- cls = __qClass(aString);
-
- i1 = __intVal(index1) - 1;
- if (i1 >= 0) {
- i2 = __intVal(index2) - 1;
- if (i2 < i1) {
- goto ret;
- }
-
- cp = _stringVal(aString);
- l = i2 - i1 + 1;
-
- if ((cls == @global(String)) || (cls == @global(Symbol))) {
- n = _stringSize(aString);
- if (i2 < n) {
- cp += i1;
- DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
-
- if (l > 32767) {
- l = 32767;
- }
- if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
-
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- cp += nInstBytes;
- n = __byteArraySize(aString) - nInstBytes;
-
- if (__isBytes(aString)) {
- if (i2 < n) {
- cp += i1;
- DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
- if (l > 32767) {
- l = 32767;
- }
- if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
-
- /* Unicode */
- if (__isWords(aString)) {
- n = n / 2;
- if (i2 < n) {
- WIDECHAR *w_cp = (WIDECHAR *)cp;
-
- w_cp += i1;
-
- if (! TextOutW(hDC, pX, pY, w_cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
- }
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ int pX, pY;
+ COLORREF fgColor;
+
+ pX = __intVal(x);
+ pY = __intVal(y);
+
+ if (opaque == true) {
+ SetBkMode(hDC, OPAQUE);
+ } else {
+ SetBkMode(hDC, TRANSPARENT);
+ }
+ fgColor = GetTextColor(hDC);
+ SetTextColor(hDC, fgColor);
+ SetBkColor(hDC, 0xFFFFFFFF);
+
+ cls = __qClass(aString);
+
+ i1 = __intVal(index1) - 1;
+ if (i1 >= 0) {
+ i2 = __intVal(index2) - 1;
+ if (i2 < i1) {
+ goto ret;
+ }
+
+ cp = _stringVal(aString);
+ l = i2 - i1 + 1;
+
+ if ((cls == @global(String)) || (cls == @global(Symbol))) {
+ n = _stringSize(aString);
+ if (i2 < n) {
+ cp += i1;
+ DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
+
+ if (l > 32767) {
+ l = 32767;
+ }
+ if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ cp += nInstBytes;
+ n = __byteArraySize(aString) - nInstBytes;
+
+ if (__isBytes(aString)) {
+ if (i2 < n) {
+ cp += i1;
+ DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
+ if (l > 32767) {
+ l = 32767;
+ }
+ if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+
+ /* Unicode */
+ if (__isWords(aString)) {
+ n = n / 2;
+ if (i2 < n) {
+ WIDECHAR *w_cp = (WIDECHAR *)cp;
+
+ w_cp += i1;
+
+ if (! TextOutW(hDC, pX, pY, w_cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+ }
ret:
- RETURN ( self );
+ RETURN ( self );
}
%}.
self primitiveFailed
@@ -2285,86 +2303,86 @@
&& __bothSmallInteger(index1, index2)
&& __bothSmallInteger(x, y))
{
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- int pX, pY;
- COLORREF fgColor;
-
- pX = __intVal(x);
- pY = __intVal(y);
- pY -= __intVal(fontAscent);
-
- if (opaque == true) {
- SetBkMode(hDC, OPAQUE);
- } else {
- SetBkMode(hDC, TRANSPARENT);
- }
- fgColor = GetTextColor(hDC);
- SetTextColor(hDC, fgColor);
- SetBkColor(hDC, 0xFFFFFFFF);
-
- cls = __qClass(aString);
-
- i1 = __intVal(index1) - 1;
- if (i1 >= 0) {
- i2 = __intVal(index2) - 1;
- if (i2 < i1) {
- goto ret;
- }
-
- cp = _stringVal(aString);
- l = i2 - i1 + 1;
-
- if ((cls == @global(String)) || (cls == @global(Symbol))) {
- n = _stringSize(aString);
- if (i2 < n) {
- cp += i1;
- DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
-
- if (l > 32767) {
- l = 32767;
- }
- if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
-
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- cp += nInstBytes;
- n = __byteArraySize(aString) - nInstBytes;
-
- if (__isBytes(aString)) {
- if (i2 < n) {
- cp += i1;
- DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
- if (l > 32767) {
- l = 32767;
- }
- if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
-
- /* Unicode */
- if (__isWords(aString)) {
- n = n / 2;
- if (i2 < n) {
- WIDECHAR *w_cp = (WIDECHAR *)cp;
-
- w_cp += i1;
-
- if (! TextOutW(hDC, pX, pY, w_cp, l)) {
- DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
- }
- goto ret;
- }
- }
- }
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ int pX, pY;
+ COLORREF fgColor;
+
+ pX = __intVal(x);
+ pY = __intVal(y);
+ pY -= __intVal(fontAscent);
+
+ if (opaque == true) {
+ SetBkMode(hDC, OPAQUE);
+ } else {
+ SetBkMode(hDC, TRANSPARENT);
+ }
+ fgColor = GetTextColor(hDC);
+ SetTextColor(hDC, fgColor);
+ SetBkColor(hDC, 0xFFFFFFFF);
+
+ cls = __qClass(aString);
+
+ i1 = __intVal(index1) - 1;
+ if (i1 >= 0) {
+ i2 = __intVal(index2) - 1;
+ if (i2 < i1) {
+ goto ret;
+ }
+
+ cp = _stringVal(aString);
+ l = i2 - i1 + 1;
+
+ if ((cls == @global(String)) || (cls == @global(Symbol))) {
+ n = _stringSize(aString);
+ if (i2 < n) {
+ cp += i1;
+ DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
+
+ if (l > 32767) {
+ l = 32767;
+ }
+ if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ cp += nInstBytes;
+ n = __byteArraySize(aString) - nInstBytes;
+
+ if (__isBytes(aString)) {
+ if (i2 < n) {
+ cp += i1;
+ DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
+ if (l > 32767) {
+ l = 32767;
+ }
+ if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+
+ /* Unicode */
+ if (__isWords(aString)) {
+ n = n / 2;
+ if (i2 < n) {
+ WIDECHAR *w_cp = (WIDECHAR *)cp;
+
+ w_cp += i1;
+
+ if (! TextOutW(hDC, pX, pY, w_cp, l)) {
+ DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
+ }
+ goto ret;
+ }
+ }
+ }
ret:
- RETURN ( self );
+ RETURN ( self );
}
%}.
self primitiveFailed
@@ -2399,7 +2417,7 @@
!
fillArcX:x y:y width:width height:height from:startAngle angle:angle
- in:ignoredDrawableId with:aDC
+ in:ignoredDrawableId with:aDC
"fill an arc. If any coordinate is not integer, an error is triggered.
The angles may be floats or integer - they are given in degrees."
@@ -2412,136 +2430,136 @@
float angle1, angle2;
if (__isSmallInteger(startAngle))
- angle1 = (float)(__intVal(startAngle));
+ angle1 = (float)(__intVal(startAngle));
else if (__isFloat(startAngle)) {
- angle1 = __floatVal(startAngle);
+ angle1 = __floatVal(startAngle);
} else if (__isShortFloat(startAngle)) {
- angle1 = __shortFloatVal(startAngle);
+ angle1 = __shortFloatVal(startAngle);
} else goto bad;
if (__isSmallInteger(angle))
- angle2 = (float)(__intVal(angle));
+ angle2 = (float)(__intVal(angle));
else if (__isFloat(angle)) {
- angle2 = __floatVal(angle);
+ angle2 = __floatVal(angle);
} else if (__isShortFloat(angle)) {
- angle2 = __shortFloatVal(angle);
+ angle2 = __shortFloatVal(angle);
} else goto bad;
if (angle2 <= 0) {
- RETURN (self);
+ RETURN (self);
}
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(x, y)
&& __bothSmallInteger(width, height))
{
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- HBRUSH hBrush, prevBrush;
- HPEN prevPen = 0;
- COLORREF fgColor;
- int hatch, hasHatch;
-
- w = __intVal(width);
- h = __intVal(height);
- __x = __intVal(x);
- __y = __intVal(y);
-
- fgColor = GetTextColor(hDC);
-
- hasHatch= 1;
-
- if (hatchSymbol == @symbol(none)) {
- hasHatch= 0;
- } else if (hatchSymbol == @symbol(horizontal)) {
- hatch= HS_HORIZONTAL;
- } else if (hatchSymbol == @symbol(vertical)) {
- hatch= HS_VERTICAL;
- } else if (hatchSymbol == @symbol(cross)) {
- hatch= HS_CROSS;
- } else if (hatchSymbol == @symbol(bDiagonal)) {
- hatch= HS_BDIAGONAL;
- } else if (hatchSymbol == @symbol(fDiagonal)) {
- hatch= HS_FDIAGONAL;
- } else if (hatchSymbol == @symbol(diagonalCross)) {
- hatch= HS_DIAGCROSS;
- } else
- hasHatch= 0;
-
- if (hasHatch) {
- hBrush = CreateHatchBrush(hatch, fgColor);
- } else {
- hBrush = CreateSolidBrush(fgColor);
- }
-
- prevBrush = SelectObject(hDC, hBrush);
- if (hBrush == 0) {
- DPRINTF(("fillArc: no brush\n"));
- } else {
- HPEN hPen = 0;
-
- if (0 /* __isWinNT */) {
- fgColor = GetTextColor(hDC);
- hPen = CreatePen(PS_SOLID, 1, fgColor);
- prevPen = SelectObject(hDC, hPen);
- if (hPen == 0) {
- DPRINTF(("fillArc: no pen\n"));
- goto failpen;
- }
- } else {
- prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
- w++;
- h++;
- }
-
- {
- double xB, yB, xE, yE, xR, yR;
-
- xR = w / 2;
- yR = h / 2;
- if (angle2 - angle1 >= 360) {
- xB = xE = __x + xR + 0.5;
- yB = yE = __y /*+ yR + 0.5*/;
- } else {
- double sin(), cos();
- float rad1, rad2;
-
- if (angle1 <= 180)
- angle1 = 180 - angle1;
- else
- angle1 = 360 + 180 - angle1;
- angle2 = angle1 - angle2;
- /* sigh - compute the intersections ... */
- rad1 = (angle1 * 3.14159265359) / 180.0;
- rad2 = (angle2 * 3.14159265359) / 180.0;
- xB = cos(rad1) * xR;
- yB = sin(rad1) * yR;
- xE = cos(rad2) * xR;
- yE = sin(rad2) * yR;
- xB = __x + xR - xB + 0.5;
- yB = __y + yR - yB + 0.5;
- xE = __x + xR - xE + 0.5;
- yE = __y + yR - yE + 0.5;
- }
- DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
-
- Pie(hDC,
- __x, __y,
- __x + w + 1, __y + h + 1,
- (int)xB, (int)yB,
- (int)xE, (int)yE);
-
- if (hPen) {
- DeleteObject(hPen);
- }
- }
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ HBRUSH hBrush, prevBrush;
+ HPEN prevPen = 0;
+ COLORREF fgColor;
+ int hatch, hasHatch;
+
+ w = __intVal(width);
+ h = __intVal(height);
+ __x = __intVal(x);
+ __y = __intVal(y);
+
+ fgColor = GetTextColor(hDC);
+
+ hasHatch= 1;
+
+ if (hatchSymbol == @symbol(none)) {
+ hasHatch= 0;
+ } else if (hatchSymbol == @symbol(horizontal)) {
+ hatch= HS_HORIZONTAL;
+ } else if (hatchSymbol == @symbol(vertical)) {
+ hatch= HS_VERTICAL;
+ } else if (hatchSymbol == @symbol(cross)) {
+ hatch= HS_CROSS;
+ } else if (hatchSymbol == @symbol(bDiagonal)) {
+ hatch= HS_BDIAGONAL;
+ } else if (hatchSymbol == @symbol(fDiagonal)) {
+ hatch= HS_FDIAGONAL;
+ } else if (hatchSymbol == @symbol(diagonalCross)) {
+ hatch= HS_DIAGCROSS;
+ } else
+ hasHatch= 0;
+
+ if (hasHatch) {
+ hBrush = CreateHatchBrush(hatch, fgColor);
+ } else {
+ hBrush = CreateSolidBrush(fgColor);
+ }
+
+ prevBrush = SelectObject(hDC, hBrush);
+ if (hBrush == 0) {
+ DPRINTF(("fillArc: no brush\n"));
+ } else {
+ HPEN hPen = 0;
+
+ if (0 /* __isWinNT */) {
+ fgColor = GetTextColor(hDC);
+ hPen = CreatePen(PS_SOLID, 1, fgColor);
+ prevPen = SelectObject(hDC, hPen);
+ if (hPen == 0) {
+ DPRINTF(("fillArc: no pen\n"));
+ goto failpen;
+ }
+ } else {
+ prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
+ w++;
+ h++;
+ }
+
+ {
+ double xB, yB, xE, yE, xR, yR;
+
+ xR = w / 2;
+ yR = h / 2;
+ if (angle2 - angle1 >= 360) {
+ xB = xE = __x + xR + 0.5;
+ yB = yE = __y /*+ yR + 0.5*/;
+ } else {
+ double sin(), cos();
+ float rad1, rad2;
+
+ if (angle1 <= 180)
+ angle1 = 180 - angle1;
+ else
+ angle1 = 360 + 180 - angle1;
+ angle2 = angle1 - angle2;
+ /* sigh - compute the intersections ... */
+ rad1 = (angle1 * 3.14159265359) / 180.0;
+ rad2 = (angle2 * 3.14159265359) / 180.0;
+ xB = cos(rad1) * xR;
+ yB = sin(rad1) * yR;
+ xE = cos(rad2) * xR;
+ yE = sin(rad2) * yR;
+ xB = __x + xR - xB + 0.5;
+ yB = __y + yR - yB + 0.5;
+ xE = __x + xR - xE + 0.5;
+ yE = __y + yR - yE + 0.5;
+ }
+ DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
+
+ Pie(hDC,
+ __x, __y,
+ __x + w + 1, __y + h + 1,
+ (int)xB, (int)yB,
+ (int)xE, (int)yE);
+
+ if (hPen) {
+ DeleteObject(hPen);
+ }
+ }
failpen:
- if (prevPen) SelectObject(hDC, prevPen);
- DeleteObject(hPen);
-
- SelectObject(hDC, prevBrush);
- DeleteObject(hBrush);
- }
- RETURN ( self );
+ if (prevPen) SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+
+ SelectObject(hDC, prevBrush);
+ DeleteObject(hBrush);
+ }
+ RETURN ( self );
}
bad: ;
%}.
@@ -2573,53 +2591,53 @@
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(x, y)
&& __bothSmallInteger(width, height)) {
- w = __intVal(width);
- h = __intVal(height);
-
- if ((w >= 0) && (h >= 0)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- HBRUSH hBrush, prevBrush;
- RECT rct;
- COLORREF fgColor;
- int hatch, hasHatch;
-
- fgColor = GetTextColor(hDC);
- hasHatch= 1;
-
- if (hatchSymbol == @symbol(none)) {
- hasHatch= 0;
- } else if (hatchSymbol == @symbol(horizontal)) {
- hatch= HS_HORIZONTAL;
- } else if (hatchSymbol == @symbol(vertical)) {
- hatch= HS_VERTICAL;
- } else if (hatchSymbol == @symbol(cross)) {
- hatch= HS_CROSS;
- } else if (hatchSymbol == @symbol(bDiagonal)) {
- hatch= HS_BDIAGONAL;
- } else if (hatchSymbol == @symbol(fDiagonal)) {
- hatch= HS_FDIAGONAL;
- } else if (hatchSymbol == @symbol(diagonalCross)) {
- hatch= HS_DIAGCROSS;
- } else
- hasHatch= 0;
-
- if (hasHatch) {
- hBrush = CreateHatchBrush(hatch, fgColor);
- } else {
- hBrush = CreateSolidBrush(fgColor);
- }
-
- rct.left = __intVal(x);
- rct.top = __intVal(y);
- rct.right = rct.left + w; // + 1;
- rct.bottom = rct.top + h; // + 1;
-
- prevBrush = SelectObject(hDC, hBrush);
- FillRect(hDC, &rct, hBrush);
- SelectObject(hDC, prevBrush);
- DeleteObject(hBrush);
-
- }
+ w = __intVal(width);
+ h = __intVal(height);
+
+ if ((w >= 0) && (h >= 0)) {
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ HBRUSH hBrush, prevBrush;
+ RECT rct;
+ COLORREF fgColor;
+ int hatch, hasHatch;
+
+ fgColor = GetTextColor(hDC);
+ hasHatch= 1;
+
+ if (hatchSymbol == @symbol(none)) {
+ hasHatch= 0;
+ } else if (hatchSymbol == @symbol(horizontal)) {
+ hatch= HS_HORIZONTAL;
+ } else if (hatchSymbol == @symbol(vertical)) {
+ hatch= HS_VERTICAL;
+ } else if (hatchSymbol == @symbol(cross)) {
+ hatch= HS_CROSS;
+ } else if (hatchSymbol == @symbol(bDiagonal)) {
+ hatch= HS_BDIAGONAL;
+ } else if (hatchSymbol == @symbol(fDiagonal)) {
+ hatch= HS_FDIAGONAL;
+ } else if (hatchSymbol == @symbol(diagonalCross)) {
+ hatch= HS_DIAGCROSS;
+ } else
+ hasHatch= 0;
+
+ if (hasHatch) {
+ hBrush = CreateHatchBrush(hatch, fgColor);
+ } else {
+ hBrush = CreateSolidBrush(fgColor);
+ }
+
+ rct.left = __intVal(x);
+ rct.top = __intVal(y);
+ rct.right = rct.left + w; // + 1;
+ rct.bottom = rct.top + h; // + 1;
+
+ prevBrush = SelectObject(hDC, hBrush);
+ FillRect(hDC, &rct, hBrush);
+ SelectObject(hDC, prevBrush);
+ DeleteObject(hBrush);
+
+ }
}
RETURN ( self );
@@ -2639,85 +2657,85 @@
if (__isExternalAddressLike(aDC)
&& __isSmallInteger(numberOfPoints)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- POINT p;
- HBRUSH hBrush, prevBrush;
- COLORREF fgColor;
- int hatch, hasHatch;
-
- num = __intVal(numberOfPoints);
- if (num < 3) {
- RETURN ( self );
- }
- for (i=0; i<num; i++) {
- point = __AT_(aPolygon, __MKSMALLINT(i+1));
- if (! __isPoint(point)) goto fail;
- px = _point_X(point);
- py = _point_Y(point);
- if (! __bothSmallInteger(px, py))
- goto fail;
- }
-
- fgColor = GetTextColor(hDC);
- hasHatch= 1;
-
- if (hatchSymbol == @symbol(none)) {
- hasHatch= 0;
- } else if (hatchSymbol == @symbol(horizontal)) {
- hatch= HS_HORIZONTAL;
- } else if (hatchSymbol == @symbol(vertical)) {
- hatch= HS_VERTICAL;
- } else if (hatchSymbol == @symbol(cross)) {
- hatch= HS_CROSS;
- } else if (hatchSymbol == @symbol(bDiagonal)) {
- hatch= HS_BDIAGONAL;
- } else if (hatchSymbol == @symbol(fDiagonal)) {
- hatch= HS_FDIAGONAL;
- } else if (hatchSymbol == @symbol(diagonalCross)) {
- hatch= HS_DIAGCROSS;
- } else
- hasHatch= 0;
-
- if (hasHatch) {
- hBrush = CreateHatchBrush(hatch, fgColor);
- } else {
- hBrush = CreateSolidBrush(fgColor);
- }
-
- if (hBrush == 0) {
- DPRINTF(("fillPolygon: no brush\n"));
- } else {
- HPEN prevPen;
-
- prevBrush = SelectObject(hDC, hBrush);
- prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
-
- BeginPath(hDC);
-
- for (i=0; i<num; i++) {
- point = __AT_(aPolygon, __MKSMALLINT(i+1));
- px = _point_X(point);
- py = _point_Y(point);
- if (i == 0) {
- MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
- } else {
- if (i == (num-1)) {
- p.x = __intVal(px);
- p.y = __intVal(py);
- PolylineTo(hDC, &p, 1);
- } else {
- LineTo(hDC, __intVal(px), __intVal(py));
- }
- }
- }
-
- EndPath(hDC);
- FillPath(hDC);
- SelectObject(hDC, prevPen);
- SelectObject(hDC, prevBrush);
- DeleteObject(hBrush);
- }
- RETURN ( self );
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ POINT p;
+ HBRUSH hBrush, prevBrush;
+ COLORREF fgColor;
+ int hatch, hasHatch;
+
+ num = __intVal(numberOfPoints);
+ if (num < 3) {
+ RETURN ( self );
+ }
+ for (i=0; i<num; i++) {
+ point = __AT_(aPolygon, __MKSMALLINT(i+1));
+ if (! __isPoint(point)) goto fail;
+ px = _point_X(point);
+ py = _point_Y(point);
+ if (! __bothSmallInteger(px, py))
+ goto fail;
+ }
+
+ fgColor = GetTextColor(hDC);
+ hasHatch= 1;
+
+ if (hatchSymbol == @symbol(none)) {
+ hasHatch= 0;
+ } else if (hatchSymbol == @symbol(horizontal)) {
+ hatch= HS_HORIZONTAL;
+ } else if (hatchSymbol == @symbol(vertical)) {
+ hatch= HS_VERTICAL;
+ } else if (hatchSymbol == @symbol(cross)) {
+ hatch= HS_CROSS;
+ } else if (hatchSymbol == @symbol(bDiagonal)) {
+ hatch= HS_BDIAGONAL;
+ } else if (hatchSymbol == @symbol(fDiagonal)) {
+ hatch= HS_FDIAGONAL;
+ } else if (hatchSymbol == @symbol(diagonalCross)) {
+ hatch= HS_DIAGCROSS;
+ } else
+ hasHatch= 0;
+
+ if (hasHatch) {
+ hBrush = CreateHatchBrush(hatch, fgColor);
+ } else {
+ hBrush = CreateSolidBrush(fgColor);
+ }
+
+ if (hBrush == 0) {
+ DPRINTF(("fillPolygon: no brush\n"));
+ } else {
+ HPEN prevPen;
+
+ prevBrush = SelectObject(hDC, hBrush);
+ prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
+
+ BeginPath(hDC);
+
+ for (i=0; i<num; i++) {
+ point = __AT_(aPolygon, __MKSMALLINT(i+1));
+ px = _point_X(point);
+ py = _point_Y(point);
+ if (i == 0) {
+ MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
+ } else {
+ if (i == (num-1)) {
+ p.x = __intVal(px);
+ p.y = __intVal(py);
+ PolylineTo(hDC, &p, 1);
+ } else {
+ LineTo(hDC, __intVal(px), __intVal(py));
+ }
+ }
+ }
+
+ EndPath(hDC);
+ FillPath(hDC);
+ SelectObject(hDC, prevPen);
+ SelectObject(hDC, prevBrush);
+ DeleteObject(hBrush);
+ }
+ RETURN ( self );
fail: ;
}
@@ -2725,9 +2743,9 @@
!
scaleTest_displayString:aString x:x y:y
- "draw a string at the coordinate x/y -
- draw foreground-pixels only (in current paint-color),
- leaving background as-is. If the transformation involves scaling,
+ "draw a string at the coordinate x/y -
+ draw foreground-pixels only (in current paint-color),
+ leaving background as-is. If the transformation involves scaling,
the fonts point-size is scaled as appropriate."
|id pX pY fontUsed sz s fontsEncoding|
@@ -2735,31 +2753,31 @@
"hook for non-strings (i.e. attributed text)"
(aString isString not
or:[aString isText]) ifTrue:[
- ^ aString displayOn:self x:x y:y
+ ^ aString displayOn:self x:x y:y
].
gcId isNil ifTrue:[
- self initGC
+ self initGC
].
fontUsed := font.
transformation notNil ifTrue:[
- pX := transformation applyToX:x.
- pY := transformation applyToY:y.
- transformation noScale ifFalse:[
- sz := font size.
- sz isNil ifTrue:[
- "/ oops - not a real font; use original font
- fontUsed := font
- ] ifFalse:[ |yS|
- yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch.
- yS := self scale y / yS.
- fontUsed := font size:(sz * yS) rounded.
- ]
- ]
+ pX := transformation applyToX:x.
+ pY := transformation applyToY:y.
+ transformation noScale ifFalse:[
+ sz := font size.
+ sz isNil ifTrue:[
+ "/ oops - not a real font; use original font
+ fontUsed := font
+ ] ifFalse:[ |yS|
+ yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch.
+ yS := self scale y / yS.
+ fontUsed := font size:(sz * yS) rounded.
+ ]
+ ]
] ifFalse:[
- pX := x.
- pY := y.
+ pX := x.
+ pY := y.
].
pX := pX rounded.
pY := pY rounded.
@@ -2768,25 +2786,25 @@
fontUsed := fontUsed onDevice:device.
fontsEncoding := fontUsed encoding.
(characterEncoding ~~ fontsEncoding) ifTrue:[
- [
- s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
- ] on:CharacterEncoderError do:[:ex|
- "substitute a default value for codes that cannot be represented
- in the new character set"
- ex proceedWith:ex defaultValue.
- ].
+ [
+ s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
+ ] on:CharacterEncoderError do:[:ex|
+ "substitute a default value for codes that cannot be represented
+ in the new character set"
+ ex proceedWith:ex defaultValue.
+ ].
].
id := fontUsed fontId.
id isNil ifTrue:[
- "hook for alien fonts"
- fontUsed displayString:s x:x y:y in:self
+ "hook for alien fonts"
+ fontUsed displayString:s x:x y:y in:self
] ifFalse:[
- deviceFont ~~ fontUsed ifTrue:[
- device setFont:id in:gcId.
- deviceFont := fontUsed
- ].
- device displayString:s x:pX y:pY in:drawableId with:gcId
+ deviceFont ~~ fontUsed ifTrue:[
+ device setFont:id in:gcId.
+ deviceFont := fontUsed
+ ].
+ device displayString:s x:pX y:pY in:drawableId with:gcId
]
"Modified: 1.7.1997 / 17:08:35 / cg"
@@ -2833,84 +2851,84 @@
compressColorMapImage: image
"calculates a new color map for the image, using only used colors"
- |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
+ |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
oldImage := image.
depth := oldImage depth.
oldImage photometric ~~ #palette ifTrue:[
- Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
- ^ image
+ Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
+ ^ image
].
usedColors := oldImage realUsedColors.
usedColors size == (1 bitShift:depth) ifTrue:[
- Transcript showCR:'Compress colorMap: All colors are used - no compression.'.
- ^ image
+ Transcript showCR:'Compress colorMap: All colors are used - no compression.'.
+ ^ image
].
usedColors size == oldImage colorMap size ifTrue:[
- Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'.
- ^ image
+ Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'.
+ ^ image
].
- "/ translation table
- oldToNew := ByteArray new:(1 bitShift:depth).
- newColorMap := usedColors asArray.
- newColorMap sort:self sortBlockForColors.
-
- oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
- |newPixel|
-
- (usedColors includes:clr) ifTrue:[
- newPixel := newColorMap indexOf:clr.
- oldToNew at:oldIdx put:newPixel-1.
- ]
- ].
-
- oldBits := oldImage bits.
- newBits := ByteArray new:(oldBits size).
- depth ~~ 8 ifTrue:[
- "/ expand/compress can only handle 8bits
- tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:tmpBits
- mapping:oldToNew.
- tmpBits
- compressPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:nil
- ] ifFalse:[
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:oldToNew.
- ].
-
- newImage := oldImage species new
- width:oldImage width
- height:oldImage height
- depth:depth
- fromArray:newBits.
-
- newImage colorMap:newColorMap.
- newImage fileName:oldImage fileName.
- newImage mask:(oldImage mask copy).
-
- ^ newImage
+ "/ translation table
+ oldToNew := ByteArray new:(1 bitShift:depth).
+ newColorMap := usedColors asArray.
+ newColorMap sort:self sortBlockForColors.
+
+ oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
+ |newPixel|
+
+ (usedColors includes:clr) ifTrue:[
+ newPixel := newColorMap indexOf:clr.
+ oldToNew at:oldIdx put:newPixel-1.
+ ]
+ ].
+
+ oldBits := oldImage bits.
+ newBits := ByteArray new:(oldBits size).
+ depth ~~ 8 ifTrue:[
+ "/ expand/compress can only handle 8bits
+ tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
+ oldBits
+ expandPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:tmpBits
+ mapping:oldToNew.
+ tmpBits
+ compressPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:newBits
+ mapping:nil
+ ] ifFalse:[
+ oldBits
+ expandPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:newBits
+ mapping:oldToNew.
+ ].
+
+ newImage := oldImage species new
+ width:oldImage width
+ height:oldImage height
+ depth:depth
+ fromArray:newBits.
+
+ newImage colorMap:newColorMap.
+ newImage fileName:oldImage fileName.
+ newImage mask:(oldImage mask copy).
+
+ ^ newImage
"Created: / 28.7.1998 / 20:03:11 / cg"
"Modified: / 15.9.1998 / 17:53:32 / cg"
!
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId
- width:w height:h
+ width:w height:h
"do a bit-blt; copy bits from the rectangle defined by
srcX/srcY and w/h from the sourceId drawable to the rectangle
below dstX/dstY in the destId drawable. Trigger an error if any
@@ -2923,39 +2941,40 @@
if (! __isExternalAddressLike(srcGCId)
|| ! __isExternalAddressLike(dstGCId)) {
- goto fail;
+ goto fail;
}
if (__bothSmallInteger(w, h)
&& __bothSmallInteger(srcX, srcY)
&& __bothSmallInteger(dstX, dstY)) {
- HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId));
- HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId));
-
- int fun, aFunctionSymbol;
- int src_fg, src_bg, dst_fg, dst_bg;
- char buf[5];
+ HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId));
+ HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId));
+
+ int fun;
+ OBJ aFunctionSymbol;
+ int src_fg, src_bg, dst_fg, dst_bg;
+ char buf[5];
// fun = dstGcData->bitbltrop2;
- aFunctionSymbol= __INST(function);
-
- if (aFunctionSymbol == @symbol(copy)) {
- fun = SRCCOPY /* R2_COPYPEN */ ;
+ aFunctionSymbol= __INST(function);
+
+ if (aFunctionSymbol == @symbol(copy)) {
+ fun = SRCCOPY /* R2_COPYPEN */ ;
/* bfun = BITBLT_COPY; */
- } else if (aFunctionSymbol == @symbol(copyInverted)) {
- fun = NOTSRCCOPY /* R2_NOTCOPYPEN */;
+ } else if (aFunctionSymbol == @symbol(copyInverted)) {
+ fun = NOTSRCCOPY /* R2_NOTCOPYPEN */;
/* bfun = BITBLT_COPYINVERTED; */
- } else if (aFunctionSymbol == @symbol(xor)) {
- fun = SRCINVERT /* R2_XORPEN */;
+ } else if (aFunctionSymbol == @symbol(xor)) {
+ fun = SRCINVERT /* R2_XORPEN */;
/* bfun = BITBLT_XOR; */
- } else if (aFunctionSymbol == @symbol(and)) {
- fun = SRCAND /* R2_MASKPEN */ ;
+ } else if (aFunctionSymbol == @symbol(and)) {
+ fun = SRCAND /* R2_MASKPEN */ ;
/* bfun = BITBLT_AND; */
- } else if (aFunctionSymbol == @symbol(or)) {
- fun = MERGECOPY /* R2_MERGEPEN */ ;
+ } else if (aFunctionSymbol == @symbol(or)) {
+ fun = MERGECOPY /* R2_MERGEPEN */ ;
/* bfun = BITBLT_OR; */
- }
+ }
// convert 123 to string [buf]
// itoa(fun, buf, 10);
@@ -2964,75 +2983,75 @@
/*
#if 0
- switch (fun) {
- case BITBLT_COPY:
- console_printf("BITBLT_COPY\n");
- break;
- case BITBLT_COPYINVERTED:
- console_printf("BITBLT_COPYINVERTED\n");
- break;
- case BITBLT_XOR:
- console_printf("BITBLT_XOR\n");
- break;
- case BITBLT_AND:
- console_printf("BITBLT_AND\n");
- break;
- case BITBLT_OR:
- console_printf("BITBLT_OR\n");
- break;
- }
+ switch (fun) {
+ case BITBLT_COPY:
+ console_printf("BITBLT_COPY\n");
+ break;
+ case BITBLT_COPYINVERTED:
+ console_printf("BITBLT_COPYINVERTED\n");
+ break;
+ case BITBLT_XOR:
+ console_printf("BITBLT_XOR\n");
+ break;
+ case BITBLT_AND:
+ console_printf("BITBLT_AND\n");
+ break;
+ case BITBLT_OR:
+ console_printf("BITBLT_OR\n");
+ break;
+ }
#endif
*/
// fun = dstGcData->bitbltrop2;
- if (0 /* fun == BITBLT_COPY */) {
- src_fg = dst_fg = 0xFFFFFF;
- src_bg = dst_bg = 0x000000;
- } else {
- src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */;
- src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */;
- dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */;
- dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */;
- }
-
- SetBkColor(dstDC, dst_fg);
- SetTextColor(dstDC, dst_bg);
-
- SetBkColor(srcDC, src_fg);
- SetTextColor(srcDC, src_bg);
+ if (0 /* fun == BITBLT_COPY */) {
+ src_fg = dst_fg = 0xFFFFFF;
+ src_bg = dst_bg = 0x000000;
+ } else {
+ src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */;
+ src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */;
+ dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */;
+ dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */;
+ }
+
+ SetBkColor(dstDC, dst_fg);
+ SetTextColor(dstDC, dst_bg);
+
+ SetBkColor(srcDC, src_fg);
+ SetTextColor(srcDC, src_bg);
/*
- CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
- CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
+ CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
+ CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
*/
- if (BitBlt(dstDC,
- __intVal(dstX), __intVal(dstY),
- __intVal(w), __intVal(h),
- srcDC,
- __intVal(srcX), __intVal(srcY),
- fun)
- == 0
- ) {
- console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
- }
+ if (BitBlt(dstDC,
+ __intVal(dstX), __intVal(dstY),
+ __intVal(w), __intVal(h),
+ srcDC,
+ __intVal(srcX), __intVal(srcY),
+ fun)
+ == 0
+ ) {
+ console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
+ }
/*
- if (dstGcData != srcGcData) {
- SetBkColor(dstDC, dstGcData->bgColor);
- SetTextColor(dstDC, dstGcData->fgColor);
- }
- SetBkColor(srcDC, srcGcData->bgColor);
- SetTextColor(srcDC, srcGcData->fgColor);
+ if (dstGcData != srcGcData) {
+ SetBkColor(dstDC, dstGcData->bgColor);
+ SetTextColor(dstDC, dstGcData->fgColor);
+ }
+ SetBkColor(srcDC, srcGcData->bgColor);
+ SetTextColor(srcDC, srcGcData->fgColor);
*/
/*
- if (srcGcData != dstGcData) {
- _releaseDC(srcGcData);
- }
- _releaseDC(dstGcData);
+ if (srcGcData != dstGcData) {
+ _releaseDC(srcGcData);
+ }
+ _releaseDC(dstGcData);
*/
- RETURN ( self );
+ RETURN ( self );
}
fail: ;
@@ -3094,23 +3113,23 @@
/*console_printf("CreateBitmap Color\n");*/
if (__bothSmallInteger(w, h) && __isSmallInteger(d) /*&& ISCONNECTED */) {
- if (__intVal(d) == 1) {
- newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
- } else {
+ if (__intVal(d) == 1) {
+ newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
+ } else {
#if 0
- if (__intVal(d) != __depth) {
- console_printf("invalid depth\n");
- RETURN (nil);
- }
+ if (__intVal(d) != __depth) {
+ console_printf("invalid depth\n");
+ RETURN (nil);
+ }
#endif
- newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) );
- }
-
- if (newBitmapHandle) {
- RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
- }
+ newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) );
+ }
+
+ if (newBitmapHandle) {
+ RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
+ }
/*
- DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
+ DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
*/
}
RETURN (nil);
@@ -3139,67 +3158,67 @@
"Image 16 bits"
aForm depth = 16 ifTrue:[
- bitsWithTransparency := aForm bits.
+ bitsWithTransparency := aForm bits.
].
"Image 24 and 32 bits"
aForm depth >= 24 ifTrue:[
- |bestFormat|
- bestFormat := aForm bestSupportedImageFormatFor: Display.
- bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat.
+ |bestFormat|
+ bestFormat := aForm bestSupportedImageFormatFor: Display.
+ bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat.
].
"Image up to 8 bits"
aForm depth <= 8 ifTrue:[
- aForm depth < 8 ifTrue:[
- sortedImage := aForm asImageWithDepth: 8.
- ].
+ aForm depth < 8 ifTrue:[
+ sortedImage := aForm asImageWithDepth: 8.
+ ].
"/ sortedImage := self sortColorMapImage: aForm.
- sortedImage := self compressColorMapImage: sortedImage.
-
- formMask := sortedImage mask.
- formMask isNil
- ifTrue:[bitsWithTransparency := sortedImage bits ]
- ifFalse:[
- |bitsWithTransparencySize|
- formMask := formMask asImageWithDepth: sortedImage depth.
- bitsWithTransparency := sortedImage bits copy.
- bitsWithTransparencySize := bitsWithTransparency size.
- formMask bits doWithIndex:[:maskBit :index |
- bitsWithTransparencySize >= index ifTrue:[
- maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"].
+ sortedImage := self compressColorMapImage: sortedImage.
+
+ formMask := sortedImage mask.
+ formMask isNil
+ ifTrue:[bitsWithTransparency := sortedImage bits ]
+ ifFalse:[
+ |bitsWithTransparencySize|
+ formMask := formMask asImageWithDepth: sortedImage depth.
+ bitsWithTransparency := sortedImage bits copy.
+ bitsWithTransparencySize := bitsWithTransparency size.
+ formMask bits doWithIndex:[:maskBit :index |
+ bitsWithTransparencySize >= index ifTrue:[
+ maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"].
"/ maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)].
- ].
- ].
- ].
-
- redVector := sortedImage colorMap redVector.
- greenVector := sortedImage colorMap greenVector.
- blueVector := sortedImage colorMap blueVector.
+ ].
+ ].
+ ].
+
+ redVector := sortedImage colorMap redVector.
+ greenVector := sortedImage colorMap greenVector.
+ blueVector := sortedImage colorMap blueVector.
].
- self
- drawBits: bitsWithTransparency
- redVector: redVector
+ self
+ drawBits: bitsWithTransparency
+ redVector: redVector
greenVector: greenVector
blueVector: blueVector
bitsPerPixel: sortedImage bitsPerPixel
- depth: sortedImage depth
- width: sortedImage width
- height: sortedImage height
- into: self id
- x: x
- y: y
- width: sortedImage width
- height: sortedImage height
- with: gcId.
+ depth: sortedImage depth
+ width: sortedImage width
+ height: sortedImage height
+ into: self id
+ x: x
+ y: y
+ width: sortedImage width
+ height: sortedImage height
+ with: gcId.
!
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
"draw a bitImage which has depth id, width iw and height ih into
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
@@ -3215,27 +3234,27 @@
an unlimited stack, and thus cannot send primitiveFailed
"
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:(dstx rounded) y:(dsty rounded)
- width:w height:h
- with:aGCId)
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:(dstx rounded) y:(dsty rounded)
+ width:w height:h
+ with:aGCId)
ifFalse:[
- "
- also happens, if a segmentation violation occurs in the
- XPutImage ...
- "
- self primitiveFailed
+ "
+ also happens, if a segmentation violation occurs in the
+ XPutImage ...
+ "
+ self primitiveFailed
].
!
-drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
- width:imageWidth height:imageHeight
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
+drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
+ width:imageWidth height:imageHeight
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
"draw a bitImage which has depth id, width iw and height ih into
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
@@ -3250,14 +3269,14 @@
sorry; I had to separate it into 2 methods, since XPutImage needs
an unlimited stack, and thus cannot send primitiveFailed
"
- (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
- width:imageWidth height:imageHeight
- into:ignoredDrawableId
- x:(dstx rounded) y:(dsty rounded)
- width:w height:h
- with:aGCId)
+ (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
+ width:imageWidth height:imageHeight
+ into:ignoredDrawableId
+ x:(dstx rounded) y:(dsty rounded)
+ width:w height:h
+ with:aGCId)
ifFalse:[
- self primitiveFailed
+ self primitiveFailed
].
!
@@ -3276,70 +3295,70 @@
if (__bothSmallInteger(w, h)
&& __isNonNilObject(anArray)) {
- OBJ cls = __qClass(anArray);
-
- b_width = __intVal(w);
- b_height = __intVal(h);
- bytesPerRowST = (b_width + 7) / 8;
- bytesPerRowWN = ((b_width + 15) / 16) * 2;
- padding = bytesPerRowWN - bytesPerRowST;
-
- if ((padding == 0) && (cls == @global(ByteArray))) {
- b_bits = __ByteArrayInstPtr(anArray)->ba_element;
- cp = 0;
- } else {
- int nBytes = b_height * bytesPerRowWN;
-
- if (nBytes < sizeof(fastBits)) {
- cp = b_bits = fastBits;
- } else {
- cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
- if (! cp) goto fail;
- }
- }
- if (cp) {
- if (__qIsArrayLike(anArray)) {
- OBJ *op;
-
- index = 1;
- op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- num = *op++;
- if (! __isSmallInteger(num))
- goto fail;
- *cp++ = __intVal(num);
- }
- cp += padding;
- }
- } else if (__qIsByteArrayLike(anArray)) {
- unsigned char *pBits;
-
- pBits = __ByteArrayInstPtr(anArray)->ba_element;
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- *cp++ = ( *pBits++ /*^ 0xFF*/ );
- }
- cp += padding;
- }
- } else {
- goto fail;
- }
- }
+ OBJ cls = __qClass(anArray);
+
+ b_width = __intVal(w);
+ b_height = __intVal(h);
+ bytesPerRowST = (b_width + 7) / 8;
+ bytesPerRowWN = ((b_width + 15) / 16) * 2;
+ padding = bytesPerRowWN - bytesPerRowST;
+
+ if ((padding == 0) && (cls == @global(ByteArray))) {
+ b_bits = __ByteArrayInstPtr(anArray)->ba_element;
+ cp = 0;
+ } else {
+ int nBytes = b_height * bytesPerRowWN;
+
+ if (nBytes < sizeof(fastBits)) {
+ cp = b_bits = fastBits;
+ } else {
+ cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+ if (! cp) goto fail;
+ }
+ }
+ if (cp) {
+ if (__qIsArrayLike(anArray)) {
+ OBJ *op;
+
+ index = 1;
+ op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ num = *op++;
+ if (! __isSmallInteger(num))
+ goto fail;
+ *cp++ = __intVal(num);
+ }
+ cp += padding;
+ }
+ } else if (__qIsByteArrayLike(anArray)) {
+ unsigned char *pBits;
+
+ pBits = __ByteArrayInstPtr(anArray)->ba_element;
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ *cp++ = ( *pBits++ /*^ 0xFF*/ );
+ }
+ cp += padding;
+ }
+ } else {
+ goto fail;
+ }
+ }
/*
- CPRINTF(("create bitmap ...\n"));
+ CPRINTF(("create bitmap ...\n"));
*/
- newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
-
- if (newBitmapHandle ) {
+ newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
+
+ if (newBitmapHandle ) {
/*
- DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
+ DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
*/
- if (allocatedBits) {
- free(allocatedBits);
- }
- RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
- }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
+ RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
+ }
}
fail: ;
/*
@@ -3347,9 +3366,9 @@
*/
if (allocatedBits) {
/*
- CPRINTF(("freeing up bitmap bits ...\n"));
+ CPRINTF(("freeing up bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
/*
CPRINTF(("returning nil ...\n"));
@@ -3359,12 +3378,12 @@
!
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
- width:imageWidth height:imageHeight
- x:srcx y:srcy
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
+ width:imageWidth height:imageHeight
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
"since XPutImage may allocate huge amount of stack space
(some implementations use alloca), this must run with unlimited stack."
@@ -3376,9 +3395,9 @@
unsigned char *__imageBits = 0;
if (__isByteArray(imageBits)) {
- __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
+ __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
} else if (__isExternalBytesLike(imageBits)) {
- __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
+ __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
}
if (/* ISCONNECTED
@@ -3391,120 +3410,120 @@
&& __isSmallInteger(padd)
&& __imageBits)
{
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- DWORD r;
- DWORD g;
- DWORD b;
- } bitmap;
-
- HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
- HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ DWORD r;
+ DWORD g;
+ DWORD b;
+ } bitmap;
+
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
+ HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
/*
- DDPRINTF(("hDC = %x\n", hDC));
+ DDPRINTF(("hDC = %x\n", hDC));
*/
- if (__intVal(padd) != WIN32PADDING) {
- int row, col;
- unsigned char *cp;
- unsigned char *pBits;
- int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
- int bi = __intVal(bitsPerPixel);
-
- b_width = __intVal(w);
- b_height = __intVal(h);
- bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
- bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
- padding = bytesPerRowWN - bytesPerRowST;
- nBytes = b_height * bytesPerRowWN;
- /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
- if (padding) {
- if (nBytes < sizeof(fastBits)) {
- cp = b_bits = fastBits;
- } else {
- cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
- }
- if (cp) {
- pBits = __imageBits;
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- *cp++ = *pBits++;
- }
- cp += padding;
- }
- } else
- goto fail;
- }
- }
-
- if (b_bits == 0) {
- b_bits = __imageBits;
- }
-
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
- if (__intVal(imageDepth) == 24) {
- /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.r = 0xff0000;
- bitmap.g = 0x00ff00;
- bitmap.b = 0x0000ff;*/
- bitmap.bmiHeader.biCompression = BI_RGB;
- } else if (__intVal(imageDepth) == 16) {
- /*bitmap.bmiHeader.biCompression = BI_RGB;
- bitmap.bmiHeader.biCompression = BI_BITFIELDS;
- bitmap.b = 0x001f;
- bitmap.g = 0x07e0;
- bitmap.r = 0xf800;*/
- bitmap.b = 0;
- bitmap.g = 0;
- bitmap.r = 0;
- bitmap.bmiHeader.biCompression = BI_RGB;
- }
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
- bitmap.bmiHeader.biWidth = __intVal(imageWidth);
- bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
- bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
- /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
-
- SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
- __intVal(w), __intVal(h),
- __intVal(srcx), __intVal(srcy),
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ if (__intVal(padd) != WIN32PADDING) {
+ int row, col;
+ unsigned char *cp;
+ unsigned char *pBits;
+ int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
+ int bi = __intVal(bitsPerPixel);
+
+ b_width = __intVal(w);
+ b_height = __intVal(h);
+ bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
+ bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
+ padding = bytesPerRowWN - bytesPerRowST;
+ nBytes = b_height * bytesPerRowWN;
+ /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
+ if (padding) {
+ if (nBytes < sizeof(fastBits)) {
+ cp = b_bits = fastBits;
+ } else {
+ cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+ }
+ if (cp) {
+ pBits = __imageBits;
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ *cp++ = *pBits++;
+ }
+ cp += padding;
+ }
+ } else
+ goto fail;
+ }
+ }
+
+ if (b_bits == 0) {
+ b_bits = __imageBits;
+ }
+
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
+ if (__intVal(imageDepth) == 24) {
+ /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.r = 0xff0000;
+ bitmap.g = 0x00ff00;
+ bitmap.b = 0x0000ff;*/
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ } else if (__intVal(imageDepth) == 16) {
+ /*bitmap.bmiHeader.biCompression = BI_RGB;
+ bitmap.bmiHeader.biCompression = BI_BITFIELDS;
+ bitmap.b = 0x001f;
+ bitmap.g = 0x07e0;
+ bitmap.r = 0xf800;*/
+ bitmap.b = 0;
+ bitmap.g = 0;
+ bitmap.r = 0;
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ }
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+ bitmap.bmiHeader.biWidth = __intVal(imageWidth);
+ bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
+ bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
+ /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
+
+ SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
+ __intVal(w), __intVal(h),
+ __intVal(srcx), __intVal(srcy),
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
/*
- SetDIBits(hDC,hBitmap,
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ SetDIBits(hDC,hBitmap,
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
*/
/*
- StretchDIBits(hDC,
- __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
- __intVal(w), __intVal(h), // width & height of destination rectangle
- __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
- __intVal(w), __intVal(h), // width & height of source rectangle
- (void *)b_bits, // bitmap bits
- (BITMAPINFO*)&bitmap, // bitmap data
- DIB_RGB_COLORS, // usage options
- SRCCOPY // raster operation code
- );
+ StretchDIBits(hDC,
+ __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
+ __intVal(w), __intVal(h), // width & height of destination rectangle
+ __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
+ __intVal(w), __intVal(h), // width & height of source rectangle
+ (void *)b_bits, // bitmap bits
+ (BITMAPINFO*)&bitmap, // bitmap data
+ DIB_RGB_COLORS, // usage options
+ SRCCOPY // raster operation code
+ );
*/
- if (allocatedBits) {
- free(allocatedBits);
- }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
/*
#ifndef CACHE_LAST_DC
- _releaseDC(gcData);
+ _releaseDC(gcData);
#endif
*/
- RETURN ( true );
+ RETURN ( true );
}
fail: ;
@@ -3513,14 +3532,14 @@
*/
if (allocatedBits) {
/*
- PRINTF(("freeing up temp bitmap bits ...\n"));
+ PRINTF(("freeing up temp bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
/*
#ifndef CACHE_LAST_DC
if (hDC) {
- _releaseDC(gcData);
+ _releaseDC(gcData);
}
#endif
*/
@@ -3529,12 +3548,12 @@
^ false
!
-primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
- width:imageWidth height:imageHeight
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
+primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
+ width:imageWidth height:imageHeight
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
"since XPutImage may allocate huge amount of stack space
(some implementations use alloca), this must run with unlimited stack."
@@ -3550,27 +3569,27 @@
int padd = 8;
if (__isByteArray(imageBits)) {
- __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
+ __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
} else if (__isExternalBytesLike(imageBits)) {
- __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
+ __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
}
if (__isByteArray(redVector)) {
- __redVector = __ByteArrayInstPtr(redVector)->ba_element;
+ __redVector = __ByteArrayInstPtr(redVector)->ba_element;
} else if (__isExternalBytesLike(redVector)) {
- __redVector = (unsigned char *)(__externalBytesAddress(redVector));
+ __redVector = (unsigned char *)(__externalBytesAddress(redVector));
}
if (__isByteArray(greenVector)) {
- __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
+ __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
} else if (__isExternalBytesLike(greenVector)) {
- __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
+ __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
}
if (__isByteArray(blueVector)) {
- __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
+ __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
} else if (__isExternalBytesLike(blueVector)) {
- __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
+ __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
}
if (/* ISCONNECTED
@@ -3582,120 +3601,120 @@
&& __bothSmallInteger(imageDepth, bitsPerPixel)
&& __imageBits)
{
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- RGBQUAD bmiColors[256];
- } bitmap;
-
- HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
- HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
- int col;
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ RGBQUAD bmiColors[256];
+ } bitmap;
+
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
+ HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
+ int col;
/*
- DDPRINTF(("hDC = %x\n", hDC));
+ DDPRINTF(("hDC = %x\n", hDC));
*/
- if (padd != WIN32PADDING) {
-
- int row, col;
- unsigned char *cp;
- unsigned char *pBits;
- int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
- int bi = __intVal(bitsPerPixel);
+ if (padd != WIN32PADDING) {
+
+ int row, col;
+ unsigned char *cp;
+ unsigned char *pBits;
+ int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
+ int bi = __intVal(bitsPerPixel);
// console_fprintf(stderr, "Non WIN32PADDING");
- b_width = __intVal(w);
- b_height = __intVal(h);
- bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
- bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
- padding = bytesPerRowWN - bytesPerRowST;
- nBytes = b_height * bytesPerRowWN;
- /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
- if (padding) {
- if (nBytes < sizeof(fastBits)) {
- cp = b_bits = fastBits;
- } else {
- cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
- }
- if (cp) {
- pBits = __imageBits;
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- *cp++ = *pBits++;
- }
- cp += padding;
- }
- } else
- goto fail;
- }
- }
-
- if (b_bits == 0) {
- b_bits = __imageBits;
- }
-
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
- bitmap.bmiHeader.biCompression = BI_RGB;
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
- bitmap.bmiHeader.biWidth = __intVal(imageWidth);
- bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
- bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
- /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
-
- if (__intVal(imageDepth) <= 8) {
- for(col=0;col<256;col++)
- {
- bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed
- bitmap.bmiColors[col].rgbGreen = __greenVector[col];
- bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue
- bitmap.bmiColors[col].rgbReserved = 0;
-
- }
- }
-
- bitmap.bmiColors[255].rgbBlue=255;
- bitmap.bmiColors[255].rgbGreen=255;
- bitmap.bmiColors[255].rgbRed =255;
-
- SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
- __intVal(w), __intVal(h),
- 0, 0, /* __intVal(srcx), __intVal(srcy), */
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ b_width = __intVal(w);
+ b_height = __intVal(h);
+ bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
+ bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
+ padding = bytesPerRowWN - bytesPerRowST;
+ nBytes = b_height * bytesPerRowWN;
+ /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
+ if (padding) {
+ if (nBytes < sizeof(fastBits)) {
+ cp = b_bits = fastBits;
+ } else {
+ cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+ }
+ if (cp) {
+ pBits = __imageBits;
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ *cp++ = *pBits++;
+ }
+ cp += padding;
+ }
+ } else
+ goto fail;
+ }
+ }
+
+ if (b_bits == 0) {
+ b_bits = __imageBits;
+ }
+
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+ bitmap.bmiHeader.biWidth = __intVal(imageWidth);
+ bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
+ bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
+ /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
+
+ if (__intVal(imageDepth) <= 8) {
+ for(col=0;col<256;col++)
+ {
+ bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed
+ bitmap.bmiColors[col].rgbGreen = __greenVector[col];
+ bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue
+ bitmap.bmiColors[col].rgbReserved = 0;
+
+ }
+ }
+
+ bitmap.bmiColors[255].rgbBlue=255;
+ bitmap.bmiColors[255].rgbGreen=255;
+ bitmap.bmiColors[255].rgbRed =255;
+
+ SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
+ __intVal(w), __intVal(h),
+ 0, 0, /* __intVal(srcx), __intVal(srcy), */
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
/*
- SetDIBits(hDC,hBitmap,
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ SetDIBits(hDC,hBitmap,
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
*/
/*
- StretchDIBits(hDC,
- __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
- __intVal(w), __intVal(h), // width & height of destination rectangle
- __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
- __intVal(w), __intVal(h), // width & height of source rectangle
- (void *)b_bits, // bitmap bits
- (BITMAPINFO*)&bitmap, // bitmap data
- DIB_RGB_COLORS, // usage options
- SRCCOPY // raster operation code
- );
+ StretchDIBits(hDC,
+ __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
+ __intVal(w), __intVal(h), // width & height of destination rectangle
+ __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
+ __intVal(w), __intVal(h), // width & height of source rectangle
+ (void *)b_bits, // bitmap bits
+ (BITMAPINFO*)&bitmap, // bitmap data
+ DIB_RGB_COLORS, // usage options
+ SRCCOPY // raster operation code
+ );
*/
- if (allocatedBits) {
- free(allocatedBits);
- }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
/*
#ifndef CACHE_LAST_DC
- _releaseDC(gcData);
+ _releaseDC(gcData);
#endif
*/
- RETURN ( true );
+ RETURN ( true );
}
fail: ;
@@ -3704,14 +3723,14 @@
*/
if (allocatedBits) {
/*
- PRINTF(("freeing up temp bitmap bits ...\n"));
+ PRINTF(("freeing up temp bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
/*
#ifndef CACHE_LAST_DC
if (hDC) {
- _releaseDC(gcData);
+ _releaseDC(gcData);
}
#endif
*/
@@ -3796,94 +3815,94 @@
sortBlockForColors
^ [:a :b |
- a redByte == b redByte ifTrue:[
- a greenByte == b greenByte ifTrue:[
- a blueByte < b blueByte
- ] ifFalse:[
- a greenByte < b greenByte
- ]
- ] ifFalse:[
- a redByte < b redByte
- ]
+ a redByte == b redByte ifTrue:[
+ a greenByte == b greenByte ifTrue:[
+ a blueByte < b blueByte
+ ] ifFalse:[
+ a greenByte < b greenByte
+ ]
+ ] ifFalse:[
+ a redByte < b redByte
+ ]
].
!
sortColorMapImage: image
"calculates a new color map for the image, sorting colors"
- |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
+ |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits|
sortBlock := self sortBlockForColors.
oldImage := image.
depth := oldImage depth.
oldImage photometric ~~ #palette ifTrue:[
- Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
- ^ image
+ Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
+ ^ image
].
usedColors := oldImage realColorMap.
- "/ translation table
- oldToNew := ByteArray new:(1 bitShift:depth).
- newColorMap := usedColors asArray.
- newColorMap sort:sortBlock.
-
- oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
- |newPixel|
-
- (usedColors includes:clr) ifTrue:[
- newPixel := newColorMap indexOf:clr.
- oldToNew at:oldIdx put:newPixel-1.
- ]
- ].
-
- oldBits := oldImage bits.
- newBits := ByteArray new:(oldBits size).
- depth ~~ 8 ifTrue:[
- "/ expand/compress can only handle 8bits
- tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:tmpBits
- mapping:oldToNew.
- tmpBits
- compressPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:nil
- ] ifFalse:[
- oldBits
- expandPixels:depth
- width:oldImage width
- height:oldImage height
- into:newBits
- mapping:oldToNew.
- ].
-
- newImage := oldImage species new
- width:oldImage width
- height:oldImage height
- depth:depth
- fromArray:newBits.
-
- newImage colorMap:newColorMap.
- newImage fileName:oldImage fileName.
- newImage mask:(oldImage mask copy).
-
- ^newImage
+ "/ translation table
+ oldToNew := ByteArray new:(1 bitShift:depth).
+ newColorMap := usedColors asArray.
+ newColorMap sort:sortBlock.
+
+ oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
+ |newPixel|
+
+ (usedColors includes:clr) ifTrue:[
+ newPixel := newColorMap indexOf:clr.
+ oldToNew at:oldIdx put:newPixel-1.
+ ]
+ ].
+
+ oldBits := oldImage bits.
+ newBits := ByteArray new:(oldBits size).
+ depth ~~ 8 ifTrue:[
+ "/ expand/compress can only handle 8bits
+ tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
+ oldBits
+ expandPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:tmpBits
+ mapping:oldToNew.
+ tmpBits
+ compressPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:newBits
+ mapping:nil
+ ] ifFalse:[
+ oldBits
+ expandPixels:depth
+ width:oldImage width
+ height:oldImage height
+ into:newBits
+ mapping:oldToNew.
+ ].
+
+ newImage := oldImage species new
+ width:oldImage width
+ height:oldImage height
+ depth:depth
+ fromArray:newBits.
+
+ newImage colorMap:newColorMap.
+ newImage fileName:oldImage fileName.
+ newImage mask:(oldImage mask copy).
+
+ ^newImage
!
-transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
- width:imageWidth height:imageHeight
- into:ignoredDrawableId
- x:dstx y:dsty
- width:w height:h
- with:aGCId
+transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth
+ width:imageWidth height:imageHeight
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aGCId
"since XPutImage may allocate huge amount of stack space
(some implementations use alloca), this must run with unlimited stack."
@@ -3899,27 +3918,27 @@
int padd = 8;
if (__isByteArray(imageBits)) {
- __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
+ __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
} else if (__isExternalBytesLike(imageBits)) {
- __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
+ __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
}
if (__isByteArray(redVector)) {
- __redVector = __ByteArrayInstPtr(redVector)->ba_element;
+ __redVector = __ByteArrayInstPtr(redVector)->ba_element;
} else if (__isExternalBytesLike(redVector)) {
- __redVector = (unsigned char *)(__externalBytesAddress(redVector));
+ __redVector = (unsigned char *)(__externalBytesAddress(redVector));
}
if (__isByteArray(greenVector)) {
- __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
+ __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
} else if (__isExternalBytesLike(greenVector)) {
- __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
+ __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
}
if (__isByteArray(blueVector)) {
- __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
+ __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
} else if (__isExternalBytesLike(blueVector)) {
- __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
+ __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
}
if (/* ISCONNECTED
@@ -3931,159 +3950,159 @@
&& __bothSmallInteger(imageDepth, bitsPerPixel)
&& __imageBits)
{
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- RGBQUAD bmiColors[256];
- } bitmap;
-
- HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
- HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
- int col;
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ RGBQUAD bmiColors[256];
+ } bitmap;
+
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
+ HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
+ int col;
/*
- DDPRINTF(("hDC = %x\n", hDC));
+ DDPRINTF(("hDC = %x\n", hDC));
*/
- if (padd != WIN32PADDING) {
-
- int row, col;
- unsigned char *cp;
- unsigned char *pBits;
- int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
- int bi = __intVal(bitsPerPixel);
+ if (padd != WIN32PADDING) {
+
+ int row, col;
+ unsigned char *cp;
+ unsigned char *pBits;
+ int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
+ int bi = __intVal(bitsPerPixel);
// console_fprintf(stderr, "Non WIN32PADDING");
- b_width = __intVal(w);
- b_height = __intVal(h);
- bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
- bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
- padding = bytesPerRowWN - bytesPerRowST;
- nBytes = b_height * bytesPerRowWN;
- /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
- if (padding) {
- if (nBytes < sizeof(fastBits)) {
- cp = b_bits = fastBits;
- } else {
- cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
- }
- if (cp) {
- pBits = __imageBits;
- for (row = b_height; row; row--) {
- for (col = bytesPerRowST; col; col--) {
- *cp++ = *pBits++;
- }
- cp += padding;
- }
- } else
- goto fail;
- }
- }
-
- if (b_bits == 0) {
- b_bits = __imageBits;
- }
-
- bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmap.bmiHeader.biPlanes = 1;
- bitmap.bmiHeader.biCompression = BI_RGB;
- bitmap.bmiHeader.biSizeImage = 0;
- bitmap.bmiHeader.biXPelsPerMeter = 0;
- bitmap.bmiHeader.biYPelsPerMeter = 0;
- bitmap.bmiHeader.biClrUsed = 0;
- bitmap.bmiHeader.biClrImportant = 0;
- bitmap.bmiHeader.biWidth = __intVal(imageWidth);
- bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
- bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
- /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
-
- if (__intVal(imageDepth) <= 8) {
- for(col=0;col<256;col++)
- {
- bitmap.bmiColors[col].rgbBlue = 0;
- bitmap.bmiColors[col].rgbGreen = 0;
- bitmap.bmiColors[col].rgbRed = 0;
- bitmap.bmiColors[col].rgbReserved = 0;
-
- }
- }
-
- bitmap.bmiColors[255].rgbBlue=255;
- bitmap.bmiColors[255].rgbGreen=255;
- bitmap.bmiColors[255].rgbRed =255;
- bitmap.bmiColors[255].rgbReserved = 0;
- StretchDIBits(hDC,
- __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
- __intVal(w), __intVal(h), // width & height of destination rectangle
- 0, 0, /* __intVal(srcx), __intVal(srcy), */ // x & y coord of source upper-left corner
- __intVal(w), __intVal(h), // width & height of source rectangle
- (void *)b_bits, // bitmap bits
- (BITMAPINFO*)&bitmap, // bitmap data
- DIB_RGB_COLORS, // usage options
- SRCAND // raster operation code
- );
+ b_width = __intVal(w);
+ b_height = __intVal(h);
+ bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
+ bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
+ padding = bytesPerRowWN - bytesPerRowST;
+ nBytes = b_height * bytesPerRowWN;
+ /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
+ if (padding) {
+ if (nBytes < sizeof(fastBits)) {
+ cp = b_bits = fastBits;
+ } else {
+ cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+ }
+ if (cp) {
+ pBits = __imageBits;
+ for (row = b_height; row; row--) {
+ for (col = bytesPerRowST; col; col--) {
+ *cp++ = *pBits++;
+ }
+ cp += padding;
+ }
+ } else
+ goto fail;
+ }
+ }
+
+ if (b_bits == 0) {
+ b_bits = __imageBits;
+ }
+
+ bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bitmap.bmiHeader.biPlanes = 1;
+ bitmap.bmiHeader.biCompression = BI_RGB;
+ bitmap.bmiHeader.biSizeImage = 0;
+ bitmap.bmiHeader.biXPelsPerMeter = 0;
+ bitmap.bmiHeader.biYPelsPerMeter = 0;
+ bitmap.bmiHeader.biClrUsed = 0;
+ bitmap.bmiHeader.biClrImportant = 0;
+ bitmap.bmiHeader.biWidth = __intVal(imageWidth);
+ bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
+ bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
+ /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
+
+ if (__intVal(imageDepth) <= 8) {
+ for(col=0;col<256;col++)
+ {
+ bitmap.bmiColors[col].rgbBlue = 0;
+ bitmap.bmiColors[col].rgbGreen = 0;
+ bitmap.bmiColors[col].rgbRed = 0;
+ bitmap.bmiColors[col].rgbReserved = 0;
+
+ }
+ }
+
+ bitmap.bmiColors[255].rgbBlue=255;
+ bitmap.bmiColors[255].rgbGreen=255;
+ bitmap.bmiColors[255].rgbRed =255;
+ bitmap.bmiColors[255].rgbReserved = 0;
+ StretchDIBits(hDC,
+ __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
+ __intVal(w), __intVal(h), // width & height of destination rectangle
+ 0, 0, /* __intVal(srcx), __intVal(srcy), */ // x & y coord of source upper-left corner
+ __intVal(w), __intVal(h), // width & height of source rectangle
+ (void *)b_bits, // bitmap bits
+ (BITMAPINFO*)&bitmap, // bitmap data
+ DIB_RGB_COLORS, // usage options
+ SRCAND // raster operation code
+ );
/*
- if (__intVal(imageDepth) <= 8) {
- for(col=0;col<256;col++)
- {
- bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed
- bitmap.bmiColors[col].rgbGreen = __greenVector[col];
- bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue
- bitmap.bmiColors[col].rgbReserved = 0;
-
- }
- }
-
- bitmap.bmiColors[255].rgbBlue=0;
- bitmap.bmiColors[255].rgbGreen=0;
- bitmap.bmiColors[255].rgbRed =0;
- bitmap.bmiColors[255].rgbReserved = 0;
- StretchDIBits(hDC,
- __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
- __intVal(w), __intVal(h), // width & height of destination rectangle
- 0, 0, // x & y coord of source upper-left corner
- __intVal(w), __intVal(h), // width & height of source rectangle
- (void *)b_bits, // bitmap bits
- (BITMAPINFO*)&bitmap, // bitmap data
- DIB_RGB_COLORS, // usage options
- SRCPAINT // raster operation code
- );
+ if (__intVal(imageDepth) <= 8) {
+ for(col=0;col<256;col++)
+ {
+ bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed
+ bitmap.bmiColors[col].rgbGreen = __greenVector[col];
+ bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue
+ bitmap.bmiColors[col].rgbReserved = 0;
+
+ }
+ }
+
+ bitmap.bmiColors[255].rgbBlue=0;
+ bitmap.bmiColors[255].rgbGreen=0;
+ bitmap.bmiColors[255].rgbRed =0;
+ bitmap.bmiColors[255].rgbReserved = 0;
+ StretchDIBits(hDC,
+ __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
+ __intVal(w), __intVal(h), // width & height of destination rectangle
+ 0, 0, // x & y coord of source upper-left corner
+ __intVal(w), __intVal(h), // width & height of source rectangle
+ (void *)b_bits, // bitmap bits
+ (BITMAPINFO*)&bitmap, // bitmap data
+ DIB_RGB_COLORS, // usage options
+ SRCPAINT // raster operation code
+ );
*/
/*
- SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
- __intVal(w), __intVal(h),
- 0, 0,
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
+ __intVal(w), __intVal(h),
+ 0, 0,
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
*/
/*
- SetDIBits(hDC,hBitmap,
- 0,__intVal(h),
- (void *)b_bits,
- (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
+ SetDIBits(hDC,hBitmap,
+ 0,__intVal(h),
+ (void *)b_bits,
+ (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
*/
/*
- StretchDIBits(hDC,
- __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
- __intVal(w), __intVal(h), // width & height of destination rectangle
- __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
- __intVal(w), __intVal(h), // width & height of source rectangle
- (void *)b_bits, // bitmap bits
- (BITMAPINFO*)&bitmap, // bitmap data
- DIB_RGB_COLORS, // usage options
- SRCCOPY // raster operation code
- );
+ StretchDIBits(hDC,
+ __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner
+ __intVal(w), __intVal(h), // width & height of destination rectangle
+ __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner
+ __intVal(w), __intVal(h), // width & height of source rectangle
+ (void *)b_bits, // bitmap bits
+ (BITMAPINFO*)&bitmap, // bitmap data
+ DIB_RGB_COLORS, // usage options
+ SRCCOPY // raster operation code
+ );
*/
- if (allocatedBits) {
- free(allocatedBits);
- }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
/*
#ifndef CACHE_LAST_DC
- _releaseDC(gcData);
+ _releaseDC(gcData);
#endif
*/
- RETURN ( true );
+ RETURN ( true );
}
fail: ;
@@ -4092,14 +4111,14 @@
*/
if (allocatedBits) {
/*
- PRINTF(("freeing up temp bitmap bits ...\n"));
+ PRINTF(("freeing up temp bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
/*
#ifndef CACHE_LAST_DC
if (hDC) {
- _releaseDC(gcData);
+ _releaseDC(gcData);
}
#endif
*/
@@ -4120,24 +4139,24 @@
char *fn;
if (__isStringLike(aFontName)) {
- fn = __stringVal(aFontName);
- if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
- hFont = GetStockObject(ANSI_FIXED_FONT);
- } else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
- hFont = GetStockObject(ANSI_VAR_FONT);
- } else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
- hFont = GetStockObject(SYSTEM_FONT);
- } else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
- hFont = GetStockObject(SYSTEM_FIXED_FONT);
- } else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
- hFont = GetStockObject(DEVICE_DEFAULT_FONT);
- } else {
- hFont = GetStockObject(ANSI_FIXED_FONT);
- }
- if (hFont) {
- DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
- RETURN ( __MKEXTERNALADDRESS(hFont) );
- }
+ fn = __stringVal(aFontName);
+ if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
+ hFont = GetStockObject(ANSI_FIXED_FONT);
+ } else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
+ hFont = GetStockObject(ANSI_VAR_FONT);
+ } else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
+ hFont = GetStockObject(SYSTEM_FONT);
+ } else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
+ hFont = GetStockObject(SYSTEM_FIXED_FONT);
+ } else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
+ hFont = GetStockObject(DEVICE_DEFAULT_FONT);
+ } else {
+ hFont = GetStockObject(ANSI_FIXED_FONT);
+ }
+ if (hFont) {
+ DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
+ RETURN ( __MKEXTERNALADDRESS(hFont) );
+ }
}
%}.
^ nil
@@ -4186,17 +4205,17 @@
If not available, try next smaller font.
If no font fits, return nil"
- ^ self
- getFontWithFamily:familyString
- face:faceString
- style:styleString
- size:sizeArg
- sizeUnit:#pt
- encoding:encodingSym
+ ^ self
+ getFontWithFamily:familyString
+ face:faceString
+ style:styleString
+ size:sizeArg
+ sizeUnit:#pt
+ encoding:encodingSym
!
getFontWithFamily:familyString face:faceString
- style:styleArgString size:sizeArgOrNil sizeUnit:sizeUnit encoding:encodingSym
+ style:styleArgString size:sizeArgOrNil sizeUnit:sizeUnit encoding:encodingSym
"try to get the specified font, if not available, try the next smaller
font."
@@ -4209,90 +4228,90 @@
"special: if face is nil, allow access to X-fonts"
faceString isNil ifTrue:[
- sizeArgOrNil notNil ifTrue:[
- theName := familyString , '-' , sizeArgOrNil printString
- ] ifFalse:[
- theName := familyString
- ].
- theName notNil ifTrue:[
- theId := self createFontFor:theName.
- ].
- theId isNil ifTrue:[
- theId := self getDefaultFontWithEncoding:encodingSym
- ].
- ^ theId
+ sizeArgOrNil notNil ifTrue:[
+ theName := familyString , '-' , sizeArgOrNil printString
+ ] ifFalse:[
+ theName := familyString
+ ].
+ theName notNil ifTrue:[
+ theId := self createFontFor:theName.
+ ].
+ theId isNil ifTrue:[
+ theId := self getDefaultFontWithEncoding:encodingSym
+ ].
+ ^ theId
].
"/ spacing other than 'normal' is contained as last component
"/ in style
styleString notNil ifTrue:[
- ((styleString endsWith:'-narrow')
- or:[styleString endsWith:'-semicondensed']) ifTrue:[
- |i|
- i := styleString lastIndexOf:$-.
- spacing := styleString copyFrom:(i+1).
- styleString := styleString copyTo:(i-1).
- ] ifFalse:[
- spacing := 'normal'.
- ].
+ ((styleString endsWith:'-narrow')
+ or:[styleString endsWith:'-semicondensed']) ifTrue:[
+ |i|
+ i := styleString lastIndexOf:$-.
+ spacing := styleString copyFrom:(i+1).
+ styleString := styleString copyTo:(i-1).
+ ] ifFalse:[
+ spacing := 'normal'.
+ ].
].
xlatedStyle := styleString.
xlatedStyle notNil ifTrue:[
- xlatedStyle := xlatedStyle first asString
+ xlatedStyle := xlatedStyle first asString
].
id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString
- slant:styleString "/ xlatedStyle
- spacing:spacing
- pixelSize:nil
- size:sizeArgOrNil
- registry:'*'
- encoding:encodingSym.
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString
+ slant:styleString "/ xlatedStyle
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArgOrNil
+ registry:'*'
+ encoding:encodingSym.
id isNil ifTrue:[
- (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
- "/ too stupid: encodings come in both cases
- "/
- id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString
- slant:styleString "/ xlatedStyle
- spacing:spacing
- pixelSize:nil
- size:sizeArgOrNil
- registry:'*'
- encoding:encodingSym asUppercase.
- id isNil ifTrue:[
- id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString
- slant:styleString "/ xlatedStyle
- spacing:spacing
- pixelSize:nil
- size:sizeArgOrNil
- registry:'*'
- encoding:encodingSym asLowercase.
-
- id isNil ifTrue:[
- id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString asLowercase
- slant:styleString asLowercase
- spacing:spacing
- pixelSize:nil
- size:sizeArgOrNil
- registry:'*'
- encoding:encodingSym asLowercase.
- ]
- ]
- ]
+ (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
+ "/ too stupid: encodings come in both cases
+ "/
+ id := self
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString
+ slant:styleString "/ xlatedStyle
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArgOrNil
+ registry:'*'
+ encoding:encodingSym asUppercase.
+ id isNil ifTrue:[
+ id := self
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString
+ slant:styleString "/ xlatedStyle
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArgOrNil
+ registry:'*'
+ encoding:encodingSym asLowercase.
+
+ id isNil ifTrue:[
+ id := self
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString asLowercase
+ slant:styleString asLowercase
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArgOrNil
+ registry:'*'
+ encoding:encodingSym asLowercase.
+ ]
+ ]
+ ]
].
^ id
@@ -4301,8 +4320,8 @@
!
getFontWithFoundry:foundry family:family weight:weight
- slant:slant spacing:spc pixelSize:pixelSize size:pointSize
- registry:registry encoding:encodingArg
+ slant:slant spacing:spc pixelSize:pixelSize size:pointSize
+ registry:registry encoding:encodingArg
"get the specified font, if not available, return nil.
For now, this is a poor (incomplete) emulation of the X code ...
@@ -4322,35 +4341,35 @@
"
Windows-NT/95 allows the creation of a font with the following parameters
- nHeight
- nWidth
- nEscapement
- nOrientation
- fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
- fdwItalic TRUE or FALSE
- fdwUnderline TRUE or FALSE
- fdwStrikeOut TRUE or FALSE
- fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
- fdwOutputPrecision DEFAULT, STRING, CHAR, ...
- fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ...
- fdwQuality DEFAULT, DRAFT, or PROOF.
- fdwPitchAndFamily
- DEFAULT, FIXED or VARIABLE pitch
- DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
- lpszFace
- Typeface Name
+ nHeight
+ nWidth
+ nEscapement
+ nOrientation
+ fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
+ fdwItalic TRUE or FALSE
+ fdwUnderline TRUE or FALSE
+ fdwStrikeOut TRUE or FALSE
+ fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
+ fdwOutputPrecision DEFAULT, STRING, CHAR, ...
+ fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ...
+ fdwQuality DEFAULT, DRAFT, or PROOF.
+ fdwPitchAndFamily
+ DEFAULT, FIXED or VARIABLE pitch
+ DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
+ lpszFace
+ Typeface Name
These two above descriptions will be matched as follows:
- foundry - ignored
- family - mapped to type face name.
- weight - mapped to fnWeight
- slant - used for style
- spacing - NOT USED INITIALLY
- pixelSize - NOT USED INITIALLY
- size - mapped to nHeight
- registry - NOT USED INITIALLY
- encoding - mapped to fdwCharSet
+ foundry - ignored
+ family - mapped to type face name.
+ weight - mapped to fnWeight
+ slant - used for style
+ spacing - NOT USED INITIALLY
+ pixelSize - NOT USED INITIALLY
+ size - mapped to nHeight
+ registry - NOT USED INITIALLY
+ encoding - mapped to fdwCharSet
"
|logSize encoding|
@@ -4358,13 +4377,13 @@
encoding := encodingArg asSymbol.
pixelSize notNil ifTrue:[
- logSize := pixelSize
+ logSize := pixelSize
] ifFalse:[
- logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
+ logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
].
%{
HGDIOBJ hFont;
- int pointSize, nHeight, nWidth, nEscapement, nOrientation;
+ int nHeight, nWidth, nEscapement, nOrientation;
char* work;
char* work2;
DWORD fnWeight;
@@ -4395,153 +4414,153 @@
fdwCharSet = ANSI_CHARSET;
if ((encoding == @symbol('ms-ansi'))) {
- fdwCharSet = ANSI_CHARSET;
+ fdwCharSet = ANSI_CHARSET;
} else if (encoding == @symbol('ms-default')
- || encoding == @symbol(*)) {
- fdwCharSet = DEFAULT_CHARSET;
+ || encoding == @symbol(*)) {
+ fdwCharSet = DEFAULT_CHARSET;
} else if ((encoding == @symbol('ms-symbol'))
- || (encoding == @symbol('misc-fontspecific'))) {
- fdwCharSet = SYMBOL_CHARSET;
+ || (encoding == @symbol('misc-fontspecific'))) {
+ fdwCharSet = SYMBOL_CHARSET;
} else if ((encoding == @symbol('ms-shiftjis'))
- || (encoding == @symbol('jisx0208.1983-0'))){
- fdwCharSet = SHIFTJIS_CHARSET;
+ || (encoding == @symbol('jisx0208.1983-0'))){
+ fdwCharSet = SHIFTJIS_CHARSET;
} else if ((encoding == @symbol('ms-gb2312'))
- || (encoding == @symbol('gb2312.1980-0'))) {
- fdwCharSet = GB2312_CHARSET;
+ || (encoding == @symbol('gb2312.1980-0'))) {
+ fdwCharSet = GB2312_CHARSET;
} else if ((encoding == @symbol('ms-hangeul'))
- || (encoding == @symbol('ksc5601.1987-0'))) {
- fdwCharSet = HANGEUL_CHARSET;
+ || (encoding == @symbol('ksc5601.1987-0'))) {
+ fdwCharSet = HANGEUL_CHARSET;
} else if ((encoding == @symbol('ms-chinesebig5'))
- || (encoding == @symbol('big5'))) {
- fdwCharSet = CHINESEBIG5_CHARSET;
+ || (encoding == @symbol('big5'))) {
+ fdwCharSet = CHINESEBIG5_CHARSET;
} else if (encoding == @symbol('ms-oem')) {
- fdwCharSet = OEM_CHARSET;
+ fdwCharSet = OEM_CHARSET;
} else if (encoding == @symbol('ms-johab')) {
- fdwCharSet = JOHAB_CHARSET;
+ fdwCharSet = JOHAB_CHARSET;
} else if ((encoding == @symbol('ms-hebrew'))
- || (encoding == @symbol('ms-cp1255'))) {
- fdwCharSet = HEBREW_CHARSET;
+ || (encoding == @symbol('ms-cp1255'))) {
+ fdwCharSet = HEBREW_CHARSET;
} else if ((encoding == @symbol('ms-arabic'))
- || (encoding == @symbol('ms-cp1256'))) {
- fdwCharSet = ARABIC_CHARSET;
+ || (encoding == @symbol('ms-cp1256'))) {
+ fdwCharSet = ARABIC_CHARSET;
} else if ((encoding == @symbol('ms-greek'))
- || (encoding == @symbol('ms-cp1253'))) {
- fdwCharSet = GREEK_CHARSET;
+ || (encoding == @symbol('ms-cp1253'))) {
+ fdwCharSet = GREEK_CHARSET;
} else if ((encoding == @symbol('ms-turkish'))
- || (encoding == @symbol('ms-cp1254'))) {
- fdwCharSet = TURKISH_CHARSET;
+ || (encoding == @symbol('ms-cp1254'))) {
+ fdwCharSet = TURKISH_CHARSET;
} else if ((encoding == @symbol('ms-russian'))
- || (encoding == @symbol('ms-cp1251'))) {
- fdwCharSet = RUSSIAN_CHARSET;
+ || (encoding == @symbol('ms-cp1251'))) {
+ fdwCharSet = RUSSIAN_CHARSET;
} else if ((encoding == @symbol('ms-easteurope'))
- || (encoding == @symbol('ms-cp1250'))) {
- fdwCharSet = EASTEUROPE_CHARSET;
+ || (encoding == @symbol('ms-cp1250'))) {
+ fdwCharSet = EASTEUROPE_CHARSET;
} else if ((encoding == @symbol('ms-baltic'))
- || (encoding == @symbol('ms-cp1257'))) {
- fdwCharSet = BALTIC_CHARSET;
+ || (encoding == @symbol('ms-cp1257'))) {
+ fdwCharSet = BALTIC_CHARSET;
} else if ((encoding == @symbol('ms-vietnamese'))) {
- fdwCharSet = VIETNAMESE_CHARSET;
+ fdwCharSet = VIETNAMESE_CHARSET;
} else if ((encoding == @symbol('ms-thai'))) {
- fdwCharSet = THAI_CHARSET;
+ fdwCharSet = THAI_CHARSET;
} else if ((encoding == @symbol('ms-mac'))) {
- fdwCharSet = MAC_CHARSET;
+ fdwCharSet = MAC_CHARSET;
#ifdef UNICODE_CHARSET
} else if ((encoding == @symbol('ms-unicode'))) {
- fdwCharSet = UNICODE_CHARSET;
+ fdwCharSet = UNICODE_CHARSET;
#endif
}
if ( __isString( family ) ) {
- work = __stringVal( family );
- if (strcmp( work, "nil" ) != 0 ) {
- strncpy( faceName, work, sizeof(faceName)-1 );
- }
+ work = __stringVal( family );
+ if (strcmp( work, "nil" ) != 0 ) {
+ strncpy( faceName, work, sizeof(faceName)-1 );
+ }
}
/* Q: should we allow those ? (they make ST/X programs less portable to X */
if( __isString( weight ) ) {
- work = __stringVal( weight );
- if (strcmp( work, "bold" ) == 0 ) {
- fnWeight = FW_BOLD;
- } else if (strcmp( work, "medium" ) == 0 ) {
- fnWeight = FW_MEDIUM;
- } else if (strcmp( work, "normal" ) == 0 ) {
- fnWeight = FW_NORMAL;
- } else if (strcmp( work, "light" ) == 0 ) {
- fnWeight = FW_LIGHT;
- } else if (strcmp( work, "demi" ) == 0 ) {
- fnWeight = FW_LIGHT;
- } else if (strcmp( work, "heavy" ) == 0 ) {
- fnWeight = FW_HEAVY;
- } else if (strcmp( work, "extraBold" ) == 0 ) {
- fnWeight = FW_EXTRABOLD;
- } else if (strcmp( work, "semiBold" ) == 0 ) {
- fnWeight = FW_SEMIBOLD;
- } else if (strcmp( work, "thin" ) == 0 ) {
- fnWeight = FW_THIN;
- } else if (strcmp( work, "extraLight" ) == 0 ) {
- fnWeight = FW_EXTRALIGHT;
- }
+ work = __stringVal( weight );
+ if (strcmp( work, "bold" ) == 0 ) {
+ fnWeight = FW_BOLD;
+ } else if (strcmp( work, "medium" ) == 0 ) {
+ fnWeight = FW_MEDIUM;
+ } else if (strcmp( work, "normal" ) == 0 ) {
+ fnWeight = FW_NORMAL;
+ } else if (strcmp( work, "light" ) == 0 ) {
+ fnWeight = FW_LIGHT;
+ } else if (strcmp( work, "demi" ) == 0 ) {
+ fnWeight = FW_LIGHT;
+ } else if (strcmp( work, "heavy" ) == 0 ) {
+ fnWeight = FW_HEAVY;
+ } else if (strcmp( work, "extraBold" ) == 0 ) {
+ fnWeight = FW_EXTRABOLD;
+ } else if (strcmp( work, "semiBold" ) == 0 ) {
+ fnWeight = FW_SEMIBOLD;
+ } else if (strcmp( work, "thin" ) == 0 ) {
+ fnWeight = FW_THIN;
+ } else if (strcmp( work, "extraLight" ) == 0 ) {
+ fnWeight = FW_EXTRALIGHT;
+ }
} else if (__isSmallInteger(weight)) {
- fnWeight = __intVal(weight);
+ fnWeight = __intVal(weight);
}
if(__isSmallInteger( logSize )) {
- nHeight = __intVal( logSize );
+ nHeight = __intVal( logSize );
}
if (__isString(slant)) {
- work2 = __stringVal( slant );
- work = __stringVal( slant );
-
- if (strncmp(work2, "italic", 6) == 0) {
- fdwItalic = TRUE;
- if ( work2[6] == '-' )
- strncpy( work, &work2[7], ( strlen( work2) - 7) );
- } else {
- if (strncmp(work2, "oblique", 7) == 0) {
- fdwItalic = TRUE;
- if ( work2[7] == '-' )
- strncpy( work, &work2[8], ( strlen( work2) - 8) );
- }
- }
- if (strncmp( work, "underline", 9 ) == 0 ) {
- fdwUnderline = TRUE;
- if( work[10] == '-' )
- strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
- }
- if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
- fdwStrikeOut = TRUE;
- }
+ work2 = __stringVal( slant );
+ work = __stringVal( slant );
+
+ if (strncmp(work2, "italic", 6) == 0) {
+ fdwItalic = TRUE;
+ if ( work2[6] == '-' )
+ strncpy( work, &work2[7], ( strlen( work2) - 7) );
+ } else {
+ if (strncmp(work2, "oblique", 7) == 0) {
+ fdwItalic = TRUE;
+ if ( work2[7] == '-' )
+ strncpy( work, &work2[8], ( strlen( work2) - 8) );
+ }
+ }
+ if (strncmp( work, "underline", 9 ) == 0 ) {
+ fdwUnderline = TRUE;
+ if( work[10] == '-' )
+ strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
+ }
+ if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
+ fdwStrikeOut = TRUE;
+ }
}
DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n",
- faceName, nHeight, nWidth, fnWeight));
+ faceName, nHeight, nWidth, fnWeight));
hFont = CreateFont( -nHeight, /* character height - not cell height */
- nWidth,
- nEscapement,
- nOrientation,
- fnWeight,
- fdwItalic,
- fdwUnderline,
- fdwStrikeOut,
- fdwCharSet,
- fdwOutputPrecision,
- fdwClipPrecision,
- fdwQuality,
- fdwPitchAndFamily,
- faceName );
+ nWidth,
+ nEscapement,
+ nOrientation,
+ fnWeight,
+ fdwItalic,
+ fdwUnderline,
+ fdwStrikeOut,
+ fdwCharSet,
+ fdwOutputPrecision,
+ fdwClipPrecision,
+ fdwQuality,
+ fdwPitchAndFamily,
+ faceName );
if (hFont != NULL) {
- DPRINTF(("createFont: %x\n", hFont));
+ DPRINTF(("createFont: %x\n", hFont));
/*
#ifdef COUNT_RESOURCES
- __cnt_font++;
- RES1PRINTF(("CreateFont %d\n", __cnt_font));
+ __cnt_font++;
+ RES1PRINTF(("CreateFont %d\n", __cnt_font));
#endif
*/
- RETURN ( __MKEXTERNALADDRESS(hFont) );
+ RETURN ( __MKEXTERNALADDRESS(hFont) );
}
DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
@@ -4550,14 +4569,14 @@
"
Display getFontWithFoundry:'*'
- family:'courier'
- weight:'medium'
- slant:'r'
- spacing:nil
- pixelSize:nil
- size:13
- registry:'iso8859'
- encoding:'*'
+ family:'courier'
+ weight:'medium'
+ slant:'r'
+ spacing:nil
+ pixelSize:nil
+ size:13
+ registry:'iso8859'
+ encoding:'*'
"
"new NT Version: 20.2.1997 / 22:33:29 / dq"
@@ -5028,35 +5047,35 @@
%{ /* NOCONTEXT */
if (__isExternalAddress(aDrawableId)){
- BITMAP bitmap;
- HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
- HBITMAP memBM;
- HANDLE compatibleDC, rootDC, hdcScreen;
+ BITMAP bitmap;
+ HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
+ HBITMAP memBM;
+ HANDLE compatibleDC, rootDC, hdcScreen;
// HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
- if (! hBitmap) {
- RETURN (nil);
- }
-
- if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
+ if (! hBitmap) {
+ RETURN (nil);
+ }
+
+ if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
/*
- DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
+ DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
*/
- } else {
+ } else {
/*
- DPRINTF(("noinfo returned for bitmap\n"));
+ DPRINTF(("noinfo returned for bitmap\n"));
*/
- /* mhmh - can this happen ? */
- bitmap.bmBitsPixel = 1;
- }
+ /* mhmh - can this happen ? */
+ bitmap.bmBitsPixel = 1;
+ }
/*
- gcData->hBitmap = hBitmap;
- gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
+ gcData->hBitmap = hBitmap;
+ gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
*/
- rootDC = CreateDC("DISPLAY", NULL, NULL, NULL);
- compatibleDC = CreateCompatibleDC(rootDC);
- SelectObject(compatibleDC, hBitmap);
+ rootDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ compatibleDC = CreateCompatibleDC(rootDC);
+ SelectObject(compatibleDC, hBitmap);
// hdcScreen= CreateDC("NULL", NULL, NULL, NULL);
// compatibleDC = rootDC;
@@ -5066,10 +5085,10 @@
// memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight );
// SelectObject ( compatibleDC, memBM );
- RETURN (__MKEXTERNALADDRESS(compatibleDC));
+ RETURN (__MKEXTERNALADDRESS(compatibleDC));
/*
- RETURN ( __MKEXTERNALADDRESS(gcData) );
+ RETURN ( __MKEXTERNALADDRESS(gcData) );
*/
}
RETURN (nil);
@@ -5093,20 +5112,21 @@
COLORREF fgColor;
HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
int lStyle, bkMode, hMask, maskOrgX, maskOrgY;
- int style, lineStyle, capStyle, joinStyle;
+ OBJ lineStyle, capStyle, joinStyle;
+ int style;
int lw;
int BK_TRANSPARENT;
BK_TRANSPARENT = 1;
- lw= __INST(lineWidth);
+ lw= __intVal(__INST(lineWidth));
/* fgColor = __intVal(__INST(foreground)) & 0xffffff; */
fgColor = GetTextColor(hDC);
lineStyle=__INST(lineStyle);
capStyle=__INST(capStyle);
joinStyle=__INST(joinStyle);
- hMask= __INST(mask);
+ hMask= __intVal(__INST(mask));
maskOrgX=__intVal(maskOriginX);
maskOrgY=__intVal(maskOriginY);
@@ -5155,12 +5175,12 @@
if (fgColor == 0 /* BlackPixel */ ) {
hPen = GetStockObject(BLACK_PEN);
prevPen = SelectObject(hDC, hPen);
- RETURN( hPen );
+ RETURN( __MKEXTERNALADDRESS(hPen) );
}
if (fgColor == 1 /* WhitePixel */) {
hPen = GetStockObject(WHITE_PEN);
prevPen = SelectObject(hDC, hPen);
- RETURN( hPen );
+ RETURN( __MKEXTERNALADDRESS(hPen) );
}
}
@@ -5280,8 +5300,7 @@
}
prevPen = SelectObject(hDC, hPen);
-
- RETURN (hPen);
+ RETURN (__MKEXTERNALADDRESS(hPen));
%}
!
@@ -5424,7 +5443,7 @@
|penHandle|
- penHandle := ExternalBytes address: self getPenForMyContext.
+ penHandle := self getPenForMyContext.
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aDC)
@@ -5502,14 +5521,14 @@
info := (self class getPrinterInformationString: self name) asUppercase.
(info includesSubString: ',PSCRIPT,')
- ifTrue: [
- retVal := self class postScriptBlackWhite not.
+ ifTrue: [
+ retVal := self class postScriptBlackWhite not.
"/ retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not.
- ]
- ifFalse: [
- retVal := (info includesSubString: 'PDF')
- ifTrue: [true]
- ifFalse: [self numberOfColorBitsPerPixel > 1].
+ ]
+ ifFalse: [
+ retVal := (info includesSubString: 'PDF')
+ ifTrue: [true]
+ ifFalse: [self numberOfColorBitsPerPixel > 1].
].
^retVal
@@ -5535,29 +5554,29 @@
|docInfoStruct nameAddress title fileNameAddress|
gcId isNil ifTrue:[
- self buildPrinter
+ self buildPrinter
].
abort := false.
title := aString ? 'Smalltalk/X'.
nameAddress := title asExternalBytes unprotectFromGC.
aFileName isNil ifFalse:[
- fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
+ fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
].
docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
docInfoStruct
- cbSize:docInfoStruct sizeInBytes;
- lpszDocName:nameAddress address.
+ cbSize:docInfoStruct sizeInBytes;
+ lpszDocName:nameAddress address.
fileNameAddress isNil ifFalse:[
- docInfoStruct lpszOutput:fileNameAddress address
+ docInfoStruct lpszOutput:fileNameAddress address
].
jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
jobid > 0 ifFalse:[
- jobid = -1 ifTrue:[
- abort := true.
- ^ nil
- ].
+ jobid = -1 ifTrue:[
+ abort := true.
+ ^ nil
+ ].
"/ ^ self error
- OpenError raiseErrorString:'Cannot create printer job'.
+ OpenError raiseErrorString:'Cannot create printer job'.
].
self startPage
@@ -5625,28 +5644,28 @@
examples
"
- [exBegin]
+ [exBegin]
|gc font|
gc := WinPrinterContext openGraphicContext.
gc isNil ifTrue:[^ self ].
[
- gc startPrintJob:'Test'.
- gc paint:(Color black).
- gc displayLineFromX:10 y:40 toX:100 y:40.
- font := (Font family:'helvetica' face:'roman' style:'bold' size:16) onDevice:(gc device).
-
- gc font:font.
- gc paint:(Color red).
- gc displayString:'hallo' x:10 y:(40 + font ascent).
-
- gc paint:(Color black).
- gc displayLineFromX:10 y:(40 + font height) toX:100 y:(40 + font height).
+ gc startPrintJob:'Test'.
+ gc paint:(Color black).
+ gc displayLineFromX:10 y:40 toX:100 y:40.
+ font := (Font family:'helvetica' face:'roman' style:'bold' size:16) onDevice:(gc device).
+
+ gc font:font.
+ gc paint:(Color red).
+ gc displayString:'hallo' x:10 y:(40 + font ascent).
+
+ gc paint:(Color black).
+ gc displayLineFromX:10 y:(40 + font height) toX:100 y:(40 + font height).
] ensure:[
- gc close.
+ gc close.
].
- [exEnd]
+ [exEnd]
"
! !
@@ -5712,10 +5731,10 @@
bot := top + extent y.
aRectangle notNil ifTrue:[
- lft := lft max:aRectangle left.
- top := top max:aRectangle top.
- rgt := rgt min:aRectangle right.
- bot := bot min:aRectangle bottom.
+ lft := lft max:aRectangle left.
+ top := top max:aRectangle top.
+ rgt := rgt min:aRectangle right.
+ bot := bot min:aRectangle bottom.
].
super clippingRectangle:(Rectangle left:lft top:top right:rgt bottom:bot).
!
@@ -5736,7 +5755,7 @@
"answer the transformation excluding the fontScale factor"
^ WindowingTransformation scale:(self scale)
- translation:(self translation).
+ translation:(self translation).
!
transformation:aTransformation
@@ -5745,8 +5764,8 @@
|s t|
aTransformation notNil ifTrue:[
- s := aTransformation scale.
- t := aTransformation translation.
+ s := aTransformation scale.
+ t := aTransformation translation.
].
self scale:s.
self translation:t.
@@ -5778,7 +5797,7 @@
trans := Point x:(self leftMargin) y:(self topMargin).
aTranslation notNil ifTrue:[
- trans := trans + aTranslation.
+ trans := trans + aTranslation.
].
super translation:((trans * fontScale) rounded).
@@ -5796,7 +5815,7 @@
end := aString size.
end ~~ 0 ifTrue:[
- self displayOpaqueString:aString from:1 to:end x:x y:y.
+ self displayOpaqueString:aString from:1 to:end x:x y:y.
].
!
@@ -5808,7 +5827,7 @@
index2 < index1 ifTrue:[^ self].
transformation isNil ifTrue:[
- self initTransformation.
+ self initTransformation.
].
tscale := transformation scale.
fscale := tscale / fontScale.
@@ -5819,8 +5838,8 @@
transformation scale:fscale.
super displayString:aString from:index1 to:index2
- x:xFont truncated
- y:yFont truncated.
+ x:xFont truncated
+ y:yFont truncated.
transformation scale:tscale.
!
@@ -5831,7 +5850,7 @@
end := aString size.
end ~~ 0 ifTrue:[
- self displayString:aString from:1 to:end x:x y:y.
+ self displayString:aString from:1 to:end x:x y:y.
].
!
@@ -5843,18 +5862,18 @@
angle := drawAngle.
angle >= 360 ifTrue:[
- angle := angle - (((angle // 360)) * 360)
+ angle := angle - (((angle // 360)) * 360)
] ifFalse:[
- angle < 0 ifTrue:[
- angle := angle - (((angle // 360)) * 360).
- angle := angle + 360.
- angle >= 360 ifTrue:[
- angle := angle - (((angle // 360)) * 360)
- ]
- ].
+ angle < 0 ifTrue:[
+ angle := angle - (((angle // 360)) * 360).
+ angle := angle + 360.
+ angle >= 360 ifTrue:[
+ angle := angle - (((angle // 360)) * 360)
+ ]
+ ].
].
angle == 0 ifTrue:[
- super displayString:aString x:x y:y angle:drawAngle opaque:opaque.
+ super displayString:aString x:x y:y angle:drawAngle opaque:opaque.
].
! !
@@ -5869,19 +5888,19 @@
metrics isNil ifTrue:[^ nil ].
metrics ascent:((metrics ascent / fontScale y) rounded)
- descent:((metrics descent / fontScale y) rounded + 1)
- maxAscent:((metrics maxAscent / fontScale y) rounded)
- maxDescent:((metrics maxDescent / fontScale y) rounded + 1)
- minWidth:((metrics minWidth / fontScale x) rounded)
- maxWidth:((metrics maxWidth / fontScale x) rounded)
- avgWidth:((metrics averageWidth / fontScale x) rounded).
+ descent:((metrics descent / fontScale y) rounded + 1)
+ maxAscent:((metrics maxAscent / fontScale y) rounded)
+ maxDescent:((metrics maxDescent / fontScale y) rounded + 1)
+ minWidth:((metrics minWidth / fontScale x) rounded)
+ maxWidth:((metrics maxWidth / fontScale x) rounded)
+ avgWidth:((metrics averageWidth / fontScale x) rounded).
^ metrics
!
getFontWithFoundry:foundry family:family weight:weight
- slant:slant spacing:spc pixelSize:pixelSize size:pointSize
- registry:registry encoding:encoding
+ slant:slant spacing:spc pixelSize:pixelSize size:pointSize
+ registry:registry encoding:encoding
"compute the pixels dependent on the Screen current resolution"
@@ -5889,21 +5908,21 @@
psize := pixelSize.
- psize isNil ifTrue:[
- psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded.
+ psize isNil ifTrue:[
+ psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded.
].
^ super getFontWithFoundry:foundry family:family weight:weight
- slant:slant spacing:spc pixelSize:psize size:pointSize
- registry:registry encoding:encoding
+ slant:slant spacing:spc pixelSize:psize size:pointSize
+ registry:registry encoding:encoding
!
titleFont
"answer the font used for displaying page numbers..."
titleFont isNil ifTrue:[
- titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10.
- titleFont := titleFont onDevice:(self device).
+ titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10.
+ titleFont := titleFont onDevice:(self device).
].
^ titleFont
!
@@ -5912,7 +5931,7 @@
"set the font used for displaying page numbers..."
(aFont notNil and:[aFont ~= titleFont]) ifTrue:[
- titleFont := aFont onDevice:(self device).
+ titleFont := aFont onDevice:(self device).
].
!
@@ -5952,10 +5971,10 @@
|margin|
transformation isNil ifTrue:[
- margin := Point x:(self leftMargin) y:(self topMargin).
-
- transformation := WindowingTransformation scale:fontScale
- translation:(margin * fontScale).
+ margin := Point x:(self leftMargin) y:(self topMargin).
+
+ transformation := WindowingTransformation scale:fontScale
+ translation:(margin * fontScale).
].
!
@@ -5967,13 +5986,13 @@
printPageNumbers := true.
Language == #de ifTrue:[ pageNumberFormat := 'Seite %1' ]
- ifFalse:[ pageNumberFormat := 'page %1' ].
+ ifFalse:[ pageNumberFormat := 'page %1' ].
! !
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'printing process'!
displayTitleDo:aNoneArgAction
-
+
|oldClip oldTrans oldFont|
oldClip := clipRect.
@@ -5999,18 +6018,18 @@
|s|
needsEndOfPage ifFalse:[
- ^ self
+ ^ self
].
needsEndOfPage := false.
printPageNumbers == true ifTrue:[
- self displayTitleDo:[
- s := pageNumberFormat bindWith:pageCounter.
-
- self displayString:s
- x:(self extent x - (font widthOf:s))
- y:(self extent y + (font ascent)).
- ]
+ self displayTitleDo:[
+ s := pageNumberFormat bindWith:pageCounter.
+
+ self displayString:s
+ x:(self extent x - (font widthOf:s))
+ y:(self extent y + (font ascent)).
+ ]
].
super endPage.
!
@@ -6020,7 +6039,7 @@
if the current page is not closed by endPage, a endPage is forward to the device"
needsEndOfPage ifTrue:[
- self endPage.
+ self endPage.
].
super startPage.
needsEndOfPage := true.
@@ -6031,7 +6050,7 @@
pixelPerInch
^ Point x:(self pixelsPerInchOfScreenWidth)
- y:(self pixelsPerInchOfScreenHeight).
+ y:(self pixelsPerInchOfScreenHeight).
!
resolution
@@ -6041,9 +6060,9 @@
!WinPrinterContext class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.42 2012-04-25 19:46:59 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.43 2013-01-11 15:09:26 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.42 2012-04-25 19:46:59 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.43 2013-01-11 15:09:26 cg Exp $'
! !