home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / IconGroup.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.8 KB  |  212 lines

  1. /* -*- Mode: C++; tab-width: 4; 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.    IconGroup.c -- functions dealing with icon groups.
  20.    Created: Chris Toshok <toshok@netscape.com>, 13-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #define WANT_GROUPS
  26. #include "IconGroup.h"
  27. #undef WANT_GROUPS
  28.  
  29. //////////////////////////////////////////////////////////////////////////
  30. //
  31. // Private functions
  32. //
  33. //////////////////////////////////////////////////////////////////////////
  34. /* extern */ void
  35. IconGroup_createOneIcon(fe_icon *                icon,
  36.                         struct fe_icon_data *    data,
  37.                         Widget                    toplevel,
  38.                         Pixel                    foreground_pixel,
  39.                         Pixel                    background_pixel)
  40. {
  41.     // Create the icon only if the info and data are not NULL
  42.     if (icon->pixmap == 0 && data)
  43.     {
  44.         fe_NewMakeIcon(toplevel,
  45.                        foreground_pixel,
  46.                        background_pixel,
  47.                        icon,
  48.                        NULL,
  49.                        data->width,
  50.                        data->height,
  51.                        data->mono_bits,
  52.                        data->color_bits,
  53.                        data->mask_bits,
  54.                        False);
  55.     }
  56. }
  57. //////////////////////////////////////////////////////////////////////////
  58.  
  59. //////////////////////////////////////////////////////////////////////////
  60. //
  61. // Public functions
  62. //
  63. //////////////////////////////////////////////////////////////////////////
  64. /* extern */ void
  65. IconGroup_createAllIcons(IconGroup *group, 
  66.                          Widget toplevel, 
  67.                          Pixel foreground_pixel, 
  68.                          Pixel transparent_pixel)
  69. {
  70.     // Normal icon.
  71.     IconGroup_createOneIcon(&group->pixmap_icon,
  72.                             group->pixmap_data,
  73.                             toplevel,
  74.                             foreground_pixel,
  75.                             transparent_pixel);
  76.  
  77.     // Insensitive icon.
  78.     IconGroup_createOneIcon(&group->pixmap_i_icon,
  79.                             group->pixmap_i_data,
  80.                             toplevel,
  81.                             foreground_pixel,
  82.                             transparent_pixel);
  83.  
  84.     // Mouse-over icon.
  85.     IconGroup_createOneIcon(&group->pixmap_mo_icon,
  86.                             group->pixmap_mo_data,
  87.                             toplevel,
  88.                             foreground_pixel,
  89.                             transparent_pixel);
  90.     
  91.     // Mouse-down icon.
  92.     IconGroup_createOneIcon(&group->pixmap_md_icon,
  93.                             group->pixmap_md_data,
  94.                             toplevel,
  95.                             foreground_pixel,
  96.                             transparent_pixel);
  97. }
  98. //////////////////////////////////////////////////////////////////////////
  99.  
  100.  
  101. typedef struct 
  102. {
  103.     char *        name;
  104.     IconGroup * group;
  105. } _name_and_group_t;
  106.  
  107. static _name_and_group_t _iconGroups[] =
  108. {
  109.     // Browser
  110.     { "Back",            &TB_Back_group },
  111.     { "Forward",        &TB_Forward_group },
  112.     { "Home",            &TB_Home_group },
  113.     { "Search",            &TB_Search_group },
  114.     { "Places",            &TB_Places_group },
  115.     { "LoadImages",        &TB_LoadImages_group },
  116.     { "Print",            &TB_Print_group },
  117.     { "Reload",            &TB_Reload_group },
  118.     { "Stop",            &TB_Stop_group },
  119.     { "MixSecurity",    &TB_MixSecurity_group },
  120. #ifdef MOZ_MAIL_NEWS
  121.     // Mail/News
  122.     { "GetMsg",            &MNTB_GetMsg_group },
  123.     { "Compose",        &MNTB_Compose_group },
  124.     { "Addgroup",        &MNTB_AddGroup_group },
  125.     { "Reply",            &MNTB_Reply_group },
  126.     { "ReplyAll",        &MNTB_ReplyAll_group },
  127.     { "Forward",        &MNTB_Forward_group },
  128.     { "File",            &MNTB_File_group },
  129.     { "Trash",            &MNTB_Trash_group },
  130.     { "Next",            &MNTB_Next_group },
  131.     { "Prev",            &MNTB_Prev_group },
  132.     { "NewFolder",        &MNTB_NewFolder_group },
  133.     { "MarkRead",        &MNTB_MarkRead_group },
  134.  
  135.     // Compose
  136.     { "Send",            &MNC_Send_group },
  137.     { "Quote",            &MNC_Quote_group },
  138.     { "Address",        &MNC_Address_group },
  139.     { "Attach",            &MNC_Attach_group },
  140.     { "SpellCheck",        &MNC_SpellCheck_group },
  141.     { "Save",            &MNC_Save_group },
  142.     { "Directory",        &MNC_Directory_group },
  143.  
  144.     // Address Book
  145.     { "NewPerson",        &MNAB_NewPerson_group },
  146.     { "NewList",        &MNAB_NewList_group },
  147.     { "Properties",        &MNAB_Properties_group },
  148.     { "Call",            &MNAB_Call_group },
  149. #endif
  150. #ifdef EDITOR
  151.     // Editor
  152.     { "New",            &ed_new_group },
  153.     { "Open",            &ed_open_group },
  154.     { "Browse",            &ed_browse_group },
  155.     { "Save",            &ed_save_group },
  156.     { "Publish",        &ed_publish_group },
  157.     { "Cut",            &ed_cut_group },
  158.     { "Copy",            &ed_copy_group },
  159.     { "Paste",            &ed_paste_group },
  160.     { "Link",            &ed_link_group },
  161.     { "Target",            &ed_target_group },
  162.     { "Image",            &ed_image_group },
  163.     { "Hrule",            &ed_hrule_group },
  164.     { "Table",            &ed_table_group },
  165.     { "Bold",            &ed_bold_group },
  166.     { "Italic",            &ed_italic_group },
  167.     { "Underline",        &ed_underline_group },
  168.     { "Bullet",            &ed_bullet_group },
  169.     { "Number",            &ed_number_group },
  170.     { "Indent",            &ed_indent_group },
  171.     { "Outdent",        &ed_outdent_group },
  172.     { "Left",            &ed_left_group },
  173.     { "Center",            &ed_center_group },
  174.     { "Right",            &ed_right_group },
  175.     { "Find",            &ed_find_group },
  176.     { "Spellcheck",        &ed_spellcheck_group },
  177.     { "Print",            &ed_print_group },
  178.     { "Insert",            &ed_insert_group },
  179.     { "Clear",            &ed_clear_group },
  180. #endif /* EDITOR */
  181. };
  182.  
  183. //////////////////////////////////////////////////////////////////////////
  184. //
  185. // Find the icon group for a name
  186. //
  187. //////////////////////////////////////////////////////////////////////////
  188. IconGroup *
  189. IconGroup_findGroupForName(char * name)
  190. {
  191.     Cardinal i;
  192.  
  193.     if (!name)
  194.     {
  195.         return NULL;
  196.     }
  197.  
  198.     for(i = 0; i < XtNumber(_iconGroups); i++)
  199.     {
  200.         _name_and_group_t * pair = &_iconGroups[i];
  201.  
  202.         if (XP_STRCASECMP(name,pair->name) == 0)
  203.         {
  204.             return pair->group;
  205.         }
  206.     }
  207.  
  208.         // The home icon
  209.     return &TB_Home_group;
  210. }
  211.  
  212.