CharacterSetView.st
changeset 4974 0bf6ebf6f25b
parent 4722 48daa9baf996
child 5165 d38afb4825a5
--- a/CharacterSetView.st	Fri Mar 25 17:02:30 2016 +0100
+++ b/CharacterSetView.st	Fri Mar 25 17:02:39 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "
  COPYRIGHT (c) 2004 by eXept Software AG
               All Rights Reserved
@@ -124,7 +122,7 @@
     |top panel v bNext bPrev bFirst bLast comboList rangeLabel codePointLabel
      first last next prev enable update updateCodePoint w h
      minPage maxPage insertCharacter deviceFont minCode maxCode
-     htmlHolder|
+     htmlHolder codePageList|
 
     htmlHolder := false asValue.
 
@@ -153,7 +151,7 @@
     panel := HorizontalPanelView in:top.
     panel origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
     panel bottomInset:-25.
-    panel horizontalLayout:#left.
+    panel horizontalLayout:#leftSpace.
 
     aConsumingView notNil ifTrue:[
         v useSameFontAs:aConsumingView.
@@ -229,17 +227,19 @@
     ].
 
     update := [
-            |uOffs selectedCodePoint lbl|
+            |uOffs selectedCodePoint lbl nm|
 
             aCharacterEncoderOrNil isNil ifTrue:[
-                lbl := 'u%1 ... u%2'
+                lbl := 'u%1..u%2'
             ] ifFalse:[
-                lbl := '%1 ... %2'
+                nm := aCharacterEncoderOrNil userFriendlyNameOfEncoding.
+                lbl := '%1..%2 / %3'
             ].
             uOffs := v codePage * 16r0100.
             rangeLabel label:(lbl 
                         bindWith:((uOffs printStringRadix:16) leftPaddedTo:4 with:$0)
-                        with:(((uOffs + 16rFF) printStringRadix:16) leftPaddedTo:4 with:$0)).
+                        with:(((uOffs + 16rFF) printStringRadix:16) leftPaddedTo:4 with:$0)
+                        with:nm).
             rangeLabel repairDamage.
         ].
 
@@ -291,18 +291,25 @@
         comboList := ComboListView in:panel.
         comboList extent:(16@16).
         comboList label:'?'.
+        codePageList := 
+            #(
+                (16r00   'Latin')          
+                (16r03   'Greek')  
+                (16r05   'Hebrew')  
+                (16r06   'Arabic')
+                (16r22   'Math')   
+                (16r29   'Math Symbols') 
+                (16r2A   'Math Operators') 
+                (16r21   'Arrows & Math Letters') 
+                (16r23   'Technical') 
+                (16r20   'Currency') 
+                (16r33   'Units') 
+                (16r27   'Dingbat')
+                (16r25   'Block Graphic') 
+            ).
         comboList 
-            list:   #('Latin' 'Greek'  'Hebrew'  'Arabic'
-                      'Math'   'Math Symbols-A' 'Math Symbols-B' 'Math Operators' 'Math Letter Symbols' 
-                      'Technical' 'Currency' 'Arrows' 'Dingbat'
-                      'Block Graphic'  
-                     );
-            values: #( 
-                       16r00 16r03      16r05 16r06
-                       16r22 16r27          16r29          16r2A          16r21
-                       16r23 16r20 16r21 16r27 
-                       16r25               
-                     ).
+            list:   (codePageList collect:#second);
+            values: (codePageList collect:#first). 
         comboList action:
             [:cp | 
                 v codePage:cp. 
@@ -430,15 +437,13 @@
         0 to:15 do:[:col |
             |x0 x1 x codePoint decodedCodePoint s|
 
-            codePoint := (codePage * 16r100) + (rowBase + col).
+            codePoint := decodedCodePoint := (codePage * 16r100) + (rowBase + col).
             encoderOrNil notNil ifTrue:[
                 [
                     decodedCodePoint := (encoderOrNil decode:codePoint) ? 0
                 ] on:DecodingError do:[:ex|
                     decodedCodePoint := ex defaultValue.
                 ].
-            ] ifFalse:[
-                decodedCodePoint := codePoint
             ].
             s := (Character value:decodedCodePoint) asString.
 
@@ -462,6 +467,7 @@
         ].
     ].
 
+    self paint:(Color grey).
     0 to:16 do:[:col |
         |x|
 
@@ -475,6 +481,7 @@
         y := (row * hRow) rounded asInteger.
         self displayLineFromX:0 y:y toX:width y:y.
     ].
+    self paint:(Color black).
 
     "
      (self extent:300@600) open
@@ -608,18 +615,18 @@
         ^ preferredExtent
     ].
 
-    ^ ((4 + gc font width + 4) * 16)
+    ^ ((4 + (gc font widthOf:'W') + 4) * 16)
        @
-      ((4 + gc font height + 4) * 16)
+      ((4 + (gc font heightOf:'W') + 4) * 16)
 ! !
 
 !CharacterSetView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/CharacterSetView.st,v 1.35 2015-02-27 18:52:54 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/CharacterSetView.st,v 1.35 2015-02-27 18:52:54 cg Exp $'
+    ^ '$Header$'
 ! !