Lisp HUG Maillist Archive

Windows toolbars

Hi Lispworkers
I am struggling with toolbars on LWW6 and Windows 7 and have two questions.

1. Size of toolbar-buttons
I would like toolbar-buttons larger than 16x16 pixels.
In capiref the following is stated regarding toolbar-button:
"Each image should be of the correct size for the toolbar. By
default, this is 16 pixels wide and 16 pixels high."
- Does this mean that 16x16 is a default value that you can change or is it not possible to use larger toolbar-buttons?

2. Change toolbar-button image
I can change toolbar-button images for normal toolbars, but not for toolbars attached to an interface.
Below is a small example of an interface with an attached toolbar and also a normal toolbar. In the normal toolbar, it is possible to change the images by clicking. The leftmost image is changed directly and the rightmost is changed by selection. What puzzles me is that I cannot change the images in the interface attached toolbar in the same manner.
- Any thoughts?

PS. Toggling the image in the interface attached toolbar works in LW6 for Mac OS X.
Best regards,
Sven

---
(capi:define-interface test-panel () ()
  (:panes
   (toolbar capi:toolbar
            :items (list (make-instance 'capi:toolbar-component
                                        :items (list (make-instance 'capi:toolbar-button
                                                                    :image :std-undo
                                                                    :callback 'toggle-image))
                                        :callback-type :item)
                         (make-instance 'capi:toolbar-component
                                        :items (list (make-instance 'capi:toolbar-button
                                                                    :image :std-undo
                                                                    :selected-image :std-redo))
                                        :interaction :multiple-selection))))
  (:layouts
   (main-layout capi:simple-layout
                '(toolbar)))
  (:default-initargs
   :toolbar-items (make-toolbar-items)))

(defun make-toolbar-items ()
  (list (make-instance 'capi:toolbar-component
                       :items (list (make-instance 'capi:toolbar-button
                                                   :image :std-undo
                                                   :callback 'toggle-image))
                       :callback-type :item)
        (make-instance 'capi:toolbar-component
                       :items (list (make-instance 'capi:toolbar-button
                                                   :image :std-undo
                                                   :selected-image :std-redo))
                       :interaction :multiple-selection)))

(defun toggle-image (item)
  (setf (capi:toolbar-button-image item) (if (eq (capi:toolbar-button-image item) :std-redo)
                                             :std-undo
                                           :std-redo)))

(capi:display (make-instance 'test-panel))
---

Re: Windows toolbars

Sven Emtell <sven.emtell <at> doremir.com> writes:

> 
> 
> Hi Lispworkers
> I am struggling with toolbars on LWW6 and Windows 7 and have two questions.
> 
> 1. Size of toolbar-buttons
> I would like toolbar-buttons larger than 16x16 pixels.
> In capiref the following is stated regarding toolbar-button:
> "Each image should be of the correct size for the toolbar. Bydefault, this is 
16 pixels wide and 16 pixels high."
> - Does this mean that 16x16 is a default value that you can change or is it 
not possible to use larger toolbar-buttons?
> 
> 2. Change toolbar-button image
> I can change toolbar-button images for normal toolbars, but not for toolbars 
attached to an interface.
> Below is a small example of an interface with an attached toolbar and also a 
normal toolbar. In the normal toolbar, it is possible to change the images by 
clicking. The leftmost image is changed directly and the rightmost is changed 
by selection. What puzzles me is that I cannot change the images in the 
interface attached toolbar in the same manner.
> - Any thoughts?

Hi Sven,

To manage toolbar-button size you probably want to try the :image-width and 
:image-height options in the toolbar itself (assuming you want uniformly-sized 
buttons, using external images). That works for me (on WinXP, at least).

If you want to update or change a toolbar created via :toolbar-items I think 
you have to specify something via the :toolbar-states interface initarg. I 
messed around with that briefly, but in the end decided it wasn't going to give 
me the results I wanted (in any case I mainly use custom toolbars now, built 
using a pinboard-layout and some modest Win32 hackery). Maybe have a look at 
the interface-toolbar-state function?

Hope that helps,
Chris




RE: Windows toolbars

Hi,

As Chris says you can use the :image-width and :image-height options in the toolbar itself and provide images of the correct size (see below - images are attached). FWIW we opted to use a toolbar in the layout rather than :toolbar-items because of the extra flexibility with image-sizes and changing images etc. We use this on Windows 7 and it seems to work well. You lose the ability to have the toolbar docked or undocked but we decided that was less important. 
 
hth

Paul

(gp:register-image-translation 'undo (current-pathname ".\\undo.png"))
(gp:register-image-translation 'redo (current-pathname ".\\redo.png"))

(capi:define-interface test-panel () ()
  (:panes
   (toolbar capi:toolbar
            :image-width 24
            :image-height 24
            :items (list (make-instance 'capi:toolbar-component
                                        :items (list (make-instance 'capi:toolbar-button
                                                                    :image 'undo
                                                                    :callback 'toggle-image))
                                        :callback-type :item)
                         (make-instance 'capi:toolbar-component
                                        :items (list (make-instance 'capi:toolbar-button
                                                                    :image 'undo
                                                                    :selected-image 'redo))
                                        :interaction :multiple-selection))))
  (:layouts
   (main-layout capi:simple-layout
                '(toolbar)))
  (:default-initargs
   :toolbar-items (make-toolbar-items)))

(defun make-toolbar-items ()
  (list (make-instance 'capi:toolbar-component
                       :items (list (make-instance 'capi:toolbar-button
                                                   :image 'undo
                                                   :callback 'toggle-image))
                       :callback-type :item)
        (make-instance 'capi:toolbar-component
                       :items (list (make-instance 'capi:toolbar-button
                                                   :image 'undo
                                                   :selected-image 'redo))
                       :interaction :multiple-selection)))

(defun toggle-image (item)
  (setf (capi:toolbar-button-image item) (if (eq (capi:toolbar-button-image item) 'redo)
                                             'undo
                                           'redo)))

(capi:display (make-instance 'test-panel))


-----Original Message-----
From: owner-lisp-hug@lispworks.com [mailto:owner-lisp-hug@lispworks.com] On Behalf Of Christopher Melen
Sent: 16 October 2011 21:00
To: lisp-hug@lispworks.com
Subject: Re: Windows toolbars


Sven Emtell <sven.emtell <at> doremir.com> writes:

> 
> 
> Hi Lispworkers
> I am struggling with toolbars on LWW6 and Windows 7 and have two questions.
> 
> 1. Size of toolbar-buttons
> I would like toolbar-buttons larger than 16x16 pixels.
> In capiref the following is stated regarding toolbar-button:
> "Each image should be of the correct size for the toolbar. Bydefault, this is 
16 pixels wide and 16 pixels high."
> - Does this mean that 16x16 is a default value that you can change or is it 
not possible to use larger toolbar-buttons?
> 
> 2. Change toolbar-button image
> I can change toolbar-button images for normal toolbars, but not for toolbars 
attached to an interface.
> Below is a small example of an interface with an attached toolbar and also a 
normal toolbar. In the normal toolbar, it is possible to change the images by 
clicking. The leftmost image is changed directly and the rightmost is changed 
by selection. What puzzles me is that I cannot change the images in the 
interface attached toolbar in the same manner.
> - Any thoughts?

Hi Sven,

To manage toolbar-button size you probably want to try the :image-width and 
:image-height options in the toolbar itself (assuming you want uniformly-sized 
buttons, using external images). That works for me (on WinXP, at least).

If you want to update or change a toolbar created via :toolbar-items I think 
you have to specify something via the :toolbar-states interface initarg. I 
messed around with that briefly, but in the end decided it wasn't going to give 
me the results I wanted (in any case I mainly use custom toolbars now, built 
using a pinboard-layout and some modest Win32 hackery). Maybe have a look at 
the interface-toolbar-state function?

Hope that helps,
Chris




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