DeviceWorkstation.st
changeset 89 ea2bf46eb669
parent 86 032006651226
child 94 8931597dfa3c
equal deleted inserted replaced
88:8f9c629a4245 89:ea2bf46eb669
    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.22 1994-11-28 21:00:42 claus Exp $
    37 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.23 1995-02-06 00:36:13 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.22 1994-11-28 21:00:42 claus Exp $
    58 $Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.23 1995-02-06 00:36:13 claus Exp $
    59 "
    59 "
    60 !
    60 !
    61 
    61 
    62 documentation
    62 documentation
    63 "
    63 "
   400 
   400 
   401 setInputFocusTo:aWindowId
   401 setInputFocusTo:aWindowId
   402     ^ self subclassResponsibility
   402     ^ self subclassResponsibility
   403 ! !
   403 ! !
   404 
   404 
   405 !DeviceWorkstation methodsFor:'enumeration'!
   405 !DeviceWorkstation methodsFor:'enumerating'!
   406 
   406 
   407 allViewsDo:aBlock
   407 allViewsDo:aBlock
   408     "evaluate the argument, aBlock for all known views"
   408     "evaluate the argument, aBlock for all known views"
   409 
   409 
   410 "/    idToViewMapping notNil ifTrue:[
   410 "/    idToViewMapping notNil ifTrue:[
  1006 
  1006 
  1007 sendKeyPress:untranslatedKey x:x y:y to:someone
  1007 sendKeyPress:untranslatedKey x:x y:y to:someone
  1008     "forward a key-press event to some handler;
  1008     "forward a key-press event to some handler;
  1009      the key is translated via the translation table here."
  1009      the key is translated via the translation table here."
  1010 
  1010 
  1011     |xlatedKey|
  1011     |xlatedKey delegate dest|
  1012 
  1012 
  1013     xlatedKey := self translateKey:untranslatedKey.
  1013     xlatedKey := self translateKey:untranslatedKey.
  1014     xlatedKey notNil ifTrue:[
  1014     xlatedKey notNil ifTrue:[
  1015 	someone delegate notNil ifTrue:[
  1015 	(delegate := someone delegate) notNil ifTrue:[
  1016 	    someone delegate keyPress:xlatedKey x:x y:y view:someone
  1016 	    delegate keyPress:xlatedKey x:x y:y view:someone
  1017 	] ifFalse:[
  1017 	] ifFalse:[
  1018 	    someone keyPress:xlatedKey x:x y:y
  1018 	    (dest := someone controller) isNil ifTrue:[
       
  1019 		dest := someone
       
  1020 	    ].
       
  1021 	    dest keyPress:xlatedKey x:x y:y
  1019 	]
  1022 	]
  1020     ]
  1023     ]
  1021 !
  1024 !
  1022 
  1025 
  1023 sendKeyRelease:untranslatedKey x:x y:y to:someone
  1026 sendKeyRelease:untranslatedKey x:x y:y to:someone
  1024     "forward a key-release event to some handler;
  1027     "forward a key-release event to some handler;
  1025      the key is translated via the translation table here."
  1028      the key is translated via the translation table here."
  1026 
  1029 
  1027     |xlatedKey|
  1030     |xlatedKey delegate dest|
  1028 
  1031 
  1029     xlatedKey := self translateKey:untranslatedKey.
  1032     xlatedKey := self translateKey:untranslatedKey.
  1030     xlatedKey notNil ifTrue:[
  1033     xlatedKey notNil ifTrue:[
  1031 	someone delegate notNil ifTrue:[
  1034 	(delegate := someone delegate) notNil ifTrue:[
  1032 	    someone delegate keyRelease:xlatedKey x:x y:y view:someone
  1035 	    delegate keyRelease:xlatedKey x:x y:y view:someone
  1033 	] ifFalse:[
  1036 	] ifFalse:[
  1034 	    someone keyRelease:xlatedKey x:x y:y
  1037 	    (dest := someone controller) isNil ifTrue:[
       
  1038 		dest := someone
       
  1039 	    ].
       
  1040 	    dest keyRelease:xlatedKey x:x y:y
  1035 	]
  1041 	]
  1036     ]
  1042     ]
  1037 !
  1043 !
  1038 
  1044 
  1039 translateKey:untranslatedKey
  1045 translateKey:untranslatedKey
  1040     "Return the key translated via the translation table.
  1046     "Return the key translated via the translation table.
       
  1047      Your application program should never depend on the values returned
       
  1048      by this method, but instead use symbolic keys (such as #FindNext).
       
  1049      Doing so allows easier reconfiguration by changing the translation map
       
  1050      in the 'smalltalk.rc' or 'display.rc' startup files.
  1041 
  1051 
  1042      First, the modifier is prepended, making character X into
  1052      First, the modifier is prepended, making character X into
  1043      AltX, CtrlX or CmdX (on most systems, no separate Cmd (or Meta)
  1053      AltX, CtrlX or CmdX (on most systems, no separate Cmd (or Meta)
  1044      key exists; on those we always get AltX).
  1054      key exists; on those we always get AltX).
       
  1055      If multiple modifiers are active, the symbol becoms the concatenation
       
  1056      as in AltCtrlq (for control-alt-q). Shift will affect the last component,
       
  1057      thus the above with shift becoms: AltCtrlQ instead.
       
  1058      Some keyboards offer both Alt and Meta keys - on those, the first has a
       
  1059      prefix of Alt, the second has Cmd as prefix. Keyboards with only an Alt
       
  1060      key will will create prefix codes of Cmd for that.
       
  1061      For symbolic keys (i.e.Tab, Backspace etc, shift is ignored).
  1045      Then the result is used as a key into the translation keyboardMap
  1062      Then the result is used as a key into the translation keyboardMap
  1046      to get the final return value."
  1063      to get the final return value."
  1047 
  1064 
  1048     |xlatedKey|
  1065     |xlatedKey|
  1049 
  1066 
  1050     xlatedKey := untranslatedKey.
  1067     xlatedKey := untranslatedKey.
  1051     controlDown ifTrue:[
  1068     controlDown ifTrue:[
  1052 	(xlatedKey size == 1) ifTrue:[   "a single character"
  1069 	xlatedKey := ('Ctrl' , xlatedKey asString) asSymbol
  1053 	    xlatedKey := ('Ctrl' , untranslatedKey asString) asSymbol
       
  1054 	].
       
  1055     ].
  1070     ].
  1056     metaDown ifTrue:[
  1071     metaDown ifTrue:[
  1057 	(untranslatedKey isMemberOf:Character) ifTrue:[
  1072 	xlatedKey := ('Cmd' , xlatedKey asString) asSymbol
  1058 	    xlatedKey := ('Cmd' , untranslatedKey asString) asSymbol
       
  1059 	]
       
  1060     ].
  1073     ].
  1061     altDown ifTrue:[
  1074     altDown ifTrue:[
  1062 	(untranslatedKey isMemberOf:Character) ifTrue:[
  1075 	xlatedKey := ('Alt' , xlatedKey asString) asSymbol
  1063 	    xlatedKey := ('Alt' , untranslatedKey asString) asSymbol
       
  1064 	]
       
  1065     ].
  1076     ].
  1066 
  1077 
  1067     xlatedKey := keyboardMap valueFor:xlatedKey.
  1078     xlatedKey := keyboardMap valueFor:xlatedKey.
  1068     ^ xlatedKey
  1079     ^ xlatedKey
  1069 ! !
  1080 ! !
  1508 
  1519 
  1509     allFonts := self listOfAvailableFonts.
  1520     allFonts := self listOfAvailableFonts.
  1510     allFonts isNil ifTrue:[^ nil].
  1521     allFonts isNil ifTrue:[^ nil].
  1511     families := Set new.
  1522     families := Set new.
  1512     allFonts do:[:fntDescr |
  1523     allFonts do:[:fntDescr |
  1513 "/ old:
       
  1514 "/        family := fntDescr at:1.
       
  1515 "/ new:
       
  1516 	family := fntDescr family.
  1524 	family := fntDescr family.
  1517 	family notNil ifTrue:[
  1525 	family notNil ifTrue:[
  1518 	    families add:family
  1526 	    families add:family
  1519 	]
  1527 	]
  1520     ].
  1528     ].
  1521     ^ families
  1529     ^ families asSortedCollection
  1522 
  1530 
  1523     "
  1531     "
  1524      Display fontFamilies
  1532      Display fontFamilies
  1525     "
  1533     "
  1526 !
  1534 !
  1533     allFonts := self listOfAvailableFonts.
  1541     allFonts := self listOfAvailableFonts.
  1534     allFonts isNil ifTrue:[^ nil].
  1542     allFonts isNil ifTrue:[^ nil].
  1535 
  1543 
  1536     faces := Set new.
  1544     faces := Set new.
  1537     allFonts do:[:fntDescr |
  1545     allFonts do:[:fntDescr |
  1538 "/ old:
       
  1539 "/        family := fntDescr at:1.
       
  1540 "/        (family = aFamilyName) ifTrue:[
       
  1541 "/            face := fntDescr at:2.
       
  1542 "/            faces add:face
       
  1543 "/        ]
       
  1544 "/ new:
       
  1545 	aFamilyName = fntDescr family ifTrue:[
  1546 	aFamilyName = fntDescr family ifTrue:[
  1546 	    faces add:(fntDescr face)
  1547 	    faces add:(fntDescr face)
  1547 	]
  1548 	]
  1548     ].
  1549     ].
  1549     ^ faces
  1550     ^ faces asSortedCollection
  1550 
  1551 
  1551     "
  1552     "
  1552      Display facesInFamily:'times'
  1553      Display facesInFamily:'times'
  1553      Display facesInFamily:'fixed'
  1554      Display facesInFamily:'fixed'
  1554     "
  1555     "
  1562     allFonts := self listOfAvailableFonts.
  1563     allFonts := self listOfAvailableFonts.
  1563     allFonts isNil ifTrue:[^ nil].
  1564     allFonts isNil ifTrue:[^ nil].
  1564 
  1565 
  1565     styles := Set new.
  1566     styles := Set new.
  1566     allFonts do:[:fntDescr |
  1567     allFonts do:[:fntDescr |
  1567 "/ old:
       
  1568 "/        family := fntDescr at:1.
       
  1569 "/        (family = aFamilyName) ifTrue:[
       
  1570 "/            face := fntDescr at:2.
       
  1571 "/            (face = aFaceName) ifTrue:[
       
  1572 "/                style := fntDescr at:3.
       
  1573 "/                styles add:style
       
  1574 "/            ]
       
  1575 "/        ]
       
  1576 	(aFamilyName = fntDescr family) ifTrue:[
  1568 	(aFamilyName = fntDescr family) ifTrue:[
  1577 	    (aFaceName = fntDescr face) ifTrue:[
  1569 	    (aFaceName = fntDescr face) ifTrue:[
  1578 		styles add:fntDescr style
  1570 		styles add:fntDescr style
  1579 	    ]
  1571 	    ]
  1580 	]
  1572 	]
  1581     ].
  1573     ].
  1582     ^ styles
  1574     ^ styles asSortedCollection
  1583 
  1575 
  1584     "
  1576     "
  1585      Display stylesInFamily:'times' face:'medium'
  1577      Display stylesInFamily:'times' face:'medium'
  1586      Display stylesInFamily:'times' face:'bold'
  1578      Display stylesInFamily:'times' face:'bold'
  1587     "
  1579     "
  1842     "change color in map at:index to rgb (0..100)"
  1834     "change color in map at:index to rgb (0..100)"
  1843 
  1835 
  1844     ^ self subclassResponsibility
  1836     ^ self subclassResponsibility
  1845 !
  1837 !
  1846 
  1838 
       
  1839 redComponentOfColor:colorId
       
  1840     "get red component (0..100) of color in map at:index"
       
  1841 
       
  1842     self getRGBFrom:colorId into:[:r :g :b | ^ r]
       
  1843 !
       
  1844 
       
  1845 greenComponentOfColor:colorId
       
  1846     "get green component (0..100) of color in map at:index"
       
  1847 
       
  1848     self getRGBFrom:colorId into:[:r :g :b | ^ g]
       
  1849 !
       
  1850 
       
  1851 blueComponentOfColor:colorId
       
  1852     "get blue component (0..100) of color in map at:index"
       
  1853 
       
  1854     self getRGBFrom:colorId into:[:r :g :b | ^ b]
       
  1855 !
       
  1856 
  1847 getRGBFromName:colorName into:aBlock
  1857 getRGBFromName:colorName into:aBlock
  1848     "get rgb components (0..100) of color named colorName,
  1858     "get rgb components (0..100) of color named colorName,
  1849      and evaluate the 3-arg block, aBlock with them.
  1859      and evaluate the 3-arg block, aBlock with them.
  1850      The method here only handles some often used colors;
  1860      The method here only handles some often used colors;
  1851      getRGBFromName should not be used, since colorNames other
  1861      getRGBFromName should not be used, since colorNames other