home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1990 / USEROC90.MSA / LISTINGS_PATTERNS.C < prev    next >
C/C++ Source or Header  |  1990-08-19  |  3KB  |  83 lines

  1. /* Demo program showing fill patterns/styles in rounded filled boxes */
  2. /*  By R.A.Waddilove    */
  3.  
  4. short    control[12],        /* These arrays are used by  */
  5.         intin[128],            /* GEM and you don't need to */
  6.         ptsin[128],            /* worry about them. Define  */
  7.         intout[128],        /* them, then forget them.     */
  8.         ptsout[128];
  9.  
  10. short    work_in[11]={1,1,1,1,1,1,1,1,1,1,2},
  11.         work_out[57],        /* holds various VDI parameters */
  12.         handle,                /* virtual workstation handle */
  13.         wchar,hchar,        /* character size */
  14.         wbox,hbox;            /* character box size */
  15.  
  16. main()                        /* void means we aren't passing parameters */
  17. {
  18.     short x,y,button,i,j,box[4],pat[16];
  19.     appl_init();            /* initialise GEM AES arrays, return id */
  20.     handle = graf_handle(&wchar,&hchar,&wbox, &hbox); /* GEM VDI handle */
  21.     v_opnvwk(work_in, &handle, work_out);    /* open virtual workstation */
  22.     v_hide_c(handle);                        /* hide mouse */
  23.     v_clrwk(handle);                        /* clear the screen */
  24.  
  25.  
  26. /* draw the fill patterns */
  27.     vsf_color(handle,1);            /* colour=black */
  28.     for ( x=0; x<24; ++x )    {        /* pattern styles 1-24 */
  29.         vsf_interior(handle,2);        /* set patterned fill */
  30.         vsf_style(handle,x+1);        /* choose pattern to fill with*/
  31.         box[0] = x*26;                /* top left x */
  32.         box[1] = 0;                    /* top left y */
  33.         box[2] = box[0]+23;            /* bottom right x */
  34.         box[3] = box[1]+40;            /* bottom right y */
  35.         v_rfbox(handle,box);        /* draw rounded filled box */
  36.     }
  37.  
  38. /* draw the hatch patterns */
  39.     vsf_color(handle,1);            /* colour=black */
  40.     for ( x=0; x<12; ++x )    {        /* pattern styles 1-12 */
  41.         vsf_interior(handle,3);        /* set hatch fill */
  42.         vsf_style(handle,x+1);        /* choose pattern to fill with*/
  43.         box[0] = x*52;                /* top left x */
  44.         box[1] = 50;                /* top left y */
  45.         box[2] = box[0]+48;            /* bottom right x */
  46.         box[3] = box[1]+40;            /* bottom right y */
  47.         v_rfbox(handle,box);        /* draw rounded filled box */
  48.     }
  49.  
  50. /* Now for my own fill pattern! */
  51.     pat[0] =  0x0F0F;
  52.     pat[1] =  0x0F0F;
  53.     pat[2] =  0x0000;
  54.     pat[3] =  0x0000;
  55.     pat[4] =  0xAAAA;
  56.     pat[5] =  0xAAAA;
  57.     pat[6] =  0xBBBB;
  58.     pat[7] =  0xBBBB;
  59.     pat[8] =  0xCCCC;
  60.     pat[9] =  0xCCCC;
  61.     pat[10] = 0xBBBB;
  62.     pat[11] = 0xBBBB;
  63.     pat[12] = 0x0000;
  64.     pat[13] = 0x0000;
  65.     pat[14] = 0x1234;
  66.     pat[15] = 0x4321;
  67.     vsf_udpat(handle,pat,1);
  68.     vsf_interior(handle,4);        /* set user defined fill */
  69.     box[0] = 40;                /* top left x */
  70.     box[1] = 100;                /* top left y */
  71.     box[2] = 600;                /* bottom right x */
  72.     box[3] = 140;                /* bottom right y */
  73.     v_rfbox(handle,box);        /* draw rounded filled box */
  74.  
  75. /* quit back to the desktop */
  76.     do {
  77.         vq_mouse(handle, &button, &x, &y);    /* get mouse x,y,button state */
  78.     } while ( button==0 );        /* wait until a button is pressed */
  79.     v_show_c(handle,1);            /* show mouse */
  80.     v_clsvwk(handle);            /* close virtual workstation */
  81.     appl_exit();                /* tell GEM we've finished */
  82. }
  83.