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