comparison lisp/gui.el @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children 95016f13131a
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
62 (append props 62 (append props
63 `(popup ,parent initially-unmapped t 63 `(popup ,parent initially-unmapped t
64 menubar-visible-p nil 64 menubar-visible-p nil
65 has-modeline-p nil 65 has-modeline-p nil
66 default-toolbar-visible-p nil 66 default-toolbar-visible-p nil
67 default-gutter-visible-p nil
68 modeline-shadow-thickness 0 67 modeline-shadow-thickness 0
69 left ,(+ fleft (- (/ fwidth 2) 68 left ,(+ fleft (- (/ fwidth 2)
70 (/ (* dfwidth fontw) 69 (/ (* dfwidth fontw)
71 2))) 70 2)))
72 top ,(+ ftop (- (/ fheight 2) 71 top ,(+ ftop (- (/ fheight 2)
81 80
82 (defun gui-button-p (object) 81 (defun gui-button-p (object)
83 "True if OBJECT is a GUI button." 82 "True if OBJECT is a GUI button."
84 (and (vectorp object) 83 (and (vectorp object)
85 (> (length object) 0) 84 (> (length object) 0)
86 (eq 'button (aref object 0)))) 85 (eq 'gui-button (aref object 0))))
87 86
88 (make-face 'gui-button-face "Face used for gui buttons") 87 (make-face 'gui-button-face "Face used for gui buttons")
89 (if (not (face-differs-from-default-p 'gui-button-face)) 88 (if (not (face-differs-from-default-p 'gui-button-face))
90 (progn 89 (progn
91 (set-face-reverse-p 'gui-button-face t) 90 (set-face-reverse-p 'gui-button-face t)
96 95
97 (defun make-gui-button (string &optional action user-data) 96 (defun make-gui-button (string &optional action user-data)
98 "Make a GUI button whose label is STRING and whose action is ACTION. 97 "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 98 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." 99 is non-nil, ACTION will be called with one argument, USER-DATA."
101 (vector 'button 100 (vector 'gui-button
102 :descriptor string 101 (if (featurep 'xpm)
103 :face 'gui-button-face 102 (xpm-button-create
104 :callback `(funcall (quote ,action) (quote ,user-data)))) 103 string gui-button-shadow-thickness
104 (color-instance-name (face-foreground-instance 'gui-button-face))
105 (color-instance-name (face-background-instance 'gui-button-face)))
106 (xbm-button-create string gui-button-shadow-thickness))
107 action user-data))
105 108
106 (defun insert-gui-button (button &optional pos buffer) 109 (defun insert-gui-button (button &optional pos buffer)
107 "Insert GUI button BUTTON at POS in BUFFER." 110 "Insert GUI button BUTTON at POS in BUFFER."
108 (check-argument-type 'gui-button-p button) 111 (check-argument-type 'gui-button-p button)
109 (make-annotation (make-glyph button) 112 (let ((annotation
110 pos 'text buffer nil)) 113 (make-annotation (make-glyph (car (aref button 1)))
114 pos 'text buffer nil
115 (make-glyph (cadr (aref button 1)))))
116 (action (aref button 2)))
117 (and action
118 (progn
119 (set-annotation-action annotation action)
120 (set-annotation-data annotation (aref button 3))))))
111 121
112 ;;; gui.el ends here 122 ;;; gui.el ends here