home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xlibpr3.zip / basicwin / getvis / visual.frag < prev   
Text File  |  1989-11-25  |  1KB  |  57 lines

  1. #include <X11/Xlib.h>
  2. #include <X11/Xutil.h>
  3.  
  4. visual()
  5. {
  6. Display *display;
  7. Colormap colormap;
  8. Window window;
  9. int screen;
  10.     .
  11.     .
  12.     .
  13. XVisualInfo vTemplate;    /* template of the visual we want */
  14. XVisualInfo *visualList;  /* list of XVisualInfo structs that match */
  15. int visualsMatched;       /* number of visuals that match */
  16.     .
  17.     .
  18.     .
  19. /* 
  20.  * Set up the XVisualInfo template so that it returns 
  21.  * a list of all the visuals of depth 8 defined on the 
  22.  * current screen by the X server 
  23.  */
  24. vTemplate.screen = screen;
  25. vTemplate.depth = 8; 
  26. .XX "XGetVisualInfo, example using"
  27. visualList = XGetVisualInfo (display, VisualScreenMask | 
  28.         VisualDepthMask, &vTemplate, &visualsMatched);
  29. if ( visualsMatched == 0 )
  30.     fatalError ("No matching visuals\en");
  31.  
  32. /*
  33.  * Create a colormap for a window using the first of the visuals
  34.  * in the list ov XVisualInfo structs returned by XGetVisualInfo.
  35.  */
  36. .XX "XCreateColormap, example using"
  37. colormap = XCreateColormap (display, RootWindow(display, screen), 
  38.     visualList[0].visual, AllocNone);
  39.     .
  40.     .
  41.     .
  42. window = XCreateWindow (display, RootWindow(display, screen),
  43.     x, y, width, height, border_width, vTemplate.depth,
  44.     InputOutput, visualList[0].visual, mask, &attributes);
  45. XSetWindowColormap(display, window, colormap);
  46. .XX "XSetWindowColormap, example using"
  47.  
  48. /* All done with visual information.  Free it.  */
  49.  
  50. XFree(visualList);
  51. .XX "XFree, example using"
  52.     .
  53.     .
  54.     .
  55. } /* end routine */
  56. .Pe
  57.