Category : C Source Code
Archive   : TOOLS151.ZIP
Filename : TCTOOLS.BOD
Output of file : TCTOOLS.BOD contained in archive : TOOLS151.ZIP
TC-Tools LIBRARY
Overview
The TC-Tools library for the PC contains many libraries of
routines that are useful for the Turbo C programmer. These
libraries consist of easy to use, highly sophisticated I/O
routines that are packaged together for easy inclusion into Turbo
C developments.
The libraries include a Video Services Library, a Pop Out
Window Library, and a Keyboard and Input Library.
The Video Services Library contains routines that deal at a
low level with the screen. The routines in VLIB consist of
String and Character I/O routines, Attribute modification
routines, Cursor control routines, Block Fill routines, Character
Graphics Routines, Screen Reading Routines, Screen saving
routines, and various control routines.
The Pop Out Window Library contains routines that deal with
the screen at a slightly higher level. The routines in WLIB con-
sist of Window handling routines which allow the user to open a
window, close a window, move a window, print inside a window,
etc... The routines are an integrated package that requires the
VLIB low level routines and that rely on one another so that when
one window is accessed if that window is not on top of all the
other windows then it is first activated (ie. brought to the top)
before it is used.
The Keyboard and Input Library consists of routines to in-
terface a program gracefully with the keyboard and the user. The
library contains routines to do the low level I/O with the
keyboard as well as higher level functions that perform data
entry on the screen such as getting a string with editing, get-
ting integers, simplifying menu construction as well as automat-
ing menus, etc....
Libraries
KLIB - Keyboard and Input Library
VLIB - Video Library
WLIB - Window (Pop Out) Library
1
Installation
A list of the Files that will be found in the archive con-
taining the TC-Tools system are as follows:
1. TCTOOLS.H - TC-Tools Header File
2. TCTOOLSS.LIB - Small Model Library File
3. TCTOOLSM.LIB - Medium Model Library File
4. TCTOOLSC.LIB - Compact Model Library File
5. TCTOOLSL.LIB - Large Model Library File
6. TCTOOLSH.LIB - Huge Model Library File
7. K_*.C - KLIB Source Files
8. V_*.C - VLIB Source Files
9. W_*.C - WLIB Source Files
10. W_PRINTF.ASM - WLIB Printf Routine
11. TCTOOLS.BAT - Batch File to Build All Models
12. TCTOOLS2.BAT - Same as TCTOOLS.BAT but w/o
Assembler routine delete and
compile.
13. TCTOOLS1.BAT - Batch File to Replace one
Module in all Libraries
14. TVIDEO.* - VLIB Test Routine & Proj File
15. TWINDOW.* - WLIB Test Routine & Proj File
16. TKEYS.* - KLIB Test Routine & Proj File
17. *.OBJ - Routine Object Files that use
Inline or are written in As-
sembler and BGI files.
18. TCTOOLS.DOC - This Document.
19. TCTOOLS3.BAT - Batch File to Insert BGI
drivers into Libraries.
20. TCT_INIT.C - Initialize for TC-Tools.
If you have Turbo-C 2.0 all you need to do is to copy the .H
file to your normal Turbo-C include directory and the .LIB
files to the Turbo-C library directory. If you have Turbo-C
1.5 then you have to do a little more work. First you must
use BGIOBJ to create .OBJ files in the TC-Tools directory
for all the drivers and font files for the BGI. These must
be generated with the /F switch because TC-Tools expects
them to be far pointers. Example Command:
BGIOBJ /F EGAVGA
After all of these have been converted (*.BGI and *.CHR)
then run the batch file TCTOOLS3.BAT which will insert all
the version 1.5 files into the libraries. From this point
just follow the above instructions for version 2.0.
2
KLIB Routine Overview
KLIB contains routines to do keyboard I/O. The routines in
KLIB consist of a keyboard status routine, a keyboard keystroke
interface routine, on the screen string editing routines, on the
screen form editors, a windowed menu driver and a set of routines
that make entering integers, floats, doubles and longs easy.
Keyboard Status Routine
K_STAT - Checks the keyboard buffer to determine
if a keystroke is waiting to be read.
This routine is used in function k_getc
too.
Keystroke Interface Routine
K_GETC - Reads a key from the keyboard. Routine
includes an optional echo and wait flag.
String Editing Routines
K_GETSTRING - Allows for clearing of a string variable
followed by on the screen editing within
a rectangular area of the screen with
full cursor control and insert/delete
operations.
K_EDITSTRING - Allows for editing of a string variable
within a specified area of the screen
with full cursor control and
insert/delete operations.
Form Editing Routines
K_FORMLEFT - Allows for editing of a specified form
from the left side of a given format.
This routine will skip hard characters
in the format automatically during entry
allowing for easy date, number, special
sequences, etc... The routine also al-
lows for full editing of the form.
K_FORMRIGHT - Allows for editing of a specified form
from the right side of a given format.
This routines capabilities are exactly
that of k_formleft except for the direc-
tion characters are moved while enter-
ing.
3
Menu Driver Routine
K_MENU - Allows for specification and selection
of menu items within a window. This
routine will skip "dead" lines and al-
lows for up and down arrow key movement
for making a selection.
Number Entry Routines
K_GETINT - Allows for clearing and keyboard han-
dling for an integer field of specified
length.
K_EDITINT - Allows for editing of an integer field
of specified length.
K_GETLONG - Allows for clearing and keyboard han-
dling for a long integer field of
specified length.
K_EDITLONG - Allows for editing of a long integer
field of specified length.
4
TC-Tools Common Routine Overview
TC-Tools contains at present only one common routine and
that is TCT_INIT. This routine is the initialization code for
the all libraries and MUST BE CALLED FIRST!!!!!
TCT_INIT - Initializes Video Card Drivers and sets
up all global variables to default
values.
5
VLIB Routine Overview
VLIB contains routines to do fast I/O to the video screen.
The routines in VLIB consist of String I/O routines, Attribute
modification routines, Cursor control routines, Block Fill
routines, Character Graphics Routines, Screen Reading Routines,
Screen saving routines, and various control routines.
String & Character I/O Routines
V_APUTCH - Outputs a given character to the screen at
the current cursor position with a specified
attribute.
V_APUTS - Outputs a given string to the screen at the
current cursor position with a specified at-
tribute.
V_PUTC - Outputs a given character to the screen at a
given row,column address with a specified at-
tribute.
V_PUTCH - Outputs a given character to the screen at
the current cursor position without affecting
the existing attributes.
V_PUTS - Outputs a given string to the screen without
affecting the attributes on the screen.
V_WRITE - Outputs a given string the screen at a given
row, column starting address with a given at-
tribute.
V_WRITEC - Outputs a given string to the screen and cen-
ters it between two given column addresses
with a given attribute.
V_WRITEL - Outputs a given string to the screen at a
given row, column starting address with clip-
ping to a given length with a given at-
tribute.
Attribute Routines
V_ATTR - Changes the attribute on the screen without
destroying the characters over a given rec-
tangular area.
V_ATTRC - Changes the attribute on the screen without
destroying the characters over a given cen-
tered rectangular area.
V_MKATTR - Calculate the single integer attribute from a
given foreground and background.
6
Cursor Control Routines
V_COL - Reads the current cursor column address and
returns it to the user as an integer.
V_CUROFF - Turns the cursor image off. This does not
stop the logical cursor from updating it just
makes it invisible.
V_CURON - Turns the cursor image on. This is the
reverse of v_curoff.
V_GETCUR - Returns the current cursor status. True if
on and False if off. Also returns current
scan line layout.
V_GORC - Move cursor to given row,column address.
V_MODCUR - Modify the cursor image. This allows the
user to change the cursor image while remem-
bering the old cursor image.
V_ROW - Reads the current cursor row address and
returns it to the user as an integer.
Block Fill Routines
V_CLS - Clears the screen to a given attribute.
V_FILL - Fills a given rectangular area on the screen
with a given character with a given at-
tribute.
V_FILLC - Fills a given centered rectangular area on
the screen with a given character with a
given attribute.
Character Graph Routines
V_BOX - This routine will draw a box on the screen
given the rectangular coordinates of the box,
the border attribute, the inside attribute,
and the border type.
V_HLINE - This routine will draw a horizontal line on
the screen using either single or double
character graphics lines. It will also fix
any intersections with other vertical charac-
ter graphics lines.
V_VLINE - This routine will draw a vertical line on the
7
screen using either single or double charac-
ter graphics lines. It will also fix any in-
tersections with other horizontal character
graphics lines.
8
Screen Reading Routines
V_GETC - This routine will read the character at the
current cursor position on the screen and
return it as an integer. The attribute is
stripped before returning.
V_GETINT - This routine will try to make sense out of a
given area of the screen and try to produce
an integer number from this which it will
return.
V_GETLONG - This routine will try to make sense out of a
given area of the screen and try to produce a
long number from this which it will return.
V_GETFLOAT - This routine will try to make sense out of a
given area of the screen and try to produce a
floating point number from this which it will
return.
V_GETDOUBLE - This routine will try to make sense out of a
given area of the screen and try to produce a
double precision floating point number from
this area which it will return.
V_GETS - This routine will create a string variable
from screen information given a rectangular
area boundary.
Control & Misc Routines
V_HEAPOK - This routine will return a true/false value
based on whether there is enough memory in
the heap for a malloc operation given the
size of the area needed.
V_PAGE - This routine will change the displayed page
to the one specified.
V_SETMODE - This routine will allow the user to set the
video mode of the hardware. This routine
will also recall v_init to update the public
variables.
V_WRTPAG - This routine sets the page that vlib routines
will write to. The page does not necessarily
need to be the one displayed.
9
WLIB Routine Overview
WLIB contains routines that allow the user to implement
sophisticated pop out windows. The routines in WLIB consist of
routines to open and close windows on the screen, perform various
controls of windows on the screen, and to perform miscellaneous
control functions inside the window.
The windows created by WLIB are completely independant of
each other and most of the routines require a window pointer in
their call structures. This means that if a window is behind
another window it is still accessible just by refering to it by
its pointer. Whenever the user calls a WLIB routine with a win-
dow pointer and that window is not the top window the first thing
the system does is to bring it to the top.
At this point there is a potential problem with the window
system in that if many windows are created and then removed out
of order the user could conceivably use up memory. This is due
to the way Turbo-C and DOS do memory allocations. Work is ongo-
ing to try to solve this problem.
Another item of interest about the pop out windows is that
whenever a window is 'topped' (i.e. another window is placed on
top of the current one) the information inside the window is
saved so that the contents can be restored the next time the win-
dow becomes active.
Open & Close Routines
W_OPEN - Opens a window with specified parameters
and sets the window up in the linked
list.
W_CLOSE - Closes a window from the screen and
fixes the linked list.
W_CLOSEALL - Closes all windows from the screen and
clears the linked list.
Window Control Routines
W_MOVE - Will move a window to a new row/ column
address given its window pointer and the
row and column for the upper left hand
corner.
10
Window Control Routines (cont)
W_TITLE - Routine to allow titling of windows.
This routine will accept a justification
parameter, window pointer, and string
for the title.
W_TOP - Brings the specified window to the top
of the screen.
Misc Window Routines
W_CLS - Clears the video screen only inside the
window. Allows specification of the at-
tribute for the screen area inside the
window.
W_GORC - Allows positioning of the cursor rela-
tive to the origin of the window instead
of the origin of the screen.
W_PRINTF - Allows standard 'C' printing inside and
clamped within a window boundary. Full
printf format controls are implemented.
11
KLIB Library
Introduction
The KLIB system of keyboard interface routines is an easy to
use and fast set of routines to allow the Turbo-C user to develop
data entry screen and menu driven applications easily and effi-
ciently.
The KLIB system implements a set of on the screen editors
and low level keystroke handling routines. The power of KLIB
comes into play when data needs to be entered on a data entry
screen. With its string editing capabilities and form editing
capabilities in conjunction with the number entry routines KLIB
makes programming a data entry screen a snap.
When the menu handler is added to this KLIB really starts to
shine by reducing development time for the user interface of any
application program. The menu handler does windows so menus do
not destroy what was underneath and are fully tiled.
12
K_CINS
The k_cins routine is used by the form editors to insert a
character at the current cursor position without disturbing the
solid characters in the form.
Usage:
void k_cins(ch,tempstring,string,format,
index,upcase,direction);
char ch; Character to be inserted.
char *tempstring; String stripped of all solid chars.
char *string; String returned with all solid
characters back in place.
char *format; format of string.
int index; Current cursor position index
int upcase; Convert to Upper Case Flag.
int direction; Direction to move characters.
13
K_EDITINT
The k_editint routine will allow the user to edit a given
integer variable on the screen. Note: the integer can only be
edited in a form acceptable to the Turbo-C atoi routine.
Usage:
void k_editint(direction,row,col,attr,prec,number);
int direction; Direction to Edit (LEFT or RIGHT).
int row; Row for Edit Field.
int col; Left Side Column.
int attr; Screen Attribute.
int prec; Number of digits.
int *number; Integer number to edit.
14
K_EDITLONG
The k_editlong routine will allow the user to edit a given
long integer variable on the screen. Note: the long can only be
edited in a form acceptable to the Turbo-C atol routine.
Usage:
void k_editlong(direction,row,col,attr,prec,number);
int direction; Direction to Edit (LEFT or RIGHT).
int row; Row for Edit Field.
int col; Left Side Column.
int attr; Screen Attribute.
int prec; Number of digits.
long *number; Long number to edit.
15
K_EDITSTRING
This function allows the user to edit a given string within
a specified boundary on the screen. The string can either be
edited from the upper left corner or the lower right corner of
the screen area specified. K_EDITSTRING also allows for a maxi-
mum length for the string and a screen attribute value for the
screen field. The editing capabilities of the string edit and
get routines are more fully described in Appendix C starting on
page 97 .
Usage:
void k_editstring(dir,string,maxlen,row,col,cols,attr);
KEYDIR dir; direction of edit (LEFT or RIGHT)
char *string; string to edit
int maxlen; maximum length of string to edit
int row; upper left corner row of screen
field
int col; upper left corner column of screen
field
int cols; number of columns for screen field
int attr; screen attribute for field
16
K_FILL
The k_fill routine is used by the k_stringleft and
k_stringright routines to fill the specified string area of the
screen with the given attribute. The k_fill routine takes all
the variables into account to produce the screen area even if the
last row (i.e. maxlen is not evenly divisible by cols) is shorter
than the other rows.
Usage:
void k_fill(row,col,cols,maxlen,rows,attr);
int row; Upper left corner row
int col; Upper left corner column
int cols; Number of columns per row
int maxlen; Maximum length of area
int *rows; Calculated number of rows
int attr; Screen attribute for string area.
17
K_FORMLEFT
This routine will allow the user to edit a specified field
starting from the left side of the specified field. The routine
will only accept characters of the specified type and will
automatically skip over any field characters that are not of the
reserved types. For a full discussion of the code types see Ap-
pendix B starting on page 93 .
Usage:
void k_formleft(string,format,row,col,attr);
char *string; string to edit - If zero length
then the string is first filled
with all non-editable characters
found in the format string.
char *format; format of string to edit. This
string can contain any form the
user wishes by specifying the for-
mat of editable and non-editable
characters.
Editable Characters:
c : only alphabetic characters
C : only capitalized alphabetic
characters. Any lower case
entries are converted to upper
case
n : only alphanumeric characters
N : only capitalized alphanumeric
characters. Any lower case
entries are converted to upper
case
a : only ASCII characters
A : only capitalized ASCII charac-
ters. Any lower case entries
are converted to upper case
9 : only decimal digits
x : only hexidecimal digits
X : only capitalized hexidecimal
digits. Any lower case
hexidecimal digits are con-
verted to upper case
int row; row number for field
int col; left column number for field
int attr; screen attribute for field
18
K_FORMRIGHT
This routine will allow the user to edit a specified field
starting from the bottom and right side of the specified field.
The routine will only accept characters of the specified type and
will automatically skip over any field characters that are not of
the reserved types. For a full discussion of the code types see
Appendix B starting on page 93 .
Usage:
void k_formright(string,format,row,col,attr);
char *string; string to edit - If zero length
then the string is first filled
with all non-editable characters
found in the format string.
char *format; format of string to edit. This
string can contain any form the
user wishes by specifying the for-
mat of editable and non-editable
characters.
Editable Characters:
c : only alphabetic characters
C : only capitalized alphabetic
characters. Any lower case
entries are converted to upper
case
n : only alphanumeric characters
N : only capitalized alphanumeric
characters. Any lower case
entries are converted to upper
case
a : only ASCII characters
A : only capitalized ASCII charac-
ters. Any lower case entries
are converted to upper case
9 : only decimal digits
x : only hexidecimal digits
X : only capitalized hexidecimal
digits. Any lower case
hexidecimal digits are con-
verted to upper case
int row; row number for field
int col; left column number for field
int attr; screen attribute for field
19
K_GETC
The k_getc routine is the backbone of the KLIB system. This
routine is the lowest level of interface with the keyboard. It
allows for keystroke waiting and echoing.
Usage:
int k_getc(wait,echo);
int wait; Wait for a keystroke flag.
0 - Don't Wait
1 - Wait
int echo; Echo the Keystroke to the screen flag.
0 - Don't Echo
1 - Echo
20
K_GETINT
The k_getint routine allows the user to enter a integer num-
ber on the screen with full editing capabilities.
Usage:
int k_getint(direction,row,col,attr,prec);
int direction; Direction to edit (LEFT or RIGHT)
int row; Row for Field
int col; Starting Column for field
int attr; Screen Attribute
int prec; Number of digits
21
K_GETLONG
The k_getlong routine allows the user to enter a long number
on the screen with full editing capabilities.
Usage:
long k_getlong(direction,row,col,attr,prec);
int direction; Direction to edit (LEFT or RIGHT)
int row; Row for Field
int col; Starting Column for field
int attr; Screen Attribute
int prec; Number of digits
22
K_GETSTRING
The k_getstring routine allows the user to enter a string
within a blank string field on the screen with full editing
capabilities including Page Up, Page Down, Home, End, Left,
Right, Up, Down, Insert, Delete, Backspace and Escape. For a
complete discussion on field edits consult Appendix C starting on
page 97 .
Usage:
void k_getstring(direction,string,maxlen,row,col
cols,attr);
int direction; Direction of edit (LEFT or RIGHT)
char *string; String Variable to store string in
int maxlen; Maximum Length of string
int row; Upper Left Corner Row
int col; Upper Left Corner Column
int cols; Number of columns per row
int attr; Screen Attribute for field
23
K_INSTR
The k_instr routine is a low level routine used by the other
routines to extract a specified section of a string from the full
string.
Usage:
char *k_instr(string1,string2,start,end);
char *string1; Partial String returned
char *string2; Full String to extract from
int start; Starting Index for Partial
int end; Ending Index for Partial
24
K_MENU
The k_menu routine allows the user to build a static set of
structures to automatically create and select items from a menu.
For a full description of the menu structure and how to initial-
ize it for use in your routines refer to Appendix D starting on
page 98 .
Usage:
int k_menu(menu);
struct menu *menu; Pointer to Menu Structure.
Returns:
Selection from structure definition.
25
K_MOVCURS
The k_movcurs routine is a low level routine used by the
form editing routines k_formleft and k_formright to move the cur-
sor with skipping over any solid characters in the field.
Usage:
int k_movcurs(index,pcol,lcol,rcol,format,adder);
int index; Index into string
int pcol; Current screen column
int lcol; Column of left side of field
int rcol; Column of right side of field
char *format; Format of field.
int adder; Number to add to pcol & index
26
K_OUTLEFT
The k_outleft routine outputs the given string into a string
field starting at the upper left corner on the screen clamping
the columns and performing wrap around to fit the string into the
selected area.
Usage:
void k_outleft(string,maxlen,row,col,rows,cols,attr);
char *string; String to output to screen
int maxlen; Maximum length of string
int row; Upper Left Corner Row
int col; Upper Left Corner Column
int rows; Number of rows
int cols; Number of columns
int attr; Screen Attribute
27
K_OUTRIGHT
The k_outright routine outputs the given string into a
string field starting at the lower right corner on the screen
clamping the columns and performing wrap around to fit the string
into the selected area.
Usage:
void k_outright(string,maxlen,row,col,rows,cols,attr);
char *string; String to output to screen
int maxlen; Maximum length of string
int row; Upper Left Corner Row
int col; Upper Left Corner Column
int rows; Number of rows
int cols; Number of columns
int attr; Screen Attribute
28
K_REFILL
The k_refill routine is a low level routine used by the
k_formleft and k_formright routines to refill a given string into
the specified format.
Usage:
void k_refill(string1,string2,format);
char *string1; String without solid chars
char *string2; Full string with all solids
char *format; Format for string field
29
K_STAT
The k_stat routine will return the status of the keyboard as
either a standard boolean TRUE or boolean FALSE. This routine
can be used to check for the presence of a waiting keystroke.
Usage:
int k_stat();
Returns:
0 if no keystroke waiting
1 if a keystroke is waiting
30
K_STRINGLEFT
The k_stringleft routine is a low level routine that edits a
string field from the upper left corner. The user should use the
k_getstring and k_editstring routines. This is just here for
completeness of the documentation.
Usage:
int k_stringleft(string,maxlen,row,col,cols,attr,
length,move,outleft,outright);
char *string; String to use for editing.
int maxlen; Maximum Length of String
int row; Upper Left Corner Row
int col; Upper Left Corner Column
int cols; Number of columns per row
int attr; Screen Attribute
int length; Current Length of string
int move; Cursor Movement Flag
int outleft; Allow movement out of left side of
field
int outright; Allow movement out of right side of
field
31
K_STRINGRIGHT
The k_stringright routine is a low level routine that edits
a string field from the lower right corner. The user should use
the k_getstring and k_editstring routines. This is just here for
completeness of the documentation.
Usage:
int k_stringright(string,maxlen,row,col,cols,attr,
length,move,outleft,outright);
char *string; String to use for editing.
int maxlen; Maximum Length of String
int row; Upper Left Corner Row
int col; Upper Left Corner Column
int cols; Number of columns per row
int attr; Screen Attribute
int length; Current Length of string
int move; Cursor Movement Flag
int outleft; Allow movement out of left side of
field
int outright; Allow movement out of right side of
field
32
K_STRIP
The k_strip routine is a low level routine to strip all of
the non editable characters from a string using the format given.
Usage:
int k_strip(string1,string2,format,index);
char *string1; Partial string stripped of solid
characters
char *string2; Full string in format style
char *format; Format of full string
int index; Index of cursor position into
string
33
Quick Reference for KLIB Routines
void k_cins(ch,string,string,format,index,upcase,direction);
void k_editint(direction,row,col,attr,prec,number);
void k_editlong(direction,row,col,attr,prec,number);
void k_editstring(dir,string,maxlen,row,col,cols,attr);
void k_fill(row,col,cols,maxlen,rows,attr);
void k_formleft(string,format,row,col,attr);
void k_formright(string,format,row,col,attr);
int k_getc(wait,echo);
int k_getint(direction,row,col,attr,prec);
long k_getlong(direction,row,col,attr,prec);
void k_getstring(direction,string,maxlen,row,col,cols,attr);
char *k_instr(string,string,start,end);
int k_menu(menu);
int k_movcurs(index,pcol,lcol,rcol,format,adder);
void k_outleft(string,maxlen,row,col,rows,cols,attr);
void k_outright(string,maxlen,row,col,rows,cols,attr);
void k_refill(string,string,format);
int k_stat();
int k_stringleft(string,maxlen,row,col,cols,attr,length,move,
outleft,outright);
int k_stringright(string,maxlen,row,col,cols,attr,length,move,
outleft,outright);
int k_strip(string,string,format,index);
ch - Character Variable
string - Various String Variables
format - String variable to hold format for form edit
index - Index into string
upcase - Convert to Upper Case Flag
Direction - Direction Flag (LEFT or RIGHT)
row - Integer Row Number (1-25)
col - Integer Column Number (1-80)
rows - Integer Number of Rows
cols - Integer Number of Columns
attr - Integer Attribute value (see pg 36 )
prec - Number of digits
number - Number returned by number edit routines
maxlen - Maximum string length for string edit routines
wait - Wait for keystroke flag
echo - Echo keystroke flag
pcol - Current column
lcol - Left column of field
rcol - Right column of field
length - Current length of string for string edit routines
adder - Move cursor amount to add to cursor position
menu - Menu Structure pointer for k_menu routine
start - Start Index for k_instr
end - End Index for k_instr
move - Cursor Movement Flag
outleft - Movement out of left side of field allowed
34
outright - Movement out of right side of field allowed
35
TC-Tools Common Library
Introduction
The only routine in the TC-Tools Common system is the in-
itialization routine TCT_INIT.C. This routine will determine the
type of video card in use and the default parameters for the cur-
rent modes from the card like number of rows and columns, etc...
36
TCT_INIT
The tct_init routine is used to initialize the TC-Tools
library system for use with your system or anybody elses system.
It performs automatic recognition of the video card and sets up
the limits for screen pages, rows, columns, etc... This routine
must be called before any other routine in the libraries unless
you know what you are doing and have looked at the routine to be
sure it does not use any global variables.
Usage:
void tct_init();
37
VLIB Library
Introduction
The VLIB system of fast screen routines is an easy to use
and fast set of routines designed to assist the Turbo-C user in
developing screen intensive applications.
The main reason these routines perform screen I/O faster
than their normal C counterparts is the fact that they write
directly to screen memory instead of using the bios routines
built into the pc anywhere they can.
VLIB Cursor Update
The flag Write_update can be used by the user in any
routines. By setting this flag to a 1 (the default) anytime the
routines that write strings to the screen (v_aputs, v_puts,
v_write, v_writec, v_writel) will update the cursor to the end of
the writing. If the flag is set to 0 or FALSE then the cursor
does not update.
Quick Tips
A couple of quick tips are in order:
1. Anytime a routine calls for an attribute if the
attribute passed is a -1 then the routine will use
the existing attribute of the screen.
2. If you have problems using a screen then try these
defaults:
Max_text_page = 0;
Cardwait = 0;
Routines
The following pages contain descriptions of each individual
library routine including a general description, an example call
usage in some places and a variable list for each routine in the
VLIB system.
38
V_APUTCH
The v_aputch routien is used to output a single character to
the screen at the current cursor location with attribute control.
The information passed to this routine consists of only the
character to output and the attribute to use for the character.
Usage:
void v_aputch(ch,attr);
char ch; Character to be output to the screen
int attr; Attribute to be used on screen
Example:
#include
#include
void main(void)
{
tct_init();
.
.
.
v_aputch('[',v_mkattr(WHITE,MAGENTA));
};
This example should produce at the current cursor location a
White on Magenta background left square bracked.
39
V_APUTS
The v_aputs routine is used to output a string to the screen
at the current cursor location with attributes.
The information passed to this routine includes the string
to be printed and the attribute to use while printing.
Usage:
void v_aputs(string,attr);
char *string; String to output to screen
int attr; Attribute to use for screen
Example:
#include
#include
void main(void)
{
tct_init();
.
.
.
v_aputs("This is a test",v_mkattr(WHITE,BLUE);
};
This should output to the screen at the current cursor loca-
tion the string "This is a test" in White letters on a blue back-
ground.
40
V_ATTR
The v_attr routine is used to change the foreground and
background attributes of a rectangular area on the screen without
affecting any of the information that is on the screen.
The information passed to this routine includes the upper
left corner (row,col), how many rows (rows), how many columns
(cols), and the attribute ((Background << 4) + Foreground). You
can use v_mkattr to supply the attribute value.
Usage:
void v_attr(row,col,rows,cols,attr);
int row; Upper Left Corner Row (1-25)
int col; Upper Left Corner Column (1-80)
int rows; Number of Rows
int cols; Number of Columns
int attr; Attribute value ((Back << 4) + Fore)
Example:
#include
#include
void main(void)
{
tct_init();
.
.
.
v_attr(10,10,10,10,v_mkattr(LIGHTGRAY,BLACK));
};
This should all the characters on the screen in the area in-
side (10,10) - (20,20) to have Lightgray characters with a black
background.
41
V_ATTRC
The v_attrc routine is used to change the foreground and
background attributes of a centered rectangular area on the
screen without affecting any of the information that is on the
screen.
The information passed to this routine includes the top row
(row), the left column (lcol), the right column (rcol), the num-
ber of rows (rows), the number of columns (cols), and the at-
tribute ((Background << 4) + Foreground). You can use v_mkattr
to supply the attribute value.
The centering is figured out by the following means:
(1) Calculate center point between lcol and rcol.
center = ( lcol + rcol ) / 2
(2) Calculate the starting column point.
start = center - ( cols / 2 )
The v_attrc routine will then change the screen attribute to
the new given attribute in the rectangle described by (row,start)
to ( (row + rows),(start + cols) ).
Usage:
void v_attrc(row,lcol,rcol,rows,cols,attr);
int row; Top Row (1-25)
int lcol; Left Column (1-80)
int rcol; Right Column (1-80)
int rows; Number of Rows
int cols; Number of Columns
int attr; Attribute value ((Back << 4) + Fore)
42
V_BOX
The v_box routine is used to draw a bordered box on the
screen with a selectable border, an interior attribute, and a
border attribute.
The information passed to this routine includes the upper
left corners row (row), the upper left corners column (col), the
number of rows (rows), the number of columns (cols), the interior
attribute (wattr), the border attribute (battr), and the border
style (border). You can use v_mkattr to supply the attribute
values for the interior and the border.
Usage:
void v_box(row,col,rows,cols,wattr,battr,border);
int row; Upper Left Corner Row (1-25)
int col; Upper Left Corner Column (1-80)
int rows; Number of Rows
int cols; Number of Columns
int wattr; Interior Attribute value
int battr; Border Attribute value
int border; Border Style
The standard border characters are defined in the v_box
routine. To index to the border desired use the following
TCTOOLS.H defined constants:
ÚÄÄÄÄ¿ ÛÛÛÛÛÛ ÛßßßßÛ
³ ³ SINGLEBORDER Û Û SOLIDBORDER Û Û EVENSOLIDBORDER
ÀÄÄÄÄÙ ÛÛÛÛÛÛ ÛÜÜÜÜÛ
ÉÍÍÍÍ» °°°°°° ±±±±±±
º º DOUBLEBORDER ° ° LHATCHBORDER ± ± MHATCHBORDER
ÈÍÍÍͼ °°°°°° ±±±±±±
ÕÍÍÍ͸ ÞßßßßÝ ²²²²²²
³ ³ MIXEDBORDER1 Þ Ý THINSOLIDBORDER ² ² HHATCHBORDER
ÔÍÍÍ; ÞÜÜÜÜÝ ²²²²²²
ÖÄÄÄÄ·
º º MIXEDBORDER2
ÓÄÄÄĽ
43
V_CLS
This routine is a macro using v_fill with the standard
default call to fill the screen with spaces from row 1 to
Max_text_v and column 1 to Max_text_h. The user must supply the
attribute.
Usage:
void v_cls(attr);
int attr; attribute to clear screen with
The standard call used with v_fill is as follows:
v_fill(1,1,Max_text_v,Max_text_h,attr,' ');
44
V_COL
This routine is used to find out what column the cursor is
pointing to. There is nothing passed to this routine and it
returns an integer column location.
Usage:
int v_col();
Return:
Returns the column position of the cursor.
45
V_CUROFF
This routine will turn off the cursor so that it is not
visible on the screen. However the cursor is still tracked and
moved consistent with writing and v_gorc, etc...
This routine has no parameters and does not return anything.
Usage:
void v_curoff();
46
V_CURON
This routine will turn on the cursor so that it is visible
on the screen. The routine has no parameters and does not return
anything.
Usage:
void v_curon();
47
V_FILL
This routine will fill a rectangular area of the screen with
a specified character possessing a specified attribute.
The rectangular area is defined by the Upper Left Corner row
(row), the upper left corner column (col), the number of rows
(rows), and the number of columns (cols).
Usage:
void v_fill(row,col,rows,cols,attr,ch);
int row; Upper Left Corner Row (1-25)
int col; Upper Left Corner Column (1-80)
int rows; Number of Rows
int cols; Number of Columns
int attr; Attribute value ((Back << 4) + Fore)
char ch; Character to use during fill
48
V_FILLC
The v_fillc routine is used to fill a rectangular area on
the screen.
The information passed to this routine includes the top row
(row), the left column (lcol), the right column (rcol), the num-
ber of rows (rows), the number of columns (cols), the attribute
((Background << 4) + Foreground), and the character for filling
with. You can use v_mkattr to supply the attribute value.
The centering is figured out by the following means:
(1) Calculate center point between lcol and rcol.
center = ( lcol + rcol ) / 2
(2) Calculate the starting column point.
start = center - ( cols / 2 )
The v_fillc routine will then fill in the rectangle
described by (row,start) to ( (row + rows),(start + cols) ).
Usage:
void v_fillc(row,lcol,rcol,rows,cols,attr,ch);
int row; Top Row (1-25)
int lcol; Left Column (1-80)
int rcol; Right Column (1-80)
int rows; Number of Rows
int cols; Number of Columns
int attr; Attribute value ((Back << 4) + Fore)
char ch; Character used for filling
49
V_GETC
This routine will read a single character from the screen at
the current cursor location.
Usage:
int v_getc();
Returns:
Character read at cursor location
50
V_GETCUR
This routine will read the current cursor configuration and
return a boolean True value if the cursor is on or a False value
if the cursor is off. This routine will also return in a passed
variable the current scan line configuration.
Usage:
int v_getcur(&cursor);
int cursor; Variable to hold scan lines.
Returns:
The function returns two values:
0 - Cursor is currently off
1 - Cursor is currently on
51
V_GETDOUBLE
This routine will read a double precision floating point
number from the screen given the starting row and column address
and the number of columns. It must be in a format acceptable to
the Turbo-C routine atof.
Usage:
double v_getdouble(row,col,cols);
int row; Row number for integer
int col; Column Number for integer
int cols; Number of columns
Returns:
The function returns the double value read
52
V_GETFLOAT
This routine will read a single precision floating point
number from the screen given the starting row and column address
and the number of columns. It must be in a format acceptable to
the Turbo-C routine atof.
Usage:
float v_getfloat(row,col,cols);
int row; Row number for integer
int col; Column Number for integer
int cols; Number of columns
Returns:
The function returns the float value read
53
V_GETINT
This routine will read an integer number from the screen
given the starting row and column address and the number of
columns. It must be in a format acceptable to the Turbo-C
routine atoi.
Usage:
int v_getint(row,col,cols);
int row; Row number for integer
int col; Column Number for integer
int cols; Number of columns
Returns:
The function returns the integer read
54
V_GETLONG
This routine will read a long number from the screen given
the starting row and column address and the number of columns.
It must be in a format acceptable to the Turbo-C routine atol.
Usage:
long v_getlong(row,col,cols);
int row; Row number for integer
int col; Column Number for integer
int cols; Number of columns
Returns:
The function returns the long value read
55
V_GETS
This routine will return a rectangular area of the screen as
a string variable given the row, column address of the upper left
hand corner and the number of rows and columns.
The string will consist of only the characters on the screen
without regard to attribute. If more than one row is specified
the two rows are concatenated to form one string.
Usage:
void v_gets(row,col,rows,cols,string);
int row; Row Address of Upper Left Corner
int col; Column Address of Upper Left Corner
int rows; Number of Rows
int cols; Number of Columns
char *string; String variable to hold screen image
56
V_GORC
This routine will position the cursor to the specified row
and column. It is passed the row and column and returns nothing.
Usage:
void v_gorc(row,col);
int row; Row for Cursor (1-25)
int col; Column for Cursor (1-80)
57
V_HEAPOK
The v_heapok routine is used by the v_getint and v_gets
routines to check for the availability of ram to hold temporary
strings during the reading and conversion of the screen informa-
tion.
The user can also use this routine to determine if a
specified size item can be held in heap memory space.
Usage:
int v_heapok(size);
int size; Size of Memory Needed
Return:
0 - Not enough Memory
1 - There is enough Memory
58
V_HLINE
This routine will output a horizontal box character line to
the screen given the row for the line, the left end column and
the number of columns to output. It allows the user to select
single or double line characters to use and fixes any occurrences
of other box characters it runs across while drawing.
Usage:
void v_hline(row,col,cols,attr,linetype);
int row; row address for horizontal line
int col; left end column address
int cols; length of line in columns
int attr; attribute for line
int linetype; type of line to use
0 - single
1 - double
The translations used are as follows:
Left End Right End Intersection
Single: ³ to à ³ to ´ ³ to Å
º to Ç º to ¶ º to ×
Double: ³ to Æ ³ to µ ³ to Ø
º to Ì º to ¹ º to Î
59
V_MKATTR
This routine will accept a foreground and background color
and will create from these a single attribute value which is in
the following format:
attr = ( Background << 4 ) + Foreground
Usage:
attr = v_mkattr(Fore,Back);
int attr; Single Integer attribute used for
screen.
int Fore; Foreground Color
int Back; Background Color
The colors available are as follows:
BLACK BLUE GREEN
CYAN RED MAGENTA
BROWN LIGHTGRAY DARKGRAY
LIGHTBLUE LIGHTGREEN LIGHTCYAN
LIGHTRED LIGHTMAGENTA YELLOW
WHITE
These are defined constants in tctools.h. As an example the
v_mkattr routine can be used in the following ways:
int normal;
normal = v_mkattr(WHITE,BLACK); /* White on Black */
v_fill(1,1,25,80,normal,' ');
or
v_fill(1,1,25,80,v_mkattr(RED,BLUE),'?');
The first one sets the variable 'normal' to white characters
on a black background. This variable can then be used anywhere
you see attr in this document. The second shows that the
v_mkattr routine can be used in the call to another routine for
special one time cases.
All the non-blinking color combinations are already provided
in tctools.h in the form of FOREGROUNDONBACKGROUND. Example:
WHITEONBLUE.
60
V_MODCUR
This routine allows the user to set the cursor to any style
acceptable by the system. The routine also returns the cursor
style that the cursor is presently at allowing easy returning to
the original style.
Usage:
int oldcurs;
oldcurs = v_modcur(cursor);
int oldcurs; This will be the old cursor style
int cursor; This is the style to set the cursor
to.
Note: This routine uses video services function #1. The
format of the cursor variable is as follows:
cursor = ( startline << 4 ) + endline
where startline is the starting scan line and endline
is the ending scan line for the cursor.
61
V_PAGE
This routine will change which video page is displayed on
the screen. In order to use this there must be spare pages of
memory on your video card that the vlib system and the bios can
find.
Usage:
void v_page(page);
int page; Page number to display
Must be between 0 and Maxpages
62
V_PUTC
This routine will output a character at a given row and
column with a given attribute.
Usage:
void v_putc(row,col,attr,ch);
int row; Row Address for Character
int col; Column Address for Character
int attr; Attribute for Character
char ch; Character to output
63
V_PUTCH
This routine will output a character to the screen at the
current cursor location without affecting the attributes on the
screen.
Usage:
void v_putch(ch);
char ch; Character to be output
64
V_PUTS
This routine will output a string at the current cursor
location without affecting the attribute currently in force on
the screen. This routine is a macro of the v_aputs routine.
Usage:
void v_puts(string);
char *string; string to output to screen
The macro expansion for this routine is as follows:
v_puts(string) Í> v_aputs(string,-1)
65
V_ROW
This routine is used to find out what row the cursor is
pointing to. There is nothing passed to this routine and it
returns an integer row location.
Usage:
int v_row();
Return:
Returns the row position of the cursor.
66
V_SETMODE
This routine will allow the user to change the video mode
for the screen. This allows changing to graphics modes or 40
column / 80 columns, Monochrome vs. color, etc...
Usage:
int v_setmode(mode);
int mode; Mode to set Screen Mode to
Returns:
Current Mode
67
V_VLINE
This routine will output a vertical box character line to
the screen given the column for the line, the top end row and the
number of rows to output. It allows the user to select single or
double line characters to use and fixes any occurrences of other
box characters it runs across while drawing.
Usage:
void v_vline(row,col,rows,attr,linetype);
int row; top end row address
int col; column for vertical line
int rows; length of line in rows
int attr; attribute for line
int linetype; type of line to use
0 - single
1 - double
The translations used are as follows:
Top End Bottom End Intersection
Single: Ä to Â Ä to Á Ä to Å
Í to Ñ Í to Ï Í to Ø
Double: Ä to Ò Ä to Ð Ä to ×
Í to Ë Í to Ê Í to Î
68
V_WRITE
This routine will write the contents of a given string to
the screen at the location pointed to by row and col. The
v_write routine will also allow you to set the attribute for the
screen in the area written to.
Usage:
void v_write(row,col,attr,string);
int row; Row Address to write at
int col; Column Address to write at
int attr; Attribute to use for characters
char *string; String to put on screen
Note: the attribute can be -1 which will leave the attribute
the same as on the screen.
69
V_WRITEC
This routine will write the contents of a given string to
the screen centered between the lcol and rcol parameters.
The information passed to this routine includes the top row
(row), the left column (lcol), the right column (rcol), the at-
tribute ((Background << 4) + Foreground), and the string for
writing with. You can use v_mkattr to supply the attribute
value.
The centering is figured out by the following means:
(1) Calculate center point between lcol and rcol.
center = ( lcol + rcol ) / 2
(2) Calculate the starting column point.
start = center - ( string length / 2 )
Usage:
void v_writec(row,lcol,rcol,attr,string);
int row; Row Address to write at
int lcol; Left column for centering
int rcol; Right column for centering
int attr; Attribute to use for characters
char *string; String to write
70
V_WRITEL
This routine will write the contents of a given string to
the screen at the location pointed to by row and col, and will
clamp the length to the number of characters specified. The
v_writel routine will also allow you to set the attribute for the
screen in the area written to.
Usage:
void v_writel(row,col,attr,len,string);
int row; Row Address to write at
int col; Column Address to write at
int attr; Attribute to use for characters
int len; Number of characters to write
char *string; String to put on screen
Note: the attribute can be -1 which will leave the attribute
the same as on the screen.
71
V_WRTPAG
This routine will allow the user to change the video page
where the vlib routines work. The main benefit of this is the
ability to setup a secondary screen on a second page of video
memory without the user of the application seeing the setup.
Then it can be displayed quickly with v_page.
Usage:
void v_wrtpag(page);
int page; Page number for vlib routines to
use.
72
Quick Reference for VLIB Routines
void v_aputch(ch,attr);
void v_aputs(string,attr);
void v_attr(row,col,rows,cols,attr);
void v_attrc(row,lcol,rcol,rows,cols,attr);
void v_box(row,col,rows,cols,wattr,battr,border);
void v_cls(attr);
int v_col();
void v_curoff();
void v_curon();
void v_fill(row,col,rows,cols,attr,ch);
void v_fillc(row,lcol,rcol,rows,cols,attr,ch);
int v_getc();
int v_getcur(&cursor);
double v_getdouble(row,col,cols);
float v_getfloat(row,col,cols);
int v_getint(row,col,cols);
long v_getlong(row,col,cols);
void v_gets(row,col,rows,cols,string);
void v_gorc(row,col);
int v_heapok(size);
void v_hline(row,col,cols,attr,linetype);
int v_mkattr(foreground,background);
int v_modcur(cursor);
void v_page(page);
void v_putc(row,col,attr,ch);
void v_putch(ch);
void v_puts(string);
int v_row();
int v_setmode(mode);
void v_vline(row,col,rows,attr,linetype);
void v_write(row,col,attr,string);
void v_writec(row,lcol,rcol,attr,string);
void v_writel(row,col,attr,length,string);
void v_wrtpag(page);
row - Integer Row Number (1-25)
col - Integer Column Number (1-80)
lcol - Integer Left Column (used for centering)
rcol - Integer Right Column (used for centering)
rows - Integer Number of Rows
cols - Integer Number of Columns
page - Integer Video Page Number
attr - Integer Attribute value (see pg 36 )
length - Integer Number of Characters to write
ch - Character to use in fill routines
string - Array of Characters
numb - Number to return screen image as integer in
color - Color to set Pixel to
size - Size of area to check size of memory for
mode - Video Mode to set screen to
linetype - Line Type for Line drawing routines (single or double)
cursor - Cursor configuration returned by v_getcur
73
WLIB Library
Introduction
The WLIB system is a fast, easy to use and sophisticated
windowing environment for the Turbo-C developer. The routines
are mostly written in the 'C' language except for the W_PRINTF
routine which is written in assembly language and assembled using
the either the Microsoft Macro Assembler V5.0 or the Borland
Turbo Assembler V1.0.
The WLIB system implements a 'pop out' window system for use
in Turbo-C. The WLIB system handles all the nightmares of han-
dling multiple windows for the user and leaves the user free to
develop the application code for the project.
The windows generated by the WLIB system are fully tiled and
completely seperate from one another. They can have one of many
different border styles, up to six individual titles, be any size
from 2 x 2 to the size of the screen, zoomed in from the back-
ground as well as having one of several shadows applied to them.
Tiled Windows
The term tiled windows comes from the idea that if you had a
stack of say floor tiles and you spread them out on the floor in
a random order it would not be that hard to pick one tile out of
the stack and put that tile on the top of the stack. Tiled win-
dows are much the same in this respect. Take the following ex-
ample of sequences for instance:
74
First: Window #1 is opened Second: Window #2 is opened
ÚÄ Window #1 Ä¿ ÚÄ Window #1 Ä¿
³ ³ ³ ³
³ ³ ³ ÉÍ Window #2 Í»
³ ³ ³ º º
³ ³ ³ º º
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄĺ º
º º
ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ
Third: Window #3 is opened Fourth: Window #2 is accessed
ÚÄ Window #1 Ä¿ ÚÄ Window #1 Ä¿
³ ³ ³ ³
³ ÉÍ Window #2 Í» ³ ÉÍ Window #2 Í»
ÕÍ Window #3 ͸ º ÕÍ Window #3º º
³ ³ º ³ º º
³ ³ º ³ º º
³ ³ º ³ º º
³ ³ÍÍÍÍÍÍÍÍÍÍͼ ³ ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ
ÔÍÍÍÍÍÍÍÍÍÍÍÍ; ÔÍÍÍÍÍÍÍÍÍÍÍÍ;
Fifth: Window #1 is accessed Sixth: Window #3 is closed
ÚÄ Window #1 Ä¿ ÚÄ Window #1 Ä¿
³ ³ ³ ³
³ ³w #2 Í» ³ ³w #2 Í»
ÕÍ Wi³ ³ º ³ ³ º
³ ³ ³ º ³ ³ º
³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ º
³ ³ º º º
³ ³ÍÍÍÍÍÍÍÍÍÍͼ ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ
ÔÍÍÍÍÍÍÍÍÍÍÍÍ;
Seventh: Window #1 is closed
ÉÍ Window #2 Í»
º º
º º
º º
º º
ÈÍÍÍÍÍÍÍÍÍÍÍÍͼ
As can be seen you can shuffle the stack of windows any way
you want and the WLIB system keeps track of whats where and how
to redraw it and whats behind it.
75
Zoomed Windows
The WLIB system also allows the user to select whether win-
dows will be zoomed out of screen or not. Zooming consists of
starting with a small box and subsequently drawing larger boxes
until the window border is at the size requested. The global
variable Zoom_window can be set by any user routine to select or
deselect this function. To select zooming set Zoom_window to a
1, to deselect the zooming feature set Zoom_window to a 0.
Shadowed Windows
Shadowed windows is another feature of the WLIB system that
can be selected and deselected by the user. Shadowing consists
of a border surronding one of the corners of the window. The
shadow directions implemented are as follows:
Left Down using Light Hatch Right Down using Medium Hatch
ÚÄÄ Window ÄÄ¿ ÚÄÄ Window ÄÄ¿
°°³ ³ ³ ³±±
°°³ ³ ³ ³±±
°°³ ³ ³ ³±±
°°³ ³ ³ ³±±
°°ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ±±
°°°°°°°°°°°°°° ±±±±±±±±±±±±±±
Left Up using Heavy Hatch Right Up using Solid Hatch
²²²²²²²²²²²²²² ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
²²ÚÄÄ Window ÄÄ¿ ÚÄÄ Window ÄÄ¿ÛÛ
²²³ ³ ³ ³ÛÛ
²²³ ³ ³ ³ÛÛ
²²³ ³ ³ ³ÛÛ
²²³ ³ ³ ³ÛÛ
ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ
Each shadow can have its own color attributes allowing the
maximum effect based on the window colors. There are three
global variables that can be set to control the shading of win-
dows from any user routine. These are (1) Shadow_window which
controls the direction of the shadow, (2) Shadow_attr which con-
trols the color attributes of shadows, and (3) Shadow_type which
controls what characters are used for the shadows.
76
Shadowed Windows (cont)
At present Shadow_window can have one of five values as fol-
lows:
1. NODIR - No direction means no shadow
2. LEFTUP - Shadow to the left and above the window.
3. RIGHTUP - Shadow to the right and above the window.
4. LEFTDOWN - Shadow to the left and below the window.
5. RIGHTDOWN - Shadow to the right and below the window.
Shadow_type can be any one of the following:
1. BLANKSHD - Shadow with blanks.
2. LHATCHSHD - Shadow using light hatch characters.
3. MHATCHSHD - Shadow using medium hatch characters.
4. HHATCHSHD - Shadow using heavy hatch characters.
5. SOLIDSHD - Shadow using solid characters.
The Shadow_attr value can be set via use of the v_mkattr
routine the form to follow for White characters on a blue back-
ground would be:
Shadow_attr = v_mkattr(WHITE,BLUE);
See the description of v_mkattr on page 58 for a full descrip-
tion of the v_mkattr routine and a discussion of the possible
colors.
Border Styles
The WLIB system allows for the use of many different border
styles in the creation of windows. These border styles are the
same as that used by the v_box routine from the VLIB system. See
page 41 for a full list of the possible border styles for windows
in the WLIB system.
77
Window Titles
Windows created with the WLIB system can have up to six dif-
ferent titles applied to them. Following is a window with all
six titles:
ÉÍ Top Left ÍÍÍÍÍÍÍ Top Center ÍÍÍÍÍÍÍ Top Right Í»
º º
º º
º º
º º
º º
ÈÍ Bottom Left ÍÍÍ Bottom Center ÍÍ Bottom Right ͼ
Please refer to page 88 for a full description of how to
specify titles for the WLIB system.
Usage
Once these files have been copied onto the hard disk so
Turbo-C can find them the WLIB system is set and ready to go.
The general program format for applications using the WLIB system
is as follows:
Main File Subroutine File
#include
#include
void main(void) int subroutine(void)
{ {
tct_init(); any wlib routines
. any vlib routines
. };
any wlib routines
any vlib routines
.
.
};
The only requirement is that you call the tct_init routine
before calling any other wlib or vlib functions.
78
Usage (cont)
To declare a window and to get it open and on the screen is
very simple. Here is an example program that opens a window and
then puts a title on the top border with centering and then
removes the window:
#include
#include
void main(void)
{
WINDOWPTR window;
tct_init();
window = w_open(10,10,15,20,v_mkattr(WHITE,BLUE),
v_mkattr(LIGHTGRAY,BLACK),MIXEDBORDER1);
w_title(window,v_mkattr(MAGENTA,GREEN),TOPCENTER,
"This is a title");
w_close(window);
};
In order to use the system libraries effectively it is
easiest to use a project file of the style:
myprogram (myprograms.h)
c:\turboc\lib\tctoolsx.lib
Name this file myprogram.prj and select the file using the
project menu selection under Turbo-C. The tctoolsx.lib files are
the files that contains the version of the VLIB and WLIB routines
for the model you are using.
79
W_CHANGE
The w_change routine is used to change the size of a window
to a new number of rows and columns. If the window is not the
top window then it is first moved to the top.
Usage:
void w_change(window,rows,cols,update);
WINDOWPTR window; Window to modify
int rows; New number of rows
int cols; New number of columns
int update; Not Implemented.
80
W_CLOSE
This routine will close a window on the screen given its
pointer. The memory is deallocated and what ever was behind the
window is either moved to other windows or redisplayed.
Usage:
void w_close(window);
WINDOWPTR window; Window to Close
81
W_CLOSEALL
This routine will systematically close all windows on the
screen starting with the top window and working back through the
screen. This is a good routine to use when exiting a program due
to an error because it frees all of DOS's memory.
Usage:
void w_closeall();
82
W_CLS
This routine will clear the screen area inside a window
given the attribute and the window pointer of the window.
Usage:
void w_cls(window,attr);
WINDOWPTR window; window to clear
int attr; attribute to clear with
83
W_GORC
This routine will position the cursor to the given row and
column address inside a window. The row and column address are
relative to the origin of the window instead of the screen like
v_gorc.
Usage:
void w_gorc(window,row,col);
WINDOWPTR window; window to use for cursor move
int row; row address relative to window
int col; column address relative to
window
84
W_INTERSECT
This routine will fix all intersections between windows ef-
fectively correcting all conflicts of background information
while bringing a window forward to be the top window.
Usage:
void w_intersect(window);
WINDOWPTR window; Window to fix background for
85
W_MOVE
This routine will move a window to the specified row, column
address. If the window is not the top window the window is first
brought to the top and then moved to the new row and column for
the upper left hand corner.
Usage:
void w_move(window,row,col);
WINDOWPTR window; Window to move
int row; New row address for upper left
corner of window.
int col; New column address for upper left
corner of window.
86
W_OPEN
This routine will open a window on the screen given its up-
per left corner row and column, the number of rows and columns
describing the size of the window, the attribute to use for the
inside of the window, the attribute to use for the border, and
the border style.
Usage:
w = w_open(row,col,rows,cols,wattr,battr,border);
WINDOWPTR w; Window pointer returned
int row; Upper left corner row
int col; Upper left corner column
int rows; Number of rows
int cols; Number of columns
int wattr; Attribute for inside of window
int battr; Attribute for border
int border; Border Style
Note: See page 41 for a full description of individual
border styles.
87
W_PRINTF
This routine will allow the user to use the standard printf
formatted print controls for printing within a window. This com-
mand uses the routine cprintf from the Turbo-C runtime library
with the only addition being the possibility to select which win-
dow to print to.
Usage:
void w_printf(window,fmt,...);
WINDOWPTR window; Window to print to
char *fmt; Format string for printf
... Variables as called for in variable
string.
88
W_SHADOW
This routine will shadow a window based on the three global
variables Shadow_window, Shadow_attr and Shadow_type.
Usage:
void w_shadow(direction,shadestyle,row,col,rows,cols);
DIRTYPE direction; Direction of Shadow
SHADES shadestyle; Type of Shadow
int row; Upper left corner row
int col; Upper left corner column
int rows; Number of rows
int cols; Number of columns
89
W_TITLE
This routine will allow the user to put titles on windows.
The w_title routine requires a window pointer, the attribute to
use for the title, the justification for the title, and a string
containing the title.
Usage:
void w_title(window,attr,justify,title);
WINDOWPTR window; Window to use for title
int attr; Attribute to use for title
TITLEDIR justify; Justification to use for title
char *title; Title itself
Titles can be placed at six different areas or justifica-
tions on a window. The following defined constants make it easy
to inform w_title of which one to use:
1. TOPLEFT - Top Border Left Justified
2. TOPRIGHT - Top Border Right Justified
3. TOPCENTER - Top Border Center Justified
4. BOTTOMLEFT - Bottom Border Left Justified
5. BOTTOMRIGHT - Bottom Border Right Justified
6. BOTTOMCENTER - Bottom Border Center Justified
These constants are included in tctools.h in the enumeration
variable type TITLEDIR.
90
W_TOP
This routine allows the user to bring a window to the top of
the screen. All of the WLIB routines will perform this function
but this function is provided to the user for the case in which
he/she does not want to use one of the other WLIB routines to ac-
cess a window.
Usage:
void w_top(window);
WINDOWPTR window; Window to make top
91
W_ZOOM
This routine is a low level routine to zoom a window to its
final size. It uses the global variables Zoom_window and
Zoom_delay to generate the effect.
Usage:
void w_zoom(row,col,rows,cols,wattr,battr,border);
int row; Upper left corner row for window
int col; Upper left corner column for window
int rows; Number of rows in window
int cols; Number of columns in window
int wattr; Interior attribute in use for window
int battr; Border attribute in use for window
int border; Border style in use for window
92
Quick Reference for WLIB Routines
void w_change(window,rows,cols,update);
void w_close(window);
void w_closeall();
void w_cls(window,attr);
void w_gorc(window,row,col);
void w_intersect(window);
void w_move(window,row,col);
WINDOWPTR w_open(row,col,rows,cols,wattr,battr,border);
void w_printf(window,char *fmt,...);
void w_shadow(direction,shadetype,row,col,rows,cols);
void w_title(window,attr,justify,title);
void w_top(window);
void w_zoom(row,col,rows,cols,wattr,battr,border);
row - Integer Row Number (1-25)
col - Integer Column Number (1-80)
rows - Integer Number of Rows
cols - Integer Number of Columns
attr - Integer Attribute value (Background << 4) + Foreground
Note: A value of -1 will leave the current
attribute on the screen.
wattr - Integer Attribute value for inside a window
battr - Integer Attribute value for border of a window
window - Pointer to a window
fmt - Printf Format String
justify - Integer Title Justification Number
title - Character String title
border - Integer Border Style Number
93
A. KLIB Form Edit Format Description
The two form editing routines included in the KLIB section
of the TC-Tools library should prove to be very useful as general
purpose data entry handlers. This is due to the wealth of field
specifications allowed. The form editors can handle characters,
numbers, hex numbers, ascii or alphanumeric. They will also
capitalize all entrys if desired. The following is the basic
list of field qualifiers:
c - Alphabetic Character a-z & A-Z
C - Capitalized Alphabetic Character A-Z
n - Alphanumeric Character a-z, A-Z or 0-9
N - Capitalized Alphanumeric Character A-Z or 0-9
a - Ascii Characters 0x00 to 0x7F
A - Capitalized Ascii Characters 0x00 to 0x7F
with a-z converted to A-Z
9 - Only digits 0-9
x - Hexidecimal Digits 0-9, a-f and A-F
X - Capitalized Hexidecimal Digits 0-9 and A-F
With these field definitions it is quite easy to produce
formats of varying complexity. Here are some examples:
Date - 99/99/99 - MM/DD/YY 12/12/88
Date - 99-99-99 - MM-DD-YY 12-12-88
Date - AAA 99, 9999 - MMM DD, YYYY May 06, 1989
All of these are valid formats for the form editors any
character not in the above list found in the format is considered
to be non-editable and all cursor movement and character place-
ment moves around it. How about more examples:
Integer - 9999 - 1234
Float - 99.99E99 - 12.34E12
Hex - XXXXh - 76ABh
94
B. KLIB Editing Keys
K_FORMLEFT Editing Keys
Home - Will move the cursor to the first
editable character position in the
field.
End - Will move the cursor to the last
editable character position in the
field.
Insert - Switches between Insert and Overstrike
Modes. Insert can be seen by an in-
crease in size of the cursor over over-
strike. The default is overstrike.
Left Arrow - Moves the cursor one character to the
left and will jump over any non-editable
space.
Right Arrow - Moves the cursor one character to the
right and will jump over any non-
editable space.
Backspace - Deletes the character just before the
cursor and moves all characters to the
right of the cursor one character left
to fill the gap.
Delete - Deletes the character at the current
cursor position and moves the rest of
the string to the left one character.
Escape - Clears the string and re-initializes it
to contain blanks and non-editable
characters.
Carriage Return - Causes acceptance of the field edit and
returns from k_formleft routine.
Any other Key - If within key range as specified in for-
mat (see Appendix A) then inserts or
overwrites the character at the current
cursor position.
95
K_FORMRIGHT Editing Keys
Home - Will move the cursor to the first
editable character position in the
field.
End - Will move the cursor to the last
editable character position in the
field.
Insert - Switches between Insert and Overstrike
Modes. Insert can be seen by an in-
crease in size of the cursor over over-
strike. The default is overstrike.
Left Arrow - Moves the cursor one character to the
left and will jump over any non-editable
space.
Right Arrow - Moves the cursor one character to the
right and will jump over any non-
editable space.
Backspace - Deletes the character just before the
cursor and moves all characters to the
right of the cursor one character left
to fill the gap.
Delete - Deletes the character at the current
cursor position and moves the rest of
the string to the left one character.
Escape - Clears the string and re-initializes it
to contain blanks and non-editable
characters.
Carriage Return - Causes acceptance of the field edit and
returns from k_formright routine.
Any other Key - If within key range as specified in for-
mat (see Appendix A) then inserts or
overwrites the character at the current
cursor position.
96
K_STRINGLEFT Editing Keys
Home - Will move the cursor to the upper left
hand corner of the string field.
End - Will move the cursor to the last charac-
ter found in the field.
Insert - Switches between Insert and Overstrike
Modes. Insert can be seen by an in-
crease in size of the cursor over over-
strike. The default is overstrike.
Left Arrow - Moves the cursor one character to the
left and will wrap the cursor from row
to row going up.
Right Arrow - Moves the cursor one character to the
right and will wrap the cursor from row
to row going down.
Up Arrow - Moves the cursor up one row and clamps
it at the top row.
Down Arrow - Moves the cursor down one row and clamps
it at the last row of text.
Page Up - Moves the cursor to the top row in the
same column.
Page Down - Moves the cursor to the last text row.
If the current column is greater than
the ending column then it clamps it at
the ending column
Backspace - Deletes the character just before the
cursor and moves all characters to the
right of the cursor one character left
to fill the gap.
Delete - Deletes the character at the current
cursor position and moves the rest of
the string to the left one character.
Escape - Clears the string and repositions the
cursor to the upper left corner posi-
tion.
Carriage Return - Causes acceptance of the edit and
97
returns from k_stringleft routine.
Any other Key - If within ASCII range then inserts or
overwrites the character at the current
cursor position.
98
K_STRINGRIGHT Editing Keys
Home - Will move the cursor to the upper left
hand corner of the text in the string
field.
End - Will move the cursor to the last charac-
ter position.
Insert - Switches between Insert and Overstrike
Modes. Insert can be seen by an in-
crease in size of the cursor over over-
strike. The default is overstrike.
Left Arrow - Moves the cursor one character to the
left and will wrap the cursor from row
to row going up.
Right Arrow - Moves the cursor one character to the
right and will wrap the cursor from row
to row going down.
Up Arrow - Moves the cursor up one row and clamps
it at the top row.
Down Arrow - Moves the cursor down one row and clamps
it at the last row of text.
Page Up - Moves the cursor to the top row in the
same column. If the current column is
less than the starting column of the
text then it is clamped to the start
column.
Page Down - Moves the cursor to the last text row.
Backspace - Deletes the character at the current
cursor position and moves all characters
to the right of the cursor one character
left to fill the gap. Then refills the
field from the lower right corner.
Delete - Deletes the character to the right of
the cursor and moves the rest of the
string to the right one character.
Escape - Clears the string and repositions the
cursor to the lower right corner posi-
tion.
Carriage Return - Causes acceptance of the edit and
99
returns from k_stringleft routine.
Any other Key - If within ASCII range then inserts or
overwrites the character at the current
cursor position.
100
C. Menu Structure and Initialization
The k_menu routine is a powerhouse of user interface
capability. It allows a relatively easy description of a menu to
be layed out in static structures at compile time. Soon I hope
to also have as part of the TC-Tools system a menu generator that
will generate a .h file for a specified menu. This routine is
also a lead into a pull-down menu system I am currently working
on.
Basically to describe a menu there is three structures that
need to be defined and they are:
menu - Holds the overall menu parameters
menuline - Holds each individual line of the menu
titleline - Holds each individual title of the menu
To see the structure of these please look near the start of
the file TCTOOLS.H. Now for an example:
static menuline L004 = {"Selection Line #3",1,LEFT,WHITEONBLUE,
WHITEONGREEN,0,3,NULL,NULL,NULL};
static menuline L003 = {"-----------------",0,LEFT,WHITEONBLUE,
WHITEONGREEN,0,0,&L004,NULL,NULL};
static menuline L002 = {"Selection Line #2",1,LEFT,WHITEONBLUE,
WHITEONGREEN,0,2,&L003,NULL,NULL};
static menuline L001 = {"Selection Line #1",1,LEFT,WHITEONBLUE,
WHITEONGREEN,0,1,&L002,NULL,NULL};
static titleline T001 = {" This is a 4 line Menu",TOPCENTER,
"WHITEONMAGENTA,NULL};
static menu Menuname = {0,0,0,0,0,WHITEONBLUE,WHITEONMAGENTA,
CENTER,MIXEDBORDER1,&L001,&T001};
This sequence of statements above your main entry produces a
menu that looks like this centered in the middle of the screen.
ÕÍÍ This is a 4 line Menu Í͸
³ Selection Line #1 ³
³ Selection Line #2 ³
³ ----------------- ³
³ Selection Line #3 ³
ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ;
The cursor would automatically skip line #3 and return 1, 2
or 3 as the return value based on when the user hit return. For
a further example of this code look at TKEYS.C.
101
D. Global Variables, #defines and Enumerations
PC-Types
IBMCONVERTIBLE IBM - Convertible PC
UNKNOWN1 Unknown Model
UNKNOWN2 Unknown Model
IBMAT IBM-AT - 80286 PC
IBMPCJR IBM-PCJR - 8088 PC
IBMXT IBM-XT - 8088 PC
IBMPC IBM-PC - 8088 PC
Border Styles
NOBORDER No Border on Box
BLANKBORDER Blank Border on Box
SINGLEBORDER Single Line Border on Box
DOUBLEBORDER Double Line Border on Box
MIXEDBORDER1 Mixed V-Single H-Double Border
MIXEDBORDER2 Mixed H-Single V-Double Border
SOLIDBORDER Solid Fill Border on Box
EVENSOLIDBORDER Even Width Solid Fill Border on Box
THINSOLIDBORDER Thin Width Solid Fill Border on Box
LHATCHBORDER Light Hatch Fill Border on Box
MHATCHBORDER Medium Hatch Fill Border on Box
HHATCHBORDER Heavy Hatch Fill Border on Box
USERBORDER User Border on Box
Line Styles
SINGLELINE Single Line
DOUBLELINE Double Line
Title Justifications
TOPLEFT Top Border - Left Justified
TOPRIGHT Top Border - Right Justified
TOPCENTER Top Border - Center Justified
BOTTOMLEFT Bottom Border - Left Justified
BOTTOMRIGHT Bottom Border - Right Justified
BOTTOMCENTER Bottom Border - Center Justified
Shading Styles
BLANKSHD Blank Shading - Background Color
LHATCHSHD Light Hatch Fill Shading
MHATCHSHD Medium Hatch Fill Shading
HHATCHSHD Heavy Hatch Fill Shading
SOLIDSHD Solid Fill Shading
102
General Directions
LEFT Left Direction
RIGHT Right Direction
CENTER Center Direction
LEFTUP Left and Up Direction
RIGHTUP Right and Up Direction
LEFTDOWN Left and Down Direction
RIGHTDOWN Right and Down Direction
Keyboard Edit Directions
FROMLEFT Edit Field from Left Side
FROMRIGHT Edit Field from Right Side
Constant Length String Definitions
str8 String of 8 chars for Borders
str80 String of 80 chars = 1 line w/o attr
str160 String of 160 chars = 1 line w/ attr
Global Variables
Graph_driver Graphics Driver Code
Graph_mode Graphics Mode Code
Graph_error Graphics Error Code
Page_zero_seg Text Page 0 Segment
Cur_page_seg Current Text Page Segment
Max_text_page Maximum Text Pages
Cur_text_page Current Text Page
Cardwait Card wait flag
Systemid PC Model Identification
Submodelid Sub Model Identification
Max_text_h Number of Columns on Screen
Max_text_v Number of Rows on Screen
Write_update Update Cursor Position Flag
Last_window Pointer to Last Window on List
Shade[5] Shade Style Array
Zoom_window Zoom Window Flag
Zoom_delay Zoom Delay Value - Tics
Shadow_window Shadow Window Flag
Shadow_attr Shadow Screen Attribute
Shadow_type Shadow Style Value
Keypad Keypad Flag
103
Color Definitions
BLACK BLUE GREEN
CYAN RED MAGENTA
BROWN LIGHTGRAY DARKGRAY
LIGHTBLUE LIGHTGREEN LIGHTCYAN
LIGHTRED LIGHTMAGENTA YELLOW
WHITE
Non-Blinking Color Combinations
See TCTOOLS.H
Keyboard Return Values
See TCTOOLS.H
104
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/