home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
167_01
/
c_window.doc
< prev
next >
Wrap
Text File
|
1985-08-21
|
30KB
|
1,124 lines
C_WINDOW
--------
Windowing for the IBM PC with the C Language
Version 1.00
C_WINDOW
----------------------------------------------------------------------
INTRODUCTION
C_WINDOW is a collection of functions that give windowing capa-
bility to the C programmer using an IBM PC or true compatible.
C_WINDOW is written entirely in MicroSoft (Lattice) C, Version
2.03. It was compiled using the small model for both code and
data and is distributed in .OBJ format, ready to be linked to
your C programs. The source code of C_WINDOW is available for
$15. See page 11 of this documentation for details.
The core C_WINDOW files are:
C_WINDOW.OBJ - The compiled windowing code
C_WINDOW.DOC - The documentation
C_WDEF.INC - Include file for your C code
C_W-DEMO.EXE - Windowing demonstration program
To use the C_WINDOW functions in your Lattice C program:
(1) Include the file C_WDEF.INC in your C source file.
C_WDEF.INC defines the C_WINDOW functions and associated
constants and variables. If the C_WDEF.INC file is missing,
you can extract it from the sample program C_W-DEMO.C listed
at the end of this documentation.
(2) Compile your C source file using the small code and data
model.
(3) Link C_WINDOW.OBJ to your code:
LINK CS + yourprog + C_WINDOW, yourprog.EXE,, MCS.LIB
To allow other C compilers to compile the C_WINDOW source code,
standard C syntax is used where-ever possible. There are only
three non-standard C functions used: INT86(), PEEK() and POKE().
If your compiler doesn't include these functions, you will have
to write your own. Lattice C compatible versions of the three
above functions, written in assembler, plus a full explanation,
are on the source code disk. Also, if you don't have an IBM PC or
compatible, and you are familiar with reading and writing to the
video RAM of your computer, you can adapt C_WINDOW for use on
your PC.
Near the end of this documentation is the C source of a sample
windowing program. It has been compiled as C_W-DEMO.EXE and is
part of the C_WINDOW package. If C_W-DEMO.EXE is missing, you can
extract the source of C_W-DEMO.C from this documentation and
compile it to see a demonstration of C_WINDOW.
An array of bytes, called the window buffer, is used to store
each defined window, plus the section of the screen that each
window overlays. The window buffer size has been defined in the
C_WINDOW code to be 10000 bytes. This is a compromise value.
Larger allows more active window definitions, smaller means a
1
C_WINDOW
----------------------------------------------------------------------
smaller program. When a window is defined, storage is allocated
in the window buffer. The standard IBM PC screen, in 80 column
alphanumeric mode, uses 4000 bytes (80 x 25 x 2) of video RAM.
Each character on the screen has a trailing attribute byte that
indicates if the character is bright or dark, blinking, etc.
10000 bytes is enough to create a window the size of the screen
(4000 bytes to save old screen, 4000 for window), plus another
little window. Or several medium sized windows.
C_WINDOW allows deallocation of window storage so you can have as
many windows as you like by deallocating and redefining them as
needed. The only restriction is that only as many windows as can
be defined in the window buffer can be visible at any one time.
The main reason why the window buffer's size is explicitly
defined in the code, rather than using dynamic memory allocation
is that if the program can load on a particular computer with x
amount of memory, then it will run on that computer. The program
is self-contained.
OVERVIEW OF FUNCTIONS
YOU MUST ALWAYS CALL W_INIT() BEFORE USING ANY OF C_WINDOW's
FUNCTIONS. Do NOT neglect to do this, as several important data
pointers are initialized.
There are two kinds of functions available: those that are
specific to the C_WINDOW environment, and those that are comple-
mentary. The functions specific to C_WINDOW are preceded by "W_".
The four major windowing functions are:
(1) Defining a window with W_DEF().
(2) Opening a window with W_OPEN().
(3) Closing the most recently opened window with W_CLOSE().
(4) Deallocating window(s) and releasing window buffer
space with W_KILL().
The flag "err_exit" controls the action taken when a windowing
error occurs. "err_exit" is declared as EXTERNal CHAR in
C_WDEF.INC. If you set "err_exit" to TRUE (default), the program
will return to the operating system after an error message window
is displayed. The name of the windowing function and what is
wrong with what you are asking the function to do will be
indicated in the error message window.
If you set "err_exit" FALSE, for all C_WINDOW functions that
return a status code (1 == OK, 0 == error), be sure to check that
no error has occurred. If a windowing function returns an error
code, do not ignore it. Terminate the program and check your
code for the cause of the error. Often the problem is as simple
as mixing the X and Y coordinates up, or not specifying enough
arguments when a function is called.
2
C_WINDOW
----------------------------------------------------------------------
A window's width and height is specified when it is defined. When
it is opened, it can be located at any location on the screen, as
long as it doesn't stray outside of the screen's boundaries. If
you have specified a border for a window, the writeable area of
the window is reduced to fit inside the border. THE UPPER LEFT
CORNER OF THE WRITEABLE AREA OF A WINDOW IS AT HORIZONTAL (X)
COORDINATE 0 AND VERTICAL (Y) COORDINATE 0. IF NO WINDOWS ARE
OPEN, WINDOWING COMMANDS ARE RELATIVE TO THE STANDARD 80 x 25
SCREEN.
No more than one version of a defined window can be open at any
one time, irregardless of screen placement. This is because each
window's storage contains information about the section of screen
it overlaid and opening a second version of the same window would
overwrite that information.
W_WRITE() is the C_WINDOW screen writing function. It does not
attempt to interpret and act on any characters, including carriage
returns and line feeds. The only action taken is to wrap-around on
the active window if the cursor is at the right side of the window
and to scroll up if the bottom of the window is reached. Any extra
text handling will have to be added by you. The advantage is that
you can write any character to a window with W_WRITE().
W_GETSTR() is the C_WINDOW screen string input function. You can
specify the maximum length of an input string so that no borders
are over-written. Character editing capabilities are included.
The standard C function SSCANF() can be used to perform formatted
input conversion on the string read by W_GETSTR().
Any standard C input/output functions that involve outputting
carriage returns or line feeds to the screen MUST be avoided when
a window is open. The standard C input/output functions know
nothing about the windowing environment and can easily write
across a window's border. Functions like PRINTF() can be used
with care, providing the user (1) first positions the cursor in a
window with W_GOTOXY() (2) never sends a carriage return or line
feed to the screen and (3) avoids writing across a window's
border.
All function calls must include all parameters, even if they are
only dummy place-holders. For example, if a window has been
defined without a border, the window opening function W_OPEN()
must include all 5 parameters, even though the border type
specification is ignored.
C_WINDOW automatically selects 80 column alphanumeric mode
whether you have