Top Document: Motif FAQ (Part 4 of 9) Previous Document: 69) How do I obtain the size of a unmanaged shell widget? Next Document: 71) Can a non-shell Motif widget have a different visual type from See reader questions & answers on this topic! - Help others by sharing your knowledge [Last modified: Feb 00] Answer: You must specify the colormap, visual type, and depth for the shell before it is realized. If you don't specify all three resources (or specify them incorrectly), you will probably get BadMatch protocol errors from your X server. Ken Lee, http://www.rahul.net/kenton/ Mike Stroyan, mike_stroyan@fc.hp.com, adds: It is convenient to use XrmPutResource to cause all widgets to pick up a consistent set of visual, depth, and colormap. It is just very difficult to get at each and every shell including menushells created by functions like XmVaCreateSimpleMenuBar and XmVaCreateSimpleOptionMenu. This example uses the default visual for menus, but a non-default for the top level shell: if (!non_default_dialogs) { /* Set default depth and colormap of shell widgets, especially menus */ Screen *default_screen; int default_depth; Colormap default_colormap; XrmDatabase db = XtDatabase(display); XrmValue v; default_screen = DefaultScreenOfDisplay(display); default_depth = DefaultDepthOfScreen(default_screen); default_colormap = DefaultColormapOfScreen(default_screen); v.size = sizeof(default_depth); v.addr = (XtPointer) &default_depth; XrmPutResource(&db,"*XmMenuShell.depth", XmRInt, &v); XrmPutResource(&db,"*XmDialogShell.depth", XmRInt, &v); v.size = sizeof(default_colormap); v.addr = (XtPointer) &default_colormap; XrmPutResource(&db,"*XmMenuShell.colormap", XmRColormap, &v); XrmPutResource(&db,"*XmDialogShell.colormap", XmRColormap, &v); } /* Get visual information. */ template.screen = DefaultScreen(display); template.class = TrueColor; template.depth = 24; mask = VisualScreenMask | VisualDepthMask | VisualClassMask; vilist = XGetVisualInfo(display, mask, &template, &nvisual); if (nvisual == 0) { fprintf(stderr, "Cannot find an acceptable visual!0); exit(1); } visual = vilist[0].visual; depth = vilist[0].depth; XFree((char *) vilist); private_colormap = XCreateColormap(display, DefaultRootWindow(display), visual, AllocNone); { XColor real, exact; XAllocNamedColor(display, private_colormap, "Green", &real, &exact); green = real.pixel; } XtVaSetValues(toplevel, XmNdepth, depth, XmNvisual, visual, XmNcolormap, private_colormap, NULL); if (non_default_dialogs) { /* Set non-default visual for all widgets. */ XrmDatabase db = XtDatabase(display); XrmValue v; v.size = sizeof(visual); v.addr = (XtPointer) &visual; XrmPutResource(&db,"*visual", XmRVisual, &v); } User Contributions:Top Document: Motif FAQ (Part 4 of 9) Previous Document: 69) How do I obtain the size of a unmanaged shell widget? Next Document: 71) Can a non-shell Motif widget have a different visual type from Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: kenton@rahul.net (Ken Lee)
Last Update March 27 2014 @ 02:11 PM
|
Comment about this article, ask questions, or add new information about this topic: