home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRO1.ZIP / DEMO.C next >
Text File  |  1988-12-23  |  41KB  |  1,545 lines

  1. /* Comments are sparse.  Use TUTOR1.C -> TUTOR5.C to get started */
  2.  
  3. #include "pro.h"
  4. #include "xglobals.h"
  5. #include "vs.h"
  6. #include "colors.h"
  7. #include "mouse.h"
  8. #include "video.h"
  9. #include "keyboard.h"
  10. #include "xcodes.h"
  11. #include <conio.h>
  12. #include <string.h>
  13.  
  14. void main(void);
  15. int runmenu(unsigned int, unsigned int, int, int);
  16. void attributes(void);
  17. void mouse_message(void);
  18. void chgmethod(void);
  19. int makebackground(void);
  20. int makemenu(char **, int, char *, char *);
  21. void panel1(unsigned int);
  22. void panel2(unsigned int);
  23. void panel3(unsigned int);
  24. void panel4(unsigned int);
  25. void panel5(unsigned int);
  26. void panel6(unsigned int);
  27. void panel7(unsigned int);
  28. void panel8(unsigned int);
  29. void panel9(unsigned int);
  30. void panel10(unsigned int);
  31.  
  32. /* miscellaneous global variables */
  33. unsigned int window_handle[20];
  34.  
  35. /* A buffer for use by sprintf */
  36. char buffer[4000];
  37.  
  38. /* Some menu selections I use in a sample menu */
  39. char *menu[6] = {"Move a file", "Copy a file", "Delete a file", "Load a file", "Save a file", "Exit to DOS"};
  40.  
  41. void main()
  42. {
  43.  
  44.     int count, a, b, c, d, ox, oy;
  45.     unsigned int handle;
  46.  
  47.     /* Setting various global parameters */
  48.     active_attr = lightgray + (black << 4);
  49.     inactive_attr = lightgray + (black << 4);
  50.     active_tile_attr = lightgreen + (black << 4);
  51.     inactive_tile_attr = white + (black << 4);
  52.     scroll_bars_on = NO_BARS;
  53.     thumbwheels_on = NO_BARS;
  54.     mouse_installed = kb_ismouse();
  55.     method = DMA;
  56.     snowfree = FALSE;
  57.  
  58.     printf("Change video modes at any time by pressing\n\
  59. (A) ANSI, (B) BIOS, (S) snowfree DMA, (D) DMA.\n\n\
  60. Press any key to continue.");chgmethod();
  61.  
  62.     /* initialize the WINDOW PRO */
  63.     wn_init();
  64.  
  65.     /* turn off the cursor */
  66.     wn_hidecur();
  67.  
  68.     /* make a background */
  69.     window_handle[0] = makebackground();
  70.  
  71.     /* set up a menu window to use later on in the demo */
  72.     window_handle[11] = makemenu(menu, 6, "Files Menu","\021─┘ = confirm");
  73.  
  74.     /* set up a window to display the copyright notice */
  75.     window_handle[12] = wn_createw(25, 80, 15, 10, 1, 1, 5, 49, FALSE,
  76.         HEAD_ON, NULL, "Press any key to continue");
  77.     vs_clrvs(window_handle[12], 0, white, blue);
  78.     vs_printf(window_handle[12], 0, white, blue,
  79. " This has been a presentation of The WINDOW PRO\n\n\
  80.               Seabreeze Software\n\n\
  81.             Copyright (c) 1986-1988");
  82.  
  83.     /* Make the ten windows we use in big opening number */
  84.     window_handle[1] = wn_createw(18,50,1,1,1,1,5,8,FALSE,
  85.         HEAD_ON,NULL,NULL);
  86.     vs_fillattr(window_handle[1], 0, 1, 1, 50, 18, white, blue);
  87.     vs_puts(window_handle[1], 0, 3, 1, 3, white, blue, "The");
  88.     vs_puts(window_handle[1], 0, 2, 3, 6, white, blue, "WINDOW");
  89.     vs_puts(window_handle[1], 0, 3, 5, 3, white, blue, "PRO");
  90.     for (count = 2; count <= 10; count++) {
  91.         window_handle[count] = wn_copyw(window_handle[1]);
  92.     }
  93.  
  94.     /* set the position of the top 4 windows in the opener */
  95.     a = 4;
  96.     for (count = 1; count <= 4; count++) {
  97.         handle = window_handle[count];
  98.         WDW->physical_x = a;
  99.         WDW->physical_y = 2;
  100.  
  101.         a += 21;
  102.     }
  103.  
  104.     /* set the position of the bottom 4 windows in the opener */
  105.     a = 67;
  106.     for (count = 6; count <= 9; count++) {
  107.         handle = window_handle[count];
  108.         WDW->physical_x = a;
  109.         WDW->physical_y = 18;
  110.         a -= 21;
  111.     }
  112.  
  113.     /* set the position of the middle windows in the opener */
  114.     handle = window_handle[10];
  115.     WDW->physical_x = 4;
  116.     WDW->physical_y = 10;
  117.     handle = window_handle[5];
  118.     WDW->physical_x = 67;
  119.     WDW->physical_y = 10;
  120.  
  121.  
  122.         /* Bring out each window onto the screen */
  123.     for (count = 1; count <= 10; count++) {
  124.         handle = window_handle[count];
  125.         wn_flybox(physical_columns/2, physical_rows/2, 1, 1,
  126.             WDW->physical_x, WDW->physical_y, WDW->port_rows,
  127.             WDW->port_columns, 10, 50, box4, black, black);
  128.         wn_openw(window_handle[count]);
  129.         if (kbhit()) chgmethod();
  130.     }
  131.  
  132.     /* start distinguishing between the active and inactive windows */
  133.     active_attr = white + (black << 4);
  134.  
  135.     /* Move each one to center stage, and blow it up */
  136.     for (count = 1; count <= 10; count++) {
  137.         /* lets us use the WDW macro */
  138.         handle = window_handle[count];
  139.  
  140.         /* bring it to the top of the windows */
  141.         wn_openw(handle);
  142.  
  143.         /* remember the original column position */
  144.         ox = a = WDW->physical_x;
  145.  
  146.         /* move it to the center columns */
  147.         while (a != 36) {
  148.             if (a < 36) a++;
  149.             else a--;
  150.             wn_locatew(handle, a, WDW->physical_y);
  151.             if (kbhit()) chgmethod();
  152.         }
  153.  
  154.         handle = window_handle[count];
  155.  
  156.         /* remember the original row position */
  157.         oy = a = WDW->physical_y;
  158.  
  159.         /* move it to the center rows */
  160.         while (a != 10) {
  161.             if (a < 10) a++;
  162.             else a--;
  163.             wn_locatew(handle, WDW->physical_x, a);
  164.             if (kbhit()) chgmethod();
  165.         }
  166.  
  167.         /* change the window background to red */
  168.         vs_clrvs(handle, 0, white, red);
  169.  
  170.  
  171.         /* move it up and to the left, so we can increase its size */
  172.         for (a = 0; a < 6; a++) {
  173.             wn_movew(handle, -3, -1);
  174.             if (kbhit()) chgmethod();
  175.         }
  176.  
  177.         /* increase its size */
  178.         for (a = 0; a < 6; a++) {
  179.             wn_sizet(handle, 0, 6, 2);
  180.             if (kbhit()) chgmethod();
  181.         }
  182.  
  183.         /* change the window name */
  184.         wn_namet(handle, 0, "Press any key to continue");
  185.  
  186.         /* Each window is used to show off a different feature */
  187.         switch (count) {
  188.             case 1 : panel1(handle);
  189.                  break;
  190.             case 2 : panel2(handle);
  191.                  break;
  192.             case 3 : panel3(handle);
  193.                  break;
  194.             case 4 : panel4(handle);
  195.                  break;
  196.             case 5 : panel5(handle);
  197.                  break;    
  198.             case 6 : panel6(handle);
  199.                  break;
  200.             case 7 : panel7(handle);    
  201.                  break;
  202.             case 8 : panel8(handle);
  203.                  break;
  204.             case 9 : panel9(handle);
  205.                 break;
  206.             case 10: panel10(handle);
  207.         }
  208.  
  209.         /* get rid of the window name */
  210.         wn_namet(handle, 0,NULL);
  211.  
  212.  
  213.         /* shrink it back down */
  214.         for (a = 0; a < 6; a++) {
  215.             wn_sizet(handle, 0, -6, -2);
  216.         }
  217.  
  218.         /* move it back to the center */
  219.         for (a = 0; a < 6; a++) {
  220.             wn_movew(handle, 3, 1);
  221.             if (kbhit()) chgmethod();
  222.         }
  223.  
  224.         /* move it back to its original row position */
  225.         a = WDW->physical_y;
  226.         while (a != oy) {
  227.             if (a < oy) a++;
  228.             else a--;
  229.             wn_locatew(handle, WDW->physical_x, a);
  230.             if (kbhit()) chgmethod();
  231.         }
  232.  
  233.         /* move it back to its original column position */
  234.         a = WDW->physical_x;
  235.         while (a != ox) {
  236.             if (a < ox) a++;
  237.             else a--;
  238.             wn_locatew(handle, a, WDW->physical_y);
  239.             if (kbhit()) chgmethod();
  240.         }
  241.         }
  242.  
  243.     /* display the copyright notice */
  244.     wn_openw(window_handle[12]);
  245.     chgmethod();
  246.  
  247.     /* close each window */
  248.     for (count = 1; count <=10; count++) {
  249.         handle = window_handle[count];
  250.         a = WDW->physical_x;
  251.         b = WDW->physical_y;
  252.         c = WDW->port_rows;
  253.         d = WDW->port_columns;
  254.         wn_delw(handle);
  255.         wn_flybox(a, b, c, d, physical_columns / 2,
  256.             physical_rows / 2, 1, 1, 10, 50, box4, black,
  257.             black);
  258.         if (kbhit()) chgmethod();
  259.     }
  260.     wn_delw(window_handle[12]);
  261.     wn_delw(window_handle[11]);
  262.     wn_delw(0);
  263.  
  264.     /* restore the background screen */
  265.         wn_restorescr();
  266.  
  267.     /* restore the cursor position */
  268.     v_gotoxy(oldx,oldy);
  269.  
  270.     /* restore the cursor shape */
  271.     v_curshape(oldb, olde);
  272. }
  273.  
  274.  
  275. /* sets up a window to use as the backdrop for the entire demo */
  276. int makebackground()
  277. {
  278.     unsigned int handle;
  279.     unsigned char tile_handle = 0;
  280.  
  281.     handle = wn_createw(physical_rows, physical_columns, 1, 1, 1, 1,
  282.         physical_rows - 2, physical_columns - 2, FALSE, NONE, NULL,
  283.         NULL);
  284.     vs_fillchar(handle, 0, 1, 1, TILE->vs_columns, TILE->vs_rows, '░',
  285.         white, green);
  286.     wn_openw(handle);
  287.     return(handle);
  288. }
  289.  
  290. /* display the introduction */
  291. void panel1(handle)
  292. unsigned int handle;
  293. {
  294.     wn_suspendw(handle);
  295.     /* format the string */
  296.     vs_printf(handle,0,white,red,
  297. "\n\n               The WINDOW PRO\n\n\
  298.                  version 1.4\n\n\
  299.   Copyright (c) 1986, 1987 by Kenneth Stott\n\n\n\
  300.               Seabreeze Software\n\
  301.          397 Dal-Rich Village Suite 169\n\
  302.            Richardson, Texas 75080\n\n\
  303.                 (214) 437-2729");
  304.  
  305.     /* flash the window contents onto the screen */
  306.     wn_suspendw(handle);
  307.     chgmethod();
  308.  
  309.     /* output trailer message */
  310.     vs_clrvs(handle, 0, white, blue);
  311.     vs_puts(handle, 0, 3, 1, 3, white, blue, "The");
  312.     vs_puts(handle, 0, 2, 3, 6, white, blue, "WINDOW");
  313.     vs_puts(handle, 0, 3, 5, 3, white, blue, "PRO");
  314. }
  315.  
  316.  
  317. /*
  318.  * this routine outputs two different messages -- depending on whether
  319.  * a mouse is or isn't installed
  320. */
  321.  
  322. void mouse_message()
  323. {
  324.     int aa;
  325.     unsigned int handle;
  326.     unsigned char *db;
  327.  
  328.     aa = active_attr;
  329.     db = default_box;
  330.  
  331.     active_attr = lightgray + (black << 4);
  332.     default_box = box0;
  333.     
  334.     /* create the window */
  335.     handle = wn_createw(7,44,19,8,1,1,7,44,FALSE,HEAD_ON,NULL,NULL);    
  336.     
  337.     /* fill it with color */
  338.     vs_fillattr(handle, 0, 1, 1, 44, 7, white, blue);
  339.  
  340.     /* select the appropriate message */    
  341.     if (mouse_installed) sprintf(buffer,
  342. "Since you've got a mouse, you can also\n\
  343. try out the WINDOW PRO mouse support\n\
  344. in this next example...\n\n\
  345. Press any key to continue");
  346.     else sprintf(buffer,
  347. "Too bad you don't have a mouse installed.\n\
  348. The WINDOW PRO has excellent mouse\n\
  349. support for this next example...\n\n\
  350. Press any key to continue");
  351.  
  352.     /* output it to the window */
  353.     wn_suspendw(handle);    
  354.     vs_format(handle, 0, white, blue, buffer);
  355.     wn_suspendw(handle);
  356.  
  357.     /* display the window */
  358.     wn_openw(handle);
  359.  
  360.     /* wait for a response */
  361.     chgmethod();
  362.     
  363.     /* remove the window */
  364.     wn_delw(handle);
  365.  
  366.     /* restore the global variables */
  367.     active_attr = aa;
  368.     default_box = db;
  369. }
  370.  
  371. void panel2(handle)
  372. unsigned int handle;
  373. {    
  374.  
  375.     int aa;
  376.  
  377.         /* format the string */
  378.     sprintf(buffer,
  379. "\n\
  380. The WINDOW PRO is a\n\n\
  381.        * fast,\n\
  382.        * compact, and\n\
  383.        * feature-packed,\n\n\
  384. virtual screen manager that lets you create\n\
  385. programs that look and feel like\n\n\
  386.        * Framework,\n\
  387.        * Lotus,\n\
  388.        * dBase III, and\n\
  389.        * other top-sellers.");
  390.  
  391.     /* output it to the window */
  392.     wn_suspendw(handle);
  393.     vs_format(handle, 0, white, red, buffer);
  394.     wn_suspendw(handle);    
  395.     chgmethod();
  396.  
  397.     /* format another string */    
  398.     sprintf(buffer,
  399. "You can quickly implement complex\n\n\
  400.        * dialog boxes,\n\
  401.        * context sensitive help,\n\
  402.        * pop-up, and\n\
  403.        * pull-down menus,\n\n\
  404. The following was created completely with\n\
  405. The WINDOW PRO.  No tricks-- just\n\
  406. straight-forward WINDOW PRO functions.");
  407.  
  408.     /* clear the window and output new message */
  409.     wn_suspendw(handle);
  410.     vs_clrvs(handle, 0, white, red);
  411.     vs_locatecur(handle, 0, 1, 1);
  412.     vs_format(handle, 0, white, red, buffer);
  413.     wn_suspendw(handle);    
  414.     chgmethod();
  415.  
  416.     /* set the attributes */
  417.      aa = active_attr;
  418.      active_attr = white + (blue << 4);
  419.      active_tile_attr = yellow + (blue << 4);
  420.  
  421.     /* display the mouse message */
  422.     mouse_message();
  423.  
  424.     /* display the menu */
  425.     runmenu(window_handle[11], 1, 30, 5);
  426.  
  427.     /* restore active attribute to original value */
  428.     active_attr = aa;
  429.  
  430.     /* output trailer message */
  431.     vs_clrvs(handle, 0, white, green);
  432.     vs_locatecur(handle, 0, 1, 1);
  433.     sprintf(buffer,
  434. "Complex\n\
  435. Windows\n\n\
  436.  Mouse\n\
  437. Support\n");
  438.     vs_format(handle, 0, white, green, buffer);
  439. }
  440.  
  441.  
  442. int makemenu(menu_choices, number_choices, name, help)
  443. char **menu_choices, *name, *help;
  444. int number_choices;
  445. {
  446.     unsigned int handle;
  447.     unsigned char tile_handle, th[3];
  448.     int maxwidth = 0, count, width, ita, namewidth, helpwidth;
  449.     unsigned char *db;
  450.  
  451.     /* save the values of these global variables */
  452.     db = default_box;
  453.     ita = inactive_tile_attr;
  454.  
  455.     /* then change them to what we need */
  456.     default_box =box3;
  457.     inactive_tile_attr = yellow + (blue << 4);
  458.  
  459.         /* determine the width of the menu */
  460.     for (count = 0; count < number_choices; count++) {
  461.         width = strlen(menu_choices[count]) + 3;
  462.         if (width > maxwidth) maxwidth = width;
  463.     }
  464.  
  465.     namewidth = strlen(name);
  466.     if (namewidth > maxwidth) maxwidth = namewidth;
  467.  
  468.     helpwidth = strlen(help);
  469.     if (helpwidth > maxwidth) maxwidth = helpwidth;
  470.  
  471.     /* Make the window that will hold the menu */
  472.     handle = wn_createw(number_choices + 4, maxwidth, 1, 1, 1, 1,
  473.         number_choices + 4, maxwidth, FALSE, HEAD_ON, NULL, NULL);
  474.  
  475.     /* activate the tile in the window */
  476.     th[0] = 0;
  477.     wn_actt(handle,th[0]);
  478.  
  479.     /* make a second tile and put it in the window */
  480.     th[1] = wn_createt(handle, NULL, maxwidth, number_choices + 4, 1, 1);
  481.     wn_openabst(handle, th[1], 1);
  482.  
  483.     /* make a third tile and put it in the window */
  484.     th[2] = wn_createt(handle, NULL, maxwidth, number_choices + 4, 1, 1);
  485.     tile_handle = th[0];
  486.     wn_openabst(handle, th[2], TILE->port_rows - 2);
  487.  
  488.     /* fill the tiles with color */
  489.     vs_fillattr(handle, th[0], 1, 1, maxwidth, 1, yellow, blue);
  490.     vs_fillattr(handle, th[1], 1, 1, maxwidth, 1, yellow, blue);
  491.     vs_fillattr(handle, th[2], 1, 1, maxwidth, number_choices, green, black);
  492.  
  493.     /* put the strings in the top and bottom tiles */
  494.     vs_puts(handle, th[0],1 + ((maxwidth - namewidth) / 2), 1, namewidth,
  495.         yellow, blue, name);
  496.     vs_puts(handle, th[1],1 + ((maxwidth - helpwidth) / 2), 1, helpwidth,
  497.         yellow, blue, help);
  498.  
  499.     /* put the strings in the center tile */
  500.     for (count = 0; count < number_choices; count++) {
  501.          vs_puts(handle, th[2], 3, 1 + count, maxwidth - 3, green,
  502.             black, menu_choices[count]);
  503.     }
  504.  
  505.     /* put the scroll bars on the center tile */
  506.     wn_togscroll(handle, th[2], BOTH_BARS);
  507.     wn_togthumb(handle, th[2], NO_BARS);
  508.  
  509.     /* reset the gobal variables back to their original values */
  510.     inactive_tile_attr = ita;
  511.     default_box = db;
  512.  
  513.     return(handle);
  514. }
  515.  
  516. #define LOCATE        1
  517.  
  518. int runmenu(handle, default_choice, x1, y1)
  519. unsigned int handle;
  520. unsigned int default_choice;
  521. int x1, y1;
  522.  
  523. {
  524.     int curr_choice, cb, ce, button_event, new_location, event, co, timeout;
  525.     unsigned int x, y, mx, my;
  526.     unsigned char tile_handle;
  527.  
  528.         /* position and open the menu on the screen */
  529.     wn_locatew(handle, x1, y1);
  530.     wn_openw(handle);
  531.  
  532.     /* highlight default choice */
  533.     curr_choice = default_choice;
  534.  
  535.     /* initialize event */
  536.     event  = 0;
  537.  
  538.     /* change the cursor size */
  539.     cb = cursor_b;
  540.     ce = cursor_e;
  541.     co = cursor_on;
  542.     cursor_b = 0;
  543.     cursor_e = 15;
  544.  
  545.     /* display the cursor */
  546.     wn_showcur();
  547.     if (mouse_installed) kb_showmouse();
  548.  
  549.     /* set tile handle to center tile */
  550.     tile_handle = WDW->tiles[WDW->first_tile]->forward;
  551.  
  552.     /* set the center tile as the active tile */
  553.     wn_actt(handle, tile_handle);
  554.  
  555.     /* forces highlighting of default choice */
  556.     TILE->cursor_y = 0;
  557.     timeout = 15;
  558.  
  559.     /* command loop */
  560.     while (event != XENTER) {
  561.  
  562.         /* reset the event */
  563.         event = 0;
  564.  
  565.         /* reset new_location */
  566.         new_location = curr_choice;
  567.  
  568.         /* put the cursor on the current item */
  569.         if (TILE->cursor_y != curr_choice) {
  570.             vs_locatecur(handle, tile_handle, 1, curr_choice);
  571.             if (mouse_installed) kb_hidemouse();
  572.             vs_fillattr(handle, tile_handle, 1, curr_choice,
  573.                 WDW->port_columns, curr_choice, black, lightgray);
  574.             if(mouse_installed) kb_showmouse();
  575.         }
  576.  
  577.         /* if there is a key in the buffer get it */
  578.         if (kbhit()) {
  579.             event = kb_getxc();
  580.         }
  581.  
  582.         else if (mouse_installed) {
  583.  
  584.             button_event = kb_mouseclicks(1, timeout, &mx, &my);
  585.  
  586.             /* convert mouse coordinates to physical screen coordinates */
  587.             x = mx;
  588.             y = my;
  589.             kb_convertcoords(&x,&y);
  590.  
  591.             /*
  592.              * if it is a click in the active tile then set a to point
  593.              * to new row to highlight  and set event to indicate mouse event
  594.              * if a DOUBECLICK exit.
  595.             */
  596.  
  597.             /* these three button events translate into actions */
  598.             if ((button_event == CLICK) ||
  599.                 (button_event == DOUBLECLICK) ||
  600.                 (button_event == HOLDING)) {
  601.  
  602.                 /*
  603.                  * clicking in a location or holding and
  604.                  * positioning the cursor moves the selected
  605.                  * item.  double-clicking on an item selects
  606.                  * it and confirms
  607.                 */
  608.                 if (wn_isonvs(handle, tile_handle, &x, &y)) {
  609.                     new_location = y;
  610.                     if ((button_event == CLICK) ||
  611.                         (button_event == HOLDING))
  612.                         event = LOCATE;
  613.                     else event = XENTER;
  614.                     }
  615.  
  616.                 /*
  617.                  * doing any of these things on a scroll bar
  618.                  * is the the same as hitting the up or down
  619.                  * key
  620.                 */
  621.                 if ((wn_isonsbd(handle, tile_handle, x, y)) ||
  622.                     (wn_isonsbr(handle, tile_handle, x, y))) {
  623.                     event = XDOWN;
  624.                 }
  625.                 if ((wn_isonsbu(handle, tile_handle, x, y)) ||
  626.                     (wn_isonsbl(handle, tile_handle, x, y))) {
  627.                     event = XUP;
  628.                 }
  629.                 if ((wn_isonvs(handle, WDW->last_tile, &x, &y)) &&
  630.                     (button_event == CLICK)) {
  631.                     event = XENTER;
  632.                 }
  633.  
  634.             }
  635.  
  636.             /*
  637.              * if it is a button press then lower timeout rate
  638.              * to speed up scrolling rate
  639.             */
  640.             if (button_event == PRESS) {
  641.  
  642.                 /* use maximum sampling rate if dragging a selection */
  643.                 if (wn_isonvs(handle,
  644.                     WDW->tiles[WDW->first_tile]->forward,
  645.                     &x, &y)) timeout = -1;
  646.  
  647.                 /* use a little slower sampling rate if in the scroll bar area */
  648.                 else if (
  649.                     (wn_isonvrbar(handle,
  650.                     WDW->tiles[WDW->first_tile]->forward,
  651.                     x, y)) ||
  652.                     (wn_isonhbar(handle,
  653.                     WDW->tiles[WDW->first_tile]->forward,
  654.                     x, y))) timeout = 2;
  655.             }
  656.  
  657.             /*
  658.              * If the user releases the button then up time out
  659.              * rate to something suitable for clicking
  660.             */
  661.             if (button_event == RELEASE) timeout = 10;
  662.         }
  663.  
  664.         /* if there is an event .... */
  665.         if (event != 0) {
  666.  
  667.             /* interpret the event into a new current item */
  668.             if ((event == XUP) || (event == XLEFT)) curr_choice--;
  669.             if ((event == XDOWN) || (event == XRIGHT)) curr_choice++;
  670.             if (event == XHOME) curr_choice = 1;
  671.             if (event == XEND) curr_choice = 6;
  672.             if ((event == LOCATE) || (event == XENTER)) {
  673.                 curr_choice = new_location;
  674.             }
  675.  
  676.             /* check for wrap around */
  677.             if (curr_choice < 1) curr_choice = TILE->port_rows;
  678.             if (curr_choice > TILE->port_rows) curr_choice = 1;
  679.  
  680.             if (curr_choice != TILE->cursor_y) {
  681.  
  682.                 /* de-highlight the current item */
  683.                 if (mouse_installed) kb_hidemouse();
  684.                 vs_fillattr(handle, tile_handle, 1, TILE->cursor_y,
  685.                     WDW->port_columns, TILE->cursor_y,
  686.                     green, black);
  687.                 if (mouse_installed) kb_showmouse();
  688.             }
  689.         }
  690.     }
  691.  
  692.     /* reset cursor size */
  693.     cursor_b = cb;
  694.     cursor_e = ce;
  695.     if (mouse_installed) kb_hidemouse();
  696.  
  697.     /* close the window */
  698.     wn_closew(handle);
  699.  
  700.     /* reset the cursor */
  701.     if (!co) wn_hidecur();
  702.  
  703.     /* return results */
  704.     return(curr_choice);
  705. }
  706.  
  707. void panel3(handle)
  708. unsigned int handle;
  709. {
  710.     int key = 0, x, y;
  711.  
  712.     /* format a string */
  713.     sprintf(buffer,
  714. "The WINDOW PRO is a\n\n\
  715.           * virtual screen manager.\n\n\
  716. Virtual screens are the basis of most\n\
  717. editors, providing the support for\n\n\
  718.           * horizontal scrolling, and\n\
  719.           * windowing.\n\n\
  720. Let me give you an example. I'll shrink\n\
  721. this window, and you pan through it with\n\
  722. the arrow keys.  I'll also activate scroll\n\
  723. bars (with a simple function call) to\n\
  724. remind the user of what keys to use.");
  725.  
  726.     /* output to window */
  727.     wn_suspendw(handle);
  728.     vs_format(handle, 0, white, red, buffer);
  729.     wn_suspendw(handle);
  730.     chgmethod();
  731.  
  732.     /* shrink it down and put on scroll bars and a message */
  733.     wn_sizet(handle, 0, -10, -10);
  734.     wn_togscroll(handle, 0, BOTH_BARS);
  735.     wn_togthumb(handle, 0, BOTH_BARS);
  736.     wn_namet(handle, 0, "Press ENTER to continue");
  737.  
  738.     /* stay in command loop until ENTER is pressed */
  739.     while (key != XENTER) {
  740.         /* get the keypress */
  741.         key = kb_getxc();
  742.  
  743.         /* set scroll indicators to 0 */
  744.         x = y = 0;
  745.  
  746.         /* interpret each keypress into scrolling values */
  747.         switch (key) {
  748.             case XUP   : y = -1;
  749.                     break;
  750.             case XDOWN : y = 1;
  751.                     break;
  752.             case XLEFT : x = -1;
  753.                     break;
  754.             case XRIGHT: x = 1;
  755.                     break;
  756.             case XHOME : wn_locatevs(handle, 0, 1, 1);
  757.                     break;
  758.             case XEND  : wn_locatevs(handle, 0, 100, 100);
  759.                     break;
  760.             }
  761.  
  762.         /* scroll the virtual screen */
  763.         wn_scrollvs(handle, 0, x, y);
  764.         wn_sync_tw_to_vs(handle, 0);
  765.         }
  766.  
  767.     /* expand it back out again, change the message & turn off scroll bars */
  768.     wn_sizet(handle, 0, 10, 10);
  769.     wn_namet(handle, 0, "Press any key to continue");
  770.     wn_togscroll(handle, 0, NO_BARS);
  771.     wn_togthumb(handle, 0, NO_BARS);
  772.  
  773.     /* set the virtual screen to the top left corner */
  774.     wn_locatevs(handle, 0, 1, 1);
  775.  
  776.     /* output trailer message */
  777.     vs_clrvs(handle, 0, white, magenta);
  778.     vs_locatecur(handle, 0, 1, 1);
  779.     sprintf(buffer,
  780. "Virtual\n\
  781. Screens\n\n\
  782. Scroll\n\
  783. Bars");
  784.     vs_format(handle, 0, white, magenta, buffer);
  785. }
  786.  
  787. void panel4(handle)
  788. unsigned int handle;
  789. {
  790.         unsigned int mhandle, timer;
  791.         int count;
  792.  
  793.     /* print the basic text */
  794.     sprintf(buffer,
  795. "The WINDOW PRO is easy to use.  It\n\
  796. has a windows-like printf that works\n\
  797. just like regular printf but adds\n\
  798. some extras like color support.\n\n\
  799. Watch I'll count to 10 like this:\n\n\
  800. for (count = 1; count <= 10; count++)\n\
  801.   vs_printf(wdw,tile,fgcolor, bgcolor,\n\
  802.   \042count %%d\\n\042,count);\n\n");
  803.     wn_suspendw(handle);
  804.     vs_format(handle, 0, white, red, buffer);
  805.     wn_suspendw(handle);
  806.     chgmethod();
  807.  
  808.     /* set up a window to count in  and open it */
  809.     mhandle = wn_createw(15, 20, 29, 5, 1, 1, 15, 20, FALSE, HEAD_ON,
  810.         "vs_printf","Press any key");
  811.     wn_namet(handle, 0, NULL);
  812.     wn_openw(mhandle);
  813.  
  814.     /* print a little message */
  815.     sprintf(buffer,"First slowly...\n\n");
  816.     vs_format(mhandle, 0, white, red, buffer);
  817.  
  818.     /*
  819.      * count from one to ten -- slowly
  820.     */
  821.     for (count = 1; count <= 10; count++) {
  822.         sprintf(buffer,"count %d.\n",count);
  823.         vs_format(mhandle, 0, green, black, buffer);
  824.         for (timer = 0; timer < (unsigned int) 50000; timer++);
  825.     }
  826.     chgmethod();
  827.  
  828.     /* clear the window */
  829.     vs_clrvs(mhandle, 0, white, black);
  830.     vs_locatecur(mhandle, 0, 1, 1);
  831.  
  832.     /* print a little message */
  833.     sprintf(buffer,"And now quickly....\n\n");
  834.     vs_format(mhandle, 0, white, red, buffer);
  835.  
  836.     /* count fast */
  837.     for (count = 1; count <= 10; count++) {
  838.         sprintf(buffer,"count %d.\n",count);
  839.         vs_format(mhandle, 0, yellow, black, buffer);
  840.     }
  841.     chgmethod();
  842.  
  843.     /* get rid of the counting window */
  844.     wn_delw(mhandle);
  845.  
  846.     /* format a string */
  847.     sprintf(buffer,
  848. "The WINDOW PRO also supports a windows-like\n\
  849. gets.  It works the same as the gets that\n\
  850. you're used to but adds support for color\n\
  851. and scrolling.  Watch how vs_gets works.");
  852.  
  853.     /* clear the window and output the string */
  854.     wn_suspendw(handle);
  855.     vs_clrvs(handle, 0, white, red);
  856.     vs_locatecur(handle, 0, 1, 1);
  857.     vs_format(handle, 0, white, red, buffer);
  858.     wn_namet(handle, 0, "Press any key to continue");
  859.     wn_suspendw(handle);
  860.     chgmethod();
  861.  
  862.     /* turn off the window name */
  863.     wn_namet(handle, 0, NULL);
  864.  
  865.     /* set up a new window for demonstrating vs_gets */
  866.     mhandle = wn_createw(3, 45, 29, 5, 1, 1, 2, 35, FALSE, HEAD_ON,
  867.         "vs_gets --- scrolling ON","Press ENTER to terminate vs_gets");
  868.  
  869.     /* clear the window */
  870.     vs_clrvs(mhandle, 0, white, blue);
  871.  
  872.     /* display the window */
  873.     wn_openw(mhandle);
  874.  
  875.     /* turn on the cursor */
  876.     wn_showcur();
  877.  
  878.     /* use vs_gets */
  879.     vs_gets(mhandle, 0, TRUE, buffer, white, blue, 200);
  880.  
  881.     /* turn off the cursor */
  882.     wn_hidecur();
  883.  
  884.     /* change the window name */
  885.     wn_namet(mhandle, 0, "Press any key to continue");
  886.     chgmethod();
  887.  
  888.     /* suspend the window while we fix a few things */
  889.     wn_suspendw(mhandle);
  890.  
  891.     /* change the window name */
  892.     wn_namew(mhandle, "vs_gets --- scrolling OFF");
  893.  
  894.     /* change the name on the bottom of the window */
  895.     wn_namet(mhandle, 0, "Press ENTER to terminate vs_gets");
  896.  
  897.     /* erase everything in the window */
  898.     vs_clrvs(mhandle, 0, white, blue);
  899.  
  900.     /*
  901.      * set the upper left corner of the window = to the upper left
  902.      * corner of the virtual screen
  903.     */
  904.     wn_locatevs(mhandle, 0, 1, 1);
  905.  
  906.     /* reset the cursor position */
  907.     vs_locatecur(mhandle, 0, 1, 1);
  908.  
  909.     /* turn on the cursor */
  910.     wn_showcur();
  911.  
  912.     /* flash the results of the above to the screen */
  913.     wn_suspendw(mhandle);
  914.  
  915.     /* demonstrate vs_gets without scrolling */
  916.     vs_gets(mhandle, 0, FALSE, buffer, white, blue, 200);
  917.  
  918.     /* turn off the cursor */
  919.     wn_hidecur();
  920.  
  921.     /* change the name of the window */
  922.     wn_namet(mhandle, 0, "Press any key to continue");
  923.     chgmethod();
  924.  
  925.     /* get rid of the demonstration window */
  926.     wn_delw(mhandle);
  927.  
  928.     /* output the trailer message */
  929.     vs_clrvs(handle, 0, white, brown);
  930.     vs_locatecur(handle, 0, 1, 1);
  931.     sprintf(buffer,
  932. "  Easy\n\n\
  933.    to\n\n\
  934.    use");
  935.     vs_format(handle, 0, white, brown, buffer);
  936. }
  937.  
  938. void panel5(handle)
  939. unsigned int handle;
  940. {
  941.     unsigned int mhandle, count, b;
  942.  
  943.     /* format a string */
  944.     sprintf(buffer,
  945. "The WINDOW PRO uses 3 screen update methods:\n\n\
  946.           * DMA,\n\
  947.           * BIOS, and\n\
  948.           * ANSI.\n\n\
  949. Each is available at runtime.  You can even\n\
  950. switch in mid-application.\n\n\
  951. These features give your products a\n\n\
  952.           * wider customer base,\n\
  953.           * reduce hardware dependence, and\n\
  954.           * provide a built-in approach to\n\
  955.             user customization.");
  956.  
  957.     /* output a string */
  958.     wn_suspendw(handle);
  959.     vs_format(handle, 0, white, red, buffer);
  960.     wn_suspendw(handle);
  961.     chgmethod();
  962.  
  963.     /* format another string */
  964.     sprintf(buffer,
  965. "More specifically\n\n\
  966. ** DMA is fast, but causes snow on some\n\
  967.    old CGA cards, and is ill-behaved by\n\
  968.    MS-WINDOWS' and DESQVIEW's standards.\n\n\
  969. ** BIOS makes your programs compatible with\n\
  970.    MS-WINDOWS and DESQVIEW.\n\n\
  971. ** ANSI makes you programs more hardware\n\
  972.    independent, running from remote\n\
  973.    terminals, on DEC PC's, and other\n\
  974.    equipment is very feasible.  You can even\n\
  975.    modify the command sequences to support\n\
  976.    additional equipment.");
  977.  
  978.     /* clear the screen and output the string */
  979.     wn_suspendw(handle);
  980.     vs_clrvs(handle, 0, white, red);
  981.     vs_locatecur(handle, 0, 1, 1);
  982.     vs_format(handle, 0, white, red, buffer);
  983.     wn_suspendw(handle);
  984.     chgmethod();
  985.  
  986.     /* format another string */
  987.     sprintf(buffer,
  988. "See what kind of performance difference\n\
  989. you can detect.  I'll count to ten again.\n\
  990. First, I'll use the DMA approach and then\n\
  991. I'll use the BIOS method.\n\n\n");
  992.  
  993.     /* output the string */
  994.     wn_suspendw(handle);
  995.     vs_clrvs(handle, 0, white, red);
  996.     vs_locatecur(handle, 0, 1, 1);
  997.     vs_format(handle, 0, white, red, buffer);
  998.     wn_suspendw(handle);
  999.     chgmethod();
  1000.  
  1001.     b = method;
  1002.  
  1003.     /* set up a window to count in  and open it */
  1004.     mhandle = wn_createw(15, 20, 29, 5, 1, 1, 15, 20, FALSE, HEAD_ON,
  1005.         "DMA updating","Press any key");
  1006.     wn_namet(handle, 0, NULL);
  1007.     wn_openw(mhandle);
  1008.  
  1009.     method = DMA;
  1010.  
  1011.     /* count */
  1012.     for (count = 1; count <= 10; count++) {
  1013.         sprintf(buffer,"count %d.\n",count);
  1014.         vs_format(mhandle, 0, red, black, buffer);
  1015.     }
  1016.     chgmethod();
  1017.  
  1018.     /* clear the window */
  1019.     vs_clrvs(mhandle, 0, white, black);
  1020.     vs_locatecur(mhandle, 0, 1, 1);
  1021.  
  1022.     /* change the window name */
  1023.     wn_namew(mhandle, "BIOS updating");
  1024.  
  1025.     /* change to the BIOS update method */
  1026.     method = BIOS;
  1027.  
  1028.     /* count */
  1029.     for (count = 1; count <= 10; count++) {
  1030.         sprintf(buffer,"count %d.\n",count);
  1031.         vs_format(mhandle, 0, magenta, black, buffer);
  1032.     }
  1033.     chgmethod();
  1034.  
  1035.     /* change back to default updating */
  1036.     method = b;
  1037.  
  1038.     /* get rid of the window */
  1039.     wn_delw(mhandle);
  1040.  
  1041.     /* output the trailer message */
  1042.     vs_clrvs(handle, 0, white, black);
  1043.     vs_locatecur(handle, 0, 1, 1);
  1044.     sprintf(buffer,
  1045. "  BIOS\n\n\
  1046.   DMA\n\n\
  1047.   ANSI");
  1048.     vs_format(handle, 0, white, black, buffer);
  1049. }
  1050.  
  1051. void panel6(handle)
  1052. unsigned int handle;
  1053. {
  1054.     /* format a string */
  1055.     sprintf(buffer,
  1056. "The WINDOW PRO provides complete\n\
  1057. control over colors...\n\n");
  1058.  
  1059.     /* output the string */
  1060.     wn_suspendw(handle);
  1061.     vs_format(handle, 0, white, red, buffer);
  1062.     wn_suspendw(handle);
  1063.     chgmethod();
  1064.  
  1065.     /* display the attributes window */
  1066.     attributes();
  1067.  
  1068.     /* output the string */
  1069.     wn_suspendw(handle);
  1070.     vs_clrvs(handle, 0, white, red);
  1071.     vs_locatecur(handle, 0, 1, 1);
  1072.     vs_format(handle, 0, white, red,
  1073. "The WINDOW PRO uses logical colors.  No\n\
  1074. matter how you write your programs The\n\
  1075. WINDOW PRO stores the actual attribute\n\
  1076. values in a single location.  This \n\n\
  1077.      * Lets you easily give your\n\
  1078.        end-users customizable color\n\
  1079.        schemes (like BORLAND and\n\
  1080.        MICROSOFT products,) and\n\n");
  1081.  
  1082.     vs_format(handle, 0, white, red,
  1083. "     * Makes porting applications\n\
  1084.        simpler.  You can create color\n\
  1085.        keys for several terminals and,\n\
  1086.        video boards, making your\n\
  1087.        application look consistent on\n\
  1088.        all hardware.");
  1089.  
  1090.     wn_suspendw(handle);
  1091.     chgmethod();
  1092.  
  1093.     /* output the trailer message */
  1094.     vs_clrvs(handle, 0, yellow, black);
  1095.     vs_locatecur(handle, 0, 1, 1);
  1096.     sprintf(buffer,
  1097. " Custom\n\n\
  1098.  Color\n\n\
  1099.  Support");
  1100.     vs_format(handle, 0, yellow, black, buffer);
  1101.  
  1102.  
  1103. }
  1104.  
  1105. void attributes()
  1106. {
  1107.  
  1108.     unsigned int window_handle, count1, count2;
  1109.     char *bg = "Background||v    ";
  1110.  
  1111.     /* set up ta window to display the attributes in */
  1112.     window_handle = wn_createw(25, 80, 35, 2, 1, 1, 20, 20, FALSE,
  1113.         HEAD_ON, "Video Attributes", NULL);
  1114.  
  1115.     /* position the cursor */
  1116.     vs_locatecur(window_handle,0,2,1);
  1117.  
  1118.     /* output the horizontal titles */
  1119.     vs_format(window_handle, 0, white, black, "Foreground-->");
  1120.     vs_locatecur(window_handle,0,4,3);
  1121.     for (count1 = 0; count1 < 16; count1++) {
  1122.         sprintf(buffer, "%X", count1);
  1123.         vs_format(window_handle, 0, white, black, buffer);
  1124.     }
  1125.  
  1126.     /* output the rest line by line */
  1127.     for (count1 = 0; count1 < 16; count1++) {
  1128.  
  1129.         /* output the vertical title */
  1130.         vs_locatecur(window_handle, 0, 1, count1+4);
  1131.         sprintf(buffer, "%c %X", bg[count1], count1);
  1132.         vs_format(window_handle, 0, white, black, buffer);
  1133.         
  1134.         /* output the attribute display for the current line */
  1135.         for (count2 = 0; count2 < 16; count2++) {
  1136.             vs_putc(window_handle, 0, count2 + 4, count1 + 4, count2, count1, 'x');
  1137.         }
  1138.     }
  1139.     
  1140.     /* display the window */
  1141.     wn_openw(window_handle);
  1142.      chgmethod();
  1143.  
  1144.     /* get rid of the window */
  1145.      wn_delw(window_handle);
  1146. }
  1147.  
  1148. void panel7(handle)
  1149. unsigned int handle;
  1150. {
  1151.         unsigned char th[3];
  1152.     int event = 0;
  1153.     
  1154.     th[0] = 0;
  1155.     active_tile_attr = lightgreen + (black << 4);
  1156.     inactive_tile_attr = white + (black << 4);
  1157.  
  1158.     /* format a string */
  1159.     sprintf(buffer,
  1160. "The WINDOW PRO lets you associate several\n\
  1161. virtual screens with a single window.  You\n\
  1162. can\n\n\
  1163.         * split windows and display\n\
  1164.           multiple virtual screens in\n\
  1165.           in a single split-window\n\
  1166.         * swap virtual screens in and out\n\
  1167.         * and change the sizes of split\n\
  1168.           window areas (we call them tiles)\n\n\
  1169. This is the basis for things like segmented\n\
  1170. pull-down menus, and other sophisticated\n\
  1171. screen effects.\n\n\
  1172. Watch this example.");
  1173.  
  1174.     /* output the string */
  1175.     wn_suspendw(handle);
  1176.     vs_format(handle, 0, white, red, buffer);
  1177.     wn_suspendw(handle);
  1178.     chgmethod();
  1179.  
  1180.     /* change the tile name */
  1181.     wn_namet(handle, th[0], "first virtual screen");
  1182.  
  1183.     /* create a second tile */
  1184.     th[1] = wn_createt(handle, "second virtual screen", 80, 25, 1, 1);
  1185.  
  1186.     /* fill in the second tile with color */
  1187.     vs_clrvs(handle, th[1], white, green);
  1188.  
  1189.     /* format a string and output it to the second tile */
  1190.     sprintf(buffer,
  1191. "This is a second virtual screen.  It is\n\
  1192. completely independent of the first\n\
  1193. virtual screen.\n\n\
  1194. -- Pan using the arrow keys\n\
  1195. -- Swap virtual screens HOME\n\
  1196. -- Switch virtual screens END\n\
  1197. -- Size using PgUp/PgDn\n\
  1198. -- ENTER to continue");
  1199.  
  1200.     wn_suspendw(handle);
  1201.     vs_format(handle, th[1], white, green, buffer);
  1202.  
  1203.     /* display the second tile */
  1204.     wn_opent(handle, th[1]);
  1205.  
  1206.     /* make the second tile a little bigger */
  1207.     wn_sizet(handle, th[0], 0, -3);
  1208.  
  1209.     /* make the second tile the active tile */
  1210.     wn_actt(handle, th[1]);
  1211.  
  1212.     /* turn on the scroll bars */
  1213.     wn_togscroll(handle, th[1], BOTH_BARS);
  1214.  
  1215.     /* flash all changes to the screen */
  1216.     wn_suspendw(handle);
  1217.  
  1218.     /* main command loop: exits on pressing ENTER */
  1219.     while (event != XENTER) {
  1220.  
  1221.         /* get keystroke */
  1222.         event = kb_getxc();
  1223.  
  1224.         /* select an action */
  1225.         switch (event) {
  1226.             case XUP     : wn_scrollvs(handle, WDW->active_tile, 0, -1);
  1227.                       break;
  1228.             case XDOWN     : wn_scrollvs(handle, WDW->active_tile, 0, 1);
  1229.                     break;
  1230.             case XLEFT    : wn_scrollvs(handle, WDW->active_tile, -1, 0);
  1231.                     break;
  1232.             case XRIGHT    : wn_scrollvs(handle, WDW->active_tile, 1, 0);
  1233.                     break;
  1234.             case XPGUP    : wn_sizet(handle, WDW->first_tile, 0, -1);
  1235.                     break;
  1236.             case XPGDN    : wn_sizet(handle, WDW->first_tile, 0, 1);
  1237.                     break;
  1238.             case XHOME    : wn_swapt(handle, th[0], handle, th[1]);
  1239.                       event = XEND;
  1240.             case XEND    : if (WDW->active_tile == th[0]) {
  1241.                         wn_suspendw(handle);
  1242.                         wn_togscroll(handle, th[0], NO_BARS);
  1243.                         wn_togscroll(handle, th[1], BOTH_BARS);
  1244.                         wn_actt(handle, th[1]);
  1245.                         wn_suspendw(handle);
  1246.                     }
  1247.                     else {
  1248.                         wn_suspendw(handle);
  1249.                         wn_togscroll(handle, th[1], NO_BARS);
  1250.                         wn_togscroll(handle, th[0], BOTH_BARS);
  1251.                         wn_actt(handle, th[0]);
  1252.                         wn_suspendw(handle);
  1253.                     }
  1254.                     break;
  1255.         }
  1256.     }
  1257.  
  1258.     /* close up the second tile */
  1259.     wn_closet(handle, th[1]);
  1260.  
  1261.     /* turn off the scroll bars */
  1262.     wn_togscroll(handle, th[0], NO_BARS);
  1263.  
  1264.     /* output the trailer message */
  1265.     vs_clrvs(handle, th[0], black, red);
  1266.     wn_locatevs(handle, th[0], 1, 1);
  1267.     vs_locatecur(handle, th[0], 1, 1);
  1268.     sprintf(buffer,"\n\n Tiles");
  1269.     vs_format(handle, th[0], black, red, buffer);
  1270. }
  1271.  
  1272. void panel8(handle)
  1273. unsigned int handle;
  1274. {
  1275.     unsigned int mhandle;
  1276.     unsigned char th;
  1277.  
  1278.     /* format a string */
  1279.     sprintf(buffer,
  1280. "The WINDOW PRO gives you complete control\n\
  1281. over\n\n\
  1282.          * border characters, and\n\
  1283.          * border styles.\n\n\
  1284. Border characters are up to you.  You can\n\
  1285. use any of the several built-in sets of\n\
  1286. border characters, or create your own.\n\n\
  1287. Border styles let you create shadowing\n\
  1288. effects.\n\n\
  1289. Look at the following example for an idea\n\
  1290. of the flexibility of The WINDOW PRO.");
  1291.  
  1292.     /* output the string */
  1293.     wn_suspendw(handle);
  1294.     vs_format(handle, 0, white, red, buffer);
  1295.     wn_suspendw(handle);
  1296.     chgmethod();
  1297.  
  1298.     /* setup a window to demonstrate border stuff */
  1299.     mhandle = wn_createw(25, 80, 29, 5, 1, 1, 12, 25, FALSE, HEAD_ON,
  1300.         "BORDER CHARACTERS",NULL);
  1301.  
  1302.     /* create a second tile -- to show the full effect of certain changes */
  1303.     th = wn_createt(mhandle, "Press any key", 80, 25, 1, 1);
  1304.  
  1305.     /* fill both tiles with color */
  1306.     vs_clrvs(mhandle, 0, black, lightgray);
  1307.     vs_clrvs(mhandle, th, black, lightgray);
  1308.  
  1309.     /* display the second tile */
  1310.     wn_opent(mhandle, th);
  1311.  
  1312.     /* display the window */
  1313.     wn_openw(mhandle);
  1314.  
  1315.     /* display various border styles */
  1316.     wn_chgbord(mhandle, box1);
  1317.     chgmethod();
  1318.     wn_chgbord(mhandle, box2);
  1319.     chgmethod();
  1320.     wn_chgbord(mhandle, box3);
  1321.     chgmethod();
  1322.     wn_chgbord(mhandle, box4);
  1323.     chgmethod();
  1324.     sprintf(buffer,
  1325. "\n\n    Border Styles");
  1326.     vs_format(mhandle, 0, black, lightgray, buffer);
  1327.     wn_namet(mhandle, th, NULL);
  1328.     wn_namew(mhandle, NULL);
  1329.     wn_togborder(mhandle, UPPER_LEFT);
  1330.     chgmethod();
  1331.     wn_togborder(mhandle, UPPER_RIGHT);
  1332.     chgmethod();
  1333.     wn_togborder(mhandle, LOWER_RIGHT);
  1334.     chgmethod();
  1335.     wn_togborder(mhandle, LOWER_LEFT);
  1336.     chgmethod();
  1337.     wn_togborder(mhandle, NONE);
  1338.     chgmethod();
  1339.     wn_togborder(mhandle, HEAD_ON);
  1340.     wn_chgbord(mhandle, box0);
  1341.     chgmethod();
  1342.  
  1343.     /* get rid of the demonstration window */
  1344.     wn_delw(mhandle);
  1345.  
  1346.     /* output the trailer message */
  1347.     vs_clrvs(handle, 0, black, green);
  1348.     vs_locatecur(handle, 0, 1, 1);
  1349.  
  1350.     sprintf(buffer,
  1351. "Flexible\n\n\
  1352.  Border\n\n\
  1353.  Styles");
  1354.     vs_format(handle, 0, black, green, buffer);
  1355. }
  1356.  
  1357. void panel9(handle)
  1358. unsigned int handle;
  1359. {
  1360.  
  1361.     unsigned int mhandle[3];
  1362.     int count;
  1363.  
  1364.     sprintf(buffer,
  1365. "The WINDOW PRO provides several methods of\n\
  1366. controlling overlapping of windows\n\n\
  1367. First, some overlapping windows...");
  1368.     wn_suspendw(handle);
  1369.     vs_format(handle, 0, white, red, buffer);
  1370.     wn_suspendw(handle);
  1371.     chgmethod();
  1372.  
  1373.     for (count = 0; count < 3; count++) {
  1374.         mhandle[count] = wn_createw(25, 80, 20 + (count * 3),
  1375.             4 + (count * 3), 1, 1, 10, 15, FALSE, HEAD_ON,
  1376.             NULL,NULL);
  1377.         vs_clrvs(mhandle[count], 0, white, black + 3 + count);
  1378.         wn_openw(mhandle[count]);
  1379.     }
  1380.     chgmethod();
  1381.  
  1382.     sprintf(buffer,
  1383. "Popular programs like Framework & Symphony\n\
  1384. actually use several methods of manipulating\n\
  1385. overlapping windows like\n\n\
  1386.           * activation,\n\
  1387.           * hiding,\n\
  1388.           * opening, and\n\
  1389.           * closing.\n\n\
  1390. The differences are subtle but important.\n\
  1391. Particularly important when you commit to\n\
  1392. BRAND X and find out that the subtleties\n\
  1393. escaped you, the client wants changes made,\n\
  1394. BRAND X won't do it, and the deadline\n\
  1395. looms closer.  See if you can pick up on\n\
  1396. the differences.");
  1397.  
  1398.     wn_suspendw(handle);
  1399.     vs_clrvs(handle, 0, white, red);
  1400.     vs_locatecur(handle, 0, 1, 1);
  1401.     vs_format(handle, 0, white, red, buffer);
  1402.     wn_suspendw(handle);
  1403.     wn_actw(handle);
  1404.     chgmethod();
  1405.  
  1406.     sprintf(buffer,
  1407. "Activating a window temporarily brings it\n\
  1408. it to the top and reinserts the previously\n\
  1409. active window back into the stack at its\n\
  1410. original position.\n\n\
  1411. Watch what happens when a window is\n\
  1412. activated.  (For future reference, the\n\
  1413. bright bordered window is the active window,\n\
  1414. and there is always an active window on the\n\
  1415. screen.)");
  1416.     wn_suspendw(handle);
  1417.     vs_clrvs(handle, 0, white, red);
  1418.     vs_locatecur(handle, 0, 1, 1);
  1419.     vs_format(handle, 0, white, red, buffer);
  1420.     wn_suspendw(handle);
  1421.     chgmethod();
  1422.     wn_actw(mhandle[2]);
  1423.     chgmethod();
  1424.  
  1425.     for (count = 0; count < 2; count++) {
  1426.         wn_actw(mhandle[count]);
  1427.         chgmethod();
  1428.         wn_actw(mhandle[2]);
  1429.         chgmethod();
  1430.     }
  1431.  
  1432.     sprintf(buffer,
  1433. "Hiding a window supresses its display\n\
  1434. 'Un-hiding' it reinserts it back into its\n\
  1435. original position in the stack\n\n\
  1436. Watch closely as I hide and un-hide each\n\
  1437. window.");
  1438.     wn_suspendw(handle);
  1439.     vs_clrvs(handle, 0, white, red);
  1440.     vs_locatecur(handle, 0, 1, 1);
  1441.     vs_format(handle, 0, white, red, buffer);
  1442.     wn_suspendw(handle);
  1443.     wn_actw(handle);
  1444.     chgmethod();
  1445.     wn_actw(mhandle[2]);
  1446.     chgmethod();
  1447.  
  1448.     for (count = 0; count < 3; count++) {
  1449.         wn_hidew(mhandle[count]);
  1450.         chgmethod();
  1451.         wn_hidew(mhandle[count]);
  1452.         if (count == 2) wn_actw(mhandle[count]);
  1453.         chgmethod();
  1454.     }
  1455.  
  1456.     sprintf(buffer,
  1457. "Opening a window places it permanently on\n\
  1458. top of the stack of windows.\n\n\
  1459. Closing a window removes it from the screen.\n\n\
  1460. Notice what happens as I close and open\n\
  1461. each window.");
  1462.     wn_suspendw(handle);
  1463.     vs_clrvs(handle, 0, white, red);
  1464.     vs_locatecur(handle, 0, 1, 1);
  1465.     vs_format(handle, 0, white, red, buffer);
  1466.     wn_suspendw(handle);
  1467.     wn_actw(handle);
  1468.     chgmethod();
  1469.     wn_actw(mhandle[2]);
  1470.     chgmethod();
  1471.  
  1472.     for (count = 2; count >= 0; count--) {
  1473.         wn_closew(mhandle[count]);
  1474.         chgmethod();
  1475.         wn_openw(mhandle[count]);
  1476.         chgmethod();
  1477.     }
  1478.  
  1479.     for (count = 0; count < 3 ; count++) wn_closew(mhandle[count]);
  1480.  
  1481.     vs_clrvs(handle, 0, red, black);
  1482.     vs_locatecur(handle, 0, 1, 1);
  1483.  
  1484.     sprintf(buffer,
  1485. "  Over\n\n\
  1486.  lapping\n\n\
  1487.  Windows");
  1488.     vs_format(handle, 0, red, black, buffer);
  1489. }
  1490.  
  1491. void panel10(handle)
  1492. unsigned int handle;
  1493. {
  1494.     wn_suspendw(handle);
  1495.     vs_format(handle, 0, white, red,
  1496. "The WINDOW PRO is distributed under the\n\
  1497. shareware marketing concept.  You are free\n\
  1498. to incorporate The WINDOW PRO shareware\n\
  1499. version into your applications programs and\n\
  1500. may distribute those programs royalty free.\n\n\
  1501. To get the full benefit of The WINDOW PRO,\n");
  1502.  
  1503.     vs_format(handle, 0, white, red,
  1504. "register with Seabreeze for updates and\n\
  1505. technical support. The shareware users\n\
  1506. manual contains additional information on\n\
  1507. registering, or you can contact:\n\n\
  1508.              Kenneth Stott\n\
  1509.           Seabreeze Software\n\
  1510.    397 Dal-Rich Village Suite 169\n\
  1511.       Richardson, Texas 75080\n\n\
  1512.           (214) 437-2729");
  1513.  
  1514.     wn_suspendw(handle);
  1515.     chgmethod();
  1516.  
  1517.     vs_clrvs(handle, 0, magenta, black);
  1518.     vs_locatecur(handle, 0, 1, 1);
  1519.  
  1520.     sprintf(buffer,
  1521. "\n\
  1522.  Share-\n\
  1523.   ware");
  1524.     vs_format(handle, 0, magenta, black, buffer);
  1525. }
  1526.  
  1527. void chgmethod()
  1528. {
  1529.     char a;
  1530.  
  1531.     a = getch();
  1532.     switch (upcase(a)) {
  1533.     case 'A' : method = ANSI;
  1534.            break;
  1535.     case 'B' : method = BIOS;
  1536.            break;
  1537.     case 'S' : method = DMA;
  1538.            snowfree = TRUE;
  1539.            break;
  1540.     case 'D' : method = DMA;
  1541.            snowfree = FALSE;
  1542.            break;
  1543.     }
  1544. }
  1545.