home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 12 / CD_ASCQ_12_0294.iso / vrac / panshr24.zip / PANELS24.DOC < prev    next >
Text File  |  1993-11-17  |  16KB  |  478 lines

  1.  
  2.  
  3.  
  4.  
  5.   ▒▒▒▒▒▒▄ ▒▒▒▒▒▒▄ ▒▒▒▄▄ ▒▒▄ ▒▒▒▒▒▒▄ ▒▒▄     ▒▒▒▒▒▒▄              ▒▒▒▒▒▒▄
  6.   ▒▒█▀▒▒█ ▒▒█▀▒▒█ ▒▒█▒▒█▒▒█ ▒▒█▀▀▀▀ ▒▒█     ▒▒█▀▀▀▀     F        ▒▒█▀▀▀▀
  7.   ▒▒▒▒▒▒█ ▒▒▒▒▒▒█ ▒▒█ ▀▒▒▒█ ▒▒▒▒▒▄  ▒▒█     ▒▒▒▒▒▒▄       O      ▒▒█
  8.   ▒▒█▀▀▀▀ ▒▒█ ▒▒█ ▒▒█   ▒▒█ ▒▒█▀▀▀  ▒▒█      ▀▀▀▒▒█         R    ▒▒█
  9.   ▒▒█     ▒▒█ ▒▒█ ▒▒█   ▒▒█ ▒▒▒▒▒▒▄ ▒▒▒▒▒▒▄ ▒▒▒▒▒▒█              ▒▒▒▒▒▒▄
  10.    ▀▀      ▀▀  ▀▀  ▀▀    ▀▀  ▀▀▀▀▀▀  ▀▀▀▀▀▀  ▀▀▀▀▀▀               ▀▀▀▀▀▀
  11.  
  12.  
  13.  
  14.                            Version 2.4
  15.  
  16.                         A User Interface
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.                            BC Systems
  41.                           7801 Dublin
  42.                        Wichita, KS  67206
  43.  
  44.                         CIS: 73171,2442
  45.  
  46.  
  47.                   Copyright 1989-1993, Jay Brown
  48.  
  49.  
  50. I. Overview
  51.  
  52. "Panels for C" is a set of routines which may be called by your
  53. Application program to do screen oriented input and output.  Screen
  54. layouts, or panels, are simple text files that you can create with
  55. an ordinary word processor.  Panels always have a file extension of
  56. PAN.  The format of a panel is covered in a later section.
  57.  
  58. A panel definition may reside in its own file separate from your
  59. application source code, or it may be defined as a string within
  60. your application code.  The advantage for a separate file is the
  61. interpreted nature of the screen layout.  The panel may be changed
  62. without recompiling the application program.  The advantage of
  63. using a string to define the panel is reduced disk I/O during the
  64. execution of your program.
  65.  
  66. The author recommends that during the development of an
  67. application, panels are defined within their own files.  When an
  68. application is compiled for production, you may consider moving the
  69. panel definitions to the program source for efficiency and
  70. security.  A utility call PAN2H has been created to translate a
  71. panel file to a C header file.  Also, a utility to simplify the
  72. creation and modification of panels has been developed, called IPD
  73. (Interactive Panel Design).
  74.  
  75. Panels for C is distributed as shareware.  This software is
  76. protected by copyright laws.  Users may register by purchasing
  77. either the object or source packages, see the enclosed order form. 
  78. Registered users can expect the software to be supported by the
  79. publisher.  Also, notification of future releases can be expected. 
  80. BC Systems grants to purchasers of either object or source packages
  81. a no-fee license to resell applications created with the Panel
  82. routines.  The only constraint is that the application code and
  83. documentation MUST contain the following acknowledgement:  
  84.  
  85.              Portions copyright 1989-1993, J. Brown.
  86.  
  87.  
  88.  
  89. II. Executing a Panels Program
  90.  
  91. While a panel is active, during the execution of a panels
  92. application program, the following keys are used for data input:
  93.  
  94. <Right Tab>    Moves cursor to the next unprotected screen field.
  95.  
  96. <Left Tab>     Moves cursor to the previous unprotected screen
  97.                field.
  98.  
  99. <Enter>        Moves cursor to the first unprotected screen field
  100.                on the next line.
  101.  
  102. <Home>         Moves cursor to the first unprotected screen field.
  103.  
  104. <End>          Move cursor to the end of the current field.
  105.  
  106. <Ins>          Toggles insert mode on and off.  The cursor is a
  107.                little larger when insert mode is on.
  108.  
  109. <Del>          Deletes the character under the cursor.
  110.  
  111. <Ctrl><End>    Erase to end of field.
  112.  
  113. <Arrows>       Moves the cursor in the appropriate direction,
  114.                possibly into a protected area.  A click will be
  115.                heard, if attempting to enter data into a protected
  116.                area.
  117.  
  118. <Func keys> <Page Up> <Page Down> <Esc>
  119.                When one of these keys is pressed execution returns
  120.                to the application program.  These response keys
  121.                are the default, and any keystroke can be
  122.                configured as a response key by the application
  123.                programmer.
  124.  
  125.  
  126. III. Panel Design
  127.  
  128.                         Text File Format
  129.  
  130. A panel text file begins with an optional size statement followed
  131. by an optional background statement.  One or more tag statements
  132. are used to relate field attributes and field names to special
  133. characters or symbols.  After the tag statements is the actual
  134. screen layout, which must begin with a tagged symbol.
  135.  
  136.   size <ul_row> <ul_col> <lr_row> <lr_col>
  137.   background <color>
  138.   tag <sym> <attr> [<variable list>]
  139.          .
  140.          .
  141.          .
  142.   <symbol>..................................
  143.   ..........................................
  144.   ..........................................
  145.          .
  146.          .
  147.          .
  148.  
  149.  
  150.                          Size Statement
  151.  
  152. This is an optional panel statement, and if present must precede
  153. the background statement or the first tag statement.  This
  154. statement simply sets the size and location of the window in which
  155. the panel will be constructed.
  156.  
  157.   Format:
  158.     size <ul_row> <ul_col> <lr_row> <lr_col>
  159.  
  160.   where:
  161.     <ul_row> upper left row of the window
  162.     <ul_col> upper left column of the window
  163.     <lr_row> lower right row of the window
  164.     <lr_col> lower right window column 
  165.  
  166.   Example:
  167.     size 0 0 13 39  Defines a panel to be 14 rows by 40 columns
  168.                     located in the upper left part of the screen.
  169.  
  170.  
  171. If a size statement is not present within a panel definition, the
  172. default window coordinates are 0,0 and 24,79.  If a panel is
  173. defined to be smaller than the previous active panel, the previous
  174. panel will be partially visible behind the new panel.  However, the
  175. overlaid panel will not be active again until the new panel is
  176. destroyed (i.e. no I/O functions may be performed on the previous
  177. panel).
  178.  
  179.  
  180.                       Background Statement
  181.  
  182. This is an optional panel statement, and if present must precede
  183. the first tag statement.  This statement simply sets the screen
  184. background color when a color adapter is in use.  If a monochrome
  185. adapter is in use the background statement is ignored.
  186.  
  187.   Format:
  188.     background <color>
  189.  
  190.   where:  <color> is a digit 0 - 7 
  191.  
  192.   Color codes:  0 = Black (Default)
  193.                 1 = Blue
  194.                 2 = Green
  195.                 3 = Cyan
  196.                 4 = Red
  197.                 5 = Magenta
  198.                 6 = Brown
  199.                 7 = White
  200.  
  201.  
  202.                           Tag Statement
  203.  
  204. A tag statement allows you to relate a special character or symbol
  205. with a field definition.  This definition includes the field
  206. attributes as well as the field names.
  207.  
  208.   Format:
  209.     tag <sym> <attr> [<variable list>]
  210.  
  211.   where:
  212.     <sym>      is one character symbol not used anywhere on the
  213.                actual screen layout.  This symbol will relate
  214.                screen attributes and field names to specific
  215.                locations on the screen.
  216.  
  217.     <Attr>     is the field attribute.  
  218.  
  219.   Attribute codes:
  220.           P = Protected
  221.           U = Unprotected (Default)
  222.           H = High Intensity
  223.           L = Low Intensity (Default)
  224.           B = Blink
  225.           R = Reverse
  226.           _ = Underline
  227.           D = Dark
  228.           0 = Black 
  229.           1 = Blue
  230.           2 = Green
  231.           3 = Cyan
  232.           4 = Red
  233.           5 = Magenta
  234.           6 = Brown
  235.           7 = White (Default)
  236.  
  237. Some attributes may have no effect with certain monitor types (i.e.
  238. the color codes will have no effect when using a monochrome display
  239. adapter).  Some attributes are mutually exclusive -- either P or U
  240. may be used, but not both; either H or L may be used; and only one
  241. color code may be specified.
  242.  
  243. <variable list>     One or more field names separated by at least
  244.                     one blank.  Valid names are no more than eight
  245.                     characters beginning with a letter.  No
  246.                     special characters are allowed.
  247.  
  248. Each variable or field name is matched to a field on the screen
  249. layout.  If more fields are defined with the tag symbol than
  250. variables in the list, the last variable name in the list is used
  251. to name the remaining fields.  In this case, a subscript other than
  252. 1 is used to access like named fields.
  253.  
  254.  
  255.                             Examples
  256.  
  257.  
  258.  
  259. In this example, there are two unprotected fields.  The first field
  260. may be accessed using the name FIELD subscripted by 1, and the
  261. second field is referenced as FIELD with a subscript of 2.
  262.  
  263. The screen background color is defined to be blue.  The ! symbol
  264. defines protected red fields.  The @ symbol defines protected,
  265. reverse fields with white characters.  The asterisk tagged field is
  266. named SELECT and will be unprotected, underlined and green.
  267.  
  268. The screen background color is defined to be white.  The ! symbol
  269. defines protected red fields.  This example demonstrates the use of
  270. the size statement.  The panel is defined as a 7 x 27 character box
  271. to be displayed in the lower right part of the screen.
  272.  
  273.  
  274.                           Panel Design
  275.  
  276. Try your hand at designing your own panel!  Use any word processor
  277. to create the panel file.  Be sure your file has an extension of
  278. PAN.
  279.  
  280. Optionally, you may use IPD to create and modify a panel, type:
  281.  
  282.                            ipd [<fn>]
  283.  
  284. After your panel text file has been created, type:
  285.  
  286.                           showpan <fn>
  287.  
  288. where <fn> is your panel file name without the .PAN extension.
  289.  
  290.  
  291. IV. Programming with Panels
  292.  
  293. Only a few Panel routines are needed to do complete screen level
  294. I/O with your application program.  What follows here and on
  295. subsequent pages is a description of each routine available to link
  296. with your program.
  297.  
  298. void pan_init();
  299.  
  300.      This routine is used to initialize the Panels for C
  301.      environment.  It determines what video adapter is in use, etc. 
  302.      This function must be called before any of the other functions
  303.      are used.
  304.  
  305. void pan_activate(char *fn);
  306.  
  307.      This routine will paint the screen using the panel defined in
  308.      the text file <fn>.pan.  Memory is allocated for a panel
  309.      variable table.  If a panel was previously active it will
  310.      exist behind the new panel.  Optionally, the character string
  311.      <fn> may be a complete panel definition.  The activate
  312.      function determines whether the string is a file name or a
  313.      panel definition by the presence or absence of a newline
  314.      character within the string.  A file name will not have a
  315.      newline character in it.
  316.  
  317. unsigned pan_execute(char *name, 
  318.                      int sub, 
  319.                      int alarm);
  320.  
  321.      Positions the cursor to the named field or first unprotected
  322.      field if name is NULL.  Sub is the subscript of the name
  323.      field.  A bell will sound if alarm is true.  Control will
  324.      return from this routine when a response key is pressed.  The
  325.      response key code (as defined in keys.h ) is the return value.
  326.  
  327.      The following is a list of global variables assigned values by
  328.      the pan_execute function:
  329.  
  330.           pan_row             Indicates the row on which the
  331.                               cursor was placed prior to detecting
  332.                               a response key from the user.
  333.  
  334.           pan_col             Indicates the column on which the
  335.                               cursor was placed prior to detecting
  336.                               a response key from the user.
  337.  
  338.           pan_field_name Indicates the current field name under
  339.                          the cursor when the user pressed a
  340.                          response key.
  341.  
  342.           pan_field_sub  Indicates the current field subscript
  343.                          under the cursor when the user pressed a
  344.                          response key.
  345.  
  346. void pan_destroy();
  347.  
  348.      This routine frees memory occupied by the panel variable table
  349.      and restores the panel behind the active panel if present.
  350.  
  351. void pan_field_attr(char *name, 
  352.                     int sub, 
  353.                     char *attr);
  354.  
  355.      Changes the screen attributes of the named panel field after
  356.      the  panel has been activated.  Useful for indicating an error
  357.      to the user by highlighting or blinking the contents of the
  358.      erroneous field.
  359.  
  360. void pan_put_field(char *name, 
  361.                    int sub, 
  362.                    char *value);
  363.  
  364.      This routine transfers value to the named panel field.
  365.  
  366. void pan_get_field(char *name, 
  367.                    int sub, 
  368.                    char *value);
  369.  
  370.      This routine transfers the named panel field to value .
  371.  
  372. void pan_sound(int freq, int dur);
  373.  
  374.      Produces a sound of freq frequency and at least dur duration
  375.      on the  speaker.  The duration is in hundredths of a second.
  376.  
  377. void pan_delay(int dur);
  378.  
  379.      Wait for at least dur hundredths of a second to elapse.
  380.  
  381. unsigned pan_get_key();
  382.  
  383.      Wait for a keystroke from the user and return the key code as
  384.      defined within the keys.h header file.
  385.  
  386. void pan_idle_func(int (*func)());
  387.  
  388.      Sets up a user supplied function to be called while
  389.      panel_execute or get_key is waiting for a keystroke from the
  390.      user.  func is a pointer to a function which returns an
  391.      integer value.  The NULLF value, defined within panel.h may be
  392.      used to disable an idle function call.
  393.  
  394. void pan_error(16, int line, char *msg);
  395.  
  396.      Abort the application program by cleaning up any active
  397.      panels.  This function then displays the msg parameter and
  398.      line number if not zero.  The abort code of 16 should be used
  399.      by the application program, other codes are used within the
  400.      panel routines.
  401.  
  402. void pan_resp_keys(unsigned exitkeys[]);
  403.  
  404.      This function allows the programmer to override the default
  405.      response keys.  An array of unsigned integers is passed.  The
  406.      last value within the exitkeys table must be zero.
  407.  
  408. PAN_LIST *pan_linit();
  409.  
  410.      Allocate and initialize a list pick structure.  This function
  411.      returns a pointer to the list pick structure. 
  412.  
  413. void pan_ladd(PAN_LIST *list, char *desc, void *data);
  414.  
  415.      Add a list pick element to the indicated list structure.  desc
  416.      is the text to appear in the list, and "data" is anything
  417.      associated with the element and hidden from the user.
  418.  
  419. void pan_lfree(PAN_LIST *list, int free_desc, int free_data);
  420.  
  421.      Free all memory associated with the indicated list structure. 
  422.      "free_desc" is a flag indicating whether to free memory
  423.      associated with each list item description.  "free_data" is a
  424.      flag indicating whether to free memory associated with each
  425.      hidden data object.
  426.  
  427. void pan_lact(PAN_LIST *list);
  428.  
  429.      This function activates the indicated list structure, i.e.
  430.      makes it visible to the user.
  431.  
  432. unsigned pan_lexec(PAN_LIST *list);
  433.  
  434.      This function executes the indicated list structure, i.e.
  435.      allows the user to make a selection.  The exit key code is
  436.      returned by this function.
  437.  
  438.  
  439. V. Compilation and Linkage
  440.  
  441. Included in the Panels for C package is one or more of the
  442. following object files:
  443.  
  444.      SPANELR.OBJ    MicroSoft C DOS small model 
  445.      LPANELR.OBJ    MicroSoft C DOS large model
  446.      SPANELP.OBJ    MicroSoft C OS/2 small model
  447.      LPANELP.OBJ    MicroSoft C OS/2 large model
  448.      SPANELTC.OBJ   Turbo C DOS small model
  449.      LPANELTC.OBJ   Turbo C DOS large model
  450.  
  451.  
  452.                            MicroSoft C
  453.  
  454. Assuming you have written a DOS program to be compiled with
  455. MicroSoft C, you could use one of the following commands to compile
  456. and link it with the Panel routines:
  457.  
  458.      Small model:
  459.           cl /AS /F 2000 YourPgm.c spanelr.obj  
  460.  
  461.      Large model:
  462.           cl /AL /F 2000 YourPgm.c lpanelr.obj   
  463.  
  464. The /F option sets the size of the program stack for the executable
  465. file.  This must be set to an adequate value.  A makefile is also
  466. included in the package to illustrate how panel programs are built.
  467.  
  468.  
  469.                              Turbo C
  470.  
  471. Using the Turbo C integrated development environment, create a
  472. project file with your source file name and either SPANELTC.OBJ or
  473. LPANELTC.OBJ listed in it.  Select the make EXE option from the
  474. compile menu.
  475.  
  476. For other compilers, consult your reference manual.  Be sure to
  477. include the files PANEL.H and KEYS.H in your source code.
  478.