home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / LVSWIN31.ZIP / DEMO.CPP next >
Text File  |  1992-02-21  |  28KB  |  959 lines

  1. /*
  2.  *            LVS Windows
  3.  *      The Window Class System
  4.  *
  5.  *        Copyright 1991, 1992 (c), Lake View Software
  6.  *                                  4321 Harborough Rd.
  7.  *                                  Columbus, OH 43220
  8.  *        All rights reserved.
  9.  *
  10.  * DEMO.CPP
  11.  */
  12.  
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <time.h>
  16. #include <dos.h>
  17. #ifdef __TURBOC__
  18.     #include <alloc.h>
  19. #else
  20.     /*
  21.      * Zortech
  22.      */
  23.     #define random(num)     (int)(((long)rand()*(num))/(0x7FFFU + 1))
  24.     #define delay           usleep
  25.     #define coreleft        farcoreleft
  26. #endif
  27. #include <conio.h>
  28. #include <ctype.h>
  29. #include <stdio.h>
  30. #include "LVSwin.HPP"       // LVS Windows main header
  31. #include "LVS_prn.hpp"        // printer class
  32. #include "LVSmenu.hpp"      // Menu class header file
  33. #include "LVSpick.HPP"
  34.  
  35. // extern unsigned _stklen = 10000;   // makes no difference.
  36.  
  37. /*
  38.  * Declare internal functions
  39.  */
  40.  
  41. int v_socialsecurity(void *num) ;
  42. void rand_open (WinObj &w), show_time (), move_windows (struct time t),
  43.      data_entry (), paradox_entry (), moving_windows (),
  44.      random_windows (), scroll_demo (), scroll_window (),
  45.      menu_demo (), menu_demo2 (), pick_demo (), help (),
  46.      logo ();
  47. void Parse_Command_Line (int argc, char **argv);
  48.  
  49. /*
  50.  * Some global data
  51.  */
  52. int VGA = 0;                // has vga flag
  53. int Use_VGA = 1;            // try to use vga graphics/colors by default
  54. int mouse_mode = M_FULL;    // Default mouse mode
  55.  
  56. void main (int argc, char **argv)
  57. {
  58.  
  59.     Parse_Command_Line (argc, argv);
  60.  
  61.     // Turn clock on
  62.     Win_setbkloop (show_time);          // Set background keyboard loop
  63.                                         // This will run the clock and move
  64.                                         // the global windows
  65.  
  66.     Win_setonkey (F1,help);             // Set F1 to function help
  67.     Win_setonkey (F10, Win_Calculator);
  68.     Win_setonkey (F5, Win_Calendar);
  69.  
  70.     /*
  71.      * If desqview is present this will allow LVS to give time
  72.      * back when waiting for user input
  73.      */
  74.     Win_DesqView_Aware ();
  75.  
  76.     /*
  77.      * Display the logo & open the main screen
  78.      */
  79.     logo ();
  80.  
  81.     /*
  82.      * Open the main menu
  83.      */
  84.     WinMenu m;                                      // create Main menu object
  85.  
  86.     int bkground_color = _RED;
  87.  
  88.     if (VGA)
  89.         bkground_color = _LBLUE;
  90.  
  91.     m.open (4, 26, 15, 52, W_DOUSIN, bkground_color|WHITE, 
  92.             bkground_color|BLACK);             // Open the window
  93.     m.shadow ();                               // make a shadow for the window
  94.     m.set_keyattr (bkground_color|YELLOW);     // change the hot key attribute
  95.  
  96.     bkground_color = _LGREY;
  97.     if (VGA)
  98.         bkground_color = _WHITE;
  99.     m.title (" Demo Menu ");                 // Give the window a title
  100.  
  101.     /*
  102.      * Define the menu selections
  103.      */
  104.     m.prompt (1, 2, 1, " 1. Data entry       ", "", '1');
  105.     m.prompt (2, 2, 2, " 2. Moving windows   ", "", '2');
  106.     m.prompt (3, 2, 3, " 3. Random windows   ", "", '3');
  107.     m.prompt (4, 2, 4, " 4. Lotus style menu ", "", '4');
  108.     m.prompt (5, 2, 5, " 5. Pick-List demo   ", "", '5');
  109.     m.prompt (6, 2, 6, " 6. Scrolling demo   ", "", '6');
  110.     #ifdef __TURBOC__
  111.         m.prompt (7, 2, 7, " 7. Paradox entry    ", "", '7');
  112.     #else
  113.         m.printf (7, 2, " 7. Paradox entry    ");
  114.     #endif
  115.     m.prompt (8, 2, 0, " 0. Quit             ", "", '0');
  116.  
  117.     /*
  118.      * Init the mouse driver
  119.      */
  120.  
  121.     Win_mouse_mode (mouse_mode);
  122.  
  123.     
  124.     int choice = 1;                 // start with menu selection ret_val = 1
  125.  
  126.     while (choice != 0) 
  127.         {                           // loop till Quit is selected
  128.  
  129.         choice = m.read (choice);   // get menu selection from user
  130.  
  131.         switch (choice) 
  132.             {
  133.             case 1: 
  134.                 data_entry ();
  135.                 break;
  136.             case 2: 
  137.                 moving_windows ();
  138.                 break;
  139.             case 3: 
  140.                 random_windows ();
  141.                 break;
  142.             case 4: 
  143.                 m.hide ();
  144.                 menu_demo ();
  145.                 break;
  146.             case 5: 
  147.                 pick_demo ();
  148.                 break;
  149.             case 6: 
  150.                 scroll_demo ();
  151.                 break;
  152.             case 7:
  153.                 #ifdef __TURBOC__
  154.                     paradox_entry ();
  155.                 #endif
  156.                 break;
  157.             }
  158.         }
  159.  
  160.     // all windows will close automatically with there destructors
  161. }
  162.  
  163. void Parse_Command_Line (int argc, char **argv)
  164. {
  165.     int arg = 0;
  166.  
  167.     while (++arg < argc) 
  168.         {
  169.         if (argv[arg][0] == '-' || argv[arg][0] == '/') 
  170.             {
  171.             switch (toupper (argv[arg][1])) 
  172.                 {
  173.                 case 'B': 
  174.                     Win_bios(W_ON);     // Turn on use of bios writes
  175.                     break;
  176.  
  177.                 case 'S': 
  178.                     Win_snow(W_ON);     // Turn on use of snow suppression
  179.                     break;
  180.  
  181.                 case 'M': 
  182.                     switch (toupper (argv[arg][2]))
  183.                         {
  184.                         case 'N':                 // Mouse off
  185.                             mouse_mode = M_NONE;
  186.                             break;
  187.  
  188.                         case 'S':                 // Mouse full support
  189.                             mouse_mode = M_SIMPLE;
  190.                             break;
  191.  
  192.                         default:
  193.                             Win_mono(W_ON);     // Force black & white only
  194.                             break;
  195.                         }
  196.                         break;
  197.                 case '5': 
  198.                     VGA_setlines (50);
  199.                     break;
  200.                 case '4':
  201.                     VGA_setlines (43);
  202.                     break;
  203.                 case '2':
  204.                     VGA_setlines (28);
  205.                     break;
  206.                 case 'V':
  207.                     Use_VGA = 0;
  208.                     break;
  209.                 }  // switch
  210.             }  // if argv[0]
  211.         }   // while
  212. }
  213.  
  214. //*********************Pick-List Demo************************
  215.  
  216. static char *list[] = { "January",   "February",
  217.                         "March",     "April",
  218.                         "May",       "June",
  219.                         "July",      "August",
  220.                         "September", "October",
  221.                         "November",  "December",  0 };
  222.  
  223. void pick_demo()
  224. {
  225.     WinPick pl;
  226.  
  227.     int bk = _BLUE;
  228.     if (VGA)
  229.         bk = _DGREY;
  230.  
  231.     pl.open (3, 33, 9, 45, W_DOUSIN, bk|WHITE, bk|GREEN);  // open pick window
  232.     pl.shadow();
  233.     pl.title ("Pick-List");
  234.     pl.prompt (list);           // assign a list
  235.     int choice = pl.read();     // get user selection, closes window when finished
  236.  
  237.     // Display the results of the pick.
  238.     if (choice != W_ESCAPE) 
  239.         {
  240.         WinObj w;
  241.         w.open (6, 23, 11, 53, W_DOUSIN, bk|GREEN, bk|WHITE);
  242.         w.title (" Answer ");
  243.         w.shadow ();
  244.         w.printf (1, 1, "You picked ");
  245.         w.set_attr (bk|YELLOW);
  246.         w.printf ("%s.", list[choice]);
  247.         w.set_attr (bk|LGREY);
  248.         w.printf (3, 1, "Press any key to continue.");
  249.         w.get_key ();
  250.         }
  251. }
  252.  
  253. //**********************Menu Demo****************************
  254. // First level of a lotus style menu
  255. void menu_demo ()
  256. {
  257.     WinMenu m;                                      // Create a menu object
  258.     m.open (1, 0, 1, 79, W_NOBORDER, _BLUE|WHITE);  // init the window
  259.     m.message_line (2);                             // Set message line to 2
  260.     m.set_keyattr (_BLUE|YELLOW);                   // hot key attribute
  261.     m.set_barattr (_RED|WHITE);                     // make bar white on red
  262.  
  263.     // Declare some menu selections
  264.     m.prompt (0,  0, 1, " Worksheet ", "Global, Column, Status, Delete", 'W');
  265.     m.prompt (0, 12, 2, " Range ", "Format, Label, Erase, Name, Justify, Prot", 'R');
  266.     m.prompt (0, 20, 3, " Copy ",  "Copy a cell or range of cells", 'C');
  267.     m.prompt (0, 27, 4, " mOve ",  "Move a cell or range of cells", 'O');
  268.     m.prompt (0, 34, 5, " File ",  "Retrieve, Save, Combine, Xtract...", 'F');
  269.     m.prompt (0, 41, 6, " Print ", "Print a worksheet to a printer or file", 'P');
  270.     m.prompt (0, 49, 0, " Quit ",  "Quit the menu demo", 'Q');
  271.                     
  272.     int choice=1;
  273.     while (choice != 0) 
  274.         {
  275.         choice = m.read(choice);        // Get a menu selection
  276.         if (choice == W_ESCAPE)
  277.             break;
  278.         switch (choice) 
  279.             {
  280.             case 1:
  281.                 menu_demo2();           // Goto next menu level
  282.                 break;
  283.             case 2:
  284.                 break;
  285.             }
  286.         }
  287.     // Menu object will destruct and close automatically.
  288. }
  289.  
  290. void menu_demo2()       // Second level of a lotus style menu
  291. {
  292.     WinMenu m;
  293.     m.open (1, 0, 1, 79, W_NOBORDER, _BLUE|WHITE);
  294.     m.message_line (2);                             // Set message line to 1
  295.     m.set_keyattr (_BLUE|YELLOW);                   // make hot key yellow
  296.     m.set_barattr (_RED|WHITE);                     // make bar white on red
  297.  
  298.     m.prompt (0,  0, 1, " Global ", "Global functions", 'G');
  299.     m.prompt (0,  9, 2, " Column ", "Delete, Insert", 'C');
  300.     m.prompt (0, 18, 3, " Status ", "Display worksheet status", 'S');
  301.     m.prompt (0, 27, 4, " Delete ", "Delete the entire worksheet", 'D');
  302.     m.prompt (0, 36, 5, " sYstem ", "Shell to DOS", 'Y');
  303.     m.prompt (0, 45, 0, " Quit ", "Quit to the main menu", 'Q');
  304.     int choice=1;
  305.     while (choice != 0) 
  306.         {
  307.         choice = m.read(choice);
  308.         if (choice == W_ESCAPE)
  309.             break;
  310.  
  311.         switch (choice) 
  312.             {
  313.             case 1:
  314.                 break;
  315.             case 2:
  316.                 break;
  317.             case 5:
  318.                 Win_clrscr ();
  319.                 puts ("Type 'EXIT' to return to demo.\n\n\n");
  320.                 system ("");
  321.                 m.update_all ();
  322.                 break;
  323.             }
  324.         }
  325. }
  326.  
  327. //*************************Moving windows Demo*************************
  328. WinObj Global_Win[2];   // Some global window objects to move
  329.  
  330. void moving_windows()
  331. /*
  332.  * Open the moving windows
  333.  */
  334. {
  335.     // Windows will open or close with each call
  336.     if (!Global_Win[0].is_open()) 
  337.         {
  338.         Global_Win[0].open (1, 1, 10, 25, W_DOUBLE, _MAGENTA|BLACK, _MAGENTA|BLUE);
  339.         Global_Win[0].shadow ();
  340.         Global_Win[0].title (" Moving Window 1 ");
  341.         Global_Win[0] << "Here is some text in a moving window.";
  342.  
  343.         Global_Win[1].open (1, 54, 10, 79, W_DOUSIN, _GREEN|BLACK, _GREEN|WHITE);
  344.         Global_Win[1].shadow ();
  345.         Global_Win[1].title (" Moving Window 2 ");
  346.         Global_Win[1] << "Here is some text in the second moving window.";
  347.         }
  348.     else 
  349.         {
  350.         Global_Win[0].close ();
  351.         Global_Win[1].close ();
  352.         }
  353. }
  354.  
  355. // Function to move the random windows every second
  356. // This function is called by the clock function with the current time
  357. void move_windows (struct Win_time_s t)
  358. {
  359.     static int x = 1, y = 1, sec_hold = 0;
  360.  
  361.     if (!Global_Win[0].is_open())
  362.         return;
  363.  
  364.     if (sec_hold != t.sec)       // only move once a second
  365.         {
  366.         sec_hold = t.sec;
  367.         x += 6;
  368.         y += 2;
  369.         if ( x > 60 || y > 18)
  370.             {
  371.             x = 0;
  372.             y = 0;
  373.             }
  374.         Global_Win[0].move (y, x);
  375.  
  376.         // randomly move the second window
  377.         Global_Win[1].move (random(Win_Max_y () - 11), random(54));
  378.         }
  379. }
  380.  
  381. //***********************Scroll Demo**********************************
  382. WinObj Scroll;            // Scrolling text demo window object
  383. WinObj Scroll2;
  384.  
  385. void scroll_demo ()
  386. {
  387.     // Open window once the first time
  388.     if (!Scroll.is_open()) 
  389.         {
  390.         int bkground = _CYAN;
  391.         if (VGA)
  392.             bkground = _LCYAN;
  393.  
  394.         Scroll.hide ();         // open the window hidden
  395.         Scroll.open (2, 56, 8, 78, W_DOUSIN, bkground|BLACK, bkground|BLUE);
  396.         Scroll.shadow ();
  397.         Scroll.title (" Slow Scroll ");
  398.  
  399.         if (VGA)
  400.             bkground = _YELLOW;
  401.         else
  402.             bkground = _BLUE;
  403.  
  404.         Scroll2.hide ();
  405.         Scroll2.open (11, 56, 16, 78, W_DOUSIN, bkground|RED, bkground|BLACK);
  406.         Scroll2.shadow ();
  407.         Scroll2.title (" Fast Scroll ");
  408.         }
  409.  
  410.     /*
  411.      * Now just hide or unhide the windows
  412.      */
  413.     static int hidden = 1;
  414.  
  415.     if (hidden)
  416.         {
  417.         Scroll.unhide ();
  418.         Scroll2.unhide ();
  419.         hidden = 0;
  420.         }
  421.     else
  422.         {
  423.         Scroll.hide ();
  424.         Scroll2.hide ();
  425.         hidden = 1;
  426.         }
  427. }
  428.  
  429. void random_message (WinObj &w)
  430. /*
  431.  * All the print messages here accomplish the same results,
  432.  * a cr/lf followed by some text.
  433.  */
  434. {
  435.     switch (random (6))
  436.         {
  437.     case 0:
  438.         w << '\n' << ' ' << w.get_version();
  439.         break;
  440.     case 1:
  441.         w << '\n' << " Lake View Software";
  442.         break;
  443.     case 2:
  444.         w << '\n' << " Borland C++ v2.0";
  445.         break;
  446.     case 3:
  447.         w << "\n Turbo C++ v1.01";
  448.         break;
  449.     case 4:
  450.         w.printf ("\n Support Shareware");
  451.         break;
  452.     default:
  453.         w.puts ("\n Some Scrolling Text");
  454.         break;
  455.     }
  456. }
  457.  
  458. void scroll_window ()
  459. {
  460.     if (!Scroll.is_open())
  461.         return;
  462.  
  463.        static clock_t clock1 = 0, clock2 = 0;
  464.  
  465.     if ((clock1 + 5) < clock () )
  466.         {
  467.         random_message (Scroll);
  468.         clock1 = clock ();
  469.         }
  470.  
  471.     if ((clock2+1) < clock ())
  472.         {
  473.         random_message (Scroll2);    // Fast scroll
  474.         clock2 = clock ();
  475.         }
  476. }
  477.  
  478. //**********************Random Windows Demo***************************
  479.  
  480. void random_windows ()
  481. {
  482.     WinObj w[5];
  483.  
  484.     for (int i = 0; i < 5; i++)
  485.         {
  486.         rand_open (w[i]);
  487.         delay (250);
  488.         }
  489.     w[0].clr_win ();
  490.     w[0] << "Press any key to continue.";
  491.     w[0].get_key (0, 10);    // wait 10 seconds for a key
  492. }
  493.  
  494. // Function to open random windows on the screen
  495. void rand_open (WinObj &w)
  496. {
  497.     static cnt = 0;
  498.     int sr, er, sc, ec;
  499.     int color, bcolor, btype;
  500.  
  501.     sr = random (Win_Max_y () - 14);
  502.     sc = random (40);
  503.     er = sr + 10 + random ((Win_Max_y () - 14)-sr);
  504.     ec = sc + 15 + random (63-sc);
  505.  
  506.     int bk_colors = 8;
  507.     if (VGA)
  508.         bk_colors = 16;
  509.  
  510.     color = random (bk_colors) * 16 + random (16);
  511.     bcolor = random (bk_colors) * 16 + random (16);
  512.     btype = random (MAX_BOX_TYPE + 1);
  513.     w.open (sr, sc, er, ec, btype, color, bcolor);
  514.     w.shadow ();
  515.     w.title (" Random Window ");
  516.     w << "This is random window #(" << ++cnt << ")";
  517. }
  518.  
  519. //************************Data Entry Demo********************************
  520.  
  521. void paint_data_screen (WinObj &w)
  522. /*
  523.  * Paint the data entry screen
  524.  */
  525. {
  526.     w.puts (0, 29, "Compiler");
  527.     w.puts (6, 2, "First letter upper:");
  528.     w.puts (7, 4, "Force upper case:");
  529.     w.puts (8, 1, "Picture (\"A9A 9A9\"):");
  530.     w.puts (9, 9, "Phone style:");
  531.     w.puts (10, 10, "SS # style:");
  532.     w.puts (11, 5, "Zip code style:");
  533.     w.puts (12, 9, "Date style:");
  534.     w.puts (13, 6, "Double (10,2):");
  535.     w.puts (14, 11, "Long (5):");
  536.     w.puts (15, 16, "Int:");
  537.     w.puts (16, 8, "Single char:");
  538. }
  539.  
  540. int button_press (int value)
  541. /*
  542.  * Routine to call when the press a button in the data entry screen
  543.  */
  544. {
  545.     int return_value = 0;
  546.  
  547.     switch (value)
  548.         {
  549.         case 1:                     /* 'Ok' Button Pressed */
  550.             return_value = PGDN;    /* Normal data entry exit */
  551.             break;
  552.  
  553.         case 2:                     /* 'Cancel' Button Pressed */
  554.             return_value = ESC;     /* Data entry quit */
  555.             break;  
  556.         }
  557.  
  558.     return return_value;
  559. }
  560.  
  561. int read_data (WinObj &w)
  562. /* 
  563.  * read data for data_entry or print for print_data
  564.  */
  565. {
  566.     static char
  567.         first[40] = "",
  568.         upper[20] = "",
  569.         picture[8] = "",
  570.         phone[15] = "",
  571.         ss[12] = "",
  572.         zip[15] = "",
  573.         date[9] = "";
  574.  
  575.     static double
  576.         d = 0.0;
  577.  
  578.     static long
  579.         l = 0;
  580.  
  581.     static int
  582.         i = 0;
  583.  
  584.     static char
  585.         ch = ' ';
  586.  
  587.     static 
  588.         comp_selected = 0;
  589.  
  590.     char
  591.         *compiler_radio[] = {"Borland C++ v3.0", "Borland C++ v2.0",
  592.                              "Turbo C++ v1.0", "Zortech C++ v3.0"};
  593.  
  594.     /*
  595.      * Draw/fill a box and get a radio group
  596.      */
  597.     int old_attr = w.set_attr (_CYAN|BLACK);
  598.     w.set_getattr (_CYAN|WHITE);
  599.     w.box (1, 22, 4, 50, W_SPACES, 1);
  600.     w.get_radio (1, 25, compiler_radio, comp_selected, 4);
  601.     w.set_attr (old_attr);
  602.  
  603.     /*
  604.      * Get some regular gets
  605.      */
  606.     w.set_getattr (_LGREY|BLACK);
  607.     w.get (6 , 22, first, 'F', sizeof(first) - 1);  // upper case first letters
  608.     w.get (7 , 22, upper, 'U', sizeof(upper) -1);   // upper case all letters
  609.     w.get (8 , 22, picture, "A9A 9A9");             // Canadian zip code using picture
  610.     w.get (9 , 22, phone, 'P');                     // phone number style
  611.     w.get (10 , 22, ss, 'S');                       // social security style
  612.         w.valid (v_socialsecurity);                 // validate the ss number
  613.     w.get (11, 22, zip, 'Z');                       // US zip code style
  614.     w.get (12, 22, date, 'D');                      // date style
  615.     w.get (13, 22, d, 10, 3);                       // double 10 long with 3 decimal places
  616.     w.get (14, 22, l, 5);                           // long 5 digits in length
  617.     w.get (15, 22, i);                              // integer at default length
  618.     w.get (16, 22, ch);                             // single character get
  619.  
  620.     /*
  621.      * Get some buttons
  622.      */
  623.     w.set_getattr (_BLACK|GREEN);
  624.     w.get_button (1, 60, "   Ok   ", button_press, 1);
  625.     w.get_button (3, 60, " Cancel ", button_press, 2);
  626.  
  627.     /*
  628.      * Prompt the user for the input and return the results
  629.      */
  630.     return (w.read ());
  631. }
  632.  
  633. void print_data ()
  634. {
  635.     if (!Win_Get_YN ("Printer ready"))
  636.         return;
  637.     
  638.     Win_Prn p;
  639.     if (p.open () != W_OK)
  640.         {
  641.         Win_Error ("Can't open printer port!");
  642.         return;
  643.         }
  644.  
  645.     paint_data_screen (p);        // Paint the screen in memory
  646.     read_data (p);                // Paint the gets in memory
  647.  
  648.     //
  649.     // Now lets change some of the print attributes.
  650.     // These normaly would could be set before each printf or puts...
  651.     // but since I used the same routines to print the screen and the
  652.     // page this is being done later.
  653.     //
  654.     p.set_pageattr (P_NORMAL);    // Set attributes for the entire page
  655.     p.set_attr (P_UNDERLINE, 1, 14, 15);    // Underline the last name
  656.  
  657.     p.print_page ();            // Print physical page
  658.  
  659.     p.close ();                    // could let close with distructor
  660. }
  661.  
  662. void data_entry()
  663. {
  664.     WinObj  w(40,75);                   // Create the main entry window
  665.     w.open (3, 4, 18, 75, W_DOUBLE, _BLUE|WHITE, _BLUE|YELLOW);
  666.     w.shadow ();
  667.     w.title(" Data Entry ");
  668.  
  669.     paint_data_screen (w);                // Paint the screen
  670.  
  671.     if (read_data (w) != ESC)            // Get the data
  672.         if (Win_Get_YN ("Do you wish to print the data"))
  673.             print_data ();
  674. }
  675.  
  676. int v_socialsecurity(void *num) 
  677. /*
  678.  * Valid function for ss number
  679.  */
  680. {
  681.     char *ss = (char *) num;
  682.     if (strchr (ss, ' '))
  683.         {
  684.         Win_Error ("No spaces in SS number!");
  685.         return 0;       // fail valid, make user correct this get
  686.         }
  687.  
  688.     return 1;  // pass valid
  689. }
  690.  
  691. //*************************Paradox Entry*********************************
  692. #ifdef __TURBOC__
  693. char *Text[] = {
  694.     "Entering text in a Paradox Table is one of the many features of LVS",
  695.     "Windows.  It allows you to enter directly into the Paradox record",
  696.     "buffer, with no temporary variables.",
  697.     "",
  698.     "I'd like to show you how to enter text in a Paradox Table using LVS",
  699.     "Windows, but I would have to write this in the large model and I've",
  700.     "only supplied the small model here.  So here's what the code would",
  701.     "look like.",
  702.     "",
  703.     "To view the code use the Up and Down arrows keys.",
  704.     "                   Esc to exit",
  705.     "",
  706.     "",
  707.     "#include <pxengine.h>",
  708.     "#include <LVSwin.hpp>",
  709.     "",
  710.     "main ()  {",
  711.     "   TABLEHANDLE TblHandle;",
  712.     "   RECORDHANDLE RecHandle;",
  713.     "",
  714.     "   PXInit ();                              // Init the PX engine",
  715.     "   PXTblOpen (\"SALES\", &TblHandle, 0, 0);  // Open the table",
  716.     "   PXRecBufOpen (TblHandle, &RecHandle);   // Open a record buffer",
  717.     "   PXRecFirst (TblHandle);                 // Point to the first record",
  718.     "   PXRecGet (TblHandle, RecHandle);        // Read the record.",
  719.     "",
  720.     "   WinObj w;                               // my window object",
  721.     "   w.open (0, 0, 24, 79);                  // Open the window",
  722.     "   w.PXrecord (TblHandle, RecHandle);      // give winobj the PX info",
  723.     "   w.PXget (1, 1, 1, 'F');                 // Get the first field, style 'F'",
  724.     "   w.PXget (3, 1, 2, 'F');",
  725.     "   w.PXget (5, 1, 11, 'P');                // Get the 11 field, style Phone",
  726.     "   w.PXget (7, 1, 17, 10, 2);",
  727.     "   w.PXget (9, 1, 18, 3, 0);",
  728.     "   w.PXread ();                            // Read the user input",
  729.     "   PXRecUpdate (TblHandle, RecHandle);     // update the PX record",
  730.     "   PXExit ();                              // Stop the PX engine",
  731.     "}",
  732.     "",
  733.     "",
  734.     "Paradox in a Trademark of Borland",
  735.     0 };
  736.  
  737. void paradox_entry ()
  738. {
  739.     WinObj w (43, 78);
  740.  
  741.     w.open (1, 0, 23, 79, W_SINGLE, _BLUE|WHITE, _BLUE|CYAN);
  742.     w.title (" Paradox Entry ");
  743.     int i = -1;
  744.     while (Text [++i])
  745.         w.puts (i+1, 2, Text [i]);
  746.  
  747.     w.gotoxy ();
  748.  
  749.     int key = 0;
  750.     do {
  751.         key = w.get_key (0, 60);      // wait 1 minute for a key press
  752.  
  753.         switch (key)
  754.             {
  755.             case UP:
  756.                 w.gotoxy (w.wherey () - 1, w.wherex ());
  757.                 break;
  758.             case DOWN:
  759.                 if (w.wherey () < w.max_y ())
  760.                     w.gotoxy (w.wherey () + 1, w.wherex ());
  761.                 break;
  762.             case LEFT:
  763.                 w.gotoxy (w.wherey (), w.wherex () - 1);
  764.                 break;
  765.             case RIGHT:
  766.                 w.gotoxy (w.wherey (), w.wherex () + 1);
  767.                 break;
  768.             }
  769.  
  770.         } while (key && (key != ESC));
  771. }
  772. #endif
  773.  
  774. //**************************Clock function*******************************
  775.  
  776. static WinObj clock_win;        // create a static window object
  777.  
  778. void show_time ()                   // Show time in upper left corner of screen
  779. {
  780.     static struct Win_time_s t;
  781.     static unsigned char hold;
  782.  
  783.     if (!clock_win.is_open())       // open small clock window once
  784.         {
  785.         int color = _LGREY|BLUE;
  786.         if (VGA)
  787.             color = _WHITE|BLUE;
  788.             
  789.         clock_win.open (0, 0, 0, 79, W_NOBORDER, color);
  790.         clock_win.center (0, "Lake View Software");
  791.         }
  792.  
  793.     /*
  794.      * First show the clock
  795.      */
  796.     Win_gettime (&t);
  797.  
  798.     if (hold != t.sec) 
  799.         {
  800.         hold = t.sec;
  801.         clock_win.printf (0, 1, "%02d:%02d:%02d", t.hour, t.min, t.sec);
  802.         #ifndef DOS386
  803.         clock_win.printf (0, 73, "%6ld", (long )coreleft ());  // show free mem
  804.         #endif
  805.         }
  806.  
  807.     /*
  808.      * Move the random windows
  809.      */
  810.     move_windows (t);
  811.  
  812.     /*
  813.      * scroll text in window
  814.      */
  815.     scroll_window ();
  816.  
  817. }
  818.  
  819. //**********************Help Function***********************************
  820. void help()
  821. {
  822.     static int is_active=0;
  823.     int old_x, old_y;
  824.  
  825.     if (is_active++)
  826.         return;
  827.  
  828.     /*
  829.      * Save current cursor position
  830.      */
  831.     Win_getxy (&old_y, &old_x);
  832.  
  833.     WinObj help;
  834.  
  835.     int bkground = _LGREY;
  836.     if (VGA)
  837.         bkground = _LBLUE;
  838.  
  839.     help.open (2, 11, 22, 67, W_SINGLE, bkground|BLACK, bkground|WHITE);
  840.     help.shadow ();
  841.     help.title (" Help Window ");
  842.     help.center (1, "Data Entry Keys");
  843.     help.gotoxy (3, 1) << "/ arrows        Move cursor to next/prev field.";
  844.     help.printf (4, 1, "%c/%c arrows        Move cursor to next/prev column.",26,27);
  845.     help.printf (5, 1, "Crtl_%c/%c          Move cursor to next/prev word.", 26, 27);
  846.     help.puts (6, 1, "Ctrl_R/L arrows   Pan window right/left one column.");
  847.     help.puts (7, 1, "Ctrl_D/U          Pan window down/up one row.");
  848.     help.puts (8, 1, "PgDn              Exit read mode.");
  849.     help.puts (9, 1, "Esc               Quit read mode.");
  850.     int hold_attr = help.set_attr (bkground|WHITE);
  851.     help.center (11, "Non Picture Gets Only");
  852.     help.set_attr (hold_attr);
  853.     help.puts (12, 1, "Insert            Toggle insert/overtype mode.");
  854.     help.puts (13, 1, "Delete            Delete character under cursor.");
  855.     help.puts (14, 1, "Backspace         Delete previous character.");
  856.     hold_attr = help.set_attr (bkground|RED);
  857.     help.center (17, "Copyright (c) 1992, Lake View Software");
  858.     help.set_attr (hold_attr);
  859.     help.center (18, "Press any key to exit.");
  860.     Win_getkey (15);                    // wait 15 seconds for a key 
  861.  
  862.     Win_gotoxy (old_y, old_x);          // Restore cursor position
  863.     is_active = 0;                      // turn off active flag
  864. }
  865.  
  866.  
  867. //*****************************Logo*****************************************
  868.  
  869. void function_key_mouse_routine (int y, int x)
  870. /*
  871.  * Check mouse clicks for function keys
  872.  * This routine will be attached to the footer
  873.  * window.
  874.  */
  875. {
  876.     if (y != 0)
  877.         return;
  878.  
  879.     if (x >=21 && x <= 27)
  880.         Win_keystuf (F1);
  881.  
  882.     if (x >= 30 && x <= 40)
  883.         Win_keystuf (F5);
  884.  
  885.     if (x >= 43 && x <= 56)
  886.         Win_keystuf (F10);
  887. }
  888.  
  889. static WinObj Main;         // the main screen window
  890. static WinObj Footer;       // window for the footer
  891. static WinObj logo_w;         // window for our logo
  892.  
  893. void logo ()
  894. {
  895.     int max_y = Win_Max_y ();           // Get the max y coordinate
  896.  
  897.     if (Use_VGA)
  898.         {
  899.         if (VGA_videotype () == V_VGA)
  900.             {
  901.             /*
  902.              * Turn blink off to allow highlight backgrounds
  903.              */
  904.             VGA_setblink (W_OFF);
  905.  
  906.             /*
  907.              * load special fonts
  908.              */
  909.  
  910.             VGA_fontload ();
  911.  
  912.             VGA++;      // set vga flag
  913.             }
  914.         }
  915.  
  916.     /*
  917.      * Open a window to cover the screen
  918.      */
  919.     int bkground = _BLACK;
  920.     if (VGA)
  921.         bkground = _DGREY;
  922.     Main.open (0, 0, max_y, 79, W_NOBORDER, bkground|LGREY);
  923.  
  924.     for (int x = 0; x < max_y * 2 + max_y / 5; x++)
  925.         Main.printf ("- LVS Windows -- Lake View Software -");
  926.     
  927.  
  928.     /*
  929.      * Display the footer
  930.      */
  931.     int color = _LGREY|BLACK;
  932.     if (VGA)
  933.         color = _WHITE|BLACK;
  934.  
  935.     Footer.open (max_y, 0, max_y, 79, W_NOBORDER, color);
  936.     Footer.puts (0, 21, "F1=Help, F5=Calendar, F10=Calculator");
  937.     Footer.set_mouseroutine (function_key_mouse_routine);
  938.  
  939.     /*
  940.      * Display the logo
  941.      */
  942.     color = _BLACK;
  943.     if (VGA)
  944.         color = _DGREY;
  945.  
  946.     logo_w.open (max_y - 5, 19, max_y - 2, 59, W_DOUSIN, 
  947.                color|WHITE, color|YELLOW);
  948.     logo_w.shadow ();
  949.  
  950.     logo_w.title (logo_w.get_version ());
  951.     logo_w.center (0, "The C++ window class system");
  952.     logo_w.center (1,"Copyright (c) 1992");
  953.  
  954.     // start random number generator
  955.     srand (1);
  956.  
  957.     show_time ();   // displays the title bar and time for the first time
  958. }
  959.