Lisp HUG Maillist Archive

CAPI: Pushbuttons ... Own "style" ?

Hi all:

I am currently doing my first steps in CAPI. I am about to define a GUI for an amateur radio transmitter (http://www.adat.ch/img/adt200a_big.jpg). In doing so I want to create a user-configurable touch interface. The interface is intended to enable the user to configure buttons with functions the device executes upon being pushed.


(hopefully the embedded image is displayed here ....)

These buttons are made from images - which is not what I want to do. I see no way of creating a "theme" for all my elements without resorting to images - I'd need to be able to define the shape of a button (from a structure of visual elements  - in the button example this is the green background, the text "VFO", the white area, the labels "A" etc).

Is there a way thatI just don't see ? I can see a way using OpenGL panes - maybe?

The code I used to create this is quite simple:

(in-package :cl-user)

(defpackage #:de.consequor.scratch.capi
  (:nicknames #:ccag.capi)
  (:use #:cl
        #:capi))

(in-package #:de.consequor.scratch.capi)

(defmacro mk-image-push-button (image-filepath data selection-fn)
  `(make-instance 'capi:push-button
  :data ,data
  :image (merge-pathnames
     ,image-filepath
   *gui-elements-pathname*)
  :callback ,selection-fn))

(eval-when (:compile-toplevel :execute :load-toplevel)

  (defparameter *gui-elements-pathname* #p "~/scratch/")

  (defparameter *vfo-a-btn* (mk-image-push-button
     "vfo_a.png"
     "VFO_A"
     nil))

  (defparameter *vfo-b-btn* (mk-image-push-button
     "vfo_b.png"
     "VFO_B"
     nil))

  (defparameter *vfo-c-btn* (mk-image-push-button
     "vfo_c.png"
     "VFO_C"
     nil)))

(defun test-buttons ()
  (capi:contain
   (make-instance 'push-button-panel
  :items (list *vfo-a-btn* *vfo-b-btn* *vfo-c-btn*))))


Thanks in advance for any hints ...

Best regards

   Frank


RE: CAPI: Pushbuttons ... Own "style" ?

Hi Frank,


I find the easiest way to create custom widgets of this sort is to use pinboard-layouts, pinboard-objects and input-models. You could possibly look at Edi Weitz's midgets library for inspiration.



CAPI objects are mostly native interface components, and aren't really designed to be 'customized' in this way (you'll probably find yourself fighting the CAPI if you try).. There are certainly ways to change the appearance and behaviour of CAPI objects, if you are willing to dig into platform-specific techniques for modifying look and feel. But I find the least painful route is to resort to pinboard-layouts/objects. ACL's Common Graphics has lisp widgets, which are somewhat analogous.


Best,
Christopher


From: frank.goenninger@consequor.de
Date: Sat, 2 Feb 2013 22:38:22 +0100
Subject: CAPI: Pushbuttons .... Own "style" ?
To: lisp-hug@lispworks.com

Hi all:

I am currently doing my first steps in CAPI. I am about to define a GUI for an amateur radio transmitter (http://www.adat.ch/img/adt200a_big.jpg). In doing so I want to create a user-configurable touch interface. The interface is intended to enable the user to configure buttons with functions the device executes upon being pushed.


(hopefully the embedded image is displayed here ...)

These buttons are made from images - which is not what I want to do. I see no way of creating a "theme" for all my elements without resorting to images - I'd need to be able to define the shape of a button (from a structure of visual elements  - in the button example this is the green background, the text "VFO", the white area, the labels "A" etc).

Is there a way thatI just don't see ? I can see a way using OpenGL panes - maybe?

The code I used to create this is quite simple:

(in-package :cl-user)

(defpackage #:de.consequor.scratch.capi
  (:nicknames #:ccag.capi)
  (:use #:cl
        #:capi))

(in-package #:de.consequor.scratch.capi)

(defmacro mk-image-push-button (image-filepath data selection-fn)
  `(make-instance 'capi:push-button
  :data ,data
  :image (merge-pathnames
     ,image-filepath
   *gui-elements-pathname*)
  :callback ,selection-fn))

(eval-when (:compile-toplevel :execute :load-toplevel)

  (defparameter *gui-elements-pathname* #p "~/scratch/")

  (defparameter *vfo-a-btn* (mk-image-push-button
     "vfo_a.png"
     "VFO_A"
     nil))

  (defparameter *vfo-b-btn* (mk-image-push-button
     "vfo_b.png"
     "VFO_B"
     nil))

  (defparameter *vfo-c-btn* (mk-image-push-button
     "vfo_c.png"
     "VFO_C"
     nil)))

(defun test-buttons ()
  (capi:contain
   (make-instance 'push-button-panel
  :items (list *vfo-a-btn* *vfo-b-btn* *vfo-c-btn*))))


Thanks in advance for any hints ...

Best regards

   Frank


Updated at: 2020-12-10 08:35 UTC