comparison lisp/gui.el @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents c42ec1d1cded
children 697ef44129c6
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
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
67 modeline-shadow-thickness 0 68 modeline-shadow-thickness 0
68 left ,(+ fleft (- (/ fwidth 2) 69 left ,(+ fleft (- (/ fwidth 2)
69 (/ (* dfwidth fontw) 70 (/ (* dfwidth fontw)
70 2))) 71 2)))
71 top ,(+ ftop (- (/ fheight 2) 72 top ,(+ ftop (- (/ fheight 2)
80 81
81 (defun gui-button-p (object) 82 (defun gui-button-p (object)
82 "True if OBJECT is a GUI button." 83 "True if OBJECT is a GUI button."
83 (and (vectorp object) 84 (and (vectorp object)
84 (> (length object) 0) 85 (> (length object) 0)
85 (eq 'gui-button (aref object 0)))) 86 (eq 'button (aref object 0))))
86 87
87 (make-face 'gui-button-face "Face used for gui buttons") 88 (make-face 'gui-button-face "Face used for gui buttons")
88 (if (not (face-differs-from-default-p 'gui-button-face)) 89 (if (not (face-differs-from-default-p 'gui-button-face))
89 (progn 90 (progn
90 (set-face-reverse-p 'gui-button-face t) 91 (set-face-reverse-p 'gui-button-face t)
95 96
96 (defun make-gui-button (string &optional action user-data) 97 (defun make-gui-button (string &optional action user-data)
97 "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.
98 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
99 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."
100 (vector 'gui-button 101 (vector 'button
101 (if (featurep 'xpm) 102 :descriptor string
102 (xpm-button-create 103 :face 'gui-button-face
103 string gui-button-shadow-thickness 104 :callback `(funcall (quote ,action) (quote ,user-data))))
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))
108 105
109 (defun insert-gui-button (button &optional pos buffer) 106 (defun insert-gui-button (button &optional pos buffer)
110 "Insert GUI button BUTTON at POS in BUFFER." 107 "Insert GUI button BUTTON at POS in BUFFER."
111 (check-argument-type 'gui-button-p button) 108 (check-argument-type 'gui-button-p button)
112 (let ((annotation 109 (make-annotation (make-glyph button)
113 (make-annotation (make-glyph (car (aref button 1))) 110 pos 'text buffer nil))
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))))))
121 111
122 ;;; gui.el ends here 112 ;;; gui.el ends here