Dec 192017
 
Public Domain C Windowing package. (Full C source).
File WIN.ZIP from The Programmer’s Corner in
Category C Source Code
Public Domain C Windowing package. (Full C source).
File Name File Size Zip Size Zip Type
SCRIO.C 18449 3492 deflated
SCRIO.OBJ 2807 1513 deflated
WIN.C 25196 4069 deflated
WIN.DOC 11283 4119 deflated
WIN.H 4037 808 deflated
WIN.OBJ 4121 1997 deflated
WINDEMO.C 5873 1705 deflated
WINDEMO.EXE 11797 6813 deflated
WINDEMO.OBJ 3666 2128 deflated

Download File WIN.ZIP Here

Contents of the WIN.DOC file




C-WIN - A Public Domain 'C' Windowing System
--------------------------------------------

Introduction
============

This package was developed as a result of my desire to have a windowing
system written in a portable language. In the three years I've been
using the 'C' language I've progressed through six compilers. Each time
I've had to make extensive modifications to assembly language
subroutines to adapt them to the new compiler environment. In addition,
I've occasionally used commercial libraries of functions for which I've
only had executable code. These libraries, of course, did not work with
the new compiler and I was faced with a choice of purchasing a new
version of the library or writing my own functions to replace the
library routines I was using. After encountering this agony several
times I've come up with a simple solution. If I don't have the source
code to a function, it does not get linked into any of my programs!

I'm well aware that there are many commercial windowing packages
available and some are even willing to give you the source code. These
packages must be outstanding because they sure cost a lot.
Nevertheless, here is my first effort at a 'C' windowing package.
Humble as it may be the cost is right on. It is free and you can have
the source code. I don't want to sell it to you and I don't want you to
make a contribution if you like it.It is 100% public domain software,
do with it as you please.

Compilers Supported
===================

This software has been developed using both Borland Turbo C V1.0 and
Microsoft C V5.00. I've also tested the code using Microsoft C V4.00.
I've tried to write this code in a portable manner and it should compile
with little or no change on most of the newer compilers which are
following the ANSI standard. I have used the Microsoft extension
keywords "pascal" and "near" to generate more efficient code but, if
your compiler doesn't support them, they can be removed without harming
anything.

Files
=====

The package consists of a single header and two source code files:

WIN.H The header file for use by the application code
as well as the windowing library code.

WIN.C The high level windowing functions. All code in
this file is machine independent.

SCRIO.C The low level screen access routines. This code
is machine dependent and is written for the IBM/PC
and true compatibles.

WINDEMO.C A short demo program which shows some of the
windowing functions in action.

Video Equipment
===============

This code will work properly on both TTL Monchrome and IBM CGA video
boards. In addition, it should work fine on both EGA and VGA boards.
Following are some comments related to these video cards:

-Monochrome: The ScrInitialize function will detect a monochrome
mode and automatically convert all attribute bytes
to black and white. This is done in a manner that
I find to be reasonable, if you disagree change the
code that does the conversion.

-CGA: Due to the snow generated by most CGA cards if the
video buffer is accessed during video refresh this
code disables the video signal while directly
updating the video buffer.

-EGA: Currently EGA color modes are treated as CGA. Most
schemes I've seen to detect an EGA search the EGA
extended BIOS for the IBM copyright notice. This,
to me, is not a good approach. I have seen one
method which used an INT 10h function added by the
EGA which caused no harm if an EGA was not
installed. At the time I read about it I was not
really interested in EGA and now that I am I can't
find the article. I also don't have access to EGA
documentation so I can't even figure out which
routine was being used.If you know how to detect
EGA add the code to ScrInitialize. Most EGA's
will work as CGA with the video signal being
disabled but this is not required with the EGA.

-VGA: Currently VGA color modes are treated as CGA. I've
never seen a VGA or any docs on it. If you've got
one, I hope this code works. If it doesn't,
I'm sorry, but I can't help.


Room for Improvement
====================

The functions included in this package provide the basics for developing
an application using a windowed environment. There is certainly room
for improvement and I encourage you to enhance the functionality of
this package. Some suggestions:

- Enhance the Move and Hide window functions to support windows which
are not fully visible (i.e. partially overlayed).

- Use these functions to develop a higher level of support for things
like 123 style menus, pull down menus, data entry forms, etc.

