CharacterSetView.st
changeset 2662 8f3c0771493c
parent 2660 851d38de3274
child 2663 a8564131810a
equal deleted inserted replaced
2661:f68913f2facf 2662:8f3c0771493c
    14 
    14 
    15 View subclass:#CharacterSetView
    15 View subclass:#CharacterSetView
    16 	instanceVariableNames:'codePageHolder selectedCodePointHolder masterViewOrNil'
    16 	instanceVariableNames:'codePageHolder selectedCodePointHolder masterViewOrNil'
    17 	classVariableNames:''
    17 	classVariableNames:''
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Collections-Text-Encodings'
    19 	category:'Views-Misc'
    20 !
    20 !
    21 
    21 
    22 !CharacterSetView class methodsFor:'documentation'!
    22 !CharacterSetView class methodsFor:'documentation'!
    23 
    23 
    24 copyright
    24 copyright
    42     or to insert characters into a textView (opened by a textEditors misc-specialCharacters menu).
    42     or to insert characters into a textView (opened by a textEditors misc-specialCharacters menu).
    43 
    43 
    44     Author:
    44     Author:
    45         Claus Gittinger
    45         Claus Gittinger
    46 "
    46 "
       
    47 !
       
    48 
       
    49 examples
       
    50 "
       
    51     CharacterSetView openOn:(Button defaultFont).
       
    52 
       
    53 
       
    54     CharacterSetView 
       
    55         openAsInputFor:Transcript
       
    56         label:'Input to Transcript'
       
    57         clickLabel:'Click to input character'
       
    58 "
    47 ! !
    59 ! !
    48 
    60 
    49 !CharacterSetView class methodsFor:'instance creation'!
    61 !CharacterSetView class methodsFor:'instance creation'!
    50 
    62 
    51 new
    63 new
    90 !
   102 !
    91 
   103 
    92 openOn:aFont label:viewLabel clickLabel:clickLabel asInputFor:aView
   104 openOn:aFont label:viewLabel clickLabel:clickLabel asInputFor:aView
    93     |top panel v bNext bPrev bFirst bLast rangeLabel codePointLabel
   105     |top panel v bNext bPrev bFirst bLast rangeLabel codePointLabel
    94      first last next prev enable update updateCodePoint w h
   106      first last next prev enable update updateCodePoint w h
    95      minPage maxPage|
   107      minPage maxPage insertCharacter|
    96 
   108 
    97     minPage := 0.
   109     minPage := 0.
    98     maxPage := (aFont onDevice:Screen current) getFontMetrics maxCode >> 8.
   110     maxPage := (aFont onDevice:Screen current) getFontMetrics maxCode >> 8.
    99 
   111 
   100     top := StandardSystemView new.
   112     top := StandardSystemView new.
   112     aView notNil ifTrue:[
   124     aView notNil ifTrue:[
   113         v useSameFontAs:aView.
   125         v useSameFontAs:aView.
   114     ].
   126     ].
   115 
   127 
   116     "/ actions
   128     "/ actions
       
   129     aView notNil ifTrue:[
       
   130         insertCharacter := [:char | 
       
   131                                 (char isString ifTrue:[char] ifFalse:[Array with:char])
       
   132                                 do:[:char | |unicodePoint unicodeChar|
       
   133                                     unicodePoint := CharacterEncoder encode:(char codePoint) from:aView characterEncoding into:'unicode'.
       
   134                                     unicodeChar := Character value:unicodePoint.
       
   135                                     aView dispatchEvent:(WindowEvent keyPress:unicodeChar x:0 y:0 view:v).
       
   136                                     aView dispatchEvent:(WindowEvent keyRelease:unicodeChar x:0 y:0 view:v).
       
   137                                 ].
       
   138                            ].
       
   139     ].
       
   140 
   117     updateCodePoint := [
   141     updateCodePoint := [
   118             |selectedCodePoint selectedChar 
   142             |selectedCodePoint selectedChar 
   119              isLetter isDigit isUppercase isLowercase|
   143              isLetter isDigit isUppercase isLowercase|
   120 
   144 
   121             selectedCodePoint := v selectedCodePoint.
   145             selectedCodePoint := v selectedCodePoint.
   140                             with:(isUppercase ifTrue:'Uc' ifFalse:[isLowercase ifTrue:'lc' ifFalse:''])
   164                             with:(isUppercase ifTrue:'Uc' ifFalse:[isLowercase ifTrue:'lc' ifFalse:''])
   141                             with:(isLetter ifTrue:'Letter' ifFalse:[(isDigit ifTrue:'Digit' ifFalse:'')])
   165                             with:(isLetter ifTrue:'Letter' ifFalse:[(isDigit ifTrue:'Digit' ifFalse:'')])
   142                         ).
   166                         ).
   143             ].
   167             ].
   144             codePointLabel repairDamage.
   168             codePointLabel repairDamage.
       
   169 
       
   170             aView notNil ifTrue:[
       
   171                 selectedCodePoint notNil ifTrue:[
       
   172                     insertCharacter value:(Character value:selectedCodePoint).
       
   173                     v selectedCodePointHolder value:nil.
       
   174                 ]
       
   175             ]
   145     ].
   176     ].
   146 
   177 
   147     update := [
   178     update := [
   148             |uOffs selectedCodePoint|
   179             |uOffs selectedCodePoint|
   149 
   180 
   442 ! !
   473 ! !
   443 
   474 
   444 !CharacterSetView class methodsFor:'documentation'!
   475 !CharacterSetView class methodsFor:'documentation'!
   445 
   476 
   446 version
   477 version
   447     ^ '$Header: /cvs/stx/stx/libwidg2/CharacterSetView.st,v 1.15 2004-02-26 16:17:23 cg Exp $'
   478     ^ '$Header: /cvs/stx/stx/libwidg2/CharacterSetView.st,v 1.16 2004-02-27 11:41:40 cg Exp $'
   448 ! !
   479 ! !