--- a/PluggableAdaptor.st Sat Apr 27 19:56:35 1996 +0200
+++ b/PluggableAdaptor.st Sat Apr 27 19:59:26 1996 +0200
@@ -43,6 +43,13 @@
overhead and complexity.
Therefore, in many situations, an AspectAdaptor is the better choice.
+ Notice:
+ this class was implemented using protocol information
+ from alpha testers - it may not be complete or compatible to
+ the corresponding ST-80 class.
+ If you encounter any incompatibilities, please forward a note
+ describing the incompatibility verbal (i.e. no code) to the ST/X team.
+
[author:]
Claus Gittinger
"
@@ -51,141 +58,143 @@
examples
"
an adaptor for the variable x:
-
- |m x t|
+ [exBegin]
+ |m x t|
- m := (PluggableAdaptor new)
- getBlock:[:m | x]
- putBlock:[:m :newValue | x := newValue. Transcript showCr:x]
- updateBlock:[:m :aspect :param | Transcript showCr:'changed'].
- t := Toggle new.
- t model:m.
- t label:'toggle me'.
- t open.
-
+ m := (PluggableAdaptor new)
+ getBlock:[:m | x]
+ putBlock:[:m :newValue | x := newValue. Transcript showCr:x]
+ updateBlock:[:m :aspect :param | Transcript showCr:'changed'].
+ t := Toggle new.
+ t model:m.
+ t label:'toggle me'.
+ t open.
+ [exEnd]
an adaptor to send #destroy:
-
- |m t|
+ [exBegin]
+ |m t|
- m := (PluggableAdaptor new)
- getBlock:[:m | false]
- putBlock:[:m :newValue | t destroy]
- updateBlock:[:m :aspect :param | ].
- t := Button new.
- t model:m.
- t label:'close me'.
- t open.
-
+ m := (PluggableAdaptor new)
+ getBlock:[:m | false]
+ putBlock:[:m :newValue | t destroy]
+ updateBlock:[:m :aspect :param | ].
+ t := Button new.
+ t model:m.
+ t label:'close me'.
+ t open.
+ [exEnd]
as above, more convenient setup:
+ [exBegin]
+ |m t|
- |m t|
-
- t := Button new.
+ t := Button new.
- m := (PluggableAdaptor on:t) performAction:#destroy.
- t model:m.
- t label:'close me'.
- t open.
-
+ m := (PluggableAdaptor on:t) performAction:#destroy.
+ t model:m.
+ t label:'close me'.
+ t open.
+ [exEnd]
extract values from a complex model:
-
- |model dialog name pId|
+ [exBegin]
+ |model dialog name pId|
- model := Plug new.
- model respondTo:#name with:[name].
- model respondTo:#name: with:[:newValue | name := newValue].
- model respondTo:#passportId with:[pId].
- model respondTo:#passportId: with:[:newValue | pId := newValue].
- name := 'John Smith'.
- pId := 56785432.
+ model := Plug new.
+ model respondTo:#name with:[name].
+ model respondTo:#name: with:[:newValue | name := newValue].
+ model respondTo:#passportId with:[pId].
+ model respondTo:#passportId: with:[:newValue | pId := newValue].
+ name := 'John Smith'.
+ pId := 56785432.
- dialog := Dialog new.
+ dialog := Dialog new.
+
+ dialog addInputFieldOn:((PluggableAdaptor on:model)
+ getBlock:[:m | m name]
+ putBlock:[:m :v | m name:v]
+ updateBlock:[:m :a :p | false]).
- dialog addInputFieldOn:((PluggableAdaptor on:model)
- getBlock:[:m | m name]
- putBlock:[:m :v | m name:v]
- updateBlock:[:m :a :p | false]).
-
- dialog addVerticalSpace.
+ dialog addVerticalSpace.
- dialog addInputFieldOn:((PluggableAdaptor on:model)
- getBlock:[:m | m passportId printString]
- putBlock:[:m :v | m passportId:v asNumber]
- updateBlock:[:m :a :p | false]).
- dialog addAbortButton; addOkButton.
- dialog width:200; sizeFixed:true.
- dialog open.
+ dialog addInputFieldOn:((PluggableAdaptor on:model)
+ getBlock:[:m | m passportId printString]
+ putBlock:[:m :v | m passportId:v asNumber]
+ updateBlock:[:m :a :p | false]).
+ dialog addAbortButton; addOkButton.
+ dialog width:200; sizeFixed:true.
+ dialog open.
- dialog accept value ifTrue:[
- Transcript showCr:'accepted.'.
- ].
- Transcript showCr:' Name: ' , model name.
- Transcript showCr:' ID : ' , model passportId printString.
-
+ dialog accept value ifTrue:[
+ Transcript showCr:'accepted.'.
+ ].
+ Transcript showCr:' Name: ' , model name.
+ Transcript showCr:' ID : ' , model passportId printString.
+ [exEnd]
+
extract values from a point into different labels:
-
- |p t l|
+ [exBegin]
+ |p t l|
- p := 10 @ 20.
+ p := 10 @ 20.
- t := HorizontalPanelView new.
- t extent:200@50.
- t horizontalLayout:#fitSpace.
+ t := HorizontalPanelView new.
+ t extent:200@50.
+ t horizontalLayout:#fitSpace.
- l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#x putSelector:#x:);
- labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
- l := Label in:t.
- l model:((PluggableAdaptor on:p) getSelector:#y putSelector:#y:);
- labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
- t open.
+ l := Label in:t.
+ l model:((PluggableAdaptor on:p) getSelector:#x putSelector:#x:);
+ labelMessage:#value; aspect:#value;
+ level:-1;
+ sizeFixed:true.
+ l := Label in:t.
+ l model:((PluggableAdaptor on:p) getSelector:#y putSelector:#y:);
+ labelMessage:#value; aspect:#value;
+ level:-1;
+ sizeFixed:true.
+ t open.
- (Delay forSeconds:5) wait.
- p x:100.
- p changed.
-
+ (Delay forSeconds:5) wait.
+ p x:100.
+ p changed.
+ [exEnd]
extract values from an array into different labels:
-
- |a t l|
+ [exBegin]
+ |a t l|
- a := #('one' 'two' 'three').
+ a := #('one' 'two' 'three').
- t := HorizontalPanelView new.
- t extent:200@50.
- t horizontalLayout:#fitSpace.
+ t := HorizontalPanelView new.
+ t extent:200@50.
+ t horizontalLayout:#fitSpace.
- l := Label in:t.
- l model:((PluggableAdaptor on:a) collectionIndex:1);
- labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
- l := Label in:t.
- l model:((PluggableAdaptor on:a) collectionIndex:2);
- labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
- l := Label in:t.
- l model:((PluggableAdaptor on:a) collectionIndex:3);
- labelMessage:#value; aspect:#value;
- level:-1;
- sizeFixed:true.
- t open.
+ l := Label in:t.
+ l model:((PluggableAdaptor on:a) collectionIndex:1);
+ labelMessage:#value; aspect:#value;
+ level:-1;
+ sizeFixed:true.
+ l := Label in:t.
+ l model:((PluggableAdaptor on:a) collectionIndex:2);
+ labelMessage:#value; aspect:#value;
+ level:-1;
+ sizeFixed:true.
+ l := Label in:t.
+ l model:((PluggableAdaptor on:a) collectionIndex:3);
+ labelMessage:#value; aspect:#value;
+ level:-1;
+ sizeFixed:true.
+ t open.
- (Delay forSeconds:5) wait.
- a at:1 put:'1'.
- a changed.
+ (Delay forSeconds:5) wait.
+ a at:1 put:'1'.
+ a changed.
+ [exEnd]
"
! !
@@ -301,5 +310,5 @@
!PluggableAdaptor class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.10 1996-04-25 16:43:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.11 1996-04-27 17:59:14 cg Exp $'
! !