home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / xfedor.zip / XFree86 / src / xfedor / main.c < prev    next >
C/C++ Source or Header  |  1999-03-02  |  8KB  |  241 lines

  1. /* Copyright 1989 GROUPE BULL -- See licence conditions in file COPYRIGHT */
  2. #include "stdio.h"
  3. extern int strcmp() ;
  4.  
  5. #include "couche.h"
  6. #include "edit.h"      /* WMENU, WEDIT, WBASE, HEDIT */
  7. #include "tabbord.h"   /* WTAB */
  8. #define HMENU 22
  9. #include "font.h"      /* HFONT */
  10.  
  11. extern int BackColor ;
  12.  
  13. /*************************** VARIABLES IMPORTEES ************************/
  14.  
  15. extern int nf_font ;
  16. extern int nf_garb ;
  17. extern int nf_edit ;
  18. extern int nf_tabbord ;
  19. extern int nf_num ;
  20. extern int nf_grille ;
  21. extern int nf_helpnum ;
  22. extern int nf_save ;
  23. extern int nf_test ;
  24. extern int nf_cars ;
  25. extern int nf_extrafont ;
  26. extern int nf_sos ;
  27. extern int nf_colormap ;
  28.  
  29. /************************************************************************/
  30.  
  31. int FIN ;        /* booleen de terminaison */
  32. int root,nf_mono ;     /* fenetre mere de l'application */
  33.  
  34. int xori = 10, yori = 10;
  35.  
  36. int UnixFileNameMode = 1 ;     /* 0 ou 1, utiliser dans filer,bitmap et sos */
  37.  
  38. /*****************************************************************/
  39.  
  40. Init_fedor(reverse,display,
  41.        fontfile,bitfile,mousefile,pixfile,
  42.        argc,argv,geom,imaform,font1,font2)
  43.     int reverse ;
  44.     char * display ;
  45.     char * fontfile ;
  46.     char * bitfile ;
  47.     char * mousefile ;
  48.     char * pixfile ;
  49.     int argc;
  50.     char ** argv ;
  51.         char * geom ;
  52.         int imaform ;        
  53.         char * font1 ;
  54.         char * font2 ;
  55.  
  56. {
  57.     root = w_initial(reverse,display,font1,font2,
  58.              argc,argv,geom,imaform);
  59.                 
  60.     nf_mono = w_ouvrir (root,xori, yori,
  61.                 10+WMENU+WEDIT+WBASE+10+WTAB+10,
  62.                 10+HEDIT+10+HFONT,
  63.                 "xfedor_font_editor",CURS2,0,WMON) ;
  64.  
  65.     Init_Rast(BackColor) ;
  66.     Init_dialogue();     /* creation popup confirm + nf_msg + nf_scan */
  67.     Init_bitmap();       /* getenv MAP */
  68.     Init_sos() ;         /* getenv SOS + fenetre nf_sos */
  69.     Init_filer() ;       /* getenv BDF */
  70.  
  71.     Init_edit();         /* creatmap nf_edit */
  72.     Init_grille();       /* creatmap nf_grille + 3+nundo getimage */
  73.     Init_tabbord(pixfile,mousefile,bitfile);  /* creatmap nf_tabbord */
  74.     Init_test();         /* creat    nf_test */
  75.     Init_num();         /* creatmap nf_num */
  76.     Init_garb();         /* creatmap nf_garb */
  77.     Init_save();         /* creatmap nf_save */
  78.     Init_extrafont() ;   /* creat    nf_extra */
  79.     Init_font();         /* creatmap nf_font */
  80.     Init_colormap();     /* creatmap nf_colormap */
  81.     
  82.     if (GetFont(fontfile) != 1) {
  83.         fprintf(stderr,"Fedor : Can't read font : %s\n",fontfile);
  84.         GetFont("initfont");
  85.     }
  86.  
  87.     LoadBitmap(pixfile,2) ;
  88.     LoadBitmap(mousefile,1);
  89.     LoadBitmap(bitfile,0);
  90.  
  91.     MontrerCarTrav() ;
  92.  
  93.     w_montrer(nf_mono);
  94. }
  95.  
  96. /*****************************************************************/
  97. Autom_General(evt)  
  98. /* dispatching d'un evenement sur les diverses fenetres */
  99.     myEvent * evt;
  100. {
  101.   if (evt->window == nf_tabbord)      Autom_tabbord(evt); else
  102.   if (evt->window == nf_garb)       Autom_garb(evt); else
  103.   if (evt->window == nf_num)            Autom_num(evt); else
  104.   if (evt->window == nf_helpnum)     Autom_helpnum(evt); else
  105.   if (evt->window == nf_font)         Autom_font(evt); else
  106.   if (evt->window == nf_edit)         Autom_edit(evt); else
  107.   if (evt->window == nf_save)         Autom_save(evt); else
  108.   if (evt->window == nf_test)         Autom_test(evt); else  
  109.   if (evt->window == nf_cars)         Autom_cars(evt); else
  110.   if (evt->window == nf_extrafont)     Autom_extrafont(evt); else
  111.   if (evt->window == nf_sos)             Autom_sos(evt); else
  112.   if (evt->window == nf_grille)     Autom_grille(evt); else
  113.   if (evt->window == nf_colormap)     Autom_colormap(evt); else
  114.   if (evt->type == CloseWindow)        FIN=1;
  115. }
  116.  
  117. Dispatch()
  118. /* Lecture des evenements .
  119.    verif de la grammaire avec correction possible
  120.    envoi a l'automate general qui aiguille vers les modules
  121.    jusqu'a FIN */
  122. {    myEvent evt ;
  123.     static int zonecour = -1 ;
  124.     static int fencour = -1 ;
  125.     
  126.     FIN = 0 ;
  127.     do {
  128.          attente(&evt);
  129.         /* PHASE DE CORRECTION SUR EVENEMENTS INCOHERENTS */
  130.          if (evt.type==EnterZone) {
  131.           if (zonecour == evt.zone) continue /* -> w_attente */;
  132.                 /* INUTILE DE REENTRER DANS LA MEME ZONE */
  133.           if (zonecour != -1) { int z,f ;
  134.                 /* ON RENTRE DANS UNE NOUVELLE ZONE ALORS
  135.                    QU'ON N'EST PAS SORTI DE LA COURANTE */
  136.               z = evt.zone ;
  137.               f = evt.window ;      /* memorise l'evt */
  138.               evt.window = fencour ;
  139.               evt.type = LeaveZone ; /* on quitte */
  140.               evt.zone = zonecour ;   /* proprement la */
  141.               Autom_General(&evt);      /* zone courante */
  142.               evt.zone = z ;
  143.               evt.window = f ;
  144.               evt.type = EnterZone ; /* restaure l'evt */
  145.            }
  146.            zonecour = evt.zone ;
  147.            fencour = evt.window ;       /* MISE A JOUR ETAT */
  148.          } else
  149.          if (evt.type==LeaveZone) {
  150.            if (zonecour != evt.zone) {
  151.                 /* ON QUITTE UNE ZONE SANS Y ETRE RENTRER */
  152.               evt.zone = zonecour ;
  153.               evt.window = fencour ;  /* on quitte d'abord */
  154.               Autom_General(&evt);      /* la zone courante */
  155.               zonecour = -1 ;
  156.               fencour = -1 ;
  157.               continue ;          /* ignore le leave */
  158.            }
  159.            zonecour = -1 ;
  160.            fencour = -1 ;            /* MISE A JOUR ETAT */
  161.          } 
  162.          Autom_General(&evt);
  163.     } while (!FIN) ;
  164. }
  165.  
  166. int Usage() 
  167. {
  168.       fprintf(stderr,"\nUsage:\txfedor\t[-f fontfile] [-m mousefile] [-b bitmapfile] [-p pixmapfile]\n") ; 
  169.       fprintf(stderr,"\t\t[-z] [-xy] [-rv] [-f1 fontname] [-f2 fontname]\n");
  170.       fprintf(stderr,"\t\t[-g +x+y] [-d host:display.screen]\n") ;
  171.           fprintf(stderr,"\tfontfile\tBDF font file (.bdf appended if not present)\n");
  172.           fprintf(stderr,"\tbitmapfile\tX11 bitmap file (.xbm is first search)\n");
  173.           fprintf(stderr,"\tmousefile\t2 X11 bitmap files (mousefileFore & Mask)\n");
  174.           fprintf(stderr,"\tpixmapfile\tXPM file format (.xpm is first search)\n");
  175.       fprintf(stderr,"\t-z\tspecify ZPixmap image transfert with X Server\n");
  176.       fprintf(stderr,"\t-xy\tspecify XYPixmap image transfert with X Server\n");
  177.       fprintf(stderr,"\t-f1\tspecify font to be use in general interface\n");
  178.       fprintf(stderr,"\t-f2\tspecify font to be use in mouse guide lines\n");
  179.       fprintf(stderr,"\t-rv\tswap foreground and background colors\n");
  180.     exit(0) ;
  181. }
  182.  
  183.  
  184. /*****************************************************************/
  185. main(argc,argv)
  186. int argc; 
  187. char **argv ;
  188.  
  189. {
  190.     int reverse = 0 ;
  191.     char * display = NULL ;
  192.     char * fontfile = "initfont" ;
  193.     char * bitfile = "" ;
  194.     char * mousefile = "" ;
  195.     char * pixfile = "" ;
  196.     char * geom = NULL ;
  197.     int bidon ;
  198.     char ** command ;
  199.     int imaform = 0 ;       /* XYPixmap = 0 , ZPixmap = 1 */
  200.     char * font1 = 
  201.       "-adobe-times-bold-r-normal--14-140-75-75-p-77-iso8859-1";
  202.     char * font2 = 
  203.       "-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1" ;
  204.  
  205.     /* printf("XFEDOR (daniel) v_color_xpm3 5.0 07/91\n"); */
  206.     printf("XFEDOR 5.0.1 11/98\n");
  207.  
  208.     command = argv ;
  209.     while (*++argv) {
  210.         if (!strcmp(*argv,"-d") || !strcmp(*argv,"-display")) 
  211.             if (*++argv) display = *argv ; else Usage(); else
  212.         if (!strcmp(*argv,"-g") || !strcmp(*argv,"-geometry")) 
  213.             if (*++argv) geom = *argv ; else Usage(); else
  214.         if (!strcmp(*argv,"-rv")) reverse = 1 ; else
  215.         if (!strcmp(*argv,"-z")) imaform = 2 ; else
  216.         if (!strcmp(*argv,"-xy")) imaform = 1 ; else
  217.         if (!strcmp(*argv,"-f") || !strcmp(*argv,"-fn")) 
  218.             if (*++argv) fontfile = *argv ; else Usage(); else
  219.         if (!strcmp(*argv,"-f1")) 
  220.             if (*++argv) font1 = *argv ; else Usage(); else
  221.         if (!strcmp(*argv,"-f2")) 
  222.             if (*++argv) font2 = *argv ; else Usage(); else
  223.         if (!strcmp(*argv,"-b")) 
  224.             if (*++argv) bitfile = *argv ; else Usage(); else
  225.         if (!strcmp(*argv,"-m")) 
  226.             if (*++argv) mousefile = *argv ; else Usage(); else
  227.         if (!strcmp(*argv,"-p")) 
  228.             if (*++argv) pixfile = *argv ; else Usage(); 
  229.         else Usage() ;
  230.     }
  231.  
  232.     if (geom) XParseGeometry(geom,&xori,&yori,&bidon,&bidon);
  233.  
  234.     Init_fedor(reverse,display,
  235.            fontfile,bitfile,mousefile,pixfile,
  236.            argc,command,geom,imaform,font1,font2);
  237.     
  238.     Dispatch();
  239.     w_close() ;
  240. }
  241.