glasgow@POPEYE.NOSC.MIL (Michael Glasgow) (09/20/89)
I am having a problem with Visuals and Colormaps. I am running on a Navy Desktop Computer, which is a Sun 4/110 and a CG6 color board. I am running the XNews server provided under Sun OS 4.0.3. The problem is that this server defines two visuals: PseudoColor and StaticColor. The default is the StaticColor visual. So, if I AllocNamedColors with the DefaultColormap, I get something close, but not exactly what I wanted. What I want to do is to Alloc Colors from the Colormap whose visual is of type PseudoColor. I am also using the X Toolkit. If I weren't, I suppose that I could simply create a window with the proper visual, and if I accessed the default colormap of this window, I would be able to allocate my colors properly. But in the Toolkit, there is no way to set the visual for a given widget, at least none that I know of. My question is this, how can I show true colors in a widget, when the default visual is of type StaticColor? Also, is the DefaultColormap apply to a window, or does it apply to a visual? I have queried the Visuals and found the proper type, but do no see how I can get the colormap from the Visual Info. Maybe this is not possible, but it seems to me like it should be. One final note. Is there a call that returns the number of un-allocated color cells in a Colormap? Such as: XQueryFreeCells( dpy, cmap, cells, ncells ) Display *dpy; Colormap cmap; XColor cells[ncells]; int *ncells; This call would return the number of free cells in a colormap, as well as a list of all of the free cells. Is there a way to do this now? And if not, will something like this be added in the future? Michael Glasgow glasgow@popeye.nosc.mil
swick@ATHENA.MIT.EDU (Ralph R. Swick) (09/20/89)
> But in the Toolkit, there is no way to set the visual > for a given widget None of the built-in widget classes (e.g. Core) have a Visual resource, you are correct, but that does not prevent other widgets from declaring such a resource and thereby giving the application control. In R3 the default visual type (in XtCreateWindow) is always CopyFromParent. In the revisions just published for the R4 specification, the Shell class defines a Visual resource which is intended to satisfy simple cases such as yours. > My question is this, how can I show true colors in a widget, when > the default visual is of type StaticColor? Until R4 is released, your only choice is to explicitly set the visual type in the realize procedure of your widget. > Also, is the DefaultColormap apply to a window, or does it apply > to a visual? A colormap is associated with a specific visual when it is created, and may only be used with that visual. The DefaultColormap is the colormap of the root window and can only be used with other windows that have the same visual type as the root window. > One final note. Is there a call that returns the number of > un-allocated color cells in a Colormap? Not in Xlib or in Xt. > Is there a way to do > this now? Only by allocating until the server says 'no more'.
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/20/89)
Also, is the DefaultColormap apply to a window, or does it apply to a visual? A visual. I have queried the Visuals and found the proper type, but do no see how I can get the colormap from the Visual Info. There aren't preallocated colormaps for all visuals, there's just the default colormap, which is what gets used for the root window initially. Some sharing of maps for other visuals can be done with Xlib's standard colormap mechanism. Is there a call that returns the number of un-allocated color cells in a Colormap? There is no protocol request for this. The theory is that you should just allocate along in whatever map you prefer, and if you run out, use CopyColormapAndFree to move stuff over to a new map. And if not, will something like this be added in the future? No plans.