DeviceWorkstation.st
changeset 38 2652fc96e660
parent 26 ac9f66dc8f53
child 39 1eb8d508411c
--- a/DeviceWorkstation.st	Wed Mar 30 03:25:26 1994 +0200
+++ b/DeviceWorkstation.st	Wed Mar 30 12:13:08 1994 +0200
@@ -34,7 +34,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.10 1994-01-09 21:53:00 claus Exp $
+$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.11 1994-03-30 10:13:08 claus Exp $
 written jan 93 by claus
 '!
 
@@ -42,47 +42,47 @@
 
 documentation
 "
-this abstract class defines common protocol to all Display types.
+    this abstract class defines common protocol to all Display types.
 
-instance variables:
+    instance variables:
 
-displayId       <Number>        the device id of the display
-visualType      <Symbol>        one of #StaticGray, #PseudoColor, ... #TrueColor
-monitorType     <Symbol>        one of #monochrome, #color, #unknown
+    displayId       <Number>        the device id of the display
+    visualType      <Symbol>        one of #StaticGray, #PseudoColor, ... #TrueColor
+    monitorType     <Symbol>        one of #monochrome, #color, #unknown
 
-depth           <Integer>       bits per color
-ncells          <Integer>       number of colors (i.e. colormap size; not always == 2^depth)
-bitsPerRGB      <Integer>       number of valid bits per rgb component
-                                (actual number taken in A/D converter; not all devices report the true value)
-hasColors       <Boolean>       true, if display supports colors
-hasGreyscales   <Boolean>       true, if display supports grey-scales (i.e is not b/w display)
-width           <Integer>       number of horizontal pixels
-height          <Integer>       number of vertical pixels 
-heightMM        <Number>        screen height in millimeter
-widthMM         <Number>        screen width in millimeter
-resolutionHor   <Number>        pixels per horizontal millimeter
-resolutionVer   <Number>        pixels per vertical millimeter
+    depth           <Integer>       bits per color
+    ncells          <Integer>       number of colors (i.e. colormap size; not always == 2^depth)
+    bitsPerRGB      <Integer>       number of valid bits per rgb component
+                                    (actual number taken in A/D converter; not all devices report the true value)
+    hasColors       <Boolean>       true, if display supports colors
+    hasGreyscales   <Boolean>       true, if display supports grey-scales (i.e is not b/w display)
+    width           <Integer>       number of horizontal pixels
+    height          <Integer>       number of vertical pixels 
+    heightMM        <Number>        screen height in millimeter
+    widthMM         <Number>        screen width in millimeter
+    resolutionHor   <Number>        pixels per horizontal millimeter
+    resolutionVer   <Number>        pixels per vertical millimeter
 
-knownViews      <Collection>    all views known
-knownIds        <Collection>    corresponding device-view ids
-knownBitmaps    <Collection>    all known device bitmaps
-knownBitmapIds  <Collection>    corresponding device-bitmap ids
+    knownViews      <Collection>    all views known
+    knownIds        <Collection>    corresponding device-view ids
+    knownBitmaps    <Collection>    all known device bitmaps
+    knownBitmapIds  <Collection>    corresponding device-bitmap ids
 
-dispatching     <Boolean>       true, if currently in dispatch loop
+    dispatching     <Boolean>       true, if currently in dispatch loop
 
-controlDown     <Boolean>       true, if control key currently pressed
-shiftDown       <Boolean>       true, if shift key currently pressed
-metaDown        <Boolean>       true, if meta key (cmd-key) is currently pressed
-altDown         <Boolean>       true, if alt key is currently pressed
+    controlDown     <Boolean>       true, if control key currently pressed
+    shiftDown       <Boolean>       true, if shift key currently pressed
+    metaDown        <Boolean>       true, if meta key (cmd-key) is currently pressed
+    altDown         <Boolean>       true, if alt key is currently pressed
 
-motionEventCompression
+    motionEventCompression
 
-lastId          <Number>
-lastView        <View>
+    lastId          <Number>
+    lastView        <View>
 
