aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-03 07:11:10 +0000
committerRichard M. Stallman1997-07-03 07:11:10 +0000
commit2f47738170a6efb203068ffac892b17fba78d0ec (patch)
tree9aae1ab2fb9eb8a20222362b2322a3e6fb34c39e
parent3aec85bf553bd5ce6d513a963e95305df383849d (diff)
downloademacs-2f47738170a6efb203068ffac892b17fba78d0ec.tar.gz
emacs-2f47738170a6efb203068ffac892b17fba78d0ec.zip
(color-sample, editable-color): New widget types.
(widget-button-face): Default value widget-button-face. (widget-default-button-face-get): Use variable widget-button-face.
-rw-r--r--lisp/wid-edit.el34
1 files changed, 29 insertions, 5 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index d5783d07b17..198599ba6ed 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -157,6 +157,10 @@ This exists as a variable so it can be set locally in certain buffers.")
157 :group 'widget-documentation 157 :group 'widget-documentation
158 :group 'widget-faces) 158 :group 'widget-faces)
159 159
160(defvar widget-button-face 'widget-button-face
161 "Face used for buttons in widges.
162This exists as a variable so it can be set locally in certain buffers.")
163
160(defface widget-button-face '((t (:bold t))) 164(defface widget-button-face '((t (:bold t)))
161 "Face used for widget buttons." 165 "Face used for widget buttons."
162 :group 'widget-faces) 166 :group 'widget-faces)
@@ -1533,17 +1537,13 @@ If that does not exists, call the value of `widget-complete-field'."
1533 (error "Unknown escape `%c'" escape))) 1537 (error "Unknown escape `%c'" escape)))
1534 (widget-put widget :buttons buttons))) 1538 (widget-put widget :buttons buttons)))
1535 1539
1536(defvar widget-button-face nil
1537 "Face to use for buttons.
1538This is a variable so that it can be buffer-local.")
1539
1540(defun widget-default-button-face-get (widget) 1540(defun widget-default-button-face-get (widget)
1541 ;; Use :button-face or widget-button-face 1541 ;; Use :button-face or widget-button-face
1542 (or (widget-get widget :button-face) 1542 (or (widget-get widget :button-face)
1543 (let ((parent (widget-get widget :parent))) 1543 (let ((parent (widget-get widget :parent)))
1544 (if parent 1544 (if parent
1545 (widget-apply parent :button-face-get) 1545 (widget-apply parent :button-face-get)
1546 'widget-button-face)))) 1546 widget-button-face))))
1547 1547
1548(defun widget-default-sample-face-get (widget) 1548(defun widget-default-sample-face-get (widget)
1549 ;; Use :sample-face. 1549 ;; Use :sample-face.
@@ -3389,6 +3389,30 @@ To use this type, you must define :match or :match-alternatives."
3389 (widget-setup) 3389 (widget-setup)
3390 (widget-apply widget :notify widget event)))) 3390 (widget-apply widget :notify widget event))))
3391 3391
3392;;; The alternative `editable-color' widget and its subroutine.
3393
3394(define-widget 'color-sample 'choice-item
3395 "A color name (with sample)."
3396 :format "(%{sample%})"
3397 :sample-face-get 'widget-color-item-button-face-get)
3398
3399(define-widget 'editable-color 'editable-field
3400 "A color name, editable"
3401 :tag "Color"
3402 :format "%{%t%}: %v"
3403 :complete-function 'widget-color-complete
3404 :value-create 'widget-editable-color-value-create
3405 :prompt-match '(lambda (color) (member color widget-color-choice-list))
3406 :prompt-history 'widget-string-prompt-value-history)
3407
3408(defun widget-editable-color-value-create (widget)
3409 (widget-field-value-create widget)
3410 (forward-line -1)
3411 (end-of-line)
3412 (let ((child (widget-create-child-and-convert
3413 widget 'color-sample (widget-get widget :value))))
3414 (widget-put widget :children (list child))))
3415
3392;;; The Help Echo 3416;;; The Help Echo
3393 3417
3394(defun widget-echo-help-mouse () 3418(defun widget-echo-help-mouse ()