--- a/Controller.st Wed Jul 23 12:58:22 2008 +0200
+++ b/Controller.st Wed Jul 23 13:58:24 2008 +0200
@@ -37,19 +37,19 @@
documentation
"
Controllers can be used to controll the user-interactions
- to a model which is shown in a view.
+ to a model which is shown in a view.
For very simple views (and due to the evolution of Smalltalk/X),
many view-classes have the controller function integrated.
To allow both controller and non-controller operation, events are
sent directly to the view, if the view has no controller
- (i.e. if its controller instance variable is nil).
+ (i.e. if its controller instance variable is nil).
Otherwise, the controller gets the event message.
For now (vsn 2.10.4) there are only a few view classes using controllers;
however, over time, more will be converted, since separating the controller
- offers much more flexibility
+ offers much more flexibility
(although view initialization becomes a bit more complex).
Over time, expect the buttonPress/Release/Motion and keyPress/Release
@@ -58,29 +58,29 @@
This migration should be backward compatible.
Device coordinates vs. Logical coordinates:
- if the view has a non-identity transformation (for example: drawing
- in millimeters or inches), the application/controller may or may not
- be interested in device coordinates in button/key events.
- Most are not, these will receive logical coordinates transparently
- in theyr button/key-Press/Release/Motion methods.
- Those which are interested should redefine the corresponding
- device-Key/Button-Press/Release/Motion methods.
- Of course, it is always possible to map between device and logical
- coordinates, using `view transformation applyTo/applyInverseTo:',
- if both coordinates are required (which is unlikely).
+ if the view has a non-identity transformation (for example: drawing
+ in millimeters or inches), the application/controller may or may not
+ be interested in device coordinates in button/key events.
+ Most are not, these will receive logical coordinates transparently
+ in theyr button/key-Press/Release/Motion methods.
+ Those which are interested should redefine the corresponding
+ device-Key/Button-Press/Release/Motion methods.
+ Of course, it is always possible to map between device and logical
+ coordinates, using `view transformation applyTo/applyInverseTo:',
+ if both coordinates are required (which is unlikely).
[Instance variables:]
- view <View> the view I control
+ view <View> the view I control
- model <Model> the model which is to be worked on
+ model <Model> the model which is to be worked on
[author:]
- Claus Gittinger
+ Claus Gittinger
[see also:]
- View Model WindowGroup
- WindowEvent DeviceWorkstation
+ View Model WindowGroup
+ WindowEvent DeviceWorkstation
"
! !
@@ -132,52 +132,52 @@
ST/X style static menus - going to be obsoleted ...
"
(menu := view middleButtonMenu) notNil ifTrue:[
- menu showAtPointer.
- ^ self
+ menu showAtPointer.
+ ^ self
].
menu := self yellowButtonMenu.
menu notNil ifTrue:[
- menuPerformer := self menuPerformer.
+ menuPerformer := self menuPerformer.
- "
- a temporary kludge:
- pass myself as receiver, the menuPerformer as performer;
- the menu will send its messages to either the
- menuPerformer or me (its receiver).
- This allows for the ST-80 behavior, where some messages
- go to the model, others to the view
- (copy/cut/paste).
- "
- (prevReceiver := menu receiver) isNil ifTrue:[
+ "
+ a temporary kludge:
+ pass myself as receiver, the menuPerformer as performer;
+ the menu will send its messages to either the
+ menuPerformer or me (its receiver).
+ This allows for the ST-80 behavior, where some messages
+ go to the model, others to the view
+ (copy/cut/paste).
+ "
+ (prevReceiver := menu receiver) isNil ifTrue:[
"/ menu receiver:menuPerformer.
- menu menuPerformer:menuPerformer.
- menu receiver:self.
- ].
+ menu menuPerformer:menuPerformer.
+ menu receiver:self.
+ ].
- "
- Launch the menu. It is supposed
- to return an actionSelector.
- "
- actionSelector := view startUpMenu:menu.
+ "
+ Launch the menu. It is supposed
+ to return an actionSelector.
+ "
+ actionSelector := view startUpMenu:menu.
- actionSelector notNil notNil ifTrue:[
- actionSelector isSymbol ifTrue:[
- menuPerformer perform:actionSelector
- ] ifFalse:[
- (actionSelector isArray
- and:[actionSelector size == 2
- and:[(actionSelector at:1) isSymbol]]) ifTrue:[
- menuPerformer
- perform:(actionSelector at:1)
- with:(actionSelector at:2)
- ]
- ]
- ].
+ actionSelector notNil notNil ifTrue:[
+ actionSelector isSymbol ifTrue:[
+ menuPerformer perform:actionSelector
+ ] ifFalse:[
+ (actionSelector isArray
+ and:[actionSelector size == 2
+ and:[(actionSelector at:1) isSymbol]]) ifTrue:[
+ menuPerformer
+ perform:(actionSelector at:1)
+ with:(actionSelector at:2)
+ ]
+ ]
+ ].
- menu receiver:prevReceiver.
+ menu receiver:prevReceiver.
- ^ self
+ ^ self
].
"Modified: 21.1.1997 / 15:45:48 / cg"
@@ -185,18 +185,18 @@
!Controller methodsFor:'accessing'!
-menuHolder
+menuHolder
"by default, the model has to provide the menu"
model isNil ifTrue:[
- ^ view menuHolder
+ ^ view menuHolder
].
^ model
"Modified: 22.8.1996 / 09:11:43 / cg"
!
-menuPerformer
+menuPerformer
"by default, the model is performing menu actions"
model isNil ifTrue:[^ view].
@@ -217,7 +217,7 @@
"Modified: 28.2.1997 / 19:52:50 / cg"
!
-sensor
+sensor
"return my views sensor"
^ view sensor
@@ -276,12 +276,12 @@
deviceButtonMotion:state x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a buttonMotion with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #buttonMotion:x:y:"
@@ -290,8 +290,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self buttonMotion:state x:lx y:ly
@@ -301,12 +301,12 @@
deviceButtonMultiPress:button x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a buttonMultiPress with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #buttonMultiPress:x:y:"
@@ -315,8 +315,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self buttonMultiPress:button x:lx y:ly
@@ -326,12 +326,12 @@
deviceButtonPress:button x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a buttonPress with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #buttonPress:x:y:"
@@ -340,8 +340,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self buttonPress:button x:lx y:ly
@@ -351,12 +351,12 @@
deviceButtonRelease:button x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a buttonRelease with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #buttonRelease:x:y:"
@@ -365,8 +365,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self buttonRelease:button x:lx y:ly
@@ -376,12 +376,12 @@
deviceKeyPress:key x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a keyPress with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #keyPress:x:y:"
@@ -390,8 +390,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self keyPress:key x:lx y:ly
@@ -401,12 +401,12 @@
deviceKeyRelease:key x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a keyRelease with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #keyRelease:x:y:"
@@ -415,8 +415,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self keyRelease:key x:lx y:ly
@@ -426,12 +426,12 @@
devicePointerEnter:state x:x y:y
"this is the low-level (untransformed) event as received
- from the device (i.e. coordinates are in device coordinates).
+ from the device (i.e. coordinates are in device coordinates).
If there is a transformation, apply the inverse
and send a pointerEnter with the logical coordinates.
Controllers which are interested in deviceCoordinates should
- redefine this method -
+ redefine this method -
those which are interested in logical coordinates
should redefine #pointerEnter:x:y:"
@@ -440,8 +440,8 @@
lx := x.
ly := y.
(trans := view transformation) notNil ifTrue:[
- lx := trans applyInverseToX:lx.
- ly := trans applyInverseToY:ly.
+ lx := trans applyInverseToX:lx.
+ ly := trans applyInverseToY:ly.
].
self pointerEnter:state x:lx y:ly
@@ -471,23 +471,23 @@
windowGroup := view windowGroup.
windowGroup notNil ifTrue:[
- action := key.
- key == #Tab ifTrue:[
- (view tabRequiresControl not
- or:[ view sensor ctrlDown ]) ifTrue:[
- view graphicsDevice shiftDown ifTrue:[
- action := #FocusPrevious.
- ] ifFalse:[
- action := #FocusNext.
- ]
- ]
- ].
- action == #FocusNext ifTrue:[
- windowGroup focusNext.
- ].
- action == #FocusPrevious ifTrue:[
- windowGroup focusPrevious.
- ].
+ action := key.
+ key == #Tab ifTrue:[
+ (view tabRequiresControl not
+ or:[ view sensor ctrlDown ]) ifTrue:[
+ view graphicsDevice shiftDown ifTrue:[
+ action := #FocusPrevious.
+ ] ifFalse:[
+ action := #FocusNext.
+ ]
+ ]
+ ].
+ action == #FocusNext ifTrue:[
+ windowGroup focusNext.
+ ].
+ action == #FocusPrevious ifTrue:[
+ windowGroup focusPrevious.
+ ].
].
^ self
@@ -540,7 +540,7 @@
"Modified: 11.6.1997 / 13:18:09 / cg"
!
-startUp
+startUp
"startup the controller; this is sent when the view realizes,
right before it becomes visible.
Can be redefined in subclasses to do some startup action."
@@ -556,14 +556,6 @@
|sym menuHolder m|
-"/ (m := view middleButtonMenu) notNil ifTrue:[
-"/ "/
-"/ "/ has been assigned a static middleButtonMenu
-"/ "/ (or a cached menu)
-"/ "/
-"/ ^ m
-"/ ].
-
menuHolder := self menuHolder.
"
@@ -571,15 +563,15 @@
if there is a model, and a menuMessage is defined,
ask model for the menu and launch that if non-nil.
"
- (menuHolder notNil
+ (menuHolder notNil
and:[(sym := view menuMessage) notNil
and:[sym isSymbol]]) ifTrue:[
- "
- ask menuHolder (model) for the menu
- "
- (menuHolder respondsTo:sym) ifTrue:[
- ^ menuHolder perform:sym.
- ]
+ "
+ ask menuHolder (model) for the menu
+ "
+ (menuHolder respondsTo:sym) ifTrue:[
+ ^ menuHolder perform:sym.
+ ]
].
^ nil
@@ -589,5 +581,5 @@
!Controller class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Controller.st,v 1.55 2008-01-11 19:24:32 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Controller.st,v 1.56 2008-07-23 11:58:24 cg Exp $'
! !