home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c003 / 1.ddi / DEMOS / MENU.DOC < prev    next >
Encoding:
Text File  |  1986-11-26  |  2.7 KB  |  80 lines

  1.       menu2.c -- a menu display and selection routine
  2.  
  3.     ************* Copyright 1985 by Vermont Creative Software **************
  4.  
  5.  
  6.     USAGE
  7.  
  8.     To display a pop-up menu on a screen, allow menu selection, and then
  9.     restore the original screen content.
  10.  
  11.     FUNCTION
  12.  
  13.     This function displays a menu that resides in a memory file.
  14.  
  15.     Menus have the following format:
  16.  
  17.      Menus can consist of any number of items.
  18.  
  19.      Menu items can be arranged in one or more rows, and each row can
  20.      have one or more items.  The same number of items must be on each
  21.      row except the last one.
  22.  
  23.      The same space must be allocated to each item in the menu.  Use
  24.      spaces to pad items to make them all the same length.
  25.  
  26.     The window in which the menu is to be displayed is passed as an
  27.     argument of menu2().  Additional parameters specify the number of items
  28.     in the menu, number of characters per item, the number of items per row
  29.     and the default position of the bar cursor.
  30.  
  31.     The menu-window is made a pop-up window.
  32.  
  33.     The menu-window is placed on the screen and the menu text moved to the
  34.     window.
  35.  
  36.     The default item is highlighted.
  37.  
  38.      Highlighting is accomplished by using a sub-window that is
  39.      one-menu item in size.  The sub-window is placed over the menu
  40.      item, and v_natt is called to change the text attribute within the
  41.      window to REVERSE or LREVERSE.
  42.  
  43.     Cursor pad keys are used to move the highlight area to other menu
  44.     items.
  45.  
  46.     Pressing the enter key "selects" the menu item highlighted, which
  47.     causes the following sequence:
  48.  
  49.      The original screen is restored.
  50.  
  51.      The code number of the menu item is returned on exit.
  52.  
  53.      The cursor is restored to its original position.
  54.  
  55.     Source code for this function is included on the system diskette.
  56.  
  57.     COMMENT
  58.  
  59.     This program illustrates how the capabilities of Windows for C can be
  60.     used to program a high-quality menu selection display.
  61.  
  62.     Pop-up windows are implemented just by designating the window to be
  63.     a pop-up as opposed to an overwrite window.
  64.  
  65.     The capability to change the attribute of a section of a window is
  66.     provided by v_natt().
  67.  
  68.      v_natt() is used in menu() to highlight the selected menu items.
  69.  
  70.      Highlighting is accomplished by placing a small window just the
  71.      size of one menu-item space over the menu item and then using
  72.      v_natt() to change the attribute of the window to REVERSE.
  73.  
  74.      When a menu item is de-selected, v_natt() is used to restore the
  75.      original attribute.
  76.  
  77.     The status line that displays the number of the selected menu item
  78.     provides another illustration of the ability of Windows for C to
  79.     simplify screen management.
  80.