[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: widget ?
>>>>> <20011005183109K.1000@pine.kuee.kyoto-u.ac.jp> にて、
>>>>> "土" = <tsuchiya@pine.kuee.kyoto-u.ac.jp> さんは書きました:
土> Form の送信ボタンなどを widget.el で利用されているボタンのような
土> faceで表現することにしたら、ちょっと格好良くなったりしないでしょう
土> か?
山> E21 だけだったら比較的簡単だと思うので、どうぞやって下さいまし。:-)
土> 適当に実装してみました。
これだとマウスが通るだけでボタンがへこみますが、
やっぱりボタンが押されたときにへこんで欲しいです。
こんなかんじで widget を使った実装にしてはどうでしょう?
Index: w3m-e21.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m-e21.el,v
retrieving revision 1.30
diff -u -r1.30 w3m-e21.el
--- w3m-e21.el 2001/10/05 09:24:14 1.30
+++ w3m-e21.el 2001/10/11 02:41:02
@@ -36,6 +36,7 @@
(require 'w3m-macro)
(require 'w3m-fsf)
+(require 'wid-edit)
;; Functions and variables which should be defined in the other module
;; at run-time.
@@ -117,7 +118,7 @@
;;; Form buttons
(defface w3m-form-button-face
'((((type x w32 mac) (class color))
- (:box (:line-width 1 :style released-button)
+ (:box (:line-width 2 :style released-button)
:background "lightgrey" :foreground "black"))
(((class color) (background light)) (:foreground "cyan" :underline t))
(((class color) (background dark)) (:foreground "red" :underline t))
@@ -125,9 +126,19 @@
"*Face to fontify buttons in forms."
:group 'w3m-face)
+(defface w3m-form-button-mouse-face
+ '((((type x w32 mac) (class color))
+ (:box (:line-width 2 :style released-button)
+ :background "DarkSeaGreen1" :foreground "black"))
+ (((class color) (background light)) (:foreground "cyan" :underline t))
+ (((class color) (background dark)) (:foreground "red" :underline t))
+ (t (:underline t)))
+ "*Face to fontify focused buttons in forms."
+ :group 'w3m-face)
+
(defface w3m-form-button-pressed-face
'((((type x w32 mac) (class color))
- (:box (:line-width 1 :style pressed-button)
+ (:box (:line-width 2 :style pressed-button)
:background "lightgrey" :foreground "black"))
(((class color) (background light)) (:foreground "cyan" :underline t))
(((class color) (background dark)) (:foreground "red" :underline t))
@@ -135,33 +146,29 @@
"*Face to fontify pressed buttons in forms."
:group 'w3m-face)
+(define-widget 'w3m-form-button 'push-button
+ "Widget for w3m form button."
+ :keymap widget-keymap
+ :action (function (lambda (widget &optional e)
+ (eval (widget-get widget :w3m-form-action)))))
+
(defun w3m-form-make-button (start end properties)
"Make button on the region from START to END."
(if w3m-form-use-fancy-faces
- (or (and (face-attribute 'w3m-form-button-face :box)
- (eq ?\[ (char-after start))
- (eq ?\] (char-before end))
- (save-excursion
- (goto-char start)
- (delete-char 1)
- (insert " ")
- (goto-char end)
- (delete-char -1)
- (insert " ")
- (add-text-properties
- (1+ start) (1- end)
- (append '(face
- w3m-form-button-face
- mouse-face
- w3m-form-button-pressed-face)
- properties))))
- (add-text-properties
- start end
- (append '(face
- w3m-form-button-face
- mouse-face
- w3m-form-button-pressed-face)
- properties)))
+ (progn (and (face-attribute 'w3m-form-button-face :box)
+ (eq ?\[ (char-after start))
+ (eq ?\] (char-before end))
+ (save-excursion
+ (goto-char start)
+ (delete-char 1)
+ (insert " ")
+ (goto-char end)
+ (delete-char -1)
+ (insert " ")
+ (widget-convert-button
+ 'w3m-form-button (1+ start) (1- end)
+ :w3m-form-action (plist-get properties 'w3m-action))))
+ (add-text-properties start end properties))
(add-text-properties start end
(append '(face w3m-form-face)
properties))))
@@ -266,7 +273,16 @@
'help-echo
"mouse-2 prompts to input URL"))))))
+(defun w3m-setup-widget-faces ()
+ (make-local-variable 'widget-button-face)
+ (make-local-variable 'widget-mouse-face)
+ (make-local-variable 'widget-button-pressed-face)
+ (setq widget-button-face 'w3m-form-button-face)
+ (setq widget-mouse-face 'w3m-form-button-mouse-face)
+ (setq widget-button-pressed-face 'w3m-form-button-pressed-face))
+
(add-hook 'w3m-mode-hook 'w3m-setup-header-line)
+(add-hook 'w3m-mode-hook 'w3m-setup-widget-faces)
(provide 'w3m-e21)
;;; w3m-e21.el ends here.
--
Yuuichi Teranishi (寺西裕一) <teranisi@gohome.org>
PGP 5.0i Public Key: http://www.gohome.org/pgp5/teranisi.key
"For tomorrow may rain, so I'll follow the sun."