stk/Demos/stklos-demo2.stklos

65 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

1999-09-27 07:20:21 -04:00
#!/bin/sh
:;exec /usr/local/bin/stk -f "$0" "$@"
1996-09-27 06:29:02 -04:00
;;;;
;;;; s t k l o s - d e m o 2 . s t k -- A demo which use some STklos classes
;;;;
1999-02-02 06:13:40 -05:00
;;;; Copyright <20> 1993-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
1996-09-27 06:29:02 -04:00
;;;;
1999-09-05 07:16:41 -04:00
;;;; Permission to use, copy, modify, distribute,and license this
;;;; software and its documentation for any purpose is hereby granted,
;;;; provided that existing copyright notices are retained in all
;;;; copies and that this notice is included verbatim in any
;;;; distributions. No written agreement, license, or royalty fee is
;;;; required for any of the authorized uses.
;;;; This software is provided ``AS IS'' without express or implied
;;;; warranty.
1996-09-27 06:29:02 -04:00
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 24-Aug-1993 19:55
1999-09-27 07:20:21 -04:00
;;;; Last file update: 13-Sep-1999 18:03 (eg)
1996-09-27 06:29:02 -04:00
(require "Tk-classes")
1998-04-10 06:59:06 -04:00
;;;; Make canvas
(define f (make <Frame>))
(define l (make <Label> :parent f :text "A simple demo written in STklos"))
(define c (make <Canvas> :parent f :relief "groove" :height 400 :width 700))
1999-02-02 06:13:40 -05:00
(define m (make <Label> :parent f :font '(Courier -12) :justify 'left
1998-04-10 06:59:06 -04:00
:text "This demo file illustrates the use of bind-for-dragging with various parameters:
- Left button to drag any kind of object.
- Left button with Shift key pressed to drag an object and executes user hooks
- Right button to move red objects only."))
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
(define q (make <Button> :text "Quit" :command (lambda () (exit 0))))
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
(pack l c m q :in f :expand #t :fill 'both)
(pack f)
1996-09-27 06:29:02 -04:00
1998-04-10 06:59:06 -04:00
;;;; Make items
1996-09-27 06:29:02 -04:00
(define r1 (make <rectangle> :coords '(0 0 50 50)
:parent c
:fill "red"
:tags "red"))
(define r2 (make <rectangle> :coords '(100 100 150 150)
:parent c
:fill "blue"))
(define t (make <Text-Item> :coords '(80 80)
:parent c
:fill "red"
:tags "red"
:text "Hello world!"))
;; Button 1 for dragging objects
(bind-for-dragging c)
;; Button 1 for dragging objects (with user hooks)
(bind-for-dragging c :tag 'all
:modifier "Shift"
:start (lambda (w x y) (format #t "Start to drag ~S\n" w))
:motion (lambda (w x y) (format #t "Move ~A ~A\n" x y))
:stop (lambda (w x y) (format #t "Stop with ~S\n" w)))
;; Button 3 for dragging red objects (i.e. r1 and t)
(bind-for-dragging c :tag "red" :button 3)