DeviceWorkstation.st
changeset 38 2652fc96e660
parent 26 ac9f66dc8f53
child 39 1eb8d508411c
equal deleted inserted replaced
37:c2dc1832c0f1 38:2652fc96e660
    32 DeviceWorkstation comment:'
    32 DeviceWorkstation comment:'
    33 
    33 
    34 COPYRIGHT (c) 1993 by Claus Gittinger
    34 COPYRIGHT (c) 1993 by Claus Gittinger
    35               All Rights Reserved
    35               All Rights Reserved
    36 
    36 
    37 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.10 1994-01-09 21:53:00 claus Exp $
    37 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.11 1994-03-30 10:13:08 claus Exp $
    38 written jan 93 by claus
    38 written jan 93 by claus
    39 '!
    39 '!
    40 
    40 
    41 !DeviceWorkstation class methodsFor:'documentation'!
    41 !DeviceWorkstation class methodsFor:'documentation'!
    42 
    42 
    43 documentation
    43 documentation
    44 "
    44 "
    45 this abstract class defines common protocol to all Display types.
    45     this abstract class defines common protocol to all Display types.
    46 
    46 
    47 instance variables:
    47     instance variables:
    48 
    48 
    49 displayId       <Number>        the device id of the display
    49     displayId       <Number>        the device id of the display
    50 visualType      <Symbol>        one of #StaticGray, #PseudoColor, ... #TrueColor
    50     visualType      <Symbol>        one of #StaticGray, #PseudoColor, ... #TrueColor
    51 monitorType     <Symbol>        one of #monochrome, #color, #unknown
    51     monitorType     <Symbol>        one of #monochrome, #color, #unknown
    52 
    52 
    53 depth           <Integer>       bits per color
    53     depth           <Integer>       bits per color
    54 ncells          <Integer>       number of colors (i.e. colormap size; not always == 2^depth)
    54     ncells          <Integer>       number of colors (i.e. colormap size; not always == 2^depth)
    55 bitsPerRGB      <Integer>       number of valid bits per rgb component
    55     bitsPerRGB      <Integer>       number of valid bits per rgb component
    56                                 (actual number taken in A/D converter; not all devices report the true value)
    56                                     (actual number taken in A/D converter; not all devices report the true value)
    57 hasColors       <Boolean>       true, if display supports colors
    57     hasColors       <Boolean>       true, if display supports colors
    58 hasGreyscales   <Boolean>       true, if display supports grey-scales (i.e is not b/w display)
    58     hasGreyscales   <Boolean>       true, if display supports grey-scales (i.e is not b/w display)
    59 width           <Integer>       number of horizontal pixels
    59     width           <Integer>       number of horizontal pixels
    60 height          <Integer>       number of vertical pixels 
    60     height          <Integer>       number of vertical pixels 
    61 heightMM        <Number>        screen height in millimeter
    61     heightMM        <Number>        screen height in millimeter
    62 widthMM         <Number>        screen width in millimeter
    62     widthMM         <Number>        screen width in millimeter
    63 resolutionHor   <Number>        pixels per horizontal millimeter
    63     resolutionHor   <Number>        pixels per horizontal millimeter
    64 resolutionVer   <Number>        pixels per vertical millimeter
    64     resolutionVer   <Number>        pixels per vertical millimeter
    65 
    65 
    66 knownViews      <Collection>    all views known
    66     knownViews      <Collection>    all views known
    67 knownIds        <Collection>    corresponding device-view ids
    67     knownIds        <Collection>    corresponding device-view ids
    68 knownBitmaps    <Collection>    all known device bitmaps
    68     knownBitmaps    <Collection>    all known device bitmaps
    69 knownBitmapIds  <Collection>    corresponding device-bitmap ids
    69     knownBitmapIds  <Collection>    corresponding device-bitmap ids
    70 
    70 
    71 dispatching     <Boolean>       true, if currently in dispatch loop
    71     dispatching     <Boolean>       true, if currently in dispatch loop
    72 
    72 
    73 controlDown     <Boolean>       true, if control key currently pressed
    73     controlDown     <Boolean>       true, if control key currently pressed
    74 shiftDown       <Boolean>       true, if shift key currently pressed
    74     shiftDown       <Boolean>       true, if shift key currently pressed
    75 metaDown        <Boolean>       true, if meta key (cmd-key) is currently pressed
    75     metaDown        <Boolean>       true, if meta key (cmd-key) is currently pressed
    76 altDown         <Boolean>       true, if alt key is currently pressed
    76     altDown         <Boolean>       true, if alt key is currently pressed
    77 
    77 
    78 motionEventCompression
    78     motionEventCompression
    79 
    79 
    80 lastId          <Number>
    80     lastId          <Number>
    81 lastView        <View>
    81     lastView        <View>
    82 
    82 
    83 keyboardMap     <KeyBdMap>      mapping for keys
    83     keyboardMap     <KeyBdMap>      mapping for keys
    84 isSlow          <Boolean>       set/cleared from startup - used to turn off
    84     isSlow          <Boolean>       set/cleared from startup - used to turn off
    85                                 things like popup-shadows etc.
    85                                     things like popup-shadows etc.
    86 "
    86 "
    87 ! !
    87 ! !
    88 
    88 
    89 !DeviceWorkstation class methodsFor:'initialization'!
    89 !DeviceWorkstation class methodsFor:'initialization'!
    90 
    90 
   842 
   842 
   843 addKnownView:aView withId:aNumber
   843 addKnownView:aView withId:aNumber
   844     "add the View aView with Id:aNumber to the list of known views/id's"
   844     "add the View aView with Id:aNumber to the list of known views/id's"
   845 
   845 
   846     knownViews isNil ifTrue:[
   846     knownViews isNil ifTrue:[
   847         knownViews := (VariableArray new:100) grow:0.
   847         knownViews := OrderedCollection new "(VariableArray new:100) grow:0".
   848         knownIds := (VariableArray new:100) grow:0
   848         knownIds := OrderedCollection new "(VariableArray new:100) grow:0"
   849     ].
   849     ].
   850     knownViews add:aView.
   850     knownViews add:aView.
   851     knownIds add:aNumber.
   851     knownIds add:aNumber.
   852     lastView := aView.
   852     lastView := aView.
   853     lastId := aNumber
   853     lastId := aNumber
   992         ]
   992         ]
   993     ]
   993     ]
   994 !
   994 !
   995 
   995 
   996 dispatchPendingEvents
   996 dispatchPendingEvents
   997     [self eventPending] whileTrue:[
   997     Object abortSignal catch:[
   998         self dispatchEventFor:nil withMask:nil
   998         [self eventPending] whileTrue:[
       
   999             self dispatchEventFor:nil withMask:nil
       
  1000         ]
   999     ]
  1001     ]
  1000 !
  1002 !
  1001 
  1003 
  1002 dispatchModalWhile:aBlock
  1004 dispatchModalWhile:aBlock
  1003     "get and process next event for any view as long as the 
  1005     "get and process next event for any view as long as the 
  1662     ^ self subclassResponsibility
  1664     ^ self subclassResponsibility
  1663 ! !
  1665 ! !
  1664 
  1666 
  1665 !DeviceWorkstation methodsFor:'drawing'!
  1667 !DeviceWorkstation methodsFor:'drawing'!
  1666 
  1668 
       
  1669 displayString:aString x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
       
  1670     "draw a string"
       
  1671 
       
  1672     ^ self subclassResponsibility
       
  1673 !
       
  1674 
       
  1675 displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
       
  1676     "draw part of a string"
       
  1677 
       
  1678     "should be redefined to avoid creation of throw-away string" 
       
  1679     self displayString:(aString copyFrom:i1 to:i2)
       
  1680                      x:x 
       
  1681                      y:y 
       
  1682                      in:aDrawableId 
       
  1683                      with:aGCId
       
  1684                      round:round
       
  1685                      opaque:opaque
       
  1686 !
       
  1687 
  1667 displayString:aString x:x y:y in:aDrawableId with:aGCId
  1688 displayString:aString x:x y:y in:aDrawableId with:aGCId
  1668     "draw a string - draw foreground only"
  1689     "draw a string - draw foreground only.
  1669 
  1690      If the coordinates are not integers, retry with rounded." 
  1670     ^ self subclassResponsibility
  1691 
       
  1692     self displayString:aString 
       
  1693          x:x 
       
  1694          y:y 
       
  1695          in:aDrawableId 
       
  1696          with:aGCId 
       
  1697          round:true
       
  1698          opaque:false
  1671 !
  1699 !
  1672 
  1700 
  1673 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  1701 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  1674     "draw part of a string - draw foreground only"
  1702     "draw a sub-string - draw foreground only.
  1675 
  1703      If the coordinates are not integers, retry with rounded." 
  1676     self displayString:(aString copyFrom:index1 to:index2)
  1704 
  1677                      x:x y:y in:aDrawableId with:aGCId
  1705     self displayString:aString 
       
  1706          from:index1
       
  1707          to:index2
       
  1708          x:x 
       
  1709          y:y 
       
  1710          in:aDrawableId 
       
  1711          with:aGCId 
       
  1712          round:true
       
  1713          opaque:false
  1678 !
  1714 !
  1679 
  1715 
  1680 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
  1716 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
  1681     "draw a string - draw both foreground and background"
  1717     "draw a string - draw foreground on background.
  1682 
  1718      If the coordinates are not integers, retry with rounded." 
  1683     ^ self subclassResponsibility
  1719 
       
  1720     self displayString:aString 
       
  1721          x:x 
       
  1722          y:y 
       
  1723          in:aDrawableId 
       
  1724          with:aGCId 
       
  1725          round:true
       
  1726          opaque:true
  1684 !
  1727 !
  1685 
  1728 
  1686 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  1729 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  1687     "draw part of a string - draw both foreground and background"
  1730     "draw a sub-string - draw foreground on background.
  1688 
  1731      If the coordinates are not integers, retry with rounded." 
  1689     self displayOpaqueString:(aString copyFrom:index1 to:index2)
  1732 
  1690                            x:x y:y in:aDrawableId with:aGCId
  1733     self displayString:aString 
       
  1734          from:index1
       
  1735          to:index2
       
  1736          x:x 
       
  1737          y:y 
       
  1738          in:aDrawableId 
       
  1739          with:aGCId 
       
  1740          round:true
       
  1741          opaque:true
  1691 !
  1742 !
  1692 
  1743 
  1693 displayPointX:x y:y in:aDrawableId with:aGCId
  1744 displayPointX:x y:y in:aDrawableId with:aGCId
  1694     "draw a point"
  1745     "draw a point"
  1695 
  1746 
  1697 !
  1748 !
  1698 
  1749 
  1699 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
  1750 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
  1700     "draw a line"
  1751     "draw a line"
  1701 
  1752 
       
  1753     "could add a bresenham line drawer here ..."
  1702     ^ self subclassResponsibility
  1754     ^ self subclassResponsibility
  1703 !
  1755 !
  1704 
  1756 
  1705 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  1757 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  1706     "draw a rectangle"
  1758     "draw a rectangle"
  1707 
  1759 
       
  1760     "should draw four lines here"
  1708     ^ self subclassResponsibility
  1761     ^ self subclassResponsibility
  1709 !
  1762 !
  1710 
  1763 
  1711 displayPolygon:aPolygon in:aDrawableId with:aGCId
  1764 displayPolygon:aPolygon in:aDrawableId with:aGCId
  1712     "draw a polygon"
  1765     "draw a polygon"
  1713 
  1766 
       
  1767     "should draw the lines here"
  1714     ^ self subclassResponsibility
  1768     ^ self subclassResponsibility
  1715 !
  1769 !
  1716 
  1770 
  1717 copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
  1771 copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
  1718                       width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY
  1772                       width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY