;; -*-Mode: Scheme;-*- ;; ;; Copyright (C) 1995, 1996 Josh MacDonald ;; ;; Permission to use, copy, and/or distribute this software and its ;; documentation for any purpose and without fee is hereby granted, provided ;; that both the above copyright notice and this permission notice appear in ;; all copies and derived works. Fees for distribution or use of this ;; software or derived works may only be charged with express written ;; permission of the copyright holder. ;; This software is provided ``as is'' without express or implied warranty. ;; ;; $Id: view-toplev.stk,v 1.1 2003/12/19 22:57:30 willchu Exp $ ;; $ProjectHeader: stk ucb2.29 Thu, 11 Sep 2003 14:07:59 -0700 hilfingr $ ;; (require "placement") (require "Button") (unless (and (provided? "view-toplev") (not *debug*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; TOPLEVEL WIDGET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define PLACEMENT_INITIAL_POSITION (make-point 1000 1000)) (define VIEW_CANVAS_SIZE '(5000 5000)) (define VIEW_CANVAS_SIZE_X (car VIEW_CANVAS_SIZE)) (define VIEW_CANVAS_SIZE_Y (cadr VIEW_CANVAS_SIZE)) (define VIEW_PLACE_NEAR '(1000 1000 1100 1500)) (define VIEW_WINDOW_MINSIZE '(400 300)) (define VIEW_WINDOW_MAXSIZE '(1200 900)) (define CANVAS_X_SCROLLINC 0) (define CANVAS_Y_SCROLLINC 0) (define VIEW_BITMAP (format #f "@~a/icons/view" *EnvDraw-library*)) (define FOCUS_MENUENTRY_INDEX 2) (define (describe-envdraw) (require "dialog") (STk::make-dialog :window '.describeenv :title "About EnvDraw" :text "EnvDraw is a tool for constructing environment and box-and-pointer diagrams with the STk interpreter. EnvDraw was written by Josh MacDonald . Please report bugs and/or comments by email." :grab #f :default 0 :buttons (list (list "Dismiss" (lambda () '())) (list " Help " envdraw-help)))) (define (envdraw-help) (STk:show-help-file "envdraw.html")) (define (update-object-label t obj) (slot-set! (object-label-of t) 'text (safely-format obj))) (define (bind-for-entrance self tl obj) (bind self "" (lambda () (update-object-label tl obj)))) (define (toggle-focus tl) (if (eq? *view-root* tl) (begin (unfocus-toplevel *view-root*) (set! *view-root* #t)) (begin (if (view-toplevel? *view-root*) (unfocus-toplevel *view-root*)) (focus-toplevel tl) (set! *view-root* tl)))) (define (focus-toplevel tl) (slot-set! (object-label-of tl) 'background FOCUSED_COLOR) (menu-entry-configure (menu-of tl) FOCUS_MENUENTRY_INDEX :label "Focus")) (define (unfocus-toplevel tl) (slot-set! (object-label-of *view-root*) 'background UNFOCUSED_COLOR) (menu-entry-configure (menu-of tl) FOCUS_MENUENTRY_INDEX :label "Unfocus")) (define-class () ((clean :initform #t :getter cleanflag-of :setter set-cleanflag!))) (define-class () ((canv :getter canvas-of) (menu :getter menu-of) (obj-label :getter object-label-of) (xscrollbar :getter xscrollbar-of) (yscrollbar :getter yscrollbar-of) (startx :getter scroll-startx-of) (starty :getter scroll-starty-of) (metro :getter metropolis-of :initform #f) (syms-alist :initform '() :getter syms-alist-of) (pred-alist :initform '()) (color :initform (car COLORS_LIST) :getter color-of) (table :initform (make-hash-table) :getter table-of))) (define-method initialize((self ) initargs) (next-method) (prepend! self *toplevel-views*) (slot-set! self 'title "ObjectView") (slot-set! self 'min-size VIEW_WINDOW_MINSIZE) (slot-set! self 'max-size VIEW_WINDOW_MAXSIZE) (slot-set! self 'geometry VIEW_WINDOW_INITSIZE) (let* ((frame (make :parent self :background MENU_BACKGROUND_COLOR)) (optionframe (make :parent frame :background MENU_BACKGROUND_COLOR)) (menub (make :parent optionframe :relief 'raised :text "Options" :background MENU_BACKGROUND_COLOR :active-background MENU_ABACKGROUND_COLOR :foreground MENU_FOREGROUND_COLOR)) (menu (make :parent menub :activebackground MENU_ABACKGROUND_COLOR :foreground MENU_FOREGROUND_COLOR :background MENU_BACKGROUND_COLOR)) (cmenu (make :parent menu :activebackground MENU_ABACKGROUND_COLOR :foreground MENU_FOREGROUND_COLOR :background MENU_BACKGROUND_COLOR)) (label (make