home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / window / miscutil / c_window.doc < prev    next >
Encoding:
Text File  |  1987-01-16  |  34.0 KB  |  991 lines

  1.  
  2.  
  3.   
  4.             
  5.  
  6.  
  7.        
  8.        
  9.     
  10.       
  11.  
  12.  
  13.  
  14.        
  15.                                                      
  16.                                                     
  17.  
  18.                              C Windowing Toolbox
  19.                              -------------------
  20.  
  21.                                      for
  22.                     IBM Personal Computers and Compatibles
  23.                                  Version 1.2
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.         
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.       IBM, IBM PC are trademarks of International Business Machines Corp.
  59.       Microsoft is a trademark of Microsoft Corp.
  60.       Lattice is a trademark of Lattice Corp.
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                                                       C Windowing Toolbox
  70.    ----------------------------------------------------------------------
  71.  
  72.  
  73.     INTRODUCTION
  74.             
  75.         C Windowing Toolbox is a collection of functions that give 
  76.         windowing capability to the C programmer using an IBM PC or true 
  77.         compatible. The windowing functions are written entirely in 
  78.         Microsoft C and were compiled using the small model for both code 
  79.         and data. It is distributed in .OBJ format, ready to be linked to 
  80.         your Microsoft and Lattice C programs. The source code of the C 
  81.         Windowing Toolbox, compatible with both the Microsoft (Lattice) C 
  82.         version 2.xx compiler and the Microsoft C version 3/4 compiler is 
  83.         available for $15. See the end of this documentation for details.  
  84.  
  85.         The C Windowing Toolbox files are:
  86.         
  87.              C_WINLAT.OBJ       - The compiled windowing code linkable to
  88.                                   programs compiled by the Microsoft 
  89.                                   version 2/Lattice C compiler
  90.  
  91.              C_WINMSC.OBJ       - The compiled windowing code linkable to
  92.                                   programs compiled by the Microsoft
  93.                                   version 3 or 4 C compiler
  94.         
  95.              C_WINDOW.DOC       - The documentation
  96.         
  97.              C_WDEF.H           - Include file for your C code
  98.         
  99.              C_WDEMO.C          - Source of windowing demonstration 
  100.                                   program
  101.         
  102.              C_WDEMO.EXE        - Windowing demonstration program
  103.  
  104.         To use the Windowing functions in your Microsoft/Lattice C 
  105.         program: 
  106.         
  107.          (1) Include the file C_WDEF.H in your C source file.  
  108.              C_WDEF.H defines the windowing functions and associated 
  109.              constants and variables.
  110.  
  111.          (2) Compile your C source using the small code and data model.  
  112.  
  113.          (3) Link the windowing code to your program: 
  114.         
  115.              Microsoft C version 2/Lattice -
  116.  
  117.                LINK CS + yourprog + C_WINLAT, yourprog.EXE,, MCS.LIB
  118.  
  119.              Microsoft C version 3/4 -
  120.  
  121.                LINK yourprog + C_WINMSC; 
  122.  
  123.         To allow other C compilers to compile the windowing source code, 
  124.         standard C syntax is used where-ever possible. There are only 
  125.         three non-standard C functions used: INT86(), PEEK() and POKE().  
  126.         The Microsoft version 2/Lattice C compiler has these functions in 
  127.  
  128.  
  129.                                                                         1
  130.  
  131.  
  132.  
  133.  
  134.  
  135.                                                       C Windowing Toolbox
  136.    ----------------------------------------------------------------------
  137.  
  138.  
  139.         its library. The Microsoft C version 3/4 compiler doesn't support 
  140.         PEEK() and POKE() so suitable versions, written in C, are 
  141.         included in the C_WINDOW.C source file. Microsoft C version 
  142.         2/Lattice compatible versions of the three above functions 
  143.         written in assembler, plus a full explanation, are also on the 
  144.         source code disk. If your compiler doesn't include INT86() PEEK() 
  145.         or POKE(), you can modify either the C or assembler sources 
  146.         mentioned above to suit your compiler. Also, if you don't have an 
  147.         IBM PC or compatible, and you are familiar with reading and 
  148.         writing to the video RAM of your computer, you can adapt the 
  149.         windowing code for use on your PC.  
  150.         
  151.         C_WDEMO.C is the C source of a sample windowing program. It has 
  152.         been compiled as C_WDEMO.EXE and is part of the windowing package.  
  153.  
  154.  
  155.     SCREEN CONCEPTS
  156.  
  157.         An array of bytes, called the window buffer, is used to store 
  158.         each defined window, plus the section of the screen that each 
  159.         window overlays.  The window buffer size has been defined in the 
  160.         windowing code to be 10000 bytes.  This is a compromise value.  
  161.         Larger allows more active window definitions, smaller means a 
  162.         smaller program.  When a window is defined, storage is allocated 
  163.         in the window buffer.  The standard IBM PC screen, in 80 column 
  164.         alphanumeric mode, uses 4000 bytes (80 x 25 x 2) of video RAM.  
  165.         Each character on the screen has a trailing attribute byte that 
  166.         indicates if the character is bright or dark, blinking, red, 
  167.         blue, etc.  10000 bytes is enough to create a window the size of 
  168.         the screen (4000 bytes to save old screen, 4000 for window), plus 
  169.         another little window. Or several medium sized windows.  
  170.  
  171.         C Windowing Toolbox allows deallocation of window storage so you 
  172.         can have as many windows as you like by deallocating and 
  173.         redefining them as needed. The only restriction is that only as 
  174.         many windows as can be defined in the window buffer can be 
  175.         visible at any one time.  
  176.  
  177.         The main reason why the window buffer's size is explicitly 
  178.         defined in the code, rather than using dynamic memory allocation 
  179.         is that if the program can load on a particular computer with x 
  180.         amount of memory, then it will run on that computer. The program 
  181.         is self-contained.  
  182.  
  183.  
  184.     OVERVIEW OF THE WINDOWING FUNCTIONS
  185.             
  186.         YOU MUST ALWAYS CALL W_INIT() BEFORE USING ANY WINDOWING
  187.         FUNCTIONS. Do NOT neglect to do this, as several important data 
  188.         pointers are initialized.  
  189.  
  190.         There are two kinds of functions available: those that are 
  191.         specific to the windowing environment, and those that are comple-
  192.         mentary. The functions specific to windowing are preceded by "W_".  
  193.  
  194.  
  195.                                                                         2
  196.  
  197.  
  198.  
  199.  
  200.  
  201.                                                       C Windowing Toolbox
  202.    ----------------------------------------------------------------------
  203.  
  204.  
  205.         
  206.         The four major windowing functions are:
  207.         
  208.                 (1) Defining a window with W_DEF().
  209.                 (2) Opening a window with W_OPEN().
  210.                 (3) Closing the most recently opened window with W_CLOSE(). 
  211.                 (4) Deallocating window(s) and releasing window buffer 
  212.                     space with W_KILL().  
  213.         
  214.         The flag "err_exit" controls the action taken when a windowing 
  215.         error occurs. "err_exit" is declared as EXTERNal CHAR in 
  216.         C_WDEF.H. If you set "err_exit" to TRUE (default), the program 
  217.         will return to the operating system after an error message window 
  218.         is displayed.  The name of the windowing function and what is 
  219.         wrong with what you are asking the function to do will be 
  220.         indicated in the error message window.  
  221.  
  222.         If you set "err_exit" FALSE, for all windowing functions that 
  223.         return a status code (1 == OK, 0 == error), be sure to check that 
  224.         no error has occurred. If a windowing function returns an error 
  225.         code, do not ignore it.  Terminate the program and check your 
  226.         code for the cause of the error. Often the problem is as simple 
  227.         as mixing the X and Y coordinates up, or not specifying enough 
  228.         arguments when a function is called.  
  229.  
  230.         A window's width and height is specified when it is defined.  When 
  231.         it is opened, it can be located at any location on the screen, as 
  232.         long as it doesn't stray outside of the screen's boundaries. If 
  233.         you have specified a border for a window, the writable area of 
  234.         the window is reduced to fit inside the border. THE UPPER LEFT 
  235.         CORNER OF THE WRITABLE AREA OF A WINDOW IS AT HORIZONTAL (X) 
  236.         COORDINATE 0 AND VERTICAL (Y) COORDINATE 0. IF NO WINDOWS ARE 
  237.         OPEN, WINDOWING COMMANDS ARE RELATIVE TO THE STANDARD 80 x 25 
  238.         SCREEN.  
  239.  
  240.         No more than one version of a defined window can be open at any 
  241.         one time, irregardless of screen placement. This is because each 
  242.         window's storage contains information about the section of screen 
  243.         it overlaid and opening a second version of the same window would 
  244.         overwrite that information.  
  245.  
  246.         W_WRITE() is the windowing screen writing function. It does not 
  247.         attempt to interpret and act on any characters, including carriage 
  248.         returns and line feeds. The only action taken is to wrap-around on 
  249.         the active window if the cursor is at the right side of the window 
  250.         and to scroll up if the bottom of the window is reached. Any extra 
  251.         text handling will have to be added by you. The advantage is that 
  252.         you can write any character to a window with W_WRITE().  
  253.  
  254.         W_GETSTR() is the windowing screen string input function. You can 
  255.         specify the maximum length of an input string so that no borders 
  256.         are over-written. Character editing capabilities are included.  
  257.         The standard C function SSCANF() can be used to perform formatted 
  258.         input conversion on the string read by W_GETSTR().  
  259.  
  260.  
  261.                                                                         3
  262.  
  263.  
  264.  
  265.  
  266.  
  267.                                                       C Windowing Toolbox
  268.    ----------------------------------------------------------------------
  269.  
  270.  
  271.         
  272.         Any standard C input/output functions that involve outputting 
  273.         carriage returns or line feeds to the screen MUST be avoided when 
  274.         a window is open. The standard C input/output functions know 
  275.         nothing about the windowing environment and can easily write 
  276.         across a window's border. Functions like PRINTF() can be used 
  277.         with care, providing the user (1) first positions the cursor in a 
  278.         window with W_GOTOXY() (2) never sends a carriage return or line 
  279.         feed to the screen and (3) avoids writing across a window's 
  280.         border.  
  281.  
  282.         All function calls must include all parameters, even if they are 
  283.         only dummy place-holders. For example, if a window has been 
  284.         defined without a border, the window opening function W_OPEN() 
  285.         must include all 8 parameters, even though the border 
  286.         specifications are ignored.  
  287.  
  288.         The windowing code automatically selects 80 column alphanumeric 
  289.         mode whether you have a monochrome or graphics screen. The 
  290.         windowing functions W_FGCOLOR() and W_BGCOLOR() set character 
  291.         display attributes. Attribute definitions, controlling character 
  292.         color, intensity, etc, are contained in C_WDEF.H. To select 
  293.         standard white-on-black for either a monochrome or color screen, 
  294.         specify 0 (black) as the character background attribute and 7 
  295.         (white) as the foreground attribute. The foreground and 
  296.         background bit masks defined in C_WDEF.H correspond to the the 
  297.         actual bit values in a character attribute byte.  
  298.  
  299.         The integer variable "b_usage" is always set to the maximum 
  300.         amount of windowing buffer space used so far. You can use it to 
  301.         determine the smallest windowing buffer that will work with your 
  302.         program.
  303.         
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         4
  328.  
  329.  
  330.  
  331.  
  332.  
  333.                                                       C Windowing Toolbox
  334.    ----------------------------------------------------------------------
  335.  
  336.  
  337.     FUNCTIONS CONTAINED IN C WINDOWING TOOLBOX
  338.         
  339.       W_INIT - Initialize windowing 
  340.  
  341.         Usage: 
  342.  
  343.           w_init(); 
  344.  
  345.         W_INIT() sets up pointers to the window buffer, detects the type 
  346.         of monitor (color or monochrome), selects 80 column alphanumeric 
  347.         mode, sets the display page to zero, and sets up initial window 
  348.         dimensions to 80 x 25. It also initializes the text foreground 
  349.         color to white and the text background color to black. If your 
  350.         computer is not an IBM PC or compatible, W_INIT will detect this 
  351.         and abort the program.  
  352.  
  353.         YOU MUST CALL W_INIT() BEFORE CALLING ANY OTHER windowing
  354.         FUNCTIONS. Failure to do this can cause random sections of memory 
  355.         to be overwritten.  
  356.  
  357.  
  358.       W_DEF - Define a window 
  359.  
  360.         Usage: 
  361.     
  362.           wnum = w_def (wid, hgt, border);
  363.             int  wnum;  /* 0 if error, window access number otherwise */
  364.             int  wid;  /* Width of window, including optional border  */
  365.             int  hgt;  /* Height of window, including optional border */
  366.             char border;  /* TRUE (1) if border, FALSE (0) if no border */
  367.         
  368.         Example:
  369.         
  370.             if ((w1 = w_def(x1, y1, TRUE)) == 0)
  371.                     /* w_def error handler here */
  372.             /* otherwise continue */
  373.  
  374.         Define a window and reserve storage for it in the window buffer.  
  375.         A window must be defined before it is opened.  
  376.  
  377.         The width and height parameters include the window border, if a 
  378.         border is specified. If the window has a border, then the 
  379.         writable area of the window is reduced to fit inside the border.  
  380.         For example, a bordered window that has a width of 30 and a height 
  381.         of 10 has writable coordinates of 0..27 in the horizontal (X) 
  382.         direction and 0..7 in the vertical (Y) direction. If the window 
  383.         didn't have a border, the X and Y ranges would be 0..29 and 0..9 
  384.         respectively.  
  385.  
  386.         You cannot define a window larger than the standard screen. Also, 
  387.         the window must not be smaller than three columns by three rows 
  388.         if a border is specified and one row by one column if no border 
  389.         is specified. In other words, at least one writable character 
  390.         position must be on the window.  
  391.  
  392.  
  393.                                                                         5
  394.  
  395.  
  396.  
  397.  
  398.  
  399.                                                       C Windowing Toolbox
  400.    ----------------------------------------------------------------------
  401.  
  402.  
  403.  
  404.         Be sure to check the return code for 0, the error condition.  
  405.         Errors occur if the window is too small, too big, or if there is 
  406.         not enough room for the window in the window buffer.  
  407.  
  408.  
  409.       W_OPEN - Open a pre-defined window
  410.  
  411.         Usage:
  412.  
  413.           status = w_open (wnum, x, y, clear, wbgc, bdr_type, bfgc, bbgc);
  414.             int  status;  /* 1 if success, 0 if error */
  415.             int  wnum;  /* Value returned by a previous W_DEF() */
  416.             int  x;  /* Horizontal coordinate of upper left corner */
  417.             int  y;  /* Vertical coordinate of upper left corner */
  418.             char clear;  /* TRUE means pre-clear window, FALSE means
  419.                             retain previous contents */
  420.             char wbgc; /* Window background color */
  421.             char bdr_type;  /* Border type (if specified by W_DEF()) */
  422.             char bfgc; /* Border foreground color */
  423.             char bbgc; /* Border background color */
  424.         
  425.         Open a window that has been previously defined by a call to 
  426.         W_DEF(). If a window is being opened for the first time, then the 
  427.         contents of the window are initialized to spaces. If the window 
  428.         is being opened after having been previously open, the previous 
  429.         contents of the window will be re-displayed, unless "clear" is 
  430.         set to TRUE. The include file C_WDEF.H defines the six border 
  431.         types.
  432.  
  433.         "x" and "y" are absolute locations on the standard 80 x 25 screen 
  434.         and specify the location of the upper left corner of the window 
  435.         to be opened.  
  436.  
  437.         "wbgc" is the background color for the window. Any spaces in the 
  438.         window will take on the background color attribute. Non-blank 
  439.         areas are not affected. Set this to 0 (black) for a monochrome 
  440.         screen.  
  441.  
  442.         "bfgc" is the foreground color and "bbgc" is the background color 
  443.         of the border.  
  444.  
  445.         The include file C_WDEF.H defines the colors available. If you 
  446.         have a color graphics adapter, you can set the background and 
  447.         foreground of the border to the same color to produce an extra 
  448.         thick border.  
  449.  
  450.         Be sure to check the return code for 0, the error condition.  
  451.         Errors occur if wnum is to small or big, if the window is already 
  452.         open, or if the window won't fit on the screen at the absolute 
  453.         X,Y location specified.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         6
  460.  
  461.  
  462.  
  463.  
  464.  
  465.                                                       C Windowing Toolbox
  466.    ----------------------------------------------------------------------
  467.  
  468.  
  469.       W_CLOSE - Close a window 
  470.  
  471.         Usage: 
  472.  
  473.           w_close(); 
  474.  
  475.         Close the most recently opened window and restore the previously 
  476.         overwritten section of screen.  
  477.  
  478.         If you attempt to close the standard screen, W_CLOSE() will 
  479.         simply return, so extra W_CLOSE() calls are ignored.  
  480.  
  481.         There is no error return code.  
  482.  
  483.  
  484.       W_KILL - Deallocate window(s)
  485.  
  486.         Usage:
  487.  
  488.           status = w_kill (wnum);
  489.             int  status;  /* 1 if success, 0 if error */
  490.             int  wnum;  /* Number of window to kill */
  491.     
  492.         Deallocate window, and all subsequently defined windows. For 
  493.         example:
  494.         
  495.                 if ((w1 = w_def(x1, y1, FALSE)) == 0)
  496.                         /* Error handler here */
  497.                 if ((w2 = w_def(x2, y2, TRUE)) == 0)
  498.                         /* Error handler here */
  499.                 if ((w3 = w_def(x3, y3, TRUE)) == 0)
  500.                         /* Error handler here */
  501.                 /* De-allocate w2. Also de-allocate w3, because */
  502.                 /* it was defined after w2, but not w1, because */
  503.                 /* it was defined before w2 */
  504.                 if ((status = w_kill(w2)) == 0)
  505.                         /* w_kill error handler here */
  506.  
  507.         When W_KILL() is called, all of the open windows on the screen 
  508.         are automatically closed. This is done because the deallocated 
  509.         window(s) may be partially or fully under a window that is not 
  510.         being deallocated.  
  511.  
  512.         Be sure to check the return code for 0, the error condition.  
  513.         Errors occur if wnum is too small or too big or if no window is 
  514.         associated with wnum.  
  515.       
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         7
  526.  
  527.  
  528.  
  529.  
  530.  
  531.                                                       C Windowing Toolbox
  532.    ----------------------------------------------------------------------
  533.  
  534.  
  535.       W_SCROLL - Scroll contents of window
  536.  
  537.         Usage:
  538.  
  539.           w_scroll (dir, num);
  540.             int  dir;  /* Direction of scroll; 0 == up, 1 == down */
  541.             int  num;  /* Number of lines to scroll */
  542.  
  543.         The current window is scrolled in "dir" direction for "num" 
  544.         lines.
  545.  
  546.  
  547.       W_WRITE - Write a string to a window
  548.  
  549.         Usage:
  550.  
  551.           w_write (s);
  552.             char  *s;  /* Pointer to string */
  553.  
  554.  
  555.         Display NULL terminated string in current window at location set 
  556.         by W_GOTOXY(). If the right hand side of the window is reached, 
  557.         the cursor will wrap-around to the next line. If the cursor 
  558.         reaches the bottom of the current window, the contents of the 
  559.         window will scroll up 1 line. The cursor will locate at the 
  560.         character position immediately beyond the last character in the 
  561.         string.  
  562.  
  563.         No control characters are recognized, so any character can be 
  564.         displayed. W_FGCOLOR() and W_BGCOLOR() set the background and 
  565.         foreground attributes of the displayed character(s). See 
  566.         C_WDEF.H for the pre-defined display attribute values.  
  567.                 
  568.  
  569.       W_GETSTR - Read string
  570.  
  571.         Usage:
  572.  
  573.           w_getstr (s, maxc);
  574.             char *s;  /* Pointer to input buffer */
  575.             int  maxc;  /* Max char count */
  576.  
  577.         Read a string from the keyboard. Always position the cursor with 
  578.         W_GOTOXY() before calling W_GETSTR(). "maxc" is the maximum 
  579.         number of characters allowed. The cursor will not move beyond the 
  580.         limit specified by "maxc". For example, if "maxc" == 10, then 
  581.         only 10 characters can be entered. This is useful for avoiding 
  582.         over-writing a window's borders.  
  583.  
  584.         You can edit the input string:
  585.  
  586.                 (1) Pressing <RETURN> as the first keystroke leaves the
  587.                     input buffer unaltered.
  588.                 (2) If the first keystroke is a printable character, the
  589.  
  590.  
  591.                                                                         8
  592.  
  593.  
  594.  
  595.  
  596.  
  597.                                                       C Windowing Toolbox
  598.    ----------------------------------------------------------------------
  599.  
  600.  
  601.                     rest of the input buffer will be cleared.
  602.                 (3) The back-space key deletes one character to the left
  603.                     of the cursor.
  604.                 (4) The DEL key deletes the character above the cursor.
  605.                 (5) The left and right arrow keys move the cursor along 
  606.                     the input buffer string.
  607.                 (6) The END key moves the cursor to the end of the 
  608.                     string.
  609.                 (7) The HOME key moves the cursor to the beginning of
  610.                     the string.
  611.                 (8) Pressing <RETURN> ends the editing.
  612.  
  613.         The input buffer must be at least 1 byte longer than "maxc", to 
  614.         make room for the trailing '\0', which is always appended.  
  615.  
  616.         W_FGCOLOR() and W_BGCOLOR() set the background and foreground 
  617.         attributes of the displayed character(s). See C_WDEF.H for the 
  618.         pre-defined display attribute values.  
  619.         
  620.                 
  621.       W_DSP1 - Display 1 character
  622.  
  623.         Usage:
  624.  
  625.           status = w_dsp1 (x, y, ch);
  626.             int  status;  /* 1 if success, 0 if error */
  627.             int  x;  /* X position */
  628.             int  y;  /* Y position */
  629.             char ch;  /* character */
  630.  
  631.         Display a single character at an X, Y location relative to the 
  632.         currently open window. The cursor will locate directly over the 
  633.         displayed character.
  634.  
  635.         If no windows are open, the X and Y coordinates correspond to 
  636.         absolute locations on the standard 80 x 25 screen. The upper left 
  637.         coordinate is (0, 0).  
  638.  
  639.         W_FGCOLOR() and W_BGCOLOR() set the background and foreground 
  640.         attributes of the displayed character. See C_WDEF.H for the 
  641.         pre-defined display attribute values.  
  642.         
  643.         Be sure to check the return code for 0, the error condition. An 
  644.         error occurs if the X,Y position is outside of the currently 
  645.         active window.  
  646.                 
  647.  
  648.       W_FGCOLOR - Set text foreground color
  649.  
  650.         Usage:
  651.  
  652.           i = w_fgcolor(color);
  653.             int  i; /* 1 if success, 0 if error */
  654.             int color; /* foreground color bit mask */
  655.  
  656.  
  657.                                                                         9
  658.  
  659.  
  660.  
  661.  
  662.  
  663.                                                       C Windowing Toolbox
  664.    ----------------------------------------------------------------------
  665.  
  666.  
  667.  
  668.         Set the text foreground color for text displayed by W_WRITE(), 
  669.         W_DSP1(), W_GETSTR() and BORDER(). The value of color can be one 
  670.         of the values defined in C_WDEF.H for foreground colors. Note 
  671.         that the foreground color is an exact attribute byte bit mask.  
  672.         
  673.         Be sure to check the return code for 0, the error condition. An 
  674.         error occurs if "color" is less than 0 or greater than 255.
  675.                 
  676.  
  677.       W_BGCOLOR - Set text background color
  678.  
  679.         Usage:
  680.  
  681.           i = w_bgcolor(color);
  682.             int  i; /* 1 if success, 0 if error */
  683.             int color; /* background color bit mask */
  684.  
  685.         Set the text background color for text displayed by W_WRITE(), 
  686.         W_DSP1(), W_GETSTR() and BORDER(). The value of color can be one 
  687.         of the values defined in C_WDEF.H for background colors. Note 
  688.         that the background color value is an exact attribute byte bit 
  689.         mask.  
  690.         
  691.         Be sure to check the return code for 0, the error condition. An 
  692.         error occurs if the color value is less than 0 or greater than 
  693.         255.
  694.         
  695.  
  696.       W_GETCY - Get vertical (Y) position of cursor
  697.  
  698.         Usage:
  699.  
  700.           i = w_getcy();
  701.             int  i;  /* Y position */
  702.         
  703.         This function returns the current Y position of the cursor, 
  704.         relative to the upper left corner (0, 0) of the writable part of 
  705.         the current window. If no windows are open, the Y position is 
  706.         relative to the upper left corner of the standard screen.  
  707.  
  708.  
  709.       W_GETCX - Get horizontal (X) position of cursor
  710.  
  711.         Usage:
  712.  
  713.           i = w_getcx();
  714.             int  i;  /* X position */
  715.         
  716.         This function returns the current X position of the cursor, 
  717.         relative to the upper left corner (0, 0) of the writable part of 
  718.         the current window. If no windows are open, the X position is 
  719.         relative to the upper left corner of the standard screen.  
  720.  
  721.  
  722.  
  723.                                                                        10
  724.  
  725.  
  726.  
  727.  
  728.  
  729.                                                       C Windowing Toolbox
  730.    ----------------------------------------------------------------------
  731.  
  732.  
  733.  
  734.       W_GOTOXY - Move cursor
  735.  
  736.         Usage:
  737.  
  738.           status = w_gotoxy (x, y);
  739.             int  status;  /* 1 if success, 0 if error */
  740.             int  x;  /* Horizontal position */
  741.             int  y;  /* Vertical position */
  742.  
  743.         Go to specified X, Y location on the writable part of the 
  744.         current window. If you specified a border when you defined and 
  745.         opened the window, the writable part of the window is reduced to 
  746.         fit inside the border. For example, if you specified a window 
  747.         that was 10 x 10, and it had a border, then the horizontal (X) 
  748.         and vertical (Y) coordinates for W_GOTOXY() can vary between 
  749.         0..7.  
  750.         
  751.         If there are no windows open, the coordinates refer to the 
  752.         standard 80 x 25 screen.  
  753.         
  754.         Be sure to check the return code for 0, the error condition. An 
  755.         error occurs if the X,Y position is outside of the currently 
  756.         active window.  
  757.  
  758.  
  759.       W_WRITEXY - Write a string to a window at X, Y
  760.  
  761.         Usage:
  762.  
  763.           w_write (x, y, s);
  764.             int   x,y; /* Location */
  765.             char  *s;  /* Pointer to string */
  766.  
  767.  
  768.         This function combines W_GOTOXY () and W_WRITE ().  Display NULL 
  769.         terminated string in current window at location (X,Y).  If the 
  770.         right hand side of the window is reached, the cursor will wrap-
  771.         around to the next line. If the cursor reaches the bottom of the 
  772.         current window, the contents of the window will scroll up 1 line. 
  773.         The cursor will locate at the character position immediately 
  774.         beyond the last character in the string.  
  775.  
  776.         No control characters are recognized, so any character can be 
  777.         displayed. W_FGCOLOR() and W_BGCOLOR() set the background and 
  778.         foreground attributes of the displayed character(s). See 
  779.         C_WDEF.H for the pre-defined display attribute values.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        11
  790.  
  791.  
  792.  
  793.  
  794.  
  795.                                                       C Windowing Toolbox
  796.    ----------------------------------------------------------------------
  797.  
  798.  
  799.     COMPLEMENTARY FUNCTIONS
  800.  
  801.       The following functions are not part of the windowing environment.  
  802.       They are included because they provide useful windowing support.  
  803.  
  804.  
  805.       BORDER - Draw border on screen
  806.  
  807.         Usage:
  808.  
  809.           status = border (x, y, wid, hgt, type);
  810.             int  status;  /* 1 if success, 0 if error */
  811.             int  x;  /* Upper left horizontal position */
  812.             int  y;  /* Upper left vertical position */
  813.             int  wid;  /* Width of border */
  814.             int  hgt;  /* Height of border */
  815.             char type;  /* Type of border */
  816.  
  817.         Draw a border around an area of the screen. X and Y are absolute 
  818.         coordinates, relative to the standard 80 x 25 screen. The upper 
  819.         leftmost coordinate of the standard screen is (0, 0) and the lower 
  820.         right coordinate of the standard screen is (79, 24).
  821.  
  822.         There are six types of borders:
  823.                 (a) type = 0;  /* Border outline is spaces */
  824.                 (b) type = 1;  /* Single line border,
  825.                                   Horizontal and vertical */
  826.                 (c) type = 2;  /* Double line border,
  827.                                   Horizontal and vertical */
  828.                 (d) type = 3;  /* Double horizontal lines,
  829.                                   Single vertical lines */
  830.                 (e) type = 4;  /* Single horizontal lines,
  831.                                   Double vertical lines */
  832.                 (f) type = 5;  /* Solid block horizontal and vertical */
  833.  
  834.         The include file C_WDEF.H defines the border types listed above.  
  835.         
  836.         W_FGCOLOR() and W_BGCOLOR() set the background and foreground 
  837.         attributes of the displayed character(s). See C_WDEF.H for the 
  838.         pre-defined display attribute values.  
  839.         
  840.         Be sure to check the return code for 0, the error condition. An 
  841.         error occurs if the border type is not one of the types specified 
  842.         or if the border will not fit on the standard 80 x 25 screen.
  843.  
  844.  
  845.       KEYIN - Read a keyboard character
  846.  
  847.         Usage:
  848.  
  849.           c = keyin();
  850.             char  c;  /* Character returned */
  851.  
  852.  
  853.  
  854.  
  855.                                                                        12
  856.  
  857.  
  858.  
  859.  
  860.  
  861.                                                       C Windowing Toolbox
  862.    ----------------------------------------------------------------------
  863.  
  864.  
  865.         Read the next character entered at the keyboard. The character is 
  866.         not echoed to the screen. C_WDEF.H declares a variable "extend" 
  867.         as EXTERNal CHAR. If the character location "extend" is set to 
  868.         TRUE (1) when KEYIN() returns, then the value returned by KEYIN() 
  869.         is the extended character code. Otherwise, the character is a 
  870.         regular ASCII character. For example: 
  871.  
  872.                 c = keyin();
  873.                 if (extend)
  874.                         /* process function keys, etc */
  875.                 else
  876.                         /* standard character */
  877.  
  878.  
  879.       BEEP - Sound speaker
  880.  
  881.         Usage:
  882.  
  883.         beep(count);
  884.           int  count;  /* Duration */
  885.  
  886.         Beep the speaker. A value of 500 for "count" gives a short chirp. 
  887.         "count" is an integer value, so it must not exceed 32,767.
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.                                                                        13
  922.  
  923.  
  924.  
  925.  
  926.  
  927.                                                       C Windowing Toolbox
  928.    ----------------------------------------------------------------------
  929.  
  930.  
  931.     GETTING THE C SOURCE
  932.  
  933.         You can get the C Windowing Toolbox source code for $15 from:
  934.  
  935.              Christopher McVicar
  936.              124 Wellington Heights
  937.              Avon, Connecticut  06001
  938.  
  939.         The above price includes North American shipping. Add $3 for 
  940.         overseas air mail shipping. I will include a receipt with every 
  941.         order so businesses can keep their records straight. The source 
  942.         will be on a DOS 2.1 formatted single sided 5 1/4" floppy 
  943.         diskette.  
  944.  
  945.         Also on the diskette are:
  946.                 (1) A text file explaining what the Lattice C functions 
  947.                     PEEK(), POKE(), and INT86() do.  
  948.                 (2) Assembler sources for PEEK(), POKE(), and INT86().  
  949.                 (3) Assembler source and .OBJ files for an alternate 
  950.                     screen display function that checks the horizontal 
  951.                     retrace signal of the video display so that no "snow" 
  952.                     appears when writing to the screen.
  953.                 (4) A text file indexer program with C source.
  954.                 (5) An ImagePrint demonstration. ImagePrint is a print
  955.                     quality enhancing program that my company sells. It
  956.                     runs on Epson (tm) compatible printers.
  957.  
  958.     DISCLAIMER
  959.  
  960.         Users of C Windowing Toolbox do so at their own risk. No 
  961.         representations as to the program's suitability for any purpose 
  962.         are made. Users of C Windowing Toolbox are entirely responsible 
  963.         for loss or damage of any kind caused by C Windowing Toolbox.  
  964.  
  965.  
  966.     RESTRICTIONS
  967.  
  968.         Non-commercial users of C Windowing Toolbox may use C Windowing 
  969.         Toolbox without any restrictions.  
  970.  
  971.         Commercial users of C Windowing Toolbox, i.e. individuals or 
  972.         companies using or planning to use C Windowing Toolbox as part of 
  973.         a saleable product, must contact me, Christopher McVicar, and get 
  974.         written permission to include part or all of C Windowing Toolbox 
  975.         in their product.
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.                                                                        14
  988.  
  989.  
  990.  
  991.