home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFILEMAN / XFILEMAN.TAR / xfilemanager / multi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  6.8 KB  |  297 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.  
  25. #include "global.h"
  26.  
  27. #define    ABSDIFF(a,b)    ((long)((a) - (b)) < 0 ? (b) - (a) : (a) - (b))
  28.  
  29. /*
  30.  * Global variables
  31.  */
  32.  
  33. static    Time        multi_t = 0;    /* Timer fuer Doppelclicks */
  34.  
  35.  
  36.  
  37. /*********************************************************
  38.  * name:    startMulti
  39.  * description:    ruecksetzen des Selction-bereichs und
  40.  *        festlegen der Startposition des Multi-
  41.  *        bereichs, sowie ein erstes Umranden
  42.  *        des Bereichs
  43.  * input:    none
  44.  * output:    none
  45.  * date:    14.6.93
  46.  *********************************************************/
  47. XtActionProc    startMulti     (Widget w, XButtonEvent *e,
  48.                 String *s, Cardinal *c)
  49. {
  50.     /*
  51.      * Nachpruefen ob Doppelclick fuer Multi
  52.      */
  53.     if (ABSDIFF(e->time,multi_t) < defaults.click_interval &&
  54.         multi_vs < 16000 && multi_ve < 16000) {
  55.         Dimension    i = multi_vs, j = 0;
  56.         char        buf[2048];
  57.         char        nbuf[2048];
  58.         int        prog_type = folder->file[i]->prog_type;
  59.         char        *dir;
  60.  
  61.         /*
  62.          * Diese Option gilt nur fuer Datenfiles
  63.          */
  64.         if (prog_type == FILE_EXEC || prog_type == FILE_DIR ||
  65.             prog_type == FILE_LINK || prog_type == FILE_LOCK ||
  66.             prog_type == FILE_ROOT || prog_type == FILE_PLAIN)
  67.             return;
  68.  
  69.         /*
  70.          * Feststellen was fuer ein Datentyp es ist
  71.          */
  72.         while (filetypes[j].cmd && filetypes[j].type != prog_type)
  73.             j++;
  74.  
  75.         if (!filetypes[j].type == prog_type)
  76.             return;
  77.  
  78.         buf[0] = '\0';
  79.         dir = getPath(folder->dir);
  80.         if (!strcmp(dir,"/"))
  81.             dir = "";
  82.  
  83.         /*
  84.          * Datenfiles zusammensuchen
  85.          */
  86.         do {
  87.             if (prog_type != folder->file[i]->prog_type)
  88.                 return;
  89.             sprintf(buf,"%s %s/%s\0",buf,dir,folder->file[i]->name);
  90.  
  91.         } while (++i <= multi_ve);
  92.  
  93.         sprintf(nbuf,filetypes[j].cmd,buf);
  94.  
  95.         /*
  96.          * ausfuehren
  97.          */
  98.         SYSTEM (nbuf);
  99.  
  100.         /*
  101.          * Multibereich loeschen
  102.          */
  103.         clearMulti (w,NULL,NULL,NULL);
  104.     }
  105.     else {
  106.         int        y;
  107.  
  108.         clearMulti (w,NULL,NULL,NULL);
  109.  
  110.         /*
  111.          * Die Anfangsposition des Multis belegen
  112.          */
  113.         y = (e->y - 4)/DIR_Y_STEP;
  114.  
  115.         /*
  116.          * Ueberpruefen ob ueberhaupt ein Multi gebildet werden kann
  117.          */
  118.         if (y >= 0 && y < folder->file_count) {
  119.             multi_vs = y;
  120.             multi_ve = y;
  121.  
  122.             multi_fo = folder;
  123.             /*
  124.              * Neuen Multi markieren. Nur ein Eintrag
  125.              */
  126.             XDrawRectangle (XtDisplay(w),XtWindow(w),selc_gc,
  127.                     16, y*DIR_Y_STEP + 4,
  128.                     folder->max_length + 50 + typelength, 20);
  129.         }
  130.         else
  131.             multi_vs = 16000;
  132.     }
  133. }
  134.  
  135. /*********************************************************
  136.  * name:    followMulti
  137.  * description:    Ausdehnen des Multibereichs je nach Maus
  138.  *        position
  139.  * input:    none
  140.  * output:    none
  141.  * date:    14.6.93
  142.  *********************************************************/
  143. XtActionProc    followMulti    (Widget w, XButtonEvent *e,
  144.                 String *s, Cardinal *c)
  145. {
  146.     int        y;
  147.  
  148.     /*
  149.      * Die Anfangsposition des Multis belegen
  150.      */
  151.     if (folder == multi_fo && multi_fo && multi_vs < 16000) {
  152.         y = (e->y - 4)/DIR_Y_STEP;
  153.  
  154.         if (y < 0)
  155.             y = 0;
  156.         else if (y >= multi_fo->file_count - 1)
  157.             y = multi_fo->file_count - 1;
  158.  
  159.         /*
  160.          * Ueberpruefen ob ueberhaupt ein Multi gebildet werden kann
  161.          */
  162.         if (multi_ve != y) {
  163.             Dimension mi,ma;
  164.  
  165.             /*
  166.              * Alten Multi-Rahmen loeschen
  167.              */
  168.             if (multi_vs < multi_ve) {
  169.                 mi = multi_vs;
  170.                 ma = multi_ve;
  171.             }
  172.             else {
  173.                 mi = multi_ve;
  174.                 ma = multi_vs;
  175.             }
  176.             XDrawRectangle (XtDisplay(multi_fo->window),
  177.                     XtWindow(multi_fo->window),back_gc,
  178.                     16,mi*DIR_Y_STEP + 4,
  179.                     multi_fo->max_length + 50 + typelength,
  180.                     20 + (ma - mi)*DIR_Y_STEP);
  181.  
  182.             /*
  183.              * Neues Ende des Rahmens
  184.              */
  185.             multi_ve = y;
  186.  
  187.             /*
  188.              * Neuen Multi-Rahmen zeichnen
  189.              */
  190.             if (multi_vs < multi_ve) {
  191.                 mi = multi_vs;
  192.                 ma = multi_ve;
  193.             }
  194.             else {
  195.                 mi = multi_ve;
  196.                 ma = multi_vs;
  197.             }
  198.             XDrawRectangle (XtDisplay(multi_fo->window),
  199.                     XtWindow(multi_fo->window),selc_gc,
  200.                     16,mi*DIR_Y_STEP + 4,
  201.                     multi_fo->max_length + 50 + typelength, 
  202.                     20 + (ma - mi)*DIR_Y_STEP);
  203.         }
  204.     }
  205. }
  206.  
  207. /*********************************************************
  208.  * name:    endMulti
  209.  * description:    beenden des Multi-bereichs, eigentlich
  210.  *        nicht notwendig.
  211.  * input:    none
  212.  * output:    none
  213.  * date:    14.6.93
  214.  *********************************************************/
  215. XtActionProc    endMulti       (Widget w, XButtonEvent *e,
  216.                 String *s, Cardinal *c)
  217. {
  218.     multi_t = e->time;
  219. }
  220.  
  221. /*********************************************************
  222.  * name:    clearMulti
  223.  * description:    loeschen des Multibereichs
  224.  * input:    none
  225.  * output:    none
  226.  * date:    14.6.93
  227.  *********************************************************/
  228.  
  229. XtActionProc    clearMulti     (Widget w, XEvent *e,
  230.                 String *s, Cardinal *c)
  231. {
  232.     Dimension mi,ma;
  233.  
  234.     if (multi_fo && multi_vs < 16000) {
  235.         /*
  236.          * Alten Multi-Rahmen loeschen
  237.          */
  238.         if (multi_vs < multi_ve) {
  239.             mi = multi_vs;
  240.             ma = multi_ve;
  241.         }
  242.         else {
  243.             mi = multi_ve;
  244.             ma = multi_vs;
  245.         }
  246.         XDrawRectangle (XtDisplay(multi_fo->window),
  247.                 XtWindow(multi_fo->window),back_gc,
  248.                 16,mi*DIR_Y_STEP + 4,
  249.                 multi_fo->max_length + 50 + typelength, 
  250.                 20 + (ma - mi)*DIR_Y_STEP);
  251.  
  252.         /*
  253.          * Werte zurueck setzen
  254.          */
  255.         multi_vs = 16000;
  256.         multi_ve = 16000;
  257.         multi_fo = NULL;
  258.         MULTI = FALSE;
  259.     }
  260. }
  261.  
  262. /*********************************************************
  263.  * name:    refreshMulti
  264.  * description:    Neuzeichnen des Multirahmens nach einem Expose
  265.  * input:    none
  266.  * output:    none
  267.  * date:    14.6.93
  268.  *********************************************************/
  269.  
  270. XtActionProc    refreshMulti     (Widget w, XEvent *e,
  271.                 String *s, Cardinal *c)
  272. {
  273.     Dimension mi,ma;
  274.  
  275.     if (multi_fo && multi_fo->window == w && multi_vs < 16000) {
  276.         /*
  277.          * Alten Multi-Rahmen loeschen
  278.          */
  279.         if (multi_vs < multi_ve) {
  280.             mi = multi_vs;
  281.             ma = multi_ve;
  282.         }
  283.         else {
  284.             mi = multi_ve;
  285.             ma = multi_vs;
  286.         }
  287.         XDrawRectangle (XtDisplay(multi_fo->window),
  288.                 XtWindow(multi_fo->window),selc_gc,
  289.                 16,mi*DIR_Y_STEP + 4,
  290.                 multi_fo->max_length + 50 + typelength, 
  291.                 20 + (ma - mi)*DIR_Y_STEP);
  292.  
  293.     }
  294. }
  295.  
  296.  
  297.