Sunil S Nandihalli sunil.nandihalli@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))