- Speed up the TextOut functions.These functions rely on the ROM
BIOS character out routines as a result of my desire to stay 100%
with 'C' code. I was tempted many times to rip out ScrTextOut and
replace it with assembly code which directly accessed the hardware.
I've resisted only because the BIOS code is tolerable in most
situations and this code is much more portable than assembly code.
With higher speed machines becoming more commonplace this problem
may diminish.

I intend to work on some of these enhancements as time permits and I'm
sure you can think of many more. I would be very pleased if people
making fixes and enhancements to this code would communicate their work
to me. If we all work together we may be able to come up with a public
domain package which rivals those expensive commercial versions.

Disclaimer
==========

Many people in the software industry are quite happy to sell you
software while assuming no responsibility for its functionality or
usefulness.I am happy to give you this software but I also cannot
accept any responsibility for it. I've tested this code and to the best
of my knowledge it works and contains no errors. I simply state that I
think it is both functional and useful, I do not guarantee it. You need
to test the code to determine if it will be useful to you. If you
encounter problems with it, fix them. That's why you wanted the source
in the first place, right?

Bob Withers
649 Meadowbrook St
Allen, Texas 75002

Functions Available in WIN.C
============================

WinExplodeWindow Draws an exploding window on the screen. The
screen area behind the window is not saved, the
window is simply drawn.

WinDrawWindow Draws a window on the screen without saving the
screen area behind the window.

WinCreateWindow Creates a screen window and displays it at the
requested location. The are behind the window
is saved and will be restored when the window
is destroyed.

WinDestroyWindow Destroys a previously created window. The
saved screen area is restored and all resources
allocated to support the window are freed.

WinScrollWindowUp Scrolls a window up one line.

WinScrollWindowDown Scrolls a window down one line.

WinSetCursorPos Positions the cursor either relative to an
open window or to absolute screen locations.

WinClearScreen Clears a window (or the entire screen) to the
requested color attribute.

WinTextOut Displays a string within the requested window
at the current cursor location (for the
selected window). If the string would extend
beyond the window it is truncated.

WinCenterText Centers a text string within a window on the
requested row.

WinMoveWindow Moves an existing window to a new location on
the screen. There are a couple of caveats in
this version of the package:
1) The window must be fully visible (i.e. no
other window overlaying any part of it)
for this routine to work properly.
2) It is the callers responsibility to
insure that the moved window will still
fit on the screen at the new location.
3) The size of the window may not be changed,
it can only be moved to a new location.

WinGetWindowRow Returns the absolute row (1 relative) of the
selected window.

WinGetWindowCol Returns the absolute column (1 relative) of
the selected window.

WinGetWindowWidth Returns the number of columns available for
text within the selected window. If the
window was created with a border, this value
will be two less than the width specified in
the create call.

WinGetWindowHeight Returns the number of rows available for text
within the selected window. If the window was
created with a border, this value will be two
less than the height specified in the create
call.

WinGetWindowClr Returns the background color of a window.

WinGetWindowBdrClr Returns the border color of a window.

WinGetBorderType Returns the border type of a window.

WinHideWindow Removes a window from the screen. The window
still exists and is saved in it's current state.
All the caveats listed under WinMoveWindow
apply to the function.

WinShowWindow Shows a window which is hidden and frees the
buffer used to hold the current state of the
window.

WinInitialize Initializes the window package.This function
must be called once before any of the other
functions in this package are used. It should
NEVER be called while windows are open or the
buffers allocated to support them will be
stranded and their handles will no longer be
valid.

WinTerminate Assures that all open windows are closed.


Functions Available in SCRIO.C
==============================

ScrGetRectSize Calculates the number of bytes required to
store a screen image.

ScreenClearRect Clears a rectangle on the screen to the passed
color value.

ScrSaveRect Save a screen rectangle in a buffer provided
by the caller.

ScrRestoreRect Restores a saved screen image from a buffer
passed by the caller.

ScrSetCursorPos Positions the cursor to an absolute screen
location (1 relative).

ScrGetCursorPos Gets the absolute screen location of the cursor.

ScrCursorOn Enables the screen cursor.

ScrCursorOff Disables the screen cursor.

ScrTextOut Displays a text string to the video screen.

ScrDrawRect Draws the selected border around a screen
retangle.

ScrInitialize Determines the video equipment installed on the
machine. This routine is called by WinInitialize
and does not need to invoked by the user code.



 December 19, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)