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 ! ! |
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 |