[mcclim-devel] having an image icon on push-button
Evgeny M. Zubok
evgeny.zubok at tochka.ru
Thu Jul 23 16:41:44 UTC 2009
Sunil S Nandihalli <sunil.nandihalli at gmail.com> writes:
> Hello, I was wondering if there is a way to have image-icons on
> push-buttons.. Regards, Sunil
You may, for example, create a new class picture-button-pane, create
pattern from icon image (for example, XPM) and draw pattern above the
push-button in handle-repaint :after method. In this simple example the
dimension of icon.xpm is 21x21 (icon is attached). Also I hardcoded
width and height of the button in (compose-space...) to (29x29 px) and
translation to (4,4).
Type (picture-button-demo::run) to run the example.
(defpackage :picture-button-demo
(:use #:clim-lisp #:clim))
(in-package :picture-button-demo)
(defun run ()
(run-frame-top-level (make-application-frame 'button-demo)))
(defclass picture-button-pane (push-button-pane)
((pattern :accessor pattern :initarg :pattern)))
(define-application-frame button-demo ()
()
(:menu-bar nil)
(:panes
(button
(make-pane
'picture-button-pane
:name 'picture-button
:pattern (climi::make-pattern-from-bitmap-file
"/path/to/your/icon.xpm" :format :pixmap-3))))
(:layouts
(:main button)))
(defmethod handle-repaint :after ((pane picture-button-pane) region)
(draw-design pane (pattern pane)
:transformation (make-transformation 0 0 0 0 4 4)
:clipping-region region))
(defmethod compose-space ((gadget picture-button-pane) &key width height)
(declare (ignore width height))
(make-space-requirement :width 29 :height 29
:max-height 29 :max-width 29
:min-height 29 :min-width 29))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: icon.xpm
Type: image/x-xpixmap
Size: 684 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/mcclim-devel/attachments/20090723/fdc61d65/attachment.xpm>
More information about the mcclim-devel
mailing list