comparison lisp/gui.el @ 454:d7a9135ec789 r21-2-42

Import from CVS: tag r21-2-42
author cvs
date Mon, 13 Aug 2007 11:40:54 +0200
parents 3ecd8885ac67
children 5be46355cc42
comparison
equal deleted inserted replaced
453:270b05afd845 454:d7a9135ec789
92 (set-face-background 'gui-button-face '(((x color) . "grey75") 92 (set-face-background 'gui-button-face '(((x color) . "grey75")
93 ((mswindows color) . "grey75"))) 93 ((mswindows color) . "grey75")))
94 (set-face-foreground 'gui-button-face '(((x color) . "black") 94 (set-face-foreground 'gui-button-face '(((x color) . "black")
95 ((mswindows color) . "black"))))) 95 ((mswindows color) . "black")))))
96 96
97
98 (defun gui-button-action (instance action user-data)
99 (let ((domain (image-instance-domain instance)))
100 (with-current-buffer (if (windowp domain)
101 (window-buffer domain) nil)
102 (funcall action user-data))))
103
97 (defun make-gui-button (string &optional action user-data) 104 (defun make-gui-button (string &optional action user-data)
98 "Make a GUI button whose label is STRING and whose action is ACTION. 105 "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 106 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." 107 is non-nil, ACTION will be called with one argument, USER-DATA.
108 When ACTION is called, the buffer containing the button is made current."
101 (vector 'button 109 (vector 'button
102 :descriptor string 110 :descriptor string
103 :face 'gui-button-face 111 :face 'gui-button-face
104 :callback `(funcall (quote ,action) (quote ,user-data)))) 112 :callback-ex `(lambda (image-instance event)
113 (gui-button-action image-instance
114 (quote ,action)
115 (quote ,user-data)))))
105 116
106 (defun insert-gui-button (button &optional pos buffer) 117 (defun insert-gui-button (button &optional pos buffer)
107 "Insert GUI button BUTTON at POS in BUFFER." 118 "Insert GUI button BUTTON at POS in BUFFER."
108 (check-argument-type 'gui-button-p button) 119 (check-argument-type 'gui-button-p button)
109 (make-annotation (make-glyph button) 120 (make-annotation (make-glyph button)