home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xpt / part01 / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-28  |  1.0 KB  |  52 lines

  1. /**
  2.  *
  3.  * xpt -- An X Periodic Table
  4.  *
  5.  * init.c -- initialize the colors needed
  6.  *
  7.  * Written by Joel P. Lord 03/05/93
  8.  *
  9.  *    This software is available for free distribution,
  10.  * under the condition that this not be removed from the
  11.  * source code.
  12.  *
  13. **/
  14.  
  15.  
  16. #include "xpt.h"
  17.  
  18. unsigned long GetNumColor();
  19.  
  20. init_colors()
  21. {
  22.   default_cmap = DefaultColormap(p_disp, DefaultScreen(p_disp));
  23.  
  24.   mbgpix = GetColors("NavyBlue", default_cmap, BP);
  25.   mfgpix = GetColors("white", default_cmap, WP);
  26.   red = GetColors("red", default_cmap, WP);
  27.   white = mfgpix;
  28.   slate_grey = GetColors("slategrey", default_cmap, BP);
  29. }
  30.  
  31. unsigned long GetNumColor(num, cmap, def)
  32. unsigned long num;
  33. Colormap cmap;
  34. unsigned long def;
  35. {
  36.   XColor color;
  37.   unsigned long retval;
  38.  
  39.   color.pixel = num;
  40.   color.red = ((num >> 16) * 256);
  41.   color.green = ((num >> 8) & 0xFF) * 256;
  42.   color.blue = (num & 0xFF) * 256;
  43.   color.flags = DoBlue | DoGreen | DoRed;
  44.  
  45.   if (XAllocColor(p_disp, cmap, &color) == 0)
  46.     retval = def;
  47.   else
  48.     retval = color.pixel;
  49.  
  50.   return retval;
  51. }
  52.