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

  1. #include <conio.h>
  2. #include "c:\tc\wgt\wgt.h"
  3. /*   WORDUP Graphics Toolkit   Version 2.1
  4.      Demonstration program 14
  5.  
  6. Demonstrates string input,mouse cursor shape and speed, and
  7. wflashcursor, cursor coordinates (xc,yc)
  8.  
  9. */
  10.  
  11. color palette[256];
  12. int i;
  13.  
  14. char *charlist=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.";
  15.     // this is a list of all the possible characters you can enter
  16.     // with wstring. If the character is not in the list, nothing will
  17.     // happen and the cursor will remain in the same position.
  18.  
  19. char *yesno="YNyn";
  20.     // used for yes/no answers only
  21.  
  22. char *string;
  23.  
  24. void main(void)
  25. {
  26. vga256();        // initializes system
  27.  
  28. for (i=1; i<253; i++)
  29.    wsetrgb(i,i+30,i+30,i,&palette);         // just something other
  30.                         // than black!
  31. wsetrgb(253,60,60,60,&palette);
  32. wsetrgb(254,50,50,50,&palette);
  33. wsetrgb(255,40,40,40,&palette);
  34. wsetpalette(0,255,&palette);
  35.  
  36. wcls(255);
  37.  
  38. wtextcolor(253);
  39. wtexttransparent(2);                    // must do this
  40.                             // or characters
  41.                             // will not erase
  42.  
  43. // wstring allows strings to be inputted using special keys such as
  44. // the arrow keys, backspace, delete, insert, home and end, etc.
  45.  
  46. string= (char *)malloc(11);            // remember to add one for
  47.                         // the null character. This
  48.                         // string is 10 chars long.
  49.  
  50. strcpy(string," ");            // now make sure it is empty
  51.  
  52.  
  53. curspeed=2400;
  54. // type in a string, try using the special keys
  55. wouttextxy(10,1,"Type in a string: ");
  56. wstring(150,1,string,charlist,10);
  57.  
  58.  
  59. free(string);            // now free the memory
  60.  
  61.  
  62.  
  63. string= (char *)malloc(2);
  64. strcpy(string," ");
  65.  
  66. // now try a yes or no answer, try letters other than {YNyn}
  67. wouttextxy(10,30,"Do you want to quit? ");
  68. wstring(170,30,string,yesno,1);
  69. free(string);
  70.  
  71.  
  72. wsetcursor(0,7);            // now do something interactive
  73. curspeed=1;                // with the mouse
  74. i=minit();
  75. moff();
  76. do {
  77.    mread();
  78.    xc=(mx/8)*8;                // divide by 8 and multiply by 8
  79.    yc=(my/8)*8;                // to make 8*8 squares
  80.    wflashcursor();
  81.    if (but==1)
  82.      {
  83.      wsetcolor(rand() % 64);
  84.      wline(0,0,xc,yc);            // do something in graphics as well
  85.      }
  86.    } while (!kbhit());
  87.  
  88.  
  89.  
  90. textmode(C80);                // used to return to text mode
  91. }