home *** CD-ROM | disk | FTP | other *** search
- " objects to hold various state dependant event handling.
- *
- * eventHandler.self,v 1.3 1993/07/22 00:15:16 richards Exp
- *
- * eventHandler.self,v
- # Revision 1.3 1993/07/22 00:15:16 richards
- # Moved back to having event handlers per operation.
- # eventHandler/buttons now support substitution.
- # poly.self has primitive substitution handler, except that it has
- # no concept of context.
- #
- # Revision 1.2 1993/07/18 20:22:29 richards
- # Added substitution of polynomials (not quite working properly yet).
- # Some tests for this added to test4.
- # Buttons work, selections work, and eventHandling is coming along.
- #
- # Revision 1.1 1993/07/14 21:42:08 richards
- # Moved event handling out of the equationView and into a seperate set of object.
- # Equation selecting works!
- #
- *
- *
- **************************
- ***** STATE ****
- **************************
- "
-
- " :=(ADDSLOTS)=: "
- aa _AddSlotsIfAbsent: (| editor = () |).
-
- aa editor _AddSlotsIfAbsent: (|
- ^ prototypes* = ().
- ^ oddballs* = ().
- ^ traits = ().
- ^ mixins = ().
- |)
-
- " :=(TRAITS DEFINITIONS)=:aa editor"
- aa editor traits _AddSlotsIfAbsent: (|
- genericEventHandler = ().
- selectionEventHandler = ().
- areaSelectionHandler = ().
- substitutionSelectionEventHandler = ().
- substituteeSelectionEventHandler = ().
- |)
-
- aa editor prototypes _AddSlotsIfAbsent: (|
- genericEventHandler = ().
- selectionEventHandler = ().
- areaSelectionHandler = ().
- substitutionSelectionEventHandler = ().
- substituteeSelectionEventHandler = ().
- |)
-
- aa editor traits genericEventHandler _Define: (|
- _ parent* = traits clonable.
- ^ copy = ( clone ).
- ^ copyForView: vue = ( |c|
- c: copy.
- c vue: vue.
- c
- ).
-
- ^ selectUp: pt = (42).
- ^ selectDown: pt = (42).
- ^ copyUp: pt = (42).
- ^ copyDown: pt = (42).
- ^ menuUp: pt = (42).
- ^ menuDown: pt = (42).
- ^ motion: pt = (42).
- ^ enter: pt = (
- vue topView caption: instructionText
- ).
-
- ^ isSelectionHandler = (false).
- ^ isAreaSelectionHandler = (false).
- ^ isSubstitutionHandler = (false).
-
- instructionText = ( 'Handler: ', handlerName ).
- handlerName = ('generic').
-
- printString = ( '<eventHandler>' , handlerName).
-
- resetHandler = (
- vue topView handlerForNextWindow: aa editor selectionEventHandler.
- vue viewHandler isSelectionHandler ifFalse: [
- vue viewHandler: aa editor selectionEventHandler copyForView: vue.
- ].
- ).
- |)
-
- aa editor prototypes genericEventHandler _Define: (|
- ^ parent* = aa editor traits genericEventHandler.
- vue.
- |)
-
- aa editor traits selectionEventHandler _Define: (|
- ^ parent* = aa editor traits genericEventHandler.
- ^ copy = (|c|
- c: resend.copy.
- c
- ).
-
- instructionText = ( 'Left: selects/expands Middle: picks Right: cancel' ).
- handlerName = ('selection').
-
- ^ selectDown: pt = (
- 'equationBBox: ' print.
- vue equationBBox printLine.
- 'pt: ' print.
- pt printLine.
- (vue equationBBox includes: pt) ifTrue: [
- vue subViewDo: [| :aSv. |
- aSv unHighlight
- ].
- vue subViewDo: [| :aSv. |
- aSv selectDown: pt WithSelection: equationSelection
- ].
- ] False: [
- equationSelection becomeUnselected.
- ].
- vue redraw.
- ).
-
- ^ selectUp: pt = (
- equationSelection isValidSelection ifTrue: [
- 'Selected: ' print.
- equationSelection selectedPolynum printLine.
- ]
- ).
- ^ isSelectionHandler = (true).
-
- setupNextEventHandler = (
- 'default setupNextEventHandler' printLine.
- resetHandler.
- ).
-
- cancelEventHandler = (
- equationSelection becomeUnselected.
- resetHandler.
- ).
-
- copyUp: pt = (
- setupNextEventHandler.
- ).
-
- " Cancel "
- menuUp: pt = (
- cancelEventHandler.
- ).
-
- |)
-
- aa editor prototypes selectionEventHandler _Define: aa editor genericEventHandler
- aa editor prototypes selectionEventHandler _AddSlots: (|
- ^ parent* = aa editor traits selectionEventHandler.
- ^ equationSelection <- aa editor unselectedPortion copy.
- |)
-
- aa editor traits areaSelectionHandler _Define: (|
- ^ parent* = aa editor traits genericEventHandler.
- ^ copy = (|c|
- c: resend.copy
- c
- ).
-
- instructionText = (
- areaSelect isNil ifTrue: ['Left: first point Middle: nothing Right: cancel']
- False: ['Left: second point Middle: second point Right: cancel']
- ).
-
- ^ selectUp: pt = (
- areaSelect isNil ifTrue: [
- areaSelect: pt#pt.
- vue eventMaskAdd: (xlib events pointerMotionMask || xlib events buttonMotionMask). " XXX - don't assume that it is button 2! "
- vue drawXorRectangle: areaSelect.
- vue topView caption: instructionText
- ] False: [ copyUp: pt ].
- ).
-
- ^ menuUp: pt = (
- areaSelect: nil.
- vue eventMaskRemove: (xlib events pointerMotionMask || xlib events buttonMotionMask || xlib events button2MotionMask). " XXX -- see above "
- vue topView caption: instructionText.
- ).
-
- ^ motionNotify: event = (
- vue drawXorRectangle: areaSelect. "Undraw rubber band"
- areaSelect: (areaSelect origin)#(event x@event y).
- vue drawXorRectangle: areaSelect.
- ).
-
- ^ copyUp: pt = (
- vue eventMaskRemove: (xlib events pointerMotionMask || xlib events buttonMotionMask || xlib events button2MotionMask). " XXX -- see above "
- vue drawXorRectangle: areaSelect.
- areaSelect: (areaSelect origin)#pt.
- equationSelection becomeUnselected.
- vue subViewDo: [| :aSv |
- (aSv area intersects: areaSelect) ifTrue: [
- aSv highlight.
- ].
- ].
- " now find a common ancestor! "
- " then redraw "
- vue redraw.
- ).
-
- ^ isAreaSelectionHandler = (true).
- |)
-
-
- aa editor prototypes areaSelectionHandler _Define: aa editor genericEventHandler.
- aa editor prototypes areaSelectionHandler _AddSlots: (|
- ^ parent* = aa editor traits areaSelectionHandler.
- ^ equationSelection <- aa editor unselectedPortion copy.
- areaSelect.
- |)
-
- " This event handler is a specialization of the selection handler. "
- " After the selection is ratified, the selection is unselected, recorded "
- " and then that window, and the one entered get a new selection handler "
-
- aa editor traits substitutionSelectionEventHandler _Define: (|
- _ parent* = aa editor traits selectionEventHandler.
-
- ^ copy = (| c. |
- c: resend.copy.
- c
- ).
-
- instructionText = ( 'Left: selects/expands Middle: picks Right: cancel' ).
- handlerName = ('substitutionSelection').
- isSubstitutionHandler = (true).
-
- copyUp: pt = (| nh. |
- equationSelection isValidSelection ifTrue: [
- nh: aa editor substituteeSelectionEventHandler copy.
- nh substitutor: equationSelection selectedPolynum.
- vue topView handlerForNextWindow: nh.
- vue viewHandler: nh.
- equationSelection becomeUnselected.
- ] False: [
- vue topView userError: 'You must select something before picking it.'
- ].
- ).
-
- |)
-
- aa editor prototypes substitutionSelectionEventHandler _Define: aa editor selectionEventHandler.
- aa editor prototypes substitutionSelectionEventHandler _AddSlots: (|
- _ parent* = aa editor traits substitutionSelectionEventHandler.
- |)
-
- aa editor traits substituteeSelectionEventHandler _Define: (|
- _ parent* = aa editor traits selectionEventHandler.
- ^ copy = (| c. |
- c: resend.copy.
- c substitutor: substitutor copy.
- c
- ).
-
- instructionText = ( 'Left: selects/expands Middle: substitutes Right: cancel' ).
- handlerName = ('substituteeSelection').
- isSubstitutionHandler = (true).
-
- copyUp: pt = (| np. |
- equationSelection isValidSelection ifTrue: [
- 'substituting on: ' print. vue equation printLine.
- 'substituting for: ' print. equationSelection selectedPolynum printLine.
- 'substituting: ' print. substitutor printLine.
- np: ((vue equation) substitute: substitutor For: equationSelection selectedPolynum).
- 'resulting in: ' print. np printLine.
- vue equation: np.
- resetHandler.
- vue redraw.
- ] False: [
- vue topView userError: 'You must pick what to substitute into.'
- ].
- ).
- |)
-
- aa editor prototypes substituteeSelectionEventHandler _Define: aa editor selectionEventHandler
- aa editor prototypes substituteeSelectionEventHandler _AddSlots: (|
- _ parent* = aa editor traits substituteeSelectionEventHandler.
- substitutor. " place to record what is going to be inserted "
- |)
-
-