Mercurial > hg > xemacs-beta
comparison lisp/custom/widget-example.el @ 18:d95e72db5c07 r19-15b92
Import from CVS: tag r19-15b92
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:49:43 +0200 |
parents | |
children | 859a2309aef8 |
comparison
equal
deleted
inserted
replaced
17:4579af9d8826 | 18:d95e72db5c07 |
---|---|
1 ;;; widget-example.el -- example of using the widget library | |
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.24 | |
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ | |
9 | |
10 (require 'widget) | |
11 | |
12 (eval-when-compile | |
13 (require 'widget-edit)) | |
14 | |
15 (defvar widget-example-repeat) | |
16 | |
17 (defun widget-example () | |
18 "Create the widgets from the Widget manual." | |
19 (interactive) | |
20 (switch-to-buffer "*Widget Example*") | |
21 (kill-all-local-variables) | |
22 (make-local-variable 'widget-example-repeat) | |
23 (let ((inhibit-read-only t)) | |
24 (erase-buffer)) | |
25 (widget-insert "Here is some documentation.\n\n") | |
26 (widget-create 'editable-field | |
27 :size 12 | |
28 :format "Name: %v " | |
29 "My Name") | |
30 (widget-create 'menu-choice | |
31 :tag "Choose" | |
32 :value "This" | |
33 :help-echo "Choose me, please!" | |
34 :notify (lambda (widget &rest ignore) | |
35 (message "%s is a good choice!" | |
36 (widget-value widget))) | |
37 '(item :tag "This option" :value "This") | |
38 '(choice-item "That option") | |
39 '(editable-field :menu-tag "No option" "Thus option")) | |
40 (widget-insert "Address: ") | |
41 (widget-create 'editable-field | |
42 "Some Place\nIn some City\nSome country.") | |
43 (widget-insert "\nSee also ") | |
44 (widget-create 'link | |
45 :notify (lambda (&rest ignore) | |
46 (widget-value-set widget-example-repeat | |
47 '("En" "To" "Tre")) | |
48 (widget-setup)) | |
49 "other work") | |
50 (widget-insert " for more information.\n\nNumbers: count to three below\n") | |
51 (setq widget-example-repeat | |
52 (widget-create 'editable-list | |
53 :entry-format "%i %d %v" | |
54 :notify (lambda (widget &rest ignore) | |
55 (let ((old (widget-get widget | |
56 ':example-length)) | |
57 (new (length (widget-value widget)))) | |
58 (unless (eq old new) | |
59 (widget-put widget ':example-length new) | |
60 (message "You can count to %d." new)))) | |
61 :value '("One" "Eh, two?" "Five!") | |
62 '(editable-field :value "three"))) | |
63 (widget-insert "\n\nSelect multiple:\n\n") | |
64 (widget-create 'checkbox t) | |
65 (widget-insert " This\n") | |
66 (widget-create 'checkbox nil) | |
67 (widget-insert " That\n") | |
68 (widget-create 'checkbox | |
69 :notify (lambda (&rest ignore) (message "Tickle")) | |
70 t) | |
71 (widget-insert " Thus\n\nSelect one:\n\n") | |
72 (widget-create 'radio-button-choice | |
73 :value "One" | |
74 :notify (lambda (widget &rest ignore) | |
75 (message "You selected %s" | |
76 (widget-value widget))) | |
77 '(item "One") '(item "Anthor One.") '(item "A Final One.")) | |
78 (widget-insert "\n") | |
79 (widget-create 'push-button | |
80 :notify (lambda (&rest ignore) | |
81 (if (= (length (widget-value widget-example-repeat)) | |
82 3) | |
83 (message "Congratulation!") | |
84 (error "Three was the count!"))) | |
85 "Apply Form") | |
86 (widget-insert " ") | |
87 (widget-create 'push-button | |
88 :notify (lambda (&rest ignore) | |
89 (widget-example)) | |
90 "Reset Form") | |
91 (widget-insert "\n") | |
92 (use-local-map widget-keymap) | |
93 (widget-setup)) |