home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / guilib20.zip / DEMO.CPP < prev    next >
C/C++ Source or Header  |  1993-01-17  |  19KB  |  792 lines

  1. //**************************************************************************
  2. //    This is a demo program to show how to use some of the features of
  3. //    the GUI library. To compile and run this
  4. //    demo create a project file including the files GUI.LIB and DEMO.CPP.
  5. //    Make sure that the files are located where the project says they are.
  6. //  You may also need to change to path to the GUI.H file in the #includes
  7. //    portion of this file.
  8. //
  9. //    Also note that the following files must be in the same directory as
  10. //    the executable for this program to operate properly:
  11. //
  12. //        B1.BTN
  13. //        B2.BTN
  14. //        I1.ICN
  15. //        I2.ICN
  16. //        I3.ICN
  17. //        C2.CUT
  18. //
  19. //**************************************************************************
  20.  
  21. #include "gui.h"
  22. #include <conio.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <graphics.h>
  26.  
  27. #define BKG     3
  28.  
  29. //*************************  FUNCTION PROTOTYPES  **************************
  30.  
  31. void initgraphicdemo();
  32. void gbuttondemo();
  33. void graphbuttondemo();
  34. void paneldemo();
  35. void icondemo();
  36. void acticondemo();
  37. void gmenudemo();
  38. void inputdemo();
  39. void mcursordemo();
  40. void check_radio_demo();
  41. void bitmapdemo();
  42.  
  43. void write3d(int,char *);
  44. void early_exit();
  45. void norm_exit();
  46. void do_siren();
  47. void do_tele();
  48.  
  49. //***************************  GLOBAL VARIABLES  ***************************
  50.  
  51. extern Mcursor the_mouse;
  52. Screen screen;
  53. int mouse_present=0;
  54. char ch;
  55.  
  56. //**************************************************************************
  57. //        MAIN
  58.  //**************************************************************************
  59.  
  60. void main()
  61. {
  62.     initgraphicdemo();
  63.     closegraph();
  64.     puts("Thank you for previewing the GUI library from");
  65.     puts("David S. Reinhart Associates");
  66.     exit(0);
  67. }
  68.  
  69. //**************************************************************************
  70. //**************************************************************************
  71. //**************************************************************************
  72.  
  73. void initgraphicdemo()
  74. {
  75.     screen.VGA_480_16();
  76.     delay(1000);
  77.  
  78.     if(!the_mouse.init()) {
  79.         puts("Unable to detect mouse driver. Graphic portion of this demo");
  80.         puts("requires a mouse.");
  81.         closegraph();
  82.         exit(1);
  83.         }
  84.  
  85.     setfillstyle(SOLID_FILL,BKG);
  86.     bar(0,0,getmaxx(),getmaxy());
  87.  
  88.     Bevel mainpanel;
  89.  
  90.     mainpanel.init(50,75,540,125,THICK);
  91.     mainpanel.show();
  92.  
  93.     settextjustify(CENTER_TEXT,TOP_TEXT);
  94.     write3d(100,"GUI library demonstration for Borland C++ and");
  95.     write3d(115,"Turbo C++. This demo and the included graphics library file(s)");
  96.     write3d(130,"(c) Copyright 1993, David S. Reinhart Associates");
  97.  
  98.     write3d(160,"Press the <ENTER> key or the right mouse key to progress through");
  99.     write3d(175,"the demo.");
  100.  
  101.     Panel copyrightpanel;
  102.     copyrightpanel.init(3,455,634,21,OUT,THIN);
  103.     copyrightpanel.show();
  104.     setcolor(0);
  105.     write3d(465,"(c) Copyright 1992 - David S. Reinhart Associates");
  106.  
  107.     the_mouse.arm();
  108.  
  109.     int selected=0;
  110.     while(!selected) {
  111.         while(!kbhit() && !the_mouse.RBP());
  112.         if(kbhit()) {
  113.             if((ch=getch())==27)
  114.                 early_exit();
  115.             while(kbhit())getch();
  116.             selected=1;
  117.             }
  118.         if(the_mouse.RBP())
  119.             selected=1;
  120.         }
  121.  
  122.     gbuttondemo();
  123.     graphbuttondemo();
  124.     icondemo();
  125.     acticondemo();
  126.     paneldemo();
  127.     gmenudemo();
  128.     inputdemo();
  129.     mcursordemo();
  130.     check_radio_demo();
  131.     bitmapdemo();
  132.  
  133. }
  134.  
  135. //**************************************************************************
  136.  
  137. void mcursordemo()
  138. {
  139.     int cur=1;
  140.  
  141.     the_mouse.hide();
  142.     setfillstyle(SOLID_FILL,3);
  143.     bar(0,0,getmaxx(),getmaxy()-30);
  144.  
  145.     write3d(20,"Press the left mouse key to cycle through cursors.");
  146.     write3d(35,"Press right mouse key to end.");
  147.  
  148.     the_mouse.show();
  149.     while(!the_mouse.RBP()) {
  150.         if(the_mouse.LBP()) {
  151.             cur++;
  152.             if(cur>16)cur=1;
  153.             the_mouse.changeto(cur);
  154.             while(the_mouse.LBP());
  155.             }
  156.         }
  157. }
  158.  
  159. //**************************************************************************
  160.  
  161. void gbuttondemo()
  162. {
  163.     setfillstyle(SOLID_FILL,BKG);
  164.     the_mouse.hide();
  165.     bar(0,0,getmaxx(),getmaxy()-40);
  166.  
  167.     Bevel mainpanel;
  168.     mainpanel.init(30,70,580,230,THICK);
  169.     mainpanel.show();
  170.  
  171.     write3d(85,"Buttons are one of the most fundamental graphic objects.");
  172.     write3d(100,"They are very popular within graphics environments");
  173.     write3d(115,"for getting user input. You, the programmer, have complete");
  174.     write3d(130,"control over how these button objects function. That is");
  175.     write3d(145,"to say, whether the resulting action takes place when the");
  176.     write3d(160,"button is pressed or released; how long the button remains");
  177.     write3d(175,"depressed; etc...  Experiment with the buttons below.");
  178.  
  179.     Button lowbutton;
  180.     Button medbutton;
  181.     Button hibutton;
  182.     Panel buttonpanel;
  183.  
  184.     lowbutton.init(150,230," LOW ",TEXT);
  185.     medbutton.init(300,230," MED ",TEXT);
  186.     hibutton.init(450,230," HI  ",TEXT);
  187.     buttonpanel.init(130,220,390,45,IN,THICK);
  188.     buttonpanel.show();
  189.  
  190.     lowbutton.show();
  191.     medbutton.show();
  192.     hibutton.show();
  193.  
  194.     the_mouse.show();
  195.     int selected=0;
  196.  
  197.     flushkeys();
  198.     while(!selected) {
  199.         if(the_mouse.LBP()) {
  200.             if(lowbutton.hit()) {
  201.                 lowbutton.press();
  202.                 while(the_mouse.LBP() && lowbutton.hit());
  203.                 lowbutton.show();
  204.                 if(lowbutton.hit()) {
  205.                     sound(220);
  206.                     delay(500);
  207.                     nosound();
  208.                     continue;
  209.                     }
  210.                 }
  211.             if(medbutton.hit()) {
  212.                 medbutton.press();
  213.                 while(the_mouse.LBP() && medbutton.hit());
  214.                 medbutton.show();
  215.                 if(medbutton.hit()) {
  216.                     sound(440);
  217.                     delay(500);
  218.                     nosound();
  219.                     continue;
  220.                     }
  221.                 }
  222.             if(hibutton.hit()) {
  223.                 hibutton.press();
  224.                 while(the_mouse.LBP() && hibutton.hit());
  225.                 hibutton.show();
  226.                 if(hibutton.hit()) {
  227.                     sound(880);
  228.                     delay(500);
  229.                     nosound();
  230.                     continue;
  231.                     }
  232.                 }
  233.             }// end if the_mouse.LBP
  234.         if(the_mouse.RBP()) {
  235.             selected=1;
  236.             }
  237.         if(kbhit()) {
  238.             if((ch=getch())==27)
  239.                 early_exit();
  240.             while(kbhit())getch();
  241.             selected=1;
  242.             }
  243.         }// end while !selected
  244. }
  245.  
  246. //**************************************************************************
  247.  
  248. void graphbuttondemo()
  249. {
  250.     the_mouse.hide();
  251.     setfillstyle(SOLID_FILL,BKG);
  252.     bar(0,0,getmaxx(),getmaxy()-40);
  253.  
  254.     Bevel mainpanel;
  255.     mainpanel.init(50,50,getmaxx()-100,250,THICK);
  256.     mainpanel.show();
  257.  
  258.     write3d(75,"Buttons can have not only text labels, but graphics as well!");
  259.     write3d(90,"Graphics not only make the interface look nicer, but can");
  260.     write3d(105,"also make the button's function more intuitive for the end user.");
  261.     write3d(120,"Try to guess what the outcome will be before trying out each of");
  262.     write3d(135,"the buttons below.");
  263.     write3d(165,"By the way, these graphic buttons are easy to create using the");
  264.     write3d(180,"ICONEDIT program supplied in this package.");
  265.  
  266.     Panel buttonpanel;
  267.     Button sirenbutton;
  268.     Button telebutton;
  269.  
  270.     buttonpanel.init(270,220,100,50,IN,THICK);
  271.     buttonpanel.show();
  272.     sirenbutton.init(285,235,"b1",1);
  273.     telebutton.init(330,235,"b2",1);
  274.     sirenbutton.show();
  275.     telebutton.show();
  276.     the_mouse.show();
  277.  
  278.     flushkeys();
  279.     int selected=0;
  280.     while(!selected) {
  281.         if(the_mouse.RBP())
  282.             selected=1;
  283.         if(kbhit()) {
  284.             if((ch=getch())==27)
  285.                 early_exit();
  286.             while(kbhit())getch();
  287.             selected=1;
  288.             }
  289.         if(the_mouse.LBP()) {
  290.             if(sirenbutton.hit()) {
  291.                 sirenbutton.press();
  292.                 while(the_mouse.LBP() && sirenbutton.hit());
  293.                 sirenbutton.show();
  294.                 if(sirenbutton.hit()) {
  295.                     do_siren();
  296.                     continue;
  297.                     }
  298.                 }
  299.             if(telebutton.hit()) {
  300.                 telebutton.press();
  301.                 while(the_mouse.LBP() && telebutton.hit());
  302.                 telebutton.show();
  303.                 if(telebutton.hit()) {
  304.                     do_tele();
  305.                     continue;
  306.                     }
  307.                 }
  308.             }
  309.         }
  310. }
  311.  
  312. //**************************************************************************
  313.  
  314. void paneldemo()
  315. {
  316.     the_mouse.hide();
  317.     setfillstyle(SOLID_FILL,BKG);
  318.     bar(0,0,getmaxx(),getmaxy()-40);
  319.  
  320.     Bevel mainpanel;
  321.     mainpanel.init(10,10,getmaxx()-20,70,THICK);
  322.     mainpanel.show();
  323.  
  324.     write3d(25,"Panels offer an attractive way to partition the graphics screen.");
  325.     write3d(40,"Here are some of the different types of panels that can easily");
  326.     write3d(55,"be implemented using the ObjectEase library.");
  327.  
  328.     Panel inthick;
  329.     Panel inthin;
  330.     Panel outthick;
  331.     Panel outthin;
  332.     Bevel thin;
  333.     Bevel thick;
  334.  
  335.     delay(2000);
  336.     write3d(90,"THICK STYLES                               THIN STYLES");
  337.     inthick.init(50,105,200,100,IN,THICK);
  338.     inthick.show();
  339.     inthin.init(390,105,200,100,IN,THIN);
  340.     inthin.show();
  341.     delay(1000);
  342.     outthick.init(50,220,200,100,OUT,THICK);
  343.     outthick.show();
  344.     outthin.init(390,220,200,100,OUT,THIN);
  345.     outthin.show();
  346.     delay(1000);
  347.     thick.init(50,335,200,100,THICK);
  348.     thick.show();
  349.     thin.init(390,335,200,100,THIN);
  350.     thin.show();
  351.  
  352.     the_mouse.show();
  353.     flushkeys();
  354.     while(!kbhit() && !the_mouse.RBP());
  355.     if(kbhit()) {
  356.         if((ch=getch())==27)
  357.             early_exit();
  358.         while(kbhit())getch();
  359.         }
  360. }
  361.  
  362. //**************************************************************************
  363.  
  364. void icondemo()
  365. {
  366.     the_mouse.hide();
  367.     setfillstyle(SOLID_FILL,BKG);
  368.     bar(0,0,getmaxx(),getmaxy()-40);
  369.  
  370.     Bevel mainpanel;
  371.     mainpanel.init(50,50,getmaxx()-100,200,THICK);
  372.     mainpanel.show();
  373.  
  374.     write3d(75,"What paint program would be complete without icons? Icons are");
  375.     write3d(90,"as intuitive to use as buttons, and once again, using the");
  376.     write3d(105,"ICONEDIT program, they are easy for you, the programmer, to");
  377.     write3d(120,"create. Check out the action of the icons below...");
  378.  
  379.     Panel iconpanel;
  380.     Icon drawicon;
  381.     Icon painticon;
  382.  
  383.     iconpanel.init(250,160,getmaxx()-500,50,IN,THICK);
  384.     iconpanel.show();
  385.     drawicon.init(280,170,"i1");
  386.     painticon.init(330,170,"i2");
  387.     drawicon.show();
  388.     painticon.show();
  389.     the_mouse.show();
  390.  
  391.     flushkeys();
  392.     int selected=0;
  393.     while(!selected) {
  394.         if(the_mouse.RBP())
  395.             selected=1;
  396.         if(kbhit()) {
  397.             if((ch=getch())==27)
  398.                 early_exit();
  399.             while(kbhit())getch();
  400.             selected=1;
  401.             }
  402.         if(the_mouse.LBP()) {
  403.             if(painticon.hit()) {
  404.                 if(!painticon.ispressed()) {
  405.                     painticon.choose();
  406.                     drawicon.show();
  407.                     while(the_mouse.LBP());
  408.                     continue;
  409.                     }
  410.                 }
  411.             if(drawicon.hit()) {
  412.                 if(!drawicon.ispressed()) {
  413.                     drawicon.choose();
  414.                     painticon.show();
  415.                     while(the_mouse.LBP());
  416.                     continue;
  417.                     }
  418.                 }
  419.             }
  420.         }
  421. }
  422.  
  423. //**************************************************************************
  424.  
  425. void acticondemo()
  426. {
  427.     the_mouse.hide();
  428.     setfillstyle(SOLID_FILL,BKG);
  429.     bar(0,0,getmaxx(),getmaxy()-40);
  430.  
  431.     Bevel mainpanel;
  432.     mainpanel.init(50,50,getmaxx()-100,300,THICK);
  433.     mainpanel.show();
  434.  
  435.     write3d(75,"Here's a neat graphic feature that you don't see everyday.");
  436.     write3d(90,"Want to really jazz up your interface? Want to make it stand");
  437.     write3d(105,"out in a crowd?! Instead of reversing the image of your icons");
  438.     write3d(120,"when they are selected, make them come to life! Click the icon");
  439.     write3d(135,"below to see what I mean.");
  440.     write3d(165,"And guess what... Right! These icons are also easy to create");
  441.     write3d(180,"using the ICONEDIT program");
  442.  
  443.     Panel iconpanel;
  444.     iconpanel.init(270,230,getmaxx()-(270*2),70,IN,THICK);
  445.     iconpanel.show();
  446.     Acticon aicon;
  447.     aicon.init(305,250,"i3");
  448.     aicon.show(1);
  449.     the_mouse.show();
  450.  
  451.     int selected=0;
  452.     while(!selected) {
  453.         if(the_mouse.RBP())
  454.             selected=1;
  455.         if(kbhit()) {
  456.             if((ch=getch())==27)
  457.                 early_exit();
  458.             while(kbhit())getch();
  459.             selected=1;
  460.             }
  461.         if(the_mouse.LBP()) {
  462.             if(aicon.hit()) {
  463.                 while(!the_mouse.RBP() && !kbhit())
  464.                     aicon.backforth(2);
  465.                 if(kbhit()) {
  466.                     flushkeys();
  467.                     selected=1;
  468.                     }
  469.                 if(the_mouse.RBP())
  470.                     selected=1;
  471.                 }
  472.             }
  473.         }
  474. }
  475.  
  476. //**************************************************************************
  477.  
  478. void gmenudemo()
  479. {
  480.     the_mouse.hide();
  481.     setfillstyle(SOLID_FILL,BKG);
  482.     bar(0,0,getmaxx(),getmaxy()-40);
  483.  
  484.     Bevel mainpanel;
  485.     mainpanel.init(30,50,getmaxx()-60,130,THICK);
  486.     mainpanel.show();
  487.  
  488.     write3d(75,"Do you need to include point and shoot type menu bars in your");
  489.     write3d(90,"applications? No problem! Using the ObjectEase library makes it a snap");
  490.     write3d(105,"for you to include graphic pulldown menus! See for yourself below.");
  491.     write3d(120,"You may want to note that the way these menus are implemented");
  492.     write3d(135,"requires you to keep the left mouse key pressed until you have made");
  493.     write3d(150,"your selection.");
  494.  
  495.     setfillstyle(SOLID_FILL,15);
  496.     bar(0,200,getmaxx(),210);
  497.     setfillstyle(SOLID_FILL,1);
  498.     bar(0,211,getmaxx(),350);
  499.  
  500.     Gmenubutton menubutton1;
  501.     Gmenubutton menubutton2;
  502.     gitemarray  itemarray1;
  503.     gitemarray  itemarray2;
  504.     Gmenu       gmenu1;
  505.     Gmenu       gmenu2;
  506.  
  507.     strcpy(itemarray1[1],"Item 1");
  508.     strcpy(itemarray1[2],"Item 2");
  509.     strcpy(itemarray1[3],"Item 3");
  510.     strcpy(itemarray1[4],"Item 4");
  511.  
  512.     strcpy(itemarray2[1],"Item 1");
  513.     strcpy(itemarray2[2],"Item 2");
  514.     strcpy(itemarray2[3],"Item 3");
  515.     strcpy(itemarray2[4],"Item 4");
  516.  
  517.     gmenu1.init(0,211,4,itemarray1);
  518.     gmenu2.init(100,211,4,itemarray2);
  519.  
  520.     menubutton1.init(0,200,0,15,15,0,"Menu 1");
  521.     menubutton2.init(100,200,0,15,15,0,"Menu 2");
  522.     menubutton1.show();
  523.     menubutton2.show();
  524.     the_mouse.show();
  525.  
  526.     int selected=0;
  527.     while(!selected) {
  528.         if(kbhit()) {
  529.             if((ch=getch())==27)
  530.                 early_exit();
  531.             flushkeys();
  532.             selected=1;
  533.             }
  534.         if(the_mouse.RBP())
  535.             selected=1;
  536.         if(the_mouse.LBP()) {
  537.             if(menubutton1.hit()) {
  538.                 menubutton1.press();
  539.                 gmenu1.show();
  540.                 gmenu1.hide();
  541.                 menubutton1.show();
  542.                 }
  543.             if(menubutton2.hit()) {
  544.                 menubutton2.press();
  545.                 gmenu2.show();
  546.                 gmenu2.hide();
  547.                 menubutton2.show();
  548.                 }
  549.             }
  550.         }
  551. }
  552.  
  553. //**************************************************************************
  554.  
  555. void inputdemo()
  556. {
  557.     the_mouse.hide();
  558.     setfillstyle(SOLID_FILL,BKG);
  559.     bar(0,0,getmaxx(),getmaxy()-40);
  560.  
  561.     Bevel mainpanel;
  562.     mainpanel.init(30,50,getmaxx()-60,150,THICK);
  563.     mainpanel.show();
  564.  
  565.     write3d(75,"Getting text input from a graphic based application used to be");
  566.     write3d(90,"a real hassle... NO MORE! The ObjectEase includes functions for");
  567.     write3d(105,"laying out text input fields, simulating the text cursor, and");
  568.     write3d(120,"handling the text strings input by the user. Now you can");
  569.     write3d(135,"capture graphic text input as easily as in text mode.");
  570.     write3d(150,"Try out the sample dialog below.");
  571.  
  572.     Panel dialogpanel;
  573.     dialogpanel.init(150,250,getmaxx()-300,85,IN,THICK);
  574.     dialogpanel.show();
  575.  
  576.     setcolor(15);
  577.     settextjustify(LEFT_TEXT,TOP_TEXT);
  578.     gprintxy(170,275,"First Name: ");
  579.     gprintxy(170,305,"Last Name:  ");
  580.  
  581.     Gstring fname;
  582.     Gstring lname;
  583.     fname.init(270,279,20,0);
  584.     lname.init(270,309,20,0);
  585.     fname.show();
  586.     lname.show();
  587.  
  588.     fname.get_input();
  589.     lname.get_input();
  590.  
  591.     write3d(400,"Press <ENTER> to continue...");
  592.  
  593.     flushkeys();
  594.     while(!the_mouse.RBP() && !kbhit());
  595.     if(kbhit()) {
  596.         if((ch=getch())==27)
  597.             early_exit();
  598.         flushkeys();
  599.         }
  600. }
  601.  
  602. //**************************************************************************
  603.  
  604. void check_radio_demo()
  605. {
  606.     int done=0;
  607.  
  608.     the_mouse.hide();
  609.     setfillstyle(SOLID_FILL,BKG);
  610.     bar(0,0,getmaxx(),getmaxy()-40);
  611.     Bevel title;
  612.     Panel main;
  613.  
  614.     title.init(10,10,getmaxx()-20,40,THICK);
  615.     title.show();
  616.     write3d(27,"Try out the Gcheckboxes and Gradios in the panel below...");
  617.  
  618.     main.init(50,80,getmaxx()-100,270,IN,THIN);
  619.     main.show();
  620.     the_mouse.show();
  621.     the_mouse.changeto(ARROW);
  622.  
  623.     Gcheckbox cb[5];
  624.     Gradio    gr[5];
  625.  
  626.     for(int i=0;i<5;i++) {
  627.         cb[i].init(150,100+(50*i),"Checkbox");
  628.         cb[i].show();
  629.         }
  630.  
  631.     for(i=0;i<5;i++) {
  632.         gr[i].init(400,100+(50*i),"Radio");
  633.         gr[i].show();
  634.         }
  635.  
  636.     flushkeys();
  637.     while(!the_mouse.RBP() && !done) {
  638.         if(kbhit()) {
  639.             char ch;
  640.             if((ch=getch())==13) {
  641.                 done=1;
  642.                 continue;
  643.                 }
  644.             else
  645.                 flushkeys();
  646.             }
  647.  
  648.         if(the_mouse.LBP()) {
  649.             for(i=0;i<5;i++) {
  650.                 if(cb[i].hit()) {
  651.                     if(cb[i].is_checked())
  652.                         cb[i].uncheck();
  653.                     else
  654.                         cb[i].check();
  655.                     while(the_mouse.LBP());
  656.                     }
  657.                 }//for
  658.             for(i=0;i<5;i++) {
  659.                 if(gr[i].hit()) {
  660.                     if(!gr[i].is_checked()) {
  661.                         for(int j=0;j<5;j++) {
  662.                             if(gr[j].is_checked()) {
  663.                                 gr[j].uncheck();
  664.                                 break;
  665.                                 }
  666.                             }
  667.                         gr[i].check();
  668.                         while(the_mouse.LBP());
  669.                         }
  670.                     }
  671.                 }//for
  672.             }//if LBP
  673.         }//WHILE
  674.     while(the_mouse.RBP());
  675. }
  676.  
  677. //**************************************************************************
  678.  
  679. void bitmapdemo()
  680. {
  681.     int lastx,lasty,x,y;
  682.     lastx=lasty=x,y=0;
  683.     int done=0;
  684.  
  685.     the_mouse.hide();
  686.     setfillstyle(SOLID_FILL,BKG);
  687.     bar(0,0,getmaxx(),getmaxy()-40);
  688.  
  689.     Bevel title;
  690.     title.init(10,10,getmaxx()-20,40,THICK);
  691.     title.show();
  692.     write3d(27,"Click the left mouse button on the ball and drag it around...");
  693.  
  694.     Panel main;
  695.     main.init(100,80,getmaxx()-200,200,IN,THIN);
  696.     main.show();
  697.     setfillstyle(SOLID_FILL,0);
  698.     bar(101,81,538,279);
  699.  
  700.     Bitmap ball;
  701.  
  702.     ball.init(200,150);
  703.     ball.load("c2.cut");
  704.  
  705.     ball.show_COPY();
  706.     the_mouse.show();
  707.     the_mouse.changeto(HAND);
  708.  
  709.     flushkeys();
  710.     while(!the_mouse.RBP() && !done) {
  711.         if(kbhit()) {
  712.             char ch;
  713.             if((ch=getch())==13) {
  714.                 done=1;
  715.                 continue;
  716.                 }
  717.             }
  718.  
  719.         if(the_mouse.LBP()) {
  720.             the_mouse.set_hor_bounds(121,520);
  721.             the_mouse.set_ver_bounds(101,260);
  722.             if(ball.hit()) {
  723.                 while(the_mouse.LBP()) {
  724.                     x=the_mouse.mx();
  725.                     y=the_mouse.my();
  726.                     if(x!=lastx || y!=lasty) {
  727.                         ball.moveto(x-20,y-20);
  728.                         lastx=x;
  729.                         lasty=y;
  730.                         }
  731.                     }
  732.                 the_mouse.set_hor_bounds(0,getmaxx());
  733.                 the_mouse.set_ver_bounds(0,getmaxy());
  734.                 }
  735.             }
  736.         }
  737.     while(the_mouse.RBP());
  738.     ball.show_XOR();
  739.     the_mouse.changeto(ARROW);
  740. }
  741.  
  742.  
  743.  
  744. void write3d(int y,char *text)
  745. {
  746.     settextjustify(CENTER_TEXT,TOP_TEXT);
  747.     setcolor(0);
  748.     outtextxy(getmaxx()/2,y,text);
  749.     setcolor(15);
  750.     outtextxy((getmaxx()/2)-1,y-1,text);
  751. }
  752.  
  753. //**************************************************************************
  754.  
  755. void do_siren()
  756. {
  757.     int i;
  758.  
  759.     for(i=500;i<1000;i+=7) {
  760.         sound(i);
  761.         delay(12);
  762.         }
  763.     for(i=1000;i>500;i-=7) {
  764.         sound(i);
  765.         delay(12);
  766.         }
  767.     nosound();
  768. }
  769.  
  770. //**************************************************************************
  771.  
  772. void do_tele()
  773. {
  774.     int i;
  775.  
  776.     for(i=0;i<14;i++) {
  777.         sound(440);
  778.         delay(30);
  779.         sound(880);
  780.         delay(30);
  781.         }
  782.     nosound();
  783. }
  784.  
  785. //**************************************************************************
  786.  
  787. void early_exit()
  788. {
  789.     closegraph();
  790.     puts("You have not seen the entire demonstration.");
  791.     exit(0);
  792. }