1999-02-02 06:13:40 -05:00
|
|
|
|
;;;; butbar.stk -- Button bar management
|
|
|
|
|
;;;;
|
|
|
|
|
;;;; Copyright <20> 1998-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
|
|
|
|
|
;;;;
|
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.
|
1999-02-02 06:13:40 -05:00
|
|
|
|
;;;;
|
|
|
|
|
;;;; Author: Erick Gallesio [eg@unice.fr]
|
|
|
|
|
;;;; Creation date: 8-Dec-1998 18:58
|
1999-09-05 07:16:41 -04:00
|
|
|
|
;;;; Last file update: 3-Sep-1999 19:49 (eg)
|
1999-02-02 06:13:40 -05:00
|
|
|
|
|
|
|
|
|
(require "balloon")
|
|
|
|
|
|
|
|
|
|
(select-module Tk)
|
|
|
|
|
(export make-bordered-frame make-button-bar)
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Button-bar default bindings
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(bind "ButtonBar" "<Enter>" (lambda (|W|) (tk-set! |W| :relief "raised")))
|
|
|
|
|
(bind "ButtonBar" "<Leave>" (lambda (|W|) (tk-set! |W| :relief "flat")))
|
|
|
|
|
|
|
|
|
|
;=============================================================================
|
|
|
|
|
;
|
|
|
|
|
; bordered-frame functions
|
|
|
|
|
;
|
|
|
|
|
;=============================================================================
|
|
|
|
|
|
|
|
|
|
(define (hide-bordered-frame parent)
|
|
|
|
|
(let* ((info (pack 'info parent))
|
|
|
|
|
(grand-pa (winfo 'parent parent))
|
1999-09-05 07:16:41 -04:00
|
|
|
|
(b (button (& grand-pa ".hb") :width 22 :height 5 :bd 1
|
|
|
|
|
:relief "ridge"
|
|
|
|
|
:image (make-image "tb_hborder.gif"))))
|
1999-02-02 06:13:40 -05:00
|
|
|
|
(tk-set! b :command (lambda ()
|
|
|
|
|
(pack 'unpack b)
|
|
|
|
|
(apply pack parent (cddr info))
|
|
|
|
|
(destroy b)))
|
|
|
|
|
(pack 'unpack parent)
|
|
|
|
|
(pack b :side "left")))
|
|
|
|
|
|
|
|
|
|
(define (make-bordered-frame parent)
|
|
|
|
|
(let* ((f (frame (gensym (& parent ".border") :relief "ridge" :bd 1)))
|
1999-09-05 07:16:41 -04:00
|
|
|
|
(b (button (& f ".b") :width 5 :height 22 :bd 1 :relief "ridge"
|
|
|
|
|
:image (make-image "tb_vborder.gif")
|
|
|
|
|
:command (lambda () (hide-bordered-frame f)))))
|
1999-02-02 06:13:40 -05:00
|
|
|
|
(pack b :side "left" :fill 'y)
|
|
|
|
|
(pack f :fill 'x)
|
|
|
|
|
f))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;=============================================================================
|
|
|
|
|
;
|
|
|
|
|
; make-button-bar
|
|
|
|
|
;
|
|
|
|
|
;=============================================================================
|
|
|
|
|
(define (make-button-bar parent l)
|
|
|
|
|
|
|
|
|
|
(define (make-button parent img balloon action)
|
|
|
|
|
(let* ((name (gensym (& parent ".b")))
|
|
|
|
|
(but (button name :image (make-image img) :relief "flat" :comm action)))
|
|
|
|
|
(pack but :side "left" :fill "both")
|
|
|
|
|
(add-balloon-help but balloon 1500 "#ffffb0")
|
|
|
|
|
(bindtags but (cons "ButtonBar" (bindtags but)))))
|
|
|
|
|
|
|
|
|
|
(define (make-space parent size)
|
|
|
|
|
(let ((name (gensym (& parent ".f"))))
|
|
|
|
|
(pack (frame name :width size) :side "left" :fill "both")))
|
|
|
|
|
|
|
|
|
|
;; make-button-bar starts here
|
|
|
|
|
(let ((f (make-bordered-frame parent)))
|
|
|
|
|
(for-each (lambda (x)
|
|
|
|
|
(if (integer? x)
|
|
|
|
|
(make-space f x)
|
|
|
|
|
(apply make-button f x)))
|
|
|
|
|
l)
|
|
|
|
|
f))
|
|
|
|
|
|
|
|
|
|
(provide "butbar")
|