-keyboardMap     <KeyBdMap>      mapping for keys
-isSlow          <Boolean>       set/cleared from startup - used to turn off
-                                things like popup-shadows etc.
+    keyboardMap     <KeyBdMap>      mapping for keys
+    isSlow          <Boolean>       set/cleared from startup - used to turn off
+                                    things like popup-shadows etc.
 "
 ! !
 
@@ -844,8 +844,8 @@
     "add the View aView with Id:aNumber to the list of known views/id's"
 
     knownViews isNil ifTrue:[
-        knownViews := (VariableArray new:100) grow:0.
-        knownIds := (VariableArray new:100) grow:0
+        knownViews := OrderedCollection new "(VariableArray new:100) grow:0".
+        knownIds := OrderedCollection new "(VariableArray new:100) grow:0"
     ].
     knownViews add:aView.
     knownIds add:aNumber.
@@ -994,8 +994,10 @@
 !
 
 dispatchPendingEvents
-    [self eventPending] whileTrue:[
-        self dispatchEventFor:nil withMask:nil
+    Object abortSignal catch:[
+        [self eventPending] whileTrue:[
+            self dispatchEventFor:nil withMask:nil
+        ]
     ]
 !
 
@@ -1664,30 +1666,79 @@
 
 !DeviceWorkstation methodsFor:'drawing'!
 
-displayString:aString x:x y:y in:aDrawableId with:aGCId
-    "draw a string - draw foreground only"
+displayString:aString x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
+    "draw a string"
 
     ^ self subclassResponsibility
 !
 
-displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
-    "draw part of a string - draw foreground only"
+displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
+    "draw part of a string"
+
+    "should be redefined to avoid creation of throw-away string" 
+    self displayString:(aString copyFrom:i1 to:i2)
+                     x:x 
+                     y:y 
+                     in:aDrawableId 
+                     with:aGCId
+                     round:round
+                     opaque:opaque
+!
+
+displayString:aString x:x y:y in:aDrawableId with:aGCId
+    "draw a string - draw foreground only.
+     If the coordinates are not integers, retry with rounded." 
 
-    self displayString:(aString copyFrom:index1 to:index2)
-                     x:x y:y in:aDrawableId with:aGCId
+    self displayString:aString 
+         x:x 
+         y:y 
+         in:aDrawableId 
+         with:aGCId 
+         round:true
+         opaque:false
+!
+
+displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
+    "draw a sub-string - draw foreground only.
+     If the coordinates are not integers, retry with rounded." 
+
+    self displayString:aString 
+         from:index1
+         to:index2
+         x:x 
+         y:y 
+         in:aDrawableId 
+         with:aGCId 
+         round:true
+         opaque:false
 !
 
 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
-    "draw a string - draw both foreground and background"
+    "draw a string - draw foreground on background.
+     If the coordinates are not integers, retry with rounded." 
 
-    ^ self subclassResponsibility
+    self displayString:aString 
+         x:x 
+         y:y 
+         in:aDrawableId 
+         with:aGCId 
+         round:true
+         opaque:true
 !
 
 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
-    "draw part of a string - draw both foreground and background"
+    "draw a sub-string - draw foreground on background.
+     If the coordinates are not integers, retry with rounded." 
 
-    self displayOpaqueString:(aString copyFrom:index1 to:index2)
-                           x:x y:y in:aDrawableId with:aGCId
+    self displayString:aString 
+         from:index1
+         to:index2
+         x:x 
+         y:y 
+         in:aDrawableId 
+         with:aGCId 
+         round:true
+         opaque:true
 !
 
 displayPointX:x y:y in:aDrawableId with:aGCId
@@ -1699,18 +1750,21 @@
 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
     "draw a line"
 
+    "could add a bresenham line drawer here ..."
     ^ self subclassResponsibility
 !
 
 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
     "draw a rectangle"
 
+    "should draw four lines here"
     ^ self subclassResponsibility
 !
 
 displayPolygon:aPolygon in:aDrawableId with:aGCId
     "draw a polygon"
 
+    "should draw the lines here"
     ^ self subclassResponsibility
 !