home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / icons.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  99.2 KB  |  3,282 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* */
  19. /* icons.c --- icons and stuff
  20.    Created: Jamie Zawinski <jwz@netscape.com>
  21.  */
  22.  
  23.  
  24. #include "mozilla.h"
  25. #include "xfe.h"
  26. #include "fonts.h"
  27. #include "e_kit.h"
  28.  
  29. #include <Xm/PushBP.h>        /* For fast updating of the button pixmap... */
  30.  
  31. #ifndef NETSCAPE_PRIV
  32. #include "../../lib/xp/flamer.h"
  33. #else
  34. #include "../../lib/xp/biglogo.h"
  35. #include "../../lib/xp/photo.h"
  36. #include "../../lib/xp/hype.h"
  37. #ifndef NO_SECURITY
  38. #include "../../lib/xp/rsalogo.h"
  39. #include "ssl.h"
  40. #include "xp_sec.h"
  41. #endif
  42. #ifdef JAVA
  43. #include "../../lib/xp/javalogo.h"
  44. #endif
  45. #ifdef FORTEZZA
  46. #include "../../lib/xp/litronic.h"
  47. #endif
  48. #include "../../lib/xp/coslogo.h"
  49. #include "../../lib/xp/insologo.h"
  50. #include "../../lib/xp/mclogo.h"
  51. #include "../../lib/xp/ncclogo.h"
  52. #include "../../lib/xp/odilogo.h"
  53. #include "../../lib/xp/qt_logo.h"
  54. #include "../../lib/xp/tdlogo.h"
  55. #include "../../lib/xp/visilogo.h"
  56. #endif /* !NETSCAPE_PRIV */
  57. #ifdef EDITOR
  58. #include "edt.h" /* for EDT_GetEmptyDocumentString() */
  59. #endif
  60. #ifndef NO_WEB_FONTS
  61. #include "nf.h"
  62. #include "Mnfrc.h"
  63. #include "Mnfrf.h"
  64. #include "Mnffbu.h"
  65. #endif
  66.  
  67. #define ABS(x)     (((x) < 0) ? -(x) : (x))
  68.  
  69. #include "il_icons.h"           /* Image icon enumeration. */
  70. #include "libimg.h"             /* Image Library public API. */
  71.  
  72. #include "icondata.h"
  73. #include "icons.h"
  74.  
  75. #ifndef NSPR20
  76. #include "prosdep.h"  /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
  77. #else
  78. #include "prtypes.h"
  79. #endif
  80.  
  81.  
  82. #include <xpgetstr.h> /* for XP_GetString() */
  83. extern int XFE_SECURITY_WITH;
  84. extern int XFE_SECURITY_DISABLED;
  85.  
  86.  
  87. extern char fe_LicenseData[];
  88.  
  89. #define DELAYED_ICON_BORDER    1
  90. #define DELAYED_ICON_PAD    2
  91.  
  92. static struct fe_icon fe_icons[512 + MAX_ANIM_FRAMES * MAX_ANIMS] = { { 0, } };
  93.  
  94. Pixel *fe_icon_pixels = 0;
  95.  
  96. void
  97. fe_InitIconColors (MWContext *context)
  98. {
  99.   int i;
  100.   static Boolean done = False;
  101.   Pixel pixel;
  102.  
  103.   /* Only pass through this function once per context. */
  104.   if (CONTEXT_DATA (context)->icon_colors_initialized) return;
  105.  
  106.   CONTEXT_DATA (context)->icon_colors_initialized = True;
  107.  
  108. #ifdef DEBUG_username
  109.   printf("Colormap using %d colors.\n", fe_n_icon_colors);
  110. #endif
  111.  
  112.   if (!fe_icon_pixels)
  113.     fe_icon_pixels = (Pixel *) malloc (sizeof (Pixel) * 256);
  114.     /*fe_icon_pixels = (Pixel *) malloc (sizeof (Pixel) * fe_n_icon_colors);*/
  115.   
  116.   for (i = 0; i < fe_n_icon_colors; i++)
  117.     {
  118.       XColor color;
  119.       color.red   = fe_icon_colors [i][0];
  120.       color.green = fe_icon_colors [i][1],
  121.       color.blue  = fe_icon_colors [i][2];
  122.  
  123.       pixel = fe_GetPermanentPixel (context,
  124.                                     color.red, color.green, color.blue);
  125.  
  126.       fe_icon_pixels [i] = pixel;
  127.     }
  128.   done = True;
  129. }
  130.  
  131.  
  132. static char *
  133. fe_get_app_dir(Display *dpy)
  134. {
  135.     char        clas[64];
  136.     XrmDatabase    db;
  137.     char        instance[64];
  138.     char        *type;
  139.     XrmValue    value;
  140.  
  141.     db = XtDatabase(dpy);
  142.     PR_snprintf(instance, sizeof (instance), "%s.appDir", fe_progclass);
  143.     PR_snprintf(clas, sizeof (clas), "%s.AppDir", fe_progclass);
  144.     if (XrmGetResource(db, instance, clas, &type, &value))
  145.     {
  146.         return value.addr;
  147.     }
  148.  
  149. #ifdef __sun
  150.     return "/usr/openwin/lib/netscape";
  151. #else
  152.     return "/usr/lib/X11/netscape";
  153. #endif
  154. }
  155.  
  156.  
  157. static char *
  158. fe_get_xpm_string(FILE *f, int size)
  159. {
  160.     static int    alloc;
  161.     static char    *buf = NULL;
  162.     int        c;
  163.     int        i;
  164.  
  165.     if (buf)
  166.     {
  167.         if (size > alloc)
  168.         {
  169.             alloc = size;
  170.             buf = realloc(buf, alloc);
  171.             if (!buf)
  172.             {
  173.                 return NULL;
  174.             }
  175.         }
  176.     }
  177.     else
  178.     {
  179.         if (size > 128)
  180.         {
  181.             alloc = size;
  182.         }
  183.         else
  184.         {
  185.             alloc = 128;
  186.         }
  187.         buf = malloc(alloc);
  188.         if (!buf)
  189.         {
  190.             return NULL;
  191.         }
  192.     }
  193.  
  194.     do
  195.     {
  196.         c = getc(f);
  197.     }
  198.     while ((c != '"') && (c != EOF));
  199.  
  200.     for (i = 0; i < alloc; i++)
  201.     {
  202.         c = getc(f);
  203.         buf[i] = c;
  204.         if ((c == EOF) || (buf[i] == '"'))
  205.         {
  206.             break;
  207.         }
  208.     }
  209.  
  210.     if (buf[i] != '"')
  211.     {
  212.         do
  213.         {
  214.             c = getc(f);
  215.         }
  216.         while ((c != '"') && (c != EOF));
  217.     }
  218.  
  219.     buf[i] = 0;
  220.  
  221.     return buf;
  222. }
  223.  
  224.  
  225. typedef struct {
  226.     char    type[16];
  227.     char    spec[16];
  228. } xpm_color_entry;
  229.  
  230.  
  231. typedef struct {
  232.     unsigned int    mask : 1;
  233.     unsigned int    mono : 1;
  234.     unsigned char    color;
  235. } fe_color_entry;
  236.  
  237. static fe_color_entry fe_color_entries[128];
  238.  
  239. void
  240. fe_process_color(int index, xpm_color_entry *entry)
  241. {
  242.     int    b;
  243.     int    dist;
  244.     int    g;
  245.     int    i;
  246.     int    min;
  247.     int    min_i;
  248.     int    r;
  249.  
  250.     switch (entry->type[0])
  251.     {
  252.     case 'm':
  253.         if (entry->spec[0] == '#')
  254.         {
  255.             if (entry->spec[1] == '0')
  256.             {
  257.                 fe_color_entries[index].mono = 1;
  258.             }
  259.         }
  260.         break;
  261.     case 'c':
  262.         if (entry->spec[0] == '#')
  263.         {
  264.             sscanf(entry->spec + 1, "%2x%2x%2x", &r, &g, &b);
  265.             r |= (r << 8);
  266.             g |= (g << 8);
  267.             b |= (b << 8);
  268.             min = 0xffff * 3;
  269.             min_i = 0;
  270.             for (i = 0; i < fe_n_icon_colors; i++)
  271.             {
  272.                 dist =
  273.                     ABS(r - (int) fe_icon_colors[i][0]) +
  274.                     ABS(g - (int) fe_icon_colors[i][1]) +
  275.                     ABS(b - (int) fe_icon_colors[i][2]);
  276.                 if (dist < min)
  277.                 {
  278.                     min = dist;
  279.                     min_i = i;
  280.                 }
  281.             }
  282.             fe_color_entries[index].color = min_i;
  283.         }
  284.         break;
  285.     case 's':
  286.         if (!strcmp(entry->spec, "mask"))
  287.         {
  288.             fe_color_entries[index].mask = 1;
  289.         }
  290.         break;
  291.     }
  292. }
  293.  
  294.  
  295. void
  296. fe_get_external_icon(Display *dpy, char **name, int *width, int *height,
  297.     unsigned char **mono_data, unsigned char **color_data,
  298.     unsigned char **mask_data)
  299. {
  300.     int        chars_per_pixel;
  301.     unsigned char    *color;
  302.     xpm_color_entry    entry[3];
  303.     FILE        *f;
  304.     char        file[512];
  305.     int        h;
  306.     int        i;
  307.     int        j;
  308.     int        k;
  309.     unsigned char    *mask;
  310.     int        mlen;
  311.     unsigned char    *mono;
  312.     int        ncolors;
  313.     unsigned char    *p;
  314.     char        *s;
  315.     int        w;
  316.  
  317.     f = NULL;
  318.  
  319.     mono = NULL;
  320.     color = NULL;
  321.     mask = NULL;
  322.  
  323.         if ( **name != '/' ) PR_snprintf(file, sizeof (file),
  324.             "%s/%s.xpm", fe_get_app_dir(dpy), *name);
  325.     f = fopen(file, "r");
  326.     if (!f)
  327.     {
  328.         goto BAD_BAD_ICON;
  329.     }
  330.  
  331.     s = fe_get_xpm_string(f, -1);
  332.     if (!s)
  333.     {
  334.         goto BAD_BAD_ICON;
  335.     }
  336.  
  337.     w = h = ncolors = chars_per_pixel = -1;
  338.     sscanf(s, "%d %d %d %d", &w, &h, &ncolors, &chars_per_pixel);
  339.     if ((w < 0) || (h < 0) || (ncolors < 0) || (chars_per_pixel < 0))
  340.     {
  341.         goto BAD_BAD_ICON;
  342.     }
  343.  
  344.     mlen = ((w + 7) / 8) * h;
  345.  
  346.     mono = malloc(mlen);
  347.     color = malloc(w * h);
  348.     mask = malloc(mlen);
  349.     if ((!mono) || (!color) || (!mask))
  350.     {
  351.         goto BAD_BAD_ICON;
  352.     }
  353.  
  354.     for (i = 0; i < 128; i++)
  355.     {
  356.         fe_color_entries[i].mask = 0;
  357.         fe_color_entries[i].mono = 0;
  358.         fe_color_entries[i].color = 0;
  359.     }
  360.  
  361.     for (i = 0; i < ncolors; i++)
  362.     {
  363.         s = fe_get_xpm_string(f, -1);
  364.         if ((!s) || (!(*s)) || (s[1] != ' '))
  365.         {
  366.             goto BAD_BAD_ICON;
  367.         }
  368.         entry[0].type[0] = 0;
  369.         entry[0].spec[0] = 0;
  370.         entry[1].type[0] = 0;
  371.         entry[1].spec[0] = 0;
  372.         entry[2].type[0] = 0;
  373.         entry[2].spec[0] = 0;
  374.         sscanf(s + 2, "%s %s %s %s %s %s",
  375.             entry[0].type, entry[0].spec,
  376.             entry[1].type, entry[1].spec,
  377.             entry[2].type, entry[2].spec);
  378.         fe_process_color(s[0], &entry[0]);
  379.         fe_process_color(s[0], &entry[1]);
  380.         fe_process_color(s[0], &entry[2]);
  381.     }
  382.  
  383.     for (i = 0; i < mlen; i++)
  384.     {
  385.         mask[i] = 0;
  386.         mono[i] = 0;
  387.     }
  388.  
  389.     j = 0;
  390.     k = 0;
  391.     for (i = 0; i < h; i++)
  392.     {
  393.         s = fe_get_xpm_string(f, w + 1);
  394.         if (!s)
  395.         {
  396.             goto BAD_BAD_ICON;
  397.         }
  398.         p = (unsigned char *) s;
  399.         while (*p)
  400.         {
  401.             color[j] = fe_color_entries[*p].color;
  402.             if (!fe_color_entries[*p].mask)
  403.             {
  404.                 mask[k / 8] |= (1 << (k % 8));
  405.             }
  406.             if (fe_color_entries[*p].mono)
  407.             {
  408.                 mono[k / 8] |= (1 << (k % 8));
  409.             }
  410.             p++;
  411.             j++;
  412.             k++;
  413.         }
  414.         k = ((k + 7) / 8) * 8;
  415.     }
  416.  
  417.     *width = w;
  418.     *height = h;
  419.     *mono_data = mono;
  420.     *color_data = color;
  421.     *mask_data = mask;
  422.  
  423.     fclose(f);
  424.  
  425.     return;
  426.  
  427. BAD_BAD_ICON:
  428.     if (f)
  429.     {
  430.         fclose(f);
  431.     }
  432.  
  433.     if (mono)
  434.     {
  435.         free(mono);
  436.     }
  437.     if (color)
  438.     {
  439.         free(color);
  440.     }
  441.     if (mask)
  442.     {
  443.         free(mask);
  444.     }
  445.  
  446.     *name = NULL;
  447. }
  448.  
  449. void
  450. fe_NewMakeIcon(Widget toplevel_widget, 
  451.            Pixel foreground_color,
  452.            Pixel transparent_color, fe_icon *result,
  453.            char *name, int width, int height, 
  454.            unsigned char *mono_data,
  455.            unsigned char *color_data,
  456.            unsigned char *mask_data,
  457.            Boolean hack_mask_and_cmap_p)
  458. {
  459.   Display *dpy = XtDisplay (toplevel_widget);
  460.   Screen *screen;
  461.   Window window;
  462.   Visual *v = 0;
  463.   Colormap cmap = 0;
  464.   Cardinal visual_depth = 0;
  465.   Cardinal pixmap_depth = 0;
  466.   unsigned char *data;
  467.   Boolean free_data = False;
  468.   XImage *ximage;
  469.   Pixmap pixmap = 0;
  470.   Pixmap mask_pixmap = 0;
  471.   XGCValues gcv;
  472.   GC gc;
  473.   int i;
  474.  
  475.   if (result->pixmap) return;    /* Already done. */
  476.  
  477.   if (name) fe_get_external_icon(dpy, &name, &width, &height, &mono_data,
  478.     &color_data, &mask_data);
  479.  
  480.   XtVaGetValues (toplevel_widget, XtNvisual, &v, XtNcolormap, &cmap,
  481.          XtNscreen, &screen, XtNdepth, &visual_depth, 0);
  482.  
  483.   if (hack_mask_and_cmap_p || !v)
  484.     {
  485.       v = DefaultVisualOfScreen (screen);
  486.       cmap = DefaultColormapOfScreen (screen);
  487.       visual_depth = fe_VisualDepth (dpy, v);
  488.     }
  489.  
  490.   window = RootWindowOfScreen (screen);
  491.   pixmap_depth = fe_VisualPixmapDepth (dpy, v);
  492.  
  493.   if (pixmap_depth == 1 || fe_globalData.force_mono_p)
  494.     {
  495.   MONO:
  496.       data = mono_data;
  497.     }
  498.   else
  499.     {
  500.       /* Remap the numbers in the data to match the colors we allocated.
  501.      We need to copy it since the string might not be writable.
  502.      Also, the data is 8 deep - we might need to deepen it if we're
  503.      on a deeper visual.
  504.        */
  505.       unsigned char  *data8  = 0;
  506.       unsigned short *data16 = 0;
  507.       unsigned char  *data24 = 0;
  508.       unsigned int   *data32 = 0;
  509.       unsigned long  *data64 = 0;
  510.  
  511.       if (pixmap_depth == 8)
  512.     {
  513.       data8 = (unsigned char *) malloc (width * height);
  514.       data  = (unsigned char *) data8;
  515.     }
  516.       else if (pixmap_depth == 16)
  517.     {
  518.       data16 = (unsigned short *) malloc (width * height * 2);
  519.       data   = (unsigned char *) data16;
  520.     }
  521.       else if (pixmap_depth == 24)
  522.        {
  523.          data24 = (unsigned char *) malloc (width * height * 3);
  524.          data   = (unsigned char *) data24;
  525.        }
  526.       else if (pixmap_depth == 32)
  527.     {
  528.       data32 = (unsigned int *) malloc (width * height * 4);
  529.       data   = (unsigned char *) data32;
  530.     }
  531.       else if (pixmap_depth == 64)
  532.     {
  533.       data64 = (unsigned long *) malloc (width * height * 8);
  534.       data   = (unsigned char *) data64;
  535.     }
  536.       else
  537.     {
  538.       /* Oh great, a goofy depth. */
  539.       goto MONO;
  540.     }
  541.  
  542.       free_data = True;
  543.  
  544.       if (!hack_mask_and_cmap_p)
  545.     {
  546.       if (pixmap_depth == 8)
  547.         for (i = 0; i < (width * height); i++)
  548.           data8  [i] = fe_icon_pixels [color_data [i]];
  549.       else if (pixmap_depth == 16)
  550.         for (i = 0; i < (width * height); i++)
  551.           data16 [i] = fe_icon_pixels [color_data [i]];
  552.          else if (pixmap_depth == 24)
  553.            for (i = 0; i < (width * height); i++){
  554.               unsigned int i3 = i +(i << 1);
  555.               unsigned char *color24 = (unsigned char *)(fe_icon_pixels+color_data [i]);
  556.              data24 [i3++] = *color24++;
  557.              data24 [i3++] = *color24++;
  558.              data24 [i3++] = *color24++;
  559.             }
  560.       else if (pixmap_depth == 32)
  561.         for (i = 0; i < (width * height); i++)
  562.           data32 [i] = fe_icon_pixels [color_data [i]];
  563.       else if (pixmap_depth == 64)
  564.         for (i = 0; i < (width * height); i++)
  565.           data64 [i] = fe_icon_pixels [color_data [i]];
  566.       else
  567.         abort ();
  568.     }
  569.       else
  570.     {
  571.       /* The hack_mask_and_cmap_p flag means that these colors need to come
  572.          out of the default colormap, not the window's colormap, since this
  573.          is an icon for the desktop.  So, go through the image, find the
  574.          colors that are in it, and duplicate them.
  575.        */
  576.       char color_duped [255];
  577.       Pixel new_pixels [255];
  578.       memset (color_duped, 0, sizeof (color_duped));
  579.       memset (new_pixels, ~0, sizeof (new_pixels));
  580.       for (i = 0; i < (width * height); i++)
  581.         {
  582.           if (!color_duped [color_data [i]])
  583.         {
  584.           XColor color;
  585.                   fe_colormap *colormap = fe_globalData.default_colormap;
  586.           color.red   = fe_icon_colors [color_data [i]][0];
  587.           color.green = fe_icon_colors [color_data [i]][1];
  588.           color.blue  = fe_icon_colors [color_data [i]][2];
  589.                   if (!fe_AllocColor (colormap, &color))
  590.                       fe_AllocClosestColor (colormap, &color);
  591.           new_pixels [color_data [i]] = color.pixel;
  592.           color_duped [color_data [i]] = 1;
  593.         }
  594.               switch(pixmap_depth){
  595.               case 8:
  596.                data8  [i] = new_pixels [color_data [i]];
  597.                 break;
  598.               case 16:
  599.                data16 [i] = new_pixels [color_data [i]];
  600.                 break;
  601.              case 24:
  602.                 {
  603.                  unsigned int i3 = i + (i << 1);
  604.                  unsigned char *color24 = (unsigned char *)(new_pixels+color_data [i]);
  605.                  data24 [i3++] = *color24++;
  606.                  data24 [i3++] = *color24++;
  607.                  data24 [i3++] = *color24++;
  608.                 }
  609.                 break;
  610.               case 32:
  611.                data32 [i] = new_pixels [color_data [i]];
  612.                 break;
  613.               case 64:
  614.                data64 [i] = new_pixels [color_data [i]];
  615.                 break;
  616.               default:
  617.                abort ();
  618.               }
  619.         }
  620.     }
  621.     }
  622.  
  623.   ximage = XCreateImage (dpy, v,
  624.              (data == mono_data ? 1 : visual_depth),
  625.              (data == mono_data ? XYPixmap : ZPixmap),
  626.              0,                   /* offset */
  627.              (char *) data, width, height,
  628.              8,                   /* bitmap_pad */
  629.              0);
  630.   if (data == mono_data)
  631.     {
  632.       /* This ordering is implicit in the data in icondata.h, which is
  633.      the same implicit ordering as in all XBM files.  I think. */
  634.       ximage->bitmap_bit_order = LSBFirst;
  635.       ximage->byte_order = LSBFirst;
  636.     }
  637.   else
  638.     {
  639. #if defined(IS_LITTLE_ENDIAN)
  640.       ximage->byte_order = LSBFirst;
  641. #elif defined (IS_BIG_ENDIAN)
  642.       ximage->byte_order = MSBFirst;
  643. #else
  644.   ERROR! Endianness is unknown.
  645. #endif
  646.     }
  647.  
  648.   if (data == mono_data && visual_depth != 1 && !hack_mask_and_cmap_p)
  649.     {
  650.       /* If we're in mono-mode, and the screen is not of depth 1,
  651.      deepen the pixmap. */
  652.       Pixmap shallow;
  653.       shallow = XCreatePixmap (dpy, window, width, height, 1);
  654.       pixmap  = XCreatePixmap (dpy, window, width, height, pixmap_depth);
  655.       gcv.function = GXcopy;
  656.       gcv.background = 0;
  657.       gcv.foreground = 1;
  658.       gc = XCreateGC (dpy, shallow, GCFunction|GCForeground|GCBackground,
  659.               &gcv);
  660.       XPutImage (dpy, shallow, gc, ximage, 0, 0, 0, 0, width, height);
  661.       XFreeGC (dpy, gc);
  662.  
  663.       gcv.function = GXcopy;
  664.       gcv.background = transparent_color;
  665.       gcv.foreground = foreground_color;
  666.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCBackground,
  667.               &gcv);
  668.       XCopyPlane (dpy, shallow, pixmap, gc, 0, 0, width, height, 0, 0, 1L);
  669.       XFreePixmap (dpy, shallow);
  670.       XFreeGC (dpy, gc);
  671.       /* No need for a mask in this case - the coloring is done. */
  672.       mask_data = 0;
  673.     }
  674.   else
  675.     {
  676.       /* Both the screen and pixmap are of the same depth.
  677.        */
  678.       pixmap = XCreatePixmap (dpy, window, width, height,
  679.                   (data == mono_data ? 1 : visual_depth));
  680.  
  681.       if (visual_depth == 1 && WhitePixelOfScreen (screen) == 1)
  682.     /* A server with backwards WhitePixel, like NCD... */
  683.     gcv.function = GXcopyInverted;
  684.       else
  685.     gcv.function = GXcopy;
  686.  
  687.       gcv.background = transparent_color;
  688.       gcv.foreground = foreground_color;
  689.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCBackground, &gcv);
  690.       XPutImage (dpy, pixmap, gc, ximage, 0, 0, 0, 0, width, height);
  691.       XFreeGC (dpy, gc);
  692.     }
  693.  
  694.   ximage->data = 0;
  695.   XDestroyImage (ximage);
  696.   if (free_data)
  697.     free (data);
  698.  
  699.   /* Optimization: if the mask is all 1's, don't bother sending it. */
  700.   if (mask_data)
  701.     {
  702.       int max = width * height / 8;
  703.       for (i = 0; i < max; i++)
  704.     if (mask_data [i] != 0xFF)
  705.       break;
  706.       if (i == max)
  707.     mask_data = 0;
  708.     }
  709.  
  710.   /* Fill the "transparent" areas with the background color. */
  711.   if (mask_data)
  712.     {
  713.       ximage = XCreateImage (dpy, v, 1, XYPixmap,
  714.                  0,                   /* offset */
  715.                  (char *) mask_data, width, height,
  716.                  8,                   /* bitmap_pad */
  717.                  0);
  718.       /* This ordering is implicit in the data in icondata.h, which is
  719.      the same implicit ordering as in all XBM files.  I think. */
  720.       ximage->byte_order = LSBFirst;
  721.       ximage->bitmap_bit_order = LSBFirst;
  722.  
  723.       mask_pixmap = XCreatePixmap (dpy, window, width, height, 1);
  724.  
  725.       gcv.function = GXcopy;
  726.       gc = XCreateGC (dpy, mask_pixmap, GCFunction, &gcv);
  727.       XPutImage (dpy, mask_pixmap, gc, ximage, 0, 0, 0, 0, width, height);
  728.       XFreeGC (dpy, gc);
  729.       ximage->data = 0;
  730.       XDestroyImage (ximage);
  731.  
  732.       if (! hack_mask_and_cmap_p)
  733.     {
  734.       /* Create a pixmap of the mask, inverted. */
  735.       Pixmap inverted_mask_pixmap =
  736.         XCreatePixmap (dpy, window, width, height, 1);
  737.       gcv.function = GXcopyInverted;
  738.       gc = XCreateGC (dpy, inverted_mask_pixmap, GCFunction, &gcv);
  739.       XCopyArea (dpy, mask_pixmap, inverted_mask_pixmap, gc,
  740.              0, 0, width, height, 0, 0);
  741.       XFreeGC (dpy, gc);
  742.  
  743.       /* Fill the background color through that inverted mask. */
  744.       gcv.function = GXcopy;
  745.       gcv.foreground = transparent_color;
  746.       gcv.clip_mask = inverted_mask_pixmap;
  747.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCClipMask,
  748.               &gcv);
  749.       XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
  750.       XFreeGC (dpy, gc);
  751.  
  752.       XFreePixmap (dpy, inverted_mask_pixmap);
  753.     }
  754.     }
  755.  
  756.   result->pixmap = pixmap;
  757.   result->mask = mask_pixmap;
  758.   result->width = width;
  759.   result->height = height;
  760.  
  761.   if (name)
  762.     {
  763.       free(mono_data);
  764.       free(color_data);
  765.       free(mask_data);
  766.     }
  767. }
  768.  
  769. void
  770. fe_MakeIcon(MWContext *context, Pixel transparent_color, fe_icon* result,
  771.         char *name,
  772.         int width, int height,
  773.         unsigned char *mono_data,
  774.         unsigned char *color_data,
  775.         unsigned char *mask_data,
  776.         Boolean hack_mask_and_cmap_p)
  777. {
  778.   Widget widget = CONTEXT_WIDGET (context);
  779.   Display *dpy = XtDisplay (widget);
  780.   Screen *screen;
  781.   Window window;
  782.   Visual *v = 0;
  783.   Colormap cmap = 0;
  784.   Cardinal visual_depth = 0;
  785.   Cardinal pixmap_depth = 0;
  786.   unsigned char *data;
  787.   Boolean free_data = False;
  788.   XImage *ximage;
  789.   Pixmap pixmap = 0;
  790.   Pixmap mask_pixmap = 0;
  791.   XGCValues gcv;
  792.   GC gc;
  793.   int i;
  794.  
  795.   if (result->pixmap) return;    /* Already done. */
  796.  
  797.   if (name) fe_get_external_icon(dpy, &name, &width, &height, &mono_data,
  798.     &color_data, &mask_data);
  799.  
  800.   XtVaGetValues (widget, XtNvisual, &v, XtNcolormap, &cmap,
  801.          XtNscreen, &screen, XtNdepth, &visual_depth, 0);
  802.  
  803.   if (hack_mask_and_cmap_p)
  804.     {
  805.       v = DefaultVisualOfScreen (screen);
  806.       cmap = DefaultColormapOfScreen (screen);
  807.       visual_depth = fe_VisualDepth (dpy, v);
  808.     }
  809.  
  810. #ifdef OSF1
  811.     /***
  812.        This is a major hack. We hide a 4.4b9 problem here
  813.        For some reason, sometimes, XtVaGetValues returns a zero visual.
  814.        If this happens, we core dump. This hides the problem by getting the
  815.        visual straight from the X server. "DEC port team".
  816.     ****/
  817.     if( v == 0 ){
  818.        v = DefaultVisualOfScreen( screen );
  819.     }
  820. #endif
  821.  
  822.   window = RootWindowOfScreen (screen);
  823.   pixmap_depth = fe_VisualPixmapDepth (dpy, v);
  824.  
  825.   if (pixmap_depth == 1 || fe_globalData.force_mono_p)
  826.     {
  827.   MONO:
  828.       data = mono_data;
  829.     }
  830.   else
  831.     {
  832.       /* Remap the numbers in the data to match the colors we allocated.
  833.      We need to copy it since the string might not be writable.
  834.      Also, the data is 8 deep - we might need to deepen it if we're
  835.      on a deeper visual.
  836.        */
  837.       unsigned char  *data8  = 0;
  838.       unsigned short *data16 = 0;
  839.       unsigned char  *data24 = 0;
  840.       unsigned int   *data32 = 0;
  841.       unsigned long  *data64 = 0;
  842.  
  843.       if (pixmap_depth == 8)
  844.     {
  845.       data8 = (unsigned char *) malloc (width * height);
  846.       data  = (unsigned char *) data8;
  847.     }
  848.       else if (pixmap_depth == 16)
  849.     {
  850.       data16 = (unsigned short *) malloc (width * height * 2);
  851.       data   = (unsigned char *) data16;
  852.     }
  853.       else if (pixmap_depth == 24)
  854.        {
  855.          data24 = (unsigned char *) malloc (width * height * 3);
  856.          data   = (unsigned char *) data24;
  857.        }
  858.       else if (pixmap_depth == 32)
  859.     {
  860.       data32 = (unsigned int *) malloc (width * height * 4);
  861.       data   = (unsigned char *) data32;
  862.     }
  863.       else if (pixmap_depth == 64)
  864.     {
  865.       data64 = (unsigned long *) malloc (width * height * 8);
  866.       data   = (unsigned char *) data64;
  867.     }
  868.       else
  869.     {
  870.       /* Oh great, a goofy depth. */
  871.       goto MONO;
  872.     }
  873.  
  874.       free_data = True;
  875.  
  876.       if (!hack_mask_and_cmap_p)
  877.     {
  878.       if (pixmap_depth == 8)
  879.         for (i = 0; i < (width * height); i++)
  880.           data8  [i] = fe_icon_pixels [color_data [i]];
  881.       else if (pixmap_depth == 16)
  882.         for (i = 0; i < (width * height); i++)
  883.           data16 [i] = fe_icon_pixels [color_data [i]];
  884.          else if (pixmap_depth == 24)
  885.            for (i = 0; i < (width * height); i++){
  886.               unsigned int i3 = i + (i << 1);
  887.               unsigned char *color24 = (unsigned char *)(fe_icon_pixels+color_data [i]);
  888.              data24 [i3++] = *color24++;
  889.              data24 [i3++] = *color24++;
  890.              data24 [i3++] = *color24++;
  891.             }
  892.       else if (pixmap_depth == 32)
  893.         for (i = 0; i < (width * height); i++)
  894.           data32 [i] = fe_icon_pixels [color_data [i]];
  895.       else if (pixmap_depth == 64)
  896.         for (i = 0; i < (width * height); i++)
  897.           data64 [i] = fe_icon_pixels [color_data [i]];
  898.       else
  899.         abort ();
  900.     }
  901.       else
  902.     {
  903.       /* The hack_mask_and_cmap_p flag means that these colors need to come
  904.          out of the default colormap, not the window's colormap, since this
  905.          is an icon for the desktop.  So, go through the image, find the
  906.          colors that are in it, and duplicate them.
  907.        */
  908.       char color_duped [255];
  909.       Pixel new_pixels [255];
  910.       memset (color_duped, 0, sizeof (color_duped));
  911.       memset (new_pixels, ~0, sizeof (new_pixels));
  912.       for (i = 0; i < (width * height); i++)
  913.         {
  914.           if (!color_duped [color_data [i]])
  915.         {
  916.           XColor color;
  917.                   fe_colormap *colormap = fe_globalData.default_colormap;
  918.           color.red   = fe_icon_colors [color_data [i]][0];
  919.           color.green = fe_icon_colors [color_data [i]][1];
  920.           color.blue  = fe_icon_colors [color_data [i]][2];
  921.                   if (!fe_AllocColor (colormap, &color))
  922.                       fe_AllocClosestColor (colormap, &color);
  923.           new_pixels [color_data [i]] = color.pixel;
  924.           color_duped [color_data [i]] = 1;
  925.         }
  926.               switch(pixmap_depth){
  927.               case 8:
  928.                data8  [i] = new_pixels [color_data [i]];
  929.                 break;
  930.               case 16:
  931.                data16 [i] = new_pixels [color_data [i]];
  932.                 break;
  933.               case 24:
  934.                 {
  935.                 unsigned int i3 = i + (i << 1);
  936.                 unsigned char *color24 = (unsigned char *)(new_pixels+color_data [i]);
  937.                data24 [i3++] = *color24++;
  938.                data24 [i3++] = *color24++;
  939.                data24 [i3++] = *color24++;
  940.                 }
  941.                 break;
  942.               case 32:
  943.                data32 [i] = new_pixels [color_data [i]];
  944.                 break;
  945.               case 64:
  946.                data64 [i] = new_pixels [color_data [i]];
  947.                 break;
  948.               default:
  949.                abort ();
  950.               }
  951.         }
  952.     }
  953.     }
  954.  
  955.   ximage = XCreateImage (dpy, v,
  956.              (data == mono_data ? 1 : visual_depth),
  957.              (data == mono_data ? XYPixmap : ZPixmap),
  958.              0,                   /* offset */
  959.              (char *) data, width, height,
  960.              8,                   /* bitmap_pad */
  961.              0);
  962.   if (data == mono_data)
  963.     {
  964.       /* This ordering is implicit in the data in icondata.h, which is
  965.      the same implicit ordering as in all XBM files.  I think. */
  966.       ximage->bitmap_bit_order = LSBFirst;
  967.       ximage->byte_order = LSBFirst;
  968.     }
  969.   else
  970.     {
  971. #if defined(IS_LITTLE_ENDIAN)
  972.       ximage->byte_order = LSBFirst;
  973. #elif defined (IS_BIG_ENDIAN)
  974.       ximage->byte_order = MSBFirst;
  975. #else
  976.   ERROR! Endianness is unknown.
  977. #endif
  978.     }
  979.  
  980.   if (data == mono_data && visual_depth != 1 && !hack_mask_and_cmap_p)
  981.     {
  982.       /* If we're in mono-mode, and the screen is not of depth 1,
  983.      deepen the pixmap. */
  984.       Pixmap shallow;
  985.       shallow = XCreatePixmap (dpy, window, width, height, 1);
  986.       pixmap  = XCreatePixmap (dpy, window, width, height, pixmap_depth);
  987.       gcv.function = GXcopy;
  988.       gcv.background = 0;
  989.       gcv.foreground = 1;
  990.       gc = XCreateGC (dpy, shallow, GCFunction|GCForeground|GCBackground,
  991.               &gcv);
  992.       XPutImage (dpy, shallow, gc, ximage, 0, 0, 0, 0, width, height);
  993.       XFreeGC (dpy, gc);
  994.  
  995.       gcv.function = GXcopy;
  996.       gcv.background = transparent_color;
  997.       gcv.foreground = CONTEXT_DATA (context)->fg_pixel;
  998.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCBackground,
  999.               &gcv);
  1000.       XCopyPlane (dpy, shallow, pixmap, gc, 0, 0, width, height, 0, 0, 1L);
  1001.       XFreePixmap (dpy, shallow);
  1002.       XFreeGC (dpy, gc);
  1003.       /* No need for a mask in this case - the coloring is done. */
  1004.       mask_data = 0;
  1005.     }
  1006.   else
  1007.     {
  1008.       /* Both the screen and pixmap are of the same depth.
  1009.        */
  1010.       pixmap = XCreatePixmap (dpy, window, width, height,
  1011.                   (data == mono_data ? 1 : visual_depth));
  1012.  
  1013.       if (visual_depth == 1 && WhitePixelOfScreen (screen) == 1)
  1014.     /* A server with backwards WhitePixel, like NCD... */
  1015.     gcv.function = GXcopyInverted;
  1016.       else
  1017.     gcv.function = GXcopy;
  1018.  
  1019.       gcv.background = transparent_color;
  1020.       gcv.foreground = CONTEXT_DATA (context)->fg_pixel;
  1021.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCBackground, &gcv);
  1022.       XPutImage (dpy, pixmap, gc, ximage, 0, 0, 0, 0, width, height);
  1023.       XFreeGC (dpy, gc);
  1024.     }
  1025.  
  1026.   ximage->data = 0;
  1027.   XDestroyImage (ximage);
  1028.   if (free_data)
  1029.     free (data);
  1030.  
  1031.   /* Optimization: if the mask is all 1's, don't bother sending it. */
  1032.   if (mask_data)
  1033.     {
  1034.       int max = width * height / 8;
  1035.       for (i = 0; i < max; i++)
  1036.     if (mask_data [i] != 0xFF)
  1037.       break;
  1038.       if (i == max)
  1039.     mask_data = 0;
  1040.     }
  1041.  
  1042.   /* Fill the "transparent" areas with the background color. */
  1043.   if (mask_data)
  1044.     {
  1045.       ximage = XCreateImage (dpy, v, 1, XYPixmap,
  1046.                  0,                   /* offset */
  1047.                  (char *) mask_data, width, height,
  1048.                  8,                   /* bitmap_pad */
  1049.                  0);
  1050.       /* This ordering is implicit in the data in icondata.h, which is
  1051.      the same implicit ordering as in all XBM files.  I think. */
  1052.       ximage->byte_order = LSBFirst;
  1053.       ximage->bitmap_bit_order = LSBFirst;
  1054.  
  1055.       mask_pixmap = XCreatePixmap (dpy, window, width, height, 1);
  1056.  
  1057.       gcv.function = GXcopy;
  1058.       gc = XCreateGC (dpy, mask_pixmap, GCFunction, &gcv);
  1059.       XPutImage (dpy, mask_pixmap, gc, ximage, 0, 0, 0, 0, width, height);
  1060.       XFreeGC (dpy, gc);
  1061.       ximage->data = 0;
  1062.       XDestroyImage (ximage);
  1063.  
  1064.       if (! hack_mask_and_cmap_p)
  1065.     {
  1066.       /* Create a pixmap of the mask, inverted. */
  1067.       Pixmap inverted_mask_pixmap =
  1068.         XCreatePixmap (dpy, window, width, height, 1);
  1069.       gcv.function = GXcopyInverted;
  1070.       gc = XCreateGC (dpy, inverted_mask_pixmap, GCFunction, &gcv);
  1071.       XCopyArea (dpy, mask_pixmap, inverted_mask_pixmap, gc,
  1072.              0, 0, width, height, 0, 0);
  1073.       XFreeGC (dpy, gc);
  1074.  
  1075.       /* Fill the background color through that inverted mask. */
  1076.       gcv.function = GXcopy;
  1077.       gcv.foreground = transparent_color;
  1078.       gcv.clip_mask = inverted_mask_pixmap;
  1079.       gc = XCreateGC (dpy, pixmap, GCFunction|GCForeground|GCClipMask,
  1080.               &gcv);
  1081.       XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
  1082.       XFreeGC (dpy, gc);
  1083.  
  1084.       XFreePixmap (dpy, inverted_mask_pixmap);
  1085.     }
  1086.     }
  1087.  
  1088.   result->pixmap = pixmap;
  1089.   result->mask = mask_pixmap;
  1090.   result->width = width;
  1091.   result->height = height;
  1092.  
  1093.   if (name)
  1094.     {
  1095.       free(mono_data);
  1096.       free(color_data);
  1097.       free(mask_data);
  1098.     }
  1099. }
  1100.  
  1101.  
  1102. static void
  1103. fe_make_icon_1 (MWContext *context, Pixel transparent_color, int id,
  1104.         char *name,
  1105.         int width, int height,
  1106.         unsigned char *mono_data,
  1107.         unsigned char *color_data,
  1108.         unsigned char *mask_data,
  1109.         Boolean hack_mask_and_cmap_p)
  1110. {
  1111.   fe_MakeIcon(context, transparent_color, fe_icons + id, name, width, height,
  1112.           mono_data, color_data, mask_data, hack_mask_and_cmap_p);
  1113. }
  1114.  
  1115.  
  1116. static void
  1117. fe_make_icon (MWContext *context, Pixel transparent_color, int id,
  1118.           char *name,
  1119.           int width, int height,
  1120.           unsigned char *mono_data,
  1121.           unsigned char *color_data,
  1122.           unsigned char *mask_data)
  1123. {
  1124.   fe_make_icon_1 (context, transparent_color, id, name, width, height,
  1125.           mono_data, color_data, mask_data, False);
  1126. }
  1127.  
  1128.  
  1129. static void
  1130. fe_new_init_security_icons (Widget widget)
  1131. {
  1132. #ifndef NO_SECURITY
  1133.   Pixel fg = 0;
  1134.   Pixel bg = 0;
  1135.  
  1136.   XtVaGetValues (widget, XmNbackground, &bg, 0);
  1137.   XtVaGetValues (widget, XmNforeground, &fg, 0);
  1138.  
  1139.   fe_NewMakeIcon (widget, fg, bg, &fe_icons[IL_IMAGE_INSECURE],
  1140.           NULL,
  1141.           SEC_Replace.width, SEC_Replace.height,
  1142.           SEC_Replace.mono_bits, SEC_Replace.color_bits, SEC_Replace.mask_bits,
  1143.           FALSE);
  1144.  
  1145. #endif
  1146. }
  1147.  
  1148. static void
  1149. fe_init_document_icons (MWContext *c)
  1150. {
  1151.   Pixel bg, bg2, white;
  1152.   static Bool done = False;
  1153.   Boolean save;
  1154.  
  1155.   if (done) return;
  1156.   done = True;
  1157.  
  1158.   bg = CONTEXT_DATA (c)->default_bg_pixel;
  1159.   white = WhitePixelOfScreen (XtScreen (CONTEXT_WIDGET (c)));
  1160.  
  1161.   fe_make_icon (c, bg, IL_IMAGE_DELAYED,
  1162.         NULL,
  1163.         IReplace.width, IReplace.height,
  1164.         IReplace.mono_bits, IReplace.color_bits, IReplace.mask_bits);
  1165.   fe_make_icon (c, bg, IL_IMAGE_NOT_FOUND,
  1166.         NULL,
  1167.         IconUnknown.width, IconUnknown.height,
  1168.         IconUnknown.mono_bits, IconUnknown.color_bits, IconUnknown.mask_bits);
  1169.   fe_make_icon (c, bg, IL_IMAGE_BAD_DATA,
  1170.         NULL,
  1171.         IBad.width, IBad.height,
  1172.         IBad.mono_bits, IBad.color_bits, IBad.mask_bits);
  1173.   fe_make_icon (c, bg, IL_IMAGE_EMBED,    /* #### Need an XPM for this one */
  1174.         NULL,
  1175.         IconUnknown.width, IconUnknown.height,
  1176.         IconUnknown.mono_bits, IconUnknown.color_bits, IconUnknown.mask_bits);
  1177. #ifndef NO_SECURITY
  1178.   fe_make_icon (c, bg, IL_IMAGE_INSECURE,
  1179.         NULL,
  1180.         SEC_Replace.width, SEC_Replace.height,
  1181.         SEC_Replace.mono_bits, SEC_Replace.color_bits, SEC_Replace.mask_bits);
  1182.  
  1183.   bg2 = bg;
  1184.   if (CONTEXT_DATA(c)->dashboard) {
  1185.    /* XXX need to find why we do this - dp */
  1186.     XtVaGetValues (CONTEXT_DATA (c)->dashboard, XmNbackground, &bg2, 0);
  1187.   }
  1188. #endif
  1189.   /* Load all the desktop icons */
  1190.   save = fe_globalData.force_mono_p; /* hack. hack, hack */
  1191.   if (XP_STRCASECMP(fe_globalData.wm_icon_policy, "mono") == 0)
  1192.       fe_globalData.force_mono_p = TRUE;
  1193.  
  1194.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_NAVIGATOR,    /* Navigator */
  1195.           NULL,
  1196.           Desk_Navigator.width, Desk_Navigator.height,
  1197.           Desk_Navigator.mono_bits, Desk_Navigator.color_bits,
  1198.           Desk_Navigator.mask_bits,
  1199.           True);
  1200.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_MSGCENTER,    /* Message Center */
  1201.           NULL,
  1202.           Desk_MsgCenter.width, Desk_MsgCenter.height,
  1203.           Desk_MsgCenter.mono_bits, Desk_MsgCenter.color_bits,
  1204.           Desk_MsgCenter.mask_bits,
  1205.           True);
  1206.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_ABOOK,    /* AddressBook */
  1207.           NULL,
  1208.           Desk_Address.width, Desk_Address.height,
  1209.           Desk_Address.mono_bits, Desk_Address.color_bits,
  1210.           Desk_Address.mask_bits, True);
  1211.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_BOOKMARK,    /* Bookmark */
  1212.           NULL,
  1213.           Desk_Bookmark.width, Desk_Bookmark.height,
  1214.           Desk_Bookmark.mono_bits, Desk_Bookmark.color_bits,
  1215.           Desk_Bookmark.mask_bits, True);
  1216.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_NOMAIL,    /* No new mail */
  1217.           NULL,
  1218.           Desk_Messenger.width, Desk_Messenger.height,
  1219.           Desk_Messenger.mono_bits, Desk_Messenger.color_bits,
  1220.           Desk_Messenger.mask_bits, True);
  1221.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_YESMAIL,    /* New mail */
  1222.           NULL,
  1223.           Desk_NewMail.width, Desk_NewMail.height,
  1224.           Desk_NewMail.mono_bits, Desk_NewMail.color_bits,
  1225.           Desk_NewMail.mask_bits, True);
  1226.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_NEWS,    /* News */
  1227.           NULL,
  1228.           Desk_Collabra.width, Desk_Collabra.height,
  1229.           Desk_Collabra.mono_bits, Desk_Collabra.color_bits, 
  1230.           Desk_Collabra.mask_bits, True);
  1231.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_MSGCOMPOSE,    /* Message Compose */
  1232.           NULL,
  1233.           Desk_MsgCompose.width, Desk_MsgCompose.height,
  1234.           Desk_MsgCompose.mono_bits, Desk_MsgCompose.color_bits,
  1235.           Desk_MsgCompose.mask_bits, True);
  1236. #ifdef EDITOR
  1237.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_EDITOR,    /* Editor */
  1238.           NULL,
  1239.           Desk_Composer.width, Desk_Composer.height,
  1240.           Desk_Composer.mono_bits, Desk_Composer.color_bits,
  1241.           Desk_Composer.mask_bits, True);
  1242. #endif /*EDITOR*/
  1243.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_COMMUNICATOR,    /* Communicator */
  1244.           NULL,
  1245.           Desk_Communicator.width, Desk_Communicator.height,
  1246.           Desk_Communicator.mono_bits, Desk_Communicator.color_bits,
  1247.           Desk_Communicator.mask_bits,
  1248.           True);
  1249.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_HISTORY,    /* History */
  1250.           NULL,
  1251.           Desk_History.width, Desk_History.height,
  1252.           Desk_History.mono_bits, Desk_History.color_bits,
  1253.           Desk_History.mask_bits,
  1254.           True);
  1255.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_SEARCH,    /* Search */
  1256.           NULL,
  1257.           Desk_Search.width, Desk_Search.height,
  1258.           Desk_Search.mono_bits, Desk_Search.color_bits,
  1259.           Desk_Search.mask_bits,
  1260.           True);
  1261. #ifdef NETSCAPE_PRIV
  1262. #ifdef JAVA
  1263.   fe_make_icon_1 (c, white, IL_ICON_DESKTOP_JAVACONSOLE,    /* Java Console */
  1264.           NULL,
  1265.           Desk_JavaConsole.width, Desk_JavaConsole.height,
  1266.           Desk_JavaConsole.mono_bits, Desk_JavaConsole.color_bits,
  1267.           Desk_JavaConsole.mask_bits,
  1268.           True);
  1269. #endif /* JAVA */
  1270.   fe_globalData.force_mono_p = save;
  1271. #endif /* NETSCAPE_PRIV */
  1272. }
  1273.  
  1274. static void
  1275. fe_init_gopher_icons (MWContext *c)
  1276. {
  1277.   Pixel bg;
  1278.   static Bool done = False;
  1279.  
  1280.   if (done) return;
  1281.   done = True;
  1282.  
  1283.   bg = CONTEXT_DATA (c)->default_bg_pixel;
  1284.  
  1285.   fe_make_icon (c, bg, IL_GOPHER_TEXT,
  1286.         NULL,
  1287.         GText.width, GText.height,
  1288.         GText.mono_bits, GText.color_bits, GText.mask_bits);
  1289.   fe_make_icon (c, bg, IL_GOPHER_IMAGE,
  1290.         NULL,
  1291.         GImage.width, GImage.height,
  1292.         GImage.mono_bits, GImage.color_bits, GImage.mask_bits);
  1293.   fe_make_icon (c, bg, IL_GOPHER_BINARY,
  1294.         NULL,
  1295.         GBinary.width, GBinary.height,
  1296.         GBinary.mono_bits, GBinary.color_bits, GBinary.mask_bits);
  1297.   fe_make_icon (c, bg, IL_GOPHER_SOUND,
  1298.         NULL,
  1299.         GAudio.width, GAudio.height,
  1300.         GAudio.mono_bits, GAudio.color_bits, GAudio.mask_bits);
  1301.   fe_make_icon (c, bg, IL_GOPHER_MOVIE,
  1302.         NULL,
  1303.         GMovie.width, GMovie.height,
  1304.         GMovie.mono_bits, GMovie.color_bits, GMovie.mask_bits);
  1305.   fe_make_icon (c, bg, IL_GOPHER_FOLDER,
  1306.         NULL,
  1307.         GFolder.width, GFolder.height,
  1308.         GFolder.mono_bits, GFolder.color_bits, GFolder.mask_bits);
  1309.   fe_make_icon (c, bg, IL_GOPHER_SEARCHABLE,
  1310.         NULL,
  1311.         GFind.width, GFind.height,
  1312.         GFind.mono_bits, GFind.color_bits, GFind.mask_bits);
  1313.   fe_make_icon (c, bg, IL_GOPHER_TELNET,
  1314.         NULL,
  1315.         GTelnet.width, GTelnet.height,
  1316.         GTelnet.mono_bits, GTelnet.color_bits, GTelnet.mask_bits);
  1317.   fe_make_icon (c, bg, IL_GOPHER_UNKNOWN,
  1318.         NULL,
  1319.         GUnknown.width, GUnknown.height,
  1320.         GUnknown.mono_bits, GUnknown.color_bits, GUnknown.mask_bits);
  1321. }
  1322.  
  1323. #ifdef EDITOR
  1324.  
  1325. #if 0
  1326. static void
  1327. fe_init_editor_icons_notext(MWContext* c)
  1328. {
  1329.   Pixel  bg2 = 0;
  1330.   static Bool done = False;
  1331.  
  1332.   if (done)
  1333.     return;
  1334.  
  1335.   XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg2, 0);
  1336.  
  1337.   fe_make_icon (c, bg2, IL_EDITOR_NEW,        /* 23FEB96RCJ */
  1338.         "ed_new",
  1339.         ed_new.width, ed_new.height,
  1340.         ed_new.mono_bits, ed_new.color_bits, ed_new.mask_bits);
  1341.   fe_make_icon (c, bg2, IL_EDITOR_NEW_GREY,        /* 23FEB96RCJ */
  1342.         "ed_new.i",
  1343.         ed_new_i.width, ed_new_i.height,
  1344.         ed_new_i.mono_bits, ed_new_i.color_bits, ed_new_i.mask_bits);
  1345.   fe_make_icon (c, bg2, IL_EDITOR_OPEN,
  1346.         "ed_open",
  1347.         ed_open.width, ed_open.height,
  1348.         ed_open.mono_bits, ed_open.color_bits, ed_open.mask_bits);
  1349.   fe_make_icon (c, bg2, IL_EDITOR_OPEN_GREY,
  1350.         "ed_open.i",
  1351.         ed_open_i.width, ed_open_i.height,
  1352.         ed_open_i.mono_bits, ed_open_i.color_bits, ed_open_i.mask_bits);
  1353.   fe_make_icon (c, bg2, IL_EDITOR_SAVE,    
  1354.         "ed_save",
  1355.         ed_save.width, ed_save.height,
  1356.         ed_save.mono_bits, ed_save.color_bits, ed_save.mask_bits);
  1357.   fe_make_icon (c, bg2, IL_EDITOR_SAVE_GREY,
  1358.         "ed_save.i",
  1359.         ed_save_i.width, ed_save_i.height,
  1360.         ed_save_i.mono_bits, ed_save_i.color_bits, ed_save_i.mask_bits);
  1361.   fe_make_icon (c, bg2, IL_EDITOR_BROWSE,    
  1362.         "ed_browse",
  1363.         ed_browse.width, ed_browse.height,
  1364.         ed_browse.mono_bits, ed_browse.color_bits, ed_browse.mask_bits);
  1365.   fe_make_icon (c, bg2, IL_EDITOR_BROWSE_GREY,
  1366.         "ed_browse.i",
  1367.         ed_browse_i.width, ed_browse_i.height,
  1368.         ed_browse_i.mono_bits, ed_browse_i.color_bits, ed_browse_i.mask_bits);
  1369.   fe_make_icon (c, bg2, IL_EDITOR_CUT,
  1370.         "ed_cut",
  1371.         ed_cut.width, ed_cut.height,
  1372.         ed_cut.mono_bits, ed_cut.color_bits, ed_cut.mask_bits);
  1373.   fe_make_icon (c, bg2, IL_EDITOR_CUT_GREY,
  1374.         "ed_cut.i",
  1375.         ed_cut_i.width, ed_cut_i.height,
  1376.         ed_cut_i.mono_bits, ed_cut_i.color_bits, ed_cut_i.mask_bits);
  1377.   fe_make_icon (c, bg2, IL_EDITOR_COPY,
  1378.         "ed_copy",
  1379.         ed_copy.width, ed_copy.height,
  1380.         ed_copy.mono_bits, ed_copy.color_bits, ed_copy.mask_bits);
  1381.   fe_make_icon (c, bg2, IL_EDITOR_COPY_GREY,
  1382.         "ed_copy.i",
  1383.         ed_copy_i.width, ed_copy_i.height,
  1384.         ed_copy_i.mono_bits, ed_copy_i.color_bits, ed_copy_i.mask_bits);
  1385.   fe_make_icon (c, bg2, IL_EDITOR_PASTE,
  1386.         "ed_paste",
  1387.         ed_paste.width, ed_paste.height,
  1388.         ed_paste.mono_bits, ed_paste.color_bits, ed_paste.mask_bits);
  1389.   fe_make_icon (c, bg2, IL_EDITOR_PASTE_GREY,
  1390.         "ed_paste.i",
  1391.         ed_paste_i.width, ed_paste_i.height,
  1392.         ed_paste_i.mono_bits, ed_paste_i.color_bits, ed_paste_i.mask_bits);
  1393.   fe_make_icon (c, bg2, IL_EDITOR_PRINT,
  1394.         "ed_print",
  1395.         ed_print.width, ed_print.height,
  1396.         ed_print.mono_bits, ed_print.color_bits, ed_print_i.mask_bits);
  1397.   fe_make_icon (c, bg2, IL_EDITOR_PRINT_GREY,
  1398.         "ed_print.i",
  1399.         ed_print_i.width, ed_print_i.height,
  1400.         ed_print_i.mono_bits, ed_print_i.color_bits, ed_print_i.mask_bits);
  1401.   fe_make_icon (c, bg2, IL_EDITOR_FIND,
  1402.         "ed_find",
  1403.         ed_find.width, ed_find.height,
  1404.         ed_find.mono_bits, ed_find.color_bits, ed_find.mask_bits);
  1405.   fe_make_icon (c, bg2, IL_EDITOR_FIND_GREY,
  1406.         "ed_find.i",
  1407.         ed_find_i.width, ed_find_i.height,
  1408.         ed_find_i.mono_bits, ed_find_i.color_bits, ed_find_i.mask_bits);
  1409.   fe_make_icon (c, bg2, IL_EDITOR_PUBLISH,
  1410.         "ed_publish",
  1411.         ed_publish.width, ed_publish.height, 
  1412.         ed_publish.mono_bits, ed_publish.color_bits, ed_publish.mask_bits); 
  1413.   fe_make_icon (c, bg2, IL_EDITOR_PUBLISH_GREY,
  1414.         "ed_publish.i",
  1415.         ed_publish_i.width, ed_publish_i.height, 
  1416.         ed_publish_i.mono_bits, ed_publish_i.color_bits, ed_publish_i.mask_bits); 
  1417.   
  1418.   fe_make_icon (c, bg2, IL_ICON_BACK_GREY,
  1419.         NULL,
  1420.         TB_Back_i.width, TB_Back_i.height,
  1421.         TB_Back_i.mono_bits, TB_Back_i.color_bits,
  1422.                 TB_Back_i.mask_bits);
  1423.   fe_make_icon (c, bg2, IL_ICON_LOAD_GREY,
  1424.         NULL,
  1425.         TB_LoadImages_i.width, TB_LoadImages_i.height,
  1426.         TB_LoadImages_i.mono_bits, TB_LoadImages_i.color_bits,
  1427.         TB_LoadImages_i.mask_bits);
  1428.   fe_make_icon (c, bg2, IL_ICON_FWD_GREY,
  1429.         NULL,
  1430.         TB_Forward_i.width, TB_Forward_i.height,
  1431.         TB_Forward_i.mono_bits, TB_Forward_i.color_bits,
  1432.                 TB_Forward_i.mask_bits);
  1433.   fe_make_icon (c, bg2, IL_ICON_STOP_GREY,
  1434.         NULL,
  1435.         TB_Stop_i.width, TB_Stop_i.height,
  1436.         TB_Stop_i.mono_bits, TB_Stop_i.color_bits, TB_Stop_i.mask_bits);
  1437.   done = True;
  1438. }
  1439. #endif /*0*/
  1440.  
  1441. static void fe_init_align_icons(MWContext* c) /* added 14MAR96RCJ */
  1442. {
  1443.   Pixel  bg2 = 0;
  1444.  
  1445.   XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg2, 0);
  1446.  
  1447.   fe_make_icon (c, bg2, IL_ALIGN4_RAISED,
  1448.         "ImgB2B_r",
  1449.         ImgB2B_r.width, ImgB2B_r.height,
  1450.         ImgB2B_r.mono_bits, ImgB2B_r.color_bits, ImgB2B_r.mask_bits);
  1451.  
  1452.   fe_make_icon (c, bg2, IL_ALIGN5_RAISED,
  1453.         "ImgB2D_r",
  1454.         ImgB2D_r.width, ImgB2D_r.height,
  1455.         ImgB2D_r.mono_bits, ImgB2D_r.color_bits, ImgB2D_r.mask_bits);
  1456.  
  1457.   fe_make_icon (c, bg2, IL_ALIGN3_RAISED,
  1458.         "ImgC2B_r",
  1459.         ImgC2B_r.width, ImgC2B_r.height,
  1460.         ImgC2B_r.mono_bits, ImgC2B_r.color_bits, ImgC2B_r.mask_bits);
  1461.  
  1462.   fe_make_icon (c, bg2, IL_ALIGN2_RAISED,
  1463.         "ImgC2C_r",
  1464.         ImgC2C_r.width, ImgC2C_r.height,
  1465.         ImgC2C_r.mono_bits, ImgC2C_r.color_bits, ImgC2C_r.mask_bits);
  1466.  
  1467.   fe_make_icon (c, bg2, IL_ALIGN7_RAISED,
  1468.         "ImgWL_r",
  1469.         ImgWL_r.width, ImgWL_r.height,
  1470.         ImgWL_r.mono_bits, ImgWL_r.color_bits, ImgWL_r.mask_bits);
  1471.  
  1472.   fe_make_icon (c, bg2, IL_ALIGN6_RAISED,
  1473.         "ImgWR_r",
  1474.         ImgWR_r.width, ImgWR_r.height,
  1475.         ImgWR_r.mono_bits, ImgWR_r.color_bits, ImgWR_r.mask_bits);
  1476.  
  1477.   fe_make_icon (c, bg2, IL_ALIGN1_RAISED,
  1478.         "ImgT2T_r",
  1479.         ImgT2T_r.width, ImgT2T_r.height,
  1480.         ImgT2T_r.mono_bits, ImgT2T_r.color_bits, ImgT2T_r.mask_bits);
  1481.  
  1482. } /* end fe_init_align_icons 14MAR96RCJ */
  1483.  
  1484. static void
  1485. fe_init_editor_icons_withtext(MWContext* c)
  1486. {
  1487.   Pixel  bg2 = 0;
  1488.   static Bool done = False;
  1489.  
  1490.   if (done)
  1491.     return;
  1492.  
  1493.   XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg2, 0);
  1494. /*
  1495.   fe_make_icon (c, bg2, IL_EDITOR_NEW_PT,
  1496.         "ed_new.pt",
  1497.         ed_new_pt.width, ed_new_pt.height,
  1498.         ed_new_pt.mono_bits, ed_new_pt.color_bits,
  1499.                 ed_new_pt.mask_bits);
  1500.   fe_make_icon (c, bg2, IL_EDITOR_OPEN_PT,
  1501.         "ed_open.pt",
  1502.         ed_open_pt.width, ed_open_pt.height,
  1503.         ed_open_pt.mono_bits, ed_open_pt.color_bits,
  1504.                 ed_open_pt.mask_bits);
  1505.   fe_make_icon (c, bg2, IL_EDITOR_SAVE_PT,
  1506.         "ed_save.pt",
  1507.         ed_save_pt.width, ed_save_pt.height,
  1508.         ed_save_pt.mono_bits, ed_save_pt.color_bits,
  1509.                 ed_save_pt.mask_bits);
  1510.   fe_make_icon (c, bg2, IL_EDITOR_BROWSE_PT,
  1511.         "ed_browse.pt",
  1512.         ed_browse_pt.width, ed_browse_pt.height,
  1513.         ed_browse_pt.mono_bits, ed_browse_pt.color_bits,
  1514.                 ed_browse_pt.mask_bits);
  1515.   fe_make_icon (c, bg2, IL_EDITOR_CUT_PT,
  1516.         "ed_cut.pt",
  1517.         ed_cut_pt.width, ed_cut_pt.height,
  1518.         ed_cut_pt.mono_bits, ed_cut_pt.color_bits,
  1519.                 ed_cut_pt.mask_bits);
  1520.   fe_make_icon (c, bg2, IL_EDITOR_COPY_PT,
  1521.         "ed_copy.pt",
  1522.         ed_copy_pt.width, ed_copy_pt.height,
  1523.         ed_copy_pt.mono_bits, ed_copy_pt.color_bits,
  1524.                 ed_copy_pt.mask_bits);
  1525.   fe_make_icon (c, bg2, IL_EDITOR_PASTE_PT,
  1526.         "ed_paste.pt",
  1527.         ed_paste_pt.width, ed_paste_pt.height,
  1528.         ed_paste_pt.mono_bits, ed_paste_pt.color_bits,
  1529.                 ed_paste_pt.mask_bits);
  1530.   fe_make_icon (c, bg2, IL_EDITOR_PRINT_PT,
  1531.         "ed_print.pt",
  1532.         ed_print_pt.width, ed_print_pt.height,
  1533.         ed_print_pt.mono_bits, ed_print_pt.color_bits,
  1534.                 ed_print_pt.mask_bits);
  1535.   fe_make_icon (c, bg2, IL_EDITOR_FIND_PT,
  1536.         "ed_find.pt",
  1537.         ed_find_pt.width, ed_find_pt.height,
  1538.         ed_find_pt.mono_bits, ed_find_pt.color_bits,
  1539.                 ed_find_pt.mask_bits);
  1540.   fe_make_icon (c, bg2, IL_EDITOR_PUBLISH_PT,
  1541.         "ed_publish.pt",
  1542.         ed_publish_pt.width, ed_publish_pt.height, 
  1543.         ed_publish_pt.mono_bits, ed_publish_pt.color_bits,
  1544.                 ed_publish_pt.mask_bits); 
  1545.  
  1546.   fe_make_icon (c, bg2, IL_EDITOR_NEW_PT_GREY,
  1547.         "ed_new.pt",
  1548.         ed_new_pt_i.width, ed_new_pt_i.height,
  1549.         ed_new_pt_i.mono_bits, ed_new_pt_i.color_bits,
  1550.                 ed_new_pt_i.mask_bits);
  1551.   fe_make_icon (c, bg2, IL_EDITOR_OPEN_PT_GREY,
  1552.         "ed_open.pt",
  1553.         ed_open_pt_i.width, ed_open_pt_i.height,
  1554.         ed_open_pt_i.mono_bits, ed_open_pt_i.color_bits,
  1555.                 ed_open_pt_i.mask_bits);
  1556.   fe_make_icon (c, bg2, IL_EDITOR_SAVE_PT_GREY,
  1557.         "ed_save.pt",
  1558.         ed_save_pt_i.width, ed_save_pt_i.height,
  1559.         ed_save_pt_i.mono_bits, ed_save_pt_i.color_bits,
  1560.                 ed_save_pt_i.mask_bits);
  1561.   fe_make_icon (c, bg2, IL_EDITOR_BROWSE_PT_GREY,
  1562.         "ed_browse.pt",
  1563.         ed_browse_pt_i.width, ed_browse_pt_i.height,
  1564.         ed_browse_pt_i.mono_bits, ed_browse_pt_i.color_bits,
  1565.                 ed_browse_pt_i.mask_bits);
  1566.   fe_make_icon (c, bg2, IL_EDITOR_CUT_PT_GREY,
  1567.         "ed_cut.pt",
  1568.         ed_cut_pt_i.width, ed_cut_pt_i.height,
  1569.         ed_cut_pt_i.mono_bits, ed_cut_pt_i.color_bits,
  1570.                 ed_cut_pt_i.mask_bits);
  1571.   fe_make_icon (c, bg2, IL_EDITOR_COPY_PT_GREY,
  1572.         "ed_copy.pt",
  1573.         ed_copy_pt_i.width, ed_copy_pt_i.height,
  1574.         ed_copy_pt_i.mono_bits, ed_copy_pt_i.color_bits,
  1575.                 ed_copy_pt_i.mask_bits);
  1576.   fe_make_icon (c, bg2, IL_EDITOR_PASTE_PT_GREY,
  1577.         "ed_paste.pt",
  1578.         ed_paste_pt_i.width, ed_paste_pt_i.height,
  1579.         ed_paste_pt_i.mono_bits, ed_paste_pt_i.color_bits,
  1580.                 ed_paste_pt_i.mask_bits);
  1581.   fe_make_icon (c, bg2, IL_EDITOR_PRINT_PT_GREY,
  1582.         "ed_print.pt",
  1583.         ed_print_pt_i.width, ed_print_pt_i.height,
  1584.         ed_print_pt_i.mono_bits, ed_print_pt_i.color_bits,
  1585.                 ed_print_pt_i.mask_bits);
  1586.   fe_make_icon (c, bg2, IL_EDITOR_FIND_PT_GREY,
  1587.         "ed_find.pt",
  1588.         ed_find_pt_i.width, ed_find_pt_i.height,
  1589.         ed_find_pt_i.mono_bits, ed_find_pt_i.color_bits,
  1590.                 ed_find_pt_i.mask_bits);
  1591.   fe_make_icon (c, bg2, IL_EDITOR_PUBLISH_PT_GREY,
  1592.         "ed_publish.pt",
  1593.         ed_publish_pt_i.width, ed_publish_pt_i.height, 
  1594.         ed_publish_pt_i.mono_bits, ed_publish_pt_i.color_bits,
  1595.                 ed_publish_pt_i.mask_bits); 
  1596.   fe_make_icon (c, bg2, IL_ICON_BACK_GREY, 
  1597.         NULL, 
  1598.         TB_Back_i.width, TB_Back_i.height, 
  1599.         TB_Back_i.mono_bits, TB_Back_i.color_bits,
  1600.                 TB_Back_i.mask_bits); 
  1601.   fe_make_icon (c, bg2, IL_ICON_LOAD_GREY, 
  1602.         NULL, 
  1603.         TB_LoadImages_i.width, TB_LoadImages_i.height,
  1604.         TB_LoadImages_i.mono_bits, TB_LoadImages_i.color_bits,
  1605.         TB_LoadImages_i.mask_bits);
  1606.   fe_make_icon (c, bg2, IL_ICON_FWD_GREY,
  1607.         NULL,
  1608.         TB_Forward_i.width, TB_Forward_i.height,
  1609.         TB_Forward_i.mono_bits, TB_Forward_i.color_bits,
  1610.                 TB_Forward_i.mask_bits);
  1611.   fe_make_icon (c, bg2, IL_ICON_STOP_GREY,
  1612.         NULL,
  1613.         TB_Stop_i.width, TB_Stop_i.height,
  1614.         TB_Stop_i.mono_bits, TB_Stop_i.color_bits, TB_Stop_i.mask_bits);
  1615. */
  1616.   done = True;
  1617. }
  1618.  
  1619. static void
  1620. fe_init_editor_icons_other(MWContext* c)
  1621. {
  1622.   Pixel  bg2 = 0;
  1623.   static Bool done = False;
  1624.  
  1625.   if (done)
  1626.     return;
  1627.  
  1628.   XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg2, 0);
  1629.  
  1630.   done = True;
  1631. /*  
  1632.   fe_make_icon(c, bg2, IL_EDITOR_BOLD,
  1633.            "ed_bold",
  1634.            ed_bold.width, ed_bold.height,
  1635.            ed_bold.mono_bits, ed_bold.color_bits, ed_bold.mask_bits);
  1636.   fe_make_icon(c, bg2, IL_EDITOR_BULLET,
  1637.            "ed_bullet",
  1638.            ed_bullet.width, ed_bullet.height,
  1639.            ed_bullet.mono_bits, ed_bullet.color_bits, ed_bullet.mask_bits);
  1640.   fe_make_icon(c, bg2, IL_EDITOR_CENTER,
  1641.            "ed_center",
  1642.            ed_center.width, ed_center.height,
  1643.            ed_center.mono_bits, ed_center.color_bits, ed_center.mask_bits);
  1644.   fe_make_icon(c, bg2, IL_EDITOR_CLEAR,
  1645.            "ed_clear",
  1646.            ed_clear.width, ed_clear.height,
  1647.            ed_clear.mono_bits, ed_clear.color_bits, ed_clear.mask_bits);
  1648.   fe_make_icon(c, bg2, IL_EDITOR_COLOR,
  1649.            "ed_color",
  1650.            ed_color.width, ed_color.height,
  1651.            ed_color.mono_bits, ed_color.color_bits, ed_color.mask_bits);
  1652.   fe_make_icon(c, bg2, IL_EDITOR_FIXED,
  1653.            "ed_fixed",
  1654.            ed_fixed.width, ed_fixed.height,
  1655.            ed_fixed.mono_bits, ed_fixed.color_bits, ed_fixed.mask_bits);
  1656.   fe_make_icon(c, bg2, IL_EDITOR_GROW,
  1657.            "ed_grow",
  1658.            ed_grow.width, ed_grow.height,
  1659.            ed_grow.mono_bits, ed_grow.color_bits, ed_grow.mask_bits);
  1660.   fe_make_icon(c, bg2, IL_EDITOR_GROW_GREY,
  1661.            "ed_grow.i",
  1662.            ed_grow_i.width, ed_grow_i.height,
  1663.            ed_grow_i.mono_bits, ed_grow_i.color_bits, ed_grow_i.mask_bits);
  1664.   fe_make_icon(c, bg2, IL_EDITOR_HRULE,
  1665.            "ed_hrule",
  1666.            ed_hrule.width, ed_hrule.height,
  1667.            ed_hrule.mono_bits, ed_hrule.color_bits, ed_hrule.mask_bits);
  1668.   fe_make_icon(c, bg2, IL_EDITOR_IMAGE,
  1669.            "ed_image",
  1670.            ed_image.width, ed_image.height,
  1671.            ed_image.mono_bits, ed_image.color_bits, ed_image.mask_bits);
  1672.   fe_make_icon(c, bg2, IL_EDITOR_INDENT,
  1673.            "ed_indent",
  1674.            ed_indent.width, ed_indent.height,
  1675.            ed_indent.mono_bits, ed_indent.color_bits, ed_indent.mask_bits);
  1676.   fe_make_icon(c, bg2, IL_EDITOR_ITALIC,
  1677.            "ed_italic",
  1678.            ed_italic.width, ed_italic.height,
  1679.            ed_italic.mono_bits, ed_italic.color_bits, ed_italic.mask_bits);
  1680.   fe_make_icon(c, bg2, IL_EDITOR_LEFT,
  1681.            "ed_left",
  1682.            ed_left.width, ed_left.height,
  1683.            ed_left.mono_bits, ed_left.color_bits, ed_left.mask_bits);
  1684.   fe_make_icon(c, bg2, IL_EDITOR_LINK,
  1685.            "ed_link",
  1686.            ed_link.width, ed_link.height,
  1687.            ed_link.mono_bits, ed_link.color_bits, ed_link.mask_bits);
  1688.   fe_make_icon(c, bg2, IL_EDITOR_NUMBER,
  1689.            "ed_number",
  1690.            ed_number.width, ed_number.height,
  1691.            ed_number.mono_bits, ed_number.color_bits, ed_number.mask_bits);
  1692.   fe_make_icon(c, bg2, IL_EDITOR_OUTDENT,
  1693.            "ed_outdent",
  1694.            ed_outdent.width, ed_outdent.height,
  1695.            ed_outdent.mono_bits, ed_outdent.color_bits, ed_outdent.mask_bits);
  1696.   fe_make_icon(c, bg2, IL_EDITOR_PROPS,
  1697.            "ed_props",
  1698.            ed_props.width, ed_props.height,
  1699.            ed_props.mono_bits, ed_props.color_bits, ed_props.mask_bits);
  1700.   fe_make_icon(c, bg2, IL_EDITOR_RIGHT,
  1701.            "ed_right",
  1702.            ed_right.width, ed_right.height,
  1703.            ed_right.mono_bits, ed_right.color_bits, ed_right.mask_bits);
  1704.   fe_make_icon(c, bg2, IL_EDITOR_SHRINK,
  1705.            "ed_shrink",
  1706.            ed_shrink.width, ed_shrink.height,
  1707.            ed_shrink.mono_bits, ed_shrink.color_bits, ed_shrink.mask_bits);
  1708.   fe_make_icon(c, bg2, IL_EDITOR_SHRINK_GREY,
  1709.            "ed_shrink.i",
  1710.            ed_shrink_i.width, ed_shrink_i.height,
  1711.            ed_shrink_i.mono_bits, ed_shrink_i.color_bits, ed_shrink_i.mask_bits);
  1712.   fe_make_icon(c, bg2, IL_EDITOR_TARGET,
  1713.            "ed_target",
  1714.            ed_target.width, ed_target.height,
  1715.            ed_target.mono_bits, ed_target.color_bits, ed_target.mask_bits);
  1716.   fe_make_icon(c, bg2, IL_EDITOR_TABLE,
  1717.            "ed_table",
  1718.            ed_table.width, ed_table.height,
  1719.            ed_table.mono_bits, ed_table.color_bits, ed_table.mask_bits);
  1720. */
  1721. }
  1722.  
  1723. /*
  1724.  *    Icons used on the page.
  1725.  */
  1726. static void
  1727. fe_init_editor_icons(MWContext* c)
  1728. {
  1729.   Pixel  bg_pixel = 0;
  1730.   static Bool done = False;
  1731.  
  1732.   if (done)
  1733.     return;
  1734.  
  1735.   bg_pixel = CONTEXT_DATA (c)->default_bg_pixel;
  1736.  
  1737.   done = True;
  1738.   
  1739.   fe_make_icon(c, bg_pixel, IL_EDIT_UNSUPPORTED_TAG,
  1740.            "ed_tag",
  1741.            ed_tag.width, ed_tag.height,
  1742.            ed_tag.mono_bits, ed_tag.color_bits, ed_tag.mask_bits);
  1743.   fe_make_icon(c, bg_pixel, IL_EDIT_UNSUPPORTED_END_TAG,
  1744.            "ed_tage",
  1745.            ed_tage.width, ed_tage.height,
  1746.            ed_tage.mono_bits, ed_tage.color_bits, ed_tage.mask_bits);
  1747.   fe_make_icon(c, bg_pixel, IL_EDIT_FORM_ELEMENT,
  1748.            "ed_form",
  1749.            ed_form.width, ed_form.height,
  1750.            ed_form.mono_bits, ed_form.color_bits, ed_form.mask_bits);
  1751.   fe_make_icon(c, bg_pixel, IL_EDIT_NAMED_ANCHOR,
  1752.            "ed_target",
  1753.            ed_target.width, ed_target.height,
  1754.            ed_target.mono_bits, ed_target.color_bits, ed_target.mask_bits);
  1755. }
  1756.  
  1757. /*
  1758.  *    Map the toolbar location onto an ICON id.
  1759.  */
  1760. static int gold_browser_map[] = {
  1761.   IL_ICON_BACK, IL_ICON_BACK_GREY, IL_ICON_BACK_PT, IL_ICON_BACK_PT_GREY,
  1762.   IL_ICON_FWD,  IL_ICON_FWD_GREY,  IL_ICON_FWD_PT,  IL_ICON_FWD_PT_GREY,
  1763.   IL_ICON_HOME, IL_ICON_HOME_GREY, IL_ICON_HOME_PT, IL_ICON_HOME_PT_GREY,
  1764.   IL_EDITOR_EDIT,IL_EDITOR_EDIT_GREY,IL_EDITOR_EDIT_PT,IL_EDITOR_EDIT_PT_GREY,
  1765.   IL_ICON_RELOAD,IL_ICON_RELOAD_GREY,IL_ICON_RELOAD_PT,IL_ICON_RELOAD_PT_GREY,
  1766.   IL_ICON_LOAD, IL_ICON_LOAD_GREY, IL_ICON_LOAD_PT, IL_ICON_LOAD_PT_GREY,
  1767.   IL_ICON_OPEN, IL_ICON_OPEN_GREY, IL_ICON_OPEN_PT, IL_ICON_OPEN_PT_GREY,
  1768.   IL_ICON_PRINT,IL_ICON_PRINT_GREY,IL_ICON_PRINT_PT,IL_ICON_PRINT_PT_GREY,
  1769.   IL_ICON_FIND, IL_ICON_FIND_GREY, IL_ICON_FIND_PT, IL_ICON_FIND_PT_GREY,
  1770.   IL_ICON_STOP, IL_ICON_STOP_GREY, IL_ICON_STOP_PT, IL_ICON_STOP_PT_GREY,
  1771.   IL_ICON_NETSCAPE,IL_ICON_NETSCAPE,IL_ICON_NETSCAPE_PT,IL_ICON_NETSCAPE_PT
  1772. };
  1773.  
  1774. static int gold_editor_map[] = {
  1775.   /* toolbar */
  1776.   IL_EDITOR_NEW, IL_EDITOR_NEW_GREY, IL_EDITOR_NEW_PT, IL_EDITOR_NEW_PT_GREY,
  1777.   IL_EDITOR_OPEN,IL_EDITOR_OPEN_GREY,IL_EDITOR_OPEN_PT,IL_EDITOR_OPEN_PT_GREY,
  1778.   IL_EDITOR_SAVE,IL_EDITOR_SAVE_GREY,IL_EDITOR_SAVE_PT,IL_EDITOR_SAVE_PT_GREY,
  1779.   IL_EDITOR_BROWSE,IL_EDITOR_BROWSE_GREY,IL_EDITOR_BROWSE_PT,
  1780.     IL_EDITOR_BROWSE_PT_GREY,
  1781.   IL_EDITOR_CUT,IL_EDITOR_CUT_GREY, IL_EDITOR_CUT_PT,  IL_EDITOR_CUT_PT_GREY,
  1782.   IL_EDITOR_COPY, IL_EDITOR_COPY_GREY, IL_EDITOR_COPY_PT,
  1783.     IL_EDITOR_COPY_PT_GREY,
  1784.   IL_EDITOR_PASTE, IL_EDITOR_PASTE_GREY, IL_EDITOR_PASTE_PT,
  1785.     IL_EDITOR_PASTE_PT_GREY,
  1786.   IL_ICON_PRINT, IL_ICON_PRINT_GREY, IL_ICON_PRINT_PT, IL_ICON_PRINT_PT_GREY,
  1787.   IL_ICON_FIND,  IL_ICON_FIND_GREY,  IL_ICON_FIND_PT,  IL_ICON_FIND_PT_GREY,
  1788.   IL_EDITOR_PUBLISH, IL_EDITOR_PUBLISH_GREY, IL_EDITOR_PUBLISH_PT,
  1789.     IL_EDITOR_PUBLISH_PT_GREY
  1790. };
  1791.  
  1792. #endif /* EDITOR */
  1793.  
  1794. static void
  1795. fe_init_sa_icons (MWContext *c)
  1796. {
  1797.   Pixel bg = 0;
  1798.   static Bool done = False;
  1799.   if (done) return;
  1800.   done = True;
  1801.  
  1802. /*  XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg, 0); */
  1803.  
  1804.   fe_make_icon (c, bg, IL_SA_SIGNED,
  1805.         "A_Signed",
  1806.         A_Signed.width, A_Signed.height,
  1807.         A_Signed.mono_bits, A_Signed.color_bits, A_Signed.mask_bits);
  1808.   fe_make_icon (c, bg, IL_SA_ENCRYPTED,
  1809.         "A_Encrypt",
  1810.         A_Encrypt.width, A_Encrypt.height,
  1811.         A_Encrypt.mono_bits, A_Encrypt.color_bits,
  1812.         A_Encrypt.mask_bits);
  1813.   fe_make_icon (c, bg, IL_SA_NONENCRYPTED,
  1814.         "A_NoEncrypt",
  1815.         A_NoEncrypt.width, A_NoEncrypt.height,
  1816.         A_NoEncrypt.mono_bits, A_NoEncrypt.color_bits,
  1817.         A_NoEncrypt.mask_bits);
  1818.   fe_make_icon (c, bg, IL_SA_SIGNED_BAD,
  1819.         "A_SignBad",
  1820.         A_SignBad.width, A_SignBad.height,
  1821.         A_SignBad.mono_bits, A_SignBad.color_bits,
  1822.         A_SignBad.mask_bits);
  1823.   fe_make_icon (c, bg, IL_SA_ENCRYPTED_BAD,
  1824.         "A_EncrypBad",
  1825.         A_EncrypBad.width, A_EncrypBad.height,
  1826.         A_EncrypBad.mono_bits, A_EncrypBad.color_bits,
  1827.         A_EncrypBad.mask_bits);
  1828.   fe_make_icon (c, bg, IL_SMIME_ATTACHED,
  1829.         "M_Attach",
  1830.         M_Attach.width, M_Attach.height,
  1831.         M_Attach.mono_bits, M_Attach.color_bits, M_Attach.mask_bits);
  1832.   fe_make_icon (c, bg, IL_SMIME_SIGNED,
  1833.         "M_Signed",
  1834.         M_Signed.width, M_Signed.height,
  1835.         M_Signed.mono_bits, M_Signed.color_bits, M_Signed.mask_bits);
  1836.   fe_make_icon (c, bg, IL_SMIME_ENCRYPTED,
  1837.         "M_Encrypt",
  1838.         M_Encrypt.width, M_Encrypt.height,
  1839.         M_Encrypt.mono_bits, M_Encrypt.color_bits,
  1840.         M_Encrypt.mask_bits);
  1841.   fe_make_icon (c, bg, IL_SMIME_ENC_SIGNED,
  1842.         "M_SignEncyp",
  1843.         M_SignEncyp.width, M_SignEncyp.height,
  1844.         M_SignEncyp.mono_bits, M_SignEncyp.color_bits,
  1845.         M_SignEncyp.mask_bits);
  1846.   fe_make_icon (c, bg, IL_SMIME_SIGNED_BAD,
  1847.         "M_SignBad",
  1848.         M_SignBad.width, M_SignBad.height,
  1849.         M_SignBad.mono_bits, M_SignBad.color_bits,
  1850.         M_SignBad.mask_bits);
  1851.   fe_make_icon (c, bg, IL_SMIME_ENCRYPTED_BAD,
  1852.         "M_EncrypBad",
  1853.         M_EncrypBad.width, M_EncrypBad.height,
  1854.         M_EncrypBad.mono_bits, M_EncrypBad.color_bits,
  1855.         M_EncrypBad.mask_bits);
  1856.   fe_make_icon (c, bg, IL_SMIME_ENC_SIGNED_BAD,
  1857.         "M_SgnEncypBad",
  1858.         M_SgnEncypBad.width, M_SgnEncypBad.height,
  1859.         M_SgnEncypBad.mono_bits, M_SgnEncypBad.color_bits,
  1860.         M_SgnEncypBad.mask_bits);
  1861. }
  1862.  
  1863. static void
  1864. fe_init_msg_icons (MWContext *c)
  1865. {
  1866.   Pixel bg = 0;
  1867.   static Bool done = False;
  1868.   if (done) return;
  1869.   done = True;
  1870.  
  1871. /*  XtVaGetValues (CONTEXT_DATA (c)->top_area, XmNbackground, &bg, 0); */
  1872.  
  1873.   fe_make_icon (c, bg, IL_MSG_ATTACH,
  1874.         "M_ToggleAttach",
  1875.         M_ToggleAttach.width, M_ToggleAttach.height,
  1876.         M_ToggleAttach.mono_bits, M_ToggleAttach.color_bits, M_ToggleAttach.mask_bits);
  1877. }
  1878.  
  1879. void
  1880. fe_InitIcons (MWContext *c, MSG_BIFF_STATE biffstate)
  1881. {
  1882.   int icon_index;
  1883.   Widget shell = CONTEXT_WIDGET (c);
  1884.  
  1885.   fe_init_document_icons (c);
  1886.   switch (c->type) {
  1887.       case MWContextMailMsg: /* Fall through */
  1888.       case MWContextMail:
  1889.           /* Both MailThread and MessageCenter come through here. */
  1890.           if(shell && !strcmp(XtName(shell), "MailFolder")) {
  1891.               icon_index = IL_ICON_DESKTOP_MSGCENTER;
  1892.           } else {
  1893.               icon_index = (biffstate == MSG_BIFF_NewMail) ?
  1894.                   IL_ICON_DESKTOP_YESMAIL : IL_ICON_DESKTOP_NOMAIL;
  1895.           }
  1896.     break;
  1897.       case MWContextMessageComposition:
  1898.     icon_index = IL_ICON_DESKTOP_MSGCOMPOSE;
  1899.     break;
  1900.  
  1901.       case MWContextAddressBook:
  1902.     icon_index = IL_ICON_DESKTOP_ABOOK;
  1903.     break;
  1904.       case MWContextBookmarks:
  1905.     icon_index = IL_ICON_DESKTOP_BOOKMARK;
  1906.     break;
  1907. #ifdef EDITOR
  1908.       case MWContextEditor:
  1909.         icon_index = IL_ICON_DESKTOP_EDITOR;
  1910.     break;
  1911. #endif /*EDITOR*/
  1912.       case MWContextBrowser:
  1913.         icon_index = IL_ICON_DESKTOP_NAVIGATOR;
  1914.     break;
  1915.       case MWContextHistory:
  1916.         icon_index = IL_ICON_DESKTOP_HISTORY;
  1917.     break;
  1918.       case MWContextSearch: /* FALL THROUGH */
  1919.       case MWContextSearchLdap:
  1920.         icon_index = IL_ICON_DESKTOP_SEARCH;
  1921.     break;
  1922.       case MWContextDialog:    /* FALL THROUGH */
  1923.       default:
  1924.     icon_index = IL_ICON_DESKTOP_COMMUNICATOR;
  1925.     break;
  1926.   }
  1927.  
  1928.   if (fe_icons [icon_index].pixmap) {
  1929.       Arg av [5];
  1930.       int ac = 0;
  1931.       XtSetArg (av[ac], XtNiconPixmap, fe_icons[icon_index].pixmap); ac++;
  1932.       if (!fe_icons [icon_index].mask) {
  1933.       /*
  1934.        *    Must make a mask, because olwm is so stupid, it doesn't clip
  1935.        *    mask the image to the image size, just blasts away at 60x60.
  1936.        */
  1937.       Pixmap mask_pixmap;
  1938.       Dimension height = fe_icons[icon_index].height;
  1939.       Dimension width = fe_icons[icon_index].width;
  1940.       Display*  dpy = XtDisplay(CONTEXT_WIDGET(c));
  1941.       Screen*   screen = XtScreen(CONTEXT_WIDGET(c));
  1942.       XGCValues gcv;
  1943.       GC        gc;
  1944.       
  1945.       mask_pixmap = XCreatePixmap(dpy, RootWindowOfScreen(screen),
  1946.                       width, height, 1);
  1947.       
  1948.       gcv.function = GXset;
  1949.       /* gcv.foreground = BlackPixelOfScreen(screen); */
  1950.       gc = XCreateGC(dpy, mask_pixmap, GCFunction, &gcv);
  1951.       XFillRectangle(dpy, mask_pixmap, gc, 0, 0, width, height);
  1952.       XFreeGC(dpy, gc);
  1953.  
  1954.       fe_icons[icon_index].mask = mask_pixmap;
  1955.       }
  1956.       XtSetArg (av[ac], XtNiconMask, fe_icons[icon_index].mask); ac++;
  1957.  
  1958.       XtSetValues (CONTEXT_WIDGET (c), av, ac);
  1959.   }
  1960. }
  1961.  
  1962. #ifndef NO_SECURITY
  1963. Pixmap
  1964. fe_NewSecurityPixmap (Widget widget, Dimension *w, Dimension *h,
  1965.               int type)
  1966. {
  1967.   int index = 0;
  1968.   switch (type)
  1969.     {
  1970.     case SSL_SECURITY_STATUS_ON_LOW:  index = IL_ICON_SECURITY_ON; break;
  1971.     case SSL_SECURITY_STATUS_ON_HIGH: index = IL_ICON_SECURITY_HIGH; break;
  1972. #ifdef FORTEZZA
  1973.     case SSL_SECURITY_STATUS_FORTEZZA: index = IL_ICON_SECURITY_FORTEZZA; break;
  1974. #endif
  1975.     case SSL_SECURITY_STATUS_OFF:    /* Fall Through */
  1976.     default:                index = IL_ICON_SECURITY_OFF;
  1977.     }
  1978.   fe_new_init_security_icons (widget);
  1979.   if (w) *w = fe_icons [index].width;
  1980.   if (h) *h = fe_icons [index].height;
  1981.   return fe_icons [index].pixmap;
  1982. }
  1983.  
  1984. Pixmap
  1985. fe_SecurityPixmap (MWContext *context, Dimension *w, Dimension *h,
  1986.            int type)
  1987. {
  1988.   int index = 0;
  1989.   switch (type)
  1990.     {
  1991.     case SSL_SECURITY_STATUS_ON_LOW:  index = IL_ICON_SECURITY_ON; break;
  1992.     case SSL_SECURITY_STATUS_ON_HIGH: index = IL_ICON_SECURITY_HIGH; break;
  1993. #ifdef FORTEZZA
  1994.     case SSL_SECURITY_STATUS_FORTEZZA: index = IL_ICON_SECURITY_FORTEZZA; break;
  1995. #endif
  1996.     case SSL_SECURITY_STATUS_OFF:    /* Fall Through */
  1997.     default:                index = IL_ICON_SECURITY_OFF;
  1998.     }
  1999.   if (context)    /* for awt, we know we've already done this */
  2000.       fe_init_document_icons (context);
  2001.   if (w) *w = fe_icons [index].width;
  2002.   if (h) *h = fe_icons [index].height;
  2003.   return fe_icons [index].pixmap;
  2004. }
  2005. #endif /* ! NO_SECURITY */
  2006.  
  2007. Pixmap
  2008. fe_ToolbarPixmapByName(MWContext *context, char *pixmap_name,
  2009.                Boolean disabled_p, Boolean urls_p)
  2010. {
  2011.   Boolean both_p = CONTEXT_DATA (context)->show_toolbar_text_p;
  2012.  
  2013.   /* this function should only be used for the Mail window. */
  2014.   XP_ASSERT(context->type == MWContextMail);
  2015.  
  2016.   if (!strcmp(pixmap_name, "getNewMail"))
  2017.     return fe_icons[disabled_p && both_p ? IL_MSG_GET_MAIL_PT_GREY:
  2018.            disabled_p ? IL_MSG_GET_MAIL_GREY :
  2019.            both_p ? IL_MSG_GET_MAIL_PT :
  2020.            IL_MSG_GET_MAIL].pixmap;
  2021.   else if (!strcmp(pixmap_name, "deleteMessage"))
  2022.     return fe_icons[disabled_p && both_p ? IL_MSG_DELETE_PT_GREY :
  2023.            disabled_p ? IL_MSG_DELETE_GREY :
  2024.            both_p ? IL_MSG_DELETE_PT :
  2025.            IL_MSG_DELETE].pixmap;
  2026.   else if (!strcmp(pixmap_name, "mailNew"))
  2027.     return fe_icons[disabled_p && both_p ? IL_MSG_NEW_MSG_PT_GREY :
  2028.            disabled_p ? IL_MSG_NEW_MSG_GREY :
  2029.            both_p ? IL_MSG_NEW_MSG_PT :
  2030.            IL_MSG_NEW_MSG].pixmap;
  2031.   else if (!strcmp(pixmap_name, "replyToSender"))
  2032.     return fe_icons[disabled_p && both_p ?
  2033.            IL_MSG_REPLY_TO_SENDER_PT_GREY :
  2034.            disabled_p ? IL_MSG_REPLY_TO_SENDER_GREY :
  2035.            both_p ? IL_MSG_REPLY_TO_SENDER_PT :
  2036.            IL_MSG_REPLY_TO_SENDER].pixmap;
  2037.   else if (!strcmp(pixmap_name, "replyToAll"))
  2038.     return fe_icons[disabled_p && both_p ?
  2039.            IL_MSG_REPLY_TO_ALL_PT_GREY :
  2040.            disabled_p ? IL_MSG_REPLY_TO_ALL_GREY :
  2041.            both_p ? IL_MSG_REPLY_TO_ALL_PT :
  2042.            IL_MSG_REPLY_TO_ALL].pixmap;
  2043.   else if (!strcmp(pixmap_name, "forwardMessage"))
  2044.     return fe_icons[disabled_p && both_p ?
  2045.            IL_MSG_FORWARD_MSG_PT_GREY :
  2046.            disabled_p ? IL_MSG_FORWARD_MSG_GREY :
  2047.            both_p ? IL_MSG_FORWARD_MSG_PT :
  2048.            IL_MSG_FORWARD_MSG].pixmap;
  2049.   else if (!strcmp(pixmap_name, "abort"))
  2050.     return fe_icons[disabled_p && both_p ? IL_ICON_STOP_PT_GREY :
  2051.            disabled_p ? IL_ICON_STOP_GREY :
  2052.            both_p ? IL_ICON_STOP_PT :
  2053.            IL_ICON_STOP].pixmap;
  2054.   else if (!strcmp(pixmap_name, "postNew"))
  2055.     return fe_icons[disabled_p && both_p ? IL_MSG_NEW_POST_PT_GREY:
  2056.            disabled_p ? IL_MSG_NEW_POST_GREY :
  2057.            both_p ? IL_MSG_NEW_POST_PT :
  2058.            IL_MSG_NEW_POST].pixmap;
  2059.   else if (!strcmp(pixmap_name, "send"))
  2060.     return fe_icons[disabled_p && both_p ? IL_COMPOSE_SEND_PT_GREY :
  2061.            disabled_p ? IL_COMPOSE_SEND_GREY :
  2062.            both_p ? IL_COMPOSE_SEND_PT :
  2063.            IL_COMPOSE_SEND].pixmap;
  2064.   else if (!strcmp(pixmap_name, "previousMessage"))
  2065.     return fe_icons[disabled_p && both_p ?
  2066.            IL_MSG_PREV_UNREAD_PT_GREY :
  2067.            disabled_p ? IL_MSG_PREV_UNREAD_GREY :
  2068.            both_p ? IL_MSG_PREV_UNREAD_PT :
  2069.            IL_MSG_PREV_UNREAD].pixmap;
  2070.   else if (!strcmp(pixmap_name, "nextMessage"))
  2071.     return fe_icons[disabled_p && both_p ?
  2072.            IL_MSG_NEXT_UNREAD_PT_GREY :
  2073.            disabled_p ? IL_MSG_NEXT_UNREAD_GREY :
  2074.            both_p ? IL_MSG_NEXT_UNREAD_PT :
  2075.            IL_MSG_NEXT_UNREAD].pixmap;
  2076.   else if (!strcmp(pixmap_name, "previousUnreadMessage"))
  2077.     return fe_icons[disabled_p && both_p ?
  2078.            IL_MSG_PREV_UNREAD_PT_GREY :
  2079.            disabled_p ? IL_MSG_PREV_UNREAD_GREY :
  2080.            both_p ? IL_MSG_PREV_UNREAD_PT :
  2081.            IL_MSG_PREV_UNREAD].pixmap;
  2082.   else if (!strcmp(pixmap_name, "nextUnreadMessage"))
  2083.     return fe_icons[disabled_p && both_p ?
  2084.            IL_MSG_NEXT_UNREAD_PT_GREY :
  2085.            disabled_p ? IL_MSG_NEXT_UNREAD_GREY :
  2086.            both_p ? IL_MSG_NEXT_UNREAD_PT :
  2087.            IL_MSG_NEXT_UNREAD].pixmap;
  2088.   else XP_ASSERT(0);
  2089.   return 0;    /* XXX ??? */
  2090. }
  2091.  
  2092. Pixmap
  2093. fe_ToolbarPixmap (MWContext *context, int i, Boolean disabled_p,
  2094.           Boolean urls_p)
  2095. {
  2096.   Boolean both_p = CONTEXT_DATA (context)->show_toolbar_text_p;
  2097.   int offset;
  2098.   int grey_offset;
  2099.   int pt_offset;
  2100. #ifdef EDITOR
  2101.   static align_icons_done=0;     /* added 14MAR96RCJ */
  2102. #endif
  2103.  
  2104.   if (urls_p)
  2105.     return (fe_icons [IL_ICON_TOUR + i].pixmap);
  2106.  
  2107.   offset = (both_p ? IL_ICON_BACK_PT : IL_ICON_BACK);
  2108.   grey_offset = (disabled_p ? 1 : 0);
  2109.   pt_offset = (both_p ? 1: 0);
  2110.  
  2111.   switch (context->type)
  2112.     {
  2113. #ifdef EDITOR
  2114.     case MWContextEditor:
  2115. #if 0
  2116.       if (both_p)
  2117.     fe_init_editor_icons_withtext(context);
  2118.       else
  2119.     fe_init_editor_icons_notext(context);
  2120. #endif /*0*/
  2121.  
  2122.       fe_init_editor_icons_other(context);
  2123.  
  2124.       if (i < 10)
  2125.     i = gold_editor_map[(4*i) + grey_offset + (2*pt_offset)];
  2126.       else if (i < 23) 
  2127.     i = IL_EDITOR_OTHER_GROUP + (2*(i - 10)) + grey_offset;
  2128.       else if (i>=IL_ALIGN1_RAISED && i <= IL_ALIGN7_DEPRESSED) {
  2129.            if (!align_icons_done) {
  2130.                fe_init_align_icons(context);
  2131.                align_icons_done=1;
  2132.            }
  2133.       }
  2134.       else 
  2135.     i = IL_EDITOR_BULLET + (2*(i - 23)) + grey_offset;
  2136.  
  2137.       return fe_icons[i].pixmap;
  2138.       /*NOTREACHED*/
  2139.       break;
  2140.     case MWContextBrowser:
  2141.       return fe_icons[gold_browser_map[(4*i) + grey_offset + (2*pt_offset)]].pixmap;
  2142.       /*NOTREACHED*/
  2143.       break;
  2144. #else
  2145.     case MWContextMailMsg:
  2146.       switch (i)
  2147.     {
  2148.     case 0: return fe_icons[disabled_p && both_p ? IL_MSG_NEW_MSG_PT_GREY :
  2149.                    disabled_p ? IL_MSG_NEW_MSG_GREY :
  2150.                    both_p ? IL_MSG_NEW_MSG_PT :
  2151.                    IL_MSG_NEW_MSG].pixmap;
  2152.     case 1: return fe_icons[disabled_p && both_p ?
  2153.                    IL_MSG_REPLY_TO_SENDER_PT_GREY :
  2154.                    disabled_p ? IL_MSG_REPLY_TO_SENDER_GREY :
  2155.                    both_p ? IL_MSG_REPLY_TO_SENDER_PT :
  2156.                    IL_MSG_REPLY_TO_SENDER].pixmap;
  2157.     case 2: return fe_icons[disabled_p && both_p ?
  2158.                    IL_MSG_REPLY_TO_ALL_PT_GREY :
  2159.                    disabled_p ? IL_MSG_REPLY_TO_ALL_GREY :
  2160.                    both_p ? IL_MSG_REPLY_TO_ALL_PT :
  2161.                    IL_MSG_REPLY_TO_ALL].pixmap;
  2162.     case 3: return fe_icons[disabled_p && both_p ?
  2163.                    IL_MSG_FORWARD_MSG_PT_GREY :
  2164.                    disabled_p ? IL_MSG_FORWARD_MSG_GREY :
  2165.                    both_p ? IL_MSG_FORWARD_MSG_PT :
  2166.                    IL_MSG_FORWARD_MSG].pixmap;
  2167.     case 4: return fe_icons[disabled_p && both_p ?
  2168.                    IL_MSG_NEXT_UNREAD_PT_GREY :
  2169.                    disabled_p ? IL_MSG_NEXT_UNREAD_GREY :
  2170.                    both_p ? IL_MSG_NEXT_UNREAD_PT :
  2171.                    IL_MSG_NEXT_UNREAD].pixmap;
  2172.     case 5: return fe_icons[disabled_p && both_p ?
  2173.                    IL_MSG_PREV_UNREAD_PT_GREY :
  2174.                    disabled_p ? IL_MSG_PREV_UNREAD_GREY :
  2175.                    both_p ? IL_MSG_PREV_UNREAD_PT :
  2176.                    IL_MSG_PREV_UNREAD].pixmap;
  2177.     case 6: return fe_icons[disabled_p && both_p ? IL_MSG_DELETE_PT_GREY :
  2178.                    disabled_p ? IL_MSG_DELETE_GREY :
  2179.                    both_p ? IL_MSG_DELETE_PT :
  2180.                    IL_MSG_DELETE].pixmap;
  2181.     case 7: return fe_icons[disabled_p && both_p ? IL_ICON_STOP_PT_GREY :
  2182.                 disabled_p ? IL_ICON_STOP_GREY :
  2183.                 both_p ? IL_ICON_STOP_PT :
  2184.                 IL_ICON_STOP].pixmap;
  2185.     }
  2186.     case MWContextNewsMsg:     /* ### wrong */
  2187.  
  2188.     case MWContextBrowser:
  2189.       return fe_icons [offset + (i*2) + (disabled_p ? 1 : 0)].pixmap;
  2190.       break;
  2191. #endif
  2192.     case MWContextMail:
  2193.       switch (i)
  2194.     {
  2195.     case 0: return fe_icons[disabled_p && both_p ? IL_MSG_GET_MAIL_PT_GREY:
  2196.                     disabled_p ? IL_MSG_GET_MAIL_GREY :
  2197.                     both_p ? IL_MSG_GET_MAIL_PT :
  2198.                 IL_MSG_GET_MAIL].pixmap;
  2199.     case 1: return fe_icons[disabled_p && both_p ? IL_MSG_NEW_MSG_PT_GREY :
  2200.                    disabled_p ? IL_MSG_NEW_MSG_GREY :
  2201.                    both_p ? IL_MSG_NEW_MSG_PT :
  2202.                    IL_MSG_NEW_MSG].pixmap;
  2203.     case 2: return fe_icons[disabled_p && both_p ? IL_MSG_DELETE_PT_GREY :
  2204.                 disabled_p ? IL_MSG_DELETE_GREY :
  2205.                 both_p ? IL_MSG_DELETE_PT :
  2206.                 IL_MSG_DELETE].pixmap;
  2207.                 /* change this one to 4 when the security button
  2208.                    gets put in. */
  2209.     case 3: return fe_icons[disabled_p && both_p ? IL_ICON_STOP_PT_GREY :
  2210.                 disabled_p ? IL_ICON_STOP_GREY :
  2211.                 both_p ? IL_ICON_STOP_PT :
  2212.                 IL_ICON_STOP].pixmap;
  2213.     default: fe_perror (context, "internal error: bogus mail icon accessed"); break;
  2214.     }
  2215.       break;
  2216.     case MWContextNews:
  2217.       switch (i)
  2218.     {
  2219.     case 0: return fe_icons[disabled_p && both_p ? IL_MSG_NEW_POST_PT_GREY:
  2220.                 disabled_p ? IL_MSG_NEW_POST_GREY :
  2221.                 both_p ? IL_MSG_NEW_POST_PT :
  2222.                 IL_MSG_NEW_POST].pixmap;
  2223.     case 1: return fe_icons[disabled_p && both_p ? IL_MSG_NEW_MSG_PT_GREY :
  2224.                 disabled_p ? IL_MSG_NEW_MSG_GREY :
  2225.                 both_p ? IL_MSG_NEW_MSG_PT :
  2226.                 IL_MSG_NEW_MSG].pixmap;
  2227.     case 2: return fe_icons[disabled_p && both_p ?
  2228.                      IL_MSG_REPLY_TO_SENDER_PT_GREY :
  2229.                 disabled_p ? IL_MSG_REPLY_TO_SENDER_GREY :
  2230.                 both_p ? IL_MSG_REPLY_TO_SENDER_PT :
  2231.                 IL_MSG_REPLY_TO_SENDER].pixmap;
  2232.     case 3: return fe_icons[disabled_p && both_p ? IL_MSG_FOLLOWUP_PT_GREY:
  2233.                 disabled_p ? IL_MSG_FOLLOWUP_GREY :
  2234.                 both_p ? IL_MSG_FOLLOWUP_PT :
  2235.                 IL_MSG_FOLLOWUP].pixmap;
  2236.     case 4: return fe_icons[disabled_p && both_p ?
  2237.                      IL_MSG_FOLLOWUP_AND_REPLY_PT_GREY :
  2238.                 disabled_p ? IL_MSG_FOLLOWUP_AND_REPLY_GREY :
  2239.                 both_p ? IL_MSG_FOLLOWUP_AND_REPLY_PT :
  2240.                 IL_MSG_FOLLOWUP_AND_REPLY].pixmap;
  2241.     case 5: return fe_icons[disabled_p && both_p ?
  2242.                      IL_MSG_FORWARD_MSG_PT_GREY :
  2243.                 disabled_p ? IL_MSG_FORWARD_MSG_GREY :
  2244.                 both_p ? IL_MSG_FORWARD_MSG_PT :
  2245.                 IL_MSG_FORWARD_MSG].pixmap;
  2246.     case 6: return fe_icons[disabled_p && both_p ?
  2247.                   IL_MSG_PREV_UNREAD_PT_GREY :
  2248.                 disabled_p ? IL_MSG_PREV_UNREAD_GREY :
  2249.                 both_p ? IL_MSG_PREV_UNREAD_PT :
  2250.                 IL_MSG_PREV_UNREAD].pixmap;
  2251.     case 7: return fe_icons[disabled_p && both_p ?
  2252.                      IL_MSG_NEXT_UNREAD_PT_GREY :
  2253.                 disabled_p ? IL_MSG_NEXT_UNREAD_GREY :
  2254.                 both_p ? IL_MSG_NEXT_UNREAD_PT :
  2255.                 IL_MSG_NEXT_UNREAD].pixmap;
  2256.     case 8: return fe_icons[disabled_p && both_p ?
  2257.                      IL_MSG_MARK_THREAD_READ_PT_GREY :
  2258.                 disabled_p ? IL_MSG_MARK_THREAD_READ_GREY :
  2259.                 both_p ? IL_MSG_MARK_THREAD_READ_PT :
  2260.                 IL_MSG_MARK_THREAD_READ].pixmap;
  2261.     case 9: return fe_icons[disabled_p && both_p ?
  2262.                      IL_MSG_MARK_ALL_READ_PT_GREY :
  2263.                 disabled_p ? IL_MSG_MARK_ALL_READ_GREY :
  2264.                 both_p ? IL_MSG_MARK_ALL_READ_PT :
  2265.                 IL_MSG_MARK_ALL_READ].pixmap;
  2266.     case 10:return fe_icons[disabled_p && both_p ? IL_ICON_PRINT_PT_GREY :
  2267.                 disabled_p ? IL_ICON_PRINT_GREY :
  2268.                 both_p ? IL_ICON_PRINT_PT :
  2269.                 IL_ICON_PRINT].pixmap;
  2270.     case 11:return fe_icons[disabled_p && both_p ? IL_ICON_STOP_PT_GREY :
  2271.                 disabled_p ? IL_ICON_STOP_GREY :
  2272.                 both_p ? IL_ICON_STOP_PT :
  2273.                 IL_ICON_STOP].pixmap;
  2274. /*    default: abort (); */
  2275.     default: fe_perror (context, "internal error: bogus news icon accessed"); break;
  2276.     }
  2277.       break;
  2278.  
  2279.     case MWContextMessageComposition:
  2280.       switch (i)
  2281.     {
  2282.     /* sendOrSendLater */
  2283.     case 0:
  2284.         if (fe_globalPrefs.queue_for_later_p)
  2285.         /* SendLater */
  2286.         return fe_icons[disabled_p && both_p ? IL_COMPOSE_SENDLATER_PT_GREY :
  2287.                 disabled_p ? IL_COMPOSE_SENDLATER_GREY :
  2288.                 both_p ? IL_COMPOSE_SENDLATER_PT :
  2289.                 IL_COMPOSE_SENDLATER].pixmap;
  2290.         else
  2291.         /* Send */
  2292.         return fe_icons[disabled_p && both_p ? IL_COMPOSE_SEND_PT_GREY :
  2293.                 disabled_p ? IL_COMPOSE_SEND_GREY :
  2294.                 both_p ? IL_COMPOSE_SEND_PT :
  2295.                 IL_COMPOSE_SEND].pixmap;
  2296.     /* Quote */
  2297.     case 1:return fe_icons[disabled_p && both_p ? IL_COMPOSE_QUOTE_PT_GREY :
  2298.                 disabled_p ? IL_COMPOSE_QUOTE_GREY :
  2299.                 both_p ? IL_COMPOSE_QUOTE_PT :
  2300.                 IL_COMPOSE_QUOTE].pixmap;
  2301.     /* Attach */
  2302.     case 2:return fe_icons[disabled_p &&
  2303.                 both_p ? IL_COMPOSE_ATTACH_PT_GREY :
  2304.                 disabled_p ? IL_COMPOSE_ATTACH_GREY :
  2305.                 both_p ? IL_COMPOSE_ATTACH_PT :
  2306.                 IL_COMPOSE_ATTACH].pixmap;
  2307.     /* AddressBook */
  2308.     case 3:return fe_icons[disabled_p &&
  2309.                 both_p ? IL_COMPOSE_ADDRESSBOOK_PT_GREY :
  2310.                 disabled_p ? IL_COMPOSE_ADDRESSBOOK_GREY :
  2311.                 both_p ? IL_COMPOSE_ADDRESSBOOK_PT :
  2312.                 IL_COMPOSE_ADDRESSBOOK].pixmap;
  2313.     /* Stop */
  2314.     case 4:return fe_icons[disabled_p && both_p ? IL_ICON_STOP_PT_GREY :
  2315.                 disabled_p ? IL_ICON_STOP_GREY :
  2316.                 both_p ? IL_ICON_STOP_PT :
  2317.                 IL_ICON_STOP].pixmap;
  2318.     default: fe_perror (context, "internal error: bogus compose icon accessed"); break;
  2319.     }
  2320.       break;
  2321.  
  2322.  
  2323.  
  2324.     default:
  2325.       abort ();
  2326.       break;
  2327.     }
  2328.   return 0;
  2329. }
  2330.  
  2331.  
  2332. void
  2333. fe_DrawIcon (MWContext *context, LO_ImageStruct *lo_image, int icon_number)
  2334. {
  2335.   Pixmap p = fe_icons [icon_number].pixmap;
  2336.   Pixmap m = fe_icons [icon_number].mask;
  2337.   Pixmap tmp_mask = 0;
  2338.   fe_Drawable *fe_drawable = CONTEXT_DATA (context)->drawable;
  2339.   Drawable drawable = fe_drawable->xdrawable;
  2340.   Display *dpy = XtDisplay(CONTEXT_DATA (context)->drawing_area);
  2341.   int x = lo_image->x + lo_image->x_offset
  2342.     + lo_image->border_width
  2343.     - CONTEXT_DATA (context)->document_x;
  2344.   int y = lo_image->y + lo_image->y_offset
  2345.     + lo_image->border_width
  2346.     - CONTEXT_DATA (context)->document_y;
  2347.   int w, h;
  2348.   unsigned long flags;
  2349.  
  2350.   if (!p)
  2351.     {
  2352.       icon_number = IL_IMAGE_NOT_FOUND;
  2353.       p = fe_icons [icon_number].pixmap;
  2354.     }
  2355.  
  2356.   x += fe_drawable->x_origin;
  2357.   y += fe_drawable->y_origin;
  2358.   w = fe_icons [icon_number].width;
  2359.   h = fe_icons [icon_number].height;
  2360.  
  2361.   /*
  2362.    * A delayed image with ALT text displays the icon, text, and a box instead
  2363.    * of just the icon.  I steal the code here from display text, there should
  2364.    * probably be some way to share code here.
  2365.    */
  2366.   if (icon_number == IL_IMAGE_DELAYED &&
  2367.       lo_image->alt &&
  2368.       lo_image->alt_len)
  2369.     {
  2370.       fe_Font font = fe_LoadFontFromFace (context, lo_image->text_attr,
  2371.                       &lo_image->text_attr->charset,
  2372.                       lo_image->text_attr->font_face,
  2373.                       lo_image->text_attr->size,
  2374.                       lo_image->text_attr->fontmask);
  2375.       /*char *str = (char *) lo_image->alt;*/
  2376.       int ascent, descent;
  2377.       int tx, ty;
  2378.       Boolean selected_p = False;
  2379.       XGCValues gcv, gcv3;
  2380.       GC gc, gc3;
  2381.       memset (&gcv, ~0, sizeof (gcv));
  2382.       memset (&gcv3, ~0, sizeof (gcv3));
  2383.       gcv.foreground = fe_GetPixel (context,
  2384.                     lo_image->text_attr->fg.red,
  2385.                     lo_image->text_attr->fg.green,
  2386.                     lo_image->text_attr->fg.blue);
  2387.       gcv3.foreground = fe_GetPixel (context,
  2388.                     lo_image->text_attr->bg.red,
  2389.                     lo_image->text_attr->bg.green,
  2390.                     lo_image->text_attr->bg.blue);
  2391.       gcv.line_width = 1;
  2392.  
  2393.       gc = fe_GetClipGC (CONTEXT_DATA (context)->widget,
  2394.                          GCForeground|GCLineWidth,
  2395.                          &gcv, fe_drawable->clip_region);
  2396.  
  2397.       /* beware: XDrawRectangle centers the line-thickness on the coords. */
  2398.       XDrawRectangle (dpy, drawable, gc,
  2399.                       x, y,
  2400.               lo_image->width - DELAYED_ICON_BORDER,
  2401.               lo_image->height - DELAYED_ICON_BORDER);
  2402.       x += (DELAYED_ICON_BORDER + DELAYED_ICON_PAD);
  2403.       y += (DELAYED_ICON_BORDER + DELAYED_ICON_PAD);
  2404.  
  2405.       if (!font)
  2406.       {
  2407.         return;
  2408.       }
  2409.  
  2410.       FE_FONT_EXTENTS(lo_image->text_attr->charset, font, &ascent, &descent);
  2411.  
  2412.       tx = x + w + DELAYED_ICON_PAD;
  2413.       ty = y + (h / 2) - ((ascent + descent) / 2) + ascent;
  2414.       gcv.background = fe_GetPixel (context,
  2415.                     lo_image->text_attr->bg.red,
  2416.                     lo_image->text_attr->bg.green,
  2417.                     lo_image->text_attr->bg.blue);
  2418.  
  2419.       flags = (GCForeground | GCBackground);
  2420.       FE_SET_GC_FONT(lo_image->text_attr->charset, &gcv, font, &flags);
  2421.  
  2422.       gc = fe_GetClipGC (CONTEXT_DATA (context)->widget, flags, &gcv,
  2423.                          fe_drawable->clip_region);
  2424.  
  2425.       gc3 = fe_GetClipGC (CONTEXT_DATA (context)->widget, flags, &gcv3,
  2426.                          fe_drawable->clip_region);
  2427.  
  2428.       if (CONTEXT_DATA (context)->backdrop_pixmap &&
  2429.       /* This can only happen if something went wrong while loading
  2430.          the background pixmap, I think. */
  2431.       CONTEXT_DATA (context)->backdrop_pixmap != (Pixmap) ~0 &&
  2432.       !selected_p)
  2433.         FE_DRAW_STRING (lo_image->text_attr->charset, dpy,
  2434.         drawable, font, gc, tx, ty, (char *) lo_image->alt,
  2435.         lo_image->alt_len);
  2436.       else
  2437.         FE_DRAW_IMAGE_STRING (lo_image->text_attr->charset, dpy,
  2438.         drawable, font, gc, gc3, tx, ty, (char *) lo_image->alt,
  2439.         lo_image->alt_len);
  2440.     }
  2441.  
  2442.   if (p) {
  2443.       XGCValues gcv;
  2444.       unsigned long flags;
  2445.       GC gc;
  2446.       memset (&gcv, ~0, sizeof (gcv));
  2447.       gcv.function = GXcopy;
  2448.       flags = GCFunction;
  2449.  
  2450.       if (m) /* #### no need for this if using default solid bg color */
  2451.     {
  2452.             /* We now have two masks: the icon's clip mask and the
  2453.                compositor's clip region, which both have different origins.
  2454.                When drawing the icon, we need to use a temporary clip mask
  2455.                which represents the logical AND of these two masks.  This 
  2456.                leaves the original icon clip mask unaltered for future
  2457.                use. */
  2458.  
  2459.               XGCValues gcv2;
  2460.               GC gc2;
  2461.  
  2462.               /* The clip origin for the icon clip mask. */
  2463.               gcv.clip_x_origin = x;
  2464.               gcv.clip_y_origin = y;
  2465.  
  2466.               /* Create a temporary mask and clear it. */
  2467.               tmp_mask = XCreatePixmap (dpy, drawable, w, h, 1);
  2468.               gcv2.function = GXclear;
  2469.               gc2 = XCreateGC (dpy, tmp_mask, GCFunction, &gcv2);
  2470.               XFillRectangle(dpy, tmp_mask, gc2, 0, 0, w, h);
  2471.  
  2472.               /* Use the compositors' clip region as a clip mask when copying
  2473.                  the icon mask to the temporary mask.  Note that XSetRegion
  2474.                  must be called before setting gc2's clip origin. */
  2475.               if (fe_drawable->clip_region)
  2476.                   XSetRegion(dpy, gc2, fe_drawable->clip_region);
  2477.               gcv2.function = GXcopy;
  2478.               gcv2.clip_x_origin = -gcv.clip_x_origin;
  2479.               gcv2.clip_y_origin = -gcv.clip_y_origin;
  2480.               XChangeGC(dpy, gc2, GCFunction | GCClipXOrigin | GCClipYOrigin,
  2481.                         &gcv2);
  2482.               XCopyArea (dpy, m, tmp_mask, gc2, 0, 0, w, h, 0, 0);
  2483.  
  2484.               /* Now use the temporary clip mask to draw the icon.  */
  2485.               gcv.clip_mask = tmp_mask;
  2486.               flags |= (GCClipMask | GCClipXOrigin | GCClipYOrigin);
  2487.               gc = fe_GetGCfromDW (dpy, drawable, flags, &gcv, NULL);
  2488.               XFreeGC(dpy, gc2);
  2489.     }
  2490.       else
  2491.           {
  2492.               /* We only have to deal with the compositor's clip region
  2493.                  when drawing the image. */
  2494.               gc = fe_GetGCfromDW (dpy, drawable, flags, &gcv,
  2495.                                    fe_drawable->clip_region);
  2496.           }
  2497.  
  2498.       XCopyArea (dpy, p, drawable, gc, 0, 0, w, h, x, y);
  2499.  
  2500.       if (tmp_mask)
  2501.           XFreePixmap(dpy, tmp_mask);
  2502.   } else { /* aaaaagh! */
  2503.       fe_DrawShadows(context, fe_drawable,
  2504.              x, y, 50, 50, 2, XmSHADOW_OUT);
  2505.   }
  2506. }
  2507.  
  2508. /*
  2509.  * the fe_icons array is only local to this module.  We need
  2510.  * a way to get the size of an icon form another module.
  2511.  */
  2512. void
  2513. fe_IconSize (int icon_number, long *width, long *height)
  2514. {
  2515.   *width = (long)fe_icons [icon_number].width;
  2516.   *height = (long)fe_icons [icon_number].height;
  2517. }
  2518.  
  2519. #define XFE_ABOUT_FILE        0
  2520. #define XFE_SPLASH_FILE        1
  2521. #define XFE_LICENSE_FILE    2
  2522. #define XFE_MAILINTRO_FILE    3
  2523. #define XFE_PLUGIN_FILE        4
  2524.  
  2525. struct { char *name; char *str; } fe_localized_files[] = {
  2526.     { "about",    NULL },
  2527.     { "splash",    NULL },
  2528.     { "license",    NULL },
  2529.     { "mail.msg",    NULL },
  2530.     { "plugins",    NULL }
  2531. };
  2532.  
  2533.  
  2534. static char *
  2535. fe_get_localized_file(int which)
  2536. {
  2537.     FILE        *f;
  2538.     char        file[512];
  2539.     char        *p;
  2540.     char        *ret;
  2541.     int        size;
  2542.  
  2543.     ret = fe_localized_files[which].str;
  2544.     if (ret)
  2545.     {
  2546.         return ret;
  2547.     }
  2548.  
  2549.     PR_snprintf(file, sizeof (file), "%s/%s", fe_get_app_dir(fe_display),
  2550.         fe_localized_files[which].name);
  2551.     f = fopen(file, "r");
  2552.     if (!f)
  2553.     {
  2554.         return NULL;
  2555.     }
  2556.  
  2557.     size = 20000;
  2558.     ret = malloc(size + 1);
  2559.     if (!ret)
  2560.     {
  2561.         fclose(f);
  2562.         return NULL;
  2563.     }
  2564.     size = fread(ret, 1, size, f);
  2565.     fclose(f);
  2566.     ret[size] = 0;
  2567.  
  2568.     p = strdup(ret);
  2569.     free(ret);
  2570.     if (!p)
  2571.     {
  2572.         return NULL;
  2573.     }
  2574.     ret = p;
  2575.  
  2576.     fe_localized_files[which].str = ret;
  2577.  
  2578.     return ret;
  2579. }
  2580.  
  2581.  
  2582. void *
  2583. FE_AboutData (const char *which,
  2584.           char **data_ret, int32 *length_ret, char **content_type_ret)
  2585. {
  2586.   unsigned char *tmp;
  2587.   static XP_Bool ever_loaded_map = FALSE;
  2588.   char *rv = NULL;
  2589.  
  2590.   if (0) {;} 
  2591. #ifndef NETSCAPE_PRIV
  2592.   else if (!strcmp (which, "flamer"))
  2593.     {
  2594.       /* Note, this one returns a read-only string. */
  2595.       *data_ret = (char *) flamer_gif;
  2596.       *length_ret = sizeof (flamer_gif) - 1;
  2597.       *content_type_ret = IMAGE_GIF;
  2598.     }
  2599. #else
  2600.   else if (!strcmp (which, "logo"))
  2601.     {
  2602.       /* Note, this one returns a read-only string. */
  2603.       *data_ret = (char *) biglogo_gif;
  2604.       *length_ret = sizeof (biglogo_gif) - 1;
  2605.       *content_type_ret = IMAGE_GIF;
  2606.     }
  2607.   else if (!strcmp (which, "photo"))
  2608.     {
  2609.       if (!ever_loaded_map)
  2610.     {
  2611.       *data_ret = 0;
  2612.       *length_ret = 0;
  2613.       *content_type_ret = 0;
  2614.       return 0;
  2615.     }
  2616.       /* Note, this one returns a read-only string. */
  2617.       *data_ret = (char *) photo_jpg;
  2618.       *length_ret = sizeof (photo_jpg) - 1;
  2619.       *content_type_ret = IMAGE_JPG;
  2620.     }
  2621.   else if (!strcmp (which, "hype"))
  2622.     {
  2623.       /* Note, this one returns a read-only string. */
  2624.       *data_ret = (char*)hype_au;
  2625.       *length_ret = sizeof (hype_au) - 1;
  2626.       *content_type_ret = AUDIO_BASIC;
  2627.     }
  2628. #ifndef NO_SECURITY
  2629.   else if (!strcmp (which, "rsalogo"))
  2630.     {
  2631.       /* Note, this one returns a read-only string. */
  2632.       *data_ret = (char *) rsalogo_gif;
  2633.       *length_ret = sizeof (rsalogo_gif) - 1;
  2634.       *content_type_ret = IMAGE_GIF;
  2635.     }
  2636. #endif
  2637. #ifdef JAVA
  2638.   else if (!strcmp (which, "javalogo"))
  2639.     {
  2640.       /* Note, this one returns a read-only string. */
  2641.       *data_ret = (char *) javalogo_gif;
  2642.       *length_ret = sizeof (javalogo_gif) - 1;
  2643.       *content_type_ret = IMAGE_GIF;
  2644.     }
  2645. #endif
  2646. #ifdef HAVE_QUICKTIME
  2647.   else if (!strcmp (which, "qtlogo"))
  2648.     {
  2649.       /* Note, this one returns a read-only string. */
  2650.       *data_ret = (char *) qt_logo_gif;
  2651.       *length_ret = sizeof (qt_logo_gif) - 1;
  2652.       *content_type_ret = IMAGE_GIF;
  2653.     }
  2654. #endif
  2655. #ifdef FORTEZZA
  2656.   else if (!strcmp (which, "litronic"))
  2657.     {
  2658.       /* Note, this one returns a read-only string. */
  2659.       *data_ret = (char *) litronic_gif;
  2660.       *length_ret = sizeof (litronic_gif) - 1;
  2661.       *content_type_ret = IMAGE_GIF;
  2662.     }
  2663. #endif
  2664.   else if (!strcmp (which, "coslogo"))
  2665.     {
  2666.       /* Note, this one returns a read-only string. */
  2667.       *data_ret = (char *) coslogo_jpg;
  2668.       *length_ret = sizeof (coslogo_jpg) - 1;
  2669.       *content_type_ret = IMAGE_JPG;
  2670.     }
  2671.   else if (!strcmp (which, "insologo"))
  2672.     {
  2673.       /* Note, this one returns a read-only string. */
  2674.       *data_ret = (char *) insologo_gif;
  2675.       *length_ret = sizeof (insologo_gif) - 1;
  2676.       *content_type_ret = IMAGE_GIF;
  2677.     }
  2678.   else if (!strcmp (which, "mclogo"))
  2679.     {
  2680.       /* Note, this one returns a read-only string. */
  2681.       *data_ret = (char *) mclogo_gif;
  2682.       *length_ret = sizeof (mclogo_gif) - 1;
  2683.       *content_type_ret = IMAGE_GIF;
  2684.     }
  2685.   else if (!strcmp (which, "ncclogo"))
  2686.     {
  2687.       /* Note, this one returns a read-only string. */
  2688.       *data_ret = (char *) ncclogo_gif;
  2689.       *length_ret = sizeof (ncclogo_gif) - 1;
  2690.       *content_type_ret = IMAGE_GIF;
  2691.     }
  2692.   else if (!strcmp (which, "odilogo"))
  2693.     {
  2694.       /* Note, this one returns a read-only string. */
  2695.       *data_ret = (char *) odilogo_gif;
  2696.       *length_ret = sizeof (odilogo_gif) - 1;
  2697.       *content_type_ret = IMAGE_GIF;
  2698.     }
  2699.   else if (!strcmp (which, "tdlogo"))
  2700.     {
  2701.       /* Note, this one returns a read-only string. */
  2702.       *data_ret = (char *) tdlogo_gif;
  2703.       *length_ret = sizeof (tdlogo_gif) - 1;
  2704.       *content_type_ret = IMAGE_GIF;
  2705.     }
  2706.   else if (!strcmp (which, "visilogo"))
  2707.     {
  2708.       /* Note, this one returns a read-only string. */
  2709.       *data_ret = (char *) visilogo_gif;
  2710.       *length_ret = sizeof (visilogo_gif) - 1;
  2711.       *content_type_ret = IMAGE_GIF;
  2712.     }
  2713. #endif /* !NETSCAPE_PRIV */
  2714. #ifdef EDITOR
  2715.   else if (!strcmp(which, "editfilenew"))
  2716.     {
  2717.       /* Magic about: for Editor new (blank) window */
  2718.       *data_ret = strdup(EDT_GetEmptyDocumentString());
  2719.       *length_ret = strlen (*data_ret);
  2720.       *content_type_ret = TEXT_MDL; 
  2721.     }
  2722. #endif
  2723.   else
  2724.     {
  2725.       char *a = NULL;
  2726.       char *type = TEXT_HTML;
  2727.       Boolean do_PR_snprintf = False;
  2728.       Boolean do_rot = True;
  2729.       if (!strcmp (which, ""))
  2730.     {
  2731.       do_PR_snprintf = True;
  2732.       a = fe_get_localized_file(XFE_ABOUT_FILE);
  2733.       if (a)
  2734.         {
  2735.           a = strdup(a);
  2736.           do_rot = False;
  2737.         }
  2738.       else
  2739.         {
  2740.           a = strdup (
  2741. #ifdef JAVA
  2742. #ifndef MOZ_COMMUNICATOR_ABOUT
  2743. #                  include "../../l10n/us/xp/about-java-lite.h"
  2744. #else
  2745. #                  include "../../l10n/us/xp/about-java.h"
  2746. #endif
  2747. #else
  2748. #ifndef MOZ_COMMUNICATOR_ABOUT
  2749. #                  include "../../l10n/us/xp/about-lite.h"
  2750. #else
  2751. #                  include "../../l10n/us/xp/about.h"
  2752. #endif
  2753. #endif
  2754.                  );
  2755.         }
  2756.     }
  2757.       else if (!strcmp (which, "splash"))
  2758.     {
  2759.       do_PR_snprintf = True;
  2760.       a = fe_get_localized_file(XFE_SPLASH_FILE);
  2761.       if (a)
  2762.         {
  2763.           a = strdup(a);
  2764.           do_rot = False;
  2765.         }
  2766.       else
  2767.         {
  2768.           a = strdup (
  2769. #ifdef JAVA
  2770. #ifndef MOZ_COMMUNICATOR_ABOUT
  2771. #                  include "../../l10n/us/xp/splash-java-lite.h"
  2772. #else
  2773. #                  include "../../l10n/us/xp/splash-java.h"
  2774. #endif
  2775. #else
  2776. #ifndef MOZ_COMMUNICATOR_ABOUT
  2777. #                  include "../../l10n/us/xp/splash-lite.h"
  2778. #else
  2779. #                  include "../../l10n/us/xp/splash.h"
  2780. #endif
  2781. #endif
  2782.                  );
  2783.         }
  2784.     }
  2785.       else if (!strcmp (which, "1994"))
  2786.     {
  2787.       ever_loaded_map = TRUE;
  2788.       a = strdup (
  2789. #              include "../../l10n/us/xp/authors2.h"
  2790.              );
  2791.     }
  2792.       else if (!strcmp (which,"license"))
  2793.     {
  2794.       type = TEXT_PLAIN;
  2795.       a = fe_get_localized_file(XFE_LICENSE_FILE);
  2796.       if (a)
  2797.         {
  2798.           a = strdup(a);
  2799.           do_rot = False;
  2800.         }
  2801.       else
  2802.         {
  2803.           a = strdup (fe_LicenseData);
  2804.         }
  2805.     }
  2806.  
  2807.       else if (!strcmp (which,"mozilla"))
  2808.     {
  2809.       a = strdup (
  2810. #              include "../../l10n/us/xp/mozilla.h"
  2811.               );
  2812.     }
  2813.       else if (!strcmp (which,
  2814.             "mailintro"))
  2815.     {
  2816.       type = MESSAGE_RFC822;
  2817.      a = fe_get_localized_file(XFE_MAILINTRO_FILE );
  2818.       if (a)
  2819.       {
  2820.         a = strdup( a );
  2821.         do_rot = False;
  2822.      }
  2823.      else
  2824.      {
  2825.           a = strdup (
  2826. #              include "../../l10n/us/xp/mail.h"
  2827.               );
  2828.      }
  2829.     }
  2830.  
  2831.       else if (!strcmp (which, "blank"))
  2832.     a = strdup ("");
  2833.       else if (!strcmp (which, "custom"))
  2834.         {
  2835.           do_rot = False;
  2836.       a = ekit_AboutData();
  2837.         }
  2838.  
  2839.  
  2840.       else if (!strcmp (which, "plugins"))
  2841.     {
  2842.       a = fe_get_localized_file(XFE_PLUGIN_FILE);
  2843.       if (a)
  2844.         {
  2845.           a = strdup(a);
  2846.           do_rot = False;
  2847.         }
  2848.       else
  2849.         {
  2850.           a = strdup (
  2851. #                  include "../../l10n/us/xp/aboutplg.h"
  2852.                  );
  2853.         }
  2854.     }
  2855.  
  2856.  
  2857.  
  2858.       else
  2859.     a = strdup ("\234\255\246\271\250\255\252\274\145\271\246"
  2860.             "\261\260\256\263\154\145\154\247\264\272\271"
  2861.             "\161\145\234\256\261\261\256\270\204");
  2862.       if (a)
  2863.     {
  2864.       if (do_rot)
  2865.         {
  2866.           for (tmp = (unsigned char *) a; *tmp; tmp++) *tmp -= 69;
  2867.         }
  2868.  
  2869.       if (do_PR_snprintf)
  2870.         {
  2871.           char *a2;
  2872.           int len;
  2873. #ifndef NO_SECURITY
  2874.           char *s0 = XP_GetString(XFE_SECURITY_WITH);
  2875.           char *s1 = XP_SecurityVersion(1);
  2876.           char *s2 = XP_SecurityCapabilities();
  2877.           char *ss;
  2878.           len = strlen(s0)+strlen(s1)+strlen(s2);
  2879.           ss = (char*) malloc(len);
  2880.           PR_snprintf(ss, len, s0, s1, s2);
  2881. #else
  2882.           char *ss = XP_GetString(XFE_SECURITY_DISABLED);
  2883. #endif
  2884.           len = strlen(a) + strlen(fe_version_and_locale) +
  2885.                         strlen(fe_version_and_locale) + strlen(ss);
  2886.           a2 = (char *) malloc(len);
  2887.           PR_snprintf (a2, len, a,
  2888.                fe_version_and_locale,
  2889.                fe_version_and_locale,
  2890.                ss
  2891.                );
  2892. #ifndef NO_SECURITY
  2893.           free (s2);
  2894.           free (ss);
  2895. #endif
  2896.           free (a);
  2897.           a = a2;
  2898.         }
  2899.  
  2900.       *data_ret = a;
  2901.       rv = a;  /* Return means 'free this later' */
  2902.       *length_ret = strlen (*data_ret);
  2903.       *content_type_ret = type;
  2904.     }
  2905.       else
  2906.     {
  2907.       *data_ret = 0;
  2908.       *length_ret = 0;
  2909.       *content_type_ret = 0;
  2910.     }
  2911.     }
  2912.   return rv;
  2913. }
  2914.  
  2915. void FE_FreeAboutData (void *fe_data, const char *which)
  2916. {
  2917.   if (fe_data) 
  2918.     free (fe_data);
  2919. }
  2920.  
  2921. /*****************************************************************************/
  2922. /*                       Image Library callbacks                             */
  2923. /*****************************************************************************/
  2924.  
  2925. /**************************** Icon dimensions ********************************/
  2926. JMC_PUBLIC_API(void)
  2927. _IMGCB_GetIconDimensions(IMGCB* img_cb, jint op, void* dpy_cx, int* width,
  2928.                          int* height, jint icon_number)
  2929. {
  2930.     MWContext *context = (MWContext *)dpy_cx; /* XXX This should be the FE's
  2931.                                                  display context. */
  2932.  
  2933.     /* Initialize the icon, if necessary. */
  2934.     if (icon_number >= IL_GOPHER_FIRST && icon_number <= IL_GOPHER_LAST)
  2935.         fe_init_gopher_icons (context);
  2936.     else if (icon_number >= IL_SA_FIRST && icon_number <= IL_SA_LAST)
  2937.         fe_init_sa_icons (context);
  2938.     else if (icon_number >= IL_MSG_FIRST && icon_number <= IL_MSG_LAST)
  2939.         fe_init_msg_icons (context);
  2940. #ifdef EDITOR
  2941.     else if (icon_number >= IL_EDIT_FIRST && icon_number <= IL_EDIT_LAST)
  2942.         fe_init_editor_icons(context);
  2943. #endif /*EDITOR*/
  2944.  
  2945.     /* Get the dimensions of the icon. */
  2946.     if (fe_icons [icon_number].pixmap) {
  2947.         *width  = fe_icons[icon_number].width;
  2948.         *height = fe_icons[icon_number].height;
  2949.     }
  2950.     else if (fe_icons [IL_IMAGE_NOT_FOUND].pixmap) {
  2951.         *width  = fe_icons[IL_IMAGE_NOT_FOUND].width;
  2952.         *height = fe_icons[IL_IMAGE_NOT_FOUND].height;
  2953.     }
  2954.     else /* aaaaagh! */ {
  2955.         *width = 50;
  2956.         *height = 50;
  2957.     }
  2958. }
  2959.  
  2960. /**************************** Icon display ***********************************/
  2961.  
  2962. JMC_PUBLIC_API(void)
  2963. _IMGCB_DisplayIcon(IMGCB* img_cb, jint op, void* dpy_cx, jint x, jint y,
  2964.                    jint icon_number)
  2965. {
  2966.     MWContext *context = (MWContext *)dpy_cx; /* XXX This should be the FE's
  2967.                                                  display context. */
  2968.     Pixmap icon_pixmap = fe_icons[icon_number].pixmap;
  2969.     Pixmap mask_pixmap = fe_icons[icon_number].mask;
  2970.     Pixmap tmp_mask = 0;
  2971.     fe_Drawable *fe_drawable = CONTEXT_DATA (context)->drawable;
  2972.     Drawable drawable = fe_drawable->xdrawable;
  2973.     Display *dpy = XtDisplay(CONTEXT_DATA (context)->drawing_area);
  2974.     int32 icon_x_offset, icon_y_offset;
  2975.     uint32 width, height;
  2976.     /*unsigned long flags;*/
  2977.  
  2978.     /* Compute the offset into the drawable of the icon origin. */
  2979.     icon_x_offset = x - CONTEXT_DATA(context)->document_x +
  2980.         fe_drawable->x_origin;
  2981.     icon_y_offset = y - CONTEXT_DATA(context)->document_y +
  2982.         fe_drawable->y_origin;
  2983.  
  2984.     if (!icon_pixmap) {
  2985.         icon_number = IL_IMAGE_NOT_FOUND;
  2986.         icon_pixmap = fe_icons[icon_number].pixmap;
  2987.     }
  2988.  
  2989.     width = fe_icons [icon_number].width;
  2990.     height = fe_icons [icon_number].height;
  2991.  
  2992.     if (icon_pixmap) {
  2993.         XGCValues gcv;
  2994.         unsigned long flags;
  2995.         GC gc;
  2996.         memset (&gcv, ~0, sizeof (gcv));
  2997.         gcv.function = GXcopy;
  2998.         flags = GCFunction;
  2999.  
  3000.         if (mask_pixmap) { /* #### no need for this if using default solid bg
  3001.                               color */
  3002.             /* We now have two masks: the icon's clip mask and the
  3003.                compositor's clip region, which both have different origins.
  3004.                When drawing the icon, we need to use a temporary clip mask
  3005.                which represents the logical AND of these two masks.  This 
  3006.                leaves the original icon clip mask unaltered for future
  3007.                use. */
  3008.  
  3009.             XGCValues gcv2;
  3010.             GC gc2;
  3011.  
  3012.             /* The clip origin for the icon clip mask. */
  3013.             gcv.clip_x_origin = icon_x_offset;
  3014.             gcv.clip_y_origin = icon_y_offset;
  3015.  
  3016.             /* Create a temporary mask and clear it. */
  3017.             tmp_mask = XCreatePixmap (dpy, drawable, width, height, 1);
  3018.             gcv2.function = GXclear;
  3019.             gc2 = XCreateGC (dpy, tmp_mask, GCFunction, &gcv2);
  3020.             XFillRectangle(dpy, tmp_mask, gc2, 0, 0, width, height);
  3021.  
  3022.             /* Use the compositors' clip region as a clip mask when copying
  3023.                the icon mask to the temporary mask.  Note that XSetRegion
  3024.                must be called before setting gc2's clip origin. */
  3025.             if (fe_drawable->clip_region)
  3026.                 XSetRegion(dpy, gc2, fe_drawable->clip_region);
  3027.             gcv2.function = GXcopy;
  3028.             gcv2.clip_x_origin = -gcv.clip_x_origin;
  3029.             gcv2.clip_y_origin = -gcv.clip_y_origin;
  3030.             XChangeGC(dpy, gc2, GCFunction | GCClipXOrigin | GCClipYOrigin,
  3031.                       &gcv2);
  3032.             XCopyArea (dpy, mask_pixmap, tmp_mask, gc2, 0, 0, width, height,
  3033.                        0, 0);
  3034.  
  3035.             /* Now use the temporary clip mask to draw the icon.  */
  3036.             gcv.clip_mask = tmp_mask;
  3037.             flags |= (GCClipMask | GCClipXOrigin | GCClipYOrigin);
  3038.             gc = fe_GetGCfromDW (dpy, drawable, flags, &gcv, NULL);
  3039.             XFreeGC(dpy, gc2);
  3040.     }
  3041.         else {
  3042.             /* We only have to deal with the compositor's clip region
  3043.                when drawing the icon. */
  3044.             gc = fe_GetGCfromDW (dpy, drawable, flags, &gcv,
  3045.                                  fe_drawable->clip_region);
  3046.         }
  3047.         XCopyArea (dpy, icon_pixmap, drawable, gc, 0, 0, width, height,
  3048.                    icon_x_offset, icon_y_offset);
  3049.  
  3050.         if (tmp_mask)
  3051.             XFreePixmap(dpy, tmp_mask);
  3052.     } else { /* aaaaagh! */
  3053.         fe_DrawShadows(context, fe_drawable,
  3054.                        icon_x_offset, icon_y_offset, 50, 50, 2, XmSHADOW_OUT);
  3055.     }
  3056. }
  3057.  
  3058. /*****************************************************************************/
  3059. /*                       End of Image Library callbacks                      */
  3060. /*****************************************************************************/
  3061.  
  3062. /*
  3063.  * Given an icon number, return a pointer to the corresponding static icon
  3064.  * data.  It would be a good idea to consider making this the central place
  3065.  * for associating icon numbers with icon data, since it would help simplify
  3066.  * all the XFE icon initialization code above.
  3067.  *
  3068.  * Currently, this function only deals with icons which appear on the page,
  3069.  * since its only use is to support the PostScript Front End.
  3070.  */
  3071. static struct fe_icon_data *
  3072. fe_get_icon_data(int icon_number) 
  3073. {
  3074.     switch (icon_number) {
  3075.  
  3076.         /* Image placeholder icons. */
  3077.     case IL_IMAGE_DELAYED:
  3078.         return &IReplace;
  3079.     case IL_IMAGE_NOT_FOUND:
  3080.         return &IconUnknown;
  3081.     case IL_IMAGE_BAD_DATA:
  3082.         return &IBad;
  3083. #ifndef NO_SECURITY
  3084.     case IL_IMAGE_INSECURE:
  3085.         return &SEC_Replace;
  3086. #endif /* ! NO_SECURITY */
  3087.     case IL_IMAGE_EMBED:
  3088.         return &IconUnknown;
  3089.  
  3090.         /* Gopher icons. */
  3091.     case IL_GOPHER_TEXT:
  3092.         return >ext;
  3093.     case IL_GOPHER_IMAGE:
  3094.         return &GImage;
  3095.     case IL_GOPHER_BINARY:
  3096.         return &GBinary;
  3097.     case IL_GOPHER_SOUND:
  3098.         return &GAudio;
  3099.     case IL_GOPHER_MOVIE:
  3100.         return &GMovie;
  3101.     case IL_GOPHER_FOLDER:
  3102.         return &GFolder;
  3103.     case IL_GOPHER_SEARCHABLE:
  3104.         return &GFind;
  3105.     case IL_GOPHER_TELNET:
  3106.         return >elnet;
  3107.     case IL_GOPHER_UNKNOWN:
  3108.         return &GUnknown;
  3109.  
  3110. #ifdef EDITOR    
  3111.         /* Editor icons. */
  3112.     case IL_EDIT_NAMED_ANCHOR:
  3113.         return &ed_target;
  3114.     case IL_EDIT_FORM_ELEMENT:
  3115.         return &ed_form;
  3116.     case IL_EDIT_UNSUPPORTED_TAG:
  3117.         return &ed_tag;
  3118.     case IL_EDIT_UNSUPPORTED_END_TAG:
  3119.         return &ed_tage;
  3120. #endif /* EDITOR */
  3121.         
  3122.         /* Security Advisor and S/MIME icons. */
  3123.     case IL_SA_SIGNED:
  3124.         return &A_Signed;
  3125.     case IL_SA_ENCRYPTED:
  3126.         return &A_Encrypt;
  3127.     case IL_SA_NONENCRYPTED:
  3128.         return &A_NoEncrypt;
  3129.     case IL_SA_SIGNED_BAD:
  3130.         return &A_SignBad;
  3131.     case IL_SA_ENCRYPTED_BAD:
  3132.         return &A_EncrypBad;
  3133.     case IL_SMIME_ATTACHED:
  3134.         return &M_Attach;
  3135.     case IL_SMIME_SIGNED:
  3136.         return &M_Signed;
  3137.     case IL_SMIME_ENCRYPTED:
  3138.         return &M_Encrypt;
  3139.     case IL_SMIME_ENC_SIGNED:
  3140.         return &M_SignEncyp;
  3141.     case IL_SMIME_SIGNED_BAD:
  3142.         return &M_SignBad;
  3143.     case IL_SMIME_ENCRYPTED_BAD:
  3144.         return &M_EncrypBad;
  3145.     case IL_SMIME_ENC_SIGNED_BAD:
  3146.         return &M_SgnEncypBad;
  3147.  
  3148.         /* Message attachment icon. */
  3149.     case IL_MSG_ATTACH:
  3150.         return &M_ToggleAttach;
  3151.  
  3152.         /* Return NULL if the icon number is not recognized. */
  3153.     default:
  3154.         return NULL;
  3155.     }
  3156. }
  3157.  
  3158. /* Get the dimensions of an icon in pixels for the PostScript front end. */
  3159. void
  3160. FE_GetPSIconDimensions(int icon_number, int *width, int *height)
  3161. {
  3162.     struct fe_icon_data *icon_data = fe_get_icon_data(icon_number);
  3163.     
  3164.     if (icon_data) {
  3165.         *width = icon_data->width;
  3166.         *height = icon_data->height;
  3167.     }
  3168.     else {
  3169.         *width = 0;
  3170.         *height = 0;
  3171.     }
  3172. }
  3173.  
  3174. /* Fill in the bits of an icon for the PostScript front end. */
  3175. XP_Bool
  3176. FE_GetPSIconData(int icon_number, IL_Pixmap *image, IL_Pixmap *mask) 
  3177. {
  3178.     uint8 bit_mask;
  3179.     int i, j, width, widthBytes, height, depth;
  3180.     int pixel_number, palette_index, mask_count;
  3181.     NI_PixmapHeader *img_header;
  3182.     struct fe_icon_data *icon_data;
  3183.     uint8 *color_bits, *mask_bits;
  3184.  
  3185.     icon_data = fe_get_icon_data(icon_number);
  3186.     if (!icon_data)
  3187.         return FALSE;
  3188.  
  3189.     img_header = &image->header;
  3190.     height = img_header->height;
  3191.     width = img_header->width;
  3192.     widthBytes = img_header->widthBytes;
  3193.     depth = img_header->color_space->pixmap_depth;
  3194.     color_bits = icon_data->color_bits;
  3195.     mask_bits = icon_data->mask_bits;
  3196.     
  3197.     XP_ASSERT(width == icon_data->width);
  3198.     XP_ASSERT(height == icon_data->height);
  3199.     XP_ASSERT(image->bits);
  3200.     
  3201.     switch (depth) {
  3202.     case 16:
  3203.         pixel_number = 0;
  3204.         bit_mask = 0x01;        /* Current bit within current mask byte. */
  3205.         mask_count = 0;         /* Current mask byte number. */
  3206.         for (i = 0; i < height; i++) {
  3207.             uint16 *bits = (uint16 *)((uint8 *)image->bits + widthBytes * i);
  3208.  
  3209.             for (j = 0; j < width; j++) {
  3210.                 /* If we have a mask, check whether the mask bit for this
  3211.                    pixel is set. */
  3212.                 if (mask_bits && !(mask_bits[mask_count] & bit_mask)) {
  3213.                     *bits++ = 0x0fff;
  3214.                 }
  3215.                 else {
  3216.                     palette_index = color_bits[pixel_number];
  3217.                     *bits++ = ((fe_icon_colors[palette_index][0]&0x00f0)<<4) +
  3218.                         (fe_icon_colors[palette_index][1]&0x00f0) +
  3219.                         ((fe_icon_colors[palette_index][2]&0x00f0)>>4);
  3220.                 }
  3221.                 pixel_number++;
  3222.                 if (bit_mask == 0x80) {
  3223.                     /* Start a new mask byte. */
  3224.                     bit_mask = 0x01;
  3225.                     mask_count++;
  3226.                 }
  3227.                 else {
  3228.                     bit_mask <<= 1;
  3229.                 }
  3230.             }
  3231.  
  3232.             /* Start next row of mask with a new byte. */
  3233.             if (bit_mask != 0x01) {
  3234.                 bit_mask = 0x01;
  3235.                 mask_count++;
  3236.             }
  3237.         }
  3238.         return TRUE;
  3239.         
  3240.     case 32:
  3241.         pixel_number = 0;
  3242.         bit_mask = 0x01;        /* Current bit within current mask byte. */
  3243.         mask_count = 0;         /* Current mask byte number. */
  3244.         for (i = 0; i < height; i++) {
  3245.             uint32 *bits = (uint32 *)((uint8 *)image->bits + widthBytes * i);
  3246.  
  3247.             for (j = 0; j < width; j++) {
  3248.                 /* If we have a mask, check whether the mask bit for this
  3249.                    pixel is set. */
  3250.                 if (mask_bits && !(mask_bits[mask_count] & bit_mask)) {
  3251.                     *bits++ = 0x00ffffff;
  3252.                 }
  3253.                 else {
  3254.                     palette_index = color_bits[pixel_number];
  3255.                     *bits++ = ((fe_icon_colors[palette_index][0]&0x00ff)<<16) +
  3256.                         ((fe_icon_colors[palette_index][1]&0x00ff)<<8) +
  3257.                         (fe_icon_colors[palette_index][2]&0x00ff);
  3258.                 }
  3259.                 pixel_number++;
  3260.                 if (bit_mask == 0x80) {
  3261.                     /* Start a new mask byte. */
  3262.                     bit_mask = 0x01;
  3263.                     mask_count++;
  3264.                 }
  3265.                 else {
  3266.                     bit_mask <<= 1;
  3267.                 }
  3268.             }
  3269.  
  3270.             /* Start next row of mask with a new byte. */
  3271.             if (bit_mask != 0x01) {
  3272.                 bit_mask = 0x01;
  3273.                 mask_count++;
  3274.             }
  3275.         }
  3276.         return TRUE;
  3277.     
  3278.     default:
  3279.         return FALSE;
  3280.     }
  3281. }
  3282.