90
|
1 |
'From Smalltalk/X, Version:2.10.7 on 24-aug-1995 at 8:28:49' !
|
|
2 |
|
|
3 |
ValueHolder subclass:#ConvertedValue
|
|
4 |
instanceVariableNames:'conversion'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Interface-Support-Channels'
|
|
8 |
!
|
|
9 |
|
|
10 |
!ConvertedValue class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
version
|
|
13 |
"
|
96
|
14 |
$Header: /cvs/stx/stx/libview2/ConvertedValue.st,v 1.2 1995-08-29 17:43:25 claus Exp $
|
90
|
15 |
"
|
|
16 |
!
|
|
17 |
|
|
18 |
documentation
|
|
19 |
"
|
|
20 |
a ConvertedValue translates changes on input via a conversion block
|
|
21 |
to the output. For example, if you want to have a toggle to change the
|
|
22 |
color inputs of some other labels, use a convertedValue which translates
|
|
23 |
true/false into colors:
|
|
24 |
|
|
25 |
|toggle label converter|
|
|
26 |
|
|
27 |
converter := ConvertedValue new
|
|
28 |
conversion:[:input | input == true
|
|
29 |
ifTrue:[Color red]
|
|
30 |
ifFalse:[Color blue]];
|
|
31 |
value:false.
|
|
32 |
|
|
33 |
|
|
34 |
toggle := Toggle label:'change color'.
|
|
35 |
toggle controller pressChannel:converter.
|
|
36 |
|
|
37 |
label := Label label:'see me changing'.
|
|
38 |
label foregroundChannel:converter.
|
|
39 |
|
|
40 |
toggle open.
|
|
41 |
label open.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
examples
|
|
46 |
"
|
|
47 |
examples to be added.
|
|
48 |
"
|
|
49 |
! !
|
|
50 |
|
|
51 |
!ConvertedValue methodsFor:'accessing'!
|
|
52 |
|
|
53 |
conversion:aBlock
|
|
54 |
conversion := aBlock
|
|
55 |
!
|
|
56 |
|
|
57 |
initialValue:someValue
|
|
58 |
self value:someValue
|
|
59 |
!
|
|
60 |
|
|
61 |
value:input
|
|
62 |
^ super value:(conversion value:input)
|
|
63 |
! !
|