--- a/WinPrinterContext.st Tue Oct 23 10:56:21 2007 +0200
+++ b/WinPrinterContext.st Mon Oct 29 16:29:49 2007 +0100
@@ -1,6 +1,6 @@
"
COPYRIGHT (c) 2006 by eXept Software AG
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -12,10 +12,10 @@
"{ Package: 'stx:libview2' }"
PrinterContext subclass:#WinPrinterContext
- instanceVariableNames:'deviceFonts hatch supportsColor'
- classVariableNames:''
- poolDictionaries:''
- category:'Interface-Printing'
+ instanceVariableNames:'deviceFonts hatch supportsColor'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Printing'
!
!WinPrinterContext primitiveDefinitions!
@@ -196,7 +196,7 @@
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
- All Rights Reserved
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -215,7 +215,7 @@
When you open a printer, you will typically talk to me.
[author:]
- Felix Madrid (fm@exept.de)
+ Felix Madrid (fm@exept.de)
"
! !
@@ -253,9 +253,9 @@
h := OperatingSystem openPrinter:printerNameString.
^ OperatingSystem
- getDocumentProperties:nil
- hPrinter:h
- pDeviceName:printerNameString.
+ getDocumentProperties:nil
+ hPrinter:h
+ pDeviceName:printerNameString.
"Created: / 27-07-2006 / 10:22:32 / fm"
"Modified: / 01-08-2006 / 16:01:44 / fm"
@@ -303,31 +303,31 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Advanced Lines'.
- printer foreground:Color red background:Color white.
- pairOfPointsArray
- do:[:pairOfPointsAndContext |
- |pairOfPoints|
- pairOfPoints := pairOfPointsAndContext at:1.
- printer
- lineWidth: (pairOfPointsAndContext at:2);
- lineStyle: (pairOfPointsAndContext at:3);
- capStyle: (pairOfPointsAndContext at:4);
- joinStyle: (pairOfPointsAndContext at:5);
- foreground: (pairOfPointsAndContext at:6);
-
- displayAdvanceLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2).
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Advanced Lines'.
+ printer foreground:Color red background:Color white.
+ pairOfPointsArray
+ do:[:pairOfPointsAndContext |
+ |pairOfPoints|
+ pairOfPoints := pairOfPointsAndContext at:1.
+ printer
+ lineWidth: (pairOfPointsAndContext at:2);
+ lineStyle: (pairOfPointsAndContext at:3);
+ capStyle: (pairOfPointsAndContext at:4);
+ joinStyle: (pairOfPointsAndContext at:5);
+ foreground: (pairOfPointsAndContext at:6);
+
+ displayAdvanceLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2).
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printAdvancedLines:
- (Array with: (Array with: (Array with:10@10 with:1000@5000) with: 3 with:#dashed with: #butt with: #miter with: Color green)
- with: (Array with: (Array with:10@10 with:3500@2000) with: 2 with:#solid with: #butt with: #miter with: Color yellow)
- with: (Array with: (Array with:1000@800 with:6000@5000) with: 8 with:#dashed with: #butt with: #miter with: Color black)
- with: (Array with: (Array with:2000@2800 with:2000@5000) with: 1 with:#dashed with: #butt with: #miter with: Color red)
- )
+ (Array with: (Array with: (Array with:10@10 with:1000@5000) with: 3 with:#dashed with: #butt with: #miter with: Color green)
+ with: (Array with: (Array with:10@10 with:3500@2000) with: 2 with:#solid with: #butt with: #miter with: Color yellow)
+ with: (Array with: (Array with:1000@800 with:6000@5000) with: 8 with:#dashed with: #butt with: #miter with: Color black)
+ with: (Array with: (Array with:2000@2800 with:2000@5000) with: 1 with:#dashed with: #butt with: #miter with: Color red)
+ )
"
"Created: / 07-08-2006 / 12:09:48 / fm"
@@ -402,21 +402,21 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Circles'.
- arrayOfPointsAndRadiusWithContextArray
- do:[:pointsAndRadiusWithContextArray |
- printer foreground:(pointsAndRadiusWithContextArray at:3).
- printer fillCircle:(pointsAndRadiusWithContextArray at:1)
- radius:(pointsAndRadiusWithContextArray at:2).
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Circles'.
+ arrayOfPointsAndRadiusWithContextArray
+ do:[:pointsAndRadiusWithContextArray |
+ printer foreground:(pointsAndRadiusWithContextArray at:3).
+ printer fillCircle:(pointsAndRadiusWithContextArray at:1)
+ radius:(pointsAndRadiusWithContextArray at:2).
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillCircles:
- (Array with: (Array with: 800@800 with: 600 with:Color red)
- with: (Array with: 1500@1500 with: 1000 with:Color blue)
- with: (Array with: 4000@2500 with: 2000 with:Color gray))
+ (Array with: (Array with: 800@800 with: 600 with:Color red)
+ with: (Array with: 1500@1500 with: 1000 with:Color blue)
+ with: (Array with: 4000@2500 with: 2000 with:Color gray))
"
"Created: / 07-08-2006 / 11:46:52 / fm"
@@ -559,33 +559,33 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Polygons'.
- polygonsWithContextArray
- do:[:polygonWithContextArray |
- |aPolygon|
- aPolygon := polygonWithContextArray at: 1.
- printer foreground:(polygonWithContextArray at: 2).
- aPolygon displayFilledOn: printer.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Polygons'.
+ polygonsWithContextArray
+ do:[:polygonWithContextArray |
+ |aPolygon|
+ aPolygon := polygonWithContextArray at: 1.
+ printer foreground:(polygonWithContextArray at: 2).
+ aPolygon displayFilledOn: printer.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillPolygons:
- (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: (Array with: (Polygon vertices:(
- Array
- with:1000@1000
- with:1000@2000
- with:2000@1000))
- with: Color blue)
+ (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: (Array with: (Polygon vertices:(
+ Array
+ with:1000@1000
+ with:1000@2000
+ with:2000@1000))
+ with: Color blue)
)
"
@@ -604,25 +604,25 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Fill Rectangles'.
- printer foreground:Color blue background:Color white.
- rectangles
- do:[:rectangle |
- printer fillRectangleX: rectangle origin x
- y: rectangle origin y
- width: rectangle width
- height: rectangle height.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Fill Rectangles'.
+ printer foreground:Color blue background:Color white.
+ rectangles
+ do:[:rectangle |
+ printer fillRectangleX: rectangle origin x
+ y: rectangle origin y
+ width: rectangle width
+ height: rectangle height.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext fillRectangles:
- (Array with: (Rectangle left:20 top:20 width:400 height:600)
- with: (Rectangle left:500 top:700 width:600 height:400)
- with: (Rectangle left:800 top:1000 width:1600 height:2000)
- with: (Rectangle left:1040 top:1240 width:3000 height:3000)
- )
+ (Array with: (Rectangle left:20 top:20 width:400 height:600)
+ with: (Rectangle left:500 top:700 width:600 height:400)
+ with: (Rectangle left:800 top:1000 width:1600 height:2000)
+ with: (Rectangle left:1040 top:1240 width:3000 height:3000)
+ )
"
"Created: / 07-08-2006 / 11:40:48 / fm"
@@ -685,21 +685,21 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Circles'.
- printer foreground:Color green background:Color white.
- arrayOfPointsAndRadius
- do:[:pointAndRadius |
- printer displayCircle:(pointAndRadius at:1)
- radius:(pointAndRadius at:2).
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Circles'.
+ printer foreground:Color green background:Color white.
+ arrayOfPointsAndRadius
+ do:[:pointAndRadius |
+ printer displayCircle:(pointAndRadius at:1)
+ radius:(pointAndRadius at:2).
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printCircles:
- (Array with: (Array with: 800@800 with: 600)
- with: (Array with: 1500@1500 with: 1000)
- with: (Array with: 4000@2500 with: 2000))
+ (Array with: (Array with: 800@800 with: 600)
+ with: (Array with: 1500@1500 with: 1000)
+ with: (Array with: 4000@2500 with: 2000))
"
"Created: / 07-08-2006 / 11:46:52 / fm"
@@ -716,19 +716,19 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Circles In Rectangles'.
- rectangles
- do:[:rectangle |
- printer displayCircleIn: rectangle.
- ].
+ printer startPrintJob: 'Circles In Rectangles'.
+ rectangles
+ do:[:rectangle |
+ printer displayCircleIn: rectangle.
+ ].
printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printCirclesIn:
- (Array with: (Rectangle left:20 top:20 width:400 height:600)
- with: (Rectangle left:40 top:40 width:600 height:400)
- )
+ (Array with: (Rectangle left:20 top:20 width:400 height:600)
+ with: (Rectangle left:40 top:40 width:600 height:400)
+ )
"
"Created: / 07-08-2006 / 11:48:46 / fm"
@@ -773,26 +773,26 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Lines'.
- pairOfPointsWithContextArray
- do:[:pairOfPointsAndContext |
- |pairOfPoints|
- pairOfPoints := pairOfPointsAndContext at: 1.
- printer
- foreground:(pairOfPointsAndContext at:2);
- lineWidth: (pairOfPointsAndContext at:3);
- lineStyle: (pairOfPointsAndContext at:4);
- displayLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2).
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Lines'.
+ pairOfPointsWithContextArray
+ do:[:pairOfPointsAndContext |
+ |pairOfPoints|
+ pairOfPoints := pairOfPointsAndContext at: 1.
+ printer
+ foreground:(pairOfPointsAndContext at:2);
+ lineWidth: (pairOfPointsAndContext at:3);
+ lineStyle: (pairOfPointsAndContext at:4);
+ displayLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2).
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printLines:
- (Array with: (Array with:(Array with:10@10 with:1000@5000) with: Color red with:4 with: #solid)
- with: (Array with:(Array with:10@10 with:3500@2000) with: Color blue with:1 with: #dashed)
- with: (Array with:(Array with:1000@800 with:6000@5000) with: Color black with: 1 with:#dotted)
- with: (Array with: (Array with:2000@2800 with:2000@5000) with: Color green with:8 with: nil))
+ (Array with: (Array with:(Array with:10@10 with:1000@5000) with: Color red with:4 with: #solid)
+ with: (Array with:(Array with:10@10 with:3500@2000) with: Color blue with:1 with: #dashed)
+ with: (Array with:(Array with:1000@800 with:6000@5000) with: Color black with: 1 with:#dotted)
+ with: (Array with: (Array with:2000@2800 with:2000@5000) with: Color green with:8 with: nil))
"
"Created: / 07-08-2006 / 12:09:48 / fm"
@@ -810,22 +810,22 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Points'.
- aCollectionOfPoints do:[:each |
- printer displayPointX: each x y: each y.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Points'.
+ aCollectionOfPoints do:[:each |
+ printer displayPointX: each x y: each y.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printPoints:
- (Array with: (10 @ 10)
- with: (500 @ 700)
- with: (900 @ 1000)
- with: (1500 @ 1700)
- with: (2100 @ 2000)
- with: (2500 @ 2700)
- )
+ (Array with: (10 @ 10)
+ with: (500 @ 700)
+ with: (900 @ 1000)
+ with: (1500 @ 1700)
+ with: (2100 @ 2000)
+ with: (2500 @ 2700)
+ )
"
!
@@ -839,29 +839,29 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Polygons'.
- printer foreground:Color black background:Color white.
- polygons
- do:[:aPolygon |
- aPolygon displayStrokedOn: printer.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Polygons'.
+ printer foreground:Color black background:Color white.
+ polygons
+ do:[:aPolygon |
+ aPolygon displayStrokedOn: printer.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printPolygons:
- (Array with: (Polygon vertices:(
- Array
- with:100@100
- with:600@1000
- with:3500@4000
- with:100@4000
- with:100@100))
- with: (Polygon vertices:(
- Array
- with:1000@1000
- with:1000@2000
- with:2000@1000)))
+ (Array with: (Polygon vertices:(
+ Array
+ with:100@100
+ with:600@1000
+ with:3500@4000
+ with:100@4000
+ with:100@100))
+ with: (Polygon vertices:(
+ Array
+ with:1000@1000
+ with:1000@2000
+ with:2000@1000)))
"
"Created: / 07-08-2006 / 12:09:48 / fm"
@@ -879,20 +879,20 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Polylines'.
- printer displayPolylines:evenCollectionOfPoints.
- printer endPrintJob.
+ printer startPrintJob: 'Polylines'.
+ printer displayPolylines:evenCollectionOfPoints.
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printPolylines:
- (Array with: (10 @ 10)
- with: (500 @ 700)
- with: (900 @ 1000)
- with: (1500 @ 1700)
- with: (2100 @ 2000)
- with: (2500 @ 2700)
- )
+ (Array with: (10 @ 10)
+ with: (500 @ 700)
+ with: (900 @ 1000)
+ with: (1500 @ 1700)
+ with: (2100 @ 2000)
+ with: (2500 @ 2700)
+ )
"
"Created: / 07-08-2006 / 11:40:48 / fm"
@@ -909,31 +909,31 @@
printer := self fromPrinterInfo: printerInfo.
[
- printer startPrintJob: 'Rectangles'.
- printer foreground:Color red background:Color white.
- rectanglesWithContextArray do:[:rectangleWithContextArray |
- |rectangle|
- rectangle := rectangleWithContextArray at: 1.
- printer
- foreground:(rectangleWithContextArray at:2);
- lineWidth: (rectangleWithContextArray at:3);
- lineStyle: (rectangleWithContextArray at:4);
- displayRectangleX: rectangle origin x
- y: rectangle origin y
- width: rectangle width
- height: rectangle height.
- ].
- printer endPrintJob.
+ printer startPrintJob: 'Rectangles'.
+ printer foreground:Color red background:Color white.
+ rectanglesWithContextArray do:[:rectangleWithContextArray |
+ |rectangle|
+ rectangle := rectangleWithContextArray at: 1.
+ printer
+ foreground:(rectangleWithContextArray at:2);
+ lineWidth: (rectangleWithContextArray at:3);
+ lineStyle: (rectangleWithContextArray at:4);
+ displayRectangleX: rectangle origin x
+ y: rectangle origin y
+ width: rectangle width
+ height: rectangle height.
+ ].
+ printer endPrintJob.
] forkAt: 3
"
WinPrinterContext printRectangles:
- (Array with: (Array with: (Rectangle left:30 top:10 width:400 height:600) with: Color red with:4 with: #solid)
- with: (Array with: (Rectangle left:100 top:140 width:700 height:800) with: Color blue with:1 with: #dashed)
- with: (Array with: (Rectangle left:800 top:1500 width:2600 height:3400) with: Color green with:1 with: #dotted)
- with: (Array with: (Rectangle left:1000 top:1200 width:1400 height:1600) with: Color gray with:8 with: #dashed)
- with: (Array with: (Rectangle left:2600 top:1200 width:1400 height:1600) with: Color darkGray with:1 with: #dashDotDot)
- )
+ (Array with: (Array with: (Rectangle left:30 top:10 width:400 height:600) with: Color red with:4 with: #solid)
+ with: (Array with: (Rectangle left:100 top:140 width:700 height:800) with: Color blue with:1 with: #dashed)
+ with: (Array with: (Rectangle left:800 top:1500 width:2600 height:3400) with: Color green with:1 with: #dotted)
+ with: (Array with: (Rectangle left:1000 top:1200 width:1400 height:1600) with: Color gray with:8 with: #dashed)
+ with: (Array with: (Rectangle left:2600 top:1200 width:1400 height:1600) with: Color darkGray with:1 with: #dashDotDot)
+ )
"
"Created: / 07-08-2006 / 11:40:48 / fm"
@@ -950,21 +950,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 standart method' with:10@10)
- with: (Array with:'Another test string to print' with:80@200))
+ (Array with: (Array with:'Testing printing with standart method' with:10@10)
+ with: (Array with:'Another test string to print' with:80@200))
"
"Created: / 07-08-2006 / 12:09:48 / fm"
@@ -1107,13 +1107,13 @@
int id, ir, ig, ib;
if (__bothSmallInteger(r, g) && __isSmallInteger(b)) {
- ir = (__intVal(r) >> 8) & 0xff;
- ig = (__intVal(g) >> 8) & 0xff;
- ib = (__intVal(b) >> 8) & 0xff;
-
- id = RGB( ir, ig, ib);
-
- RETURN ( __MKSMALLINT(id) );
+ ir = (__intVal(r) >> 8) & 0xff;
+ ig = (__intVal(g) >> 8) & 0xff;
+ ib = (__intVal(b) >> 8) & 0xff;
+
+ id = RGB( ir, ig, ib);
+
+ RETURN ( __MKSMALLINT(id) );
}
%}.
self primitiveFailed.
@@ -1128,19 +1128,19 @@
HDC hDC;
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF bg, oldBg;
-
- oldBg = GetBkColor(hDC);
-
- bg = __intVal(bgColorIndex) & 0xffffff;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF bg, oldBg;
+
+ oldBg = GetBkColor(hDC);
+
+ bg = __intVal(bgColorIndex) & 0xffffff;
/* bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData); */
- if (bg != oldBg) {
- SetBkColor(hDC, bg);
- }
-
- RETURN (self);
+ if (bg != oldBg) {
+ SetBkColor(hDC, bg);
+ }
+
+ RETURN (self);
}
%}
!
@@ -1151,17 +1151,17 @@
|colorId deviceColor|
(color isOnDevice:self) ifTrue:[
- colorId := color colorId.
+ colorId := color colorId.
] ifFalse:[
- deviceColor := color onDevice:self.
- deviceColor notNil ifTrue:[
- colorId := deviceColor colorId.
- ]
+ deviceColor := color onDevice:self.
+ deviceColor notNil ifTrue:[
+ colorId := deviceColor colorId.
+ ]
].
colorId isNil ifTrue:[
- 'DeviceWorkstation [warning]: could not set bg color' infoPrintCR.
+ 'DeviceWorkstation [warning]: could not set bg color' infoPrintCR.
] ifFalse:[
- self setBackground:colorId in:aGCId.
+ self setBackground:colorId in:aGCId.
]
!
@@ -1171,27 +1171,27 @@
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fg, bg, oldFg, oldBg;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fg, bg, oldFg, oldBg;
/* fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData); */
- fg = __intVal(fgColorIndex) & 0xffffff;
+ fg = __intVal(fgColorIndex) & 0xffffff;
/* bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData); */
- bg = __intVal(bgColorIndex) & 0xffffff;
-
- oldFg = GetTextColor(hDC);
- oldBg = GetBkColor(hDC);
-
- if ((fg != oldFg) || (bg != oldBg)) {
- /* Pen only depends upon fg-color */
- if (fg != oldFg) {
- SetTextColor(hDC, fg);
- }
- if (bg != oldBg) {
- SetBkColor(hDC, bg);
- }
- }
- RETURN (self);
+ bg = __intVal(bgColorIndex) & 0xffffff;
+
+ oldFg = GetTextColor(hDC);
+ oldBg = GetBkColor(hDC);
+
+ if ((fg != oldFg) || (bg != oldBg)) {
+ /* Pen only depends upon fg-color */
+ if (fg != oldFg) {
+ SetTextColor(hDC, fg);
+ }
+ if (bg != oldBg) {
+ SetBkColor(hDC, bg);
+ }
+ }
+ RETURN (self);
}
%}
!
@@ -1204,19 +1204,19 @@
HDC hDC;
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fg, oldFg;
-
- oldFg = GetTextColor(hDC);
-
- fg = __intVal(fgColorIndex) & 0xffffff;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fg, oldFg;
+
+ oldFg = GetTextColor(hDC);
+
+ fg = __intVal(fgColorIndex) & 0xffffff;
/* fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData); */
- if (fg != oldFg) {
- SetTextColor(hDC, fg);
- }
-
- RETURN (self);
+ if (fg != oldFg) {
+ SetTextColor(hDC, fg);
+ }
+
+ RETURN (self);
}
%}
!
@@ -1227,17 +1227,17 @@
|colorId deviceColor|
(color isOnDevice:self) ifTrue:[
- colorId := color colorId.
+ colorId := color colorId.
] ifFalse:[
- deviceColor := color onDevice:self.
- deviceColor notNil ifTrue:[
- colorId := deviceColor colorId.
- ]
+ deviceColor := color onDevice:self.
+ deviceColor notNil ifTrue:[
+ colorId := deviceColor colorId.
+ ]
].
colorId isNil ifTrue:[
- 'DeviceWorkstation [warning]: could not set fg color' infoPrintCR.
+ 'DeviceWorkstation [warning]: could not set fg color' infoPrintCR.
] ifFalse:[
- self setForeground:colorId in:aGCId.
+ self setForeground:colorId in:aGCId.
]
! !
@@ -1250,52 +1250,52 @@
if (__isExternalAddressLike(aDC)
&& __isSmallInteger(__INST(lineWidth))) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fgColor;
- HANDLE hPen, prevPen;
- int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
-
- lineWidth= __INST(lineWidth);
-
- if (__INST(lineStyle) == @symbol(solid)) {
- lineStyleInt= PS_SOLID;
- } else if (__INST(lineStyle) == @symbol(dashed)) {
- lineStyleInt= PS_DASH;
- } else if (__INST(lineStyle) == @symbol(dotted)) {
- lineStyleInt= PS_DOT;
- } else if (__INST(lineStyle) == @symbol(dashDot)) {
- lineStyleInt= PS_DASHDOT;
- } else if (__INST(lineStyle) == @symbol(dashDotDot)) {
- lineStyleInt= PS_DASHDOTDOT;
- } else
- lineStyleInt= PS_SOLID;
-
- if (__INST(capStyle) == @symbol(round)) {
- capStyleInt= PS_ENDCAP_ROUND;
- } else if (__INST(capStyle) == @symbol(square)) {
- capStyleInt= PS_ENDCAP_SQUARE;
- } else if (__INST(capStyle) == @symbol(flat)) {
- capStyleInt= PS_ENDCAP_FLAT;
- } else
- capStyleInt= PS_ENDCAP_FLAT;
-
- if (__INST(joinStyle) == @symbol(bevel)) {
- joinStyleInt= PS_JOIN_BEVEL;
- } else if (__INST(joinStyle) == @symbol(miter)) {
- joinStyleInt= PS_JOIN_MITER;
- } else if (__INST(joinStyle) == @symbol(round)) {
- joinStyleInt= PS_JOIN_ROUND;
- } else
- joinStyleInt= PS_JOIN_MITER;
-
-
- fgColor = GetTextColor(hDC);
-
- hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
- prevPen = SelectObject(hDC, hPen);
-
-
- RETURN (self);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fgColor;
+ HANDLE hPen, prevPen;
+ int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
+
+ lineWidth= __INST(lineWidth);
+
+ if (__INST(lineStyle) == @symbol(solid)) {
+ lineStyleInt= PS_SOLID;
+ } else if (__INST(lineStyle) == @symbol(dashed)) {
+ lineStyleInt= PS_DASH;
+ } else if (__INST(lineStyle) == @symbol(dotted)) {
+ lineStyleInt= PS_DOT;
+ } else if (__INST(lineStyle) == @symbol(dashDot)) {
+ lineStyleInt= PS_DASHDOT;
+ } else if (__INST(lineStyle) == @symbol(dashDotDot)) {
+ lineStyleInt= PS_DASHDOTDOT;
+ } else
+ lineStyleInt= PS_SOLID;
+
+ if (__INST(capStyle) == @symbol(round)) {
+ capStyleInt= PS_ENDCAP_ROUND;
+ } else if (__INST(capStyle) == @symbol(square)) {
+ capStyleInt= PS_ENDCAP_SQUARE;
+ } else if (__INST(capStyle) == @symbol(flat)) {
+ capStyleInt= PS_ENDCAP_FLAT;
+ } else
+ capStyleInt= PS_ENDCAP_FLAT;
+
+ if (__INST(joinStyle) == @symbol(bevel)) {
+ joinStyleInt= PS_JOIN_BEVEL;
+ } else if (__INST(joinStyle) == @symbol(miter)) {
+ joinStyleInt= PS_JOIN_MITER;
+ } else if (__INST(joinStyle) == @symbol(round)) {
+ joinStyleInt= PS_JOIN_ROUND;
+ } else
+ joinStyleInt= PS_JOIN_MITER;
+
+
+ fgColor = GetTextColor(hDC);
+
+ hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
+ prevPen = SelectObject(hDC, hPen);
+
+
+ RETURN (self);
}
%}.
self primitiveFailed
@@ -1308,50 +1308,50 @@
if (__isExternalAddressLike(__INST(gcId))
&& __isSmallInteger(__INST(lineWidth))) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
- COLORREF fgColor;
- HANDLE hPen;
- int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
-
- lineWidth= __INST(lineWidth);
-
- if (__INST(lineStyle) == @symbol(solid)) {
- lineStyleInt= PS_SOLID;
- } else if (__INST(lineStyle) == @symbol(dashed)) {
- lineStyleInt= PS_DASH;
- } else if (__INST(lineStyle) == @symbol(dotted)) {
- lineStyleInt= PS_DOT;
- } else if (__INST(lineStyle) == @symbol(dashDot)) {
- lineStyleInt= PS_DASHDOT;
- } else if (__INST(lineStyle) == @symbol(dashDotDot)) {
- lineStyleInt= PS_DASHDOTDOT;
- } else
- lineStyleInt= PS_SOLID;
-
- if (__INST(capStyle) == @symbol(round)) {
- capStyleInt= PS_ENDCAP_ROUND;
- } else if (__INST(capStyle) == @symbol(square)) {
- capStyleInt= PS_ENDCAP_SQUARE;
- } else if (__INST(capStyle) == @symbol(flat)) {
- capStyleInt= PS_ENDCAP_FLAT;
- } else
- capStyleInt= PS_ENDCAP_FLAT;
-
- if (__INST(joinStyle) == @symbol(bevel)) {
- joinStyleInt= PS_JOIN_BEVEL;
- } else if (__INST(joinStyle) == @symbol(miter)) {
- joinStyleInt= PS_JOIN_MITER;
- } else if (__INST(joinStyle) == @symbol(round)) {
- joinStyleInt= PS_JOIN_ROUND;
- } else
- joinStyleInt= PS_JOIN_MITER;
-
-
- fgColor = GetTextColor(hDC);
-
- hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
-
- RETURN (self);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
+ COLORREF fgColor;
+ HANDLE hPen;
+ int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
+
+ lineWidth= __INST(lineWidth);
+
+ if (__INST(lineStyle) == @symbol(solid)) {
+ lineStyleInt= PS_SOLID;
+ } else if (__INST(lineStyle) == @symbol(dashed)) {
+ lineStyleInt= PS_DASH;
+ } else if (__INST(lineStyle) == @symbol(dotted)) {
+ lineStyleInt= PS_DOT;
+ } else if (__INST(lineStyle) == @symbol(dashDot)) {
+ lineStyleInt= PS_DASHDOT;
+ } else if (__INST(lineStyle) == @symbol(dashDotDot)) {
+ lineStyleInt= PS_DASHDOTDOT;
+ } else
+ lineStyleInt= PS_SOLID;
+
+ if (__INST(capStyle) == @symbol(round)) {
+ capStyleInt= PS_ENDCAP_ROUND;
+ } else if (__INST(capStyle) == @symbol(square)) {
+ capStyleInt= PS_ENDCAP_SQUARE;
+ } else if (__INST(capStyle) == @symbol(flat)) {
+ capStyleInt= PS_ENDCAP_FLAT;
+ } else
+ capStyleInt= PS_ENDCAP_FLAT;
+
+ if (__INST(joinStyle) == @symbol(bevel)) {
+ joinStyleInt= PS_JOIN_BEVEL;
+ } else if (__INST(joinStyle) == @symbol(miter)) {
+ joinStyleInt= PS_JOIN_MITER;
+ } else if (__INST(joinStyle) == @symbol(round)) {
+ joinStyleInt= PS_JOIN_ROUND;
+ } else
+ joinStyleInt= PS_JOIN_MITER;
+
+
+ fgColor = GetTextColor(hDC);
+
+ hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
+
+ RETURN (self);
}
%}.
self primitiveFailed
@@ -1396,10 +1396,10 @@
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
-
- SelectClipRgn(hDC, NULL);
- RETURN (self);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+
+ SelectClipRgn(hDC, NULL);
+ RETURN (self);
}
%}
!
@@ -1410,20 +1410,20 @@
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- HBITMAP oldM;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ HBITMAP oldM;
/* oldM = gcData->hMask;
- if (__isExternalAddress(aBitmapId))
- gcData->hMask = _HBITMAPVAL(aBitmapId);
- else
- gcData->hMask = 0;
-
- if (oldM != gcData->hMask) {
- FLUSH_CACHED_DC(gcData);
- CPRINTF(("masks set to %x\n",gcData->hMask));
- } */
- RETURN (self);
+ if (__isExternalAddress(aBitmapId))
+ gcData->hMask = _HBITMAPVAL(aBitmapId);
+ else
+ gcData->hMask = 0;
+
+ if (oldM != gcData->hMask) {
+ FLUSH_CACHED_DC(gcData);
+ CPRINTF(("masks set to %x\n",gcData->hMask));
+ } */
+ RETURN (self);
}
%}
!
@@ -1437,7 +1437,7 @@
h | the clipping rectangle
| |
-------
- where p = ( clipX, clipY ), w = clipWidth, h = clipHeight
+ where p = ( clipX, clipY ), w = clipWidth, h = clipHeight
"
%{ /* NOCONTEXT */
@@ -1445,36 +1445,36 @@
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(clipX, clipY)
&& __bothSmallInteger(clipWidth, clipHeight) ) {
- HANDLE hDC;
- int cX, cY, cW, cH;
- POINT ptOrg;
-
-
- hDC = (HANDLE)(__externalAddressVal(aDC));
-
- GetViewportOrgEx(hDC,&ptOrg);
-
- // set the clip rectangle
- // and offset the rectangle by the viewport origin
-
- cX = __intVal(clipX) + ptOrg.x;
- cY = __intVal(clipY) + ptOrg.y;
- cW = __intVal(clipWidth)+ ptOrg.x;
- cH = __intVal(clipHeight)+ ptOrg.y;
-
- {
- HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
-
- if (region == NULL ) {
- console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
- } else {
- if (SelectClipRgn(hDC, region) == ERROR ) {
- console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
- }
- DeleteObject(region);
- }
- }
- RETURN (self);
+ HANDLE hDC;
+ int cX, cY, cW, cH;
+ POINT ptOrg;
+
+
+ hDC = (HANDLE)(__externalAddressVal(aDC));
+
+ GetViewportOrgEx(hDC,&ptOrg);
+
+ // set the clip rectangle
+ // and offset the rectangle by the viewport origin
+
+ cX = __intVal(clipX) + ptOrg.x;
+ cY = __intVal(clipY) + ptOrg.y;
+ cW = __intVal(clipWidth)+ ptOrg.x;
+ cH = __intVal(clipHeight)+ ptOrg.y;
+
+ {
+ HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
+
+ if (region == NULL ) {
+ console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
+ } else {
+ if (SelectClipRgn(hDC, region) == ERROR ) {
+ console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
+ }
+ DeleteObject(region);
+ }
+ }
+ RETURN (self);
}
%}.
self primitiveFailed
@@ -1486,7 +1486,7 @@
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aGCId)) {
- DPRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
+ DPRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
}
%}
!
@@ -1500,42 +1500,42 @@
if (__isExternalAddressLike(aDC)
&& __isSmallInteger(aNumber)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- int style;
-
- if (lineStyle == @symbol(solid)) {
- style = PS_SOLID;
- } else if (lineStyle == @symbol(dashed)) {
- style= PS_DASH;
- } else if (lineStyle == @symbol(dotted)) {
- style= PS_DOT;
- } else if (lineStyle == @symbol(dashDot)) {
- style= PS_DASHDOT;
- } else if (lineStyle == @symbol(dashDotDot)) {
- style= PS_DASHDOTDOT;
- } else
- style= PS_SOLID;
-
- if (capStyle == @symbol(round)) {
- style = PS_ENDCAP_ROUND;
- } else if (capStyle == @symbol(square)) {
- style = PS_ENDCAP_SQUARE;
- } else if (capStyle == @symbol(flat)) {
- style = PS_ENDCAP_FLAT;
- } else
- style = PS_ENDCAP_FLAT;
-
- if (joinStyle == @symbol(bevel)) {
- style = PS_JOIN_BEVEL;
- } else if (joinStyle == @symbol(miter)) {
- style = PS_JOIN_MITER;
- } else if (joinStyle == @symbol(round)) {
- style = PS_JOIN_ROUND;
- } else
- style = PS_JOIN_MITER;
-
-
- RETURN (self);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ int style;
+
+ if (lineStyle == @symbol(solid)) {
+ style = PS_SOLID;
+ } else if (lineStyle == @symbol(dashed)) {
+ style= PS_DASH;
+ } else if (lineStyle == @symbol(dotted)) {
+ style= PS_DOT;
+ } else if (lineStyle == @symbol(dashDot)) {
+ style= PS_DASHDOT;
+ } else if (lineStyle == @symbol(dashDotDot)) {
+ style= PS_DASHDOTDOT;
+ } else
+ style= PS_SOLID;
+
+ if (capStyle == @symbol(round)) {
+ style = PS_ENDCAP_ROUND;
+ } else if (capStyle == @symbol(square)) {
+ style = PS_ENDCAP_SQUARE;
+ } else if (capStyle == @symbol(flat)) {
+ style = PS_ENDCAP_FLAT;
+ } else
+ style = PS_ENDCAP_FLAT;
+
+ if (joinStyle == @symbol(bevel)) {
+ style = PS_JOIN_BEVEL;
+ } else if (joinStyle == @symbol(miter)) {
+ style = PS_JOIN_MITER;
+ } else if (joinStyle == @symbol(round)) {
+ style = PS_JOIN_ROUND;
+ } else
+ style = PS_JOIN_MITER;
+
+
+ RETURN (self);
}
%}.
self primitiveFailed
@@ -1548,17 +1548,17 @@
if (__isExternalAddress(aDC)
&& __bothSmallInteger(orgX,orgY)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- int oX, oY, maskOrgX, maskOrgY;
-
- oX = __intVal(orgX);
- oY = __intVal(orgY);
- if ((oX != maskOrgX)
- || (oY != maskOrgY)) {
- maskOrgX = __intVal(orgX);
- maskOrgY = __intVal(orgY);;
- }
- RETURN (self);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ int oX, oY, maskOrgX, maskOrgY;
+
+ oX = __intVal(orgX);
+ oY = __intVal(orgY);
+ if ((oX != maskOrgX)
+ || (oY != maskOrgY)) {
+ maskOrgX = __intVal(orgX);
+ maskOrgY = __intVal(orgY);;
+ }
+ RETURN (self);
}
%}
!
@@ -1568,10 +1568,10 @@
"Sets the viewport origin (LOGICAL point (0,0)) of the device context"
^ OperatingSystem
- setViewportOrg: gcId "deviceContext"
- x: aPoint x
- y: aPoint y
- oldOrigin: nil
+ setViewportOrg: gcId "deviceContext"
+ x: aPoint x
+ y: aPoint y
+ oldOrigin: nil
"Created: / 01-08-2006 / 16:14:08 / fm"
! !
@@ -1588,105 +1588,105 @@
double f;
if (__isSmallInteger(startAngle))
- angle1 = (float)(__intVal(startAngle));
+ angle1 = (float)(__intVal(startAngle));
else if (__isFloat(startAngle)) {
- angle1 = (float) __floatVal(startAngle);
+ angle1 = (float) __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 = (float) __floatVal(angle);
+ angle2 = (float) __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))
{
- POINT p;
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- DWORD clr = 0 /* 0xFFFFFFFF */;
- HANDLE prevPen, hPen;
- double xB, yB, xE, yE, xR, yR;
- COLORREF fgColor;
- 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);
-
- w = __intVal(width);
- h = __intVal(height);
- __x = __intVal(x);
- __y = __intVal(y);
-
- 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;
- }
- prevPen = SelectObject(hDC, hPen);
- DPRINTF(("Arc 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));
- Arc(hDC,
- __x, __y,
- __x + w, __y + h,
- (int)xB, (int)yB,
- (int)xE, (int)yE);
-
- SelectObject(hDC, prevPen);
- DeleteObject(hPen);
-
- RETURN ( self );
+ POINT p;
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ DWORD clr = 0 /* 0xFFFFFFFF */;
+ HANDLE prevPen, hPen;
+ double xB, yB, xE, yE, xR, yR;
+ COLORREF fgColor;
+ 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);
+
+ w = __intVal(width);
+ h = __intVal(height);
+ __x = __intVal(x);
+ __y = __intVal(y);
+
+ 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;
+ }
+ prevPen = SelectObject(hDC, hPen);
+ DPRINTF(("Arc 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));
+ Arc(hDC,
+ __x, __y,
+ __x + w, __y + h,
+ (int)xB, (int)yB,
+ (int)xE, (int)yE);
+
+ SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+
+ RETURN ( self );
}
bad: ;
%}.
@@ -1760,16 +1760,16 @@
%{ /* NOCONTEXT */
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(px, py)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- POINT p;
- COLORREF fgColor;
-
- int __x = __intVal(px), __y = __intVal(py);
-
- fgColor = GetTextColor(hDC);
- SetPixelV(hDC, __x, __y, fgColor);
-
- RETURN ( self );
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ POINT p;
+ COLORREF fgColor;
+
+ int __x = __intVal(px), __y = __intVal(py);
+
+ fgColor = GetTextColor(hDC);
+ SetPixelV(hDC, __x, __y, fgColor);
+
+ RETURN ( self );
}
%}
!
@@ -1789,79 +1789,79 @@
if (__isExternalAddressLike(aDC)
/* && __isExternalAddress(aDrawableId) */
&& __isSmallInteger(numberOfPoints)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- POINT p;
- DWORD clr = 0 /* 0xFFFFFFFF */;
- HANDLE prevPen, hPen;
- int lw;
- COLORREF fgColor;
- int lStyleSymbol, lStyleInt;
-
- 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;
-
- num = __intVal(numberOfPoints);
-
- 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);
-
- hPen = CreatePen(lStyleInt, lw, fgColor);
- prevPen = SelectObject(hDC, hPen);
-
- for (i=0; i<num; i++) {
- point = __AT_(aPolygon, __MKSMALLINT(i+1));
- px = _point_X(point);
- py = _point_Y(point);
- p.x = __intVal(px);
- p.y = __intVal(py);
- if (i == 0) {
- MoveToEx(hDC, p.x, p.y, NULL);
- } else {
- if (i == (num-1)) {
- PolylineTo(hDC, &p, 1);
- } else {
- LineTo(hDC, p.x, p.y);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ POINT p;
+ DWORD clr = 0 /* 0xFFFFFFFF */;
+ HANDLE prevPen, hPen;
+ int lw;
+ COLORREF fgColor;
+ int lStyleSymbol, lStyleInt;
+
+ 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;
+
+ num = __intVal(numberOfPoints);
+
+ 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);
+
+ hPen = CreatePen(lStyleInt, lw, fgColor);
+ prevPen = SelectObject(hDC, hPen);
+
+ for (i=0; i<num; i++) {
+ point = __AT_(aPolygon, __MKSMALLINT(i+1));
+ px = _point_X(point);
+ py = _point_Y(point);
+ p.x = __intVal(px);
+ p.y = __intVal(py);
+ if (i == 0) {
+ MoveToEx(hDC, p.x, p.y, NULL);
+ } else {
+ if (i == (num-1)) {
+ PolylineTo(hDC, &p, 1);
+ } else {
+ LineTo(hDC, p.x, p.y);
#ifdef PRE_04_JUN_04
- /*
- * end-point ...
- */
- LineTo(hDC, p.x+1, p.y);
+ /*
+ * end-point ...
+ */
+ LineTo(hDC, p.x+1, p.y);
#endif
- }
- }
- }
- SelectObject(hDC, prevPen);
- DeleteObject(hPen);
-
-
- RETURN ( self );
+ }
+ }
+ }
+ SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+
+
+ RETURN ( self );
}
fail: ;
%}
@@ -1890,74 +1890,74 @@
if (__isExternalAddressLike(aDC)
&& __isSmallInteger(numberOfPoints)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- POINT p;
- HANDLE prevPen, hPen;
- COLORREF fgColor;
- int lw;
- int lStyleSymbol, lStyleInt;
-
-
- 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);
-
- num = __intVal(numberOfPoints);
-
- for (i=0; i<num; i++) {
- point = __AT_(aPolyline, __MKSMALLINT(i+1));
- if (! __isPoint(point)) goto fail;
- px = _point_X(point);
- py = _point_Y(point);
- if (! __bothSmallInteger(px, py)) {
- goto fail;
- }
- }
-
- hPen = CreatePen(lStyleInt, lw, fgColor);
- prevPen = SelectObject(hDC, hPen);
-
- for (i=0; i<num; i++) {
- point = __AT_(aPolyline, __MKSMALLINT(i+1));
- px = _point_X(point);
- py = _point_Y(point);
- p.x = __intVal(px);
- p.y = __intVal(py);
- DPRINTF(("printing point"));
- DPRINTF(("displayPolygon: no pen\n"));
-
- if ((i & 1) == 0) {
- MoveToEx(hDC, p.x, p.y, NULL);
- } else {
- LineTo(hDC, p.x, p.y);
- /*
- * end-point ...
- */
- LineTo(hDC, p.x+1, p.y);
- }
- }
- SelectObject(hDC, prevPen);
- DeleteObject(hPen);
- RETURN ( self );
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ POINT p;
+ HANDLE prevPen, hPen;
+ COLORREF fgColor;
+ int lw;
+ int lStyleSymbol, lStyleInt;
+
+
+ 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);
+
+ num = __intVal(numberOfPoints);
+
+ for (i=0; i<num; i++) {
+ point = __AT_(aPolyline, __MKSMALLINT(i+1));
+ if (! __isPoint(point)) goto fail;
+ px = _point_X(point);
+ py = _point_Y(point);
+ if (! __bothSmallInteger(px, py)) {
+ goto fail;
+ }
+ }
+
+ hPen = CreatePen(lStyleInt, lw, fgColor);
+ prevPen = SelectObject(hDC, hPen);
+
+ for (i=0; i<num; i++) {
+ point = __AT_(aPolyline, __MKSMALLINT(i+1));
+ px = _point_X(point);
+ py = _point_Y(point);
+ p.x = __intVal(px);
+ p.y = __intVal(py);
+ DPRINTF(("printing point"));
+ DPRINTF(("displayPolygon: no pen\n"));
+
+ if ((i & 1) == 0) {
+ MoveToEx(hDC, p.x, p.y, NULL);
+ } else {
+ LineTo(hDC, p.x, p.y);
+ /*
+ * end-point ...
+ */
+ LineTo(hDC, p.x+1, p.y);
+ }
+ }
+ SelectObject(hDC, prevPen);
+ DeleteObject(hPen);
+ RETURN ( self );
}
fail: ;
%}
@@ -2038,14 +2038,14 @@
If the coordinates are not integers, retry with rounded."
self
- displayString:aString
- from:index1
- to:index2
- x:x
- y:y
- in:aDrawableId
- with:aGCId
- opaque:false
+ displayString:aString
+ from:index1
+ to:index2
+ x:x
+ y:y
+ in:aDrawableId
+ with:aGCId
+ opaque:false
!
displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aDC opaque:opaque
@@ -2258,25 +2258,25 @@
If the coordinates are not integers, retry with rounded."
self
- displayString:aString
- x:x
- y:y
- in:aDrawableId
- with:aDC
- opaque:false
+ displayString:aString
+ x:x
+ y:y
+ in:aDrawableId
+ with:aDC
+ opaque:false
!
displayString:aString x:x y:y in:aDrawableId with:aDC opaque:opaque
"draw a string"
self displayString:aString
- from:1
- to:aString size
- x:x
- y:y
- in:aDrawableId
- with:aDC
- opaque:opaque
+ from:1
+ to:aString size
+ x:x
+ y:y
+ in:aDrawableId
+ with:aDC
+ opaque:opaque
!
fillArcX:x y:y width:width height:height from:startAngle angle:angle
@@ -2437,8 +2437,8 @@
numberOfPoints := aPolygon size.
self
- primFillPolygon:aPolygon n:numberOfPoints
- in:ignoredDrawableId with:aGCId
+ primFillPolygon:aPolygon n:numberOfPoints
+ in:ignoredDrawableId with:aGCId
!
fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
@@ -2931,7 +2931,7 @@
!
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId
- width:w height:h
+ width:w height:h
"do a bit-blt, but only copy the low-bit plane;
copy bits from the rectangle defined by
srcX/srcY and w/h from the sourceId drawable to the rectangle
@@ -2939,10 +2939,10 @@
argument is not integer."
^ self
- copyFromId:sourceId
- x:srcX y:srcY gc:srcDCId
- to:destId x:dstX y:dstY gc:dstDCId
- width:w height:h
+ copyFromId:sourceId
+ x:srcX y:srcY gc:srcDCId
+ to:destId x:dstX y:dstY gc:dstDCId
+ width:w height:h
!
copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
@@ -2960,7 +2960,7 @@
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
bitmapId isNil ifTrue:[
- 'WINWORKSTATION: cannot create bitmap' errorPrintCR.
+ 'WINWORKSTATION: cannot create bitmap' errorPrintCR.
].
^ bitmapId
!
@@ -2975,23 +2975,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 ( __MKOBJ(newBitmapHandle));
- }
+ newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) );
+ }
+
+ if (newBitmapHandle) {
+ RETURN ( __MKOBJ(newBitmapHandle));
+ }
/*
- DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
+ DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
*/
}
RETURN (nil);
@@ -3002,12 +3002,12 @@
%{ /* NOCONTEXT */
if (__isExternalAddress(aDrawableId) /* && ISCONNECTED */ ) {
- HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
-
- if (bitmapHandle) {
- DeleteObject(bitmapHandle);
- /* _DeleteObject(bitmapHandle, __LINE__); */
- }
+ HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
+
+ if (bitmapHandle) {
+ DeleteObject(bitmapHandle);
+ /* _DeleteObject(bitmapHandle, __LINE__); */
+ }
}
%}
!
@@ -3018,9 +3018,17 @@
sortedImage := aForm.
- aForm depth > 8 ifTrue:[
- bitsWithTransparency := sortedImage bits.
+ "Image 16 bits"
+ aForm depth = 16 ifTrue:[
+ bitsWithTransparency := aForm bits.
].
+ "Image 24 and 32 bits"
+ aForm depth >= 24 ifTrue:[
+ |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.
@@ -3149,70 +3157,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 (cls == @global(Array)) {
- 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 (cls == @global(ByteArray)) {
- 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 (cls == @global(Array)) {
+ 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 (cls == @global(ByteArray)) {
+ 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 ( __MKOBJ(newBitmapHandle));
- }
+ if (allocatedBits) {
+ free(allocatedBits);
+ }
+ RETURN ( __MKOBJ(newBitmapHandle));
+ }
}
fail: ;
/*
@@ -3220,9 +3228,9 @@
*/
if (allocatedBits) {
/*
- CPRINTF(("freeing up bitmap bits ...\n"));
+ CPRINTF(("freeing up bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
/*
CPRINTF(("returning nil ...\n"));
@@ -3993,24 +4001,24 @@
char *fn;
if (__isString(aFontName) || __isSymbol(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 ( __MKOBJ(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 ( __MKOBJ(hFont) );
+ }
}
%}.
^ nil
@@ -4023,8 +4031,8 @@
rawData := Array new:15.
(self primFontMetricsOf:fontId hdc:gcId intoArray:rawData) isNil ifTrue:[
- self primitiveFailed.
- ^ self
+ self primitiveFailed.
+ ^ self
].
rawData at:11 put:#'ms-ansi'.
@@ -4055,7 +4063,7 @@
!
getFontWithFamily:familyString face:faceString
- style:styleArgString size:sizeArg encoding:encodingSym
+ style:styleArgString size:sizeArg encoding:encodingSym
"try to get the specified font, if not available, try the next smaller
font."
@@ -4066,94 +4074,94 @@
"special: if face is nil, allow access to X-fonts"
faceString isNil ifTrue:[
- sizeArg notNil ifTrue:[
- theName := familyString , '-' , sizeArg printString
- ] ifFalse:[
- theName := familyString
- ].
- theName isNil ifTrue:[
- "
- mhmh - fall back to the default font
- "
- theName := 'fixed'
- ].
- theId := self createFontFor:theName.
- theId isNil ifTrue:[
- theId := self getDefaultFont
- ].
- ^ theId
+ sizeArg notNil ifTrue:[
+ theName := familyString , '-' , sizeArg printString
+ ] ifFalse:[
+ theName := familyString
+ ].
+ theName isNil ifTrue:[
+ "
+ mhmh - fall back to the default font
+ "
+ theName := 'fixed'
+ ].
+ theId := self createFontFor:theName.
+ theId isNil ifTrue:[
+ theId := self getDefaultFont
+ ].
+ ^ 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:sizeArg
- registry:'*'
- encoding:encodingSym.
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString
+ slant:styleString "/ xlatedStyle
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArg
+ 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:sizeArg
- registry:'*'
- encoding:encodingSym asUppercase.
- id isNil ifTrue:[
- id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString
- slant:styleString "/ xlatedStyle
- spacing:spacing
- pixelSize:nil
- size:sizeArg
- registry:'*'
- encoding:encodingSym asLowercase.
-
- id isNil ifTrue:[
- id := self
- getFontWithFoundry:'*'
- family:familyString asLowercase
- weight:faceString asLowercase
- slant:styleString asLowercase
- spacing:spacing
- pixelSize:nil
- size:sizeArg
- 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:sizeArg
+ registry:'*'
+ encoding:encodingSym asUppercase.
+ id isNil ifTrue:[
+ id := self
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString
+ slant:styleString "/ xlatedStyle
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArg
+ registry:'*'
+ encoding:encodingSym asLowercase.
+
+ id isNil ifTrue:[
+ id := self
+ getFontWithFoundry:'*'
+ family:familyString asLowercase
+ weight:faceString asLowercase
+ slant:styleString asLowercase
+ spacing:spacing
+ pixelSize:nil
+ size:sizeArg
+ registry:'*'
+ encoding:encodingSym asLowercase.
+ ]
+ ]
+ ]
].
^ id
@@ -4162,8 +4170,8 @@
!
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
"get the specified font, if not available, return nil.
For now, this is a poor (incomplete) emulation of the X code ...
@@ -4183,43 +4191,43 @@
"
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|
pixelSize notNil ifTrue:[
- logSize := pixelSize
+ logSize := pixelSize
] ifFalse:[
- logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
+ logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
].
%{
HGDIOBJ hFont;
@@ -4254,152 +4262,152 @@
fdwCharSet = ANSI_CHARSET;
if ((encoding == @symbol('ms-ansi'))) {
- fdwCharSet = ANSI_CHARSET;
+ fdwCharSet = ANSI_CHARSET;
} else if (encoding == @symbol('ms-default')) {
- fdwCharSet = DEFAULT_CHARSET;
+ 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 ( __MKOBJ(hFont) );
+ RETURN ( __MKOBJ(hFont) );
}
DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
@@ -4408,14 +4416,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"
@@ -4443,57 +4451,57 @@
&& __isExternalAddressLike(aDC)
&& __isArray(rawData)
&& (__arraySize(rawData) >= 11)) {
- SIZE size;
- int avgWidth;
- HGDIOBJ hFont;
- HGDIOBJ prevFont;
- TEXTMETRIC tmet;
- static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- static int len;
- OBJ t;
- HANDLE hDC;
-
- hFont = _HGDIOBJVal(fontId);
- hDC = (HANDLE)(__externalAddressVal(aDC));
-
- /*
- * temporarily set this font in the tmpDC (root-) context
- */
-
- prevFont = SelectObject(hDC, hFont);
-
- GetTextMetricsW(hDC, &tmet);
- if (len == 0) {
- len = strlen(s);
- }
+ SIZE size;
+ int avgWidth;
+ HGDIOBJ hFont;
+ HGDIOBJ prevFont;
+ TEXTMETRIC tmet;
+ static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ static int len;
+ OBJ t;
+ HANDLE hDC;
+
+ hFont = _HGDIOBJVal(fontId);
+ hDC = (HANDLE)(__externalAddressVal(aDC));
+
+ /*
+ * temporarily set this font in the tmpDC (root-) context
+ */
+
+ prevFont = SelectObject(hDC, hFont);
+
+ GetTextMetricsW(hDC, &tmet);
+ if (len == 0) {
+ len = strlen(s);
+ }
#if 0
- GetTextExtentPoint32(hDC, s, len, &size);
- avgWidth = (size.cx / (len / 2) + 1) / 2;
+ GetTextExtentPoint32(hDC, s, len, &size);
+ avgWidth = (size.cx / (len / 2) + 1) / 2;
#else
- avgWidth = tmet.tmAveCharWidth;
+ avgWidth = tmet.tmAveCharWidth;
#endif
- __ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent); /* ascent -> (data at:1) */
- __ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent); /* descent -> (data at:2) */
- __ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent); /* maxAscent -> (data at:3) */
- __ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent); /* maxDescent -> (data at:4) */
- __ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth); /* minWidth -> (data at:5) */
- __ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth); /* maxWidth -> (data at:6) */
- __ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth); /* avgWidth -> (data at:7) */
- __ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar); /* min -> (data at:8) */
- __ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar); /* max -> (data at:9) */
- __ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar); /* default -> (data at:10) */
+ __ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent); /* ascent -> (data at:1) */
+ __ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent); /* descent -> (data at:2) */
+ __ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent); /* maxAscent -> (data at:3) */
+ __ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent); /* maxDescent -> (data at:4) */
+ __ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth); /* minWidth -> (data at:5) */
+ __ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth); /* maxWidth -> (data at:6) */
+ __ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth); /* avgWidth -> (data at:7) */
+ __ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar); /* min -> (data at:8) */
+ __ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar); /* max -> (data at:9) */
+ __ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar); /* default -> (data at:10) */
#if 0
- t = __charSetSymbolFor(tmet.tmCharSet);
- __ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t); /* charSet -> (data at:11) */
+ t = __charSetSymbolFor(tmet.tmCharSet);
+ __ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t); /* charSet -> (data at:11) */
#endif
- DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
- hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
- tmet.tmAveCharWidth));
-
- SelectObject(hDC, prevFont);
- RETURN (self);
+ DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
+ hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
+ tmet.tmAveCharWidth));
+
+ SelectObject(hDC, prevFont);
+ RETURN (self);
}
RETURN (nil);
%}
@@ -4503,12 +4511,12 @@
%{ /* NOCONTEXT */
if (__isExternalAddress(aFontId)) {
- HGDIOBJ hFont = _HGDIOBJVal(aFontId);
-
- if (hFont) {
- DPRINTF(("ReleaseFont: %x\n", hFont));
- DeleteObject(hFont);
- }
+ HGDIOBJ hFont = _HGDIOBJVal(aFontId);
+
+ if (hFont) {
+ DPRINTF(("ReleaseFont: %x\n", hFont));
+ DeleteObject(hFont);
+ }
}
%}
!
@@ -4521,13 +4529,13 @@
if (__isExternalAddressLike(aDC)
&& __isExternalAddress(aFontId))
{
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- HGDIOBJ prevFont, hFont;
-
- hFont = _HGDIOBJVal(aFontId);
- prevFont = SelectObject(hDC, hFont);
-
- RETURN ( self );
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ HGDIOBJ prevFont, hFont;
+
+ hFont = _HGDIOBJVal(aFontId);
+ prevFont = SelectObject(hDC, hFont);
+
+ RETURN ( self );
}
%}.
self primitiveFailed
@@ -4547,94 +4555,94 @@
&& __isExternalAddress(aFontId)
&& __isExternalAddressLike(__INST(gcId))
&& __isNonNilObject(aString)) {
- HGDIOBJ hFont,prevFont;
- HANDLE hDC;
- SIZE tsize;
+ HGDIOBJ hFont,prevFont;
+ HANDLE hDC;
+ SIZE tsize;
#ifndef PRE_22_FEP_2007
# define N_QUICK_CHARS 1024
- unsigned short quickWchars[N_QUICK_CHARS];
- unsigned short *wcharPtr;
- int mustFree = 0;
- int i;
+ unsigned short quickWchars[N_QUICK_CHARS];
+ unsigned short *wcharPtr;
+ int mustFree = 0;
+ int i;
#endif
- hFont = _HGDIOBJVal(aFontId);
- hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
-
- prevFont = SelectObject(hDC, hFont);
-
- i1 = __intVal(index1) - 1;
- cls = __qClass(aString);
-
- if (i1 >= 0) {
- i2 = __intVal(index2) - 1;
- if (i2 < i1) {
- RETURN ( __MKSMALLINT( 0 ) );
- }
-
- cp = (char *) _stringVal(aString);
- l = i2 - i1 + 1;
-
- if ((cls == @global(String)) || (cls == @global(Symbol))) {
- n = _stringSize(aString);
+ hFont = _HGDIOBJVal(aFontId);
+ hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
+
+ prevFont = SelectObject(hDC, hFont);
+
+ i1 = __intVal(index1) - 1;
+ cls = __qClass(aString);
+
+ if (i1 >= 0) {
+ i2 = __intVal(index2) - 1;
+ if (i2 < i1) {
+ RETURN ( __MKSMALLINT( 0 ) );
+ }
+
+ cp = (char *) _stringVal(aString);
+ l = i2 - i1 + 1;
+
+ if ((cls == @global(String)) || (cls == @global(Symbol))) {
+ n = _stringSize(aString);
commonWidthChars:
- if (i2 < n) {
- cp += i1;
+ if (i2 < n) {
+ cp += i1;
#ifdef PRE_22_FEP_2007
- GetTextExtentPoint32(hDC, cp, l, &tsize);
+ GetTextExtentPoint32(hDC, cp, l, &tsize);
#else
- if (l <= N_QUICK_CHARS) {
- wcharPtr = quickWchars;
- mustFree = 0;
- } else {
- wcharPtr = malloc(sizeof(short)*l);
- if (! wcharPtr) RETURN (__MKSMALLINT(0));
- mustFree = 1;
- }
- for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
- GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
- if (mustFree) free(wcharPtr);
+ if (l <= N_QUICK_CHARS) {
+ wcharPtr = quickWchars;
+ mustFree = 0;
+ } else {
+ wcharPtr = malloc(sizeof(short)*l);
+ if (! wcharPtr) RETURN (__MKSMALLINT(0));
+ mustFree = 1;
+ }
+ for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
+ GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
+ if (mustFree) free(wcharPtr);
#endif
#ifdef SUPERDEBUG
- if (__debug__) {
- char buf[80];
-
- GetTextFace(hDC,80,buf);
- console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
- }
+ if (__debug__) {
+ char buf[80];
+
+ GetTextFace(hDC,80,buf);
+ console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
+ }
#endif
- SelectObject(hDC, prevFont);
- RETURN ( __MKSMALLINT(tsize.cx) );
- }
- RETURN (__MKSMALLINT(0));
- }
-
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- cp += nInstBytes;
- n = __byteArraySize(aString) - nInstBytes;
-
- if (__isBytes(aString)) {
- goto commonWidthChars;
- }
-
- /* Unicode */
- if (__isWords(aString)) {
- n = n / 2;
- if (i2 < n) {
- WIDECHAR *w_cp = (WIDECHAR *)cp;
-
- w_cp += i1;
-
- GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
- SelectObject(hDC, prevFont);
- RETURN ( __MKSMALLINT(tsize.cx) );
- }
- RETURN (__MKSMALLINT(0));
- }
- }
+ SelectObject(hDC, prevFont);
+ RETURN ( __MKSMALLINT(tsize.cx) );
+ }
+ RETURN (__MKSMALLINT(0));
+ }
+
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ cp += nInstBytes;
+ n = __byteArraySize(aString) - nInstBytes;
+
+ if (__isBytes(aString)) {
+ goto commonWidthChars;
+ }
+
+ /* Unicode */
+ if (__isWords(aString)) {
+ n = n / 2;
+ if (i2 < n) {
+ WIDECHAR *w_cp = (WIDECHAR *)cp;
+
+ w_cp += i1;
+
+ GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
+ SelectObject(hDC, prevFont);
+ RETURN ( __MKSMALLINT(tsize.cx) );
+ }
+ RETURN (__MKSMALLINT(0));
+ }
+ }
}
%}.
self primitiveFailed.
@@ -4672,8 +4680,8 @@
id := gcId.
id notNil ifTrue:[
- gcId := nil.
- self deleteDC.
+ gcId := nil.
+ self deleteDC.
].
"/ Lobby unregister:self.
!
@@ -4681,15 +4689,15 @@
destroyGC:aDC
%{
if (__isExternalAddressLike(aDC)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
-
- DeleteDC(hDC);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+
+ DeleteDC(hDC);
/*
#ifdef CACHE_LAST_DC
- if (lastGcData == gcData) {
- _releaseDC(gcData);
- }
+ if (lastGcData == gcData) {
+ _releaseDC(gcData);
+ }
#endif
*/
@@ -4725,9 +4733,9 @@
releaseDeviceFonts
deviceFonts isEmptyOrNil ifFalse:[
- deviceFonts do:[:afont |
- afont releaseFromDevice.
- ].
+ deviceFonts do:[:afont |
+ afont releaseFromDevice.
+ ].
].
deviceFonts := CachingRegistry new cacheSize:10.
! !
@@ -4744,23 +4752,23 @@
index <= 0 ifTrue:[ ^ 0 ].
str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ].
true "self font isNil" ifTrue:[
- "if font not set yet, calculate based on default font"
- "/ extString := str asExternalString.
- size := Win32OperatingSystem::WinPointStructure new.
- (OperatingSystem
- getTextExtentPoint:gcId
- string:str
- size:size) ifFalse:[ ^ self error ].
- answer := size x.
+ "if font not set yet, calculate based on default font"
+ "/ extString := str asExternalString.
+ size := Win32OperatingSystem::WinPointStructure new.
+ (OperatingSystem
+ getTextExtentPoint:gcId
+ string:str
+ size:size) ifFalse:[ ^ self error ].
+ answer := size x.
"/ Transcript showCR: 'FROM PRIM ******* ', str, ' ', answer printString.
"/ Transcript showCR: 'FROM DEVICE ***** ', str, ' ',(self font widthOf:str on:self device) printString.
- #TODO.
+ #TODO.
] ifFalse:[
- answer := self font widthOf:str on:self device
+ answer := self font widthOf:str on:self device
].
index > aString size ifTrue:[
- spaceWidth := self font widthOf:Character space on:self device.
- answer := answer + ((index - aString size) * spaceWidth)
+ spaceWidth := self font widthOf:Character space on:self device.
+ answer := answer + ((index - aString size) * spaceWidth)
].
^ answer.
@@ -4775,7 +4783,7 @@
"draw a line"
self displayAdvanceLineFromX:(point1 x) y:(point1 y)
- toX:(point2 x) y:(point2 y)
+ toX:(point2 x) y:(point2 y)
!
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1
@@ -4784,52 +4792,52 @@
|pX0 pY0 pX1 pY1 easy fgId bgId|
gcId isNil ifTrue:[
- self initGC
+ self initGC
].
lineStyle == #doubleDashed ifTrue:[
- "
- if bgPaint or paint is not a real color, we have to do it the hard way ...
- "
- easy := true.
- paint isColor ifFalse:[
- easy := false
- ] ifTrue:[
- fgId := paint colorId.
- fgId isNil ifTrue:[
- easy := false
- ]
- ].
- bgPaint isColor ifFalse:[
- easy := false
- ] ifTrue:[
- bgId := bgPaint colorId.
- bgId isNil ifTrue:[
- easy := false
- ]
- ].
-
- easy ifTrue:[
- ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
- device setForeground:fgId background:bgId in:gcId.
- foreground := paint.
- background := bgPaint.
- ].
- ] ifFalse:[
- 'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
- ].
+ "
+ if bgPaint or paint is not a real color, we have to do it the hard way ...
+ "
+ easy := true.
+ paint isColor ifFalse:[
+ easy := false
+ ] ifTrue:[
+ fgId := paint colorId.
+ fgId isNil ifTrue:[
+ easy := false
+ ]
+ ].
+ bgPaint isColor ifFalse:[
+ easy := false
+ ] ifTrue:[
+ bgId := bgPaint colorId.
+ bgId isNil ifTrue:[
+ easy := false
+ ]
+ ].
+
+ easy ifTrue:[
+ ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
+ device setForeground:fgId background:bgId in:gcId.
+ foreground := paint.
+ background := bgPaint.
+ ].
+ ] ifFalse:[
+ 'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
+ ].
].
transformation notNil ifTrue:[
- pX0 := transformation applyToX:x0.
- pY0 := transformation applyToY:y0.
- pX1 := transformation applyToX:x1.
- pY1 := transformation applyToY:y1.
+ pX0 := transformation applyToX:x0.
+ pY0 := transformation applyToY:y0.
+ pX1 := transformation applyToX:x1.
+ pY1 := transformation applyToY:y1.
] ifFalse:[
- pX0 := x0.
- pY0 := y0.
- pX1 := x1.
- pY1 := y1
+ pX0 := x0.
+ pY0 := y0.
+ pX1 := x1.
+ pY1 := y1
].
pX0 := pX0 rounded.
@@ -4851,32 +4859,32 @@
if (__isExternalAddressLike(aDC)
&& __bothSmallInteger(x0, y0)
&& __bothSmallInteger(x1, y1)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- COLORREF fgColor;
- int __x1 = __intVal(x1), __y1 = __intVal(y1);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ COLORREF fgColor;
+ int __x1 = __intVal(x1), __y1 = __intVal(y1);
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n",
- __intVal(x0), __intVal(y0),
- __x1, __y1));
+ __intVal(x0), __intVal(y0),
+ __x1, __y1));
*/
/* fgColor = GetTextColor(hDC);
* hPen = CreatePen(PS_SOLID, 1, fgColor);
*/
- MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
-
- LineTo(hDC, __x1, __y1);
-
- /*
- * end-point ...
- */
- LineTo(hDC, __x1+1, __y1);
-
-
-
- RETURN ( self );
+ MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
+
+ LineTo(hDC, __x1, __y1);
+
+ /*
+ * end-point ...
+ */
+ LineTo(hDC, __x1+1, __y1);
+
+
+
+ RETURN ( self );
}
%}
!
@@ -4940,8 +4948,8 @@
|maskOriginX maskOriginY|
self maskOrigin isNil ifFalse:[
- maskOriginX := self maskOrigin x.
- maskOriginY := self maskOrigin y.
+ maskOriginX := self maskOrigin x.
+ maskOriginY := self maskOrigin y.
].
%{
@@ -4969,40 +4977,40 @@
maskOrgY=__intVal(maskOriginY);
if (lineStyle == @symbol(solid)) {
- style = PS_SOLID;
+ style = PS_SOLID;
} else if (lineStyle == @symbol(dashed)) {
- style= PS_DASH;
+ style= PS_DASH;
} else if (lineStyle == @symbol(dotted)) {
- style= PS_DOT;
+ style= PS_DOT;
} else if (lineStyle == @symbol(dashDot)) {
- style= PS_DASHDOT;
+ style= PS_DASHDOT;
} else if (lineStyle == @symbol(dashDotDot)) {
- style= PS_DASHDOTDOT;
+ style= PS_DASHDOTDOT;
} else
- style= PS_SOLID;
+ style= PS_SOLID;
lStyle &= ~PS_STYLE_MASK;
lStyle |= style;
if (capStyle == @symbol(round)) {
- style = PS_ENDCAP_ROUND;
+ style = PS_ENDCAP_ROUND;
} else if (capStyle == @symbol(square)) {
- style = PS_ENDCAP_SQUARE;
+ style = PS_ENDCAP_SQUARE;
} else if (capStyle == @symbol(flat)) {
- style = PS_ENDCAP_FLAT;
+ style = PS_ENDCAP_FLAT;
} else
- style = PS_ENDCAP_FLAT;
+ style = PS_ENDCAP_FLAT;
lStyle &= ~PS_ENDCAP_MASK;
lStyle |= style;
if (joinStyle == @symbol(bevel)) {
- style = PS_JOIN_BEVEL;
+ style = PS_JOIN_BEVEL;
} else if (joinStyle == @symbol(miter)) {
- style = PS_JOIN_MITER;
+ style = PS_JOIN_MITER;
} else if (joinStyle == @symbol(round)) {
- style = PS_JOIN_ROUND;
+ style = PS_JOIN_ROUND;
} else
- style = PS_JOIN_MITER;
+ style = PS_JOIN_MITER;
lStyle &= ~PS_JOIN_MASK;
lStyle |= style;
@@ -5010,38 +5018,38 @@
if (((lStyle & PS_STYLE_MASK) == PS_SOLID)
&& (hMask == 0)
&& (lw /* lineWidth */ <= 1)) {
- if (fgColor == 0 /* BlackPixel */ ) {
- hPen = GetStockObject(BLACK_PEN);
- prevPen = SelectObject(hDC, hPen);
- RETURN( hPen );
- }
- if (fgColor == 1 /* WhitePixel */) {
- hPen = GetStockObject(WHITE_PEN);
- prevPen = SelectObject(hDC, hPen);
- RETURN( hPen );
- }
+ if (fgColor == 0 /* BlackPixel */ ) {
+ hPen = GetStockObject(BLACK_PEN);
+ prevPen = SelectObject(hDC, hPen);
+ RETURN( hPen );
+ }
+ if (fgColor == 1 /* WhitePixel */) {
+ hPen = GetStockObject(WHITE_PEN);
+ prevPen = SelectObject(hDC, hPen);
+ RETURN( hPen );
+ }
}
hPen = (HPEN) 0;
if (0 /* __isWinNT */) {
- if (lw == 0) {
- lw = 1;
- }
- /*
- * NT supports masked drawing with any lineStyle,
- * and also non-solid lines with any lineWidth.
- */
- if (hMask) {
- Brush.lbStyle = BS_PATTERN;
- Brush.lbHatch = (DWORD)hMask;
- Brush.lbColor = fgColor;
- } else {
+ if (lw == 0) {
+ lw = 1;
+ }
+ /*
+ * NT supports masked drawing with any lineStyle,
+ * and also non-solid lines with any lineWidth.
+ */
+ if (hMask) {
+ Brush.lbStyle = BS_PATTERN;
+ Brush.lbHatch = (DWORD)hMask;
+ Brush.lbColor = fgColor;
+ } else {
#ifndef PRE_07_APR_04
- hPen = CreatePen((lStyle & PS_STYLE_MASK), lw, fgColor);
+ hPen = CreatePen((lStyle & PS_STYLE_MASK), lw, fgColor);
/* RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
* lStyle,
@@ -5049,92 +5057,92 @@
* fgColor, hMask));
*/
- SetBkMode(hDC, TRANSPARENT);
- bkMode = BK_TRANSPARENT;
+ SetBkMode(hDC, TRANSPARENT);
+ bkMode = BK_TRANSPARENT;
#else
- Brush.lbStyle = BS_SOLID;
- Brush.lbHatch = 0;
- Brush.lbColor = fgColor;
+ Brush.lbStyle = BS_SOLID;
+ Brush.lbHatch = 0;
+ Brush.lbColor = fgColor;
#endif
- }
-
- if (! hPen)
- {
- hPen = ExtCreatePen(PS_GEOMETRIC | lStyle,
- lw, /* lineWidth, */
- &Brush,
- 0, 0);
+ }
+
+ if (! hPen)
+ {
+ hPen = ExtCreatePen(PS_GEOMETRIC | lStyle,
+ lw, /* lineWidth, */
+ &Brush,
+ 0, 0);
/* RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
* lStyle,
* lw, __INST(lineWidth),
* fgColor, hMask));
*/
- if (hMask) {
- SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
- }
- }
+ if (hMask) {
+ SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
+ }
+ }
} else {
- /*
- * W95 only supports masked drawing with SOLID lines
- * also, we should use COSMETIC pens if possible
- * with non-solid lineStyles.
- */
- if ((lStyle & PS_STYLE_MASK) == PS_SOLID) {
- int ps = PS_GEOMETRIC;
-
- if (hMask) {
- Brush.lbStyle = BS_PATTERN;
- Brush.lbHatch = (DWORD)hMask;
- Brush.lbColor = fgColor;
- } else {
- Brush.lbStyle = BS_SOLID;
- Brush.lbHatch = 0;
- Brush.lbColor = fgColor;
- if (lw /* lineWidth */ <= 1) {
- ps = PS_COSMETIC;
- }
- }
-
- hPen = ExtCreatePen(ps | lStyle,
- lw, /* lineWidth */
- &Brush,
- 0, 0);
+ /*
+ * W95 only supports masked drawing with SOLID lines
+ * also, we should use COSMETIC pens if possible
+ * with non-solid lineStyles.
+ */
+ if ((lStyle & PS_STYLE_MASK) == PS_SOLID) {
+ int ps = PS_GEOMETRIC;
+
+ if (hMask) {
+ Brush.lbStyle = BS_PATTERN;
+ Brush.lbHatch = (DWORD)hMask;
+ Brush.lbColor = fgColor;
+ } else {
+ Brush.lbStyle = BS_SOLID;
+ Brush.lbHatch = 0;
+ Brush.lbColor = fgColor;
+ if (lw /* lineWidth */ <= 1) {
+ ps = PS_COSMETIC;
+ }
+ }
+
+ hPen = ExtCreatePen(ps | lStyle,
+ lw, /* lineWidth */
+ &Brush,
+ 0, 0);
/* RESPRINTF(("ExtCreatePen1 %x %d %x %x\n",
* lStyle,
* lw,
* fgColor, hMask));
*/
- if (hMask) {
- SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
- }
- } else {
-
- if (lw == 1) {
- lw = 0;
- }
-
- /*
- * dashes only supported with lineWidth 0
- */
-
- hPen = CreatePen((lStyle & PS_STYLE_MASK),
- lw,
- fgColor);
+ if (hMask) {
+ SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
+ }
+ } else {
+
+ if (lw == 1) {
+ lw = 0;
+ }
+
+ /*
+ * dashes only supported with lineWidth 0
+ */
+
+ hPen = CreatePen((lStyle & PS_STYLE_MASK),
+ lw,
+ fgColor);
/* RESPRINTF(("CreatePen %x %d %x\n",
* (lStyle & PS_STYLE_MASK),
* lw,
* fgColor));
*/
- //
- // CG: wrong; must set to opaque, if doubleDashed
- //
- SetBkMode(hDC, TRANSPARENT);
- bkMode = BK_TRANSPARENT;
- }
+ //
+ // CG: wrong; must set to opaque, if doubleDashed
+ //
+ SetBkMode(hDC, TRANSPARENT);
+ bkMode = BK_TRANSPARENT;
+ }
}
prevPen = SelectObject(hDC, hPen);
@@ -5145,11 +5153,11 @@
!
xprimDrawBits: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:aDC
+ x:srcx y:srcy
+ into:ignoredDrawableId
+ x:dstx y:dsty
+ width:w height:h
+ with:aDC
"since XPutImage may allocate huge amount of stack space
(some implementations use alloca), this must run with unlimited stack."
@@ -5161,9 +5169,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
@@ -5176,90 +5184,90 @@
&& __isSmallInteger(padd)
&& __imageBits)
{
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- struct
- {
- BITMAPINFOHEADER bmiHeader;
- DWORD r;
- DWORD g;
- DWORD b;
- } bitmap;
-
- 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 (allocatedBits) {
- free(allocatedBits);
- }
- RETURN ( true );
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ struct
+ {
+ BITMAPINFOHEADER bmiHeader;
+ DWORD r;
+ DWORD g;
+ DWORD b;
+ } bitmap;
+
+ 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 (allocatedBits) {
+ free(allocatedBits);
+ }
+ RETURN ( true );
}
fail: ;
@@ -5268,9 +5276,9 @@
*/
if (allocatedBits) {
/*
- PRINTF(("freeing up temp bitmap bits ...\n"));
+ PRINTF(("freeing up temp bitmap bits ...\n"));
*/
- free(allocatedBits);
+ free(allocatedBits);
}
%}
.
@@ -5289,37 +5297,37 @@
&& __isExternalAddressLike(penHandle)
&& __bothSmallInteger(x0, y0)
&& __bothSmallInteger(x1, y1)) {
- HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
- HANDLE hPen = (HANDLE)(__externalAddressVal(penHandle));
- COLORREF fgColor;
- HANDLE prevPen;
- int __x1 = __intVal(x1), __y1 = __intVal(y1);
+ HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
+ HANDLE hPen = (HANDLE)(__externalAddressVal(penHandle));
+ COLORREF fgColor;
+ HANDLE prevPen;
+ int __x1 = __intVal(x1), __y1 = __intVal(y1);
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n",
- __intVal(x0), __intVal(y0),
- __x1, __y1));
+ __intVal(x0), __intVal(y0),
+ __x1, __y1));
*/
/* fgColor = GetTextColor(hDC);
* hPen = CreatePen(PS_SOLID, 1, 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);
-
-
- RETURN ( self );
+ 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);
+
+
+ RETURN ( self );
}
%}
! !
@@ -5330,7 +5338,7 @@
"Informs device that we are finished writing to a page."
(OperatingSystem endPage:gcId) > 0 ifFalse:[
- self error
+ self error
]
"Created: / 27-07-2006 / 18:20:48 / fm"
@@ -5376,7 +5384,7 @@
"Starts a page."
(OperatingSystem startPage:gcId) > 0 ifFalse:[
- ^ self error
+ ^ self error
].
"Created: / 27-07-2006 / 18:25:55 / fm"
@@ -5392,28 +5400,28 @@
|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
- ].
- ^ self error
+ jobid = -1 ifTrue:[
+ abort := true.
+ ^ nil
+ ].
+ ^ self error
].
self startPage
@@ -5469,5 +5477,5 @@
!WinPrinterContext class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.21 2007-10-23 08:56:21 fm Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.22 2007-10-29 15:29:49 fm Exp $'
! !