home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_GEN
/
TVGRAPH.ZIP
/
REFER15.DOC
< prev
next >
Wrap
Text File
|
1993-12-24
|
87KB
|
2,053 lines
file Refer15.DOC
12/13/93
If you use the IDE, keep this file in a window for convenient reference.
REFERENCE SECTION Ver1.5
NOTE
Changes are relative to Turbo Vision 1.0 unless otherwise noted.
Turbo Pascal 6.0 includes documentation for Turbo Vision 1.0.
Turbo Vision 2.0 comes with Pascal 7.0 and expands on TV 1.0,
adding additional objects and methods.
TVGraphic incorporates published bug fixes for Turbo Vision
including those incorporated in the "maintanence" release of BP7.0.
Documentation on BitMaps and related views is in file BitMap.DOC.
Significant areas not presently in TVGraphic include
TV2.0 extended palettes
compatibility with Validators.
MultiCheckBoxes
Editor unit - in process
History views
If your compiler does not recognize some TV syntax when
using these units, check this file under the appropriate
unit name and the object,method,variable,etc. name to see
if there is a syntax difference between TV and TVGraphic.
TVGraphic
For objects that are analogous to Turbo Vision objects, only
methods that have been modified are listed in this section.
New methods are always listed. Assume unlisted methods are unchanged.
However, where the changes in a View's method
1. are solely to use graphic coords instead of text coords
and/or
2. only involve limiting redrawing area or frequency
then the method is not listed.
Unit Version Numbers:
Each unit exports a version number string constant under
the name of GVersion. This can be checked by using the IDE's
Evaluation window - for example include GObjects in a uses
statement and then evaluate GObjects.GVersion to get the
version of the GObjects unit.
------------------------
Application Palette
See individual objects for TVGraphics palette definitions.
Format
Foreground color = lower 4 bits, background = upper 4 bits.
TVGraphics allows all 16 colors for background.
There is no inherent "blink" in graphic mode.
Indices
TVGraphic windows use TV's "Blue" window portion of the palette
which starts at entry 8.
(default background color is light gray in TVGraphic).
TVGraphic Dialogs use TV1.0's Dialog palette which starts at
entry 32. In TV2.0, this is called the "dpGrayDialog" palette.
(default dialog background color is cyan in TVGraphic).
(TV1.0 Dialogs do not use the "Gray" window portion of
the palette despite what TV1.0's documentation says).
TV2.0 dpXXXX constants: IDE's Help says they run 1,2,3
but TV2.0 Dialog unit exports them as 0,1,2 !
TVGraphic units for Pascal 7.0 export these constants but
colors for the other two dialog palettes are not currently
supported.
Views in TVGraphic do not use the sections of the palette
that TV calls "Gray" and "Cyan" windows. It is expected
that the Cyan section will be used by HelpFile.Pas.
The Window palettes have been extended.
{1 application background}
{2-7 Menus, StatusLine}
{Scrollbars: 11-12 in Blue Window, 35-36 in dialog boxes}
{BlueWindow starts at 8, 8-10 TFrame,11-12 Scrollbar,13-14 scroller,
15 reserved}
{32-40 Dialog uses directly, remaps alot of other palettes mentioned
below. Indices are for items when inserted in a dialog}
Rule is to take view's local palette number and add 31.
{32-34 TFrame, 35-36 scrollbar}
{37 static text, 38-40 Label}
{41-46 Buttons}
{47-49 Checkboxes and Radiobuttons}
{50-52 InputLine, 52 foreground is for scroll arrow,
background for rect border around text.}
{50-56 HistoryWindow}
{57-60 TListViewer in Dialog}
{61 InfoPane, FileDialog}
------------------------
BMPDRVR Unit - see file BITMAP.DOC
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GApp Unit
* MessageBar : PGMessageBar = nil;
points to the MessageBar if one exists
* procedure ImprovePaletteColors;
for screens in VGA mode, modifies the values (shades) of
dark gray and brown from the BGI default values.
NOTE: if you DOSshell, then need to call this routine again after.
NOTE: During debugging in the IDE, if you break out of your
program, the standard colors will be restored unless
you enable
Options/Environment/StartUp EGAVGA Palette Save
from the IDE's menu.
* procedure TProgram.SetPalette(Pal : TPalette);
see TProgram
------------------------
GBut Unit see file BITMAP.DOC
------------------------
GColor Unit
+Adapt descriptions in standard color items to TVGraphic.
TVGraphic standard color item functions
function DesktopColorItems(Next: PColorItem): PColorItem;
function MenuColorItems(Next: PColorItem): PColorItem;
function DialogColorItems(Palette: Word; Next: PColorItem): PColorItem;
function WindowColorItems(Palette: Word; Next: PColorItem): PColorItem;
procedure RegisterColorSel;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GDialogs Unit
OBJECT Naming Convention
Several TVGraphic Objects have an added field in their constructors
as compared to Turbo Vision. (The added field comes last.)
These objects have different names in TVGraphic
TVGraphic Turbo Vision
TgInputLine = TInputLine
TgLabel = TLabel
TgStaticText = TStaticText
TgParamText = TParamText
* TVGraphic constants
TextButtonsMatchBitMapButtons : boolean = false;
{whether text based buttons should look like Turbo Vision
or look similar to TVGraphic's BitMap buttons}
DefaultButHt : integer = 20; default button height in standard views
DefaultDialogFont : byte = font8x14;
{Vfont set to this in TButton,TInputLine constructors.
Also in StaticText, ParamText, Label unless
overidden in Init(..,..,.,Opts) parameter.}
MouseSnapToDialogGrid : boolean = true;
causes mouse cursor to snap to a 8x14 pixel grid while a
modal Dialog is visible
VOptions constants:
DefaultOpts = 0; {= behavior most like Turbo Vision}
Text objects set VOptions to value of Opts field
in their constructor.
Opts := option1+option2+...+ fontname {font overrides default font}
Note: using txCentered automatically adjusts the
width of the view to match the centered text.
Note: TgLabel's always have background. txBackground
and txCentered have no effect.
TgStaticText,TgParamText
txDrawBackground = $80;
txCentered = $10;
TgStaticText,TgParamText,TgLabel
txAdjustSize = $20;
DefaultFontOverride = lower four bits = fontname
TgInputLine sets VOptions to value of Opts field in its constructor.
TgInputLine
KillInstantErase = $01; {prevent first keystroke from erasing}
lnRightJustify = $02; {right justify the inputline}
TDialog {user must set these VOptions after construction}
dgReturnOnAnyButton = $01; {modal dialog returns on any command}
dgHelp = $02; {non-modal dialog issues cmClose
if it receives cmCancel.
i.e. closes if ESC key pressed}
Stream Registration numbers
CancelButton: gRegBase + 1001;
OKButton: gRegBase + 1002;
Palette Names
CDialog
CButton
CCluster
* CgInputLine
* CgLabel
* CgStaticText
+TV2.0 constants
dpBlueDialog = 0; these constants do not yet affect TVGraphic
dpCyanDialog = 1;
dpGrayDialog = 2;
presently should use dpTV1Dialog = 3 with ColorSelector.
------------------------
* = unique to TVGraphic
GDrivers
TV2.0 standard functions
function GetShiftState: Byte;
function GetCtrlChar(KeyCode: Word): Char;
function GetCtrlCode(Ch: Char): Word;
MOUSE
type Used with mouse cursor grid, TMCur.GetGrid returns this type
* MGridRec = record
X : byte; Y : byte; Xoff : word; Yoff : word;
end;
NOTE:
TEvent.Buttons
For better or worse, TVGraphic returns the button number in
Event.Buttons when a mouse button is released (evMouseUp event).
Turbo Vision returns zero.
DOS CRITICAL ERROR handler
TV's text mode critical error handler must be replaced by TVGraphic's
* function GSystemError(ErrorCode: Integer; Drive: Byte): Integer; far;
or by one you write.
Note: To avoid needing to allocate memory to save a portion
of the screen, GSystemError assumes that a MenuBar exists
in your application.
You do not need a StatusLine.
DO NOT overlay the critical error handler.
GSystemError's source code is located in the demo program module.
To replace TV's handler, place following line in
your application's .Init
SysErrorFunc := GSystemError;
The following functions are called by the Critical Error handler:
function FarSelectKey : integer;
{returns user keystroke without calling DOS}
function GetCritErrorStr(ErrorCode : integer) : string;
{returns the error message}
Timer Tick Event
* procedure GetBiosTickEvent(var Event : TEvent);
if the DOS timer count differs from count at previous call to
GetBiosTickEvent, then Event returns a TVGraphic event catagory
Event.What := evTimerTick;
Event.Infolong := value return by GetBiosTicks;
otherwise Event.What is set to evNothing;
* function GetBiosTicks : longint;
returns DOS timer count stored at address $40:$6C;
{WriteCStr,WriteCStrXY have been moved to the MyGraph3 unit.}
* procedure WriteCStr(AStr : string; TxColor,HighlightColor : word);
* procedure WriteCStrXY(X,Y : integer; AStr : string;
TxColor,HighlightColor : word);
DELETED
procedure PrintStr(S: String);
SHELL ONLY - these procedures match Turbo Vision but do nothing. They are
included to make stepwise conversion from TV easier.
procedure MoveBuf(var Dest; var Source; Attr: Byte; Count: Word);
procedure MoveChar(var Dest; C: Char; Attr: Byte; Count: Word);
procedure MoveCStr(var Dest; Str: String; Attrs: Word);
procedure MoveStr(var Dest; Str: String; Attr: Byte);
------------------------
* = unique to TVGraphic
GMenu (GMenu6)
* const {user changable}
MenuBarheight : integer = 15;
height of the MenuBar in pixels,
minmum value is 15 if using Font8x14 as assigned in Init.
set BEFORE initializing the menubar.
MenuBoxheight : integer = Boxheight;
vertical line spacing in Box menus
MouseSnapToMenuGrid : boolean = true;
causes mouse cursor to snap to a properly located Charlen
by Boxheight grid while a BoxMenu executes.
Set false to use current grid with BoxMenus.
DefaultMenuFont : byte = Font8x14;
Stream Registration Numbers
RgMenuBar: gRegBase + 40;
RgMenuBox: gRegBase + 41;
RgStatusLine: gRegBase + 42;
RgMessageBar: gRegBase + 1100;
------------------------
* = unique to TVGraphic
GMsgBox
* procedure DOSErrorMessageBox(DOSErrNum : integer; FileName : string);
DosErrorMessageBox displays appropriate DOS error message
and file name using a MessageBox. Pass the global variable DosError
as parameter DOSErrNum (or pass TStream.ErrorInfo if using a Stream).
Pass the file name as FileName.
* procedure LowMemMsgBox; {Out of memory Messagebox}
MessageBox('Not enough memory available.',
nil, mfError + mfOkButton);
+function MessageBoxRect(): Word;
Automatically centered. This works with any mouse grid in use.
Dialog^.Options := Dialog^.Options or OfCentered;
+function InputBox(), InputBoxRect: Word;
Automatically centered. This works with any mouse grid in use.
Dialog^.Options := Dialog^.Options or OfCentered;
Buttons adjust position to match box size in InputBoxRect.
------------------------
* = unique to TVGraphic
GObjects At TV2.0 level in Pascal 7.0 TPU's.
const
* Str80 = string[80];
const used to offset TVGraphic's stream registration numbers
* gRegBase = 60000;
const
Stream Registration Numbers
UnSortedStringCollection: gRegBase + 51;
TCollection - Error code for method Valid
* coTruncationErr = -100; {not enough mem to load all items from disk}
TMemoryStream - TV2.0 object
present in TVGraphic units for Pascal 7.0 only. Borland doc is
in a Borland disk file.
------------------------
GStdDlg At TV2.0 level in Pascal 7.0 TPU's.
TFileList.Init - the list of passed parameters varies between
TV1.0 and TV2.0. TVGraphic matches this.
FileList.ReadDirectory and TDirListBox.NewDir make calls to the
mouse cursor to switch it to the hourglass shape and back.
To disable, set EnableHourGlass (in MCursor unit) to false.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GViews
+ MaxViewWidth = 132*Charlen;
+ MinWinSize: TPoint = (X: 16*Charlen; Y: 6*Boxheight);
+ Window Palettes extended. Dialog palette added to end.
CBlueWindow := CBlueWindow + CDialog;
CCyanWindow := CCyanWindow + CDialog;
CGrayWindow := CGrayWindow + CDialog;
+ Blinking Text Cursor
Constants that determine maximum size for blinking cursor.
(Cursor sizes itself to font stored in VFont.)
* MaxCurWidth = 2*Charlen;
* MaxCurHeight = 2*Boxheight;
* TVGraphic constants
ScrollBarWidth = 11; {0 to 11 = 12 pixels total width}
DefaultListViewerFont : byte = font8x14;
TVColor = $FFFF;
This constant is used only by other units.
It is used in VColor field of some views to indicate
that the drawing colors should come from the palette
and not from the VColor field.
AllowBothMButtons : boolean = false;
Used by all standard views.
When false
right mouse button follows TVGraphic rules - cancels
current operation including modal dialog boxes.
When true
right mouse button follows Turbo Vision 2.0 behavior
including will not cancel modal dialog box.
* VOptions constants
TWindow
twIsWindow = $80; {identifies group as a TWindow descendant}
TFrame drawing control
tfDrawBackground = $01; {fill entire size rectangle}
tfVScrollBar = $02; {user sets if bar is present in Owner}
tfHScrollBar = $04;
type This is the record type used for field TView.Hook
* TUserRec = record
case word of
0 : (R : TRect);
1 : (P1,P2 : pointer);
2 : (X1,Y1,X2,Y2 : integer);
end;
* function ASHR(AnInt : integer; Places : byte) : integer;
{does arithmetic shift right of Places on AnInt}
* function ASHL(AnInt : integer; Places : byte) : integer;
{does arithmetic shift left of Places on AnInt}
-----------------------
* = unique to TVGraphic
* GWindow
const
{used to communicate between TPanWindow and TShiftView}
cmScreenShifted = gRegBase + 2000;
cmShiftScreenDown = gRegBase + 2001;
cmShiftScreenUp = gRegBase + 2002;
const
NormalMode = 0;
{number of pixels to shift screen when mouse
cursor hits edge of a Panning window.}
ScrnShiftX : word = Grid * 20;
ScrnShiftY : word = Grid * 15;
{These values are not directly referenced by TVGraphic.
Change to suit your needs:
if using a mouse grid, be sure to shift by even
multiples of the your grid. 'Grid' used here is fixed
constant from MCur unit. Grid = 10.}
const
ShiftViewPtr : PShiftView = nil; {Global}
Stream Registration Numbers
ShiftView: gRegBase + 2000;
SubWindow: gRegBase + 2001;
PanWindow: gRegBase + 2002;
WinBackground: gRegBase + 2003;
procedure RegisterWindows;
-----------------------
* = unique to TVGraphic
* MCursor Unit (MCursor2)
Yes there alot of methods for the cursor but the average user
will use only these:
Init, Done
Show, Hide
LockShow, LockHide
RePosition
RestoreSettings (for after DOS shell)
SetGrid call once and forget
{ This type is declared in GDrivers and used by TMCur.GetGrid.
type
MGridRec = record
X : byte; Y : byte; Xoff : word; Yoff : word;
end; }
Note on the HourGlass cursor shape
switch to it with MCur.SelectHourGlass, back with MCur.SelectStdCursor.
This is intended to indicate waiting only - buttons are disabled.
const
EnableHourGlass : boolean = true; {hourglass shape will not appear
if false}
Grid = 10; {size of coarse drawing grid spacing in pixels}
FineGrid = 5; {size of fine drawing grid}
var
MCur : TMCur; Global mouse cursor object
procedure FlushMouseQue; NOTE - Flushes ALL types of mouse events
from the event que.
PMCur = ^TMCur;
TMCur = object(TPoint)
READ only
MinGridX, MinGridY : integer; {min screen coords of mouse travel}
MaxGridX,MaxGridY : integer; {max screen coords for mouse travel}
constructor Init;
SetGrid(Grid,Grid,0,0); set to 10x10 grid
SetSpeed(12,12); reduce mouse sensitivity, "normal" is 8,8
destructor Done;
procedure CenterIt;
Computes center of screen and then calls RePosition(center)
procedure CurWhere(var Pt : TPoint);
returns cursor position
procedure Limitvert(minpos,maxpos : integer);
sets vertical limits of cursor travel
procedure Limithorz(minpos,maxpos : integer);
sets horizontal limits of cursor travel
procedure Move(P : TPoint);
moves cursor to Pt, even if hidden.
function OverLapsCursor(R : TRect) : boolean;
true if R overlaps the cursor.
procedure RePosition(var Pt : TPoint);
Moves the cursor and calls FlushMouseQue.
If Pt is outside the area specified for the cursor travel,
then moves cursor to edge of specified area.
procedure RestoreSettings;
restores position,speed and limits of travel after DOS shell
procedure RestrictYMove;
keeps cursor out of MenuBar
procedure RestoreYMove;
restores cursor travel to screen top
procedure GetGrid(var AGrid : MGridRec);
sets AGrid to equal the current values of the mouse grid
procedure SetGrid(XGrid, YGrid : byte; XGridOffset, YGridOffset : word);
SetGrid not only sets the specified grid but also sets
the limit of mouse travel so the cursor won't disappear
off the right screen edge or the bottom.
It also repositions the mouse if necessary to be on
the new grid.
procedure SetSpeed(Mickx, Micky : integer);
set cursor movement speed (ratio of mickeys/pixel)
procedure SelectHourGlass;
if EnableHourGlass is true, cursor shape is set to the hourglass
procedure SelectStdCursor;
cursor shape is set to the arrow
procedure LockShow;
decrements lock count, show cursor if 0
procedure LockHide;
hide cursor if visible, increment lock count.
while lock count > 0, Show and Hide have no effect.
procedure Show;
shows the cursor
procedure Hide;
hides the cursor
end;
------------------------
* = unique to TVGraphic
+ = calls Graph unit with exceptions noted
* Unit MyGraph3
This unit traps some BGI calls before passing them to the Graph unit.
Fonts
Unit contains the two pixel clippable bit-mapped fonts.
Font8x8 appears the same as the Graph unit Default font.
Font8x14 is the same size as and looks like an EGA text mode font.
These fonts have only one size and can only be horizontal.
NOTE: if you install enough custom fonts, eventually the BGI will
assign font numbers equal to or higher than Font8x8. You will not be
able to access custom font numbers equal to and above Font8x8.
Example: Borland Pascal 7.0 has fonts defined at numbers 0 thru 10
so you will only be able to access three custom fonts.
const {for graphics mode programs}
Charlen = 8; {width of a standard graphic char in pixels}
BoxHeight = 14; {height of the standard text line}
TVGraphic clippable, bit-mapped Fonts
Font8x8 = 14; {8 by 8 pixels}
Font8x14 = 15; {8 by 14 - same size as text on EGA}
BYOff8x8 = 4; {offset down into Boxheight to center text}
BYOff8x14 = 1;
BYOffSmallFont = 0; {for use with BGI SmallFont}
{font dependent offset down into Boxheight to center text}
BYOffset : integer = 0;
The value of BYOffset is set to one of the three BYOFF constants
by SetTextStyle according to the font being selected. It can be
used when spacing lines of text vertically using Boxheight to
properly center the text font vertically within each box.
Add BYOffset to the box's upper edge when using OutTextXY or
MyGraph.MoveTo+OutText.
BXOffset = 4; {offset from left edge of box}
Utility functions
procedure WriteCStr(AStr : string; TxColor,HighlightColor : word);
Writes AStr as a single line. Text is in TxColor but anything
enclosed with ~'s is written in the highlight color. Can use
multiple pairs of ~'s.
Does not draw a background under the text.
procedure WriteCStrXY(X,Y : integer; AStr : string;
TxColor,HighlightColor : word);
X,Y are viewport relative BGI coordinates. Moves the
BGI "current pointer" to X,Y and then calls WriteCStr.
Text is written at X,Y.
function ConstStr(C : Char; N : Integer) : String;
ConstStr returns a string with N characters of value C
function CalcVertTextOffset(ViewYSize : integer) : integer;
{was named VertTextOffset in earlier versions}
Used by MenuBar,StatusLine,etc. to calc vertical offset to
center a line of text in a view. Pass view's Size.y as ViewYSize.
Font dependent - Must set font Before calling this routine!
Tested with Smallfont,Font8x8,Font8x14 in 10,15,20 pixel high
boxes.
begin
CalcVertTextOffset := (ViewYSize +1 - TextHeight(' ')) div 2 +1;
end;
BGI functions
+procedure SetTextStyle(Font, Direction : word; CharSize : word);
For font numbers less than Font8x8
calls the Graph unit SetTextStyle. If that call fails
(font not found), then sustitutes Font8x8.
Sets BYOffset to BYOffSmallFont.
For fonts Font8x8,Font8x14, sets font selection in this unit
to selected font. Sets BYOffset to matching BYOff constant.
Note that you can select the Graph unit DefaultFont (font =0)
but it doesn't clip at pixel level - see BGI/Graph unit doc.
+function TextHeight(TextString : string) : word;
returns 8 for Font8x8 and 14 for Font8x14
+function TextWidth(TextString : string) : word;
uses character width of 8 for fonts Font8x8 and Font8x14
to calculate width.
The following BGI calls are also intercepted
Bar
Bar3d
OutText
OutTextXY
------------------------
ofXXXX constants Used with TView.Options field.
ofVersion : TVGraphic ver1.1 views are ofVersion10 types {same as TV1.0}
ofFramed : TV def = TFrame draws frame for each window subview
where this bit is set.
Note: Due to different redraw order in TVGraphic, TFrame draws first
and therefore cannot draw frames for other (yet to be drawn) views.
Each view must handle its own frame drawing.
TVGraphic frame behavior:
InputLines and ListBoxes - always framed. ofFramed has no effect.
TgStaticText, TgParamText, TgLabel - view will draw its own frame
if ofFramed is set in its Options field. Default = no frame.
TCheckBoxes, TRadioButtons - view will draw its own frame
if ofFramed is set in its Options field. Default = framed.
TVGraphic does NOT recognize
ofBuffered : buffers not used in TVGraphic
ofValidate : to be supported in a future version
ofVersion20 : to be supported TVGraphic 2.0
------------------------
sfXXXX constants
These correspond to bits in the TView.State field.
sfShadow
Do not use sfShadow in releases of GViews prior to 1.02.
In 1.02 and after, sfShadow has no effect in TVGraphic and is
available as a spare state for you to play with.
sfExposed {same as TV}
true if view is Inserted directly or thru other views into the
Application AND the sfVisible bit is true. While reseting states,
TVGraphic sometimes momentarily changes this bit.
sfActive versus sfSelected - Windows versus views
{a little different from TV}
TV background:
all TGroups can have a Selected subview but only windows and
subviews within windows can be Active. When a window is
selected, it and all of its subviews are set active.
Deselection of the window sets everything inActive.
Note that a subview may not be selectable (ofSelectable not set)
but it will still become Active if it is in an active window.
TVGraphic
To allow nesting of windows, a window (unlike other views)
does not respond to SetState(sfActive,...).
It sets all its subviews'sfActive bit to match its own
sfSelected bit. In GView versions prior to 1.02, a window
never sets its own sfActive bit. For 1.02 and after, it sets it
to match its sfSelected bit.
Note that when windows are nested, there can be an Selected
subWindow (whose subViews will be Active)
plus additional subWindows all in an Selected Window (selected
Window's subviews, other than subwindows, will also be Active).
In GView versions prior to 1.02, none of the window/subwindows will
have its sfActive bit set while for 1.02 and after, the selected
window and subWindow will have their sfActive bits set.
------------------------
TApplication
In TVGraphic, Applications descend from TProgram, not TApplication!
See Deriving an Application section of main documentation file.
TDemoApp is derived in TVGDem1.PAS.
TDemoApp - only those methods that are necessary or of general
interest are listed here. See TDemoApp for code/descriptions.
procedure DosShell;
procedure GetEvent(var Event : TEvent); virtual;
timertick events
necessary update of mouse cursor, other mouse
hooks for Help windows
procedure HandleEvent example of handling a TShiftView
procedure InitHeapViewer;
procedure InitMenuBar; virtual;
procedure InitMessageBar; message that covers over the MenuBar
procedure InitShiftView; used with TPanWindow for panning screen
procedure InitStatusLine; virtual;
procedure InitToolBar;
procedure SaveDeskTop;
procedure LoadDeskTop;
procedure ShowHelp;
destructor Done; virtual;
destructor HaltDone; destructor used prior to entering graphic mode
------------------------
TBackground = object(TView)
Pattern - Not used.
In TVGraphic, Background obtains its fillstyle from the
background color of its palette entry. The fillstyle passed
to SetFillStyle is (BackgroundColor mod 4 +8).
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TButton = object(TView)
+AmDefault: Boolean; modified usage - true if button is selected
+constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
AFlags: Word);
sets VFont := DefaultDialogFont
procedure Draw; virtual; unchanged - calls DrawState
+procedure DrawState(Down: Boolean); virtual;
rewritten for graphic drawing. Button outline is always in black.
centers text vertically for any font
made virtual
when TextButtonsMatchBitMapButtons is true, then Tbuttons draw
to match appearance of TVGraphic bitmapped TIconButtons.
The text and button background is always drawn in the
Button Text Normal colors.
A shadow frame is drawn using the Shadow colors.
If ((Size.x > 2*Boxheight) and (Size.y >= 2*Boxheight))
or the button is the default button, this frame is
drawn thicker.
If a button is selected, its outline is dotted using
the background color of Text Normal.
An unselected button which is the default button has a
thicker dark border useing the Shadow colors.
+procedure HandleEvent(var Event: TEvent); virtual;
heavily altered
summary:
If button's command is disabled, its sfDisabled State flag
is set and it cannot be pressed. Redraws as necessary.
A button will not select itself if clicked with mouse unless
the bfGrabFocus (TV2.0) flag is set in Flags.
Mouse - evMouseDown presses button. No action for right
mouse button unless global AllowBothMButtons is true.
Enter key presses the Default button. The Default button is
either the Focused button, or if no button is focused,
the button with bfDefault set in Flags.
cmDefault will press the button if bfDefault is set in Flags.
not using cmGrabDefault, cmReleaseDefault:
usual HotKey behavior
+procedure MakeDefault(Enable: Boolean);
routine's code is commented out.
+procedure Press; virtual;
draws button pressed then unpressed again.
+procedure SetState(AState: Word; Enable: Boolean); virtual;
for AState=sfFocused, sets AmDefault to Enable and redraws
the view. Does not call MakeDefault.
end;
To change the Default Button after initialization:
change which button has the bfDefault flag set in its Flags field
(only one button should have this flag set at a time),
then call the old and new Default buttons' DrawView.
* TVGraphic predefined buttons
Button Size is fixed at 10*Charlen long by DefaultButHt tall.
Only the Button's Origin is specified in Init.
* PCancelButton = ^TCancelButton;
* TCancelButton = object(TButton) Issues the cmCancel command.
constructor Init(var Org : TPoint);
end;
* POKButton = ^TOKButton;
* TOKButton = object(TButton) Issues the cmOK command.
constructor Init(var Org : TPoint; DefaultButton : boolean);
if DefaultButton is true, then call to TButton sets
Turbo Vision bfDefault button flag in Flags field.
end;
+ Button Palette
background is drawn in the background color of entries 1-4
depending on State of button.
button outline/shadow:
left and top = foreground color of entry 8
right and bottom = background color of entry 8
button draws black momentarily when pushed
all text - same entries as TV
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
PCheckBoxes = ^TCheckBoxes
TCheckBoxes = object(TCluster) unmodified
TCluster:
TVGraphic corrects TV 1.0 bug in handling nil strings in TCluster.
This means you can have a Checkbox or RadioButton view without
individual box labels.
PCluster = ^TCluster
TCluster = object(TView)
+constructor Init(var Bounds: TRect; AStrings: PSItem);
sets VFont := font8x8
+procedure DrawBox(Icon: String; Marker: Char); virtual;
fix TV 1.0 bug for single line horizontal Clusters
rewritten for graphics
made virtual
+procedure HandleEvent(var Event: TEvent); virtual;
convert to graphics coords
{+Methods below are Private in TV 1.0.
In TVGraphic they are public and virtual.}
function FindSel(P: TPoint): Integer; virtual;
convert to graphic coords
function Column(Item: Integer): Integer; virtual;
handle nil strings
convert to graphic coords
function Row(Item: Integer): Integer; virtual;
convert to graphic coords
end;
+ Cluster Palette
background is drawn in the background color of entry 1.
cluster outline uses background color of entry 3
all text - same entries as TV
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TCollection = object(TObject)
+constructor Load(var S: TStream);
checks LowMemory before loading each item. If true, sets
Count equal to number of items loaded and exits.
The partially loaded collection is usable.
With Ver1.5, Sets error flag in above case. Also checks for
large enough block of memory to allocate Items, the array of
pointers (will not dip into the Safety Pool).
If not, sets error flag and constructs an empty
Collection with Limit=1 and Count =0.
procedure AtFree(Index: Integer);
missing from TV 1.0 manual
deletes and disposes of item at index.
*function Valid : integer; virtual;
returns 0 if complete collection successfully loaded,
error code otherwise. See GObject unit descript for error code(s).
See main doc file for discussion of loading and safety in
using Collections.
private
TruncationErr : boolean;
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TColorGroupList = object(TListViewer)
+procedure FocusItem(Item: Integer); virtual;
modify to send message only if color has changed
end;
TColorDialog = object(TDialog)
+constructor Init modify to allow 16 colors for background.
delete mono selector, rearrange control locations.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TDeskTop = object(TGroup)
BackGround : PBackground;
present but not doc'd in TV 1.0
function NewBackground
vaporware in TV 1.0 documentation.
procedure InitBackground
actual TV 1.0,2.0 call - constructs background
equal in size to DeskTop, called in TDeskTop.Init
+procedure HandleEvent(var Event: TEvent); virtual;
present but not documented in TV 1.0
Handles commands:
cmNext: SelectNext(False);
+cmPrev: puts current view in front of foremost
non-selectable view. (usually the background)
*constructor Load(var S : TStream); {missing in TV 1.0, added}
*procedure Store(var S : TStream); {missing in TV 1.0, added}
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TDialog = object(TWindow)
+constructor Init(var Bounds : TRect; ATitle : TTitleStr; Opts : byte);
added Opts parameter to set VOption field.
if Opts = DefaultOpts then matches TV
if Opts = ReturnOnAnyButton then Dialog will end modal state when
any button command is issued including user defined commands.
see GDialog Unit section for other options
Init sets Frame^.VOptions := tfDrawBackground;
which causes Dialog's Frame to draw a background for the view.
*function Execute : word; virtual; NEW-ADDED
calls TGroup.Execute
if global MouseSnapToDialogGrid is true then Execute sets the
mouse grid to a Charlen by Boxheight grid before the call to
TGroup.Execute and resets grid to previous values afterwards.
If set, grid is relative to top of DeskTop - Dialog grid assumes
you will insert Dialog into DeskTop.
When inserting a Dialog, easiest way is to use the ofCentered
option in the Dialog.Option field (not VOptions field). This
will center the Dialog and match it to the grid if you dimension
the Dialog vertically using the Boxheight constant and
horizontally using the Charlen constant.
(i.e. Size.x := I*Charlen
( Size.y := N*Boxheight where I,N : integer)
+function GetPalette: PPalette;
modified to return an altered palette if dialog is non-modal
and dialog's Owner has a palette, else usual palette.
This allows correct colors if inserted in a Window
(Windows use TVGraphic's extended window palettes.)
+procedure HandleEvent(var Event: TEvent); virtual;
modified for ReturnOnAnyButton
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TFrame = object(TView)
+constructor Init(var Bounds: TRect);
VFont is set to font8x8; TFrame assumes this size font
is used so may not work properly with other fonts.
+procedure Draw; virtual;
NOTE: The frame's VOptions tfDrawBackground flag is automatically
set in TDialog.Init but NOT in TWindow.Init !
User may set after window's construction if desired.
Draws a complete background if sfDragging or
the VOptions tfDrawBackground is set. Uses the background
color of the palette's Active Frame entry.
Otherwise checks VOption flags tfVScrollBar and tfHScrollBar
(set by TWindow.StandardScrollBar) and draws background under
the standard scrollbar positions for each set flag.
Finally calls DrawFrame.
*procedure DrawFrame; virtual;
Draws a background under top bar of window. Draws a rectangle
around the view and an inner rectangle if the view is active.
These border rectangles extend offscreen if the view has an
Interior larger then the screen. (Calls
TGroup.GetFullPanSize to get size for these outline rectangles.)
If the window number is 1 thru 9, draws a Next Window button
with number inside.
Next, if active, checks Flags field and draws usual icons
if flags are set in Flags. Finally draws title, shortening
it as necessary to fit. Windows numbered 1..9 draw a blue
background under the title using the background of
palette entry 6.
*function Exposed : boolean; virtual;
calls Owner^.Exposed
*procedure GetInteriorSize(var R : TRect); virtual;
returns in R the size of the area inside the frame that you
should fill with views. This size reflects whether the VOption
flags tfVScrollBar and tfHScrollBar are set. (They are set
automatically if you add scrollbar(s) using
TWindow.StandardScrollBar).
Note that if you set TFrame's tfDrawBackground in the
VOption field, it will fill this area with the TFrame
background color.
+procedure HandleEvent(var Event: TEvent); virtual;
Handles mouse events. If NextWindow button is pressed,
issues a command event with Event.Command := cmNext to
advance to next window. Otherwise emulates TV.
*procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
added to handle Panning windows. Dest is in coord system
of TFrame, not the panning window Interior.
+procedure SetState(AState: Word; Enable: Boolean); virtual;
Calls DrawView when setting sfDragging. If clearing
sfDragging or changing sfActive, calls
DrawFrame if view is Exposed.
end;
+ TFrame Palette
{ TFrame Palette layout }
{ 1 = Passive frame }
{ 2 = Passive title }
{ 3 = Active frame }
{ 4 = Active title }
{ 5 = Icons, Dragging frame }
{*6 = highlight outline, background for title of numbered windows}
CFrame = #1#1#2#2#3#4; {add #4 to map to dialog box
scrollbar background}
The background of entry #3 is used in cases where the frame
draws a complete background for a window.
Numbered,Active frames draw their inner border and their
background under the Title using background of entry 6.
{entry 6 points to same color as scrollbar's entry 1}
Icon buttons draw background with background of entry 5,
Icon uses foreground of entry 5.
Other items follow TV.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TGroup = object(TView)
Buffer: PVideoBuf; deleted
constructor Init(var Bounds: TRect);
does not set ofBuffered in Options field
! constructor Load(var S: TStream);
Calls LowMemory after loading each view and Exits if true.
This prevents TV's runtime halt with out of memory error.
! Warning: when Load exits due to LowMemory=true, the Group is
not complete - inter view pointers are not restored.
If you insert the Group, the computer will probably bomb - totally!
To check for incomplete Load, follow the TV recommended
practice of using TProgram.ValidView on the pointer
returned by S.Get. If LowMemory, ValidView will display
an insufficient memory message, dispose the Group and
return a nil pointer to you.
Load also calls SetClipToMax.
*function CurAtEdge(Event : TEvent; var Delta : TPoint;
AllowMenuAccess : boolean) : boolean; virtual;
Returns false with no other action here.
Overridden in descendents if panning with mouse cursor.
procedure ChangeBounds(var Bounds: TRect); virtual;
calls SetClipToMax rather than GetExtent(Clip);
procedure Draw; virtual;
sets Clip by calling GetClipRect(Clip), calls Redraw and
resets Clip with SetClipToMax {rather than GetExtent(Clip)}.
*procedure GetClip(var MyClip : TRect);
sets MyClip equal to Clip
*procedure GetFullPanSize(var ISize : TPoint); virtual;
ISize is set to Size here. Overridden by descendents with
larger then the screen Interiors to return size of
their Interior. Called by TFrame.DrawFrame to determine
what size to draw its outline rectangle to.
procedure InsertBefore(P, Target: PView);
same as TV except:
If P's ofCenterX or ofCenterY Option flags are set, then
P is centered but P's Origin is adjusted so that
if ofCenterX then P's Origin.x is a multiple of Charlen
if ofCenterY then P's Origin.y is a multiple of Boxheight.
procedure Lock;
always increments the LockFlag
procedure Redraw;
calls MCur.LockHide to lock the mouse cursor off
redraws the views from Last to First
calls MCur.LockShow;
*procedure SetClip(R : TRect);
allows you to set the Clip variable which is used in TVGraphic
by TView.Exposed. If a view is outside the Clip rectangle,
Exposed will be false and calls to DrawView (or TGroup.Redraw
which eventually calls DrawView for each view) will not draw.
*procedure SetClipToMax;
Calls GetExtent(R) then R.Move(VOffset.x,VOffset.y) and
finally SetClip(R).
This sets the Clip variable to the full size of the group
while taking into account VOffset. Clip is maintained
in local (group interior) coordinates. See Clip below.
procedure SetState(AState: Word; Enable: Boolean); virtual;
Lock and UnLock are Not called when AState =sfActive,sfDragging:
*procedure SetVOffset(VX,VY : integer); virtual;
sets VOffset.x = VX, VOffset.y = VY and shifts Clip to
match the change in VOffset. Always set VOffset by calling
SetVOffset so Clip will be updated!
*procedure SetZoomLevel(ZL : byte);
reserved
*function ShiftScreen(var Event : TEvent; var Shift : TPoint) : boolean;
virtual;
returns false with no other action. Overridden in descendents
that shift or Pan the screen.
procedure Unlock;
if the LockFlag > 0 then decrements the LockFlag. Does not
make any drawing calls.
private
Clip: TRect; in use in TVGraphic
Maintained in local coordinates, not absolute screen coords!
For a group with an Interior that is shifted by VOffset,
Clip is maintained in the Interior's coordinate system by
shifting its x coords by VOffset.x and shifting its y
coords by VOffset.y. This is handled by SetVOffset.
{If VOffset = (0,0), the group's Interior is unshifted by
definition. Then SetClipToMax will set Clip.A to (0,0) and
Clip.B to (Size.x,Size.y)}
LockFlag: Byte; in use in TVGraphic
procedure DrawSubViews(P, Bottom: PView);
TV draws subviews from First (top view) to Last (bottom view).
TVGraphic draws subviews from Last to First. Parameter
"Bottom" is actually the "Top" subview redrawn in TVGraphic.
procedure FreeBuffer;
returns with no action
procedure GetBuffer;
returns with no action
procedure SetCurrent(P: PView; Mode: SelectMode);
does not call Lock and UnLock.
end;
------------------------
THistory and related views
These views are present but have not been converted to graphic mode.
THistoryViewer = object(TListViewer)
THistoryWindow = object(TWindow)
THistory = object(TView)
The Draw method does nothing.
------------------------
+ = emulates TV with exceptions noted
PgInputLine = ^TgInputLine
TgInputLine = object(TView)
+constructor Init(var Bounds: TRect; AMaxLen: Integer; Opts : byte);
Opts parameter added
DefaultOpts = $00; DefaultOpts matches TV
KillInstantErase = $01 prevent first keystroke from erasing
lnRightJustify = $02; right justify the inputline
EventMask := EventMask + evTimerTick;
Vfont := DefaultDialogFont;
procedure Draw; virtual;
rewritten
+procedure HandleEvent(var Event: TEvent); virtual;
Ctrl-Del deletes line
KillInstantErase prevents first keystroke from erasing line.
+procedure SelectAll(Enable: Boolean);
if KillInstantErase, positions cursor at end of selected block
end;
+ InputLine Palette
overall background is drawn in the background color of entries 1-2.
background of selected text uses background of entry 3.
InputLine outline uses background color of entry 4
arrows indicating text extends beyond view use foreground
color of entry 4
cursor is fixed white color.
text - uses entries 1-2. (If selected uses entry 2, not 3.)
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
PgLabel = ^TgLabel
TgLabel = object(TgStaticText)
+constructor Init(var Bounds : TRect; AText : String;
ALink : PView; Opts : byte);
Opts: added parameter.
Opts = DefaultOpts then matches TV
Works like Opts parameter in StaticText except
txCentered - flag is ignored.
txDrawBackground - ignored, background always drawn
txAdjustSize
The view's Origin will be set to Bounds.A
The view's Size.x will be adjusted to the length of
AText * Charlen plus BXOffset. Size.y will be set
to Boxheight-1. Will handle text with highlighted
characters.
Note that parameter Bounds will NOT be changed if this
flag is set - you can supply a Bounds based on a
TInputline, for example, and then later reuse the width
of Bounds for setting another matching TInputLine.
Font must be uniformly spaced, 8 pixels/char such as
Font8x8,Font8x14,SmallFont.
procedure Draw; virtual;
Color and Font selection same as StaticText Draw.
Uses BYOffset in vertical positioning of text within the view.
! Text is indented 4 (BXOffset) pixels from left edge of view.
If Options has ofFramed set, then draws frame around itself.
end;
------------------------
For TgMenu objects see TMenu objects
TgStatusLine is alpha listed as if spelled TStatusLine
------------------------
TListBox = object(TListViewer)
+constructor Init(var Bounds: TRect; ANumCols: Word;
AScrollBar: PScrollBar);
modify to use horizontal scrollbar like in FileOpen dialog.
TV 2.0 has same modification.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TListViewer = object(TView)
constructor Init(var Bounds: TRect; ANumCols: Word;
AHScrollBar, AVScrollBar: PScrollBar);
OldTopItem := -1;
VFont := DefaultListViewerFont
constructor Load(var S: TStream);
set OldTopItem := -1 after loading standard fields
procedure ChangeBounds(var Bounds: TRect); virtual;
set OldTopItem := -1, then TV behavior
procedure Draw; virtual;
draws the complete view or just parts needing update
depending on boolean PartialRedraw.
*procedure DrawSelf;
decides whether partial or complete redraw of the view
is needed using Focused and OldTopItem. Sets boolean
PartialRedraw and calls DrawView.
procedure HandleEvent(var Event: TEvent); virtual;
calls DrawSelf rather than DrawView. Other redraw limiting.
TV 1.0 Bug fixes from TV 2.0 incorporated.
procedure SetRange(ARange: Integer);
set OldTopItem := -1 plus TV behavior
procedure SetState(AState: Word; Enable: Boolean); virtual;
Calls TView.SetState then
if AState is sfSelected or sfActive, calls DrawView.
Does not affect any scrollbars.
private
*PartialRedraw : boolean; {temp var}
*OldFocused : integer; {temp variable, used with partial redraws}
*OldTopItem : integer; {temp variable, used with partial redraws}
end;
+ ListViewer Palette
background drawn in background color of entry 1
outline of view uses background of entry 5
vertical divider uses foreground of entry 5
text - same as TV
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TMenuView = object(TView)
*Target : PMenuView; {temp var, pointer to child menu, nil if none}
+function Execute: Word; virtual;
heavily modified - see Menus in section with general discussion of
view behavior. Menus are about the most convoluted code in TV -
details will have to wait for later.
+procedure HandleEvent(var Event: TEvent); virtual;
added ability to snap mouse cursor to grid in BoxMenus if
SnapToMenuGrid is true. Previous grid is saved and restored.
Prevents redrawing if cmCommandSetChanged arrives while the
menu is open but not modal (Help window is popped up).
function NewSubView(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView): PMenuView; virtual;
code commented out
private
*OldCurrent : PMenuItem; {temp var, used in redrawing}
*DrawPartial : boolean; {temp var, used in redrawing}
end;
TMenuView Palette - used by all menus
menu background is background of entry 1
menu border color is background of entry 3
* PGMenu = ^TGMenu; {Ancestor of graphical menus}
* TGMenu = object(TMenuView)
Xsep : integer; {number of char spaces (not pixels) between bar menu items}
{initilize to the same value as the BarMenu Xsep for Box menus also!}
Constructor Init(var Bounds : TRect; AMenu : PMenu);
function NewSubView(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView): PMenuView; virtual;
code moved here from TMenuView.NewSubView
*procedure FillWindow(BorderColor,AColor : integer; FatBorder : boolean);
draws a Bar3d the size of the menu with border
constructor Load(var S: TStream);
procedure Store(var S: TStream);
end;
* PGMenuBar = ^TGMenuBar; {TVGraphic Bar Menu}
* TGMenuBar = object(TGMenu)
+Constructor Init(var Bounds : TRect; AMenu : PMenu);
Bounds.B.Y := Bounds.A.y + MenuBarHeight -1;
legend separation - if there are few enough entries, the separation
between legends will be set at 3 spaces, otherwise to 2 as in TV.
VFont := DefaultMenuFont;
procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
procedure Draw; virtual;
end;
* PGMenuBox = ^TGMenuBox; {TVGraphic Box menu}
* TGMenuBox = object(TGMenu)
Indent : integer; {legend starts this many pixels left of window edge}
+constructor Init(var Bounds : TRect; AMenu : PMenu;
AParentMenu : PMenuView);
vertical size set to (number of entries +2) times MenuBoxHeight
Indent := Charlen;
VFont := DefaultMenuFont;
procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
procedure Draw; virtual;
draws a cursor in left column of menu next to selected entry
plus usual menu.
constructor Load(var S: TStream);
procedure Store(var S: TStream);
end;
+ Menu Palette
background is drawn in background of entry 1
border uses background of entry 3
text - same as TV
------------------------
* = unique to TVGraphic
Unit GMenu
TVGraphic view for temporarily displaying instructions at
top edge of screen - covers MenuBar while visible.
* PGMessageBar= ^TGMessageBar;
* TGMessageBar = object(TView)
MessageText : Str80; {temp var, not saved}
constructor Init;
View is set to same size as MenuBar
State := State and not sfVisible; {set invisible!!}
handles broadcast events.
VFont := DefaultMenuFont;
procedure Busy;
shows message 'WORKING...'
procedure HandleEvent(var Event : TEvent); virtual;
responds to any cmCancel or mouse buttons by calling Hide.
procedure Hide;
calls MenuBar to redraw itself.
procedure ShowText(AText : Str80);
centers AText in the view and calls Draw.
AText may contain sections highlighted with ~'s.
procedure Draw; virtual;
uses menu palette colors. text in Selected colors.
end;
MessageBar Palette
maps directly to the Application palette - uses menu colors
background drawn in background color of entry 2
outline uses background of entry 4
normal text uses foreground of entry 5
highlighted text uses foreground of entry 7
------------------------
* = unique to TVGraphic
Unit GWindow
TPanWindow is a window with a viewable Interior larger than its
Size. It is designed to pan (shift) its Interior when
the mouse cursor reaches the edges of the screen. The usual
way to use this window is to size it to fill the entire DeskTop
DeskTop^.GetExtent(Bounds)
PanWindow.Init(Bounds,...
and then insert other TViews,TGroups,TSubWindows into the window.
Nesting of TPanWindows is not defined, but you can insert
more than one into the DeskTop. TPanWindow requires a MenuBar
but not a StatusLine.
The selected TPanWindow receives evCommand Events from the invisible
ShiftViewPtr view when ShiftView detects the mouse cursor in the
MenuBar or the StatusLine.
TPanWindow calls ShiftViewPtr^.HandleEvent to update it when
the Interior shifts or the window's State changes.
(The ShiftViewPtr view displays messages about panning
by calling the MessageBar view.)
Sizing the PanWindow's Interior
When the mouse cursor is on a grid, use the following rules to
avoid offset from grid after window pans:
Make the TPanWindow.ScrnShiftSize an integral multiple of the
mouse cursor grid size.
Make the TPanWindow.InteriorSize an integral multiple of the
mouse cursor grid size minus 1. {InteriorSize.x := N*grid -1}
* PPanWindow = ^TPanWindow;
* TPanWindow = object(TWindow)
InteriorSize : TPoint; {size of interior in pixels}
Mode : byte; {initialized to 0, reserved}
ScrnShiftSize : TPoint; {number of pixels to shift by}
constructor Init(var Bounds : TRect; ATitle : TTitleStr;
ANumber : integer; TheInteriorSize : TPoint; ThePanSteps : TPoint);
calls TWindow.Init, then sets
GrowMode := 0; {Size is fixed}
Flags := wfClose; {window can close, not move}
Frame^.VOptions := tfDrawBackground;
causes Frame to draw a background for the window
InteriorSize := TheInteriorSize;
The size of the Interior in pixels
ScrnShiftSize := ThePanSteps;
The number of pixels to shift by when panning
function CurAtEdge(Event : TEvent; var Delta : TPoint;
AllowMenuAccess : boolean) : boolean; virtual;
Returns true if Event is a screen shifting event as defined
below AND the Interior is able to shift in the indicated
direction, otherwise false.
Handles evMouseMove plus evCommand where commands
are either cmShiftScreenDown or cmShiftScreenUp.
Behavior at top of screen:
>Bug if setting AllowMenuAccess false.
panning is unreliable due to menubar eating
mousemoves in menu but not at screen top<
If AllowMenuAccess is false or PanWindow is the Modal view, then
will return true when cursor is 20 pixels or less from top
of screen, otherwise will return true only when cursor reaches
top of screen (Y=0).
Behavior at bottom of screen
If PanWindow is the modal view, will
return true when cursor goes below the window bottom
or is greater than or equal to MCur.MaxGridY.
OR If no StatusLine then
returns true if cursor is greater than or equal
to MCur.MaxGridY.
Behavior at sides of screen
Returns true if cursor is greater or equal to
MCur.MaxGridX or less than or equal to MCur.MinGridX.
Function sets Delta with number of pixels to pan by. This will be
either the +-X or +-Y value of ScrnShiftSize. (Unless Interior
is closer than that to its edge. In that case, Delta will be set
with number of pixels to the edge.)
procedure GetFullPanSize(var ISize : TPoint); virtual;
ISize is set to InteriorSize. Called by Frame to get
coords for outline rectangle.
procedure HandleEvent(var Event : TEvent); virtual;
calls TWindow.HandleEvent and then
if Event.What is evMouseMove or evCommand, calls
CurAtEdge. If CurAtEdge returns true, then calls
ShiftScreen (with value of Delta from CurAtEdge
as parameter Shift) to shift the Interior.
Handles window commands cmNext and cmPrev.
cmNext: SelectNext(False); (same as TV DeskTop)
cmPrev: puts current view in front of foremost
non-selectable view. (usually the frame)
function ShiftScreen(var Event : TEvent;
var Shift : TPoint) : boolean; virtual;
Uses Shift to change VOffset by calling SetVOffset.
Calls ShiftViewUpdate for vertical shifts.
Draws the window with its interior in the new position.
Moves the mouse cursor by the amount the Interior
has shifted so it will be over the same spot of the
Interior.
procedure ShiftViewUpdate;
Creates a Broadcast Event where Event.Command =
cmScreenShifted and calls ShiftViewPtr^.HandleEvent;
procedure SetState(AState : word; Enable : boolean); virtual;
Calls ShiftViewUpDate if AState = sfSelected.
Calls TWindow.SetState.
procedure SetVOffset(VX,VY : integer); virtual;
resets Vx,Vy to be multiples of the current mouse grid,
then calls TGroup.SetVOffset.
constructor Load(var S : TStream);
loads the view from a stream
procedure Store(var S : TStream);
stores the view to a stream
end;
------------------------
+ = emulates TV with exceptions noted
PgParamText = ^TgParamText
TgParamText = object(TgStaticText)
+constructor Init(var Bounds: TRect; AText: String;
AParamCount: Integer; Opts : byte);
Opts: added parameter - see TgStaticText description
If Options has ofFramed set, then draws frame around itself.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
commands
cmNew = 30;
cmOpen = 31;
cmSave = 32;
cmSaveAs = 33;
cmSaveAll = 34;
cmChangeDir = 35;
cmDosShell = 36;
cmCloseAll = 37;
help context
hcNew = $FF01;
hcOpen = $FF02;
hcSave = $FF03;
hcSaveAs = $FF04;
hcSaveAll = $FF05;
hcChangeDir = $FF06;
hcDosShell = $FF07;
hcExit = $FF08;
hcUndo = $FF10;
hcCut = $FF11;
hcCopy = $FF12;
hcPaste = $FF13;
hcClear = $FF14;
hcTile = $FF20;
hcCascade = $FF21;
hcCloseAll = $FF22;
hcResize = $FF23;
hcZoom = $FF24;
hcNext = $FF25;
hcPrev = $FF26;
hcClose = $FF27;
TProgram = object(TGroup)
following three methods were not present in TV1.0
function CanMoveFocus: Boolean;
function InsertWindow(P: PWindow): PWindow;
function ExecuteDialog(P: PDialog; Data: Pointer): Word;
+constructor Init;
size Program to full graphics screen.
call order changed, call InitDeskTop after
InitStatusLine,InitMenuBar
+procedure InitDeskTop; virtual;
Sizes DeskTop to fill space between the MenuBar and the StatusLine.
{User does not have to have a MenuBar or StatusLine.}
procedure InitMenuBar; virtual;
never call - always override or don't call at all
+procedure InitStatusLine; virtual;
sets vertical size to MenuBoxheight. Usually overridden.
*procedure SetPalette(Pal : TPalette);
replaces the Application palette (the colors) for the
current screen mode with palette Pal
procedure SetScreenMode(Mode: Word);
shortened to SetVideoMode(Mode);
DoneMemory;
InitScreen;
Do not call this method while in BGI graphics mode!
end;
------------------------
TRadioButtons = object(TCluster) unmodified
------------------------
+ = emulates TV with exceptions noted
TRect
+procedure Intersect(R: TRect);
adjust to match graphic coord system
+function Empty : boolean;
adjust to match graphic coord system
Note - a rectangle with all four coords equal is NOT empty
in TVGraphic. It is a point.
An empty rectangle is not set to all zeros -
Always call Empty function to check for empty.
+function Contains : boolean;
adjust to match graphic coord system
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
const for TScrollBar
CharHt = 14; not user changable
Scrollbars make alot of calculations based on assumptions
about character size. For these calculations, a scrollbar
thinks in terms of characters that are 8 pixels wide by 14
pixels tall. If your horizontal scrollbar Size is not a
multiple of 8 pixels or vertical bar is not a multiple of
14 pixels, then the indicator will not go all the way to
the right/bottom of the bar.
Things still work however.
You will not normally have to think about this.
TScrollBar = object(TView)
constructor Init(var Bounds: TRect);
If Bounds is wider than it is tall, the scrollbar will be
initialized as a horizontal scrollbar, otherwise as vertical.
The thickness of the scrollbar is set using the constant
ScrollBarWidth independent of Bounds or whether a vertical
or horizontal bar. The actual thickness is ScrollBarWidth
plus one pixels.
The scrollbar moving indicator character has changed.
Refer to TV documentation for the rest.
VFont is set to Font8x8. Other fonts are not likely to work!
procedure Draw; virtual; unchanged
*function Exposed : boolean; virtual;
added to handle Panning windows.
*procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
added to handle Panning windows.
*procedure SetState(AState: Word; Enable: Boolean); virtual;
calls TView.SetState and then calls DrawView if AState=sfActive.
Note that this means a scrollbar changes sfActive State
independently and DOES NOT require a TScroller view be present.
private
procedure DrawPos(Pos: Integer);
does the actual drawing, modified for graphics
Draws only the scrollbar (blue) background if not Active.
end;
+ ScrollBar Palette
overall background is drawn in background of entry 1
crosshatch is drawn using foreground of entry 1
indicators and arrows - same as TV
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TScroller = object(TView)
procedure ChangeBounds(var Bounds: TRect); virtual;
does NOT redraw the view
* procedure PartOfSetLimit(X, Y : integer); virtual;
{Important - New with version 1.5!}
sets Limit field to X,Y and calls SetParams for vertical and
horizontal scrollbars, if present. By overriding, the
programmer can set up a scroller for ANY vertical and
horizontal text spacing (or drawing grid spacing).
See full example of this in Demo program.
TScroller.PartOfSetLimit sets up a scroller and scrollbars
to step pixel by pixel. It causes SetLimit to require parameters
X and Y in screen (pixel) coords, not text coords.
+ procedure SetLimit(X, Y : integer); virtual;
calls PartOfSetLimit to allow overriding of SetLimit code
now transfered to PartOfSetLimit.
procedure SetState(AState: Word; Enable: Boolean); virtual;
calls TView.SetState. Does not have any affect on
any scrollbars pointed to by fields HScrollBar or VScrollBar.
See TVGraphic's TScrollBar.SetState
end;
------------------------
* = unique to TVGraphic
TShiftView, Unit GWindow
Special view for sensing mouse position at top edge of screen
and within the StatusLine, if one exists.
If cursor enters these areas and the selected window is a
TPanWindow and its interior can shift, then Shiftview uses
the MessageBar to display message about panning to user.
If right button is clicked in these areas, ShiftView issues
commands targeted at TPanWindow. These commands will cause the
TPanWindow's Interior to shift down if cursor is at top of
screen or up if cursor is in StatusLine.
ShiftView uses the MessageBar to display its messages -
so application must initialize the MessageBar.
* PShiftView = ^TShiftView;
* TShiftView = object(TView)
ScreenIsShiftedDown : boolean; read only
ScreenIsShiftedUp : boolean; read only
MessageDisplayed : boolean; read only
constructor Init(var Bounds: TRect);
calls TView.Init whic sets the booleans fields false.
then sets EventMask := EventMask or evMouseMove or evBroadcast;
procedure HandleEvent(var Event : TEvent); virtual;
responds to broadcasts of (Event.Command = cmScreenShifted)
by checking the InfoWord. If upper or lower byte = 'T' then
sets either ScreenIsShiftedDown,ScreenIsShiftedUp.
MouseEvents
evMousemove
if cursor is at top of screen or in StatusLine,
then displays message
'CLICK RIGHT BUTTON TO PAN SCREEN'
Clears the message if cursor moves out of these
areas.
evMouseDown and right button
if cursor is at top of screen or in StatusLine,
then issues a evCommand event with either
Command = cmShiftScreenDown or cmShiftScreenUp
Uses the MessageBar to display its messages.
constructor Load(var S : TStream);
loads the view from a stream
procedure Store(var S : TStream);
stores the view on a stream
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
PgStaticText = ^TgStaticText
TgStaticText = object(TView)
+constructor Init(var Bounds : TRect; AText : String; Opts : byte);
OPts: added parameter
(examples: OPts := DefaultOpts; DefaultOpts matches TV
Opts := txCentered + txDrawBackground)
DefaultOpts - no options
txCentered - if width of AText will fit in the view's Bounds,
centers text horizontally in Bounds and then
shrinks Bounds.A.x,Bounds.B.x to just contain AText.
Works with any font.
txAdjustSize - if width of AText will fit in the view's Bounds
adjusts Bounds.B.x to just contain AText. Works
with any font.
txDrawBackground - for maximum speed and minimum flicker, StaticText
does Not normally draw a background in TVGraphic. This is
almost never a problem with the short strings in Dialogs.
If you use a StaticText view wider than the narrowest
window/dialog you will ever drag across it, then you need
a background for partial screen redraws. Use this flag.
VColor is set to TVColor which causes Draw to use the palette
instead of VColor for color slection. To override, after Init
set VColor to desired color pair (byte). Format is the same as
Application palette entries.
Font selection - if lower 4 bits of Opts are not 0, then VFont
is set to equal to the lower four bits which represent a font
number. If 0, then VFont is set to DefaultDialogFont.
(Note this precludes your using the BGI DefaultFont which does
not clip properly.)
String Formating
If multiple lines, view will draw them spaced Boxheight apart.
AText may have the usual embedded formating characters ^M and ^C.
^C centers following text (up to a ^M) in the view.
^M causes following text to start on a new line.
The automatic line wrapping at the right side of the view and
the ^C centering of text assume the selected text font
is 8 pixels wide/character.
procedure Draw; virtual;
If multiple lines, view will draw them spaced Boxheight apart.
Uses the palette for colors unless VColor is not equal to TVColor.
Then uses the color pair in the lower byte of VColor for
text color and background.
Uses the text font stored in VFont.
Uses BYOffset in vertical positioning of text within the view.
! Text is indented 4 pixels from left edge of view.
If Options has ofFramed set, then draws frame around itself.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TgStatusLine = object(TView)
+constructor Init(var Bounds: TRect; ADefs: PStatusDef);
VFont := DefaultMenuFont;
procedure Draw; virtual; {unmodified - calls DrawSelect}
+procedure HandleEvent(var Event: TEvent); virtual;
passes right mouse button presses through with no action.
NOTE: when the StatusLine issues a command due to keypress's and
mouse buttons, TVGraphic sets the InfoPtr to Ptr(0000,0001)
versus TV which sets it to nil.
The change enables future implementation of TVGraphic features.
private
procedure DrawSelect(Selected: PStatusItem); {rewritten for graphics}
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
Unit GWindow
TSubWindow is an ordinary window except for its GetPalette function.
Use TSubWindow (or a descendant) when inserting a window into another
window to get correct drawing colors. TSubWindow will also work in
any situation where a regular TWindow works.
NOTE: With version 1.5, it is no longer necessary or desirable to
override GetPalette if you create a descendent of TSubWindow.
Previous overrides should be removed or modified.
* PSubWindow = ^TSubWindow; {can be inserted into a window}
* TSubWindow = object(TWindow)
+function GetPalette : PPalette; virtual;
usual behavior unless window's owner is a TWindow or
descendant (VOPtions and twIsWindow <> 0).
In these cases, GetPalette returns nil.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
In unit GObjects.
A simple collection of strings using PString pointers.
Use function NewStr(AString) to create a string and return
a PString pointer. Insert the pointer into the collection.
The collection knows how to store, load and dispose of strings.
* PUnSortedStringCollection = ^TUnSortedStringCollection;
* TUnSortedStringCollection = object(TCollection)
+procedure FreeItem(Item : Pointer); virtual;
same as TStringCollection
+function GetItem(var S : TStream) : pointer; virtual;
same as TStringCollection
+procedure PutItem(var S : TStream; Item : pointer); virtual;
same as TStringCollection
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TView = object(TObject)
*Hook : TUserRec; {not used by TVGraphic - for users of TVGraphic}
*VColor : word; {color pair(s) if overriding palette selection}
*VFont : byte; {for text font storage}
*VOptions : byte; {TVGraphics options}
*VOffset : TPoint; {used to offset the screen across a graphical
view that is larger then the screen.}
{Used by MakeLocal,MakeGlobal,Exposed}
*ZoomLevel : byte; {reserved by TVGraphics}
+constructor Load(var S: TStream);
loads added fields
*function BackColor(Color: Word): byte;
Expects Color to be a color pair from the palette.
returns bits 4-7 of Color in lower 4 bits of the byte
! +procedure ChangeBounds(var Bounds: TRect); virtual;
ChangeBounds does NOT redraw the view. Merely calls SetBounds.
+procedure DragView(Event: TEvent; Mode: Byte;
var Limits: TRect; MinSize, MaxSize: TPoint);
Lock cursor while dragging,
calls DrawView after dragging.
when using arrow keys to move, jump is based on current mouse grid.
Shift arrow keys change size.
Bug if you move and resize and then hit escape to undo.
+procedure Draw; virtual;
does nothing
+procedure DrawView;
modified for blinking cursor
+function Exposed: Boolean; virtual;
made virtual;
true if (Owner<>nil) and (sfExposed and sfVisible are set) and
Owner^.LockFlag = 0 and
intersection of view outline with Owner^.Clip <> empty.
+procedure GetClipRect(var Clip: TRect);
returns Clip in local coordinates,modified to work with VOffset.
*function ForeColor(Color: Word): byte;
Expects Color to be a color pair from the palette.
returns bits 0-3 of Color in lower 4 bits of the byte
*procedure GetScreenCoords(var R : TRect);
sets R to the absolute screen coords of the outline of the view.
(same coord system as BGI and mouse)
Takes VOffset of all Owners in the view chain into account.
R.A is upper left corner, R.B is lower right corner.
These coords are useful for setting the viewport to match
the outline of the view.
*procedure GetVPRelCoords(var R : TRect);
same as GetScreenCoords except R is Viewport relative.
Example: Passing R to the Rectangle call will draw a
rectangle outlining the view independent of the
viewport setting. Of course if the viewport is too small,
the rectangle will be clipped. If the viewport is
set to full screen, GetVPRelCoords returns same numbers
as GetScreenCoords.
+procedure HandleEvent(var Event: TEvent);
handles evTimerTick to blink the text cursor
*function HorzTextOffset : integer; virtual;
returns 0. Override if necessary in your descendants that
use the blinking text cursor.
procedure HideCursor;
same code as TV but the effect is to erase the blinking
cursor And Restore the Background Underneath It.
See also ResetCursor.
+procedure Locate(var Bounds: TRect);
implements partial redraws, major design changes
+procedure MakeGlobal(Source: TPoint; var Dest: TPoint);
rewritten
coordinate transformation Source to Dest.
Source should be in view's local coordinate system -
if view is a descendent of TGroup, then Source should be
in the coordinate system of the view's Interior.
(If VOffset = 0,0 local and Interior coords match.)
Dest is in absolute screen coords (mouse coords)
Takes VOffset of all Owners in the view chain into account.
+procedure MakeLocal(Source: TPoint; var Dest: TPoint); Virtual;
rewritten, made virtual;
coordinate transformation Source to Dest.
Source should be in absolute screen coords (mouse coords).
Dest is in coordinate system of view or in coordinate
system of view's Interior if view is TGroup descendent.
(If VOffset = 0,0 local and Interior coords match.)
Takes VOffset of all Owners in the view chain into account.
+function MouseInView(Mouse: TPoint): Boolean; virtual;
made virtual;
+procedure PutInFrontOf(Target: PView);
modified to work in graphic mode
*procedure ResetCursor(EraseIt : boolean); virtual;
was Private method, now public and virtual.
prior to ver1.5, performed no action. Now in use.
Parameter EraseIt added in ver 1.5
IMPORTANT - if the cursor is visible and you are about to
redraw your view so the background under the cursor will
be different, AND you are not calling DrawView to redraw,
then call ResetCursor(True). {Or call SetCursor}
(HandleEvent will call ResetCursor(false) to draw the cursor
at the next evTimerTick event if the view is focused.)
Erases and Draws standard TV/TVGraphic blinking text cursor.
Call with EraseIt = True to erase cursor just before redrawing.
Calls new virtual functions VertTextOffset and VertTextSpacing
to know how to position cursor vertically on screen.
Calls HorzTextOffset to help position itself horizontally.
Looks at the font name stored in VFont to determine the
vertical size of the font you are using.
Assumes horizontal spacing of 8 pixels/char.
Will not draw unless view's EventMask includes evTimerTick.
procedure Select;
fix TV 1.0 bug, add test that view is selectable before selecting
+procedure SetCursor(X, Y: Integer);
Erases the blinking cursor at the current location (if visible)
by calling ResetCursor(true).
Sets the Cursor field (cursor position) to X,Y.
See notes under ResetCursor.
+procedure SetState(AState: Word; Enable: Boolean); virtual;
calls when AState = sfVisible to ResetCurrent are modified
to work in graphics mode.
+procedure Store(var S: TStream);
stores added fields
*function UserHook(var P : Pointer; var Hk : TUserRec):boolean; virtual;
provided for TVGraphic users to override in descendents.
TView version returns false and does not change its parameters.
*function VertTextOffset : integer; virtual;
Temporarily sets BGI TextStyle to font stored in field VFont
by calling SetTextStyle(VFont, horizdir, 1),
calls CalcVertTextOffset(VertTextSpacing) to find value,
and restores previous font.
For font8x8 and font8x14 used with VertTextSpacing = Boxheight,
VertTextOffset returns the same value as global ByOffset.
Used by the blinking cursor.
Override if you need a different vertical offset for the cursor.
*function VertTextSpacing : integer; virtual;
returns constant Boxheight. Used by blinking cursor.
Override if your view's vertical text spacing differs from
Boxheight and you want cursor to match.
{Following methods are not present in TVGraphic:
procedure WriteBuf(X, Y, W, H: Integer; var Buf);
procedure WriteChar(X, Y: Integer; C: Char; Color: Byte;
Count: Integer);
procedure WriteLine(X, Y, W, H: Integer; var Buf);
procedure WriteStr(X, Y: Integer; Str: String; Color: Byte); }
private
*procedure DrawUnderRect(var R: TRect; LastView: PView);
totally different design. Minimizes number of redrawn views.
made public - procedure ResetCursor;
end;
------------------------
* = unique to TVGraphic
Unit GWindow
TWinBackground is a simple view for providing a background
in a window. It will work with or without a Frame in the window.
* PWinBackground = ^TWinBackground;
* TWinBackground = object(TView)
constructor Init(var Bounds: TRect);
calls TView.Init, then sets
GrowMode := gfGrowHiX + gfGrowHiY;
EventMask := 0;
VColor := TVColor;
procedure Draw; virtual;
fills view with solid color.
If VColor = TVColor then color from palette will match
the color that TFrame will use (if one is present) for
its background. Otherwise will use VColor as background color.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TWindow = object(TGroup)
+constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
sfShadow flag in State is not set.
*procedure Draw; virtual;
hides and locks the mouse cursor
Sets viewport to the intersection of Clip and the window outline.
Calls TFrame.Draw if dragging, otherwise TGroup.Draw.
Restores the viewport to previous size and unlocks the mouse cursor.
*procedure GetMaxSubViewSize(var R : TRect); virtual;
{was named GetInteriorSize prior to ver1.5}
if Frame <> nil then calls Frame^.GetInteriorSize(R),
otherwise calls GetExtent(R) and then shrinks R by one pixel
on all four sides to allow for an outline rectangle for the window.
+procedure HandleEvent(var Event: TEvent); virtual;
cmClose - also responds if Event.InfoPtr = Ptr(0000,0001) which
indicates sender was the scrollbar.
cmZoom - did not check InfoPtr before ver1.5, now responds if
InfoPtr is nil, @Self or Ptr(0000,0001).
+procedure SetState(AState: Word; Enable: Boolean); virtual;
rewritten for nested windows. Same behavior as TV except
No action if AState = sfActive. Sets its own and its subview's
sfActive bit to match window's sfSelected bit.
+function StandardScrollBar(AOptions: Word): PScrollBar;
if the window has a Frame then the Frame's VOption field
is set with tfVScrollBar or tfHScrollBar depending on AOptions.
Next the scrollbar is sized and its width is set using constant
ScrollBarWidth. A new scrollbar is created and inserted into the
window. If AOptions includes sbHandleKeyboard, the scrollbar
Options are set to include ofPostProcess. Finally a pointer to
the scrollbar is returned as the value of StandardScrollBar.
end;
+ Window Palettes
Window palettes are extended to map TV1 (TV2 graydialog) dialog palette.
These extensions are used by the modified TDialog.GetPalette and
may change in the next revision of TVGraphic.
CBlueWindow = #8#9#10#11#12#13#14#15 + CxDialog;
CCyanWindow = #16#17#18#19#20#21#22#23 + CxDialog;
CGrayWindow = #24#25#26#27#28#29#30#31 + CxDialog;
CxDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47+
#48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;