comparison lisp/gui.el @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 95016f13131a
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
81 81
82 (defun gui-button-p (object) 82 (defun gui-button-p (object)
83 "True if OBJECT is a GUI button." 83 "True if OBJECT is a GUI button."
84 (and (vectorp object) 84 (and (vectorp object)
85 (> (length object) 0) 85 (> (length object) 0)
86 (eq 'gui-button (aref object 0)))) 86 (eq 'button (aref object 0))))
87 87
88 (make-face 'gui-button-face "Face used for gui buttons") 88 (make-face 'gui-button-face "Face used for gui buttons")
89 (if (not (face-differs-from-default-p 'gui-button-face)) 89 (if (not (face-differs-from-default-p 'gui-button-face))
90 (progn 90 (progn
91 (set-face-reverse-p 'gui-button-face t) 91 (set-face-reverse-p 'gui-button-face t)
96 96
97 (defun make-gui-button (string &optional action user-data) 97 (defun make-gui-button (string &optional action user-data)
98 "Make a GUI button whose label is STRING and whose action is ACTION. 98 "Make a GUI button whose label is STRING and whose action is ACTION.
99 If the button is inserted in a buffer and then clicked on, and ACTION 99 If the button is inserted in a buffer and then clicked on, and ACTION
100 is non-nil, ACTION will be called with one argument, USER-DATA." 100 is non-nil, ACTION will be called with one argument, USER-DATA."
101 (vector 'gui-button 101 (vector 'button
102 (if (featurep 'xpm) 102 :descriptor string
103 (xpm-button-create 103 :face 'gui-button-face
104 string gui-button-shadow-thickness 104 :callback `(funcall (quote ,action) (quote ,user-data))))
105 (color-instance-name (face-foreground-instance 'gui-button-face))
106 (color-instance-name (face-background-instance 'gui-button-face)))
107 (xbm-button-create string gui-button-shadow-thickness))
108 action user-data))
109 105
110 (defun insert-gui-button (button &optional pos buffer) 106 (defun insert-gui-button (button &optional pos buffer)
111 "Insert GUI button BUTTON at POS in BUFFER." 107 "Insert GUI button BUTTON at POS in BUFFER."
112 (check-argument-type 'gui-button-p button) 108 (check-argument-type 'gui-button-p button)
113 (let ((annotation 109 (make-annotation (make-glyph button)
114 (make-annotation (make-glyph (car (aref button 1))) 110 pos 'text buffer nil))
115 pos 'text buffer nil
116 (make-glyph (cadr (aref button 1)))))
117 (action (aref button 2)))
118 (and action
119 (progn
120 (set-annotation-action annotation action)
121 (set-annotation-data annotation (aref button 3))))))
122 111
123 ;;; gui.el ends here 112 ;;; gui.el ends here