DeviceWorkstation.st
changeset 75 a3002e14b6bd
parent 71 6a42b2b115f8
child 81 4ba554473294
equal deleted inserted replaced
74:1afd95cb26cf 75:a3002e14b6bd
    32 
    32 
    33 DeviceWorkstation comment:'
    33 DeviceWorkstation comment:'
    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.18 1994-10-10 02:29:56 claus Exp $
    37 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.19 1994-10-28 03:14:34 claus Exp $
    38 '!
    38 '!
    39 
    39 
    40 !DeviceWorkstation class methodsFor:'documentation'!
    40 !DeviceWorkstation class methodsFor:'documentation'!
    41 
    41 
    42 copyright
    42 copyright
    53 "
    53 "
    54 !
    54 !
    55 
    55 
    56 version
    56 version
    57 "
    57 "
    58 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.18 1994-10-10 02:29:56 claus Exp $
    58 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.19 1994-10-28 03:14:34 claus Exp $
    59 "
    59 "
    60 !
    60 !
    61 
    61 
    62 documentation
    62 documentation
    63 "
    63 "
   134 
   134 
   135 buttonTranslation:anArray
   135 buttonTranslation:anArray
   136     "set the button translation, #(1 2 3) is no-translation,
   136     "set the button translation, #(1 2 3) is no-translation,
   137      #(3 2 1) is ok for left-handers"
   137      #(3 2 1) is ok for left-handers"
   138 
   138 
   139     ButtonTranslation := anArray
   139     ButtonTranslation := anArray.
       
   140     Display notNil ifTrue:[
       
   141 	Display buttonTranslation:anArray
       
   142     ].
   140 ! !
   143 ! !
   141 
   144 
   142 !DeviceWorkstation methodsFor:'initialize / release'!
   145 !DeviceWorkstation methodsFor:'initialize / release'!
   143 
   146 
   144 initialize
   147 initialize
   769 
   772 
   770 buttonTranslation
   773 buttonTranslation
   771     ^ buttonTranslation
   774     ^ buttonTranslation
   772 !
   775 !
   773 
   776 
       
   777 buttonTranslation:anArray
       
   778     buttonTranslation := anArray
       
   779 !
       
   780 
   774 multiClickTimeDelta 
   781 multiClickTimeDelta 
   775     ^ multiClickTimeDelta
   782     ^ multiClickTimeDelta
   776 !
       
   777 
       
   778 buttonTranslation:anArray
       
   779     buttonTranslation := anArray
       
   780 !
   783 !
   781 
   784 
   782 multiClickTimeDelta:milliseconds
   785 multiClickTimeDelta:milliseconds
   783     multiClickTimeDelta := milliseconds
   786     multiClickTimeDelta := milliseconds
   784 ! !
   787 ! !
   791     |curs p|
   794     |curs p|
   792 
   795 
   793     curs := Cursor crossHair on:self.
   796     curs := Cursor crossHair on:self.
   794 
   797 
   795     self ungrabPointer.
   798     self ungrabPointer.
   796     self grabPointerIn:RootView id withCursor:curs id
   799     self grabPointerIn:(RootView id) withCursor:(curs id)
   797 	     pointerMode:#async keyboardMode:#sync confineTo:nil.
   800 	 pointerMode:#async keyboardMode:#sync confineTo:nil.
   798     ActiveGrab := RootView.
   801     ActiveGrab := RootView.
   799 
   802 
   800     [self leftButtonPressed] whileFalse:[].
   803     [self leftButtonPressed] whileFalse:[].
   801     p := self pointerPosition.
   804     p := self pointerPosition.
   802 
   805 
   820 
   823 
   821     curs1 := Cursor origin on:self.
   824     curs1 := Cursor origin on:self.
   822     curs2 := Cursor corner on:self.
   825     curs2 := Cursor corner on:self.
   823 
   826 
   824     self ungrabPointer.
   827     self ungrabPointer.
   825     self grabPointerIn:RootView id withCursor:curs1 id
   828     self grabPointerIn:(RootView id) withCursor:(curs1 id)
   826 	     pointerMode:#async keyboardMode:#sync confineTo:nil.
   829 	 pointerMode:#async keyboardMode:#sync confineTo:nil.
   827     ActiveGrab := RootView.
   830     ActiveGrab := RootView.
   828 
   831 
   829     [self leftButtonPressed] whileFalse:[].
   832     [self leftButtonPressed] whileFalse:[].
   830     origin := self pointerPosition.
   833     origin := self pointerPosition.
   831 
   834 
   832     self ungrabPointer.
   835     self ungrabPointer.
   833     self grabPointerIn:RootView id withCursor:curs1 id
   836     self grabPointerIn:(RootView id) withCursor:(curs1 id)
   834 	     pointerMode:#async keyboardMode:#sync confineTo:nil.
   837 	     pointerMode:#async keyboardMode:#sync confineTo:nil.
   835 
   838 
   836 
   839 
   837     RootView noClipByChildren.
   840     RootView noClipByChildren.
   838 
   841 
  1180 	"
  1183 	"
  1181 	inputSema := Semaphore new.
  1184 	inputSema := Semaphore new.
  1182 	p := [
  1185 	p := [
  1183 	    [dispatching] whileTrue:[
  1186 	    [dispatching] whileTrue:[
  1184 		self eventPending ifFalse:[
  1187 		self eventPending ifFalse:[
       
  1188 		    Processor activeProcess setStateTo:#ioWait if:#active.
  1185 		    inputSema wait.
  1189 		    inputSema wait.
  1186 		].
  1190 		].
  1187 
  1191 
  1188 		"
  1192 		"
  1189 		 in case of an error in the dispatch (i.e. WSensor
  1193 		 in case of an error in the dispatch (i.e. WSensor
  1431 !
  1435 !
  1432 
  1436 
  1433 facesInFamily:aFamilyName
  1437 facesInFamily:aFamilyName
  1434     "return a set of all available font faces in aFamily on this display"
  1438     "return a set of all available font faces in aFamily on this display"
  1435 
  1439 
  1436     |allFonts faces family face|
  1440     |allFonts faces "family face"|
  1437 
  1441 
  1438     allFonts := self listOfAvailableFonts.
  1442     allFonts := self listOfAvailableFonts.
  1439     allFonts isNil ifTrue:[^ nil].
  1443     allFonts isNil ifTrue:[^ nil].
  1440 
  1444 
  1441     faces := Set new.
  1445     faces := Set new.
  1445 "/        (family = aFamilyName) ifTrue:[
  1449 "/        (family = aFamilyName) ifTrue:[
  1446 "/            face := fntDescr at:2.
  1450 "/            face := fntDescr at:2.
  1447 "/            faces add:face
  1451 "/            faces add:face
  1448 "/        ]
  1452 "/        ]
  1449 "/ new:
  1453 "/ new:
  1450 	fntDescr family = aFamilyName ifTrue:[
  1454 	aFamilyName = fntDescr family ifTrue:[
  1451 	    faces add:(fntDescr face)
  1455 	    faces add:(fntDescr face)
  1452 	]
  1456 	]
  1453     ].
  1457     ].
  1454     ^ faces
  1458     ^ faces
  1455 
  1459 
  1460 !
  1464 !
  1461 
  1465 
  1462 stylesInFamily:aFamilyName face:aFaceName
  1466 stylesInFamily:aFamilyName face:aFaceName
  1463     "return a set of all available font styles in aFamily/aFace on this display"
  1467     "return a set of all available font styles in aFamily/aFace on this display"
  1464 
  1468 
  1465     |allFonts styles family face style|
  1469     |allFonts styles "family face style"|
  1466 
  1470 
  1467     allFonts := self listOfAvailableFonts.
  1471     allFonts := self listOfAvailableFonts.
  1468     allFonts isNil ifTrue:[^ nil].
  1472     allFonts isNil ifTrue:[^ nil].
  1469 
  1473 
  1470     styles := Set new.
  1474     styles := Set new.
  1476 "/            (face = aFaceName) ifTrue:[
  1480 "/            (face = aFaceName) ifTrue:[
  1477 "/                style := fntDescr at:3.
  1481 "/                style := fntDescr at:3.
  1478 "/                styles add:style
  1482 "/                styles add:style
  1479 "/            ]
  1483 "/            ]
  1480 "/        ]
  1484 "/        ]
  1481 	(fntDescr family = aFamilyName) ifTrue:[
  1485 	(aFamilyName = fntDescr family) ifTrue:[
  1482 	    (fntDescr face = aFaceName) ifTrue:[
  1486 	    (aFaceName = fntDescr face) ifTrue:[
  1483 		styles add:fntDescr style
  1487 		styles add:fntDescr style
  1484 	    ]
  1488 	    ]
  1485 	]
  1489 	]
  1486     ].
  1490     ].
  1487     ^ styles
  1491     ^ styles
  1494 
  1498 
  1495 sizesInFamily:aFamilyName face:aFaceName style:aStyleName
  1499 sizesInFamily:aFamilyName face:aFaceName style:aStyleName
  1496     "return a set of all available font sizes in aFamily/aFace/aStyle
  1500     "return a set of all available font sizes in aFamily/aFace/aStyle
  1497      on this display"
  1501      on this display"
  1498 
  1502 
  1499     |allFonts sizes family face style size|
  1503     |allFonts sizes "family face style size"|
  1500 
  1504 
  1501     allFonts := self listOfAvailableFonts.
  1505     allFonts := self listOfAvailableFonts.
  1502     allFonts isNil ifTrue:[^ nil].
  1506     allFonts isNil ifTrue:[^ nil].
  1503 
  1507 
  1504     sizes := Set new.
  1508     sizes := Set new.
  1512 "/                    size := fntDescr at:4.
  1516 "/                    size := fntDescr at:4.
  1513 "/                    sizes add:size
  1517 "/                    sizes add:size
  1514 "/                ]
  1518 "/                ]
  1515 "/            ]
  1519 "/            ]
  1516 "/        ]
  1520 "/        ]
  1517 	(fntDescr family = aFamilyName) ifTrue:[
  1521 	(aFamilyName = fntDescr family) ifTrue:[
  1518 	    (fntDescr face = aFaceName) ifTrue:[
  1522 	    (aFaceName = fntDescr face) ifTrue:[
  1519 		(fntDescr style = aStyleName) ifTrue:[
  1523 		(aStyleName = fntDescr style) ifTrue:[
  1520 		    sizes add:fntDescr size
  1524 		    sizes add:fntDescr size
  1521 		]
  1525 		]
  1522 	    ]
  1526 	    ]
  1523 	]
  1527 	]
  1524     ].
  1528     ].
  1626     "release the keyboard"
  1630     "release the keyboard"
  1627 
  1631 
  1628     ^ self subclassResponsibility
  1632     ^ self subclassResponsibility
  1629 !
  1633 !
  1630 
  1634 
       
  1635 grabPointerIn:aWindowId withCursor:cursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
       
  1636     "grap the pointer - all pointer events will be reported to aWindowId. The cursor will be set to cursorId
       
  1637      for the duration of the grab. For pMode/kMode, see X documentation. The pointer is restricted to
       
  1638      confineId - if non-nil."
       
  1639 
       
  1640     ^ self subclassResponsibility
       
  1641 !
       
  1642 
  1631 grabPointerIn:aWindowId
  1643 grabPointerIn:aWindowId
  1632     "grap the pointer"
  1644     "grap the pointer - return true if ok"
  1633 
  1645 
  1634     ^ self subclassResponsibility
  1646     ^ self grabPointerIn:aWindowId withCursor:nil pointerMode:#async keyboardMode:#sync confineTo:nil
  1635 !
  1647 !
  1636 
  1648 
  1637 ungrabPointer
  1649 ungrabPointer
  1638     "release the pointer"
  1650     "release the pointer"
  1639 
  1651 
  1946     ^ self subclassResponsibility
  1958     ^ self subclassResponsibility
  1947 ! !
  1959 ! !
  1948 
  1960 
  1949 !DeviceWorkstation methodsFor:'drawing'!
  1961 !DeviceWorkstation methodsFor:'drawing'!
  1950 
  1962 
  1951 displayString:aString x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
  1963 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque
  1952     "draw a string"
  1964     "draw a string"
  1953 
  1965 
  1954     ^ self subclassResponsibility
  1966     ^ self subclassResponsibility
  1955 !
  1967 !
  1956 
  1968 
  1957 displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId round:round opaque:opaque
  1969 displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId opaque:opaque
  1958     "draw part of a string"
  1970     "draw part of a string"
  1959 
  1971 
  1960     "should be redefined to avoid creation of throw-away string" 
  1972     "
       
  1973      should be redefined in concrete subclasses
       
  1974      to avoid creation of throw-away string
       
  1975     "
  1961     self displayString:(aString copyFrom:i1 to:i2)
  1976     self displayString:(aString copyFrom:i1 to:i2)
  1962 		     x:x 
  1977 		     x:x 
  1963 		     y:y 
  1978 		     y:y 
  1964 		     in:aDrawableId 
  1979 		     in:aDrawableId 
  1965 		     with:aGCId
  1980 		     with:aGCId
  1966 		     round:round
       
  1967 		     opaque:opaque
  1981 		     opaque:opaque
  1968 !
  1982 !
  1969 
  1983 
  1970 displayString:aString x:x y:y in:aDrawableId with:aGCId
  1984 displayString:aString x:x y:y in:aDrawableId with:aGCId
  1971     "draw a string - draw foreground only.
  1985     "draw a string - draw foreground only.
       
  1986      If the coordinates are not integers, retry with rounded." 
       
  1987 
       
  1988     self 
       
  1989 	displayString:aString 
       
  1990 	x:x 
       
  1991 	y:y 
       
  1992 	in:aDrawableId 
       
  1993 	with:aGCId 
       
  1994 	opaque:false
       
  1995 !
       
  1996 
       
  1997 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
       
  1998     "draw a sub-string - draw foreground only.
       
  1999      If the coordinates are not integers, retry with rounded." 
       
  2000 
       
  2001     self 
       
  2002 	displayString:aString 
       
  2003 	from:index1
       
  2004 	to:index2
       
  2005 	x:x 
       
  2006 	y:y 
       
  2007 	in:aDrawableId 
       
  2008 	with:aGCId 
       
  2009 	opaque:false
       
  2010 !
       
  2011 
       
  2012 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
       
  2013     "draw a string - draw foreground on background.
  1972      If the coordinates are not integers, retry with rounded." 
  2014      If the coordinates are not integers, retry with rounded." 
  1973 
  2015 
  1974     self displayString:aString 
  2016     self displayString:aString 
  1975 	 x:x 
  2017 	 x:x 
  1976 	 y:y 
  2018 	 y:y 
  1977 	 in:aDrawableId 
  2019 	 in:aDrawableId 
  1978 	 with:aGCId 
  2020 	 with:aGCId 
  1979 	 round:true
  2021 	 opaque:true
  1980 	 opaque:false
  2022 !
  1981 !
  2023 
  1982 
  2024 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  1983 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  2025     "draw a sub-string - draw foreground on background.
  1984     "draw a sub-string - draw foreground only.
       
  1985      If the coordinates are not integers, retry with rounded." 
  2026      If the coordinates are not integers, retry with rounded." 
  1986 
  2027 
  1987     self displayString:aString 
  2028     self displayString:aString 
  1988 	 from:index1
  2029 	 from:index1
  1989 	 to:index2
  2030 	 to:index2
  1990 	 x:x 
  2031 	 x:x 
  1991 	 y:y 
  2032 	 y:y 
  1992 	 in:aDrawableId 
  2033 	 in:aDrawableId 
  1993 	 with:aGCId 
  2034 	 with:aGCId 
  1994 	 round:true
       
  1995 	 opaque:false
       
  1996 !
       
  1997 
       
  1998 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
       
  1999     "draw a string - draw foreground on background.
       
  2000      If the coordinates are not integers, retry with rounded." 
       
  2001 
       
  2002     self displayString:aString 
       
  2003 	 x:x 
       
  2004 	 y:y 
       
  2005 	 in:aDrawableId 
       
  2006 	 with:aGCId 
       
  2007 	 round:true
       
  2008 	 opaque:true
       
  2009 !
       
  2010 
       
  2011 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
       
  2012     "draw a sub-string - draw foreground on background.
       
  2013      If the coordinates are not integers, retry with rounded." 
       
  2014 
       
  2015     self displayString:aString 
       
  2016 	 from:index1
       
  2017 	 to:index2
       
  2018 	 x:x 
       
  2019 	 y:y 
       
  2020 	 in:aDrawableId 
       
  2021 	 with:aGCId 
       
  2022 	 round:true
       
  2023 	 opaque:true
  2035 	 opaque:true
  2024 !
  2036 !
  2025 
  2037 
  2026 displayPointX:x y:y in:aDrawableId with:aGCId
  2038 displayPointX:x y:y in:aDrawableId with:aGCId
  2027     "draw a point"
  2039     "draw a point"
  2037 !
  2049 !
  2038 
  2050 
  2039 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  2051 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  2040     "draw a rectangle"
  2052     "draw a rectangle"
  2041 
  2053 
  2042     "should draw four lines here"
  2054     "
       
  2055      should draw four lines here
       
  2056      but then, we have to reimplement all line styles here
       
  2057     "
  2043     ^ self subclassResponsibility
  2058     ^ self subclassResponsibility
  2044 !
  2059 !
  2045 
  2060 
  2046 displayPolygon:aPolygon in:aDrawableId with:aGCId
  2061 displayPolygon:aPolygon in:aDrawableId with:aGCId
  2047     "draw a polygon"
  2062     "draw a polygon"
  2048 
  2063 
  2049     "should draw the lines here"
  2064     "
       
  2065      should draw the lines here
       
  2066      but then, we have to reimplement all line styles here
       
  2067     "
  2050     ^ self subclassResponsibility
  2068     ^ self subclassResponsibility
  2051 !
  2069 !
  2052 
  2070 
  2053 copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
  2071 copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY
  2054 		      width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY
  2072 		      width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY