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