home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / educatin / morse / sendgem.c < prev   
C/C++ Source or Header  |  1985-11-19  |  4KB  |  180 lines

  1. /* GEM routines used by SENDER.C */
  2.  
  3. short    xpos, ypos;
  4.  
  5. /* GEM globals */
  6. short    contrl[12], intin[128], ptsin[128], intout[128], ptsout[128],
  7.     pxyarray[12], int_in[11], int_out[57];
  8.  
  9. /* Working storage */
  10. short    handle, wi_handle, ap_id, gl_hchar, gl_wchar,
  11.     gl_wbox, gl_hbox, xwork, ywork, wwork, hwork, xdesk, ydesk,
  12.     wdesk, hdesk, xold, yold, hold, wold, xobj, yobj, wobj, hobj,
  13.     xmouse, ymouse;
  14.  
  15. long    resrcs;
  16.  
  17. char    *no_rsc_file = "[3][Resource (.RSC) file is missing!][Abort]",
  18.     *bad_rsc_file = "[3][Resource (.RSC) file is defective.][Abort]",
  19.     infile[128], dirspec[128];
  20.  
  21. #define OB_SPEC( x )    (long *) (tree + (x) * sizeof( OBJECT ) + 12)
  22. #define OB_STATE( x )    (short *) (tree + (x) * sizeof( OBJECT ) + 10)
  23. #define TE_PTEXT( x )    (long *) (x)
  24.  
  25. clear_window( top )
  26. short top;
  27. {
  28.     short wbound[4];
  29.  
  30.     graf_mouse( M_OFF, 0x0L );
  31.     wind_update( BEG_UPDATE );
  32.     wbound[0] = xwork;
  33.     wbound[1] = top;
  34.     wbound[2] = xwork + wwork;
  35.     wbound[3] = ywork + hwork;
  36.     vsf_color( handle, BLACK );
  37.     vsf_style( handle, 5 );
  38.     vsf_interior( handle, 2 );
  39.     vr_recfl( handle, wbound );
  40.     ypos = top + (gl_hchar<<1);
  41.     xpos = xwork + gl_wchar;
  42.     wind_update( END_UPDATE );
  43.     graf_mouse( M_ON, 0x0L );
  44. }    /* clear_window */
  45.  
  46. close_window()
  47. {
  48.     wind_close( wi_handle );
  49.     graf_shrinkbox( xwork+wwork/2, ywork+hwork/2, gl_wbox, gl_hbox, xwork,
  50.       ywork, wwork, hwork );
  51.     wind_delete( wi_handle );
  52. }    /* close_window */
  53.  
  54. deselect( object )    /* Turn off deselected object in resrcs */
  55. short object;
  56. {
  57.     objc_change( resrcs, object, 0, xwork, ywork, wwork, hwork, NORMAL,
  58.       1 );
  59. }    /* deselect */
  60.  
  61. gem_init()
  62. {
  63.     /* Initialize application and open windows */
  64.     ap_id = appl_init();
  65.     handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
  66.     open_vwork();
  67.     open_window();
  68.     graf_mouse( ARROW, 0x0L );
  69. }    /* gem_init */
  70.  
  71. getfspec( finit, fspec, wcard )
  72. char *finit, *fspec, *wcard;
  73. {
  74.     short drive, okay;
  75.     char fname[128];
  76.  
  77.     if( strlen( finit ) == 0 )
  78.     {
  79.         drive = Dgetdrv();    /* current drive */
  80.         finit[0] = drive + 'A';
  81.         finit[1] = ':';
  82.         Dgetpath( &finit[2], drive+1 );    /* current directory level */
  83.         strcat( finit, wcard );
  84.     }
  85.     graf_mouse( ARROW, 0x0L );
  86.     if( !fsel_input( finit, fname, &okay ) )
  87.     {
  88.         form_alert( 1, "[3][Invalid filespec][Continue]" );
  89.         return( FALSE );
  90.     }
  91.  
  92.     /* Redraw main window */
  93.     clear_window( ywork );
  94.     graf_mouse( BUSYBEE, 0x0L );
  95.  
  96.     if( !okay ) return( FALSE );    /* CANCEL */
  97.     if( fname[0] == ' ' || fname[0] == '\0' )
  98.         return( FALSE );
  99.     merge( fspec, finit, fname );
  100.     return( TRUE );
  101. }    /* getfspec */
  102.  
  103. merge( spec, dir, file )    /* combine directory and filenames */
  104. char *spec, *dir, *file;
  105. {
  106.     char *ldir, *strrchr();
  107.  
  108.     strcpy( spec, dir );
  109.     ldir = strrchr( spec, '\\' );
  110.     if( ldir == NULL ) ldir = spec;
  111.     else ldir++;
  112.     strcpy( ldir, file );
  113. }    /* merge */
  114.  
  115. open_vwork()
  116. {
  117.     short i;
  118.  
  119.     for( i=1; i<10; i++ ) int_in[i] = 1;
  120.     int_in[10] = 2;
  121.     v_opnvwk( int_in, &handle, int_out );
  122. }    /* open_vwork */
  123.  
  124. open_window()
  125. {
  126.     wind_get( 0, WF_WORKXYWH, &xdesk, &ydesk, &wdesk, &hdesk );
  127.     wi_handle = wind_create( 0, xdesk, ydesk, wdesk, hdesk );
  128.     graf_growbox( xdesk+wdesk/2, ydesk+hdesk/2, gl_wbox, gl_hbox, xdesk,
  129.       ydesk, wdesk, hdesk );
  130.     wind_open( wi_handle, xdesk, ydesk, wdesk, hdesk );
  131.     wind_get( wi_handle, WF_WORKXYWH, &xwork, &ywork, &wwork, &hwork );
  132. }    /* open_window */
  133.  
  134. select( object )    /* Highlight selected object in resrcs */
  135. short object;
  136. {
  137.     objc_change( resrcs, object, 0, xwork, ywork, wwork, hwork, SELECTED,
  138.       1 );
  139. }    /* select */
  140.  
  141. terminate( dialog )    /* Show final dialog, close everything and quit */
  142. char *dialog;
  143. {
  144.     if( dialog != NULL ) form_alert( 1, dialog );
  145.     close_window();
  146.     m_wait( 10 );    /* Clear event queue */
  147.     v_clsvwk( handle );
  148.     appl_exit();
  149.     exit(0);
  150. }    /* terminate */
  151.  
  152. textbox( box )
  153. short box[4];
  154. {
  155.     short outline[10];
  156.  
  157.     graf_mouse( M_OFF, 0x0L );
  158.     wind_update( BEG_UPDATE );
  159.     vsf_color( handle, 0 );
  160.     vsf_interior( handle, 1 );
  161.     v_bar( handle, box );
  162.     ypos = box[1] + gl_hchar;
  163.     xpos = box[0] + gl_wchar;
  164.     vsf_color( handle, 1 );
  165.     outline[0] = outline[2] = outline[8] = box[0];
  166.     outline[1] = outline[7] = outline[9] = box[1];
  167.     outline[3] = outline[5] = box[3];
  168.     outline[4] = outline[6] = box[2];
  169.     v_pline( handle, 5, outline );
  170.     wind_update( END_UPDATE );
  171.     graf_mouse( M_ON, 0x0L );
  172. }    /* textbox */
  173.  
  174. wputs( str )
  175. char *str;
  176. {
  177.     v_gtext( handle, xpos, ypos, str );
  178.     ypos += gl_hchar;
  179. }    /* wputs */
  180.