home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / mainslct.c < prev    next >
C/C++ Source or Header  |  1991-01-05  |  4KB  |  151 lines

  1. #ifndef lint
  2. static char SccsId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /* Module:    mainslct.c (Main Select)
  6.  * Purpose:    Respond to selections from user interfaces
  7.  * Subroutine:    dispatch_select()        returns: void
  8.  * Copyright:    1989 Smithsonian Astrophysical Observatory
  9.  *        You may do anything you like with this file except remove
  10.  *        this copyright.  The Smithsonian Astrophysical Observatory
  11.  *        makes no representations about the suitability of this
  12.  *        software for any purpose.  It is provided "as is" without
  13.  *        express or implied warranty.
  14.  * Modified:    {0} Michael VanHilst    initial version           9 May 1989
  15.  *        {1} MVH support for text cursor               1 Jan 1991
  16.  *        {n} <who> -- <does what> -- <when>
  17.  */
  18.  
  19. #include <stdio.h>        /*  stderr, NULL, etc.  */
  20. #include <X11/Xlib.h>        /*  X window stuff  */
  21. #include <X11/Xutil.h>        /*  X window manager stuff  */
  22. #include "hfiles/constant.h"    /*  Define codes  */
  23. #include "hfiles/struct.h"    /*  Declare structure types  */
  24. #include "hfiles/extern.h"    /*  Extern main parameter structures  */
  25.  
  26. #ifdef ANSIC
  27.  
  28. void        dispatch_select(    int *response_data);
  29.  
  30. static void select_environment(    int response[]);
  31.  
  32. #else
  33.  
  34.   static void select_environment();
  35.   void select_cursor(), select_region(), select_halftone(), select_scalemap();
  36.   void new_dispboxmouse(), select_color(), select_pan();
  37.  
  38. #endif
  39.  
  40.  
  41. /*  Subroutine:    dispatch_select
  42.  *  Purpose:    Dispatcher for selections from the buttonbox or other
  43.  *        selection interface
  44.  */
  45. #ifdef ANSIC
  46. void dispatch_select ( int *response_data )
  47. #else
  48. void dispatch_select ( response_data )
  49.      int *response_data;
  50. #endif
  51. {
  52.   /*  Check for no selection data  */
  53.   if( response_data == NULL )
  54.     return;
  55.   /*  Check for selection with control key down  */
  56.   if( control.event.xbutton.state & ControlMask )
  57.     return;
  58.   /*  Check for switching out of cursor in text mode  */
  59.   if( control.mode == COP ) {
  60.     if(   (cursor.type == COP_Text) && (response_data[1] == 0)
  61.        && (response_data[0] != COP) && (response_data[0] != ROP) )
  62.       grab_keys_for_textcursor(0);
  63.   }
  64.   control.response = response_data;
  65.   /*  Check pane (mode) part of response  */
  66.   switch( response_data[0] ) {
  67.     /*  Environment panel selection  */
  68.   case EOP:
  69.     select_environment(response_data);
  70.     control.mode = EOP;
  71.     break;
  72.   case SOP:
  73.     /*  From the image scale pane  */
  74.     select_scalemap();
  75.     control.mode = SOP;
  76.     break;
  77.   case ZOP:
  78.     /*  From the pan pane  */
  79.     select_pan();
  80.     break;
  81.   case COP:
  82.     /*  From the cursor menu pane  */
  83.     select_cursor();
  84.     break;
  85.   case MOP:
  86.   case VOP:
  87.     /*  From the color menu pane  */
  88.     select_color();
  89.     break;
  90.   case BOP:
  91.     select_halftone();
  92.     break;
  93.   case ROP:
  94.     select_region();
  95.     break;
  96.   }
  97.   /*  Install the correct mouse icon for the new mode  */
  98.   new_dispboxmouse();
  99. }
  100.  
  101.  
  102. /*  Subroutine:    select_environment
  103.  *  Purpose:    Response to selections from the environment button sub-menu
  104.  */
  105. #ifdef ANSIC
  106. static void select_environment ( int response[] )
  107. #else
  108. static void select_environment ( response )
  109.      int response[];
  110. #endif
  111. {
  112.   void say_goodbye(), raise_windows(), get_new_cmd();
  113.   void screen_dump(), disp_dispbox();
  114.  
  115.   /*  Check the response code  */
  116.   switch( response[1] ) {
  117.   case 0:
  118.     return;
  119.   case EOP_Verbose:
  120.     /*  Toggle verbose output of text  */
  121.     control.verbose = !control.verbose;
  122.     break;
  123.   case EOP_Exit:
  124.     /*  Selected exit  */
  125.     say_goodbye(0);
  126.     break;
  127.   case EOP_Raise:
  128.     raise_windows();
  129.     break;
  130.   case EOP_NewFile:
  131.     /*  Read new command line with a popup window (see CmdNew.c)  */
  132.     get_new_cmd();
  133.     break;
  134.   case EOP_Output:
  135.     /*  Output hardcopy to a printer  */
  136.     screen_dump(!control.print_buttons);
  137.     break;
  138.   case EOP_Track:
  139.     /*  Flip the tracking mode flags  */
  140.     control.tracking ^= 1;
  141.     control.magni_track ^= 1;
  142.     break;
  143.   case EOP_TextTrack:
  144.     /*  Flip the tracking mode flag  */
  145.     control.coord_track ^= 1;
  146.     break;
  147.   default:
  148.     break;
  149.   }
  150. }
  151.