home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / window / visions / demowind.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-21  |  29.6 KB  |  795 lines

  1. /*------------------------- DEMOWIND.C -------------------------*/
  2. /*                                                              */
  3. /* This file contains the VISIONS LIBRARY WINDOW DEMO software. */
  4. /*                                                              */
  5. /*         Copyright 1990 Dan Vogel & David Bernazzani          */
  6. /*                                                              */
  7. /*   Date        Initials        Comments                       */
  8. /*                                                              */
  9. /*  03/07/90       DCV       Initial Release 0.00               */
  10. /*--------------------------------------------------------------*/
  11.  
  12. #include <stdio.h>
  13. #include "USERLIST.H"
  14. #include "USERWIND.H"
  15. #include "USERMENU.H"
  16. #include "USERFORM.H"
  17. #include "DEMOPROT.H"
  18.  
  19. static char *cnotice="VISIONS Copyright 1990 Dan Vogel & David Bernazzani";
  20.  
  21. /*--------------------------------------------------------------*/
  22.  
  23.  
  24.  
  25.  
  26. /*-----------------------------------------------------*/
  27. /*                  Run_Window                         */
  28. /*  This is the window library demonstration code.     */
  29. /* The window library demonstration consists of three  */
  30. /* parts, first an introduction to the windows library */
  31. /* demonstration, second a display of multiple windows */
  32. /* of many colors, sizes, and types, and finally an    */
  33. /* interactive window developer and display.           */
  34. /*  NOTE: In general, error checking has been removed  */
  35. /* for the sake of code clarity.  Users should check   */
  36. /* return values for errors!                           */
  37. /*-----------------------------------------------------*/
  38. int Run_Window()
  39. {
  40.    WINDOW_HEAD *clear_window;      /* Window to clear screen. */
  41.    MENU_HEAD *new_menu;
  42.  
  43.    /*-------------------------------------------*/
  44.    /* Create a window just to clear the screen. */
  45.    /*-------------------------------------------*/
  46.    DefineWindow(&clear_window, 1, 1, 24, 80,
  47.       TEXT_BLACK, TEXT_WHITE, "", NOBORDER, FALSE, FALSE, TRUE);
  48.    DisplayWindow(clear_window);
  49.  
  50.    /*-------------------------------------------*/ 
  51.    /* Tell the user what this routine is about. */
  52.    /*-------------------------------------------*/
  53.    Window_Intro();
  54.  
  55.    /*--------------------------------------------------------*/
  56.    /*  First build the window demonstration selection menu.  */
  57.    /*--------------------------------------------------------*/
  58.    DefineMenu(&new_menu, 7,7,1,1,
  59.         SINGLEBORDER, HOT_EXEC_ON, TEXT_BLUE, TEXT_WHITE,
  60.         TEXT_WHITE, TEXT_BLUE, "SELECT WINDOW DEMONSTRATION");
  61.  
  62.    AddToMenu(new_menu, "Colors of Windows", 'C', 0, *Colors_Window);
  63.    AddToMenu(new_menu, "Borders of Windows", 'B', 0, *Borders_Window);
  64.    AddToMenu(new_menu, "Exploding/Imploding Windows",
  65.         'E', 0, *Exploding_Window);
  66.    AddToMenu(new_menu, "MultiWindow Display", 'M', 0, *Multiple_Window);
  67.    AddToMenu(new_menu, "Interactive Window Demo",
  68.         'I', 0, *Interactive_Windows);
  69.    AddToMenu(new_menu, "Exit Window Demonstration", 'E', 1, NULL);
  70.  
  71.    /*---------------------------------*/
  72.    /* Get and execute user selection. */
  73.    /*---------------------------------*/
  74.    AutoDisplayMenu(new_menu);
  75.  
  76.    /*---------------------------------*/
  77.    /* And return menu memory to heap. */
  78.    /*---------------------------------*/
  79.    DeleteMenu(new_menu);
  80.  
  81.    RemoveWindow(clear_window);
  82.    DeleteWindow(clear_window);
  83.    return(0);
  84. }
  85.  
  86.  
  87.  
  88. /*-----------------------------------------------------*/
  89. /*                 Colors_Window                       */
  90. /* This routine displays a full screen window showing  */
  91. /* all possible colors available in VISIONS for        */
  92. /* backgrounds and text.  This is also useful for      */
  93. /* determining the mappings of different color values  */
  94. /* on a monochrome adaptor!  Note that VISIONS will    */
  95. /* automatically convert colors to monochrome if there */
  96. /* is no color adaptor.  Furthermore, VISIONS disables */
  97. /* background color blinking in color systems in order */
  98. /* to provide eight more colors.                       */
  99. /*-----------------------------------------------------*/
  100. int Colors_Window()
  101. {
  102.    WINDOW_HEAD *window_ptr;
  103.  
  104.    /*-----------------------------------*/
  105.    /* Set up the window and display it. */
  106.    /*-----------------------------------*/
  107.    DefineWindow(&window_ptr, 1, 1, 24, 80,
  108.         TEXT_BLACK, TEXT_WHITE, "Colors Display",
  109.         DOUBLEBORDER, FALSE, FALSE, TRUE);
  110.    DisplayWindow(window_ptr);
  111.  
  112.    /*------------------------------------------------*/
  113.    /* Now fill in the window with color information. */
  114.    /*------------------------------------------------*/
  115.    SetTextColor(TEXT_WHITE);  SetBkColor(TEXT_BLACK); 
  116.    WindMesg(4,13,"Background Colors");
  117.    WindMesg(4,53,"Text Colors");
  118.  
  119.    SetTextColor(TEXT_WHITE);  SetBkColor(TEXT_BLACK); 
  120.    WindMesg(6,13,"Black Background");
  121.    SetBkColor(TEXT_BLUE);     WindMesg(7,13,"Blue Background");
  122.    SetBkColor(TEXT_GREEN);    WindMesg(8,13,"Green Background");
  123.    SetBkColor(TEXT_CYAN);     WindMesg(9,13,"Cyan Background");
  124.    SetBkColor(TEXT_RED);      WindMesg(10,13,"Red Background");
  125.    SetBkColor(TEXT_MAGENTA);  WindMesg(11,13,"Magenta Background");
  126.    SetBkColor(TEXT_BROWN);    WindMesg(12,13,"Brown Background");
  127.    SetBkColor(TEXT_WHITE);    SetTextColor(TEXT_BLACK);
  128.    WindMesg(13,13,"White Background");
  129.    SetTextColor(TEXT_WHITE);  SetBkColor(TEXT_DGREY);
  130.    WindMesg(14,13,"Dark Grey Background");
  131.    SetBkColor(TEXT_LBLUE);    WindMesg(15,13,"Light Blue Background");
  132.    SetBkColor(TEXT_LGREEN);   WindMesg(16,13,"Light Green Background");
  133.    SetBkColor(TEXT_LCYAN);    WindMesg(17,13,"Light Cyan Background");
  134.    SetBkColor(TEXT_LRED);     WindMesg(18,13,"Light Red Background");
  135.    SetBkColor(TEXT_LMAGENTA); WindMesg(19,13,"Light Magenta Background");
  136.    SetBkColor(TEXT_YELLOW);   SetTextColor(TEXT_BLACK);
  137.    WindMesg(20,13,"Yellow Background");
  138.    SetBkColor(TEXT_BWHITE);   SetTextColor(TEXT_BLACK);
  139.    WindMesg(21,13,"Bright White Background");
  140.  
  141.    SetBkColor(TEXT_WHITE);    SetTextColor(TEXT_BLACK);
  142.    WindMesg(6,53,"Black Text");
  143.    SetTextColor(TEXT_BLUE);   WindMesg(7,53,"Blue Text");
  144.    SetTextColor(TEXT_GREEN);  WindMesg(8,53,"Green Text");
  145.    SetTextColor(TEXT_CYAN);   WindMesg(9,53,"Cyan Text");
  146.    SetTextColor(TEXT_RED);    WindMesg(10,53,"Red Text");
  147.    SetTextColor(TEXT_MAGENTA);
  148.    WindMesg(11,53,"Magenta Text");
  149.    SetTextColor(TEXT_BROWN);  SetBkColor(TEXT_WHITE);
  150.    WindMesg(12,53,"Brown Text");
  151.    SetBkColor(TEXT_BLACK);    SetTextColor(TEXT_WHITE);
  152.    WindMesg(13,53,"White Text");
  153.    SetBkColor(TEXT_WHITE);    SetTextColor(TEXT_DGREY);
  154.    WindMesg(14,53,"Dark Grey Text");
  155.    SetBkColor(TEXT_BLACK);    SetTextColor(TEXT_LBLUE);
  156.    WindMesg(15,53,"Light Blue Text");
  157.    SetTextColor(TEXT_LGREEN); WindMesg(16,53,"Light Green Text");
  158.    SetTextColor(TEXT_LCYAN);  WindMesg(17,53,"Light Cyan Text");
  159.    SetTextColor(TEXT_LRED);   WindMesg(18,53,"Light Red Text");
  160.    SetTextColor(TEXT_LMAGENTA);
  161.    WindMesg(19,53,"Light Magenta Text");
  162.    SetTextColor(TEXT_YELLOW); WindMesg(20,53,"Yellow Text");
  163.    SetTextColor(TEXT_BWHITE); WindMesg(21,53,"Bright White Text");
  164.  
  165.    WindMesg(24,28,"Hit any key to continue.");
  166.  
  167.    GetKey();    /* Wait for a user keystroke. */
  168.  
  169.    RemoveWindow(window_ptr);   /* And finally destroy the window. */
  170.    DeleteWindow(window_ptr);
  171.  
  172.    return(0);
  173. }
  174.  
  175.  
  176.  
  177.  
  178. /*-----------------------------------------------*/
  179. /*                Borders_Window                 */
  180. /* This routine displays three separate windows, */ 
  181. /* each with a different style of border in      */
  182. /* order to show the user the different border   */
  183. /* options, No Border, Single Line Border, and   */
  184. /* Double Line Border.                           */
  185. /*-----------------------------------------------*/
  186. int Borders_Window()
  187. {
  188.    WINDOW_HEAD *w_ptr1, *w_ptr2, *w_ptr3;
  189.  
  190.    /*---------------------------------------------------------*/
  191.    /* Define windows portraying the different border choices. */
  192.    /*---------------------------------------------------------*/
  193.    DefineWindow(&w_ptr1, 8, 1, 7, 39,
  194.         TEXT_BLUE, TEXT_BWHITE, "No Border Window",
  195.         NOBORDER, FALSE, FALSE, TRUE);
  196.    DefineWindow(&w_ptr2, 8, 41, 7, 39,
  197.         TEXT_BLUE, TEXT_BWHITE, "Single Border Window",
  198.         SINGLEBORDER, FALSE, TRUE, TRUE);
  199.    DefineWindow(&w_ptr3, 16, 20, 7, 39,
  200.         TEXT_BLUE, TEXT_BWHITE, "Double Border Window",
  201.         DOUBLEBORDER, TRUE, FALSE, TRUE);
  202.  
  203.    /*----------------------------*/
  204.    /* Display the three windows. */
  205.    /*----------------------------*/
  206.    DisplayWindow(w_ptr1);
  207.    DisplayWindow(w_ptr2);
  208.    DisplayWindow(w_ptr3);
  209.  
  210.    WindMesg(7,7,"Hit any key to continue.");
  211.  
  212.    GetKey();    /* Wait for a user keystroke. */
  213.  
  214.    RemoveWindow(w_ptr1);   /* And destroy the border demo windows. */
  215.    DeleteWindow(w_ptr1);
  216.    RemoveWindow(w_ptr2);
  217.    DeleteWindow(w_ptr2);
  218.    RemoveWindow(w_ptr3);
  219.    DeleteWindow(w_ptr3);
  220.  
  221.    return(0);
  222. }
  223.  
  224.  
  225.  
  226.  
  227. /*------------------------------------------------------*/
  228. /*                 Exploding_Window                     */
  229. /* This routine demonstrates the difference between     */
  230. /* an exploding/imploding window, and a 'normal'        */
  231. /* window.  This is accomplished by displaying both     */
  232. /* types of windows at the same time, and then removing */
  233. /* them.  This is done repeatedly to allow the user     */
  234. /* to more clearly see the difference.                  */
  235. /*------------------------------------------------------*/
  236. int Exploding_Window()
  237. {
  238.    WINDOW_HEAD *(window_ptr[2]);
  239.    int i;
  240.  
  241.    /*----------------------*/
  242.    /* Define both windows. */
  243.    /*----------------------*/
  244.    DefineWindow(&(window_ptr[0]), 2, 2, 11, 40,
  245.         TEXT_CYAN, TEXT_LGREEN, "EXPLODING AND IMPLODING WINDOW",
  246.         SINGLEBORDER, TRUE, TRUE, TRUE);
  247.    DefineWindow(&(window_ptr[1]), 15, 45, 7, 34,
  248.         TEXT_BLUE, TEXT_WHITE, "NON-EXPLODING/IMPLODING WINDOW",
  249.         SINGLEBORDER, FALSE, FALSE, TRUE);
  250.  
  251.  
  252.    /*--------------------------------------------*/
  253.    /* Now display and remove both several times. */
  254.    /*--------------------------------------------*/
  255.    for (i=1;i<6;i++)
  256.    {
  257.       DisplayWindow(window_ptr[0]);
  258.       DisplayWindow(window_ptr[1]);
  259.       delay(18);
  260.       RemoveWindow(window_ptr[0]);
  261.       RemoveWindow(window_ptr[1]);
  262.    }
  263.  
  264.    /*-----------------------------*/
  265.    /* Finally delete the windows. */
  266.    /*-----------------------------*/
  267.    DeleteWindow(window_ptr[0]);
  268.    DeleteWindow(window_ptr[1]);
  269.  
  270.    return(0);
  271. }
  272.  
  273.  
  274.  
  275.  
  276.  
  277. /*-------------------------------------------------*/
  278. /*               Multiple_Window                   */
  279. /* This routine is intended to show the user the   */
  280. /* ability of VISIONS to display numerous windows. */
  281. /* In this routine 28 windows are displayed on the */
  282. /* screen.  The maximum number of windows that can */
  283. /* be defined at any one time is dependent on the  */
  284. /* size of the windows, whether or not they are    */
  285. /* popup windows, and how much of the heap is being*/
  286. /* used for other purposes.  Over 100 medium size  */
  287. /* popup windows is easily attained.               */
  288. /*-------------------------------------------------*/
  289. int Multiple_Window()
  290. {
  291.    WINDOW_HEAD *(window_ptr[28]);
  292.    int i;
  293.  
  294.    /*---------------------------------------------------*/
  295.    /* Define all the windows using a variety of colors. */
  296.    /*---------------------------------------------------*/
  297.    DefineWindow(&(window_ptr[0]), 7, 64, 5, 15,
  298.         TEXT_LBLUE, TEXT_BLACK, "WINDOW # 1",
  299.         SINGLEBORDER, TRUE, TRUE, TRUE);
  300.    DefineWindow(&(window_ptr[1]), 20, 3, 5, 20,
  301.         TEXT_BROWN, TEXT_LBLUE, "WINDOW # 2",
  302.         DOUBLEBORDER, TRUE, FALSE, TRUE);
  303.    DefineWindow(&(window_ptr[2]), 14, 34, 8, 18,
  304.         TEXT_BLUE, TEXT_LRED, "WINDOW # 3",
  305.         NOBORDER, TRUE, FALSE, TRUE);
  306.    DefineWindow(&(window_ptr[3]), 17, 59, 5, 20,
  307.         TEXT_BLACK, TEXT_LCYAN, "WINDOW # 4",
  308.         DOUBLEBORDER, FALSE, TRUE, TRUE);
  309.    DefineWindow(&(window_ptr[4]), 1, 12, 5, 35,
  310.         TEXT_GREEN, TEXT_LMAGENTA, "WINDOW # 5",
  311.         NOBORDER, FALSE, TRUE, TRUE);
  312.    DefineWindow(&(window_ptr[5]), 4, 44, 6, 16,
  313.         TEXT_RED, TEXT_BWHITE, "WINDOW # 6",
  314.         SINGLEBORDER, FALSE, TRUE, TRUE);
  315.    DefineWindow(&(window_ptr[6]), 20, 55, 5, 21,
  316.         TEXT_BLUE, TEXT_BWHITE, "WINDOW # 7",
  317.         DOUBLEBORDER, TRUE, FALSE, TRUE);
  318.    DefineWindow(&(window_ptr[7]), 19, 21, 5, 17,
  319.         TEXT_RED, TEXT_WHITE, "WINDOW # 8",
  320.         SINGLEBORDER, TRUE, FALSE, TRUE);
  321.    DefineWindow(&(window_ptr[8]), 9, 23, 6, 18,
  322.         TEXT_BLACK, TEXT_YELLOW, "WINDOW # 9",
  323.         NOBORDER, FALSE, TRUE, TRUE);
  324.    DefineWindow(&(window_ptr[9]), 14, 31, 5, 20,
  325.         TEXT_WHITE, TEXT_GREEN, "WINDOW # 10",
  326.         DOUBLEBORDER, FALSE, FALSE, TRUE);
  327.    DefineWindow(&(window_ptr[10]), 17, 2, 6, 19,
  328.         TEXT_YELLOW, TEXT_BLACK, "WINDOW # 11",
  329.         SINGLEBORDER, TRUE, TRUE, TRUE);
  330.    DefineWindow(&(window_ptr[11]), 18, 16, 4, 17,
  331.         TEXT_WHITE, TEXT_CYAN, "WINDOW # 12",
  332.         NOBORDER, TRUE, TRUE, TRUE);
  333.    DefineWindow(&(window_ptr[12]), 13, 61, 6, 20,
  334.         TEXT_WHITE, TEXT_BROWN, "WINDOW # 13",
  335.         SINGLEBORDER, TRUE, TRUE, TRUE);
  336.    DefineWindow(&(window_ptr[13]), 1, 63, 7, 16,
  337.         TEXT_BLUE, TEXT_BWHITE, "WINDOW # 14",
  338.         SINGLEBORDER, TRUE, TRUE, TRUE);
  339.    DefineWindow(&(window_ptr[14]), 1, 1, 5, 15,
  340.         TEXT_LBLUE, TEXT_BLACK, "WINDOW # 15",
  341.         SINGLEBORDER, TRUE, TRUE, TRUE);
  342.    DefineWindow(&(window_ptr[15]), 5, 5, 5, 20,
  343.         TEXT_BROWN, TEXT_LBLUE, "WINDOW # 16",
  344.         DOUBLEBORDER, TRUE, FALSE, TRUE);
  345.    DefineWindow(&(window_ptr[16]), 2, 8, 8, 18,
  346.         TEXT_BLUE, TEXT_LRED, "WINDOW # 17",
  347.         NOBORDER, TRUE, FALSE, TRUE);
  348.    DefineWindow(&(window_ptr[17]), 10, 59, 5, 20,
  349.         TEXT_BLACK, TEXT_LCYAN, "WINDOW # 18",
  350.         DOUBLEBORDER, FALSE, TRUE, TRUE);
  351.    DefineWindow(&(window_ptr[18]), 19, 32, 5, 35,
  352.         TEXT_GREEN, TEXT_LMAGENTA, "WINDOW # 19",
  353.         NOBORDER, FALSE, TRUE, TRUE);
  354.    DefineWindow(&(window_ptr[19]), 8, 24, 6, 16,
  355.         TEXT_RED, TEXT_BWHITE, "WINDOW # 20",
  356.         SINGLEBORDER, FALSE, TRUE, TRUE);
  357.    DefineWindow(&(window_ptr[20]), 10, 1, 5, 21,
  358.         TEXT_BLUE, TEXT_BWHITE, "WINDOW # 21",
  359.         DOUBLEBORDER, TRUE, FALSE, TRUE);
  360.    DefineWindow(&(window_ptr[21]), 19, 61, 5, 17,
  361.         TEXT_RED, TEXT_WHITE, "WINDOW # 22",
  362.         SINGLEBORDER, TRUE, FALSE, TRUE);
  363.    DefineWindow(&(window_ptr[22]), 10, 35, 6, 18,
  364.         TEXT_BLACK, TEXT_YELLOW, "WINDOW # 23",
  365.         NOBORDER, FALSE, TRUE, TRUE);
  366.    DefineWindow(&(window_ptr[23]), 4, 11, 5, 20,
  367.         TEXT_WHITE, TEXT_GREEN, "WINDOW # 24",
  368.         DOUBLEBORDER, FALSE, FALSE, TRUE);
  369.    DefineWindow(&(window_ptr[24]), 6, 52, 6, 19,
  370.         TEXT_YELLOW, TEXT_BLACK, "WINDOW # 25",
  371.         SINGLEBORDER, TRUE, TRUE, TRUE);
  372.    DefineWindow(&(window_ptr[25]), 18, 36, 4, 17,
  373.         TEXT_WHITE, TEXT_CYAN, "WINDOW # 26",
  374.         NOBORDER, TRUE, TRUE, TRUE);
  375.    DefineWindow(&(window_ptr[26]), 16, 61, 6, 20,
  376.         TEXT_WHITE, TEXT_BROWN, "WINDOW # 27",
  377.         SINGLEBORDER, TRUE, TRUE, TRUE);
  378.    DefineWindow(&(window_ptr[27]), 5, 63, 7, 16,
  379.         TEXT_BLUE, TEXT_BWHITE, "WINDOW # 28",
  380.         SINGLEBORDER, TRUE, TRUE, TRUE);
  381.  
  382.    /*------------------------------*/
  383.    /* Now display all the windows. */
  384.    /*------------------------------*/
  385.    for (i=0;i<28;i++)
  386.    {
  387.       DisplayWindow(window_ptr[i]);
  388.       delay(12);   /* Slight pause between window displays. */
  389.    }
  390.  
  391.    /*-----------------------------------------*/
  392.    /* Big pause before we remove the windows. */
  393.    /*-----------------------------------------*/
  394.    for (i=0;i<28;i++)
  395.       delay(10);
  396.  
  397.    /*-----------------------------*/
  398.    /* Now remove all the windows. */
  399.    /*-----------------------------*/
  400.    for (i=27;i>=0;i--)
  401.    {
  402.       delay(12);   /* Slight pause between window removals. */
  403.       RemoveWindow(window_ptr[i]);
  404.       DeleteWindow(window_ptr[i]);
  405.    }
  406.  
  407.    return(0);
  408. }
  409.  
  410.  
  411.  
  412. /*-------------------------------------------------*/
  413. /*              Interactive_Windows                */
  414. /* This routine allows the user to define a window */
  415. /* including colors, sizes, borders, titles, and   */
  416. /* screen positions in an interactive way.         */
  417. /*-------------------------------------------------*/
  418. int Interactive_Windows()
  419. {
  420.    WINDOW_HEAD *window_ptr;
  421.    MENU_HEAD *bkcol_menu, *txtcol_menu, *border_menu;
  422.    MENU_HEAD *popup_menu, *implode_menu, *explode_menu;
  423.    FORM_HEAD *coord_form;
  424.    BYTE row, col, heighth, width;
  425.    long int bkcol, txtcol;
  426.    char title[81];
  427.    char s_row[3], s_col[3], s_heighth[3], s_width[3];
  428.    BYTE border;
  429.    BYTE explode, implode, popup;
  430.    int key=0;
  431.  
  432.  
  433.    Interactive_Info();     /* Tell the user what's about to happen. */
  434.  
  435.    /*---------------------------------------*/
  436.    /* Create the text color selection menu. */
  437.    /*---------------------------------------*/
  438.    MakeColorMenu(&txtcol_menu,"Select Text Color");
  439.  
  440.    /*---------------------------------------------*/
  441.    /* Create the background color selection menu. */
  442.    /*---------------------------------------------*/
  443.    MakeColorMenu(&bkcol_menu,"Select Background Color");
  444.  
  445.    /*-----------------------------------------*/
  446.    /* Create the border style selection menu. */
  447.    /*-----------------------------------------*/
  448.    DefineMenu(&border_menu,12,12,1,1,SINGLEBORDER,HOT_EXEC_ON,
  449.         TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Select Border");
  450.    AddToMenu(border_menu, "No Border", 'N', NOBORDER, NULL);
  451.    AddToMenu(border_menu, "Single Line Border", 'S', SINGLEBORDER, NULL);
  452.    AddToMenu(border_menu, "Double Line Border", 'D', DOUBLEBORDER, NULL);
  453.  
  454.    /*--------------------------------*/
  455.    /* Create the pop-up enable menu. */
  456.    /*--------------------------------*/
  457.    DefineMenu(&popup_menu,14,14,1,1,SINGLEBORDER,HOT_EXEC_ON,
  458.         TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Popup Style");
  459.    AddToMenu(popup_menu, "TRUE", 'T', 1, NULL);
  460.    AddToMenu(popup_menu, "FALSE", 'F', 2, NULL);
  461.  
  462.    /*------------------------------------------*/
  463.    /* Create the exploding window enable menu. */
  464.    /*------------------------------------------*/
  465.    DefineMenu(&explode_menu,14,14,1,1,SINGLEBORDER,HOT_EXEC_ON,
  466.         TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Exploding Style");
  467.    AddToMenu(explode_menu, "TRUE", 'T', 1, NULL);
  468.    AddToMenu(explode_menu, "FALSE", 'F', 2, NULL);
  469.  
  470.    /*------------------------------------------*/
  471.    /* Create the imploding window enable menu. */
  472.    /*------------------------------------------*/
  473.    DefineMenu(&implode_menu,14,14,1,1,SINGLEBORDER,HOT_EXEC_ON,
  474.         TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,"Imploding Style");
  475.    AddToMenu(implode_menu, "TRUE", 'T', 1, NULL);
  476.    AddToMenu(implode_menu, "FALSE", 'F', 2, NULL);
  477.  
  478.    /*-----------------------------------------------------*/
  479.    /* Create the window coordinates and title entry form. */
  480.    /*-----------------------------------------------------*/
  481.    MakeCoordForm(&coord_form, title, s_row, s_col, s_heighth, s_width);
  482.  
  483.    while (key != ESC)
  484.    {
  485.  
  486.       /*--------------------------------------------------------*/
  487.       /* Execute all the menus and forms to specify the window. */
  488.       /*--------------------------------------------------------*/
  489.       if (FormEntry(coord_form) == -1) goto exit;
  490.       /*---------------------------------*/
  491.       /* Convert the inputs to integers. */
  492.       /*---------------------------------*/
  493.       row = atoi(s_row);       col = atoi(s_col);
  494.       width = atoi(s_width);   heighth = atoi(s_heighth);
  495.  
  496.       if ((bkcol = AutoDisplayMenu(bkcol_menu)) == -1) goto exit;
  497.       bkcol = ColorConvert((int)bkcol);   /* Convert colors to numbers. */
  498.       if ((txtcol = AutoDisplayMenu(txtcol_menu)) == -1) goto exit;
  499.       txtcol = ColorConvert((int)txtcol);
  500.       if ((border = AutoDisplayMenu(border_menu)) == -1) goto exit;
  501.       if ((popup = AutoDisplayMenu(popup_menu)) == -1) goto exit;
  502.       if (popup == 2) popup = FALSE; else popup = TRUE;
  503.       if ((explode = AutoDisplayMenu(explode_menu)) == -1) goto exit;
  504.       if (explode == 2) explode = FALSE; else explode = TRUE;
  505.       if ((implode = AutoDisplayMenu(implode_menu)) == -1) goto exit;
  506.       if (implode == 2) implode = FALSE; else implode = TRUE;
  507.  
  508.       /*----------------------------------------*/
  509.       /* Tell the user to hit keys to continue. */
  510.       /*----------------------------------------*/
  511.       ErrWindow(
  512.        "Hit any key to see your window, and then another key to continue.");
  513.  
  514.       /*------------------------------------*/
  515.       /* Display the user's defined window. */
  516.       /*------------------------------------*/
  517.       DefineWindow(&window_ptr, row, col, heighth, width,
  518.         bkcol, txtcol, title, border, explode, implode, popup);
  519.  
  520.       DisplayWindow(window_ptr);
  521.  
  522.       /*---------------------------------*/
  523.       /* Force a key strike to continue. */
  524.       /*---------------------------------*/
  525.       GetKey();
  526.  
  527.       RemoveWindow(window_ptr);  /* And destroy the user's window. */
  528.       DeleteWindow(window_ptr);
  529.  
  530.    }
  531.  
  532.    /*-------------------------------------------------------*/
  533.    /* Destroy all the window specification forms and menus. */
  534.    /*-------------------------------------------------------*/
  535.    DeleteMenu(txtcol_menu);
  536.    DeleteMenu(bkcol_menu);
  537.    DeleteMenu(border_menu);
  538.    DeleteForm(coord_form);
  539. exit:
  540.    return(0);
  541. }
  542.  
  543.  
  544.  
  545.  
  546. /*------------------------------------------------------*/
  547. /*                 Interactive_Info                     */
  548. /* This routine displays a window of information to the */
  549. /* user, telling him what is about to happen with the   */
  550. /* interactive window demonstration.                    */
  551. /*------------------------------------------------------*/
  552. int Interactive_Info()
  553. {
  554.    WINDOW_HEAD *info_window;
  555.  
  556.    /*--------------------------------*/
  557.    /* Define and display the window. */
  558.    /*--------------------------------*/
  559.    DefineWindow(&info_window, 5, 3, 17, 67, TEXT_BLUE, TEXT_WHITE, 
  560.      "Interactive VISIONS Window Demonstration Introduction", 
  561.      SINGLEBORDER, TRUE, TRUE, TRUE);
  562.  
  563.    DisplayWindow(info_window);
  564.  
  565.    WindMesg(5,3,"The following is an interactive window display routine.  This");
  566.    WindMesg(6,3,"routine allows you to specify a window's coordinates, size, ");
  567.    WindMesg(7,3,"title, borders, colors, and display options, and then see the ");
  568.    WindMesg(8,3,"result interactively.  A series of forms and menus is used ");
  569.    WindMesg(9,3,"to allow you to enter your window's specifications.  Failing ");
  570.    WindMesg(10,3,"to correctly specify a window's coordinates or size may cause ");
  571.    WindMesg(11,3,"the window to be undisplayable.  Should this happen, just ");
  572.    WindMesg(12,3,"change your specifications and try again.  The interactive ");
  573.    WindMesg(13,3,"window demonstration preserves all your choices between ");
  574.    WindMesg(14,3,"window displays, so that you can default a specification to");
  575.    WindMesg(15,3,"your last selection.");
  576.  
  577.    WindMesg(17,21,"Hit any key to continue.");
  578.  
  579.    GetKey();   /* Force a keystrike to continue. */
  580.  
  581.    RemoveWindow(info_window);  /* And destroy the window. */
  582.    DeleteWindow(info_window);
  583.  
  584.    return(0);
  585. }
  586.  
  587.  
  588.  
  589. /*-----------------------------------*/
  590. /*           MakeColorMenu           */
  591. /* Create the color selection menu   */
  592. /* for the interactive windows demo. */
  593. /*-----------------------------------*/
  594. MakeColorMenu(col_menu,title)
  595. MENU_HEAD **col_menu;
  596. char *title;
  597. {
  598.  
  599.    DefineMenu(col_menu,4,4,1,1,SINGLEBORDER,HOT_EXEC_ON,
  600.         TEXT_BLUE,TEXT_WHITE,TEXT_WHITE,TEXT_BLUE,title);
  601.    AddToMenu(*col_menu, "BLACK", 'B', 1, NULL);
  602.    AddToMenu(*col_menu, "BLUE", 'B', 2, NULL);
  603.    AddToMenu(*col_menu, "GREEN", 'G', 3, NULL);
  604.    AddToMenu(*col_menu, "CYAN", 'C', 4, NULL);
  605.    AddToMenu(*col_menu, "RED", 'R', 5, NULL);
  606.    AddToMenu(*col_menu, "MAGENTA", 'M', 6, NULL);
  607.    AddToMenu(*col_menu, "BROWN", 'B', 7, NULL);
  608.    AddToMenu(*col_menu, "WHITE", 'W', 8, NULL);
  609.    AddToMenu(*col_menu, "DARK GREY", 'D', 9, NULL);
  610.    AddToMenu(*col_menu, "LIGHT BLUE", 'L', 10, NULL);
  611.    AddToMenu(*col_menu, "LIGHT GREEN", 'L', 11, NULL);
  612.    AddToMenu(*col_menu, "LIGHT CYAN", 'L', 12, NULL);
  613.    AddToMenu(*col_menu, "LIGHT RED", 'L', 13, NULL);
  614.    AddToMenu(*col_menu, "LIGHT MAGENTA", 'L', 14, NULL);
  615.    AddToMenu(*col_menu, "YELLOW", 'Y', 15, NULL);
  616.    AddToMenu(*col_menu, "BRIGHT WHITE", 'B', 16, NULL);
  617.  
  618.    return(0);
  619. }
  620.  
  621.  
  622.  
  623. /*----------------------------------------------*/
  624. /*                MakeCoordForm                 */
  625. /* Create the coordinate selection and title    */
  626. /* entry form for the interactive windows demo. */
  627. /*----------------------------------------------*/
  628. int MakeCoordForm(coord_form, title, s_row, s_col, s_heighth, s_width)
  629. FORM_HEAD **coord_form;
  630. char *title;
  631. char *s_row, *s_col, *s_heighth, *s_width;
  632. {
  633.    FORM_FIELD *field_ptr;
  634.  
  635.    DefineForm(coord_form,2,5,12,60,SINGLEBORDER,
  636.       TEXT_BLUE,TEXT_WHITE,"Window Title and Coordinates");
  637.    AddToForm(*coord_form, *IntOnly, &field_ptr);
  638.    AddToPrompt(field_ptr, 5, 2, 21, TEXT_BLUE,TEXT_WHITE,
  639.       TEXT_WHITE,TEXT_BLUE,"Top Left Corner  Row:");
  640.    strcpy(s_row,"");
  641.    AddToText(field_ptr, 5, 27, 2, TEXT_BLACK,TEXT_WHITE,
  642.       TEXT_WHITE,TEXT_BLACK,s_row);
  643.  
  644.    AddToForm(*coord_form, *IntOnly, &field_ptr);
  645.    AddToPrompt(field_ptr, 6, 19, 7, TEXT_BLUE,TEXT_WHITE,
  646.       TEXT_WHITE,TEXT_BLUE,"Column:");
  647.    strcpy(s_col,"");
  648.    AddToText(field_ptr, 6, 27, 2, TEXT_BLACK,TEXT_WHITE,
  649.       TEXT_WHITE,TEXT_BLACK,s_col);
  650.  
  651.    AddToForm(*coord_form, *IntOnly, &field_ptr);
  652.    AddToPrompt(field_ptr, 7, 19, 7, TEXT_BLUE,TEXT_WHITE,
  653.       TEXT_WHITE,TEXT_BLUE,"Height:");
  654.    strcpy(s_heighth,"");
  655.    AddToText(field_ptr, 7, 27, 2, TEXT_BLACK,TEXT_WHITE,
  656.       TEXT_WHITE,TEXT_BLACK,s_heighth);
  657.  
  658.    AddToForm(*coord_form, *IntOnly, &field_ptr);
  659.    AddToPrompt(field_ptr, 8, 19, 7, TEXT_BLUE,TEXT_WHITE,
  660.       TEXT_WHITE,TEXT_BLUE,"Width:");
  661.    strcpy(s_width,"");
  662.    AddToText(field_ptr, 8, 27, 2, TEXT_BLACK,TEXT_WHITE,
  663.       TEXT_WHITE,TEXT_BLACK,s_width);
  664.  
  665.    AddToForm(*coord_form, NULL, &field_ptr);
  666.    AddToPrompt(field_ptr, 10, 2, 6, TEXT_BLUE,TEXT_WHITE,
  667.       TEXT_WHITE,TEXT_BLUE,"Title:");
  668.    strcpy(title,"");
  669.    AddToText(field_ptr, 10, 9, 45, TEXT_BLACK,TEXT_WHITE,
  670.       TEXT_WHITE,TEXT_BLACK,title);
  671.  
  672.    return(0);
  673. }
  674.  
  675.  
  676.  
  677. /*-----------------------------------------------*/
  678. /*               Window_Intro                    */
  679. /* Introduce the user to this demonstration,     */
  680. /* explaining the purpose and what is happening. */
  681. /*-----------------------------------------------*/
  682. int Window_Intro()
  683. {
  684.    WINDOW_HEAD *intro_window;
  685.  
  686.    DefineWindow(&intro_window, 1, 1, 24, 80,
  687.         TEXT_BLUE, TEXT_WHITE, "VISIONS Window Demonstration Introduction",
  688.         SINGLEBORDER, FALSE, FALSE, TRUE);
  689.    DisplayWindow(intro_window);
  690.    WindMesg(9,5,"   The VISIONS window library demonstration is intended to introduce ");
  691.    WindMesg(10,5," the user to the window library concepts and functions through the ");
  692.    WindMesg(11,5," use of several separate window examples.  The first examples are user ");
  693.    WindMesg(12,5," passive demonstrations, where all the possible window colors and types");
  694.    WindMesg(13,5," are displayed.  The last demonstration is user interactive, allowing");
  695.    WindMesg(14,5," the user to set all the parameters associated with a window, and then");
  696.    WindMesg(15,5," display the result.  The source code used to create this demonstration");
  697.    WindMesg(16,5," is supplied with the executable.  Please remember that all VISIONS");
  698.    WindMesg(17,5," windows are text windows, graphics windows are not supported.");
  699.  
  700.    WindMesg(24,28,"Hit any key to continue.");
  701.  
  702.    GetKey();    /* Wait for a user keystroke. */
  703.  
  704.    RemoveWindow(intro_window);    /* And destroy the window. */
  705.    DeleteWindow(intro_window);
  706.  
  707.    return(0);
  708. }
  709.  
  710.  
  711.  
  712. /*-----------------------------------------------*/
  713. /*               ColorConvert                    */
  714. /* This routine converts integer values returned */
  715. /* from a menu, to long integer colors used by   */
  716. /* the interactive window demonstration.         */
  717. /*-----------------------------------------------*/
  718. long int ColorConvert(color)
  719. int color;
  720. {
  721.    long int retcolor;
  722.  
  723.    switch (color)
  724.    {
  725.    case 1:
  726.         retcolor = TEXT_BLACK;
  727.         break;
  728.    case 2:
  729.         retcolor = TEXT_BLUE;
  730.         break;
  731.    case 3:
  732.         retcolor = TEXT_GREEN;
  733.         break;
  734.    case 4:
  735.         retcolor = TEXT_CYAN;
  736.         break;
  737.    case 5:
  738.         retcolor = TEXT_RED;
  739.         break;
  740.    case 6:
  741.         retcolor = TEXT_MAGENTA;
  742.         break;
  743.    case 7:
  744.         retcolor = TEXT_BROWN;
  745.         break;
  746.    case 8:
  747.         retcolor = TEXT_WHITE;
  748.         break;
  749.    case 9:
  750.         retcolor = TEXT_DGREY;
  751.         break;
  752.    case 10:
  753.         retcolor = TEXT_LBLUE;
  754.         break;
  755.    case 11:
  756.         retcolor = TEXT_LGREEN;
  757.         break;
  758.    case 12:
  759.         retcolor = TEXT_LCYAN;
  760.         break;
  761.    case 13:
  762.         retcolor = TEXT_LRED;
  763.         break;
  764.    case 14:
  765.         retcolor = TEXT_LMAGENTA;
  766.         break;
  767.    case 15:
  768.         retcolor = TEXT_YELLOW;
  769.         break;
  770.    case 16:
  771.    default:
  772.         retcolor = TEXT_BWHITE;
  773.         break;
  774.    }
  775.  
  776.    return(retcolor);
  777. }
  778.  
  779.  
  780.  
  781.  
  782. /*-------------------------------*/
  783. /*            delay              */
  784. /* This routine provides a brute */
  785. /* force code loop delay.        */
  786. /*-------------------------------*/
  787. delay(num)
  788. {
  789.    long int i, k, j;
  790.  
  791.    for (k=0; k<num; k++)
  792.       for (i=0;i<600L;i++)
  793.          j = 3/5 + i;
  794. }
  795.