[comp.windows.x.motif] Custom CMap w/Motif Question

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

In article <4872@wrgate.WR.TEK.COM> christ@mirkwood.wr.tek.com (Chris E. Tilt) writes:
>
>Has anyone figured out how to install a custom colormap before the
>Motif widgets are created such that when they are created, they alloc
>their colors into the custom map?
>
    Missing ONE very important piece of information: WHICH MOTIF VERSION ?

    Theoretically, you should only 
      XtSetArg ( arg[0], XtNcolormap, my_colormap );
    and create your shell, it's descendants etc.
    By default, widgets do *inherit* the parent's colormap. The StringToPixel
    converter *should* use widget's colormap.

    However, if you use Motif 1.0.xxx, no such thing is true. It's version
    of Xt totaly disregards the XtNcolormap resource.
    As usually, I had to add about 80 lines of workarounds in different
    places - I have a special WsSetShellColormap call, and my WsPopupWidget
    and WsRealize must do special things to shells, I even had to overload
    the StringToPixel converter. Mighty ugly, but yes, definitelly possible.
    Note, however, that if your colormap is read/write, unless you are very
    carefull some of widgets will allocate read-only color cells there,
    which may cause you a headache. If you need it bad, I can mail you
    examples of my code. Also note that there is no support for visual, so
    you must either "fit" into default visual, or add even more code ....

    In R4 Xt, the situation seems to be better - at least from a brief look
    at the code - so I believe XtNcolormap could work, but I haven't tested
    it (yet).

-- 
=*= 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