home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFILEMAN / XFILEMAN.TAR / xfilemanager / graph.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-24  |  25.7 KB  |  782 lines

  1. /*
  2.  * Copyright 1993 by Ove Kalkan, Cremlingen, Germany
  3.  *
  4.  * Permission to use, copy, modify, distribute and sell this software and it's
  5.  * documentation for any purpose is hereby granted without fee, rpovided that
  6.  * the above copyright notice and this permission appear in supporting
  7.  * documentation, and that the name of Ove Kalkan not to be used in
  8.  * advertising or publicity pertaining to distributiopn of the software without
  9.  * specific, written prior permission. Ove Kalkan makes no representations
  10.  * about the suitability of this software for any purpose. It is provided
  11.  * as is without express or implied warranty.
  12.  *
  13.  * OVE KALKAN DISPLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  14.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABLILITY AND FITNESS, IN NO
  15.  * EVENT SHALL OVE KALKAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  16.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  17.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19.  * PERFORMANCE OF THIS SOFTWARE.
  20.  *
  21.  * $Header: filename,v 1.0 yyyy/mm/dd hh:mm:ss loginname Exp $
  22.  */
  23.  
  24. #include "global.h"
  25.  
  26. #ifdef    HAVE_XPM
  27. #include "icons.h"
  28. #else
  29. #include "bitmaps.h"
  30. #endif
  31.  
  32. /*
  33.  * The Cursor-bitmaps are only needed in this file
  34.  */
  35. #include "cursor.h"
  36. #include "cursorm.h"
  37. #include "fcursor.h"
  38. #include "fcursorm.h"
  39. #include "wcursor.h"
  40. #include "wcursorm.h"
  41.  
  42.  
  43. /*
  44.  * Global variables
  45.  */
  46.  
  47. #ifdef HAVE_XPM
  48. static    XpmAttributes    attr;
  49. #endif
  50.  
  51.  
  52. /*********************************************************
  53.  * name:    makeCursor
  54.  * description:    Erzeugt einen Cursor aus einem Icon und einem Text
  55.  * input:    Pixmap    icon
  56.  *        char    *label
  57.  * output:    Zeiger auf den Cursor
  58.  * date:    Main 93
  59.  *********************************************************/
  60. void    makeCursor ()
  61. {
  62.     Pixmap    pmap;
  63.     Pixmap    smap;
  64.     XColor    fg,bg;
  65.  
  66.     /*
  67.      * Die Pixmap erzeugen
  68.      */
  69.     fg.red = fg.blue = fg.green = 0;
  70.     bg.red = bg.blue = bg.green = 0xffff;
  71.     pmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), cursor_bits,
  72.                        cursor_width,cursor_height, 1,0, 1);
  73.     smap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), cursorm_bits,
  74.                        cursorm_width,cursorm_height, 1,0, 1);
  75.  
  76.     def_cursor = XCreatePixmapCursor(XtDisplay(toplevel),pmap,smap,&fg,&bg,
  77.                      cursor_x_hot,cursor_y_hot);
  78.  
  79.     pmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), fcursor_bits,
  80.                        fcursor_width,fcursor_height, 1,0, 1);
  81.     smap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), fcursorm_bits,
  82.                        fcursorm_width,fcursorm_height, 1,0, 1);
  83.  
  84.     file_cursor = XCreatePixmapCursor(XtDisplay(toplevel),pmap,smap,&fg,&bg,
  85.                       fcursor_x_hot,fcursor_y_hot);
  86.  
  87.     pmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), wcursor_bits,
  88.                        wcursor_width,wcursor_height, 1,0, 1);
  89.     smap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(toplevel), wcursorm_bits,
  90.                        wcursorm_width,wcursorm_height, 1,0, 1);
  91.  
  92.     busy_cursor = XCreatePixmapCursor(XtDisplay(toplevel),pmap,smap,&fg,&bg,0,0);
  93. }
  94.  
  95.  
  96.  
  97.  
  98. /*********************************************************
  99.  * name:    drawDir
  100.  * description:    zeichnet das Icon und den Names eine Dirs
  101.  *        im Dir-Feld
  102.  * input:    Widget        window;        Zielfenster
  103.  *        Dir_Glyph    *dir;        Dir-Eintrag
  104.  *        Boolean        selected;    Angewaehlt
  105.  *        Boolean        back;        Hintergrund zeichnen
  106.  * output:    -
  107.  * date:    10.6.1993
  108.  *********************************************************/
  109. void    drawDir (Widget window, Dir_Glyph *dir, Boolean selected, Boolean back)
  110. {
  111.     Pixmap    pmap;
  112.     GC    gc = line_gc;
  113.     char    buf[400];
  114.  
  115.     if (dir->flags&DIR_LINK && dir->link)
  116.         sprintf(buf,"%s -> %s",dir->name,dir->link);
  117.     else
  118.         sprintf(buf,"%s",dir->name);
  119.  
  120.     /*
  121.      * Ueberpruefen ob der Hintergrund gezeichnet werden soll oder nicht
  122.      */
  123.     if (back) {
  124.         /*
  125.          * Nachsehen ob der Eintrag angewaehlt ist oder nicht
  126.          */
  127.         if (selected) {
  128.             XFillRectangle (XtDisplay(window),XtWindow(window), selc_gc,
  129.                     dir->x + 20, dir->y, 
  130.                     XTextWidth(defaults.icon_font,buf,
  131.                     strlen(buf)) + 8, 16);
  132.             gc = white_gc;
  133.         }
  134.         else
  135.             XFillRectangle (XtDisplay(window),XtWindow(window), back_gc,
  136.                     dir->x + 20, dir->y, 
  137.                     XTextWidth(defaults.icon_font,buf,
  138.                     strlen(buf)) + 8, 16);
  139.     }
  140.  
  141.     /*
  142.      * Den Label ausgeben
  143.      */
  144.     XDrawString (XtDisplay(window),XtWindow(window), gc,
  145.             dir->x + 24, dir->y + 12, buf,
  146.             strlen(buf));
  147.  
  148.     /*
  149.      * Das Icon ausgeben
  150.      */
  151.     if (!(dir->flags & DIR_READABLE))
  152.         pmap = Dir_Locked_PM;
  153.     else if (dir->flags & DIR_LINK)
  154.         pmap = File_DLink_PM;
  155.     else if (dir->open)
  156.         pmap = Dir_Opened_PM;
  157.     else
  158.         pmap = Dir_Closed_PM;
  159.  
  160.     XCopyArea (XtDisplay(window), pmap, 
  161.             XtWindow(window), line_gc, 0,0, 16,16,
  162.             dir->x, dir->y);
  163. }
  164.  
  165.  
  166.  
  167. /*********************************************************
  168.  * name:    drawFile
  169.  * description:    zeichnet das Icon und den Names eine File
  170.  *        im Dir-Feld
  171.  * input:    Folder_Glyph    *folder;        Zielfenster
  172.  *        Dimension    entry;        File-Eintrag
  173.  *        Boolean        selected;    Angewaehlt
  174.  *        Boolean        back;        Hintergrund zeichnen
  175.  * output:    -
  176.  * date:    10.6.1993
  177.  *********************************************************/
  178. void    drawFile (Folder_Glyph *folder, int entry,
  179.           Boolean selected, Boolean back)
  180. {
  181.     Pixmap        pmap;
  182.     Widget        window;
  183.     File_Glyph    *file;
  184.     GC        gc = line_gc;
  185.  
  186.     window = folder->window;
  187.     file = folder->file[entry];
  188.  
  189.     /*
  190.      * Ueberpruefen ob der Hintergrund gezeichnet werden soll oder nicht
  191.      */
  192.     if (back) {
  193.         /*
  194.          * Nachsehen ob der Eintrag angewaehlt ist oder nicht
  195.          */
  196.         if (selected) {
  197.             XFillRectangle (XtDisplay(window),XtWindow(window), selc_gc,
  198.                     40, entry*DIR_Y_STEP + 6,
  199.                     folder->max_length - DIR_X_STEP + 50
  200.                     + typelength, 16);
  201.             gc = white_gc;
  202.         }
  203.         else
  204.             XFillRectangle (XtDisplay(window),XtWindow(window), back_gc,
  205.                     40, entry*DIR_Y_STEP + 6,
  206.                     folder->max_length - DIR_X_STEP + 50
  207.                     + typelength, 16);
  208.     }
  209.  
  210.     /*
  211.      * Den Label ausgeben
  212.      */
  213.     XDrawString (XtDisplay(window),XtWindow(window), gc,
  214.             44, entry*DIR_Y_STEP + 18, file->name,
  215.             strlen(file->name));
  216.  
  217.     {    char    buf[100];
  218.  
  219.         sprintf(buf,"%8d Bytes",file->size);
  220.         XDrawString(XtDisplay(window),XtWindow(window), gc,
  221.                 44 + folder->max_length - DIR_X_STEP
  222.                 - XTextWidth(defaults.icon_font,buf,
  223.                          strlen(buf)), 
  224.                 entry*DIR_Y_STEP + 18, buf, strlen(buf));
  225.  
  226. #ifdef SHOWRIGHTS
  227.         /* Rechte ausgeben */
  228.         sprintf(buf,"%c%c%c%c%c%c%c%c%c%c", 
  229. #ifndef COHERENT
  230.             S_ISLNK(file->mode) ? 'l' :
  231. #endif
  232.             S_ISDIR(file->mode) ? 'd' :
  233.             S_ISCHR(file->mode) ? 'c' :
  234.             S_ISBLK(file->mode) ? 'b' : '-',
  235.             S_IRUSR&file->mode ? 'r' : '-',
  236.             S_IWUSR&file->mode ? 'w' : '-',
  237.             S_IXUSR&file->mode ? 'x' : '-',
  238.             S_IRGRP&file->mode ? 'r' : '-',
  239.             S_IWGRP&file->mode ? 'w' : '-',
  240.             S_ISUID&file->mode ? 's' :
  241.             S_ISGID&file->mode ? 'g' :
  242.             S_IXGRP&file->mode ? 'x' : '-',
  243.             S_IROTH&file->mode ? 'r' : '-',
  244.             S_IWOTH&file->mode ? 'w' : '-',
  245.             S_ISUID&file->mode ? 's' :
  246.             S_ISGID&file->mode ? 'g' :
  247.             S_IXOTH&file->mode ? 'x' : '-');
  248.         XDrawString(XtDisplay(window),XtWindow(window),gc,
  249.                 34 + folder->max_length,entry*DIR_Y_STEP + 18,
  250.                 buf,strlen(buf));
  251.         /*
  252.          * First I though of also displaying the user names, but this would
  253.          * be to much at this place.
  254.          */
  255. #endif
  256.         /* Kurzbeschreibung */
  257. /*        if (file->prog_type < max_filetypes)
  258.             XDrawString (XtDisplay(window),XtWindow(window),gc,
  259.                 44 + folder->max_length,entry*DIR_Y_STEP + 18,
  260.                 filetypes[file->prog_type].description,
  261.                 strlen(filetypes[file->prog_type].description));
  262. */    }
  263.  
  264.     /*
  265.      * Das Icon ausgeben
  266.      */
  267.     switch (file->prog_type) {
  268.         case FILE_ROOT:
  269.             pmap = File_Root_PM;
  270.             break;
  271.         case FILE_LINK:
  272.             pmap = File_Link_PM;
  273.             break;
  274.         case FILE_LOCK:
  275.             pmap = File_Lock_PM;
  276.             break;
  277.         case FILE_DIR:
  278.             pmap = Dir_Closed_PM;
  279.             break;
  280.         case FILE_LDIR:
  281.             pmap = File_DLink_PM;
  282.             break;
  283.         case FILE_EXEC:
  284.             pmap = File_Exec_PM;
  285.             break;
  286.         case FILE_TAR:
  287.             pmap = File_Tar_PM;
  288.             break;
  289.         case FILE_CTAR:
  290.             pmap = File_CTar_PM;
  291.             break;
  292.         case FILE_GHOST:
  293.             pmap = File_Ghost_PM;
  294.             break;
  295.         default: {
  296.             int    i = 0;
  297.             Boolean    NOT_ENDE = 1;
  298.  
  299.             pmap = File_Plain_PM;
  300.             if (file->prog_type != FILE_PLAIN && 
  301.                 filetypes[file->prog_type].pmap)
  302.                 pmap = *filetypes[file->prog_type].pmap;
  303.         }
  304.     }
  305.     XCopyArea (XtDisplay(window), pmap, XtWindow(window), line_gc,
  306.             0,0, 16,16,20,entry*DIR_Y_STEP + 6);
  307. }
  308.  
  309.  
  310. /*********************************************************
  311.  * name:    drawWSE
  312.  * description:    Zeichnen eines Workspaceentries in einem
  313.  *        Workspacewindow
  314.  * input:    WS_Glyph    *ws    - der Workspace
  315.  *        Dimension    entry    - Eintragnummer
  316.  *        Boolean        selected - Selcetiert?
  317.  *        Boolean        back    - Hintergrund
  318.  * output:    none
  319.  * author:    Ove Kalkan
  320.  * date:    29.6.93
  321.  *********************************************************/
  322. void    drawWSE (WS_Glyph *ws, Dimension entry,
  323.          Boolean selected, Boolean back)
  324. {
  325.     Pixmap        pmap;
  326.     Widget        window;
  327.     WSE_Glyph    *wse;
  328.     GC        gc = line_gc;
  329.     Dimension    tl;
  330.  
  331.     window = ws->window;
  332.     wse = ws->wse[entry];
  333.     tl = XTextWidth(defaults.icon_font,wse->label,strlen(wse->label)) + 8;
  334.  
  335.     /*
  336.      * Ueberpruefen ob der Hintergrund gezeichnet werden soll oder nicht
  337.      */
  338.     if (back) {
  339.         /*
  340.          * Nachsehen ob der Eintrag angewaehlt ist oder nicht
  341.          */
  342.         if (selected) {
  343.             XFillRectangle (XtDisplay(window),XtWindow(window), selc_gc,
  344.                     wse->x - tl/2 + 2, wse->h + wse->y + 5,
  345.                     tl, 16);
  346.             gc = white_gc;
  347.         }
  348.         else
  349.             XFillRectangle (XtDisplay(window),XtWindow(window), back_gc,
  350.                     wse->x - tl/2 + 2, wse->h + wse->y + 5,
  351.                     tl, 16);
  352.     }
  353.  
  354.     /*
  355.      * Icon raussuchen und ausgeben
  356.      */
  357.     if (!wse->pmap) {
  358.         XDrawString (XtDisplay(window),XtWindow(window), gc,
  359.                 wse->x - tl/2 + 6, wse->y + 32, 
  360.                 wse->label,strlen(wse->label));
  361.         XCopyArea (XtDisplay(window),File_Exec_PM,XtWindow(window), gc,
  362.                0,0,16,16,wse->x - 8, wse->y);
  363.     }
  364.     else {
  365.         XDrawString (XtDisplay(window),XtWindow(window), gc,
  366.                 wse->x - tl/2 + 6, wse->h + wse->y + 16, 
  367.                 wse->label,strlen(wse->label));
  368. /*        if (wse->shape)
  369.             XShapeCombineMask(XtDisplay(window),XtWindow(window),
  370.                     ShapeBounding,wse->x - wse->w/2, wse->y,
  371.                     wse->shape,ShapeSet);
  372. */        XCopyArea (XtDisplay(window),wse->pmap,XtWindow(window), gc,
  373.                0,0,wse->w,wse->h,wse->x - wse->w/2, wse->y);
  374.     }
  375. }
  376.  
  377.  
  378. /*********************************************************
  379.  * name:    load icons
  380.  * description:    einlesen der icons aus dem Datenfile
  381.  * input:    none
  382.  * output:    none
  383.  * date:    10.5.93
  384.  *********************************************************/
  385. void    loadIcons (void)
  386. {
  387. #ifdef HAVE_XPM
  388.     /*
  389.      * Die Pixmaps fuer die Pictogramme laden
  390.      */
  391.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  392.                      XtWindow(toplevel), icon_move,
  393.                      &Icon_Move_PM, &smap,
  394.                      &attr) != XpmSuccess)
  395.         FATAL_ERROR("main: Failed to get Move Icon\n");
  396.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  397.                      XtWindow(toplevel), icon_copy,
  398.                      &Icon_Copy_PM, &smap,
  399.                      &attr) != XpmSuccess)
  400.         FATAL_ERROR("main: Failed to get Copy Icon\n");
  401.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  402.                      XtWindow(toplevel), icon_delete,
  403.                      &Icon_Delete_PM, &smap,
  404.                      &attr) != XpmSuccess)
  405.         FATAL_ERROR("main: Failed to get Delete Icon\n");
  406.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  407.                      XtWindow(toplevel), icon_warning,
  408.                      &Icon_Warning_PM, &smap,
  409.                      &attr) != XpmSuccess)
  410.         FATAL_ERROR("main: Failed to get Warning Icon\n");
  411.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  412.                      XtWindow(toplevel), icon_goto,
  413.                      &Icon_Goto_PM, &smap,
  414.                      &attr) != XpmSuccess)
  415.         FATAL_ERROR("main: Failed to get Goto Icon\n");
  416.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  417.                      XtWindow(toplevel), icon_newdir,
  418.                      &Icon_Newdir_PM, &smap,
  419.                      &attr) != XpmSuccess)
  420.         FATAL_ERROR("main: Failed to get Newdir Icon\n");
  421.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  422.                      XtWindow(toplevel), icon_info,
  423.                      &Icon_Info_PM, &smap,
  424.                      &attr) != XpmSuccess)
  425.         FATAL_ERROR("main: Failed to get Info Icon\n");
  426.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  427.                      XtWindow(toplevel), icon_hide,
  428.                      &Icon_Hide_PM, &smap,
  429.                      &attr) != XpmSuccess)
  430.         FATAL_ERROR("main: Failed to get Hide Icon\n");
  431.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  432.                      XtWindow(toplevel), icon_help,
  433.                      &Icon_Help_PM, &smap,
  434.                      &attr) != XpmSuccess)
  435.         FATAL_ERROR("main: Failed to get Help Icon\n");
  436.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  437.                      XtWindow(toplevel), icon_filter,
  438.                      &Icon_Filter_PM, &smap,
  439.                      &attr) != XpmSuccess)
  440.         FATAL_ERROR("main: Failed to get Filter Icon\n");
  441.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  442.                      XtWindow(toplevel), icon_exec,
  443.                      &Icon_Exec_PM, &smap,
  444.                      &attr) != XpmSuccess)
  445.         FATAL_ERROR("main: Failed to get Exec Icon\n");
  446.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  447.                      XtWindow(toplevel), icon_wsedit,
  448.                      &Icon_WSE_PM, &smap,
  449.                      &attr) != XpmSuccess)
  450.         FATAL_ERROR("main: Failed to get WSEdit Icon\n");
  451.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  452.                      XtWindow(toplevel), icon_wsdelete,
  453.                      &Icon_WSD_PM, &smap,
  454.                      &attr) != XpmSuccess)
  455.         FATAL_ERROR("main: Failed to get WSDelete Icon\n");
  456.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  457.                      XtWindow(toplevel), icon_makelink,
  458.                      &Icon_Link_PM, &smap,
  459.                      &attr) != XpmSuccess)
  460.         FATAL_ERROR("main: Failed to get Makelink Icon\n");
  461.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  462.                      XtWindow(toplevel), icon_pack,
  463.                      &Icon_Pack_PM, &smap,
  464.                      &attr) != XpmSuccess)
  465.         FATAL_ERROR("main: Failed to get Pack Icon\n");
  466.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  467.                      XtWindow(toplevel), icon_unpack,
  468.                      &Icon_Unpack_PM, &smap,
  469.                      &attr) != XpmSuccess)
  470.         FATAL_ERROR("main: Failed to get unpack Icon\n");
  471.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  472.                      XtWindow(toplevel), icon_root,
  473.                      &Icon_Root_PM, &smap,
  474.                      &attr) != XpmSuccess)
  475.         FATAL_ERROR("main: Failed to get Root Icon\n");
  476.  
  477.     /*
  478.      * Die IconPixmaps laden
  479.      */
  480.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  481.                      XtWindow(toplevel), dir_closed,
  482.                      &Dir_Closed_PM, &smap,
  483.                      &attr) != XpmSuccess)
  484.         FATAL_ERROR("main: Failed to get Closed Icon\n");
  485.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  486.                      XtWindow(toplevel), dir_opened,
  487.                      &Dir_Opened_PM, &smap,
  488.                      &attr) != XpmSuccess)
  489.         FATAL_ERROR("main: Failed to get Opened Icon\n");
  490.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  491.                      XtWindow(toplevel), dir_locked,
  492.                      &Dir_Locked_PM, &smap,
  493.                      &attr) != XpmSuccess)
  494.         FATAL_ERROR("main: Failed to get Locked Icon\n");
  495.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  496.                      XtWindow(toplevel), file_root,
  497.                      &File_Root_PM, &smap,
  498.                      &attr) != XpmSuccess)
  499.         FATAL_ERROR("main: Failed to get Root Icon\n");
  500.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  501.                      XtWindow(toplevel), file_tar,
  502.                      &File_CTar_PM, &smap,
  503.                      &attr) != XpmSuccess)
  504.         FATAL_ERROR("main: Failed to get Tar Icon\n");
  505.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  506.                      XtWindow(toplevel), file_ctar,
  507.                      &File_CTar_PM, &smap,
  508.                      &attr) != XpmSuccess)
  509.         FATAL_ERROR("main: Failed to get CTar Icon\n");
  510.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  511.                      XtWindow(toplevel), file_plain,
  512.                      &File_Plain_PM, &smap,
  513.                      &attr) != XpmSuccess)
  514.         FATAL_ERROR("main: Failed to get Plain Icon\n");
  515.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  516.                      XtWindow(toplevel), file_lock,
  517.                      &File_Lock_PM, &smap,
  518.                      &attr) != XpmSuccess)
  519.         FATAL_ERROR("main: Failed to get Flock Icon\n");
  520.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  521.                      XtWindow(toplevel), file_link,
  522.                      &File_Link_PM, &smap,
  523.                      &attr) != XpmSuccess)
  524.         FATAL_ERROR("main: Failed to get Link Icon\n");
  525.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  526.                      XtWindow(toplevel), file_ghost,
  527.                      &File_Ghost_PM, &smap,
  528.                      &attr) != XpmSuccess)
  529.         FATAL_ERROR("main: Failed to get Ghost Icon\n");
  530.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  531.                      XtWindow(toplevel), file_exec,
  532.                      &File_Exec_PM, &smap,
  533.                      &attr) != XpmSuccess)
  534.         FATAL_ERROR("main: Failed to get exec Icon\n");
  535.     if (XpmCreatePixmapFromData (XtDisplay(toplevel),
  536.                      XtWindow(toplevel), file_dlink,
  537.                      &File_DLink_PM, &smap,
  538.                      &attr) != XpmSuccess)
  539.         FATAL_ERROR("main: Failed to get DLink Icon\n");
  540. #else
  541.     int    b = XBlackPixel(XtDisplay(toplevel),XDefaultScreen(XtDisplay(toplevel)));
  542.     int    w = XWhitePixel(XtDisplay(toplevel),XDefaultScreen(XtDisplay(toplevel)));
  543.  
  544.     if (!(Icon_Move_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  545.                     XtWindow(toplevel), icon_move, 32,32,b,w,
  546.                     XDisplayPlanes(XtDisplay(toplevel),
  547.                         XDefaultScreen(XtDisplay(toplevel))))))
  548.         FATAL_ERROR("Failed to read move-bitmap");
  549.     if (!(Icon_Copy_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  550.                     XtWindow(toplevel), icon_copy, 32,32,b,w,
  551.                     XDisplayPlanes(XtDisplay(toplevel),
  552.                         XDefaultScreen(XtDisplay(toplevel))))))
  553.         FATAL_ERROR("Failed to read move-bitmap");
  554.     if (!(Icon_Delete_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  555.                     XtWindow(toplevel), icon_delete, 32,32,b,w,
  556.                     XDisplayPlanes(XtDisplay(toplevel),
  557.                         XDefaultScreen(XtDisplay(toplevel))))))
  558.         FATAL_ERROR("Failed to read move-bitmap");
  559.     if (!(Icon_Info_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  560.                     XtWindow(toplevel), icon_info, 32,32,b,w,
  561.                     XDisplayPlanes(XtDisplay(toplevel),
  562.                         XDefaultScreen(XtDisplay(toplevel))))))
  563.         FATAL_ERROR("Failed to read info-bitmap");
  564.     if (!(Icon_Warning_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  565.                     XtWindow(toplevel), icon_warning, 32,32,b,w,
  566.                     XDisplayPlanes(XtDisplay(toplevel),
  567.                         XDefaultScreen(XtDisplay(toplevel))))))
  568.         FATAL_ERROR("Failed to read warn-bitmap");
  569.     if (!(Icon_Newdir_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  570.                     XtWindow(toplevel), icon_newdir, 32,32,b,w,
  571.                     XDisplayPlanes(XtDisplay(toplevel),
  572.                         XDefaultScreen(XtDisplay(toplevel))))))
  573.         FATAL_ERROR("Failed to read newdir-bitmap");
  574.     if (!(Icon_WSE_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  575.                     XtWindow(toplevel), icon_wse, 32,32,b,w,
  576.                     XDisplayPlanes(XtDisplay(toplevel),
  577.                         XDefaultScreen(XtDisplay(toplevel))))))
  578.         FATAL_ERROR("Failed to read wse-bitmap");
  579.     if (!(Icon_WSD_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  580.                     XtWindow(toplevel), icon_wsd, 32,32,b,w,
  581.                     XDisplayPlanes(XtDisplay(toplevel),
  582.                         XDefaultScreen(XtDisplay(toplevel))))))
  583.         FATAL_ERROR("Failed to read wsd-bitmap");
  584.     if (!(Icon_Filter_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  585.                     XtWindow(toplevel), icon_filter, 32,32,b,w,
  586.                     XDisplayPlanes(XtDisplay(toplevel),
  587.                         XDefaultScreen(XtDisplay(toplevel))))))
  588.         FATAL_ERROR("Failed to read filter-bitmap");
  589.     if (!(Icon_Help_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  590.                     XtWindow(toplevel), icon_help, 32,32,b,w,
  591.                     XDisplayPlanes(XtDisplay(toplevel),
  592.                         XDefaultScreen(XtDisplay(toplevel))))))
  593.         FATAL_ERROR("Failed to read help-bitmap");
  594.     if (!(Icon_Hide_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  595.                     XtWindow(toplevel), icon_hide, 32,32,b,w,
  596.                     XDisplayPlanes(XtDisplay(toplevel),
  597.                         XDefaultScreen(XtDisplay(toplevel))))))
  598.         FATAL_ERROR("Failed to read hide-bitmap");
  599.     if (!(Icon_Exec_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  600.                     XtWindow(toplevel), icon_exec, 32,32,b,w,
  601.                     XDisplayPlanes(XtDisplay(toplevel),
  602.                         XDefaultScreen(XtDisplay(toplevel))))))
  603.         FATAL_ERROR("Failed to read exec-bitmap");
  604.     if (!(Icon_Link_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  605.                     XtWindow(toplevel), icon_link, 32,32,b,w,
  606.                     XDisplayPlanes(XtDisplay(toplevel),
  607.                         XDefaultScreen(XtDisplay(toplevel))))))
  608.         FATAL_ERROR("Failed to read makelink-bitmap");
  609.     if (!(Icon_Goto_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  610.                     XtWindow(toplevel), icon_goto, 32,32,b,w,
  611.                     XDisplayPlanes(XtDisplay(toplevel),
  612.                         XDefaultScreen(XtDisplay(toplevel))))))
  613.         FATAL_ERROR("Failed to read goto-bitmap");
  614.     if (!(Icon_Root_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  615.                     XtWindow(toplevel), icon_root, 32,32,b,w,
  616.                     XDisplayPlanes(XtDisplay(toplevel),
  617.                         XDefaultScreen(XtDisplay(toplevel))))))
  618.         FATAL_ERROR("Failed to read root-bitmap");
  619.     if (!(Icon_Pack_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  620.                     XtWindow(toplevel), icon_pack, 32,32,b,w,
  621.                     XDisplayPlanes(XtDisplay(toplevel),
  622.                         XDefaultScreen(XtDisplay(toplevel))))))
  623.         FATAL_ERROR("Failed to read Pack-bitmap");
  624.     if (!(Icon_Unpack_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  625.                     XtWindow(toplevel), icon_unpack, 32,32,b,w,
  626.                     XDisplayPlanes(XtDisplay(toplevel),
  627.                         XDefaultScreen(XtDisplay(toplevel))))))
  628.         FATAL_ERROR("Failed to read Unpack-bitmap");
  629.  
  630.  
  631.     if (!(File_Root_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  632.                     XtWindow(toplevel), file_root, 16,16,b,w,
  633.                     XDisplayPlanes(XtDisplay(toplevel),
  634.                         XDefaultScreen(XtDisplay(toplevel))))))
  635.         FATAL_ERROR("Failed to read fileroot-bitmap");
  636.     if (!(File_Plain_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  637.                     XtWindow(toplevel), file_plain,16,16,b,w,
  638.                     XDisplayPlanes(XtDisplay(toplevel),
  639.                         XDefaultScreen(XtDisplay(toplevel))))))
  640.         FATAL_ERROR("Failed to read fileplain-bitmap");
  641.     if (!(File_Exec_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  642.                     XtWindow(toplevel), file_exec, 16,16,b,w,
  643.                     XDisplayPlanes(XtDisplay(toplevel),
  644.                         XDefaultScreen(XtDisplay(toplevel))))))
  645.         FATAL_ERROR("Failed to read fileexec-bitmap");
  646.     if (!(Dir_Closed_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  647.                     XtWindow(toplevel), dir_closed, 16,16,b,w,
  648.                     XDisplayPlanes(XtDisplay(toplevel),
  649.                         XDefaultScreen(XtDisplay(toplevel))))))
  650.         FATAL_ERROR("Failed to read dirclose-bitmap");
  651.     if (!(Dir_Opened_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  652.                     XtWindow(toplevel), dir_open, 16,16,b,w,
  653.                     XDisplayPlanes(XtDisplay(toplevel),
  654.                         XDefaultScreen(XtDisplay(toplevel))))))
  655.         FATAL_ERROR("Failed to read diropen-bitmap");
  656.     if (!(Dir_Locked_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  657.                     XtWindow(toplevel), dir_lock, 16,16,b,w,
  658.                     XDisplayPlanes(XtDisplay(toplevel),
  659.                         XDefaultScreen(XtDisplay(toplevel))))))
  660.         FATAL_ERROR("Failed to read dirlock-bitmap");
  661.     if (!(File_DLink_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  662.                     XtWindow(toplevel), dir_link, 16,16,b,w,
  663.                     XDisplayPlanes(XtDisplay(toplevel),
  664.                         XDefaultScreen(XtDisplay(toplevel))))))
  665.         FATAL_ERROR("Failed to read dirlink-bitmap");
  666.     if (!(File_Link_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  667.                     XtWindow(toplevel), file_link, 16,16,b,w,
  668.                     XDisplayPlanes(XtDisplay(toplevel),
  669.                         XDefaultScreen(XtDisplay(toplevel))))))
  670.         FATAL_ERROR("Failed to read filelink-bitmap");
  671. /*    if (!(File_Ghost_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  672.                     XtWindow(toplevel), file_ghost, 16,16,b,w,
  673.                     XDisplayPlanes(XtDisplay(toplevel),
  674.                         XDefaultScreen(XtDisplay(toplevel))))))
  675.         FATAL_ERROR("Failed to read fileghost-bitmap");
  676. */    if (!(File_Lock_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  677.                     XtWindow(toplevel), file_lock, 16,16,b,w,
  678.                     XDisplayPlanes(XtDisplay(toplevel),
  679.                         XDefaultScreen(XtDisplay(toplevel))))))
  680.         FATAL_ERROR("Failed to read filelock-bitmap");
  681.     if (!(File_Tar_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  682.                     XtWindow(toplevel), file_tar, 16,16,b,w,
  683.                     XDisplayPlanes(XtDisplay(toplevel),
  684.                         XDefaultScreen(XtDisplay(toplevel))))))
  685.         FATAL_ERROR("Failed to read filetar-bitmap");
  686.     if (!(File_CTar_PM = XCreatePixmapFromBitmapData (XtDisplay(toplevel),
  687.                     XtWindow(toplevel), file_ctar, 16,16,b,w,
  688.                     XDisplayPlanes(XtDisplay(toplevel),
  689.                         XDefaultScreen(XtDisplay(toplevel))))))
  690.         FATAL_ERROR("Failed to read filectar-bitmap");
  691.     File_Ghost_PM = File_Plain_PM;
  692. #endif
  693. }
  694.  
  695.  
  696. /*********************************************************
  697.  * name:    ReadPixmapFromFile
  698.  * description:    einlesen einer Pixmap
  699.  * input:    char    *filename;
  700.  *        int    *w    - width_return
  701.  *        int    *h    - height_return
  702.  * output:    Pixmap    pmap;
  703.  * author:    Ove Kalkan
  704.  * date:    9.8.1993
  705.  *********************************************************/
  706. Pixmap    ReadPixmapFromFile(char *filename, int *w, int *h)
  707. {
  708.     Pixmap    back = (Pixmap) NULL;
  709.     char    *s;
  710.     Boolean    predicate (String s);
  711.  
  712.     Pixmap    tmp;
  713.     int    x,y;
  714.  
  715.     s = XtResolvePathname(XtDisplay(toplevel),NULL,filename,
  716.                   NULL,defaults.icon_dir,NULL,0,predicate);
  717.     if (!s) {
  718.         s = XtResolvePathname(XtDisplay(toplevel),NULL,filename,
  719.                       ".bm",defaults.icon_dir,NULL,0,predicate);
  720.         if (!s) {
  721.             s = XtResolvePathname(XtDisplay(toplevel),NULL,filename,
  722.                           ".xpm",defaults.icon_dir,NULL,0,predicate);
  723.             if (!s) {
  724.                 s = XtResolvePathname(XtDisplay(toplevel),NULL,filename,
  725.                              ".xbm",defaults.icon_dir,NULL,0,predicate);
  726.                 if (!s) {
  727.                     fprintf(stderr,"Error: Cannot find Icon %s\n",filename);
  728.                     return ((Pixmap) NULL);
  729.                 }
  730.             }
  731.         }
  732.     }
  733.     *w = 16;
  734.     *h = 16;
  735.  
  736. #ifdef HAVE_XPM        /* Xpm-Icon lesen */
  737.     smap = (Pixmap) NULL;
  738.     if (XpmReadFileToPixmap(XtDisplay(toplevel),XtWindow(toplevel),
  739.                 s,&back,&smap,&attr) != XpmSuccess) {
  740.         back = (Pixmap) NULL;
  741.     }
  742.     else {
  743.         *w = attr.width;
  744.         *h = attr.height;
  745.         return(back);    /* Hat geklappt, also Pixmap zurueckliefern */
  746.     }
  747. #endif            /* X11 Bitmap lesen */
  748.     smap = (Pixmap) NULL;
  749.     if (XReadBitmapFile(XtDisplay(toplevel),XtWindow(toplevel),
  750.                 s,(unsigned int *) w,(unsigned int *) h,
  751.                 &tmp,&x,&y) != BitmapSuccess) {
  752.         back = (Pixmap) NULL;
  753.     }
  754.     else {
  755.         if (!(back = XCreatePixmap(XtDisplay(toplevel),
  756.                         XtWindow(toplevel),
  757.                         *w,*h,
  758.                         XDisplayPlanes(XtDisplay(toplevel),
  759.                         XDefaultScreen(XtDisplay(toplevel)))))) {
  760.             back = (Pixmap) NULL;
  761.         }
  762.         else {
  763.             XCopyPlane(XtDisplay(toplevel),tmp,back,
  764.                     XDefaultGC(XtDisplay(toplevel),XDefaultScreen(XtDisplay(toplevel))),
  765.                     0,0,*w,*h,0,0,1);
  766.         }
  767.     }
  768.     if (!back)
  769.         fprintf(stderr,"Cannot Read Iconfile %s\n",s);
  770.     return(back);
  771. }
  772.  
  773. Boolean    predicate (String s)
  774. {
  775.     FILE    *fp;
  776.  
  777.     if ((fp = fopen(s,"r"))) {
  778.         fclose(fp);
  779.         return(TRUE);
  780.     }
  781.     return(FALSE);
  782. }