home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1989 / USER1189.MSA / LISTINGS.ARC / TEST.C < prev    next >
C/C++ Source or Header  |  1989-09-03  |  2KB  |  78 lines

  1. /* Resource file example */
  2. /*   By  Janice Murray   */
  3.  
  4. #include <obdefs.h>
  5. #include <osbind.h>
  6.  
  7. #define DIALOGUE    0    /* form/dialog */
  8. #define QUIT        3    /* BUTTON in tree DIALOGUE */
  9. #define BUTTONA        5    /* BUTTON in tree DIALOGUE */
  10. #define BUTTONB        6    /* BUTTON in tree DIALOGUE */
  11.  
  12. #define POINTER        0    /* mouse macros */
  13. #define SHOW        257
  14. #define HIDE        256
  15.  
  16. int contrl[12],
  17.      intin[128],
  18.      intout[128],
  19.      ptsin[128],
  20.      ptsout[128],
  21.      work_in[12],
  22.      work_out[57];
  23.  
  24. int    handle,            /* vdi handle */
  25.     ch,                /* character height */
  26.     cw,                /* character width */
  27.     x,y,w,h;        /* dialog coords */
  28.  
  29. OBJECT *dialog;
  30.  
  31. gem_on()
  32. {
  33.     int i;
  34.     appl_init();
  35.     handle = graf_handle(&cw,&ch,&i,&i);    /* i is dummy variable */
  36.     for (i = 0; i < 10; work_in[i++] = 1);    /* fill work_in[] */
  37.     work_in[10] = 2;
  38.     v_opnvwk(work_in,&handle,work_out);    /* open workstation */
  39. }
  40.  
  41. gem_off()
  42. {
  43.     rsrc_free();        /* free memory used by resource */
  44.     v_clsvwk(handle);    /* close workstation */
  45.     appl_exit();        /* exit program */
  46. }
  47.  
  48. main()
  49. {
  50.     gem_on();        /* initialise program */
  51.     if (!rsrc_load("test.rsc"))
  52.         gem_off();    /* exit if can't find resource */
  53.     rsrc_gaddr(0,DIALOGUE,&dialog);    /* get dialog address */
  54.     form_center(dialog,&x,&y,&w,&h);    /* centre dialog */
  55.     do_dialog();
  56.     gem_off();        /* exit */
  57. }
  58.  
  59. do_dialog()
  60. {
  61.     int result;
  62.     graf_mouse(POINTER,0);    /* mouse pointer */
  63.     graf_mouse(HIDE,0);        /* hide mouse */
  64.     form_dial(0,0,0,0,0,x,y,w,h);        /* save screen */
  65.     objc_draw(dialog,0,32767,x,y,w,h);    /* draw dialog */
  66.     do {
  67.         graf_mouse(SHOW,0);
  68.         do {
  69.             result = form_do(dialog,0);    /* do dialog */
  70.         } while ( result!=QUIT );
  71.         graf_mouse(HIDE,0);    /* hide mouse */
  72.         dialog[result].ob_state ^= SELECTED;    /* de-select object */
  73.         objc_draw(dialog,result,0,x,y,w,h);        /* draw it */
  74.     }while (result != QUIT);
  75.     graf_mouse(SHOW,0);        /* show mouse */
  76.     form_dial(3,0,0,0,0,x,y,w,h);    /* restore screen */
  77. }
  78.