stk/Lib/butbar.stk

87 lines
2.8 KiB
Plaintext

;;;; butbar.stk -- Button bar management
;;;;
;;;; Copyright © 1998-1999 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;; 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.
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 8-Dec-1998 18:58
;;;; Last file update: 3-Sep-1999 19:49 (eg)
(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))
(b (button (& grand-pa ".hb") :width 22 :height 5 :bd 1
:relief "ridge"
:image (make-image "tb_hborder.gif"))))
(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)))
(b (button (& f ".b") :width 5 :height 22 :bd 1 :relief "ridge"
:image (make-image "tb_vborder.gif")
:command (lambda () (hide-bordered-frame f)))))
(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")