rbd-scheme-driver
List of: Scheme Data Types
Subjects: Rubberbanding
Contents: Scheme Support

Description: An rbd-scheme-driver is a scheme-object that holds a rubberband driver. In addition to the driver, it holds the mouse hooks that attach Scheme mouse procedures to the drivers. Rubberbanding hooks are saved as part of the rubberband_scheme class as a vector of procedures. Rubberband_scheme also keeps a vector of arbitrary scheme-objects, which the driver can use to keep any local data.

Derivation: rbd-scheme-driver : scheme-object

C++ Type: rubberband_scheme

External Rep: #[rbd-scheme-driver %x]

where the hex value is the pointer to the object.

Example: ; rbd-scheme-driver (data type)

; Create a scheme rubberband driver and

; make it active.

; Create a vector to hold 7 elements

(define the_rb_hooks (make-vector 7))

;; the_rb_hooks

; Called once when the driver is activated.

; Can be used to set globals or the elements

; in the locals vector.

(define the_init_hook (lambda (self)


(display "rubberband driver: INIT.\n")))

;; the_init_hook


; Called when driver activated and when mouse enters

; a window.

(define the_start_hook (lambda (self pick_event)


(display "rubberband driver: START.\n")


(rbd:scheme-set-local self 0



(pick:position pick_event))


(rbd:scheme-get-position self pick_event)))

;; the_start_hook

; Called when the mouse moves within a window.

(define the_update_hook (lambda (self pick-event)


(display "rubberband driver: UPDATE.\n")


(rbd:scheme-set-local self 1



(pick:position pick-event))))

;; the_update_hook


; Called when mouse leaves window and when driver is

; deactivated.

(define the_stop_hook (lambda (self)


(display "rubberband driver: STOP.\n")))

;; the_stop_hook


; Called when view receives repaint event.

(define the_repaint_hook (lambda (self view)


(display "rubberband driver: REPAINT.\n")))

;; the_repaint_hook


; May be called by other hooks to map a pick-event to

; a position.

(define the_position_hook (lambda (self pick-event)


(display "rubberband driver: POSITION.\n")


(display "position not changed\n")))

;; the_position_hook


; Called once when the driver is deactivated.

(define the_end_hook (lambda (self)


(display "rubberband driver: END.\n")))

;; the_end_hook

(vector-set! the_rb_hooks 0 the_init_hook)

(vector-set! the_rb_hooks 1 the_start_hook)

(vector-set! the_rb_hooks 2 the_update_hook)

(vector-set! the_rb_hooks 3 the_stop_hook)

(vector-set! the_rb_hooks 4 the_repaint_hook)

(vector-set! the_rb_hooks 5 the_position_hook)

(vector-set! the_rb_hooks 6 the_end_hook)

;; ()




; Non-scheme rbd drivers can use the global variable

; 'rb-position-hook', whereas, Scheme rbd drivers use

; either that or 'the_position_hook'


; ----------------------------------

; start rubberbanding

; ----------------------------------

; Create and initialize some local variables

(define the_locals (make-vector 2))

(vector-set! the_locals 0 (position 0 0 0))

(vector-set! the_locals 1 (position 0 0 0))

;; ()


; Create the Scheme rubberband driver

(define the_scm_rbd


(rbd:scheme #f the_rb_hooks the_locals))

;; the_scm_rbd


the_scm_rbd

;; #[rbd-scheme-driver 4020fce0]


; Begin rubberbanding

(read-event)

;; #[pick-event 185 455 1 1075924776 0]


(rbd:push the_scm_rbd)

;; rubberband driver: INIT.

;; (#[rbd-driver 4021eb48])


(read-event)

;; rubberband driver: START.

;; rubberband driver: POSITION.

;; position not changed

;; rubberband driver: UPDATE.

;; ...

;; rubberband driver: UPDATE.

;; rubberband driver: UPDATE.

;; rubberband driver: STOP.


(rbd:pop)

;; rubberband driver: END.

;; (#[rbd-driver 4021eb48])


; display results

(display "Start Position: ")


(display (vector-ref the_locals 0))


(newline)

;; Start Position:

;; #[position 38.1656983627057 -92.3988426777293 0]


(display "Stop Position: ")


(display (vector-ref the_locals 1))


(newline)

;; Stop Position:

;; #[position 28.72230 -96.44886 -7.105e-15]
PDF/SCM/09SD.PDF
HTM/DATA/SCM/SCM/09SD/0057.HTM