home *** CD-ROM | disk | FTP | other *** search
- {*
- * TvViews.pas
- *
- * Enhancements to Turbo Vision views.
- *
- * Copyright 1992 by Richard W. Hansen
- *
- *}
-
- UNIT TvViews;
- {$X+}
- {$V-}
-
- {$I TVDEFS.INC}
-
- INTERFACE
-
-
- USES
- TvKeys, TvType, TvConst, TvMenus,
- App, Drivers, Menus, Objects, Views, TextView, Dos;
-
-
- CONST
- ActiveFrame1 : FrameArray = '┌╖╘╝│║─═';
- ActiveFrame2 : FrameArray = '╔╗╚╝║║══';
- PassiveFrame : FrameArray = '┌┐└┘││──';
-
- ofPosIndicator = $1000;
- ofVScrollBar = $2000;
- ofHScrollBar = $4000;
-
-
- CONST
- { Position Indicator Palette }
- { Indicator normal }
- { Indicator passive }
- { Indicator dragging }
- CPosIndicator = #2#1#3;
-
- { Max/Min button Palette }
- { Button normal }
- { Button frame normal }
- { Button dragging }
- CMinMax = #3#2#3;
-
- { 3D Dialog Frame Palette }
- { Frame passive }
- { Title passive }
- { Frame normal }
- { Title normal }
- { Frame shaded }
- { Frame icon/dragging }
- C3DFrame = #35#35#33#33#34#36;
-
-
- TYPE
- { If views that are inserted into a dialog descend from TEditView
- instead of TView, greater edit control is possible. TEditView
- handles post-edit routines and required fields.
- }
- PEditView = ^TEditView;
- TEditView = Object(TView)
- ID : Word;
- LLabel : PView;
- PostEdit : Pointer;
- EditFlags : Word;
-
- Constructor Init(var Bounds: TRect);
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Function Valid(Command: Word): Boolean; Virtual;
- Procedure SetPostEdit(P : Pointer);
- Function Empty: Boolean; Virtual;
- Procedure SetEditFlag(AFlag : Word;
- Enable: Boolean);
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
- Procedure Select; Virtual;
- Procedure AddLabel(ALabel : PView);
- Procedure Lock;
- Procedure UnLock;
- Procedure SetID(AFieldID : Word);
- Function GetID: Word;
- end;
-
-
- { This object is a position indicator, it is made to be inserted
- into a TWindow or descendant frame.
- }
- PPosIndicator = ^TPosIndicator;
- TPosIndicator = Object(TView)
- Pos : Word;
-
- Constructor Init(var Bounds: TRect);
- Procedure Draw; Virtual;
- Function GetPalette: PPalette; Virtual;
- Procedure SetState(AState: Word; Enable : Boolean); Virtual;
- Function DataSize: Word; Virtual;
- Procedure SetData(var Rec); Virtual;
- Procedure GetData(var Rec); Virtual;
- end;
-
-
- { This object implements a window minimize and maximize icon. }
- PMinMaxButton = ^TMinMaxButton;
- TMinMaxButton = Object(TView)
- Constructor Init(var Bounds : TRect);
- Procedure Draw; Virtual;
- Function GetPalette: PPalette; Virtual;
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
- end;
-
-
- PNewFrame = ^TNewFrame;
- TNewFrame = Object(TFrame)
- Procedure HandleEvent(var Event: TEvent); Virtual;
- end;
-
-
- { PNewWindow is a window that can be minimized (iconized) }
- PNewWindow = ^TNewWindow;
- TNewWindow = Object(TWindow)
- PMinMax : PMinMaxButton;
- MinSize : TPoint;
- MaxRect : TRect;
- wfSave : Word;
- Minimized : Boolean;
-
- Constructor Init(var Bounds : TRect;
- ATitle : TTitleStr;
- ANumber: Integer);
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure SizeLimits(var Min, Max : TPoint); Virtual;
- Procedure SetState(AState : Word;
- Enable : Boolean); Virtual;
- Procedure InitFrame; Virtual;
- Procedure ControlMenu(Mouse : Boolean);
- end;
-
-
- { This is a scroll bar object that can be used by two or more
- views at the same time. It will always be active, no matter
- which of the views that own it is focused.
- }
- PMultiBuffScrollBar = ^TMultiBuffScrollBar;
- TMultiBuffScrollBar = Object(TScrollBar)
- Procedure SetState(AState : Word; Enable : Boolean);Virtual;
- Destructor Done; Virtual;
- end;
-
-
- { An abstract edit buff, that will become a hex or ascii edit buffer
- for use in the TEditBuffWindow defined below.
- }
- PEditBuff = ^TEditBuff;
- TEditBuff = Object(TScroller)
- Buf : PByteBuf; { pointer to raw data }
- BufSize : Word; { actual buffer size }
- ItemSize : Byte; { display size of each char }
-
- Constructor Init(Bounds : TRect;
- Buff : Pointer;
- BuffSize : Word;
- ItemWidth : Byte;
- AVScrollBar : PScrollBar);
-
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure SetXY(Pos : TPoint);
- Procedure GetXY(var Pos : TPoint);
- Function GetOffset: Word;
- end;
-
-
- { An descendant of TEditBuff, that will become the ascii edit buffer
- in the TEditBuffWindow defined below.
- }
- PAsciiBuff = ^TAsciiBuff;
- TAsciiBuff = Object(TEditBuff)
- Constructor Init(Bounds : TRect;
- Buff : Pointer;
- BuffSize : Word;
- AVScrollBar : PScrollBar);
-
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure Draw; Virtual;
- end;
-
-
- { An descendant of TEditBuff, that will become the hex edit buffer
- in the TEditBuffWindow defined below.
- }
- PHexBuff = ^THexBuff;
- THexBuff = Object(TEditBuff)
- Constructor Init(Bounds : TRect;
- Buff : Pointer;
- BuffSize : Word;
- AVScrollBar : PScrollBar);
-
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure Draw; Virtual;
- end;
-
-
- { This object implements a ASCII/HEX editing window. It is just like
- those used with disk utilities. The window can be of any size, but to
- keep ASCII and Hex views in sync, in the side by side views, there are
- a couple things to remember. The hex view will take twice as many chars
- to display the same data as the ascii view. So the X dimemsion should
- be an even number that will allow one view to be exactly twice as big
- as the other. The X dimension should also be evenly divisible by 3.
- This will make sure that the hex display does not split a character
- across two rows. This said, make sure to account for the frame.
-
- An example : a width of 62, allows 2 chars for the frame, and will
- give hex view 40 wide and an ascii view 20 wide.
-
- Because of all the above, and because I could not get the right
- combination of gfGrow modes, the window is set up to only grow in
- the Y axis.
-
- The AOptions param in Init only uses the ofPosIndicator flag, to
- insert or not a position indicator into the frame.
- }
- PEditBuffWindow = ^TEditBuffWindow;
- TEditBuffWindow = Object(TWindow)
- MaxWidth : Word;
- MaxPos : Word; { highest position edited }
- LView : PEditBuff; { left side HEX buffer }
- RView : PEditBuff; { right side ASCII buffer }
- VScrollBar : PMultiBuffScrollBar; { vertical scroll bar }
- Indicator : PPosIndicator; { byte position indicator }
-
- Constructor Init(Bounds : TRect;
- ATitle : TTitleStr;
- ANumber : Integer;
- AOptions : Word;
- Buff : Pointer;
- BuffSize : Word);
-
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure SizeLimits(var Min, Max : TPoint); Virtual;
- Procedure SetState(AState: Word; Enable: Boolean); Virtual;
- end;
-
-
- { TFormattedTextScroller is a TScroller that will word wrap and line
- wrap at carrige returns. Give it a pointer text buffer and
- it will do its best to display it.
- }
- PFormattedTextScroller = ^TFormattedTextScroller;
- TFormattedTextScroller = Object(TScroller)
- Buffer : PCharBuf;
- BufSize : Word;
-
- Constructor Init(var Bounds : TRect;
- AVScrollBar : PScrollBar;
- Buff : PCharBuf;
- BuffSize : Word
- );
- Procedure Draw; Virtual;
- Procedure ChangeBounds(var Bounds: TRect); Virtual;
- Procedure GetNextLine( First : Word;
- var Count : Word;
- var NextCh: Word);
- Procedure CountLines;
- end;
-
-
-
- { Here is a window that contains an instance of TTerminal for
- instant text display capabilities. Pass ofVScrollBar and/or
- ofHScrollBar in AOptions, if you want scrollbars for a scrolling
- window. If you need a quick text display window, but don't
- want the bother of defining a Draw method, just slap one of these into
- the desktop. TTextWindow has a Write method for displaying strings.
- Insert a cmDisplayStr broadcast event and an InfoPtr to a string into
- the event queue with an and the string will be displayed in any open
- PTextWindow.
- }
- PTextWindow = ^TTextWindow;
- TTextWindow = Object(TNewWindow)
- Interior : PTerminal;
- HScrollBar : PScrollBar;
- VScrollBar : PScrollBar;
- Width : Byte;
- Height : Byte;
-
- Constructor Init(Bounds : TRect;
- WinTitle : String;
- WinNumber : Word;
- AOptions : Word;
- AMaxLines : Word
- );
- Procedure Clear;
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure Write(St : String);
- end;
-
-
- P3DFrame = ^T3DFrame;
- T3DFrame = object(TFrame)
- Procedure Draw; Virtual;
- Function GetPalette: PPalette; Virtual;
- Procedure GetFrame(var F : FrameArray); Virtual;
- end;
-
-
- { Redirect output to a PTextWindow. Set F to "Output" to redirect all
- Writeln statements to the window.
- }
- Procedure AssignOutput(var F : Text;
- AWindow : PTextWindow);
-
-
-