0
|
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: 0.4
|
|
8
|
|
9 ;;; Commentary:
|
|
10 ;;
|
|
11 ;; The documentation for the unbundled version of this library is
|
|
12 ;; available in `custom.texi'.
|
|
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 (let ((keywords
|
|
22 '(:create :convert-widget :format :value-create :tag :doc :from :to
|
|
23 :args :value :value-from :value-to :action :value-set
|
|
24 :value-delete :match :parent :delete :menu-tag-get
|
|
25 :value-get :choice :void :menu-tag :on :off :on-type
|
|
26 :off-type :notify :entry-format :button :children
|
|
27 :buttons :insert-before :delete-at :format-handler
|
|
28 :widget :value-pos :value-to-internal :indent
|
|
29 :help-echo
|
|
30 :value-to-external :validate :error :directory :must-match
|
|
31 :initial :type-error :value-inline :inline :match-inline
|
|
32 :greedy :button-face :value-face :keymap :size)))
|
|
33 (while keywords
|
|
34 (or (boundp (car keywords))
|
|
35 (set (car keywords) (car keywords)))
|
|
36 (setq keywords (cdr keywords))))
|
|
37
|
|
38 (defun define-widget (name class doc &rest args)
|
|
39 "Define a new widget type named NAME from CLASS.
|
|
40
|
|
41 NAME and CLASS should both be symbols, CLASS should be one of the
|
|
42 existing widget types, or nil to create the widget from scratch.
|
|
43
|
|
44 After the new widget has been defined, the following two calls will
|
|
45 create identical widgets:
|
|
46
|
|
47 * (widget-create NAME)
|
|
48
|
|
49 * (apply 'widget-create CLASS ARGS)
|
|
50
|
|
51 The third argument DOC is a documentation string for the widget."
|
|
52 (put name 'widget-type (cons class args))
|
|
53 (put name 'widget-documentation doc))
|
|
54
|
|
55 (autoload 'widget-create "widget-edit")
|
|
56 (autoload 'widget-insert "widget-edit")
|
|
57
|
|
58 (defun define-widget-group (name class doc &rest args)
|
|
59 "Define a new widget group named NAME.
|
|
60
|
|
61 CLASS should be nil, it is reserved for future use.
|
|
62
|
|
63 MATCH should be a function taking a widget group and a list of match
|
|
64 types as an argument, and returning the remaining part of the list if
|
|
65 the widget group matches the beginning of the list, or throwing
|
|
66 `no-match' if not.
|
|
67
|
|
68 CREATE should be a function taking a widget group and a list of values
|
|
69 as arguments, and returning a cons whose car is a list of widgets
|
|
70 representing the matches values and whose cdr is the remaining
|
|
71 unmatched values."
|
|
72 (put name 'widget-group (cons class args)))
|
|
73
|
|
74 ;;; The End.
|
|
75
|
|
76 (provide 'widget)
|
|
77
|
|
78 ;; widget.el ends here
|