home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 21
/
CD_ASCQ_21_040595.iso
/
dos
/
prg
/
pas
/
tvgr70
/
refer20.doc
< prev
next >
Wrap
Text File
|
1995-01-11
|
127KB
|
2,961 lines
September 1994 (v2.02 December 1994)
If you use the IDE, keep this file in a window for convenient reference.
v2.02 Note: all views in TVGraphic v2.0 or greater have the
ofVersion20 flag set in Options field.
REFERENCE SECTION Ver2.0
{ Other Documentation files:
BitMaps, BitButtons and related views in file BitMap.DOC.
Editors documentation in file Editors.DOC.
TV Help system GHelp (Borland HelpFile.Pas) in file GHelp.DOC.
TextView documentation in file TextView.DOC.
Other .DOC files cover specialized areas.
Fonts.DOC
European.DOC }
NOTES
Changes are relative to Turbo Vision 2.0 unless otherwise noted.
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.
Significant areas of Turbo Vision not presently in TVGraphic:
Outline unit
If your compiler does not recognize some TV syntax when
using TVGraphic, 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.
Included in this file :
For objects that are analogous to Turbo Vision objects,
usually only methods that have been added/deleted/modified
are listed in this section. 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 may be not listed.
Unit Version Numbers:
Each unit exports a version number string constant under
the name of GVersion. This number could be important when describing
problems and requesting support for TVGraphic.
GVersion can be checked by using the IDE's Evaluation window -
for example include GObjects in a uses statement, compile and then
evaluate GObjects.GVersion to get the version of the GObjects unit.
------------------------
Application Palette
With v2.02 the scrollbars have changed.
They now draw buttons for the indicator and control arrows.
All Application palette entries for Scrollbar indicator/arrows
have been changed from cyan on blue to black on light gray.
{See individual objects for TVGraphic palette definitions.}
Format
Foreground color = lower 4 bits, background = upper 4 bits.
TVGraphic allows all 16 colors for background.
There is no inherent "blink" in graphic mode.
Notes
Windows
TVGraphic windows use the wpBlueWindow palette unless you change
the window's Palette entry. The "Blue" window portion of the
Application palette starts at entry 8. A TVGraphic Blue window
has blue border, title block and scrollbars, otherwise lightgray.
The wpCyanWindow palette is used by the help window in unit GHelp.
(GHelp corresponds to Borland HelpFile.Pas.)
The wpGrayWindow palette is not used by the standard views.
The Window palettes have been extended. See TWindow.
Dialogs
TVGraphic v2.0 Dialogs use the palette specified in
DefaultDialogPalette. This is dpCyanDialog unless changed.
Colors for the dpBlueDialog palette have not been changed from TV.
TV2.0 dpXXXX constants: IDE's Help says they run 1,2,3
but TV2.0/TVGraphic2.0 Dialog unit exports them as 0,1,2 !
Indices
{1 application background}
{2-7 Menus, StatusLine}
BlueWindow starts at 8, CyanWindow at 16, GrayWindow at 24.
BlueWindow
8-10 TFrame,11-12 Scrollbar,13-14 Scroller,15 reserved
GrayDialog starts at 32, BlueDialog at 64, CyanDialog at 96.
CyanDialog 96-127
remaps local palettes below
{96-98 TFrame, 99-100 Scrollbar}
{101 StaticText, 102-104 Label}
{105-110 Buttons}
{111-113 Checkboxes and Radiobuttons}
{114-116 InputLine}
{117-120 HistoryIcon, HistoryWindow Scrollbar}
{121-124 ListViewer}
{125 InfoPane in FileDialog}
CAppColor =
{1-15} #$3B#$70#$78#$F4#$8F#$87#$7E#$78#$7F#$70#$13#$70#$70#$F9#$1F +
{16-31} #$37#$3F#$30#$13#$70#$30#$7E#$1E#$78#$7F#$7F#$8F#$70#$70#$F9#$7E +
{32-47} #$70#$7F#$70#$13#$70#$70#$70#$7F#$7E#$70#$71#$7F#$78#$2E#$8F#$70 +
{48-63} #$7F#$8E#$70#$FE#$8A#$70#$00#$13#$70#$70#$8F#$7E#$F1#$70#$38#$00 +
{64-79} #$17#$1F#$1A#$71#$70#$1E#$17#$1F#$1E#$20#$2B#$2F#$78#$2E#$10#$30 +
{80-95} #$3F#$3E#$70#$2F#$7A#$20#$12#$31#$70#$30#$2F#$3E#$31#$13#$38#$00 +
{96-111} #$30#$3F#$30#$13#$70#$30#$30#$3F#$3E#$70#$7A#$7F#$78#$2E#$8F#$70 +
{112-127} #$7F#$8E#$70#$BE#$8A#$70#$00#$13#$70#$70#$8F#$7E#$F1#$30#$38#$00;
CAppBlackWhite =
#$70#$70#$78#$7F#$07#$07#$0F#$07#$0F#$07#$70#$70#$07#$70#$0F +
#$07#$0F#$07#$70#$70#$07#$70#$0F#$70#$7F#$7F#$70#$07#$70#$07#$0F +
#$70#$7F#$7F#$80#$07#$70#$70#$7F#$7F#$07#$0F#$0F#$78#$0F#$0F#$07 +
#$0F#$0F#$0F#$70#$0F#$07#$70#$70#$70#$07#$70#$0F#$07#$07#$78#$00 +
#$07#$0F#$0F#$07#$70#$07#$07#$0F#$0F#$70#$78#$7F#$08#$7F#$08#$70 +
#$7F#$7F#$7F#$0F#$70#$70#$07#$70#$70#$70#$07#$7F#$70#$07#$78#$00 +
#$70#$7F#$7F#$80#$07#$70#$70#$7F#$7F#$07#$0F#$0F#$78#$0F#$0F#$07 +
#$0F#$0F#$0F#$70#$0F#$07#$70#$70#$70#$07#$70#$0F#$07#$07#$78#$00;
------------------------
unique to TVGraphic
BMPDRVR Unit - see file BITMAP.DOC
PutBitMap, WinToTVColor and other bitmap procedures
COMBOBOX Unit - see file ComboBox.Pas
supplied upon registration
A combobox is a TInputLine with an associated TListBox, similar to
a THistory. The listbox displays choices the user may select for
the inputline.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GAPP Unit
const
* GlobalGVersion = {version of this copy of TVGraphic.
string includes word "Shareware" for shareware versions.
Shareware versions may not have all features.}
Note: Programs in TVGraphic descend from TProgram, not TApplication.
TApplication is not defined. Most methods from TV's
TApplication have been added to TVGraphic's TProgram.
* MessageBar : PMessageBar = nil;
points to the MessageBar if one exists
* procedure ImprovePaletteColors;
for screens in VGA or VESA 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
Standard TV commands and help contexts
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;
------------------------
unique to TVGraphic
GBUT Unit see file BITMAP.DOC
bitmapped buttons - TIconButton, toolbar, TStaticBitMap
procedure RegisterBitMaps; Stream registration of views.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GCOLORS Unit TV's ColorSel
+ 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;
* function HelpColorItems(Next: PColorItem): PColorItem;
{the HelpWindow uses the wpCyanWindow palette}
TColorDisplay = object(TView)
+ procedure DispSetColor(var AColor: Byte); virtual;
name of above procedure is SetColor in TV2.0. This conflicts
with Graph.SetColor so TV1.0 name is used for this method.
------------------------
* = 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
TV constants
+ CDialog = CCyanDialog {CGrayDialog};
* TVGraphic constants
AlignVScrollBarsWithGrid : boolean = false;
If true, matches vertical scrollbar indicator travel
to vertical mouse grid of 14 pixels. See TScrollBar for details.
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,TgInputLine constructors.
Also in StaticText, ParamText, Label unless
overidden in Init(..,..,.,Opts) parameter.}
DefaultDialogPalette : byte = dpCyanDialog;
Used by TDialog.Init to set the Palette field of Dialogs.
MouseSnapToDialogGrid : boolean = true;
causes mouse cursor to snap to a 8x14 pixel grid while a
modal Dialog is visible
StaticTextOffset : byte = 0;
TStaticText, TLabel: Offset of text into the view.
Was 4 pixels prior to v2.02. 0 matches TurboVision.
VOptions constants:
DefaultOpts = 0; {= behavior most like Turbo Vision}
Text objects set VOptions to match options in the Opts field
of their constructor.
Opts := DefaultOpts for no options
:= 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; {v2.02 no longer needed}
txCentered = $10;
TgStaticText,TgParamText,TgLabel
txAdjustSize = $20;
DefaultFontOverride = lower four bits of Opts = 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,
Note: right justified line may not exceed width of view.}
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 Name Changes
* CgInputLine
* CgLabel
* CgStaticText
Palettes
see THistoryWindow for modified palette
TV2.0 Palette constants
dpBlueDialog = 0;
dpCyanDialog = 1;
dpGrayDialog = 2;
dpTV1Dialog = 3 Used in earlier versions of TVGraphic.
No longer defined. Use dpCyanDialog for default dialog colors.
------------------------
* = unique to TVGraphic
GDRIVERS Unit
MOUSE
type
Used with mouse cursor grid, TMCur.GetGrid returns this type.
X,Y are size of grid. Xoff,Yoff are the offset of grid from
upper left screen corner.
* MGridRec = record
X : byte; Y : byte; Xoff : word; Yoff : word;
end;
* EXTENDED KEYBOARD {thanks to Jim Mischel}
TVGraphic will detect if an extended (101) keyboard is present.
To enable detection of the extra KeyCodes of an extended keyboard,
add this line at the end of your TApplication.Init.
KeyMode := SetKeyboardMode(kbmExtended); {KeyMode : byte}
if KeyMode = kbmExtended, then 101 keyboard was detected.
Keyboard mode flags
kbmStandard = 0;
kbmExtended = $10;
101 Keyboard Extended KeyCodes
kbAltEsc = $0100; kbAltTab = $A500; kbAltEnter = $1C00;
kbAltTilde = $2900; kbAltLBrack = $1A00; kbAltRBrack = $1B00;
kbAltBSlash = $2B00; kbAltColon = $2700; kbAltQuote = $2800;
kbAltIns = $A200; kbAltDel = $A300; kbAltLeft = $9B00;
kbAltHome = $9700; kbAltEnd = $9F00; kbAltUp = $9800;
kbAltDown = $A000; kbAltPgUp = $9900; kbAltPgDn = $A100;
kbAltRight = $9D00; kbF11 = $8500; kbF12 = $8600;
kbShiftF11 = $8700; kbShiftF12 = $8800; kbCtrlF11 = $8900;
kbCtrlF12 = $8A00; kbAltF11 = $8B00; kbAltF12 = $8C00;
kbCtrlGrayMinus = $8E00; kbCtrlGrayPlus = $9000;
kbAltGrayMinus = $4A00; kbAltGrayPlus = $4E00;
kbGraySlash = $E02F; kbCtrlGraySlash = $9500; kbAltGraySlash = $A400;
kbCtrlGrayStar = $9600; kbAltGrayStar = $3700;
kbAltComma = $3300; kbAltPeriod = $3400; kbAltSlash = $3500;
kbCtrlUp = $8D00; kbCtrlDown = $9100; kbGrayStar = $372A;
EVENTS
* procedure SwallowControlKeys;
The DOS keyboard buffer can overflow if a key is held down that
calls a long Draw method repeatedly. This procedure removes
control keystrokes from the keyboard buffer until it reaches some
other keystroke.
If you have this problem, call at beginning of your Draw.
TEvent.Buttons
TVGraphic returns the button number in Event.Buttons when a
mouse button is released (evMouseUp event).
Turbo Vision returns zero.
* Timer Tick Event
evTimerTick = $0080; {an evXXXX Event constant}
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;
DOS CRITICAL ERROR handler
TV's text mode critical error handler has been modified to do nothing
except return "Abort". {As if user selected Abort from Abort/Retry.}
In any serious program, you should replace the critical error handler
with TVGraphic's GSystemError or by one you write.
* function GSystemError(ErrorCode: Integer; Drive: Byte): Integer; far;
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 large demo program.
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}
DELETED
procedure PrintStr(S: String); {text mode only}
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);
------------------------
GEDITORS Unit see file Editors.Doc
GHELP Unit TV's HelpFile.Pas - see file GHelp.Doc
supplied upon registration
------------------------
GHISTLST Unit TV's HistList
This unit is essentially unchanged in TVGraphic.
The unit name is changed to GHistLst.
The Uses clause is modified to use TVGraphic unit names.
For use with compiled TVGraphic: you may modify the source code
in the Implementation section of HistList if you also make the
changes above. Then your GHistLst unit will compile with TVGraphic.
------------------------
* = unique to TVGraphic
GMENUS Unit (was unit GMenu6 in v1.5)
Behavior
The choice of how menus respond to mouse button clicks depends
on the two booleans exported by GViews unit.
AllowBothMButtons {from GViews}
false: left button selects and right cancels.
true : both buttons select
ViewsRespondToMouseUp {from GViews}
false: TVGraphic style of versions prior to 2.0,
select on button press.
true : Turbo Vision style menu behavior,
select on button release.
* const {user changable}
MenuBarheight : integer = 15;
height of the MenuBar in pixels,
minimum 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 = false; {true in v1.5}
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;
VOptions flags
mnFatBorder = $80;
menu draws a fat border. Set by TMenuPopUp.Init.
mnCloseOnDouble = $40;
menu issues cmClose if it receives a double mouse click outside
of menu selections. Set by TWindowMenu.Init.
Palette
CWindowMenu = #128#129#130#131#132#133;
maps thru extended TWindow palettes which duplicate
CMenuView at 128-133
* PMessageBar= ^TMessageBar;
* TMessageBar = object(TView)
{for use in TWindow}
* PWindowMenu = ^TWindowMenu;
* TWindowMenu = object(TMenuPopup)
Stream Registration Numbers
RMenuBar : gRegBase + 40;
RMenuBox : gRegBase + 41;
RStatusLine : gRegBase + 42;
RMenuPopup : gRegBase + 43;
* RMessageBar : gRegBase + 1100;
* RWindowMenu : gRegBase + 1101;
------------------------
* = unique to TVGraphic
GMSGBOX Unit
mfxxxx constants
* mfMakeTaller = $1000; {increase height of MessageBox by two lines}
* 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.
DOSErrNum
0 : no error, Exit
1 : S := 'Invalid DOS function number.';
2 : S := 'File not found.';
3 : S := 'Path not found.';
4 : S := 'Too may open files.';
5 : S := 'File access denied.';
6 : S := 'Invalid file handle.';
8 : S := 'Insufficient memory.';
10: S := 'Invalid environment.';
11: S := 'Invalid format.';
12: S := 'Invalid file access code.';
15: S := 'Invalid drive number.';
16: S := 'Cannot remove current directory.';
17: S := 'Cannot rename across drives.';
18: S := 'No more files.';
else
S := 'Unspecified DOS error.'
* procedure LowMemMsgBox; {Out of memory Messagebox}
MessageBox('Not enough memory available.',
nil, mfError + mfOkButton);
+ function MessageBox(..; ..; AOptions: Word): Word;
if AOptions and mfMakeTaller <> 0
then increases height of box by two lines for longer messages.
+ function MessageBoxRect(): Word;
MessageBoxRect will be automatically centered in Owner view if
the origin of the rectangle is 0,0. Centering works with any
mouse grid in use.
Dialog^.Options := Dialog^.Options or OfCentered;
+ function InputBoxRect: Word;
InputBoxRect will be automatically centered in Owner view if
the origin of the rectangle is 0,0. Centering works with any
mouse grid in use.
Dialog^.Options := Dialog^.Options or OfCentered;
TV bug fix - Buttons adjust position to match box size.
------------------------
* = unique to TVGraphic
GOBJECTS Unit
* UpCase capitalization function
To allow for capitalization in non-English alphabets:
type
UpCaseFuncType = function(Ch : Char): Char;
function TVUpCase(Ch : Char): Char;
{TVUpCase := System.UpCase(Ch);}
const
UpCase : UpCaseFuncType = TVUpCase;
This overrides the Pascal system UpCase function in every unit which
lists GObjects in its USES clause! (all views of TVGraphic).
The TVUpCase function calls the standard Pascal UpCase function.
To modify capitalization,
1. write your function MyUpCase matching the UpCaseFuncType type.
2. assign it to UpCase at the start of your program.
UpCase := MyUpCase;
const
* Str80 = string[80];
const
Stream (TStream) Registration numbers
* gRegBase = 60000;
Used to offset the stream registration numbers of all
objects descended from TView.
TVGraphic Reg number := TV's Reg number + gRegBase.
Also used with objects unique to TVGraphic
such as TUnSortedStringCollection.
* TUnSortedStringCollection: gRegBase + 51;
TCollection - Error code for method TCollection.Valid
* coTruncationErr = -100; {not enough mem to load all items from disk}
TMemoryStream - TV2.0 object
present in TVGraphic units. Borland doc is in a Borland disk file.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GSTDDLG Unit
VOptions constants
* lbRestartSearch = $01; TSortedListBox and descendants
don't restart their alphabetical search if they lose the
Focus and regain it.
Set this flag in VOptions to force restart of search.
+ TFileDialog/TChDirDialog
The instant erase feature of the Inputline has been disabled.
It can be enabled by clearing the KillInstantErase flag bit in
the MyFileDialogPointer^.FileName^.VOptions field.
+ TFileDialog.GetFileName
TV bug fix - when are on non-current drive and enter path
starting with root directory (\.......), GetFileName uses the
current drive. Fix prepends actual drive to path.
+ TFileList.HandleEvent
TV bug fix - modified to record History if selection is made
by double clicking the mouse.
+ function ValidFileName used by File dialogs
TV bug fix - modified so it checks that length of a filename
and extension is valid, that path can be parsed.
+ TDirListBox.SetState
rewritten due to different way TVGraphic handles default button
Protected mode
GetShiftState substituted for ShiftState variable
* HourGlass cursor
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.
* GStdDlg Text strings, Character set
Changing - See file EUROPEAN.DOC.
------------------------
GVALIDAT Unit TV's Validate
This unit is essentially unchanged in TVGraphic.
The unit name is changed to GValidat.
Both Uses clauses are modified to use TVGraphic unit names.
The constant GVersion = 'G2.00'; is added as the first constant
declared in the unit's Interface section.
For use with compiled TVGraphic: you may modify the source code
in the Implementation section of Validate if you also make the
changes above. Then your GValidat unit will compile with TVGraphic.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
GVIEWS Unit
type
+ SelectMode = (NormalSelect, EnterSelect, LeaveSelect,
DrawLater, EraseLater);
const
+ MaxViewWidth = 132*Charlen;
+ MinWinSize: TPoint = (X: 16*Charlen; Y: 6*Boxheight);
* LoadVersion : word = 0; set by TView.Load to (Options and ofVersion).
{used by .Load methods to control updating}
+ Window Palettes extended. Dialog and Menu palettes added to end.
See TWindow
* TVGraphic constants
Redraw Control for TListViewer,TScroller
uvDrawView = $04; {same value as ufView in TEditors}
uvFocused = $02;
uvScrollBar = $08;
uvNotDrawByLines = $10;
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;
Scrollbar widths
(*v1.5 ScrollBarWidth = 11; {0 to 11 = 12 pixels total width}*)
HScrollBarWidth = 11; {different so TFrame interior is on 8x14 pitch}
VScrollBarWidth = 10;
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.
Mouse Button Behavior - Global
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 - selects,
will not cancel modal dialog box.
ViewsRespondToMouseUp : boolean = false;
Used by all standard views (Frames, Buttons, Menus, etc.)
When false
views respond immediately to evMouseDown (mouse button press)
When true
views wait for evMouseUp before responding (mouse button release)
This gives mouse button behavior like Turbo Vision.
TView DrawFlags masks
dfPanning = $01; view pans in a TPanWindow - set by TView
dfAlternateRedraw = $02; Use in a TGroup descendant.
Group draws from top view down, rather than bottom up.
Better redraws where several views overlap.
dfTransparent = $04; Set if view does not draw its own background.
Note: A view's Draw must still draw its background if its
Owner has dfAlternateRedraw set.
Do not alter the following flags in DrawFlags
dfIsWindow = $08; identifies group as a TWindow descendant
dfDrawUnder = $80; {temporary use bit}
TView VOptions constants {redefined by each view}
TWindow
constant NO LONGER DEFINED - use dfIsWindow in DrawFlags field.
twIsWindow = $80; {identifies group as a TWindow descendant}
TFrame drawing control
tfDrawBackground = $01; {fill entire view with background}
{values of next two constants were incorrectly documented in v1.5}
TWindow.StandardScrollBar sets the TFrame.VOptions scrollbar flags.
tfVScrollBar = $04 {02}; set if bar is present in Window
tfHScrollBar = $02 {04};
tfMarginsForText = $08; Do not alter flag
TFrame.GetInteriorSize sets/clears this flag according
to the type of margins specified by user in
call to TWindow.GetMaxSubViewSize.
See TFrame.GetInteriorSize.
type
This is the record type used for field TView.Hook and method UserHook.
* 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 Unit
Commands
const used to communicate between TPanWindow and TShiftView
cmScreenShifted = gRegBase + 2000;
cmShiftScreenDown = gRegBase + 2001;
cmShiftScreenUp = gRegBase + 2002;
const for TPanWindow
NormalMode = 0;
ScrnShiftX : word = Grid * 20;
ScrnShiftY : word = Grid * 15;
Number of pixels to shift screen when mouse
cursor hits edge of a Panning window.
These values are not directly referenced by TVGraphic.
Ignore or 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}
If you create a TShiftView, must set ShiftViewPtr to point to it.
Stream Registration Numbers
ShiftView: gRegBase + 2000;
SubWindow: gRegBase + 2001;
PanWindow: gRegBase + 2002;
WinBackground: gRegBase + 2003;
procedure RegisterWindows;
-----------------------
* = unique to TVGraphic
* MCURSOR Unit
There are many methods for the cursor but the average user
will use only these:
Show, Hide
LockShow, LockHide
RePosition move mouse cursor to new position on screen
RestoreSettings (use after DOS shell)
SetGrid if you want to specify a grid other than single pixel
Cursor Image, HotSpot
The mouse cursor has a "HotSpot" TPoint variable to indicate the
offset of the active point in the cursor image from the upper left
corner of the image.
The image is stored in two arrays, CurImageArray for the main image
and ShadowImageArray for the outline shadow. These images are 16x16
pixels. The first word of the array is the top line of the image.
The high order bit of each word is the leftmost pixel.
The main image is drawn in white and the shadow in black.
If you change the image arrays below after calling TProgram.Init,
call SelectStdCursor to display the new image.
type
TCurImageArray = array[0..15] of word;
const
HotSpot : TPoint = (x:0; y:0);
{location of Active point in the cursor}
var
CurImageArray, ShadowImageArray : TCurImageArray;
HourGlass cursor shape (not user changable)
Switch to it with MCur.SelectHourGlass, back with MCur.SelectStdCursor.
HourGlass is intended to indicate waiting only - buttons are disabled.
At Startup:
MyCursor
the mouse grid is set to (1,1,0,0) by a call to SetGrid.
{was set to (10,10,0,0) prior to v2.0}
GMenu
MouseSnapToMenuGrid is set false {was true in v1.5}
GDialogs
MouseSnapToDialogGrid is set false {was true in v1.5}
Note: This type is declared in GDrivers and used by TMCur.GetGrid.
type
MGridRec = record
X : byte; Y : byte; Xoff : word; Yoff : word;
end;
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(1,1,0,0); set to 1x1 pixel grid
SetSpeed(12,12); reduce mouse sensitivity, "normal" is 8,8
SelectStdCursor;
destructor Done;
procedure CenterIt;
Computes center of screen and then calls RePosition(center)
procedure CurWhere(var Pt : TPoint);
returns cursor position
procedure GetGrid(var AGrid : MGridRec);
sets AGrid to equal the current values of the mouse grid
> { procedure Limithorz(minpos,maxpos : integer);}
method replaced by RestrictMove
> { procedure Limitvert(minpos,maxpos : integer);}
method replaced by RestrictMove
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 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 RestoreMove; {was RestoreYMove;}
Restores cursor movement to full screen.
Use after a call to RestrictMove.
> procedure RestrictMove(R : TRect); {was RestrictYMove;}
restricts cursor movement to the rectangle R
procedure SelectHourGlass;
if EnableHourGlass is true, cursor shape is set to the hourglass
procedure SelectStdCursor;
cursor shape is set to the arrow
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 to be on the new grid.
procedure SetSpeed(Mickx, Micky : integer);
set cursor movement speed (ratio of mickeys/pixel)
procedure Show;
shows the cursor TV's ShowMouse calls this method
procedure Hide;
hides the cursor TV's HideMouse calls this method
end;
------------------------
* = unique to TVGraphic
+ = calls Graph unit with exceptions noted
* MYGRAPH Unit
This unit traps some BGI calls before passing them to the Graph unit.
It also contains the TVGraphic bitmap fonts and their driver
plus various utility functions.
Fonts (To use your own bitmapped fonts see file FONTS.DOC.)
Unit contains the two pixel-clippable bit-mapped fonts used throughout
TVGraphic.
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 stroke 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 stroke fonts.
const {for graphics mode programs}
Charlen = 8; {width of a standard graphic char in pixels}
BoxHeight = 14; {height of the standard TVGraphic text line}
font numbers for TVGraphic clippable, bit-mapped Fonts
Font8x8 = 14; {8 by 8 pixels}
Font8x14 = 15; {8 by 14 - same size as text on EGA}
MouseFont = 16; {reserved}
BYOff8x8 = 4; {offset down into Boxheight to center 8x8 text}
BYOffSmallFont = 0; {offset down to center BGI SmallFont}
DefaultBYOff8x14 = 1;
{Change BYOff8x14 to 0 when using a European font from DOS code
page - Euro alpha chars are one pixel lower than US code page.}
BYOff8x14 : integer = DefaultBYOff8x14; {menus use CalcVertTextOffset}
{font dependent offset into Boxheight to center text vertically}
BYOffset : integer = 0;
The value of BYOffset is set by SetTextStyle to BYOff8x8, BYOff8x14
or BYOffSmallFont according to the selected font. (It is 0 for all
BGI fonts.) 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, WriteCStrXY or MyGraph.MoveTo and 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 ~ ~ is written in the highlight color. Can use
multiple pairs of ~ ~.
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 versions prior to 1.5}
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;
Driver function
+ function DetectVesa16: Integer; far;
from Borland's BGIDemo program. Used to detect presence of VESA
compatible video BIOS. Note that some VESA cards must have their
utility program run to enable or load the VESA BIOS on the card.
If this is not done, these cards will not be recognized as
VESA compatible.
This function is modified to always return 0 if VESA is detected.
This corresponds to the 16 color 800x600 mode which is supported
by TVGraphic. Returns grError if VESA not detected.
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.
If you have replaced Font8x14 with a font of a different
height, then returns height specified in font header - see FONT.DOC.
+ function TextWidth(TextString : string) : word;
uses character width of 8 for fonts Font8x8 and Font8x14
to calculate width. This includes replacement fonts.
The following BGI calls are also intercepted
Bar
Bar3d
OutText
OutTextXY
------------------------
ofXXXX constants
These correspond to bits in the TView.Options field.
ofVersion20 : all views have this bit set in TVGraphic 2.0.
ofFramed :
TV frame behavior:
TFrame draws frame for each window subview where this bit is set.
TVGraphic frame behavior:
Due to different redraw order in TVGraphic, TFrame may draw first
and therefore cannot draw frames for other (yet to be drawn) views.
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.
ofBuffered : buffers are not used in TVGraphic
------------------------
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
its sfActive bit 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 (the 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 TProgram.
Example:
TDemoApp is derived in each DEMO program (TVGDemo1, TinyDemo, etc.).
TDemoApp = object(TProgram)
only those methods that are of general interest are
listed here. See TDemoApp for code/descriptions.
constructor Init;
destructor Done;
procedure DosShell;
procedure GetEvent; hooks for Help windows
procedure HandleEvent;
procedure InitMenuBar;
procedure InitMessageBar; message that covers over the MenuBar
procedure InitStatusLine;
procedure InitToolBar;
procedure SaveDeskTop;
procedure LoadDeskTop;
procedure ShowHelp;
end;
------------------------
TBackground = object(TView) DeskTop background
Pattern - Not used.
In TVGraphic, TBackground obtains its fillstyle (texture) from the
background color of its palette entry.
The fillstyle passed to the BGI's SetFillStyle procedure is
(BackgroundColor mod 4 +8) for color value less than 8.
v2.0 : For 8 and above, fillstyle is set to solidfill which
gives a solid background.
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);
bfxxxx options in AFlags saved in Flags as usual.
does NOT set AmDefault
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 false:
draws text buttons similar to TV. Background is black if pressed.
when TextButtonsMatchBitMapButtons is true:
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 and there is more than one button
in the view, the outline of the selected button is dotted
using the background color of Text Normal.
An unselected button which is the default button has a
thicker dark border using the Shadow colors.
When the button is pressed, the background is XOR'd with $FF.
+ 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 unless global
ViewsRespondToMouseUp is true.
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.
Draws the button press if Hotkey is pressed or default button
is pressed. TV does not draw in these situations.
+ procedure MakeDefault(Enable: Boolean);
routine's code is commented out.
+ procedure Press(DrawIt : boolean); virtual;
parameter DrawIt added.
if DrawIt true, then draws button pressed then unpressed again.
Usual TV code/behavior.
+ 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 DrawView for the old and new Default buttons.
* 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.
background while pressed - see DrawState
button outline/shadow:
left and top = foreground color of entry 8
right and bottom = background color of entry 8
all text - same entries as TV
------------------------
PCheckBoxes = ^TCheckBoxes
TCheckBoxes = object(TCluster)
+ methods Mark, Press TV Bug fix for 16 box checkbox
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TCluster:
TV bug in handling nil strings in TCluster.DrawMultiBox is corrected.
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 ofFramed in Options
sets VFont := font8x8
+ constructor Load(var S: TStream);
TV Bug will set ofSelectable in Option field even if it
has been cleared in the stream object.
modified code
if (Options and ofSelectable <> 0) then
SetButtonState(0, True);
+ procedure MultiDrawBox(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
Following Methods are Private in TV.
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;
TColorDisplay = object(TView)
+ procedure DispSetColor(var AColor: Byte); virtual;
name of above procedure is SetColor in TV2.0. This conflicts
with Graph.SetColor so TV1.0 name is used for this method.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TDeskTop = object(TGroup) ALL methods listed
BackGround : PBackground;
TileColumnsFirst: Boolean; {new in TV2.0}
+ constructor Init(var Bounds: TRect);
Select alternative redraw algorithm
DrawFlags := dfAlternateRedraw;
+ constructor Load(var S : TStream);
if LoadVersion >= ofVersion20 then
S.Read(TileColumnsFirst, Sizeof(TileColumnsFirst));
else
DrawFlags := DrawFlags or dfAlternateRedraw;
+ procedure Cascade(var R: TRect);
use TVGraphic coords
call DrawView at end
+ procedure HandleEvent(var Event: TEvent); virtual;
cmPrev: put Current view in front of the foremost
non-selectable view. This is usually the Background.
procedure InitBackground; virtual;
procedure Store(var S : TStream);
procedure Tile(var R: TRect);
procedure TileError; virtual;
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TDialog = object(TWindow)
+ constructor Init(var Bounds: TRect; ATitle: TTitleStr);
{versions prior to v1.5 had an additional parameter after ATitle.
constructor is now identical to TV.}
Set any options in the VOptions field after construction.
see GDialog Unit section for options
sets Palette := DefaultDialogPalette;
sets Frame^.VOptions := tfDrawBackground;
which causes Dialog's Frame to draw a complete background
for the view.
+ constructor Load(var S: TStream);
if TV1.0 Dialog on the Stream,
sets Palette := DefaultDialogPalette;
* 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.Options 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;
In v1.5, method was modified to return an altered palette if dialog
is non-modal and dialog's Owner has a palette.
In v2.0, the Window palettes are extended to duplicate dialog
palettes and this method is identical to Turbo Vision 2.0.
+ procedure HandleEvent(var Event: TEvent); virtual;
When a modal dialog receives a right mouse button event, it
issues cmCancel to close itself (unless AllowBothMButtons
is true). This is the standard TVGraphic behavior.
If (VOptions and dgReturnOnAnyButton <> 0) then dialog
calls EndModal for ANY Event.Command. This closes the dialog and
returns the Command as the result of Execute/ExecuteDialog.
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
NOTE on TFrame
The VOptions tfDrawBackground flag controls whether the Frame draws
a complete background for the window. This flag is set automatically
in TDialog.Init but NOT in TWindow.Init. For windows, if you do not
fill up the area inside the Frame completely with view(s), then set
the flag. There will be less flicker when drawing if it is not set.
Drawing Outlines of views:
TVGraphic TFrames do not draw outlines of other views. This is due
to the different order of drawing views in TVGraphic. Many TVGraphic
views draw their own outlines if their ofFramed Options flag is set.
TFrame = object(TView) ALL methods listed
+ constructor Init(var Bounds: TRect);
VFont is set to Font8x8. TFrame assumes this size font is used.
DrawFlags := DrawFlags and not dfPanning;
* constructor Load(var S: TStream);
clear dfPanning flag in DrawFlags if LoadVersion = ofVersion10
+ 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 State sfDragging flag or
the VOptions tfDrawBackground flag is set. Uses the background
color of the palette's Active Frame entry.
Otherwise checks VOptions flags tfVScrollBar and tfHScrollBar
(set by TWindow.StandardScrollBar) and draws background under
the standard scrollbar positions for each flag set.
Also checks VOptions tfMarginsForText. If set, draws background
in the extra margin area.
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
whose 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;
v2.02 uses revised TView.Exposed that tests dfPanning flag}
* procedure GetInteriorSize(var R: TRect; MarginsForText: boolean);
virtual;
{MarginsForText added v2.0}
Usually called through TWindow.GetMaxSubViewSize, not directly.
Returns in R the size of the rectangle inside the frame that you
should fill with view(s). If MarginsForText is true, then the
margin from R to the frame's left and right edges will be a
multiple of Charlen - for use with text based views, similar
spacing to Turbo Vision. Otherwise R extends up to inner frame
border line - this was the default in v1.5 and earlier.
Sets and clears the tfMarginsForText flag in VOptions field
based on parameter MarginsForText.
The size of R also reflects whether the VOptions 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 VOptions
field, it will fill this area R with the TFrame background color.
function GetPalette: PPalette; virtual;
+ procedure HandleEvent(var Event: TEvent); virtual;
Handles mouse events.
If the NextWindow button is pressed, issues a command event
with Event.Command := cmNext to advance to next window.
If Close Icon is pressed and Frames's Owner has a pull down
menu, then has its Owner ExecView the menu. When menu closes,
does a PutEvent of the menu command. If no menu then issues
cmClose as usual.
Otherwise emulates TV.
{* procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
v2.02 uses revised TView.MakeLocal that tests dfPanning flag}
+ procedure SetState(AState: Word; Enable: Boolean); virtual;
Calls DrawView when setting sfDragging.
If changing sfActive or leaving sfDragging,
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.
See section on TGroup.Load in main doc file.
! 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 crash!
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.
After loading, does not call Awaken function if LowMemory.
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);
call to DrawView when Size does not change is deleted.
+ 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 field.
* 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 around.
+ 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 as usual
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
such as TPanWindow that shift or Pan the screen.
+ procedure Unlock;
if the LockFlag > 0 then decrements the LockFlag as usual.
Does not make any drawing calls! {DrawView not called}
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 in this order only if group's DrawFlag
dfAlternateRedraw is set. Otherwise draws subviews from Last
to First.
+ procedure FreeBuffer;
returns with no action
+ procedure GetBuffer;
returns with no action
* procedure ResetCurrentDrawLater;
variant of ResetCurrent
* procedure ResetCurrentEraseLater;
variant of ResetCurrent
+ procedure ResetCursor(Eraseit : boolean); virtual;
returns with no action
+ procedure SetCurrent(P: PView; Mode: SelectMode);
does not call Lock and UnLock.
handles new values of Mode parameter
end;
------------------------
+ = emulates TV with exceptions noted
PHistoryViewer = ^THistoryViewer;
THistoryViewer = object(TListViewer)
+ constructor Init(var Bounds: TRect;
AHScrollBar, AVScrollBar: PScrollBar; AHistoryId: Word);
XSize := (Size.x+1) div Charlen;
HScrollBar^.SetRange(1, HistoryWidth-XSize + 2{3});
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
PHistoryWindow = ^THistoryWindow;
THistoryWindow = object(TWindow)
* procedure HandleEvent(var Event : TEvent); virtual;
if not AllowBothMButtons and view is modal and a right
mouse button press, then converts the Event to a Command
event with cmCancel. This will close the window.
Calls TWindow.HandleEvent.
+ procedure InitViewer(HistoryId: Word); virtual;
rewritten so can use Window's GetMaxSubViewSize(R, false) to
size the viewer. Same end result as TV.
Palette
+ CHistoryWindow = #19#19#19#24#25#26#27;
Third entry was #21, now #19. Used for Frame Icon.
The last two entries are for HistoryViewer Selected and Normal
text. They have been changed from pointing to TgInputLine
entries to pointing to TListViewer entries.
------------------------
+ = emulates TV with exceptions noted
PHistory = ^THistory;
THistory = object(TView)
+ constructor Init(var Bounds: TRect; ALink: PgInputLine;
AHistoryId: Word);
VFont := font8x14;
+ procedure HandleEvent(var Event: TEvent); virtual;
position HistoryWindow so user can see the label of the InputLine
------------------------
* = unique to TVGraphic
button with .BMP bitmap face unit GBUT
* PIconButton = ^TIconButton;
* TIconButton = Object(TButton)
see file BITMAP.DOC for full detail
------------------------
+ = emulates TV with exceptions noted
PgInputLine = ^TgInputLine TV's TInputLine
TgInputLine = object(TView)
+ constructor Init(var Bounds: TRect; AMaxLen: Integer; Opts : byte);
Opts parameter added
DefaultOpts DefaultOpts matches TV
KillInstantErase prevent first keystroke from erasing
lnRightJustify right justify the inputline
Note: right justified line may not exceed width of view:
AMaxLen <= ((Size.x+1) div Charlen) - 2
VOptions := Opts;
EventMask := EventMask + evTimerTick;
Vfont := DefaultDialogFont;
+ procedure Draw; virtual;
rewritten
+ procedure HandleEvent(var Event: TEvent); virtual;
Ctrl-Del deletes line
if KillInstantErase set in VOptions, then
first keystroke does not erase focused/highlighted line.
handles right justified input lines.
+ procedure SelectAll(Enable: Boolean);
if KillInstantErase, positions cursor at end of selected block
+ function Valid(Command: Word): Boolean; virtual;
for non-registered versions of TVGraphic, warns that Validators
are not active.
private
* function RightJustify: integer;
returns the number of spaces to push text to the right.
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
text - uses entries 1-2. (If selected uses entry 2, not 3.)
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
PgLabel = ^TgLabel TV's TLabel
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 StaticTextOffset. 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
TgInputline, for example, and then later reuse the width
of Bounds for setting another matching TgInputLine.
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 by StaticTextOffset pixels from left edge of view,
value was 4 up to v2.0, 0 for v2.02 and up (matches TurboVision).
If Options has ofFramed set, then draws frame around itself.
end;
------------------------
For TgMenu object see section following TMenuView
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TListBox = object(TListViewer)
+ function GetText();
returns empty string if nil pointer in the List
+ procedure NewList(AList: PCollection); virtual;
modified to use Lock, UpDate(uvDrawView), UnLock
instead of calling DrawView directly
+ procedure SetData(var Rec); virtual;
modified to use Lock, UpDate(uvDrawView), UnLock
instead of calling DrawView directly
end;
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TListViewer = object(TView) ALL methods listed
HScrollBar: PScrollBar;
VScrollBar: PScrollBar;
NumCols: Integer;
TopItem: Integer;
Focused: Integer;
Range: Integer;
+ constructor Init(var Bounds: TRect; ANumCols: Word;
AHScrollBar, AVScrollBar: PScrollBar);
VFont := DefaultListViewerFont
constructor Load(var S: TStream);
procedure ChangeBounds(var Bounds: TRect); virtual;
+ procedure Draw; virtual;
Draws the complete view or just the previous and
new Focused items depending on boolean PartialRedraw.
Sets OldFocused := Focused, OldTopItem := TopItem.
* procedure DrawSelf;
decides whether partial or complete redraw of the view
is needed using UpdateFlags and OldTopItem. Sets boolean
PartialRedraw and calls DrawView.
Then sets UpdateFlags = 0 and PartialRedraw to false.
function GetPalette: PPalette; virtual;
function GetText(Item: Integer; MaxLen: Integer): String; virtual;
function IsSelected(Item: Integer): Boolean; virtual;
+ procedure HandleEvent(var Event: TEvent); virtual;
Same functionality as TV but uses Lock,UnLock,Update drawing
control methods instead of calling DrawView.
procedure SelectItem(Item: Integer); virtual;
procedure SetRange(ARange: Integer);
+ procedure SetState(AState: Word; Enable: Boolean); virtual;
Calls TView.SetState then
if AState is sfSelected or sfActive, calls UpDate(uvFocused).
Does not talk to or affect scrollbars.
procedure Store(var S: TStream);
* procedure Lock;
drawing control - Inc(LockCount);
* procedure Unlock;
drawing control - decrements LockCount and calls
DrawSelf if LockCount = 0.
* procedure UpDate(AFlags: Byte);
UpDateFlags := UpdateFlags or AFlags.
If LockCount = 0 then calls DrawSelf.
private
* LockCount: Byte;
* UpdateFlags: Byte;
* PartialRedraw : boolean; {temp var}
* OldFocused : integer; {temp variable, used with partial redraws}
* OldTopItem : integer; {temp variable, used with partial redraws}
procedure FocusItemNum(Item: Integer); virtual;
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
Menus are some the most convoluted code in TV.
The Execute method does most of the work. Unless you have
source code, don't expect to understand or modify.
PMenuView = ^TMenuView;
TMenuView = object(TView) ALL methods listed
ParentMenu: PMenuView;
Menu: PMenu;
Current: PMenuItem;
* Target : PMenuView; {temp var, pointer to child menu, nil if none}
constructor Init(var Bounds: TRect);
constructor Load(var S: TStream);
+ function Execute: Word; virtual;
heavily modified
function FindItem(Ch: Char): PMenuItem;
procedure GetItemRect(Item: PMenuItem; var R: TRect); virtual;
function GetHelpCtx: Word; virtual;
function GetPalette: PPalette; virtual;
+ procedure HandleEvent(var Event: TEvent); virtual;
added ability to snap mouse cursor to grid in BoxMenus if
MouseSnapToMenuGrid 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 HotKey(KeyCode: Word): PMenuItem;
+ function NewSubView(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView): PMenuView; virtual;
code commented out - moved to TGMenu
procedure Store(var S: TStream);
private
* OldCurrent : PMenuItem; {temp var, used in redrawing}
* DrawPartial : boolean; {temp var, used in redrawing}
end;
* PGMenu = ^TGMenu; {Ancestor of graphical menus}
* TGMenu = object(TMenuView) ALL methods listed
Xsep : integer;
number of char spaces (not pixels) between bar menu items.
constructor Init(var Bounds : TRect; AMenu : PMenu);
constructor Load(var S: TStream);
procedure FillWindow(BorderColor,AColor : integer;FatBorder : boolean);
draws a Bar3d the size of the menu with border
function NewSubView(var Bounds: TRect; AMenu: PMenu;
AParentMenu: PMenuView): PMenuView; virtual;
code moved here from TMenuView.NewSubView
procedure Store(var S: TStream);
end;
PMenuBar = ^TMenuBar; {TV's Bar Menu}
TMenuBar = object(TGMenu) ALL methods listed
+ Constructor Init(var Bounds : TRect; AMenu : PMenu);
Adjusts Bounds using global MenuBarHeight
Bounds.B.Y := Bounds.A.y + MenuBarHeight -1;
legend separation Xsep - if there are few enough entries,
the separation between menu items will be set at 3 spaces,
otherwise to BarMenuLegendOffset (2) as in TV.
VFont := DefaultMenuFont;
destructor Done; virtual; {new in TV2.0}
procedure Draw; virtual;
if the Viewport does not overlap any portion of menu, then
sets the ViewPort before drawing and restores it afterwards.
+ procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
end;
PMenuBox = ^TMenuBox; {TV's Box menu}
TMenuBox = object(TGMenu) ALL methods listed
* 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;
* constructor Load(var S: TStream);
* destructor Done; virtual; {new in TVGraphic 2.0}
fix TV bug by disposing Menu list for standalone menus
(for menus where ParentMenu = nil)
+ procedure Draw; virtual;
draws fat border if mnFatBorder is set in VOptions
+ procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
* procedure Store(var S: TStream);
end;
PMenuPopup = ^TMenuPopup; {TV's Popup Menu}
TMenuPopup = object(TMenuBox) ALL methods listed
+ constructor Init(var Bounds: TRect; AMenu: PMenu);
sets mnFatBorder in VOptions
procedure HandleEvent(var Event: TEvent); virtual;
end;
{for use in TWindow}
* PWindowMenu = ^TWindowMenu; ALL methods listed
* TWindowMenu = object(TMenuPopup)
constructor Init(AMenu: PMenu);
sets the Bounds to place the menu under the window's Close Icon.
calls TMenuPopup.Init
sets mnCloseOnDouble in VOptions.
function GetPalette: PPalette; virtual;
uses CWindowMenu palette
end;
Menu Palette (TV's CMenuView) - used by all menus except TWindowMenu
CMenuView = #2#3#4#5#6#7;
+ menu background color uses background of entry 1
+ menu border color uses background of entry 3
text - same as TV
+ CWindowMenu = #128#129#130#131#132#133;
maps thru extended TWindow palettes which duplicate
CMenuView at entries 128-133
------------------------
* = unique to TVGraphic
Unit GMenu
TVGraphic view for temporarily displaying instructions at
top edge of screen - covers MenuBar while visible.
* PMessageBar= ^TMessageBar;
* TMessageBar = object(TView)
MessageText : Str80; {temp var, not saved}
constructor Init;
View's Bounds are set so it will cover the MenuBar
State := State and not sfVisible; {set invisible!}
EventMask handles broadcast events.
VFont := DefaultMenuFont;
procedure Busy;
shows message 'WORKING...'
procedure Draw; virtual;
uses separate color to draw text enclosed with ~ ~ .
see palette below for text colors.
function GetPalette : PPalette; virtual;
returns CMenuView palette {starting in TVGraphic v2.0}
procedure HandleEvent(var Event : TEvent); virtual;
responds to any cmCancel or mouse button presses 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.
end;
MessageBar Palette = CMenuView
background drawn in background color of entry 1
outline uses background of entry 3
normal text uses foreground of entry 4
highlighted text uses foreground of entry 6
------------------------
PMultiCheckBoxes = ^TMultiCheckBoxes;
TMultiCheckBoxes = object(TCluster) unmodified
------------------------
* = unique to TVGraphic
Note on TPanWindow (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.
> To use Panning
{v2.02 significant changes to panning
methods SetMode and Mode added,
method CurAtEdge details have changed.}
In Event loops, pass the event to function CurAtEdge. If it returns
true then call ShiftScreen which shifts and redraws the screen.
If TPanWindow's Mode = NormalMode {=0} AND CurAtEdge's parameter
AllowMenuAccess is true, then window pans automatically
at left and right edges but requires mouse click at top and bottom
of screen. Otherwise the window pans automatically at all its edges.
This allows drawing or dragging with the mouse cursor over the
window's entire Interior.
Call SetMode(AMode) to change/set the mode. SetMode restricts mouse
movement to within Window's boundary if Mode <> NormalMode.
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. Select with F6 or the window's
number button.
TPanWindow requires a MenuBar but not a StatusLine.
The selected TPanWindow receives evCommand Events from the
application's 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. Your application must create
a ShiftView and a MessageBar. See TVGDemo1.PAS)
Sizing the PanWindow's Interior
When the mouse cursor is on a grid greater than one pixel,
use the following rules to avoid offset from grid after
the window pans:
Make the TPanWindow.ScrnShiftSize (set in the constructor)
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}
Important Note:
TVGraphic's boolean AllowBothMButtons must be false
for TShiftView to operate correctly. See note at TShiftView.
* PPanWindow = ^TPanWindow;
* TPanWindow = object(TWindow)
InteriorSize : TPoint; {size of interior in pixels}
> now private Mode : byte; {initialized to 0 = NormalMode}
use function Mode to read, method SetMode to set.
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
Select top down redraw algorithm
DrawFlags := DrawFlags or dfAlternateRedraw;;
constructor Load(var S : TStream);
loads the view from a stream, then sets dfAlternateRedraw
in DrawFlags if LoadVersion = ofVersion10.
> function CurAtEdge(Event : TEvent; var Delta : TPoint;
AllowMenuAccess : boolean) : boolean; virtual;
Note: function completely rewritten for v2.02.
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.
Sets Delta with number of pixels to pan by. This will
be either the +-X or +-Y value of ScrnShiftSize. (If the
Interior is closer than ScrnShiftSize to its edge, Delta
will be set with number of pixels needed to pan to the edge.)
MouseMove Events
If Mode = NormalMode {=0} and AllowMenuAccess is true,
then CurAtEdge returns true if mouse cursor is in the window
and within one mouse grid division of the left or right edge
of the window. If no StatusLine, then true within one mouse
grid of bottom also.
If Mode <> NormalMode or AllowMenuAccess is false,
then returns true if mouse cursor is inside and within one
grid of any edge of the window, or if outside window.
Note: A mouse grid may be 1 pixel or larger.
Note that the detection point at the right side of the
screen is four pixels in for a window that fills the DeskTop.
Command Events
Responds to commands cmShiftScreenDown and cmShiftScreenUp
from the hidden ShiftView in the application.
Returns true if screen can shift in direction of
the command.
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 Mode : byte;
Returns Mode value. Use SetMode to set Mode. NormalMode = 0.
procedure SetMode(AMode : byte); virtual;
Sets the Mode. SetMode will retrict the mouse cursor
to the bounds of the view if Mode <> NormalMode. If called
with NormalMode , then restores the mouse travel to full screen.
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.
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.
Always returns true.
procedure ShiftViewUpdate;
Creates a Broadcast Event where Event.Command =
cmScreenShifted and calls ShiftViewPtr^.HandleEvent;
procedure Store(var S : TStream);
stores the view to a stream
end;
------------------------
+ = emulates TV with exceptions noted
PgParamText = ^TgParamText TV's TParemText
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
TProgram = object(TGroup) ALL methods listed
+ constructor Init;
call order changed,
call InitDeskTop after InitStatusLine,InitMenuBar.
initialize mouse cursor.
set Viewport to size of DeskTop if it exists,
otherwise full screen.
Select alternative redraw algorithm
DrawFlags := dfAlternateRedraw;
+ destructor Done; virtual;
added call to MCur.Done
function CanMoveFocus: Boolean;
procedure Cascade; from TV's TApplication
function ExecuteDialog(P: PDialog; Data: Pointer): Word;
procedure GetEvent(var Event: TEvent); virtual;
If event is Mouse event, update MCur position.
If there are no pending,mouse or key events, see if there is
a TimerTick event. If so, distribute it by calling HandleEvent,
otherwise call Idle.
function GetPalette: PPalette; virtual;
procedure GetTileRect(var R: TRect); virtual; from TV's TApplication
procedure HandleEvent(var Event: TEvent); virtual;
procedure Idle; virtual;
+ procedure InitDeskTop; virtual;
Sizes DeskTop to fill space between the MenuBar and the StatusLine
if they exist. Otherwise fills screen.
User does not have to have a MenuBar or StatusLine.
procedure InitMenuBar; virtual;
default menu reminds you to override this method.
procedure InitScreen; virtual;
+ procedure InitStatusLine; virtual;
sets vertical size to MenuBoxheight. Usually overridden.
function InsertWindow(P: PWindow): PWindow;
+ procedure OutOfMemory; virtual;
calls procedure LowMemMsgBox; {Out of memory Messagebox}
procedure PutEvent(var Event: TEvent); virtual;
procedure Run; virtual;
* procedure SetPalette(Pal : TPalette);
replaces the Application palette (the colors) for the
current screen mode (color, black and white) with palette Pal
! procedure SetScreenMode(Mode: Word);
set text screen mode - NOT DEFINED in TVGraphic
procedure Tile; from TV's TApplication
function ValidView(P: PView): PView;
end;
------------------------
PRadioButtons = ^TRadioButtons; unmodified
TRadioButtons = object(TCluster)
------------------------
+ = 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
NOTE on TScrollBar
With v2.02 the scrollbars have changed.
They now draw buttons for the indicator and control arrows.
All Application palette entries for Scrollbar indicator/arrows
have been changed from cyan on blue to black on light gray.
Scrollbars can now position the indicator at any point along
the bar, rather than only at text coordinates as before.
Note: If you have chosen to use a text based (8x14) mouse grid
for your DeskTop or Dialogs, you should set the following
variable true in your TApplication.Init:
AlignVScrollBarsWithGrid : boolean = false;
This matches vertical scrollbar indicator travel to a vertical
mouse grid of 14 pixels.
TScrollBar = object(TView) ALL methods listed
Value: Integer;
Min: Integer;
Max: Integer;
PgStep: Integer;
ArStep: Integer;
+ 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 constants
HScrollBarWidth or VScrollBarWidth independent of Bounds.
The actual thickness of the Scrollbar is the constant plus
one pixel.
Refer to TV documentation for the rest.
VFont is set to Font8x8. Do not change this.
OldPos is set to the value of function GetPos.
DrawFlags := DrawFlags and not dfPanning;
+ constructor Load(var S: TStream);
OldPos := GetPos;
clear dfPanning flag in DrawFlags if LoadVersion = ofVersion10
procedure Draw; virtual; unchanged
{* function Exposed : boolean; virtual;
v2.02 uses revised TView.Exposed that tests dfPanning flag}
function GetPalette: PPalette; virtual;
+ procedure HandleEvent(var Event: TEvent); virtual;
same functionality as TV except forces a redraw
after user moves indicator with mouse. This fixes TV bug.
{* procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
v2.02 uses revised TView.MakeLocal that tests dfPanning flag}
procedure ScrollDraw; virtual;
function ScrollStep(Part: Integer): Integer; virtual;
+ procedure SetParams(AValue, AMin, AMax, APgStep, AArStep: Integer);
redraws if FullDraw is true, otherwise limits redrawing
procedure SetRange(AMin, AMax: Integer);
* procedure SetState(AState: Word; Enable: Boolean); virtual;
calls TView.SetState and then calls DrawView if AState=sfActive.
Note that this means a scrollbar changes its sfActive State
independently and DOES NOT require a TScroller or TListViewer
view be present.
procedure SetStep(APgStep, AArStep: Integer);
procedure SetValue(AValue: Integer);
procedure Store(var S: TStream);
private
Chars: TScrollChars;
* PartialRedraw, FullDraw : boolean;
* OldPos : integer;
+ procedure DrawPos(Pos: Integer);
does the actual drawing, modified for graphics.
Draws only the scrollbar background if not Active.
+ function GetPos: Integer;
+ function GetSize: Integer;
* function IndicatorSize : integer;
if vertical bar, returns Indicator height, else Indicator width
end;
+ ScrollBar Palette
overall background is drawn in background of entry 1
indicators and arrows - same as TV
outline and shadow of indicator and arrow buttons is fixed.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TScroller = object(TView) ALL methods listed
HScrollBar: PScrollBar;
VScrollBar: PScrollBar;
Delta: TPoint;
Limit: TPoint;
* Spacing : TPoint; READ only {new v2.0}
contains the number of pixels the view will scroll/step by.
Use SetLimit to set this field.
> * DrawBackgroundByLines : boolean; {new v2.02}
can use in .Draw - see TVGDemo1. CheckDraw sets false if view
has scrolled vertically by more than one step, true otherwise.
* PartialRedraw : boolean;
can use in .Draw, CheckDraw sets true if view has not scrolled.
+ constructor Init(var Bounds: TRect;
AHScrollBar, AVScrollBar: PScrollBar);
Set Spacing to 1,1 to prevent divide by zero error if SetLimit
is not called. Always call SetLimit after construction.
+ constructor Load(var S: TStream);
if LoadVersion >= ofVersion20 then loads Spacing,
otherwise sets Spacing to default values
Spacing.x := Charlen; Spacing.y := Boxheight;
+ procedure ChangeBounds(var Bounds: TRect); virtual;
does NOT redraw the view
> procedure Draw Defined in descendants of TScroller.
See TMyScroller.Draw in main demo program TVGDemo1.Pas.
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
* procedure PartOfSetLimit(X, Y :integer); virtual;
PartOfSetLimit was introduced in v1.5 - user had to override.
It is no longer necessary or recommended to override this method.
Scroll step size is now set with SetLimit's added parameters
XSpacing and YSpacing.
Method sets Limit field to X,Y and calls SetParams for vertical
and horizontal scrollbars, if present. Uses values stored
in Spacing to set scrollbars.
+ procedure ScrollDraw; virtual;
if view has scrolled vertically by more than one line then
UpDate(uvDrawView), else UpDate(uvDrawByLines).
+ procedure ScrollTo(X, Y: Integer);
{procedure SetLimit(X, Y: Integer); TV version}
+ procedure SetLimit(X, Y: Integer; XSpacing, YSpacing : byte);
Sets Spacing.x := XSpacing; Spacing.y := YSpacing;
and then calls PartOfSetLimit(X,Y);
Call this method before using a TScroller or descendant.
For a text based scroller using Font8x14, use constants
Charlen and Boxheight for parameters XSpacing,YSpacing.
+ procedure SetState(AState: Word; Enable: Boolean); virtual;
Only calls TView.SetState. Does not have any affect on
scrollbars pointed to by fields HScrollBar or VScrollBar.
See TVGraphic's TScrollBar.SetState
+ procedure Store(var S: TStream);
also stores Spacing field
* procedure Lock;
drawing control - Inc(LockCount);
* procedure Unlock;
drawing control - decrements LockCount and calls
CheckDraw if LockCount = 0.
* procedure UpDate(AFlags: Byte);
ors AFlags with UpdateFlags. Calls CheckDraw if LockCount = 0.
private
* LockCount: Byte;
* UpdateFlags: Byte;
{DrawLock: Byte; deleted}
{DrawFlag: Boolean; deleted}
+ procedure CheckDraw;
sets/clears DrawBackgroundByLines and PartialRedraw based on
UpDateFlags, calls DrawView then sets UpdateFlags = 0.
end;
------------------------
* = unique to TVGraphic
TShiftView, Unit GWindow
Special view for sensing mouse position at top edge of the
screen and within the StatusLine, if one exists.
If mouse cursor enters these areas and the selected window is a
TPanWindow whose interior can shift {pan}, then Shiftview uses
the MessageBar to display a message about panning to the user.
If the right button is clicked in these areas, ShiftView issues
commands targeted at TPanWindow.HandleEvent. 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 can also respond to arrow keys - see HandleEvent.
ShiftView uses the MessageBar to display its messages -
so your application must initialize the MessageBar.
Important Note: TShiftView needs to respond to right mouse button
while the mouse cursor is within the StatusLine. This is not
compatible with standard TV behavior which has the StatusLine
respond to the right button.
TVGraphic's boolean AllowBothMButtons (unit GViews) must be false
to prevent the StatusLine from responding to the right button.
This will also prevent other views from responding to the right
button. This is the default behavior in TVGraphic and the Pascal IDE.
* 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 which sets the boolean 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.
Behavior below occurs only if screen can shift/pan.
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
evMouseDown and left button
clears the pan message.
KeyEvents
{useful if you remap the arrow keys to mouse cursor movement}
evKeyDown
if up/down arrow key and cursor at top or in StatusLine
then displays message 'PRESS ESC TO PAN SCREEN'.
if message is displayed and key is ESC,
then issues a evCommand event with either
Command = cmShiftScreenDown or cmShiftScreenUp
Uses the MessageBar to display its messages.
constructor Load(var S : TStream);
procedure Store(var S : TStream);
end;
------------------------
+ = emulates TV with exceptions noted
TSortedListBox
+ There is a flag to force a restart of the alphabetical search
whenever the view regains the Focus. See GSTDDLG heading.
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
Note on TStaticText
For maximum speed and minimum flicker, StaticText
does not normally draw its own background in Dialogs (its
DrawFlag dfTransparent causes the view under the text to
provide the background).
It does draw one if its Owner's DrawFlag dfAlternateRedraw
is set (DeskTop,TPanWindow, TApplication).
PgStaticText = ^TgStaticText TV's TStaticText
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 AText will fit (on one line) 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 AText will fit (on one line) in the view's Bounds
adjusts Bounds.B.x to just contain AText.
Takes StaticTextOffset into account.
Works with any font.
> txDrawBackground - Force view to draw its background.
With v2.02 this flag is not necessary.
StaticText background is drawn automatically if needed.
See "Note on StaticText" above.
* 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.)
> * DrawFlags := DrawFlags or dfTransparent; set since view does not
draw its own background in default redraw algorithm. v2.02
String Formating
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.
Background drawing - see "Note on StaticText" above.
> Text is indented by StaticTextOffset pixels from left edge of view,
value was 4 up to v2.02, 0 for v2.02 and up (matches TurboVision).
If Options has ofFramed set, then draws frame around itself.
String Formating - see notes under .Init
end;
------------------------
* = unique to TVGraphic
simple view for .BMP format bitmap unit GBUT
* PStaticBitMap = ^TStaticBitMap;
* TStaticBitMap = object(TView)
see file BITMAP.DOC for full detail
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TStatusLine = object(TView) {TV's StatusLine}
+ 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 unless
AllowBothMButtons is true. This pass through is required for
panning if using a TPanWindow in your program.
NOTE: when the StatusLine issues a command Event due to keypresses
or 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
TSubWindow, 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. This is identified as follows:
v1.5: Owner^.VOptions and twIsWindow <> 0
v2.0: Owner^.DrawFlags and dfIsWindow <> 0.
In these cases, GetPalette returns nil.
end;
------------------------
* = unique to TVGraphic
toolbar for bitmap buttons (TIconButton) unit GBUT
* PToolBar = ^TToolBar;
* TToolBar = object(TDialog)
see file BITMAP.DOC for full detail
------------------------
* = unique to TVGraphic
+ = emulates TV with exceptions noted
TUnSortedStringCollection, 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
see also unit GViews section
TView = object(TObject)
* Hook : TUserRec; not used by TVGraphic - use in your program
* VColor : word; color pair(s) if overriding palette selection
* VFont : byte; for text font storage
* VOptions : byte; TVGraphic options field-bits redefined in each view
* VOffset : TPoint; READ ONLY - use SetVOffset to set
{used to offset the screen across a graphical
view that is larger then the screen.
Used by MakeLocal,MakeGlobal,Exposed}
* ZoomLevel : byte; {reserved by TVGraphic}
* DrawFlags : byte; added v2.0, controls drawing properties of view
+ constructor TView.Init(var Bounds: TRect);
Options := Options or ofVersion20;
DrawFlags := dfPanning;
indicates view should pan with its Owner's Interior
+ constructor Load(var S: TStream);
loads added fields except DrawFlags
sets global variable LoadVersion to (Options or ofVersion).
{LoadVersion is referenced by descendant .Loads.}
if ofVersion > ofVersion10, then loads DrawFlags
else sets DrawFlags := dfPanning;
Options := Options or ofVersion20;
+ destructor Done; virtual;
disposes of text cursor memory if allocated.
* procedure AllocateCursorMemory; virtual;
allocates memory for text cursor. Do not call directly.
* function BackColor(Color: Word): byte;
Expects Color to be a color pair or quad returned by GetColor.
returns bits 4-7 of Color in lower 4 bits of the byte.
See ForeColor.
! + 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);
Hide cursor while dragging, calls DrawView after dragging.
When using arrow keys to move or change size of view, the size
of the move or change is based on size of the current mouse grid.
+ procedure Draw; virtual;
does nothing
* procedure DrawCursorNow;
rarely needed. forces text cursor to redraw immediately.
+ procedure DrawView;
calls ResetCursor(true) before calling Draw.
+ 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.
{Takes view's dfPanning flag in DrawFlags into account when
calculating the intersection with Owner^.Clip}
* function ForeColor(Color: Word): byte;
Expects Color to be a color pair or quad returned by GetColor.
returns bits 0-3 of Color in lower 4 bits of the byte.
See BackColor.
+ procedure GetClipRect(var Clip: TRect);
returns Clip in local coordinates, modified to work with VOffset.
* procedure GetScreenCoords(var R : TRect);
Sets R to the absolute screen coords of the outline of the view.
(same coord system as the 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 BGI Viewport to match
the outline of the view.
* procedure GetVPRelCoords(var R : TRect);
Sets R to the outline of the view in ViewPort relative coords.
(view's Origin in R.A and its lower right corner in R.B)
Example: Passing R obtained with this method to the BGI Rectangle
call will draw a rectangle outlining the view. This rectangle
will not move on screen as the Viewport's origin moves.
ALWAYS IN EVERY DRAW METHOD: add R.A.x, R.A.y to the view's
local x,y coords of every line, circle, text, etc., then pass the
sum to the BGI drawing function! This is critical since TVGraphic
changes the Viewport as it redraws.
If the Viewport is set to full screen, GetVPRelCoords returns
the same values as GetScreenCoords.
+ procedure HandleEvent(var Event: TEvent);
handles evTimerTick to blink the text cursor and controls
mouse button behavior. Otherwise same as TV2.0
procedure HideCursor;
same code as TV but the effect is to erase the blinking
cursor And Restore the Background Underneath It.
See also ResetCursor.
* function HorzTextOffset : integer; virtual;
returns 0. Used by ResetCursor to position text cursor.
Override in descendants that use the text cursor if view's text
is offset horizontally.
+ procedure Locate(var Bounds: TRect);
Changes the bounds of view to Bounds as in TV. Major design
changes in way view is redrawn.
+ procedure MakeGlobal(Source: TPoint; var Dest: TPoint);
rewritten, v2.02 modified to ignore Self.VOffset.
coordinate transformation Source to Dest.
Source should be in view's local coordinate system.
Dest is in absolute screen coords (mouse coords).
{Takes VOffset of all Owners in the view chain into account
unless view's dfPanning flag in DrawFlags is cleared. Then
ignores VOffset of direct Owner so Dest (and view) won't pan with
Owner's Interior.}
* procedure MakeInteriorGlobal(Source: TPoint; var Dest: TPoint);
new v2.02 - functions as MakeGlobal did prior to v2.02.
Use if view is a descendent of TGroup, you are setting view's
VOffset AND you want to transform coordinate points
of the view's Interior to absolute screen coords.
(If VOffset = 0,0 then local and Interior coords match
and procedure gives same results as MakeGlobal.)
+ 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, not of the view's Interior.
{Takes VOffset of all Owners in the view chain into account
unless view's dfPanning flag in DrawFlags is cleared. Then
ignores VOffset of direct Owner so Dest (and view) won't pan with
Owner's Interior.}
* procedure MakeLocalToInterior(Source: TPoint; var Dest: TPoint);
new v2.02
Use if view is a descendent of TGroup, you are setting view's
VOffset AND you want to transform absolute screen coords to
coordinate points of the view's Interior.
(If VOffset = 0,0 then local and Interior coords match
and procedure gives same results as MakeLocal.)
+ function MouseInView(Mouse: TPoint): Boolean; virtual;
made virtual;
+ procedure PutInFrontOf(Target: PView);
rewritten to work with graphic drawing
* procedure ResetCursor(EraseIt : boolean); virtual;
{TV private method, made public and virtual.
Parameter EraseIt added in ver 1.5.
Prior to ver1.5, method performed no action in TVGraphic.}
Erases and Draws standard TV/TVGraphic blinking text cursor.
NOTE - Text Cursor will not draw unless view's EventMask
includes evTimerTick.
You do not need to call this method except in case discussed next:
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 SetCursor just before drawing.
This will erase the cursor at its present location and
cause it to save the background under itself when it draws next.
(It will draw at the next evTimerTick event if the view
is focused.)
calls new virtual functions VertTextOffset and VertTextSpacing
to know how to position cursor vertically on screen.
calls new HorzTextOffset to help position itself horizontally.
Looks at the font name stored in VFont to determine the
vertical and horizontal size of the font you are using.
Will not work with proportional fonts.
+ 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. Does not respond to sfShadow.
* procedure SetViewPortToView(var SavedVP : ViewPortType);
USE Only with views in the DeskTop.
returns current Viewport values in SavedVP, then resets Viewport
to cover the intersection of this view and the current Viewport.
+ 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;
Used by ResetCursor to position text cursor.
Temporarily sets BGI TextStyle to font stored in field VFont,
calls CalcVertTextOffset(VertTextSpacing) to find value to
return, and restores previous font.
For font8x8 and font8x14 used with VertTextSpacing = Boxheight,
VertTextOffset returns the same value as global ByOffset.
Override if you need a different vertical offset for the cursor.
* function VertTextSpacing : integer; virtual;
returns constant Boxheight.
Used by ResetCursor to position text cursor.
Override if your view's vertical text spacing differs from
Boxheight and you want cursor to match.
*Following text based 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
All the private methods concern drawing and are modified or
rewritten for graphic mode.
made public - procedure ResetCursor;
end;
------------------------
* = unique to TVGraphic
TWinBackground, 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;
DrawFlags := DrawFlags and not dfPanning;
procedure Draw; virtual;
clears dfPanning DrawFlag.
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) ALL Methods listed
Flags: Byte;
ZoomRect: TRect;
Number: Integer;
Palette: Integer;
Frame: PFrame;
Title: PString;
* Menu : PView; Pointer to pull down window menu, nil if none.
+ constructor Init(var Bounds: TRect;
ATitle: TTitleStr; ANumber: Integer);
sfShadow flag in State is not set.
{VOptions := twIsWindow; with v2.0, no longer set}
DrawFlags := DrawFlags or dfIsWindow; indicates it is a Window
+ constructor Load(var S: TStream);
if LoadVersion >= ofVersion20 then
load popup menu if one exists.
else
VOptions := 0
DrawFlags := DrawFlags or dfIsWindow;
+ destructor Done; virtual;
if Menu <> nil then Dispose(Menu, Done);
procedure Close; virtual;
* procedure Draw; virtual;
Hides and locks the mouse cursor.
Sets Viewport to the intersection of Viewport and the window
outline. Calls TFrame.Draw if dragging, otherwise TGroup.Draw.
Restores the Viewport to previous size and unlocks the mouse
cursor.
* procedure DrawWindow;
Alternative to DrawView. For special case.
Causes correct redrawing of the window even when
partially covered by other windows.
(The overlapping windows must have the same Owner.)
Use when you want to redraw a subview of a de-selected
window that may be partially covered by other windows.
Note: Very few applications change the contents of a
de-selected window.
* procedure GetMaxSubViewSize(var R: TRect;
MarginsForText: boolean); virtual;
{was GetInteriorSize prior to ver1.5, MarginsForText added v2.0.}
if Frame <> nil then
calls Frame^.GetInteriorSize(R, MarginsForText),
otherwise calls GetExtent(R) and then shrinks R by one
pixel on all four sides to allow for an outline rectangle
for the window.
MarginsForText: in general set true if you are filling R with
a single view displaying text up to its border (scroller,
editor, etc.), false for graphics. See TFrame.GetInteriorSize.
function GetPalette: PPalette; virtual;
function GetTitle(MaxSize: Integer): TTitleStr; virtual;
+ procedure HandleEvent(var Event: TEvent); virtual;
if (Event.What = evKeyDown) and (Menu <> nil)
and (Event.KeyCode = kbAltSpace) then displays pulldown menu.
PutEvents the command returned by the menu if it is not 0.
if broadcast of cmCommandSetChanged occurs, passes it to
Menu^.HandleEvent.
cmClose, cmZoom - checks if Event.InfoPtr is nil, @Self
or Ptr(0000,0001) which indicates sender was the
TVGraphic StatusLine.
procedure InitFrame; virtual;
+ procedure SetState(AState: Word; Enable: Boolean); virtual;
rewritten for nested windows. Same behavior as TV except:
No action if AState = sfActive.
If AState = sfSelected, sets its own and its subview's
sfActive bits to match window's sfSelected bit.
procedure SizeLimits(var Min, Max: TPoint); virtual;
+ function StandardScrollBar(AOptions: Word): PScrollBar;
Complete description:
If the window has a Frame then the Frame's VOptions field
is set with tfVScrollBar or tfHScrollBar depending on
(AOptions and sbVertical).
Next the scrollbar is sized and its width is set using constants
HScrollBarWidth or VScrollBarWidth.
GetExtent(R);
if AOptions and sbVertical = 0 then
R.Assign(R.A.X + FrameInset+1, R.B.Y-FrameInset-HScrollBarWidth,
R.B.X-2*Charlen+FrameInset+1, R.B.Y-FrameInset)
else
R.Assign(R.B.X-FrameInset-VScrollBarWidth,R.A.Y+Boxheight,
R.B.X-FrameInset,R.B.Y-Boxheight);
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.
+ procedure Store(var S: TStream);
stores the menu to the stream with S.Put(Menu);
procedure Zoom; virtual;
end;
+ Window Palettes
Window palettes are extended to duplicate the dialog palettes
with the menu palette added to the very end.
(CxDialog has changed from version 1.5.)
CxDialog = #9#10#11#12#13#14#15+
#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31+
#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+
#64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79+
#80#81#82#83#84#85#86#87#88#89#90#91#92#93#94#95+
#96#97#98#99#100#101#102#103#104#105#106#107#108#109#110#111+
#112#113#114#115#116#117#118#119#120#121#122#123#124#125#126#127+
#2#3#4#5#6#7; {CMenuView = #2#3#4#5#6#7;}
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;
------------------------
END OF FILE.