home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d170 / surf.lha / Surf / src / menu_files.c < prev    next >
C/C++ Source or Header  |  1988-11-22  |  7KB  |  247 lines

  1. #include "gadgetdef.h"
  2.  
  3. static struct IntuiText filetext[] = {
  4.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save as", NULL },
  5.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save first", NULL },
  6.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"save next", NULL },
  7.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"open map", NULL },
  8.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"close map", NULL }
  9. };
  10.  
  11. static struct IntuiText greytext[] = {
  12.    { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"Grey model",   NULL },
  13.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Average",   NULL },
  14.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Lumin",   NULL },
  15.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"Distance",   NULL },
  16.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"R only",   NULL },
  17.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"G only",   NULL },
  18.    { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"B only",   NULL }
  19. };
  20.  
  21. static struct IntuiText packtext[] = {
  22.     { 0, 1, JAM2, 2, 0, NULL, (UBYTE *)"compression", NULL },
  23.     { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"run length", NULL },
  24.     { 0, 1, JAM2, 20, 0, NULL, (UBYTE *)"none", NULL }
  25. };
  26.  
  27.  
  28.  
  29. #define FILEFLAGS  ( ITEMTEXT | HIGHCOMP | ITEMENABLED )
  30.  
  31. static struct MenuItem packitems[] = {
  32.   { &packitems[1], /* next item */
  33.     90, 0, 110 , 10, /* x,y,w,h */
  34.     COLMEMFLAGS| CHECKED,
  35.     2, /* mutual exclude bits */
  36.     (APTR) &packtext[1],  /* grey */
  37.     NULL, /* highlight image */
  38.     'h', /* command byte ? */
  39.     NULL, /* submenu item */
  40.     0 /* next select for select dragging */
  41.     },
  42.   { NULL, /* next item */
  43.     90, 10, 110 , 10, /* x,y,w,h */
  44.     COLMEMFLAGS,
  45.     1, /* mutual exclude bits */
  46.     (APTR) &packtext[2],  /* grey */
  47.     NULL, /* highlight image */
  48.     'h', /* command byte ? */
  49.     NULL, /* submenu item */
  50.     0 /* next select for select dragging */
  51.     }
  52. };
  53.  
  54. #define GREYMUTUAL(pos) (077 ^ (1<<(pos)))
  55. static struct MenuItem greyitems[] = {
  56.   { &greyitems[1], /* next item */
  57.     90, 0, 80 , 10, /* x,y,w,h */
  58.     COLMEMFLAGS|CHECKED,
  59.     GREYMUTUAL(0), /* mutual exclude bits */
  60.     (APTR) &greytext[1],  /* average */
  61.     NULL, /* highlight image */
  62.     'h', /* command byte ? */
  63.     NULL, /* submenu item */
  64.     0 /* next select for select dragging */
  65.     },
  66.   { &greyitems[2], /* next item */
  67.     90, 10, 80 , 10, /* x,y,w,h */
  68.     COLMEMFLAGS,
  69.     GREYMUTUAL(1), /* mutual exclude bits */
  70.     (APTR) &greytext[2],  /* lumin */
  71.     NULL, /* highlight image */
  72.     'h', /* command byte ? */
  73.     NULL, /* submenu item */
  74.     0 /* next select for select dragging */
  75.     },
  76.   { &greyitems[3], /* next item */
  77.     90, 20, 80 , 10, /* x,y,w,h */
  78.     COLMEMFLAGS,
  79.     GREYMUTUAL(2), /* mutual exclude bits */
  80.     (APTR) &greytext[3],  /* dist */
  81.     NULL, /* highlight image */
  82.     'h', /* command byte ? */
  83.     NULL, /* submenu item */
  84.     0 /* next select for select dragging */
  85.     },
  86.   { &greyitems[4], /* next item */
  87.     90, 30, 80 , 10, /* x,y,w,h */
  88.     COLMEMFLAGS,
  89.     GREYMUTUAL(3), /* mutual exclude bits */
  90.     (APTR) &greytext[4],  /* dist */
  91.     NULL, /* highlight image */
  92.     'h', /* command byte ? */
  93.     NULL, /* submenu item */
  94.     0 /* next select for select dragging */
  95.     },
  96.   { &greyitems[5], /* next item */
  97.     90, 40, 80 , 10, /* x,y,w,h */
  98.     COLMEMFLAGS,
  99.     GREYMUTUAL(4), /* mutual exclude bits */
  100.     (APTR) &greytext[5],  /* dist */
  101.     NULL, /* highlight image */
  102.     'h', /* command byte ? */
  103.     NULL, /* submenu item */
  104.     0 /* next select for select dragging */
  105.     },
  106.   { NULL, /* next item */
  107.     90, 50, 80 , 10, /* x,y,w,h */
  108.     COLMEMFLAGS,
  109.     GREYMUTUAL(5), /* mutual exclude bits */
  110.     (APTR) &greytext[6],  /* dist */
  111.     NULL, /* highlight image */
  112.     'h', /* command byte ? */
  113.     NULL, /* submenu item */
  114.     0 /* next select for select dragging */
  115.     }
  116. };
  117.  
  118.  
  119.  
  120.  
  121. static struct MenuItem fileitems[] = {
  122.   { &fileitems[1], /* next item */
  123.     10, 0, 90 , 10, /* x,y,w,h */
  124.     FILEFLAGS,
  125.     0, /* mutual exclude bits */
  126.     (APTR) &filetext[0],  /* grey */
  127.     NULL, /* highlight image */
  128.     'h', /* command byte ? */
  129.     NULL, /* submenu item */
  130.     0 /* next select for select dragging */
  131.     },
  132.   { &fileitems[2], /* next item */
  133.     10, 10, 90 , 10, /* x,y,w,h */
  134.     FILEFLAGS,
  135.     0, /* mutual exclude bits */
  136.     (APTR) &filetext[1],  /* grey */
  137.     NULL, /* highlight image */
  138.     'h', /* command byte ? */
  139.     NULL, /* submenu item */
  140.     0 /* next select for select dragging */
  141.     },
  142.   { &fileitems[3], /* next item */
  143.     10, 20, 90 , 10, /* x,y,w,h */
  144.     FILEFLAGS,
  145.     0, /* mutual exclude bits */
  146.     (APTR) &filetext[2],  /* grey */
  147.     NULL, /* highlight image */
  148.     'h', /* command byte ? */
  149.     NULL, /* submenu item */
  150.     0 /* next select for select dragging */
  151.     },
  152.   { &fileitems[4], /* next item */
  153.     10, 30, 90 , 10, /* x,y,w,h */
  154.     FILEFLAGS,
  155.     0, /* mutual exclude bits */
  156.     (APTR) &packtext[0],  /* grey */
  157.     NULL, /* highlight image */
  158.     'h', /* command byte ? */
  159.     packitems, /* submenu item */
  160.     0 /* next select for select dragging */
  161.     },
  162.   { &fileitems[5], /* next item */
  163.     10, 40, 90 , 10, /* x,y,w,h */
  164.     FILEFLAGS,
  165.     0, /* mutual exclude bits */
  166.     (APTR) &filetext[3],  /* grey */
  167.     NULL, /* highlight image */
  168.     'h', /* command byte ? */
  169.     NULL, /* submenu item */
  170.     0 /* next select for select dragging */
  171.     },
  172.   { &fileitems[6], /* next item */
  173.     10, 50, IMAGE_HITWIDTH , 10, /* x,y,w,h */
  174.     COLMEMFLAGS,
  175.     1, /* mutual exclude bits */
  176.     (APTR) &greytext[0],     /* red */
  177.     NULL, /* highlight image */
  178.     'h', /* command byte ? */
  179.     greyitems, /* submenu item */
  180.     0 /* next select for select dragging */
  181.     },
  182.   { NULL, /* next item */
  183.     10, 60, 90 , 10, /* x,y,w,h */
  184.     FILEFLAGS,
  185.     0, /* mutual exclude bits */
  186.     (APTR) &filetext[4],  /* grey */
  187.     NULL, /* highlight image */
  188.     'h', /* command byte ? */
  189.     NULL, /* submenu item */
  190.     0 /* next select for select dragging */
  191.     }
  192. };
  193.  
  194. extern char *GetOutFile();
  195. extern char *GetInFile();
  196.  
  197. MenuDoFile(item)
  198. int item;
  199. {
  200.     static int filecnt = 0;
  201.     char tempbuff[80];
  202.     char *filename;
  203.     bool packflag;
  204.     int i;
  205.  
  206.     packflag = Selected( packitems[0] )?1:0;
  207.  
  208.  
  209.     switch (item ) {
  210.     case 0:
  211.         if( (filename = GetOutFile())) {
  212.             SetHourGlass();
  213.             WriteIlbm(filename, &SurfWinDef, &SurfScrnDef, packflag);
  214.         }
  215.         break;
  216.     case 1:
  217.         filecnt = 0; /* deliberate fall into case 2 */
  218.     case 2:
  219.         if( filename = GetOutFile()) {
  220.             SetHourGlass();
  221.             sprintf(tempbuff, "%s.%d", filename, filecnt++ );
  222.             WriteIlbm(tempbuff, &SurfWinDef, &SurfScrnDef, packflag);
  223.         }
  224.         break;
  225.     case 4:
  226.         if( filename = GetInFile()){
  227.             SetHourGlass();
  228.             ReadIlbm( filename);
  229.         }
  230.         break;
  231.     case 5:
  232.         for( i = 0; i < (sizeof(greyitems)/sizeof(greyitems[0])); i++ ) {
  233.             if( Selected(greyitems[i])) {
  234.                 SetGreyModel(i);
  235.             }
  236.         }
  237.         break;
  238.     case 6:
  239.         CloseImgPix();
  240.         break;
  241.     default:
  242.         break;
  243.     }
  244.  
  245.     ClearHourGlass();
  246. }
  247.