a10d535e4fce0fd79e21a6f9e3913bf74046880c
[gnus] / lisp / widget.el
1 ;;; widget.el --- a library of user interface components.
2 ;;
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: help, extensions, faces, hypermedia
7 ;; Version: 1.04
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9
10 ;;; Commentary:
11 ;;
12 ;; If you want to use this code, please visit the URL above.
13 ;;
14 ;; This file only contain the code needed to define new widget types.
15 ;; Everything else is autoloaded from `widget-edit.el'.
16
17 ;;; Code:
18
19 (eval-when-compile (require 'cl))
20
21 (defmacro define-widget-keywords (&rest keys)
22   `(eval-and-compile
23      (let ((keywords (quote ,keys)))
24        (while keywords
25          (or (boundp (car keywords))
26              (set (car keywords) (car keywords)))
27          (setq keywords (cdr keywords))))))
28
29 (define-widget-keywords :case-fold :widget-doc
30   :create :convert-widget :format :value-create :offset :extra-offset
31   :tag :doc :from :to :args :value :value-from :value-to :action
32   :value-set :value-delete :match :parent :delete :menu-tag-get
33   :value-get :choice :void :menu-tag :on :off :on-type :off-type
34   :notify :entry-format :button :children :buttons :insert-before
35   :delete-at :format-handler :widget :value-pos :value-to-internal
36   :indent :size :value-to-external :validate :error :directory
37   :must-match :type-error :value-inline :inline :match-inline :greedy
38   :button-face-get :button-face :value-face :keymap :entry-from
39   :entry-to :help-echo :documentation-property :hide-front-space
40   :hide-rear-space) 
41
42 ;; These autoloads should be deleted when the file is added to Emacs.
43 (autoload 'widget-create "widget-edit")
44 (autoload 'widget-insert "widget-edit")
45
46 ;;;###autoload
47 (defun define-widget (name class doc &rest args)
48   "Define a new widget type named NAME from CLASS.
49
50 NAME and CLASS should both be symbols, CLASS should be one of the
51 existing widget types, or nil to create the widget from scratch.
52
53 After the new widget has been defined, the following two calls will
54 create identical widgets:
55
56 * (widget-create NAME)
57
58 * (apply 'widget-create CLASS ARGS)
59
60 The third argument DOC is a documentation string for the widget."
61   (put name 'widget-type (cons class args))
62   (put name 'widget-documentation doc))
63
64 ;;; The End.
65
66 (provide 'widget)
67
68 ;; widget.el ends here