Sunday, 27 December 2009

Buttons generator

There is outstanging package in (S)XEmacs called xpm-button.el. It can generate button image on fly. It is very handy, but eye-ugly results depresses much. So I decided to write flexibly generator for eye-candy buttons, using Wand-mode. While implementing it, I also extended Wand-mode to get necessary functionality. Here is what I've got:

(wand-button 150 32 "Wand Button"
             :bg "cornflowerblue" :fg "white"
             :round 8.0 :depth 1 :yoff 8 ; :type 'pressed
             :wand-font (make-wand-font :family "Zapfino"))


(wand-button 100 20 "Wand Button"
             :bg "gray80" :fg "black" :round 10.0
             :contrast 0.5 :depth 2 ; :type 'pressed
             :wand-font (make-wand-font :family "Copperplate"))


(wand-button 100 40 (encode-coding-string "привет" 'utf-8)
             :bg "palegreen" :fg "green" :round 0.0
             :depth 4 :yoff -2 ; :type 'pressed
             :wand-font (make-wand-font :family "Arial Black"
                                        :size 20))


Quite interesting to integrate this functionality into the SXEmacs widgets. Current implementation of buttons (using ugly static images) is far from ideal.

No comments:

Post a Comment