home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
TOT11.ZIP
/
TOTDOC11.ZIP
/
CHAPT18.TXT
< prev
next >
Wrap
Text File
|
1991-02-11
|
15KB
|
334 lines
Extending
Windows
"The success hasn't gone to our price." Peugeot Motor Company
Earlier, in chapter 7: Using Windows (page 7-12) a template for
stretchable windows was presented. This template illustrated how, with
just a few procedures, you could build customized windows. In this
chapter you will learn how to use OOP techniques to extend window
objects, and gain even more flexibility. To illustrate the concepts,
the StretchWinOBJ object will be extended to provide a generic object
for scrolling virtual screens.
Window Object Structure
Before trying to extend the window objects, you need to have an under-
standing of how the window objects function. The table below describes
the data declared in each window object.
WinOBJ
Variable Description
vBorder: tCoords The (X1,Y1,X2,Y2) coordinates of the window
border.
vOuter: tCoords The (X1,Y1,X2,Y2) coordinates of the saved
screen area, i.e. window and shadow.
vUnderneathPtr: A pointer to the saved image overlaid by the
pointer window.
vSavedSize: longint The size, in bytes, of the saved area.
vTitle: string The window title.
vBorderAttr The window display attributes.
vTitleAttr
vBodyAttr
vIconsAttr: byte
vStyle:byte The window style.
vRemove: boolean A boolean to indicate whether the window will
be removed when the object is Done.
vCursX,vCursY, The cursor settings at the time the window was
vCursTop, displayed.
vCursBot: byte
vOldWin: tByteCoords The window settings at the time the window was
displayed.
vOldWinConfine: A boolean to indicate whether window settings
boolean were active when the window was displayed.
vMVisible: boolean A boolean to indicate whether the mouse was
visible when the window was displayed.
18-2 Extending the Toolkit
--------------------------------------------------------------------------------
MoveWinOBJ
Variable Description
vBoundary:tCoords The (X1,Y1,X2,Y2) coordinates of the area in
which the window can be moved.
vMoveKey: word The key to press to invoke a manual (non-mouse)
move.
vAllowMove:boolean A boolean to indicate whether the user is
allowed to move the window.
ScrollWinOBJ
Variable Description
vScrollV:boolean; A boolean to indicate whether the vertical
scroll bar is visible.
vScrollH:boolean; A boolean to indicate whether the horizontal
scroll bar is visible.
StretchWinOBJ
Variable Description
vZoomed:boolean A boolean to indicate whether the window is
currently zoomed.
vPreZoom:tCoords The coordinates of the window border prior to
zooming.
vMinWidth:byte The minimum width of the window.
vMinDepth:byte The minimum depth of the window.
vStretchKey:word The key to press to invoke a manual (non-mouse)
stretch.
vZoomKey:word The key to press to invoke a manual (non-mouse)
zoom.
vAllowStretch: A boolean to indicate whether the user is
boolean allowed to stretch the window.
vSmartStretch: A boolean to indicate whether the window will
boolean be updated during a stretch operation.
Note that the type tCoords is defined as follows:
tCoords = record
X1,Y1,X2,Y2: shortint;
end;
By now, you should already know most of the window methods in the file
TOTWIN.PAS. Review the declaration of all four windows objects for a
complete list of the methods. From an object extension perspective, the
following methods are important:
constructor Init;
Initializes the object.
Extending Windows 18-3
--------------------------------------------------------------------------------
procedure WinKey(var K:word; var X,Y: byte); VIRTUAL;
WinKey is passed keystroke details as variable parameters. If the key-
stroke is window specific, e.g. a click on the close icon, a zoom, a
window stretch etc., the method will process the key and modify the
relevant window characteristic. The value of K is then updated to indi-
cate the type of activity, e.g. set to 602 to indicate that the window
has been re-sized.
procedure StretchRefresh; VIRTUAL;
While the user is stretching the lower right window, the method Stret-
chRefresh is continuously called. This is the mechanism for dynamically
showing the user how the window will appear while it is being
stretched. The method is only called if the boolean vSmartStretch is
set to true. There are two important items to consider. Firstly, this
method will only be called while the window settings are suspended, so
any screen writing statements in the procedure must use the full-screen
coordinate system. Secondly, this method must complete its display
update very quickly. It will be called continuously during a stretch
operation, and if the procedure takes too long, the user will notice a
sluggish response.
procedure Draw; VIRTUAL;
Draw saves the contents of the portion of the screen which will be
overlaid by the window, and then draws the window and shadow.
destructor Done; VIRTUAL;
Disposes of the window object memory, and removes the window (if it is
still visible and the vRemove variable is set to true).
If you extend any window object, you will probably modify most of these
methods, since they control the window display and input processing
routines.
Extending StretchWinOBJ
To illustrate the principles of window extension, a new window object
for displaying and scrolling virtual screens will be created. You may
recall that a virtual screen is a screen which has all the properties
of the physical screen, but is not visible. A virtual screen can be up
to 255 characters wide and 255 lines deep - quite a screen! The Screen-
OBJ method PartDisplay can be used to transfer a portion of the virtual
screen to the visible screen.
18-4 Extending the Toolkit
--------------------------------------------------------------------------------
The first task in designing the new object is to decide what additional
data will be needed. Obviously, the object will need to know the
address of the virtual