home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xscm105.zip / xscm / olsubs.scm < prev    next >
Text File  |  1992-08-29  |  3KB  |  102 lines

  1. ; $Header: /home/campbell/Languages/Scheme/scm/x-scm/RCS/olsubs.scm,v 1.2 1992/07/04 05:02:17 campbell Beta $
  2. ;
  3. ; Generally useful OpenLook (OLIT) functions
  4. ;
  5. ;  Author: Larry Campbell (campbell@redsox.bsw.com)
  6. ;  Copyright 1992 by The Boston Software Works, Inc.
  7. ;  Permission to use for any purpose whatsoever granted, as long
  8. ;  as this copyright notice remains intact.  Please send bug fixes
  9. ;  or enhancements to the above email address.
  10.  
  11. (require (in-vicinity (library-vicinity) "assert.scm"))
  12.  
  13. ; Create a text widget with a caption to its left.  Returns the
  14. ; text widget's ID.
  15. ;
  16. (define (make-captioned-text-widget parent label columns . args)
  17.   #.(assert '(string? label))
  18.   #.(assert '(integer? columns))
  19.   (let* ((caption
  20.       (xt:create-managed-widget
  21.        label ol:caption parent
  22.        xt:n-label label))
  23.      (text
  24.       (xt:create-managed-widget
  25.        "text" ol:text-field caption)))
  26.     text))
  27.  
  28. (define (make-button label parent action)
  29.   (let ((widget
  30.      (xt:create-managed-widget
  31.       label
  32.       ol:oblong-button
  33.       parent)))
  34.     (xt:add-callback widget xt:n-select action)
  35.     widget))
  36.  
  37. ; (make-pulldown-menu name parent (label1 action1) (label2 action2)...)
  38.  
  39. (define (make-pulldown-menu name parent . args)
  40.   (let* ((widget (xt:create-managed-widget
  41.           name
  42.           ol:menu-button
  43.           parent))
  44.      (menu-widget (xt:get-value widget "menuPane" xt:widget)))
  45.     (do ((items args (cdr items)))
  46.     ((null? items) widget)
  47.         (let* ((item (car items))
  48.                   (label (car item))
  49.            (action (cadr item)))
  50.       (make-button label menu-widget action)))))
  51.  
  52.  
  53. (define (popup-information parent message)
  54.   #.(assert '(string? message))
  55.   (let ((nshell (xt:create-popup-shell
  56.           "information" ol:notice-shell parent
  57.           xt:n-emanate-widget parent)))
  58.     (let ((ca (xt:get-value nshell xt:n-control-area xt:widget))
  59.       (ta (xt:get-value nshell xt:n-text-area xt:widget)))
  60.       (xt:set-values ta xt:n-string message)
  61.       (make-button "OK" ca (lambda _ (xt:destroy-widget nshell))))
  62.     (xt:popup nshell 1)))
  63.  
  64.  
  65. ; Create a row of evenly-spaced buttons (typically used for the
  66. ; "OK" "Apply" "Cancel" buttons at the bottom of a panel).
  67. ; Returns nothing.
  68. ; Usage:
  69. ;   (make-button-row parent '(("label 1" action1) ("label 2" action2)))
  70. ;
  71. (define (make-button-row parent button-specifiers)
  72.   #.(assert '(list? button-specifiers))
  73.   (let ((ca (xt:create-managed-widget
  74.          "ca" ol:control-area parent))
  75.     (parent-width (xt:get-value parent xt:n-width xt:integer)))
  76.     (if (=? 0 parent-width)
  77.     (error "button-row: parent has zero width"))
  78.     (do ((items button-specifiers (cdr items)))
  79.     ((null? items) ca)
  80.       (let* ((item (car items))
  81.          (label (car item))
  82.          (action (cadr item))
  83.          (button '()))
  84.     (case label
  85.       ((xm:arrow-up xm:arrow-down xm:arrow-left xm:arrow-right)
  86.        (set! button (xt:create-managed-widget
  87.              "arrow" xm:arrow-button-gadget ca
  88.              xm:n-arrow-direction
  89.              (case label
  90.                  ((xm:arrow-down) xm:arrow-down)
  91.                  ((xm:arrow-up) xm:arrow-up)
  92.                  ((xm:arrow-left) xm:arrow-left)
  93.                  ((xm:arrow-right) xm:arrow-right))
  94.              xm:n-traversal-on #f)))
  95.       (else
  96.        (set! button (xt:create-managed-widget
  97.              label ol:oblong-button-gadget ca))))
  98.     (xt:add-callback button xt:n-select action)))))
  99.  
  100.