home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / WGT_TC21.ZIP / WGT11.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  2KB  |  77 lines

  1. #include <conio.h>
  2. #include "c:\tc\wgt\wgt.h"
  3. /*   WORDUP Graphics Toolkit   Version 2.1
  4.      Demonstration program 11
  5.  
  6. Shows the use of wgetblockwidth and wgetblockheight, and
  7. demonstrates resize procedure.
  8.  
  9. */
  10.  
  11. int i,x,y;
  12. color palette[256];
  13. block part1;            // part of the screen
  14.  
  15.  
  16. void main(void)
  17. {
  18. vga256();        // initializes system
  19.  
  20.  
  21. for (y=1; y<64; y++)        
  22.    wsetrgb(y,y,y,y,&palette);       // sets first 64 colours to grey
  23.                     // note the use of &
  24. for (y=0; y<64; y++)
  25.    wsetrgb(y+64,y,0,0,&palette);        // next 64 to red
  26. for (y=0; y<64; y++)
  27.    wsetrgb(y+128,0,y,0,&palette);       // green
  28. for (y=0; y<64; y++)
  29.    wsetrgb(y+192,0,0,y,&palette);    // blue
  30.  
  31.    wsetrgb(1,63,63,63,&palette);       // sets color 1 to white
  32.  wsetpalette(0,255,palette);        // and finally change them
  33.                     // all at once
  34.  
  35. for (y=1; y<100; y++)
  36.   {
  37.   wsetcolor(y);
  38.   wline(0,y,160,y);
  39.   }
  40. wtextcolor(1);
  41. wouttextxy(10,10,"This block will");
  42. wouttextxy(10,30,"be resized on");
  43. wouttextxy(10,50,"the screen.");
  44.  
  45.  
  46. part1=wnewblock(1,1,160,100);    // get the block
  47. getch();
  48. wcls(0);            // clear the screen
  49. x=wgetblockwidth(part1);
  50. y=wgetblockheight(part1);
  51.  
  52. textmode(C80);            // notice how you can go between text
  53. gotoxy(1,1);
  54. printf("Block width : %i\n",x);
  55. printf("Block height: %i\n",y);
  56. printf("Block size is %u bytes.",x*y+4);
  57. printf("\nPress any key to resize...");
  58. getch();
  59. vga256();            // and graphics modes
  60. wsetpalette(0,255,palette);    // but you must reset the colours.
  61.  
  62.  
  63. do {
  64. for (i=1; i<100; i+=2)
  65.    wresize(80,50,80+i,50+i,part1);
  66. for (i=100; i>0; i-=2)
  67.    wresize(80,50,80+i,50+i,part1);
  68. } while (!kbhit());
  69. getch();
  70.  
  71.  
  72. wcls(0);
  73.   
  74.  
  75. wfreeblock(part1);
  76. textmode(C80);                // used to return to text mode
  77. }