Menu items with image AND label
Hi All,
I am currently adding some icons in front of some of my menu items using a
XmPIXMAP label with the icon and the text label rendered into a pixmap.
It's working fine unless there is one or more togglebutton(s) within the
same menu.
The togglebutton seems to set the XmNleftMargin of all menu items. This
cause all the items to be right shifted on the display. The result is not
very nice and I would like to remove this spacing for all the items that
are not togglebuttons.
It looks like this:
[ ] some toggle
XXXX some label with icon
some other label withon an icon
and I would like it to look like this:
[ ] some toggle
XXXX some label with icon
some other lable withon an icon
I tried setting the XmNleftMargin resource of non-togglebuttons to a
negative value (-indicator size) and the labels are shifted to the left
but it also affects togglebutton. When I do this, the togglebuton's label is
shifted to the left and the first few characters are unreadable as they
appear behind the togglebutton's indicator (box/diamond/round).
Any idea how I can achieve this without using anything else then the Motif
widget set?
Thanks for your time.
Re: Menu items with image AND label
Jean-Sebastien Vachon wrote:[color=blue]
>
> Hi All,
>
> I am currently adding some icons in front of some of my menu items using a
> XmPIXMAP label with the icon and the text label rendered into a pixmap.
>
> It's working fine unless there is one or more togglebutton(s) within the
> same menu.
>
> The togglebutton seems to set the XmNleftMargin of all menu items. This
> cause all the items to be right shifted on the display. The result is not
> very nice and I would like to remove this spacing for all the items that
> are not togglebuttons.
>
> It looks like this:
>
> [ ] some toggle
> XXXX some label with icon
> some other label withon an icon
>
> and I would like it to look like this:
>
> [ ] some toggle
> XXXX some label with icon
> some other lable withon an icon
>
> I tried setting the XmNleftMargin resource of non-togglebuttons to a
> negative value (-indicator size) and the labels are shifted to the left
> but it also affects togglebutton. When I do this, the togglebuton's label is
> shifted to the left and the first few characters are unreadable as they
> appear behind the togglebutton's indicator (box/diamond/round).
>
> Any idea how I can achieve this without using anything else then the Motif
> widget set?
>
> Thanks for your time.[/color]
I doubt that you can achieve the look you describe. In a menu, the
RowColumn widget aligns ToggleButtons and PushButtons such that the left
edge of the label of a ToggleButton aligns with the left edge of the
label of a PushButton. In the case of PushButtons of type XmPIXMAP, the
left edge of the pixmap is considered the edge of the label.
So if you just have ToggleButtons and XmSTRING PushButtons, you get
something that looks like this:
[ ] toggle
pushbutton
[ ] toggle
If you use XmPIXMAP buttons, the above "pushbutton" region becomes
"pixmap". So if your pixmap is "XXX label", the icon part us alighen
with "toggle". If your pixmap is " label" then the text appears
offset. If you only make XmPIXMAP buttons from those actually with
icons, you can thus get to this point:
[ ] toggle
XXX pixmap
pushbutton
But you seem to want this:
[ ] toggle <- a toggle button
XXX label <- a pushbutton with icon and text rendered into the
pixmap
label <- an XmSTRING pushbutton
This may initially appear OK, but will be slightly confusing, since the
icon button appears to look like a toggle button (the icon replacing the
checkbox), but is just a pushbutton.
If this look is really what you want, just use ALL XmPIXMAP pushbuttons.
Some of them will have pixmaps that look like an unchecked toggle button
checkbox. To make them appear to be toggles, you have to keep track of
the "state", and change the pixmap when it is supposed to be "on", where
the icon part now liiks like a checked toggle button checkbox.
--
Fred L. Kleinschmidt
Associate Technical Fellow
Boeing Common User Interface Services