TabSpecRuler.st
changeset 29 b1663ac8f532
child 36 160b8f0dfd7d
equal deleted inserted replaced
28:ca403f4c5b86 29:b1663ac8f532
       
     1 'From Smalltalk/X, Version:2.10.4 on 18-nov-1994 at 12:07:44'!
       
     2 
       
     3 View subclass:#TabSpecRuler
       
     4 	 instanceVariableNames:'tabSpec titleEntry handleStyle'
       
     5 	 classVariableNames:'DefaultHandleStyle'
       
     6 	 poolDictionaries:''
       
     7 	 category:'Views-Misc'
       
     8 !
       
     9 
       
    10 !TabSpecRuler class methodsFor:'documentation'!
       
    11 
       
    12 examples
       
    13 "
       
    14         |top head spec|
       
    15 
       
    16         top := View new.
       
    17         top extent:300@100.
       
    18 
       
    19         head := TabSpecRuler in:top.
       
    20         head width:1.0.
       
    21         head level:1.
       
    22 
       
    23         spec := TabulatorSpecification new.
       
    24         spec unit:#inch.
       
    25         spec positions:#(0     1     2.5    3.5    4       5        ).
       
    26         spec align:    #(#left #left #right #right #center #decimal ).
       
    27 
       
    28         head tabulatorSpecification:spec.
       
    29         top open.
       
    30 "
       
    31 
       
    32 ! !
       
    33 
       
    34 !TabSpecRuler class methodsFor:'defaults'!
       
    35 
       
    36 updateStyleCache
       
    37     DefaultHandleStyle := StyleSheet at:'tabRulerHandleStyle'.
       
    38 
       
    39 ! !
       
    40 
       
    41 !TabSpecRuler methodsFor:'redrawing'!
       
    42 
       
    43 drawHandleAtX:x type:handleType
       
    44     "redraw a handle"
       
    45 
       
    46     handleStyle isNil ifTrue:[
       
    47         self displayLineFromX:x rounded
       
    48                             y:0
       
    49                           toX:x rounded
       
    50                             y:height - 1
       
    51     ]
       
    52 !
       
    53 
       
    54 redraw
       
    55     "redraw the handles from by tabSpec"
       
    56 
       
    57     |x|
       
    58 
       
    59     tabSpec isNil ifTrue:[^ self].
       
    60     1 to:tabSpec size do:[:i |
       
    61         x := tabSpec positionOfTab:i on:self.
       
    62         x := x rounded.
       
    63 
       
    64         self drawHandleAtX:x type:(tabSpec typeOfTab:i).
       
    65     ]
       
    66 ! !
       
    67 
       
    68 !TabSpecRuler methodsFor:'initialization'!
       
    69 
       
    70 initStyle
       
    71     super initStyle.
       
    72 
       
    73     handleStyle := DefaultHandleStyle
       
    74 
       
    75 
       
    76 !
       
    77 
       
    78 initialize
       
    79     super initialize.
       
    80 
       
    81     self height:(font height + (2 * font descent)). 
       
    82 
       
    83     "
       
    84      TabSpecRuler new open
       
    85     "
       
    86 
       
    87 
       
    88 !
       
    89 
       
    90 initEvents
       
    91     super initEvents.
       
    92     self enableButtonEvents.
       
    93     self enableMotionEvents.
       
    94 
       
    95 
       
    96 ! !
       
    97 
       
    98 !TabSpecRuler methodsFor:'accessing'!
       
    99 
       
   100 tabulatorSpecification:aTabSpec
       
   101     tabSpec := aTabSpec
       
   102 ! !
       
   103