[comp.windows.x] Colormap with widgets

jigang@alliant.backbone.uoknor.edu (Jigang Yang) (01/18/91)

I got problem about using colormaps with widgets.

I first use :  XCreateColormap() to create a new colormap and read all colors
from default colormap and save them into new colormap.

Then XInstallColormap();

Then create some widgets and attach them with some callbacks;

Then the mainloop.


In some callbacks, I change the RGB values of the new colormap(since it is
installed, it should be the current colormap), and install it again. 

But I only see the widgets using the newly changed color when they are focused.
For example, if you focus / click the button, the colormap is changed,
and then it seems to use the original colormap again! Why!!! 


-- 
----------------------------------------------------------------------
Jigang Yang                       | jigang@alliant.backbone.uoknor.edu
Geosciences Computing Network     | jigang@gcnuok.bitnet 
University of Oklahoma            | Telphone: 405-325-5540 

dsr@mir.mitre.org (Douglas S. Rand) (01/19/91)

In article <1991Jan17.173335.2260@uokmax.ecn.uoknor.edu>, jigang@alliant.backbone.uoknor.edu (Jigang Yang) writes:
> 
> I got problem about using colormaps with widgets.
> 
> I first use :  XCreateColormap() to create a new colormap and read all colors
> from default colormap and save them into new colormap.
> 
> Then XInstallColormap();
> 
> Then create some widgets and attach them with some callbacks;
> 
> Then the mainloop.
> 
> 
> In some callbacks, I change the RGB values of the new colormap(since it is
> installed, it should be the current colormap), and install it again. 
> 
> But I only see the widgets using the newly changed color when they are focused.
> For example, if you focus / click the button, the colormap is changed,
> and then it seems to use the original colormap again! Why!!! 
> 
Because when you install a colormap in a Window (remember all your Widgets are
X Windows) the colormap only becomes visible when that window is in focus.  How
else could it work on a display with only one active colormap? (I am presuming a
PseudoColor visual and one active colormap at a time)  This is what colormaps
are for.  If you want the button, or whatever, to always be colored a certain
way you must use the default colormap.


-- 
Douglas S. Rand 
Internet:   <dsrand@mitre.org>
Snail:	    MITRE, Burlington Road, Bedford, MA 
Disclaimer: MITRE might agree with me - then again...
Amateur Radio: KC1KJ

marbru@attc.UUCP (Martin Brunecky) (01/19/91)

In article <1991Jan17.173335.2260@uokmax.ecn.uoknor.edu> jigang@alliant.backbone.uoknor.edu.UUCP (Jigang Yang) writes:
>
>I got problem about using colormaps with widgets.
>
    You must tell us more about your environment...

    In Xt release X11R3 and Motif 1.0, the colormap resource is mostly
    ignored ....

    The second part - colormap ONLY installed when the widget has FOCUS
    is a part of the WINDOW MANAGER colormap focus policy, which is very
    often identical to keyboard focus policy. I have (yet) to see a system
    that will be able to use multiple colormaps at the same time. Most
    current system can only use one colormap - and which one is used is
    decided by the window manager, which is in charge of colormap installation.

    Note however, that the WM colormap handling also uses the WM_COLORMAP_
    _WINDOWS property (at least there are WM's which do and which do NOT...).



-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                           {...}sunpeaks!auto-trol!marbru
(303) 252-2499                        (sometimes also:  marbru@auto-trol.COM )
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404 

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (01/22/91)

DO NOT use XInstallColormap.  This is the WRONG way to use
colormaps.  Use the XtNcolormap resource of your shell widget.
-- 
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bcm.tmc.edu
					(713) 798-3776