home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 019.lha / Aterm / Menu.c < prev    next >
C/C++ Source or Header  |  1986-11-10  |  9KB  |  246 lines

  1. /*****************************************************
  2.  *                  Menu Definitions                 *
  3.  *                                                   *
  4.  *             Created with Menu Creator             *
  5.  *                        by                         *
  6.  *                   David Pehrson                   *
  7.  *                                                   *
  8.  *         Copyright (C) 1986  David Pehrson         *
  9.  *                 Mantis Development                *
  10.  *                                                   *
  11.  *****************************************************/
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15. #include "Options.h"
  16.  
  17. #define BAUDITEM     5
  18. #define MODEITEM     BAUDITEM + 5
  19. #define CHOPITEM     0
  20. #define XONITEM      CHOPITEM     + 2
  21. #define PROTOCOLITEM XONITEM      + 2
  22. #define CHATITEM     PROTOCOLITEM + 3
  23. #define DEFAULT ITEMENABLED | ITEMTEXT | HIGHCOMP
  24.  
  25. extern BOOL chatting;
  26.  
  27. static UBYTE stTopaz[] = "topaz.font";
  28.  
  29. static struct TextAttr taPlain = {  stTopaz, 8, FS_NORMAL, FPF_ROMFONT };
  30.  
  31. static struct IntuiText SubText[] =
  32. {
  33.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   On", NULL },
  34.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Off", NULL },
  35.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   On", NULL },
  36.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Off", NULL },
  37.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   XModem", NULL },
  38.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   XModem - CRC", NULL },
  39.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Kermit", NULL },
  40. };
  41.  
  42. static struct IntuiText ItemText[] =
  43. {
  44.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)" Ascii Capture", NULL },
  45.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)" Ascii Transmit     ", NULL },
  46.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)" Binary Receive", NULL },
  47.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)" Binary Send", NULL },
  48.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)" Prompt", NULL },
  49.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"    300", NULL },
  50.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   1200", NULL },
  51.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   2400", NULL },
  52.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   4800", NULL },
  53.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   9600", NULL },
  54.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Half", NULL },
  55.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Full", NULL },
  56.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"   Echo", NULL },
  57.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  FKey Load", NULL },
  58.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  FKey Save", NULL },
  59.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  Define FKey     ", NULL },
  60.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  Auto Chop", NULL },
  61.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  Xon/Xoff", NULL },
  62.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  Protocol", NULL },
  63.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  CHAT Mode", NULL },
  64.     { 2, 1, JAM1, 0, 1, &taPlain, (UBYTE *)"  Phone Book", NULL },
  65. };
  66.  
  67. static struct MenuItem SubItems[] =
  68. {
  69.   {
  70.      &SubItems[1], 140, 0, 64, 10, DEFAULT | CHECKIT,
  71.      2, (APTR)&SubText[0], NULL, NULL, NULL, NULL  },
  72.   {
  73.      NULL, 140, 10, 64, 10, DEFAULT | CHECKIT,
  74.      1, (APTR)&SubText[1], NULL, NULL, NULL, NULL  },
  75.   {
  76.      &SubItems[3], 140, 0, 64, 10, DEFAULT | CHECKIT,
  77.      2, (APTR)&SubText[2], NULL, NULL, NULL, NULL  },
  78.   {
  79.      NULL, 140, 10, 64, 10, DEFAULT | CHECKIT,
  80.      1, (APTR)&SubText[3], NULL, NULL, NULL, NULL  },
  81.   {
  82.      &SubItems[5], 140, 0, 136, 10, DEFAULT | CHECKIT,
  83.      6, (APTR)&SubText[4], NULL, NULL, NULL, NULL },
  84.   {
  85.      &SubItems[6], 140, 10, 136, 10, DEFAULT | CHECKIT,
  86.      5, (APTR)&SubText[5], NULL, NULL, NULL, NULL },
  87.   {
  88.      NULL, 140, 20, 136, 10, DEFAULT | CHECKIT,
  89.      3, (APTR)&SubText[6], NULL, NULL, NULL, NULL },
  90. };
  91.  
  92. static struct MenuItem Items[] =
  93. {
  94.   {
  95.      &Items[1], 0, 0, 176, 10, DEFAULT | COMMSEQ,
  96.      0, (APTR)&ItemText[0], NULL, 'C', NULL, NULL },
  97.   {
  98.      &Items[2], 0, 10, 176, 10, DEFAULT | COMMSEQ,
  99.      0, (APTR)&ItemText[1], NULL, 'T', NULL, NULL },
  100.   {
  101.      &Items[3], 0, 20, 176, 10, DEFAULT | COMMSEQ,
  102.      0, (APTR)&ItemText[2], NULL, 'R', NULL, NULL },
  103.   {
  104.      &Items[4], 0, 30, 176, 10, DEFAULT | COMMSEQ,
  105.      0, (APTR)&ItemText[3], NULL, 'S', NULL, NULL },
  106.   {
  107.      NULL, 0, 40, 176, 10, DEFAULT | COMMSEQ,
  108.      0, (APTR)&ItemText[4], NULL, 'P', NULL, NULL },
  109.   {
  110.      &Items[6], 0, 0, 72, 10, DEFAULT | CHECKIT,
  111.      30, (APTR)&ItemText[5], NULL, NULL, NULL, NULL },
  112.   {
  113.      &Items[7], 0, 10, 72, 10, DEFAULT | CHECKIT,
  114.      29, (APTR)&ItemText[6], NULL, NULL, NULL, NULL 
  115.   },
  116.   {
  117.      &Items[8], 0, 20, 72, 10, DEFAULT | CHECKIT,
  118.      27, (APTR)&ItemText[7], NULL, NULL, NULL, NULL },
  119.   {
  120.      &Items[9], 0, 30, 72, 10, DEFAULT | CHECKIT,
  121.      23, (APTR)&ItemText[8], NULL, NULL, NULL, NULL },
  122.   {
  123.      NULL, 0, 40, 72, 10, DEFAULT | CHECKIT,
  124.      15, (APTR)&ItemText[9], NULL, NULL, NULL, NULL },
  125.   {
  126.      &Items[11], 0, 0, 99, 10, DEFAULT | CHECKIT | COMMSEQ,
  127.      6, (APTR)&ItemText[10], NULL, 'H', NULL, NULL },
  128.   {
  129.      &Items[12], 0, 10, 99, 10, DEFAULT | CHECKIT | COMMSEQ,
  130.      5, (APTR)&ItemText[11], NULL, 'F', NULL, NULL },
  131.   {
  132.      NULL, 0, 20, 99, 10, DEFAULT | CHECKIT | COMMSEQ,
  133.      3, (APTR)&ItemText[12], NULL, 'E', NULL, NULL },
  134.   {
  135.      &Items[14], 0, 0, 144, 10, DEFAULT | COMMSEQ,
  136.      0, (APTR)&ItemText[13], NULL, 'K', NULL, NULL },
  137.   {
  138.      &Items[15], 0, 10, 144, 10, DEFAULT | COMMSEQ,
  139.      0, (APTR)&ItemText[14], NULL, 'W', NULL, NULL },
  140.   {
  141.      &Items[16], 0, 20, 144, 10, DEFAULT | COMMSEQ,            /* def fkey */
  142.      0, (APTR)&ItemText[15], NULL, 'D', NULL, NULL },
  143.   {
  144.      &Items[17], 0, 30, 144, 10, DEFAULT,                      /* autochop */
  145.      0, (APTR)&ItemText[16], NULL, NULL, &SubItems[0], NULL },
  146.   {
  147.      &Items[18], 0, 40, 144, 10, DEFAULT,                      /* xon/xoff */
  148.      0, (APTR)&ItemText[17], NULL, NULL, &SubItems[2], NULL },
  149.   {
  150.      &Items[19], 0, 50, 144, 10, DEFAULT,                      /* protocol */
  151.      0, (APTR)&ItemText[18], NULL, NULL, &SubItems[4], NULL },
  152.   {
  153.      &Items[20], 0, 60, 144, 10, DEFAULT | COMMSEQ | CHECKIT | MENUTOGGLE, /* Chat mode */
  154.      0, (APTR)&ItemText[19], NULL, 'O', NULL, NULL },
  155.   {
  156.      NULL, 0, 70, 144, 10, DEFAULT | COMMSEQ,                  /* phone book */
  157.      0, (APTR)&ItemText[20], NULL, 'L', NULL, NULL },
  158. };
  159.  
  160. static struct Menu Titles[] =
  161. {
  162.     { &Titles[1], 3, 0, 54, 10, MENUENABLED, " File", &Items[0] },
  163.     { &Titles[2], 56, 0, 86, 10, MENUENABLED, " Baud  ", &Items[5] },
  164.     { &Titles[3], 141, 0, 54, 10, MENUENABLED, " Mode", &Items[10] },
  165.     { NULL, 194, 0, 126, 10, MENUENABLED, " Miscellaneous", &Items[13] },
  166. };
  167.  
  168.  
  169. static struct Menu *menuStrip = Titles;
  170. static struct Window *mywindow;
  171.  
  172. /*---------------------------------------------------------*/
  173. /*    InitMenu: set up the initial (default) menu       */
  174. /*---------------------------------------------------------*/
  175.  
  176. struct Menu *InitMenu( window )
  177. struct Window *window;
  178. {
  179.    SetMenuStrip( window, menuStrip );
  180.    mywindow = window;
  181.  
  182.    return menuStrip;
  183. }
  184.  
  185. /*---------------------------------------------------------*/
  186. /*    CloseMenu: Just ClearMenuStrip.               */
  187. /*---------------------------------------------------------*/
  188.  
  189. void CloseMenu()
  190. {
  191.    ClearMenuStrip( mywindow );
  192. }
  193.  
  194. /*---------------------------------------------------------*/
  195. /*    setFlag: turn checkmark on or off           */
  196. /*---------------------------------------------------------*/
  197.  
  198. static void setFlag( menuItem, seton )
  199. register struct MenuItem *menuItem;
  200. register BOOL   seton;
  201. {
  202.    if ( seton )
  203.       menuItem->Flags |= CHECKED;
  204.    else
  205.       menuItem->Flags &= ~CHECKED;
  206. }
  207.  
  208. /*---------------------------------------------------------*/
  209. /*    SetMenu: set up the menu for the given options.       */
  210. /*---------------------------------------------------------*/
  211.  
  212. void SetMenu( opt )
  213. register struct options *opt;
  214. {
  215.    static int menuBaud[] = { 300, 1200, 2400, 4800, 9600 };
  216.    register int i;
  217.  
  218.    ClearMenuStrip( mywindow );
  219.    
  220.    /* Set the Baud Rate */
  221.    for (i = 0; i < 5; i++)
  222.       setFlag( &Items[ i + BAUDITEM ], (BOOL)(opt->Baud == menuBaud[ i ]) );
  223.  
  224.    /* Set the Mode Flag */
  225.    for (i = 0; i < 3; i++)
  226.       setFlag( &Items[ i + MODEITEM ], (BOOL)(opt->Mode == i) );
  227.  
  228.    /* Set Auto Chop Flag */
  229.    setFlag( &SubItems[ CHOPITEM + 0 ], (BOOL)(opt->AutoChop) );
  230.    setFlag( &SubItems[ CHOPITEM + 1 ], (BOOL)(!opt->AutoChop) );
  231.      
  232.    /* Set Xon Flag */
  233.    setFlag( &SubItems[ XONITEM + 0 ], (BOOL)(opt->Xon) );
  234.    setFlag( &SubItems[ XONITEM + 1 ], (BOOL)(!opt->Xon) );
  235.      
  236.    /* Set the correct Protocol */
  237.    for (i = 0; i < 3; i++)
  238.       setFlag( &SubItems[ i + PROTOCOLITEM ], (BOOL)(opt->Protocol == i) );
  239.  
  240.    /* Set CHAT Mode Flag */
  241.    setFlag( &SubItems[ CHATITEM + 0 ], chatting );
  242.    setFlag( &SubItems[ CHATITEM + 1 ], !chatting );
  243.      
  244.    SetMenuStrip( mywindow, menuStrip );
  245. }
  246.