home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / misc / sci / cp / source / idcmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-21  |  4.6 KB  |  263 lines

  1. #include "cp.h"
  2.  
  3. WORD listcode;
  4.  
  5. BOOL sel = FALSE;
  6.  
  7. int addClicked( void )
  8. {
  9.      /* routine when gadget "_Add" is clicked. */
  10.      if (AddNewSet())
  11.        {
  12.           Erase ();
  13.           DrawView ( TRUE );
  14.        }
  15.      return ( 1 );
  16. }
  17.  
  18. int newfile( void )
  19. {
  20.      /* routine when "Open File" is selected from menu. */
  21.      FreeAllSets();
  22.      AddNewSet();
  23.      Erase ();
  24.      DrawView ( TRUE );
  25.      return ( 1 );
  26. }
  27.  
  28. int deleteClicked( void )
  29. {
  30.      /* routine when gadget "_Kill" is clicked. */
  31.  
  32.      if ( OpenGTXWindow( OpendelwinWindow ))
  33.        {
  34.           Death(20);
  35.        }
  36.  
  37.      sel = FALSE;
  38.      GT_SetGadgetAttrs(delwinGadgets[0],delwinWnd,NULL,GTLV_Labels,SetList,TAG_DONE);
  39.  
  40.                do {
  41.                Wait ( 1L << delwinWnd-> UserPort-> mp_SigBit );
  42.              }
  43.           while ( HandledelwinIDCMP() );
  44.  
  45.      ClosedelwinWindow();
  46.      return (1);
  47. }
  48.  
  49.  
  50. int fullClicked( void )
  51. {
  52.      /* routine when gadget "_Full" is clicked. */
  53.      Erase();
  54.      DrawView( TRUE );
  55.      return(1);
  56. }
  57.  
  58. int zoomClicked( void )
  59. {
  60.      /* routine when gadget "_Zoom" is clicked. */
  61.      Zoom();
  62.      return (1);
  63. }
  64.  
  65. int gridClicked( void )
  66. {
  67.      /* routine when gadget "_Grid" is clicked. */
  68.      Grid();
  69.      if ( grid == TRUE ) grid = FALSE;
  70.      else grid = TRUE;
  71.      return (1);
  72. }
  73.  
  74. int quitClicked( void )
  75. {
  76.      /* routine when gadget "_Quit" is clicked. */
  77.      return (0);
  78. }
  79.  
  80.  
  81. int PlotWindowItem0( void )
  82. {
  83.  
  84. struct EasyStruct ES =
  85.    {
  86.      sizeof(struct EasyStruct),
  87.      0,
  88.      "SAIC",
  89.      "%s",
  90.      "oh ok"
  91.     };
  92.      EasyRequest (PlotWindowWnd,&ES,NULL,"cP\nby\nChris Conger\n\nScience Applications International Corp.\n1993");
  93.      return (1);
  94. }
  95.  
  96. int PlotWindowItem1( void )
  97. {
  98.      return (0);
  99. }
  100.  
  101. int PlotWindowItem2( void )
  102. {
  103.      LOGX = FALSE;
  104.      Erase();
  105.      DrawView( TRUE );
  106.      return (1);
  107. }
  108.  
  109. int PlotWindowItem3( void )
  110. {
  111.      LOGX = TRUE;
  112.      Erase();
  113.      DrawView( TRUE );
  114.      return (1);
  115. }
  116.  
  117. int PlotWindowItem4( void )
  118. {
  119.      LOGY = FALSE;
  120.      Erase();
  121.      DrawView( TRUE );
  122.      return (1);
  123. }
  124.  
  125. int PlotWindowItem5( void )
  126. {
  127.      LOGY = TRUE;
  128.      Erase();
  129.      DrawView( TRUE );
  130.      return (1);
  131. }
  132.  
  133. int PlotWindowItem6( void )
  134. {
  135.      if( sym == TRUE ) sym = FALSE;
  136.      else  sym = TRUE;
  137.      Erase();
  138.      DrawView ( FALSE );
  139.      return ( 1 );
  140. }
  141.  
  142. int PlotWindowItem7( void )
  143. {
  144. UWORD r = NULL;
  145.  
  146.      if( CPANEL == TRUE )
  147.        {
  148.           CPANEL = FALSE;
  149.           r = RemoveGList( PlotWindowWnd, PlotWindowGList, PlotWindow_CNT+1 );
  150.        }
  151.      else
  152.        {
  153.           r = AddGList( PlotWindowWnd,PlotWindowGList, NULL, PlotWindow_CNT+1, NULL );
  154.           CPANEL = TRUE;
  155.        }
  156.      Erase();
  157.      DrawView ( FALSE );
  158.      return ( 1 );
  159. }
  160.  
  161. int PlotWindowVanillaKey( void )
  162. {
  163.      switch (PlotWindowMsg.Code)
  164.        {
  165.           case 'a':
  166.           case 'A':
  167.                return( addClicked() );
  168.           case 'k':
  169.           case 'K':
  170.                return( deleteClicked() );
  171.           case 'z':
  172.           case 'Z':
  173.                return( zoomClicked() );
  174.           case 'f':
  175.           case 'F':
  176.                return( fullClicked() );
  177.           case 'g':
  178.           case 'G':
  179.                return( gridClicked() );
  180.           case 'r':
  181.           case 'R':
  182.              Erase();
  183.              DrawView( FALSE );
  184.                return( 1 );
  185.           case 'q':
  186.           case 'Q':
  187.                return ( quitClicked() );
  188.           default:
  189.                return (1);
  190.        }
  191. }
  192.  
  193.  
  194. int delwinVanillaKey(void)
  195. {
  196.  
  197.      switch (delwinMsg.Code)
  198.        {
  199.           case 'r':
  200.           case 'R':
  201.                return( canlistClicked() );
  202.  
  203.           case 'd':
  204.           case 'D':
  205.                return ( delsetClicked());
  206.        }
  207.  
  208.      return(1);
  209. }
  210.  
  211. int dellistClicked( void )
  212. {
  213.      sel = TRUE;
  214.      listcode = delwinMsg.Code;
  215.      return ( 1 );
  216. }
  217.  
  218. int delsetClicked( void )
  219. {
  220. struct Set *node;
  221. WORD k;
  222.  
  223.      if ( sel )
  224.        {
  225.           node = (struct Set *)SetList-> lh_Head;
  226.           k = 0;
  227.  
  228.           while ( k < listcode )
  229.             {
  230.                node = (struct Set *)node-> snode.ln_Succ;
  231.                k++;
  232.             }
  233.  
  234.           GT_SetGadgetAttrs(delwinGadgets[0],delwinWnd,NULL,GTLV_Labels,~0,TAG_DONE);
  235.  
  236.           FreePoints( node -> FirstPoint);
  237.           Remove( (struct Node *)node );
  238.           FreeVec( node );
  239.  
  240.           GT_SetGadgetAttrs(delwinGadgets[0],delwinWnd,NULL,GTLV_Labels,SetList,TAG_DONE);
  241.  
  242.           sel = FALSE;
  243.        }
  244.      return ( 1 );
  245. }
  246.  
  247. int canlistClicked( void )
  248. {
  249.      delwinTop = delwinWnd-> TopEdge;
  250.      delwinLeft = delwinWnd-> LeftEdge;
  251.      Erase();
  252.      DrawView( FALSE );
  253.      return ( 0 );
  254. }
  255.  
  256. int delwinCloseWindow( void )
  257. {
  258.      delwinTop = delwinWnd-> TopEdge;
  259.      delwinLeft = delwinWnd-> LeftEdge;
  260.      return ( 0 );
  261. }
  262.  
  263.