home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / TVGRAPH.ZIP / REFER15.DOC < prev    next >
Text File  |  1993-12-24  |  87KB  |  2,053 lines

  1. file Refer15.DOC
  2.  
  3. 12/13/93
  4.  
  5. If you use the IDE, keep this file in a window for convenient reference.
  6.  
  7. REFERENCE SECTION   Ver1.5
  8.  
  9.  NOTE
  10.    Changes are relative to Turbo Vision 1.0 unless otherwise noted.
  11.  
  12.    Turbo Pascal 6.0 includes documentation for Turbo Vision 1.0.
  13.    Turbo Vision 2.0 comes with Pascal 7.0 and expands on TV 1.0,
  14.    adding additional objects and methods.
  15.  
  16.    TVGraphic incorporates published bug fixes for Turbo Vision
  17.    including those incorporated in the "maintanence" release of BP7.0.
  18.  
  19.    Documentation on BitMaps and related views is in file BitMap.DOC.
  20.  
  21.    Significant areas not presently in TVGraphic include
  22.      TV2.0 extended palettes
  23.      compatibility with Validators.
  24.      MultiCheckBoxes
  25.      Editor unit - in process
  26.      History views
  27.  
  28.    If your compiler does not recognize some TV syntax when
  29.    using these units, check this file under the appropriate
  30.    unit name and the object,method,variable,etc. name to see
  31.    if there is a syntax difference between TV and TVGraphic.
  32.  
  33.    TVGraphic
  34.      For objects that are analogous to Turbo Vision objects, only
  35.      methods that have been modified are listed in this section.
  36.      New methods are always listed. Assume unlisted methods are unchanged.
  37.      However, where the changes in a View's method
  38.        1. are solely to use graphic coords instead of text coords
  39.        and/or
  40.        2. only involve limiting redrawing area or frequency
  41.  
  42.      then the method is not listed.
  43.  
  44.    Unit Version Numbers:
  45.       Each unit exports a version number string constant under
  46.    the name of GVersion. This can be checked by using the IDE's
  47.    Evaluation window - for example include GObjects in a uses
  48.    statement and then evaluate GObjects.GVersion to get the
  49.    version of the GObjects unit.
  50. ------------------------
  51.  
  52. Application Palette
  53.  
  54.     See individual objects for TVGraphics palette definitions.
  55.     Format
  56.         Foreground color = lower 4 bits, background = upper 4 bits.
  57.         TVGraphics allows all 16 colors for background.
  58.         There is no inherent "blink" in graphic mode.
  59.     Indices
  60.         TVGraphic windows use TV's "Blue" window portion of the palette
  61.           which starts at entry 8.
  62.             (default background color is light gray in TVGraphic).
  63.         TVGraphic Dialogs use TV1.0's Dialog palette which starts at
  64.           entry 32. In TV2.0, this is called the "dpGrayDialog" palette.
  65.           (default dialog background color is cyan in TVGraphic).
  66.           (TV1.0 Dialogs do not use the "Gray" window portion of
  67.           the palette despite what TV1.0's documentation says).
  68.           TV2.0 dpXXXX constants: IDE's Help says they run 1,2,3
  69.           but TV2.0 Dialog unit exports them as 0,1,2 !
  70.           TVGraphic units for Pascal 7.0 export these constants but
  71.           colors for the other two dialog palettes are not currently
  72.           supported.
  73.  
  74.         Views in TVGraphic do not use the sections of the palette
  75.             that TV calls "Gray" and "Cyan" windows. It is expected
  76.             that the Cyan section will be used by HelpFile.Pas.
  77.          The Window palettes have been extended.
  78.  
  79.     {1 application background}
  80.     {2-7 Menus, StatusLine}
  81.     {Scrollbars: 11-12 in Blue Window, 35-36 in dialog boxes}
  82.     {BlueWindow starts at 8, 8-10 TFrame,11-12 Scrollbar,13-14 scroller,
  83.                                               15 reserved}
  84.  
  85.     {32-40 Dialog uses directly, remaps alot of other palettes mentioned
  86.              below. Indices are for items when inserted in a dialog}
  87.  
  88.         Rule is to take view's local palette number and add 31.
  89.       {32-34 TFrame, 35-36 scrollbar}
  90.       {37 static text, 38-40 Label}
  91.       {41-46 Buttons}
  92.       {47-49 Checkboxes and Radiobuttons}
  93.       {50-52 InputLine, 52 foreground is for scroll arrow,
  94.                      background for rect border around text.}
  95.       {50-56 HistoryWindow}
  96.       {57-60 TListViewer in Dialog}
  97.       {61 InfoPane, FileDialog}
  98.  
  99. ------------------------
  100.  
  101. BMPDRVR Unit - see file BITMAP.DOC
  102.  
  103. ------------------------
  104. * = unique to TVGraphic
  105. + = emulates TV with exceptions noted
  106.  
  107. GApp Unit
  108.  
  109.   * MessageBar : PGMessageBar = nil;
  110.        points to the MessageBar if one exists
  111.  
  112.   * procedure ImprovePaletteColors;
  113.        for screens in VGA mode, modifies the values (shades) of
  114.        dark gray and brown from the BGI default values.
  115.        NOTE: if you DOSshell, then need to call this routine again after.
  116.        NOTE: During debugging in the IDE, if you break out of your
  117.              program, the standard colors will be restored unless
  118.              you enable
  119.                 Options/Environment/StartUp   EGAVGA Palette Save
  120.              from the IDE's menu.
  121.  
  122.   * procedure TProgram.SetPalette(Pal : TPalette);
  123.       see TProgram
  124.  
  125. ------------------------
  126.  
  127. GBut Unit  see file BITMAP.DOC
  128.  
  129. ------------------------
  130.  
  131. GColor Unit
  132.  
  133.   +Adapt descriptions in standard color items to TVGraphic.
  134.   TVGraphic standard color item functions
  135.     function DesktopColorItems(Next: PColorItem): PColorItem;
  136.     function MenuColorItems(Next: PColorItem): PColorItem;
  137.     function DialogColorItems(Palette: Word; Next: PColorItem): PColorItem;
  138.     function WindowColorItems(Palette: Word; Next: PColorItem): PColorItem;
  139.  
  140.   procedure RegisterColorSel;
  141. ------------------------
  142. * = unique to TVGraphic
  143. + = emulates TV with exceptions noted
  144.  
  145. GDialogs Unit
  146.  
  147.   OBJECT Naming Convention
  148.  
  149.     Several TVGraphic Objects have an added field in their constructors
  150.     as compared to Turbo Vision.  (The added field comes last.)
  151.     These objects have different names in TVGraphic
  152.       TVGraphic        Turbo Vision
  153.         TgInputLine  =   TInputLine
  154.         TgLabel      =   TLabel
  155.         TgStaticText =   TStaticText
  156.         TgParamText  =   TParamText
  157.  
  158. * TVGraphic constants
  159.  
  160.     TextButtonsMatchBitMapButtons : boolean = false;
  161.          {whether text based buttons should look like Turbo Vision
  162.           or look similar to TVGraphic's BitMap buttons}
  163.     DefaultButHt : integer = 20;  default button height in standard views
  164.     DefaultDialogFont : byte = font8x14;
  165.          {Vfont set to this in TButton,TInputLine constructors.
  166.           Also in StaticText, ParamText, Label unless
  167.           overidden in Init(..,..,.,Opts) parameter.}
  168.  
  169.     MouseSnapToDialogGrid : boolean = true;
  170.        causes mouse cursor to snap to a 8x14 pixel grid while a
  171.        modal Dialog is visible
  172.  
  173.     VOptions constants:
  174.         DefaultOpts = 0;    {= behavior most like Turbo Vision}
  175.  
  176.       Text objects set VOptions to value of Opts field
  177.                  in their constructor.
  178.         Opts := option1+option2+...+ fontname {font overrides default font}
  179.  
  180.             Note: using txCentered automatically adjusts the
  181.                   width of the view to match the centered text.
  182.             Note: TgLabel's always have background. txBackground
  183.                                   and txCentered have no effect.
  184.         TgStaticText,TgParamText
  185.           txDrawBackground               = $80;
  186.           txCentered                     = $10;
  187.         TgStaticText,TgParamText,TgLabel
  188.           txAdjustSize                   = $20;
  189.           DefaultFontOverride = lower four bits = fontname
  190.  
  191.       TgInputLine sets VOptions to value of Opts field in its constructor.
  192.         TgInputLine
  193.           KillInstantErase     = $01; {prevent first keystroke from erasing}
  194.           lnRightJustify       = $02; {right justify the inputline}
  195.  
  196.       TDialog    {user must set these VOptions after construction}
  197.         dgReturnOnAnyButton  = $01;  {modal dialog returns on any command}
  198.         dgHelp               = $02;  {non-modal dialog issues cmClose
  199.                                       if it receives cmCancel.
  200.                                       i.e. closes if ESC key pressed}
  201.  
  202.  
  203.   Stream Registration numbers
  204.       CancelButton: gRegBase + 1001;
  205.       OKButton:     gRegBase + 1002;
  206.  
  207.   Palette Names
  208.      CDialog
  209.      CButton
  210.      CCluster
  211.    * CgInputLine
  212.    * CgLabel
  213.    * CgStaticText
  214.  
  215.   +TV2.0 constants
  216.     dpBlueDialog = 0;  these constants do not yet affect TVGraphic
  217.     dpCyanDialog = 1;
  218.     dpGrayDialog = 2;
  219.       presently should use   dpTV1Dialog = 3 with ColorSelector.
  220.  
  221. ------------------------
  222. * = unique to TVGraphic
  223.  
  224. GDrivers
  225.  
  226.       TV2.0 standard functions
  227.   function GetShiftState: Byte;
  228.   function GetCtrlChar(KeyCode: Word): Char;
  229.   function GetCtrlCode(Ch: Char): Word;
  230.  
  231.   MOUSE
  232. type     Used with mouse cursor grid, TMCur.GetGrid returns this type
  233.  * MGridRec = record
  234.       X : byte; Y : byte; Xoff : word;  Yoff : word;
  235.     end;
  236.  
  237.  NOTE:
  238.   TEvent.Buttons
  239.     For better or worse, TVGraphic returns the button number in
  240.     Event.Buttons when a mouse button is released (evMouseUp event).
  241.     Turbo Vision returns zero.
  242.  
  243.  
  244.   DOS CRITICAL ERROR handler
  245.     TV's text mode critical error handler must be replaced by TVGraphic's
  246.  
  247.  *  function GSystemError(ErrorCode: Integer; Drive: Byte): Integer; far;
  248.     or by one you write.
  249.       Note: To avoid needing to allocate memory to save a portion
  250.       of the screen, GSystemError assumes that a MenuBar exists
  251.       in your application.
  252.       You do not need a StatusLine.
  253.       DO NOT overlay the critical error handler.
  254.       GSystemError's source code is located in the demo program module.
  255.  
  256.     To replace TV's handler, place following line in
  257.     your application's .Init
  258.                   SysErrorFunc := GSystemError;
  259.  
  260.     The following functions are called by the Critical Error handler:
  261.  
  262.     function FarSelectKey : integer;
  263.              {returns user keystroke without calling DOS}
  264.     function GetCritErrorStr(ErrorCode : integer) : string;
  265.              {returns the error message}
  266.  
  267.  Timer Tick Event
  268.  *  procedure GetBiosTickEvent(var Event : TEvent);
  269.         if the DOS timer count differs from count at previous call to
  270.         GetBiosTickEvent, then Event returns a TVGraphic event catagory
  271.               Event.What := evTimerTick;
  272.               Event.Infolong := value return by GetBiosTicks;
  273.         otherwise Event.What is set to evNothing;
  274.  
  275.  *  function GetBiosTicks : longint;
  276.         returns DOS timer count stored at address $40:$6C;
  277.  
  278.        {WriteCStr,WriteCStrXY have been moved to the MyGraph3 unit.}
  279.  *  procedure WriteCStr(AStr : string; TxColor,HighlightColor : word);
  280.  *  procedure WriteCStrXY(X,Y : integer; AStr : string;
  281.                           TxColor,HighlightColor : word);
  282.  
  283.   DELETED
  284.     procedure PrintStr(S: String);
  285.   SHELL ONLY - these procedures match Turbo Vision but do nothing. They are
  286.       included to make stepwise conversion from TV easier.
  287.     procedure MoveBuf(var Dest; var Source; Attr: Byte; Count: Word);
  288.     procedure MoveChar(var Dest; C: Char; Attr: Byte; Count: Word);
  289.     procedure MoveCStr(var Dest; Str: String; Attrs: Word);
  290.     procedure MoveStr(var Dest; Str: String; Attr: Byte);
  291.  
  292. ------------------------
  293. * = unique to TVGraphic
  294.  
  295. GMenu   (GMenu6)
  296.  
  297.  * const  {user changable}
  298.     MenuBarheight : integer = 15;
  299.              height of the MenuBar in pixels,
  300.              minmum value is 15 if using Font8x14 as assigned in Init.
  301.              set BEFORE initializing the menubar.
  302.     MenuBoxheight : integer = Boxheight;
  303.              vertical line spacing in Box menus
  304.     MouseSnapToMenuGrid : boolean = true;
  305.         causes mouse cursor to snap to a properly located Charlen
  306.         by Boxheight grid while a BoxMenu executes.
  307.         Set false to use current grid with BoxMenus.
  308.     DefaultMenuFont : byte = Font8x14;
  309.  
  310.   Stream Registration Numbers
  311.     RgMenuBar: gRegBase + 40;
  312.     RgMenuBox: gRegBase + 41;
  313.     RgStatusLine: gRegBase + 42;
  314.     RgMessageBar: gRegBase + 1100;
  315.  
  316. ------------------------
  317. * = unique to TVGraphic
  318.  
  319. GMsgBox
  320.  
  321.  * procedure DOSErrorMessageBox(DOSErrNum : integer; FileName : string);
  322.  
  323.    DosErrorMessageBox displays appropriate DOS error message
  324.    and file name using a MessageBox. Pass the global variable DosError
  325.    as parameter DOSErrNum (or pass TStream.ErrorInfo if using a Stream).
  326.    Pass the file name as FileName.
  327.  
  328.  * procedure LowMemMsgBox;      {Out of memory Messagebox}
  329.       MessageBox('Not enough memory available.',
  330.                nil, mfError + mfOkButton);
  331.  
  332.  
  333.  +function MessageBoxRect(): Word;
  334.     Automatically centered. This works with any mouse grid in use.
  335.       Dialog^.Options := Dialog^.Options or OfCentered;
  336.  +function InputBox(), InputBoxRect: Word;
  337.     Automatically centered. This works with any mouse grid in use.
  338.       Dialog^.Options := Dialog^.Options or OfCentered;
  339.     Buttons adjust position to match box size in InputBoxRect.
  340.  
  341. ------------------------
  342. * = unique to TVGraphic
  343.  
  344. GObjects        At TV2.0 level in Pascal 7.0 TPU's.
  345.  
  346. const
  347.  * Str80 = string[80];
  348.  
  349. const    used to offset TVGraphic's stream registration numbers
  350.  * gRegBase = 60000;
  351.  
  352. const
  353.  Stream Registration Numbers
  354.    UnSortedStringCollection: gRegBase + 51;
  355.  
  356.  TCollection  -    Error code for method Valid
  357.  * coTruncationErr = -100;   {not enough mem to load all items from disk}
  358.  
  359.  
  360.  TMemoryStream - TV2.0 object
  361.    present in TVGraphic units for Pascal 7.0 only. Borland doc is
  362.    in a Borland disk file.
  363. ------------------------
  364.  
  365. GStdDlg        At TV2.0 level in Pascal 7.0 TPU's.
  366.  
  367.   TFileList.Init - the list of passed parameters varies between
  368.                  TV1.0 and TV2.0.  TVGraphic matches this.
  369.  
  370.   FileList.ReadDirectory and TDirListBox.NewDir make calls to the
  371.     mouse cursor to switch it to the hourglass shape and back.
  372.     To disable, set EnableHourGlass (in MCursor unit) to false.
  373.  
  374. ------------------------
  375. * = unique to TVGraphic
  376. + = emulates TV with exceptions noted
  377.  
  378. GViews
  379.  
  380.  + MaxViewWidth = 132*Charlen;
  381.  + MinWinSize: TPoint = (X: 16*Charlen; Y: 6*Boxheight);
  382.  
  383.  
  384.  + Window Palettes extended. Dialog palette added to end.
  385.     CBlueWindow := CBlueWindow + CDialog;
  386.     CCyanWindow := CCyanWindow + CDialog;
  387.     CGrayWindow := CGrayWindow + CDialog;
  388.  
  389.  + Blinking Text Cursor
  390.     Constants that determine maximum size for blinking cursor.
  391.       (Cursor sizes itself to font stored in VFont.)
  392.  * MaxCurWidth  = 2*Charlen;
  393.  * MaxCurHeight = 2*Boxheight;
  394.  
  395.  * TVGraphic constants
  396.  
  397.     ScrollBarWidth = 11;   {0 to 11 = 12 pixels total width}
  398.     DefaultListViewerFont : byte = font8x14;
  399.  
  400.     TVColor        = $FFFF;
  401.       This constant is used only by other units.
  402.       It is used in VColor field of some views to indicate
  403.       that the drawing colors should come from the palette
  404.       and not from the VColor field.
  405.  
  406.     AllowBothMButtons : boolean = false;
  407.       Used by all standard views.
  408.       When false
  409.         right mouse button follows TVGraphic rules - cancels
  410.         current operation including modal dialog boxes.
  411.       When true
  412.         right mouse button follows Turbo Vision 2.0 behavior
  413.         including will not cancel modal dialog box.
  414.  
  415.  * VOptions constants
  416.     TWindow
  417.       twIsWindow       = $80;   {identifies group as a TWindow descendant}
  418.  
  419.     TFrame drawing control
  420.       tfDrawBackground = $01;     {fill entire size rectangle}
  421.       tfVScrollBar     = $02;     {user sets if bar is present in Owner}
  422.       tfHScrollBar     = $04;
  423.  
  424.  
  425.   type           This is the record type used for field TView.Hook
  426.  *  TUserRec = record
  427.      case word of
  428.        0 : (R : TRect);
  429.        1 : (P1,P2 : pointer);
  430.        2 : (X1,Y1,X2,Y2 : integer);
  431.      end;
  432.  
  433.  
  434.  * function ASHR(AnInt : integer; Places : byte) : integer;
  435.       {does arithmetic shift right of Places on AnInt}
  436.  * function ASHL(AnInt : integer; Places : byte) : integer;
  437.       {does arithmetic shift left of Places on AnInt}
  438.  
  439. -----------------------
  440. * = unique to TVGraphic
  441.  
  442. * GWindow
  443.     const
  444.          {used to communicate between TPanWindow and TShiftView}
  445.       cmScreenShifted    = gRegBase + 2000;
  446.       cmShiftScreenDown  = gRegBase + 2001;
  447.       cmShiftScreenUp    = gRegBase + 2002;
  448.  
  449.     const
  450.       NormalMode = 0;
  451.           {number of pixels to shift screen when mouse
  452.            cursor hits edge of a Panning window.}
  453.       ScrnShiftX : word = Grid * 20;
  454.       ScrnShiftY : word = Grid * 15;
  455.           {These values are not directly referenced by TVGraphic.
  456.             Change to suit your needs:
  457.             if using a mouse grid, be sure to shift by even
  458.             multiples of the your grid.  'Grid' used here is fixed
  459.             constant from MCur unit. Grid = 10.}
  460.  
  461.     const
  462.       ShiftViewPtr : PShiftView = nil;  {Global}
  463.  
  464.   Stream Registration Numbers
  465.       ShiftView:  gRegBase + 2000;
  466.       SubWindow:  gRegBase + 2001;
  467.       PanWindow:  gRegBase + 2002;
  468.       WinBackground:  gRegBase + 2003;
  469.  
  470.   procedure RegisterWindows;
  471.  
  472. -----------------------
  473. * = unique to TVGraphic
  474.  
  475. * MCursor Unit     (MCursor2)
  476.  
  477.   Yes there alot of methods for the cursor but the average user
  478.   will use only these:
  479.     Init, Done
  480.     Show, Hide
  481.     LockShow, LockHide
  482.     RePosition
  483.     RestoreSettings (for after DOS shell)
  484.     SetGrid         call once and forget
  485.  
  486. {  This type is declared in GDrivers and used by TMCur.GetGrid.
  487.     type
  488.       MGridRec = record
  489.         X : byte; Y : byte; Xoff : word;  Yoff : word;
  490.       end; }
  491.  
  492.   Note on the HourGlass cursor shape
  493.      switch to it with MCur.SelectHourGlass, back with MCur.SelectStdCursor.
  494.      This is intended to indicate waiting only - buttons are disabled.
  495.  
  496.   const
  497.     EnableHourGlass : boolean = true; {hourglass shape will not appear
  498.                                        if false}
  499.     Grid = 10;         {size of coarse drawing grid spacing in pixels}
  500.     FineGrid = 5;      {size of fine drawing grid}
  501.  
  502.   var
  503.     MCur : TMCur;       Global mouse cursor object
  504.  
  505.   procedure FlushMouseQue;  NOTE - Flushes ALL types of mouse events
  506.                              from the event que.
  507.  
  508.   PMCur = ^TMCur;
  509.   TMCur  = object(TPoint)
  510.     READ only
  511.       MinGridX, MinGridY : integer; {min screen coords of mouse travel}
  512.       MaxGridX,MaxGridY  : integer; {max screen coords for mouse travel}
  513.     constructor Init;
  514.           SetGrid(Grid,Grid,0,0);   set to 10x10 grid
  515.           SetSpeed(12,12);    reduce mouse sensitivity, "normal" is 8,8
  516.     destructor Done;
  517.     procedure CenterIt;
  518.         Computes center of screen and then calls RePosition(center)
  519.     procedure CurWhere(var Pt : TPoint);
  520.         returns cursor position
  521.     procedure Limitvert(minpos,maxpos : integer);
  522.         sets vertical limits of cursor travel
  523.     procedure Limithorz(minpos,maxpos : integer);
  524.         sets horizontal limits of cursor travel
  525.     procedure Move(P : TPoint);
  526.         moves cursor to Pt, even if hidden.
  527.     function  OverLapsCursor(R : TRect) : boolean;
  528.         true if R overlaps the cursor.
  529.     procedure RePosition(var Pt : TPoint);
  530.         Moves the cursor and calls FlushMouseQue.
  531.         If Pt is outside the area specified for the cursor travel,
  532.         then moves cursor to edge of specified area.
  533.     procedure RestoreSettings;
  534.         restores position,speed and limits of travel after DOS shell
  535.     procedure RestrictYMove;
  536.         keeps cursor out of MenuBar
  537.     procedure RestoreYMove;
  538.         restores cursor travel to screen top
  539.     procedure GetGrid(var AGrid : MGridRec);
  540.         sets AGrid to equal the current values of the mouse grid
  541.     procedure SetGrid(XGrid, YGrid : byte; XGridOffset, YGridOffset : word);
  542.         SetGrid not only sets the specified grid but also sets
  543.         the limit of mouse travel so the cursor won't disappear
  544.         off the right screen edge or the bottom.
  545.         It also repositions the mouse if necessary to be on
  546.         the new grid.
  547.     procedure SetSpeed(Mickx, Micky : integer);
  548.         set cursor movement speed  (ratio of mickeys/pixel)
  549.     procedure SelectHourGlass;
  550.         if EnableHourGlass is true, cursor shape is set to the hourglass
  551.     procedure SelectStdCursor;
  552.         cursor shape is set to the arrow
  553.     procedure LockShow;
  554.         decrements lock count, show cursor if 0
  555.     procedure LockHide;
  556.         hide cursor if visible, increment lock count.
  557.         while lock count > 0, Show and Hide have no effect.
  558.     procedure Show;
  559.         shows the cursor
  560.     procedure Hide;
  561.         hides the cursor
  562.   end;
  563.  
  564. ------------------------
  565. * = unique to TVGraphic
  566. + = calls Graph unit with exceptions noted
  567.  
  568. * Unit MyGraph3
  569.  
  570.   This unit traps some BGI calls before passing them to the Graph unit.
  571.  
  572. Fonts
  573.   Unit contains the two pixel clippable bit-mapped fonts.
  574.     Font8x8 appears the same as the Graph unit Default font.
  575.     Font8x14 is the same size as and looks like an EGA text mode font.
  576.   These fonts have only one size and can only be horizontal.
  577.  
  578.   NOTE: if you install enough custom fonts, eventually the BGI will
  579.   assign font numbers equal to or higher than Font8x8. You will not be
  580.   able to access custom font numbers equal to and above Font8x8.
  581.   Example: Borland Pascal 7.0 has fonts defined at numbers 0 thru 10
  582.   so you will only be able to access three custom fonts.
  583.  
  584.  
  585. const      {for graphics mode programs}
  586.   Charlen = 8;       {width of a standard graphic char in pixels}
  587.   BoxHeight = 14;    {height of the standard text line}
  588.  
  589.     TVGraphic clippable, bit-mapped Fonts
  590.   Font8x8       = 14;      {8 by 8 pixels}
  591.   Font8x14      = 15;      {8 by 14 - same size as text on EGA}
  592.  
  593.   BYOff8x8       = 4;       {offset down into Boxheight to center text}
  594.   BYOff8x14      = 1;
  595.   BYOffSmallFont = 0;       {for use with BGI SmallFont}
  596.  
  597.     {font dependent offset down into Boxheight to center text}
  598.   BYOffset : integer = 0;
  599.     The value of BYOffset is set to one of the three BYOFF constants
  600.     by SetTextStyle according to the font being selected. It can be
  601.     used when spacing lines of text vertically using Boxheight to
  602.     properly center the text font vertically within each box.
  603.     Add BYOffset to the box's upper edge when using OutTextXY or
  604.     MyGraph.MoveTo+OutText.
  605.  
  606.   BXOffset = 4;    {offset from left edge of box}
  607.  
  608. Utility functions
  609.  
  610.   procedure WriteCStr(AStr : string; TxColor,HighlightColor : word);
  611.         Writes AStr as a single line. Text is in TxColor but anything
  612.         enclosed with  ~'s is written in the highlight color. Can use
  613.         multiple pairs of  ~'s.
  614.         Does not draw a background under the text.
  615.   procedure WriteCStrXY(X,Y : integer; AStr : string;
  616.                               TxColor,HighlightColor : word);
  617.         X,Y are viewport relative BGI coordinates. Moves the
  618.         BGI "current pointer" to X,Y and then calls WriteCStr.
  619.         Text is written at X,Y.
  620.  
  621.   function ConstStr(C : Char; N : Integer) : String;
  622.      ConstStr returns a string with N characters of value C
  623.  
  624.   function CalcVertTextOffset(ViewYSize : integer) : integer;
  625.           {was named VertTextOffset in earlier versions}
  626.      Used by MenuBar,StatusLine,etc. to calc vertical offset to
  627.      center a line of text in a view. Pass view's Size.y as ViewYSize.
  628.      Font dependent - Must set font Before calling this routine!
  629.      Tested with Smallfont,Font8x8,Font8x14 in 10,15,20 pixel high
  630.      boxes.
  631.   begin
  632.     CalcVertTextOffset := (ViewYSize +1 - TextHeight(' ')) div 2 +1;
  633.   end;
  634.  
  635. BGI functions
  636.   +procedure SetTextStyle(Font, Direction : word; CharSize : word);
  637.      For font numbers less than Font8x8
  638.        calls the Graph unit SetTextStyle. If that call fails
  639.        (font not found), then sustitutes Font8x8.
  640.        Sets BYOffset to BYOffSmallFont.
  641.      For fonts Font8x8,Font8x14, sets font selection in this unit
  642.      to selected font. Sets BYOffset to matching BYOff constant.
  643.  
  644.      Note that you can select the Graph unit DefaultFont (font =0)
  645.      but it doesn't clip at pixel level - see BGI/Graph unit doc.
  646.  
  647.   +function TextHeight(TextString : string) : word;
  648.      returns 8 for Font8x8 and 14 for Font8x14
  649.   +function TextWidth(TextString : string) : word;
  650.      uses character width of 8 for fonts Font8x8 and Font8x14
  651.      to calculate width.
  652.  
  653.   The following BGI calls are also intercepted
  654.      Bar
  655.      Bar3d
  656.      OutText
  657.      OutTextXY
  658. ------------------------
  659.  
  660. ofXXXX constants           Used with TView.Options field.
  661.  
  662.   ofVersion  : TVGraphic ver1.1 views are ofVersion10 types {same as TV1.0}
  663.  
  664.   ofFramed   : TV def = TFrame draws frame for each window subview
  665.                         where this bit is set.
  666.       Note: Due to different redraw order in TVGraphic, TFrame draws first
  667.       and therefore cannot draw frames for other (yet to be drawn) views.
  668.       Each view must handle its own frame drawing.
  669.  
  670.     TVGraphic frame behavior:
  671.       InputLines and ListBoxes - always framed. ofFramed has no effect.
  672.       TgStaticText, TgParamText, TgLabel - view will draw its own frame
  673.         if ofFramed is set in its Options field. Default = no frame.
  674.       TCheckBoxes, TRadioButtons - view will draw its own frame
  675.         if ofFramed is set in its Options field. Default = framed.
  676.  
  677.   TVGraphic does NOT recognize
  678.     ofBuffered : buffers not used in TVGraphic
  679.     ofValidate : to be supported in a future version
  680.     ofVersion20 : to be supported TVGraphic 2.0
  681.  
  682. ------------------------
  683.  
  684. sfXXXX constants
  685.  
  686.   These correspond to bits in the TView.State field.
  687.  
  688.   sfShadow
  689.     Do not use sfShadow in releases of GViews prior to 1.02.
  690.     In 1.02 and after, sfShadow has no effect in TVGraphic and is
  691.     available as a spare state for you to play with.
  692.  
  693.   sfExposed  {same as TV}
  694.     true if view is Inserted directly or thru other views into the
  695.     Application AND the sfVisible bit is true. While reseting states,
  696.     TVGraphic sometimes momentarily changes this bit.
  697.  
  698.   sfActive versus sfSelected - Windows versus views
  699.     {a little different from TV}
  700.     TV background:
  701.       all TGroups can have a Selected subview but only windows and
  702.       subviews within windows can be Active. When a window is
  703.       selected, it and all of its subviews are set active.
  704.       Deselection of the window sets everything inActive.
  705.       Note that a subview may not be selectable (ofSelectable not set)
  706.       but it will still become Active if it is in an active window.
  707.     TVGraphic
  708.       To allow nesting of windows, a window (unlike other views)
  709.       does not respond to SetState(sfActive,...).
  710.       It sets all its subviews'sfActive bit to match its own
  711.       sfSelected bit. In GView versions prior to 1.02, a window
  712.       never sets its own sfActive bit. For 1.02 and after, it sets it
  713.       to match its sfSelected bit.
  714.       Note that when windows are nested, there can be an Selected
  715.       subWindow (whose subViews will be Active)
  716.       plus additional subWindows all in an Selected Window (selected
  717.       Window's subviews, other than subwindows, will also be Active).
  718.       In GView versions prior to 1.02, none of the window/subwindows will
  719.       have its sfActive bit set while for 1.02 and after, the selected
  720.       window and subWindow will have their sfActive bits set.
  721.  
  722. ------------------------
  723.  
  724. TApplication
  725.   In TVGraphic, Applications descend from TProgram, not TApplication!
  726.     See Deriving an Application section of main documentation file.
  727.     TDemoApp is derived in TVGDem1.PAS.
  728.  
  729.   TDemoApp  - only those methods that are necessary or of general
  730.        interest are listed here. See TDemoApp for code/descriptions.
  731.     procedure DosShell;
  732.     procedure GetEvent(var Event : TEvent); virtual;
  733.        timertick events
  734.        necessary update of mouse cursor, other mouse
  735.        hooks for Help windows
  736.     procedure HandleEvent        example of handling a TShiftView
  737.     procedure InitHeapViewer;
  738.     procedure InitMenuBar; virtual;
  739.     procedure InitMessageBar;    message that covers over the MenuBar
  740.     procedure InitShiftView;     used with TPanWindow for panning screen
  741.     procedure InitStatusLine; virtual;
  742.     procedure InitToolBar;
  743.     procedure SaveDeskTop;
  744.     procedure LoadDeskTop;
  745.     procedure ShowHelp;
  746.     destructor Done; virtual;
  747.     destructor HaltDone;    destructor used prior to entering graphic mode
  748.  
  749. ------------------------
  750.  
  751. TBackground = object(TView)
  752.     Pattern - Not used.
  753.          In TVGraphic, Background obtains its fillstyle from the
  754.          background color of its palette entry. The fillstyle passed
  755.          to SetFillStyle is (BackgroundColor mod 4 +8).
  756.   end;
  757.  
  758. ------------------------
  759. * = unique to TVGraphic
  760. + = emulates TV with exceptions noted
  761.  
  762. TButton = object(TView)
  763.     +AmDefault: Boolean;     modified usage - true if button is selected
  764.     +constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  765.       AFlags: Word);
  766.         sets VFont := DefaultDialogFont
  767.     procedure Draw; virtual;              unchanged - calls DrawState
  768.     +procedure DrawState(Down: Boolean); virtual;
  769.         rewritten for graphic drawing. Button outline is always in black.
  770.         centers text vertically for any font
  771.         made virtual
  772.         when TextButtonsMatchBitMapButtons is true, then Tbuttons draw
  773.           to match appearance of TVGraphic bitmapped TIconButtons.
  774.           The text and button background is always drawn in the
  775.             Button Text Normal colors.
  776.           A shadow frame is drawn using the Shadow colors.
  777.             If ((Size.x > 2*Boxheight) and (Size.y >= 2*Boxheight))
  778.             or the button is the default button, this frame is
  779.             drawn thicker.
  780.           If a button is selected, its outline is dotted using
  781.             the background color of Text Normal.
  782.           An unselected button which is the default button has a
  783.             thicker dark border useing the Shadow colors.
  784.     +procedure HandleEvent(var Event: TEvent); virtual;
  785.         heavily altered
  786.         summary:
  787.           If button's command is disabled, its sfDisabled State flag
  788.             is set and it cannot be pressed. Redraws as necessary.
  789.           A button will not select itself if clicked with mouse unless
  790.             the bfGrabFocus (TV2.0) flag is set in Flags.
  791.           Mouse - evMouseDown presses button. No action for right
  792.             mouse button unless global AllowBothMButtons is true.
  793.           Enter key presses the Default button. The Default button is
  794.             either the Focused button, or if no button is focused,
  795.             the button with bfDefault set in Flags.
  796.           cmDefault will press the button if bfDefault is set in Flags.
  797.           not using cmGrabDefault, cmReleaseDefault:
  798.           usual HotKey behavior
  799.     +procedure MakeDefault(Enable: Boolean);
  800.         routine's code is commented out.
  801.     +procedure Press; virtual;
  802.         draws button pressed then unpressed again.
  803.     +procedure SetState(AState: Word; Enable: Boolean); virtual;
  804.         for AState=sfFocused, sets AmDefault to Enable and redraws
  805.         the view. Does not call MakeDefault.
  806.   end;
  807.  
  808.   To change the Default Button after initialization:
  809.     change which button has the bfDefault flag set in its Flags field
  810.     (only one button should have this flag set at a time),
  811.     then call the old and new Default buttons' DrawView.
  812.  
  813.  
  814. * TVGraphic predefined buttons
  815.  
  816.      Button Size is fixed at 10*Charlen long by DefaultButHt tall.
  817.      Only the Button's Origin is specified in Init.
  818.  
  819. * PCancelButton = ^TCancelButton;
  820. * TCancelButton = object(TButton)      Issues the cmCancel command.
  821.     constructor Init(var Org : TPoint);
  822.   end;
  823.  
  824. * POKButton = ^TOKButton;
  825. * TOKButton = object(TButton)          Issues the cmOK command.
  826.     constructor Init(var Org : TPoint; DefaultButton : boolean);
  827.         if DefaultButton is true, then call to TButton sets
  828.         Turbo Vision bfDefault button flag in Flags field.
  829.   end;
  830.  
  831.  
  832. + Button Palette
  833.     background is drawn in the background color of entries 1-4
  834.       depending on State of button.
  835.     button outline/shadow:
  836.       left and top = foreground color of entry 8
  837.       right and bottom = background color of entry 8
  838.     button draws black momentarily when pushed
  839.     all text - same entries as TV
  840.  
  841. ------------------------
  842. * = unique to TVGraphic
  843. + = emulates TV with exceptions noted
  844.  
  845. PCheckBoxes = ^TCheckBoxes
  846. TCheckBoxes = object(TCluster)     unmodified
  847.  
  848.   TCluster:
  849.     TVGraphic corrects TV 1.0 bug in handling nil strings in TCluster.
  850.     This means you can have a Checkbox or RadioButton view without
  851.     individual box labels.
  852.  
  853. PCluster = ^TCluster
  854. TCluster = object(TView)
  855.     +constructor Init(var Bounds: TRect; AStrings: PSItem);
  856.         sets  VFont := font8x8
  857.     +procedure DrawBox(Icon: String; Marker: Char); virtual;
  858.         fix TV 1.0 bug for single line horizontal Clusters
  859.         rewritten for graphics
  860.         made virtual
  861.     +procedure HandleEvent(var Event: TEvent); virtual;
  862.         convert to graphics coords
  863.  
  864.     {+Methods below are Private in TV 1.0.
  865.      In TVGraphic they are public and virtual.}
  866.     function FindSel(P: TPoint): Integer; virtual;
  867.         convert to graphic coords
  868.     function Column(Item: Integer): Integer; virtual;
  869.         handle nil strings
  870.         convert to graphic coords
  871.     function Row(Item: Integer): Integer; virtual;
  872.         convert to graphic coords
  873.   end;
  874.  
  875.  
  876. + Cluster Palette
  877.     background is drawn in the background color of entry 1.
  878.     cluster outline uses background color of entry 3
  879.     all text - same entries as TV
  880.  
  881. ------------------------
  882. * = unique to TVGraphic
  883. + = emulates TV with exceptions noted
  884.  
  885. TCollection = object(TObject)
  886.     +constructor Load(var S: TStream);
  887.         checks LowMemory before loading each item. If true, sets
  888.         Count equal to number of items loaded and exits.
  889.         The partially loaded collection is usable.
  890.         With Ver1.5, Sets error flag in above case. Also checks for
  891.         large enough block of memory to allocate Items, the array of
  892.         pointers (will not dip into the Safety Pool).
  893.         If not, sets error flag and constructs an empty
  894.         Collection with Limit=1 and Count =0.
  895.     procedure AtFree(Index: Integer);
  896.         missing from TV 1.0 manual
  897.         deletes and disposes of item at index.
  898.     *function Valid : integer; virtual;
  899.         returns 0 if complete collection successfully loaded,
  900.         error code otherwise. See GObject unit descript for error code(s).
  901.         See main doc file for discussion of loading and safety in
  902.         using Collections.
  903.     private
  904.       TruncationErr : boolean;
  905.   end;
  906.  
  907. ------------------------
  908. * = unique to TVGraphic
  909. + = emulates TV with exceptions noted
  910.  
  911. TColorGroupList = object(TListViewer)
  912.     +procedure FocusItem(Item: Integer); virtual;
  913.         modify to send message only if color has changed
  914.   end;
  915.  
  916. TColorDialog = object(TDialog)
  917.     +constructor Init  modify to allow 16 colors for background.
  918.         delete mono selector, rearrange control locations.
  919.   end;
  920.  
  921.  
  922. ------------------------
  923. * = unique to TVGraphic
  924. + = emulates TV with exceptions noted
  925.  
  926. TDeskTop = object(TGroup)
  927.     BackGround : PBackground;
  928.         present but not doc'd in TV 1.0
  929.     function NewBackground
  930.         vaporware in TV 1.0 documentation.
  931.     procedure InitBackground
  932.         actual TV 1.0,2.0 call - constructs background
  933.         equal in size to DeskTop, called in TDeskTop.Init
  934.     +procedure HandleEvent(var Event: TEvent); virtual;
  935.         present but not documented in TV 1.0
  936.         Handles commands:
  937.             cmNext: SelectNext(False);
  938.            +cmPrev: puts current view in front of foremost
  939.                      non-selectable view. (usually the background)
  940.     *constructor Load(var S : TStream);   {missing in TV 1.0, added}
  941.     *procedure Store(var S : TStream);    {missing in TV 1.0, added}
  942.   end;
  943.  
  944. ------------------------
  945. * = unique to TVGraphic
  946. + = emulates TV with exceptions noted
  947.  
  948. TDialog = object(TWindow)
  949.     +constructor Init(var Bounds : TRect; ATitle : TTitleStr; Opts : byte);
  950.         added Opts parameter to set VOption field.
  951.       if Opts = DefaultOpts then matches TV
  952.       if Opts = ReturnOnAnyButton then Dialog will end modal state when
  953.         any button command is issued including user defined commands.
  954.       see GDialog Unit section for other options
  955.  
  956.       Init sets Frame^.VOptions := tfDrawBackground;
  957.         which causes Dialog's Frame to draw a background for the view.
  958.  
  959.     *function Execute : word; virtual;  NEW-ADDED
  960.         calls TGroup.Execute
  961.       if global MouseSnapToDialogGrid is true then Execute sets the
  962.       mouse grid to a Charlen by Boxheight grid before the call to
  963.       TGroup.Execute and resets grid to previous values afterwards.
  964.       If set, grid is relative to top of DeskTop - Dialog grid assumes
  965.       you will insert Dialog into DeskTop.
  966.       When inserting a Dialog, easiest way is to use the ofCentered
  967.       option in the Dialog.Option field (not VOptions field). This
  968.       will center the Dialog and match it to the grid if you dimension
  969.       the Dialog vertically using the Boxheight constant and
  970.       horizontally using the Charlen constant.
  971.              (i.e. Size.x := I*Charlen
  972.              (     Size.y := N*Boxheight  where I,N : integer)
  973.  
  974.     +function GetPalette: PPalette;
  975.          modified to return an altered palette if dialog is non-modal
  976.          and dialog's Owner has a palette, else usual palette.
  977.          This allows correct colors if inserted in a Window
  978.          (Windows use TVGraphic's extended window palettes.)
  979.     +procedure HandleEvent(var Event: TEvent); virtual;
  980.          modified for ReturnOnAnyButton
  981.   end;
  982.  
  983. ------------------------
  984. * = unique to TVGraphic
  985. + = emulates TV with exceptions noted
  986.  
  987. TFrame = object(TView)
  988.     +constructor Init(var Bounds: TRect);
  989.         VFont is set to font8x8; TFrame assumes this size font
  990.         is used so may not work properly with other fonts.
  991.     +procedure Draw; virtual;
  992.       NOTE: The frame's VOptions tfDrawBackground flag is automatically
  993.             set in TDialog.Init but NOT in TWindow.Init !
  994.               User may set after window's construction if desired.
  995.         Draws a complete background if sfDragging or
  996.           the VOptions tfDrawBackground is set. Uses the background
  997.           color of the palette's Active Frame entry.
  998.         Otherwise checks VOption flags tfVScrollBar and tfHScrollBar
  999.           (set by TWindow.StandardScrollBar) and draws background under
  1000.           the standard scrollbar positions for each set flag.
  1001.         Finally calls DrawFrame.
  1002.     *procedure DrawFrame; virtual;
  1003.         Draws a background under top bar of window. Draws a rectangle
  1004.         around the view and an inner rectangle if the view is active.
  1005.         These border rectangles extend offscreen if the view has an
  1006.         Interior larger then the screen. (Calls
  1007.         TGroup.GetFullPanSize to get size for these outline rectangles.)
  1008.         If the window number is 1 thru 9, draws a Next Window button
  1009.         with number inside.
  1010.         Next, if active, checks Flags field and draws usual icons
  1011.         if flags are set in Flags. Finally draws title, shortening
  1012.         it as necessary to fit. Windows numbered 1..9 draw a blue
  1013.         background under the title using the background of
  1014.         palette entry 6.
  1015.     *function Exposed : boolean; virtual;
  1016.         calls Owner^.Exposed
  1017.     *procedure GetInteriorSize(var R : TRect); virtual;
  1018.         returns in R the size of the area inside the frame that you
  1019.         should fill with views. This size reflects whether the VOption
  1020.         flags tfVScrollBar and tfHScrollBar are set. (They are set
  1021.         automatically if you add scrollbar(s) using
  1022.         TWindow.StandardScrollBar).
  1023.         Note that if you set TFrame's tfDrawBackground in the
  1024.         VOption field, it will fill this area with the TFrame
  1025.         background color.
  1026.     +procedure HandleEvent(var Event: TEvent); virtual;
  1027.         Handles mouse events. If NextWindow button is pressed,
  1028.         issues a command event with Event.Command := cmNext to
  1029.         advance to next window. Otherwise emulates TV.
  1030.     *procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
  1031.         added to handle Panning windows. Dest is in coord system
  1032.         of TFrame, not the panning window Interior.
  1033.     +procedure SetState(AState: Word; Enable: Boolean); virtual;
  1034.         Calls DrawView when setting sfDragging. If clearing
  1035.         sfDragging or changing sfActive, calls
  1036.         DrawFrame if view is Exposed.
  1037.   end;
  1038.  
  1039. + TFrame Palette
  1040.   { TFrame Palette layout }
  1041.   { 1 = Passive frame }
  1042.   { 2 = Passive title }
  1043.   { 3 = Active frame }
  1044.   { 4 = Active title }
  1045.   { 5 = Icons, Dragging frame }
  1046.   {*6 = highlight outline, background for title of numbered windows}
  1047.   CFrame      = #1#1#2#2#3#4;   {add #4 to map to dialog box
  1048.                                 scrollbar background}
  1049.   The background of entry #3 is used in cases where the frame
  1050.     draws a complete background for a window.
  1051.   Numbered,Active frames draw their inner border and their
  1052.     background under the Title using background of entry 6.
  1053.      {entry 6 points to same color as scrollbar's entry 1}
  1054.   Icon buttons draw background with background of entry 5,
  1055.     Icon uses foreground of entry 5.
  1056.   Other items follow TV.
  1057. ------------------------
  1058. * = unique to TVGraphic
  1059. + = emulates TV with exceptions noted
  1060.  
  1061. TGroup = object(TView)
  1062.     Buffer: PVideoBuf;     deleted
  1063.     constructor Init(var Bounds: TRect);
  1064.         does not set ofBuffered in Options field
  1065.  !  constructor Load(var S: TStream);
  1066.         Calls LowMemory after loading each view and Exits if true.
  1067.         This prevents TV's runtime halt with out of memory error.
  1068.  !   Warning: when Load exits due to LowMemory=true, the Group is
  1069.         not complete - inter view pointers are not restored.
  1070.         If you insert the Group, the computer will probably bomb - totally!
  1071.           To check for incomplete Load, follow the TV recommended
  1072.           practice of using TProgram.ValidView on the pointer
  1073.           returned by S.Get. If LowMemory, ValidView will display
  1074.           an insufficient memory message, dispose the Group and
  1075.           return a nil pointer to you.
  1076.  
  1077.         Load also calls SetClipToMax.
  1078.  
  1079.     *function CurAtEdge(Event : TEvent; var Delta : TPoint;
  1080.                     AllowMenuAccess : boolean) : boolean; virtual;
  1081.         Returns false with no other action here.
  1082.         Overridden in descendents if panning with mouse cursor.
  1083.     procedure ChangeBounds(var Bounds: TRect); virtual;
  1084.         calls SetClipToMax rather than GetExtent(Clip);
  1085.     procedure Draw; virtual;
  1086.         sets Clip by calling GetClipRect(Clip), calls Redraw and
  1087.         resets Clip with SetClipToMax {rather than GetExtent(Clip)}.
  1088.     *procedure GetClip(var MyClip : TRect);
  1089.         sets MyClip equal to Clip
  1090.     *procedure GetFullPanSize(var ISize : TPoint); virtual;
  1091.         ISize is set to Size here. Overridden by descendents with
  1092.         larger then the screen Interiors to return size of
  1093.         their Interior. Called by TFrame.DrawFrame to determine
  1094.         what size to draw its outline rectangle to.
  1095.     procedure InsertBefore(P, Target: PView);
  1096.         same as TV except:
  1097.         If P's ofCenterX or ofCenterY Option flags are set, then
  1098.         P is centered but P's Origin is adjusted so that
  1099.           if ofCenterX then P's Origin.x is a multiple of Charlen
  1100.           if ofCenterY then P's Origin.y is a multiple of Boxheight.
  1101.     procedure Lock;
  1102.         always increments the LockFlag
  1103.     procedure Redraw;
  1104.         calls MCur.LockHide to lock the mouse cursor off
  1105.         redraws the views from Last to First
  1106.         calls MCur.LockShow;
  1107.     *procedure SetClip(R : TRect);
  1108.         allows you to set the Clip variable which is used in TVGraphic
  1109.         by TView.Exposed. If a view is outside the Clip rectangle,
  1110.         Exposed will be false and calls to DrawView (or TGroup.Redraw
  1111.         which eventually calls DrawView for each view) will not draw.
  1112.     *procedure SetClipToMax;
  1113.         Calls GetExtent(R) then R.Move(VOffset.x,VOffset.y) and
  1114.         finally SetClip(R).
  1115.         This sets the Clip variable to the full size of the group
  1116.         while taking into account VOffset. Clip is maintained
  1117.         in local (group interior) coordinates. See Clip below.
  1118.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  1119.         Lock and UnLock are Not called when AState =sfActive,sfDragging:
  1120.     *procedure SetVOffset(VX,VY : integer); virtual;
  1121.         sets VOffset.x = VX, VOffset.y = VY and shifts Clip to
  1122.         match the change in VOffset. Always set VOffset by calling
  1123.         SetVOffset so Clip will be updated!
  1124.     *procedure SetZoomLevel(ZL : byte);
  1125.         reserved
  1126.     *function ShiftScreen(var Event : TEvent; var Shift : TPoint) : boolean;
  1127.                              virtual;
  1128.         returns false with no other action. Overridden in descendents
  1129.         that shift or Pan the screen.
  1130.     procedure Unlock;
  1131.         if the LockFlag > 0 then decrements the LockFlag. Does not
  1132.         make any drawing calls.
  1133.   private
  1134.     Clip: TRect;            in use in TVGraphic
  1135.         Maintained in local coordinates, not absolute screen coords!
  1136.         For a group with an Interior that is shifted by VOffset,
  1137.         Clip is maintained in the Interior's coordinate system by
  1138.         shifting its x coords by VOffset.x and shifting its y
  1139.         coords by VOffset.y. This is handled by SetVOffset.
  1140.         {If VOffset = (0,0), the group's Interior is unshifted by
  1141.          definition. Then SetClipToMax will set Clip.A to (0,0) and
  1142.          Clip.B to (Size.x,Size.y)}
  1143.     LockFlag: Byte;         in use in TVGraphic
  1144.     procedure DrawSubViews(P, Bottom: PView);
  1145.         TV draws subviews from First (top view) to Last (bottom view).
  1146.         TVGraphic draws subviews from Last to First. Parameter
  1147.         "Bottom" is actually the "Top" subview redrawn in TVGraphic.
  1148.     procedure FreeBuffer;
  1149.         returns with no action
  1150.     procedure GetBuffer;
  1151.         returns with no action
  1152.     procedure SetCurrent(P: PView; Mode: SelectMode);
  1153.         does not call Lock and UnLock.
  1154.   end;
  1155.  
  1156. ------------------------
  1157.  
  1158. THistory and related views
  1159.   These views are present but have not been converted to graphic mode.
  1160.     THistoryViewer = object(TListViewer)
  1161.     THistoryWindow = object(TWindow)
  1162.     THistory = object(TView)
  1163.       The Draw method does nothing.
  1164.  
  1165. ------------------------
  1166. + = emulates TV with exceptions noted
  1167.  
  1168. PgInputLine = ^TgInputLine
  1169. TgInputLine = object(TView)
  1170.     +constructor Init(var Bounds: TRect; AMaxLen: Integer; Opts : byte);
  1171.         Opts parameter added
  1172.           DefaultOpts        = $00;    DefaultOpts matches TV
  1173.           KillInstantErase   = $01     prevent first keystroke from erasing
  1174.           lnRightJustify     = $02;    right justify the inputline
  1175.         EventMask := EventMask + evTimerTick;
  1176.         Vfont := DefaultDialogFont;
  1177.     procedure Draw; virtual;
  1178.         rewritten
  1179.     +procedure HandleEvent(var Event: TEvent); virtual;
  1180.         Ctrl-Del deletes line
  1181.         KillInstantErase prevents first keystroke from erasing line.
  1182.     +procedure SelectAll(Enable: Boolean);
  1183.         if KillInstantErase, positions cursor at end of selected block
  1184.   end;
  1185.  
  1186. + InputLine Palette
  1187.     overall background is drawn in the background color of entries 1-2.
  1188.     background of selected text uses background of entry 3.
  1189.     InputLine outline uses background color of entry 4
  1190.     arrows indicating text extends beyond view use foreground
  1191.       color of entry 4
  1192.     cursor is fixed white color.
  1193.     text - uses entries 1-2. (If selected uses entry 2, not 3.)
  1194.  
  1195. ------------------------
  1196. * = unique to TVGraphic
  1197. + = emulates TV with exceptions noted
  1198.  
  1199. PgLabel = ^TgLabel
  1200. TgLabel = object(TgStaticText)
  1201.    +constructor Init(var Bounds : TRect; AText : String;
  1202.                          ALink : PView; Opts : byte);
  1203.        Opts: added parameter.
  1204.             Opts = DefaultOpts then matches TV
  1205.          Works like Opts parameter in StaticText except
  1206.             txCentered - flag is ignored.
  1207.             txDrawBackground - ignored, background always drawn
  1208.             txAdjustSize
  1209.                 The view's Origin will be set to Bounds.A
  1210.               The view's Size.x will be adjusted to the length of
  1211.               AText * Charlen plus BXOffset. Size.y will be set
  1212.               to Boxheight-1. Will handle text with highlighted
  1213.               characters.
  1214.                 Note that parameter Bounds will NOT be changed if this
  1215.               flag is set - you can supply a Bounds based on a
  1216.               TInputline, for example, and then later reuse the width
  1217.               of Bounds for setting another matching TInputLine.
  1218.                 Font must be uniformly spaced, 8 pixels/char such as
  1219.               Font8x8,Font8x14,SmallFont.
  1220.     procedure Draw; virtual;
  1221.         Color and Font selection same as StaticText Draw.
  1222.         Uses BYOffset in vertical positioning of text within the view.
  1223.        ! Text is indented 4 (BXOffset) pixels from left edge of view.
  1224.         If Options has ofFramed set, then draws frame around itself.
  1225.   end;
  1226.  
  1227. ------------------------
  1228.  
  1229. For TgMenu objects see TMenu objects
  1230. TgStatusLine is alpha listed as if spelled TStatusLine
  1231.  
  1232. ------------------------
  1233.  
  1234. TListBox = object(TListViewer)
  1235.     +constructor Init(var Bounds: TRect; ANumCols: Word;
  1236.                        AScrollBar: PScrollBar);
  1237.         modify to use horizontal scrollbar like in FileOpen dialog.
  1238.         TV 2.0 has same modification.
  1239.   end;
  1240.  
  1241. ------------------------
  1242. * = unique to TVGraphic
  1243. + = emulates TV with exceptions noted
  1244.  
  1245. TListViewer = object(TView)
  1246.     constructor Init(var Bounds: TRect; ANumCols: Word;
  1247.       AHScrollBar, AVScrollBar: PScrollBar);
  1248.           OldTopItem := -1;
  1249.           VFont := DefaultListViewerFont
  1250.     constructor Load(var S: TStream);
  1251.         set OldTopItem := -1 after loading standard fields
  1252.     procedure ChangeBounds(var Bounds: TRect); virtual;
  1253.         set OldTopItem := -1, then TV behavior
  1254.     procedure Draw; virtual;
  1255.         draws the complete view or just parts needing update
  1256.         depending on boolean PartialRedraw.
  1257.     *procedure DrawSelf;
  1258.         decides whether partial or complete redraw of the view
  1259.         is needed using Focused and OldTopItem. Sets boolean
  1260.         PartialRedraw and calls DrawView.
  1261.     procedure HandleEvent(var Event: TEvent); virtual;
  1262.         calls DrawSelf rather than DrawView. Other redraw limiting.
  1263.         TV 1.0 Bug fixes from TV 2.0 incorporated.
  1264.     procedure SetRange(ARange: Integer);
  1265.         set OldTopItem := -1 plus TV behavior
  1266.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  1267.         Calls TView.SetState then
  1268.         if AState is sfSelected or sfActive, calls DrawView.
  1269.         Does not affect any scrollbars.
  1270.   private
  1271.     *PartialRedraw : boolean;   {temp var}
  1272.     *OldFocused : integer; {temp variable, used with partial redraws}
  1273.     *OldTopItem : integer; {temp variable, used with partial redraws}
  1274.   end;
  1275.  
  1276. + ListViewer Palette
  1277.       background drawn in background color of entry 1
  1278.       outline of view uses background of entry 5
  1279.       vertical divider uses foreground of entry 5
  1280.       text - same as TV
  1281.  
  1282. ------------------------
  1283. * = unique to TVGraphic
  1284. + = emulates TV with exceptions noted
  1285.  
  1286. TMenuView = object(TView)
  1287.     *Target : PMenuView;  {temp var, pointer to child menu, nil if none}
  1288.     +function Execute: Word; virtual;
  1289.         heavily modified - see Menus in section with general discussion of
  1290.         view behavior. Menus are about the most convoluted code in TV -
  1291.         details will have to wait for later.
  1292.     +procedure HandleEvent(var Event: TEvent); virtual;
  1293.         added ability to snap mouse cursor to grid in BoxMenus if
  1294.         SnapToMenuGrid is true. Previous grid is saved and restored.
  1295.         Prevents redrawing if cmCommandSetChanged arrives while the
  1296.         menu is open but not modal (Help window is popped up).
  1297.     function NewSubView(var Bounds: TRect; AMenu: PMenu;
  1298.                        AParentMenu: PMenuView): PMenuView; virtual;
  1299.         code commented out
  1300.     private
  1301.     *OldCurrent  : PMenuItem;   {temp var, used in redrawing}
  1302.     *DrawPartial : boolean;    {temp var, used in redrawing}
  1303.   end;
  1304.  
  1305.   TMenuView Palette - used by all menus
  1306.         menu background is background of entry 1
  1307.         menu border color is background of entry 3
  1308.  
  1309. * PGMenu = ^TGMenu;       {Ancestor of graphical menus}
  1310. * TGMenu = object(TMenuView)
  1311.     Xsep    : integer; {number of char spaces (not pixels) between bar menu items}
  1312.         {initilize to the same value as the BarMenu Xsep for Box menus also!}
  1313.     Constructor Init(var Bounds : TRect; AMenu : PMenu);
  1314.     function NewSubView(var Bounds: TRect; AMenu: PMenu;
  1315.                             AParentMenu: PMenuView): PMenuView; virtual;
  1316.         code moved here from TMenuView.NewSubView
  1317.     *procedure FillWindow(BorderColor,AColor : integer; FatBorder : boolean);
  1318.         draws a Bar3d the size of the menu with border
  1319.     constructor Load(var S: TStream);
  1320.     procedure Store(var S: TStream);
  1321.   end;
  1322.  
  1323.  
  1324. * PGMenuBar = ^TGMenuBar;             {TVGraphic Bar Menu}
  1325. * TGMenuBar = object(TGMenu)
  1326.     +Constructor Init(var Bounds : TRect; AMenu : PMenu);
  1327.         Bounds.B.Y := Bounds.A.y + MenuBarHeight -1;
  1328.         legend separation - if there are few enough entries, the separation
  1329.           between legends will be set at 3 spaces, otherwise to 2 as in TV.
  1330.         VFont := DefaultMenuFont;
  1331.     procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
  1332.     procedure Draw; virtual;
  1333.   end;
  1334.  
  1335.  
  1336. * PGMenuBox = ^TGMenuBox;             {TVGraphic Box menu}
  1337. * TGMenuBox = object(TGMenu)
  1338.     Indent  : integer;  {legend starts this many pixels left of window edge}
  1339.     +constructor Init(var Bounds : TRect; AMenu : PMenu;
  1340.                          AParentMenu : PMenuView);
  1341.         vertical size set to (number of entries +2) times MenuBoxHeight
  1342.         Indent := Charlen;
  1343.         VFont := DefaultMenuFont;
  1344.     procedure GetItemRect(Item: PMenuItem; var R : TRect); virtual;
  1345.     procedure Draw; virtual;
  1346.         draws a cursor in left column of menu next to selected entry
  1347.         plus usual menu.
  1348.     constructor Load(var S: TStream);
  1349.     procedure Store(var S: TStream);
  1350.   end;
  1351.  
  1352. + Menu Palette
  1353.       background is drawn in background of entry 1
  1354.       border uses background of entry 3
  1355.       text - same as TV
  1356.  
  1357. ------------------------
  1358. * = unique to TVGraphic
  1359.  
  1360.   Unit GMenu
  1361.   TVGraphic view for temporarily displaying instructions at
  1362.      top edge of screen - covers MenuBar while visible.
  1363. * PGMessageBar= ^TGMessageBar;
  1364. * TGMessageBar = object(TView)
  1365.     MessageText : Str80;         {temp var, not saved}
  1366.     constructor Init;
  1367.         View is set to same size as MenuBar
  1368.         State := State and not sfVisible;    {set invisible!!}
  1369.         handles broadcast events.
  1370.         VFont := DefaultMenuFont;
  1371.     procedure Busy;
  1372.         shows message 'WORKING...'
  1373.     procedure HandleEvent(var Event : TEvent); virtual;
  1374.         responds to any cmCancel or mouse buttons by calling Hide.
  1375.     procedure Hide;
  1376.         calls MenuBar to redraw itself.
  1377.     procedure ShowText(AText : Str80);
  1378.         centers AText in the view and calls Draw.
  1379.         AText may contain sections highlighted with  ~'s.
  1380.     procedure Draw; virtual;
  1381.         uses menu palette colors. text in Selected colors.
  1382.   end;
  1383.  
  1384.   MessageBar Palette
  1385.     maps directly to the Application palette - uses menu colors
  1386.     background drawn in background color of entry 2
  1387.     outline uses background of entry 4
  1388.     normal text uses foreground of entry 5
  1389.     highlighted text uses foreground of entry 7
  1390.  
  1391. ------------------------
  1392. * = unique to TVGraphic
  1393.  
  1394.   Unit GWindow
  1395.  
  1396.   TPanWindow is a window with a viewable Interior larger than its
  1397.     Size. It is designed to pan (shift) its Interior when
  1398.     the mouse cursor reaches the edges of the screen. The usual
  1399.     way to use this window is to size it to fill the entire DeskTop
  1400.         DeskTop^.GetExtent(Bounds)
  1401.         PanWindow.Init(Bounds,...
  1402.     and then insert other TViews,TGroups,TSubWindows into the window.
  1403.     Nesting of TPanWindows is not defined, but you can insert
  1404.     more than one into the DeskTop. TPanWindow requires a MenuBar
  1405.     but not a StatusLine.
  1406.     The selected TPanWindow receives evCommand Events from the invisible
  1407.     ShiftViewPtr view when ShiftView detects the mouse cursor in the
  1408.     MenuBar or the StatusLine.
  1409.     TPanWindow calls ShiftViewPtr^.HandleEvent to update it when
  1410.     the Interior shifts or the window's State changes.
  1411.     (The ShiftViewPtr view displays messages about panning
  1412.     by calling the MessageBar view.)
  1413.  
  1414.     Sizing the PanWindow's Interior
  1415.       When the mouse cursor is on a grid, use the following rules to
  1416.       avoid offset from grid after window pans:
  1417.         Make the TPanWindow.ScrnShiftSize an integral multiple of the
  1418.         mouse cursor grid size.
  1419.         Make the TPanWindow.InteriorSize an integral multiple of the
  1420.         mouse cursor grid size minus 1.  {InteriorSize.x := N*grid -1}
  1421.  
  1422.  
  1423. * PPanWindow = ^TPanWindow;
  1424. * TPanWindow = object(TWindow)
  1425.     InteriorSize : TPoint;     {size of interior in pixels}
  1426.     Mode : byte;               {initialized to 0, reserved}
  1427.     ScrnShiftSize : TPoint;    {number of pixels to shift by}
  1428.     constructor Init(var Bounds : TRect; ATitle : TTitleStr;
  1429.         ANumber : integer; TheInteriorSize : TPoint; ThePanSteps : TPoint);
  1430.         calls TWindow.Init, then sets
  1431.           GrowMode := 0;             {Size is fixed}
  1432.           Flags := wfClose;          {window can close, not move}
  1433.           Frame^.VOptions := tfDrawBackground;
  1434.               causes Frame to draw a background for the window
  1435.           InteriorSize := TheInteriorSize;
  1436.               The size of the Interior in pixels
  1437.           ScrnShiftSize := ThePanSteps;
  1438.               The number of pixels to shift by when panning
  1439.  
  1440.     function CurAtEdge(Event : TEvent; var Delta : TPoint;
  1441.                       AllowMenuAccess : boolean) : boolean; virtual;
  1442.         Returns true if Event is a screen shifting event as defined
  1443.         below AND the Interior is able to shift in the indicated
  1444.         direction, otherwise false.
  1445.         Handles evMouseMove plus evCommand where commands
  1446.         are either cmShiftScreenDown or cmShiftScreenUp.
  1447.         Behavior at top of screen:
  1448.           >Bug if setting AllowMenuAccess false.
  1449.                panning is unreliable due to menubar eating
  1450.                mousemoves in menu but not at screen top<
  1451.           If AllowMenuAccess is false or PanWindow is the Modal view, then
  1452.           will return true when cursor is 20 pixels or less from top
  1453.           of screen, otherwise will return true only when cursor reaches
  1454.           top of screen (Y=0).
  1455.         Behavior at bottom of screen
  1456.           If PanWindow is the modal view, will
  1457.             return true when cursor goes below the window bottom
  1458.             or is greater than or equal to MCur.MaxGridY.
  1459.           OR If no StatusLine then
  1460.              returns true if cursor is greater than or equal
  1461.              to MCur.MaxGridY.
  1462.         Behavior at sides of screen
  1463.           Returns true if cursor is greater or equal to
  1464.           MCur.MaxGridX or less than or equal to MCur.MinGridX.
  1465.         Function sets Delta with number of pixels to pan by. This will be
  1466.         either the +-X or +-Y value of ScrnShiftSize. (Unless Interior
  1467.         is closer than that to its edge. In that case, Delta will be set
  1468.         with number of pixels to the edge.)
  1469.     procedure GetFullPanSize(var ISize : TPoint); virtual;
  1470.         ISize is set to InteriorSize. Called by Frame to get
  1471.         coords for outline rectangle.
  1472.     procedure HandleEvent(var Event : TEvent); virtual;
  1473.         calls TWindow.HandleEvent and then
  1474.         if Event.What is evMouseMove or evCommand, calls
  1475.           CurAtEdge. If CurAtEdge returns true, then calls
  1476.           ShiftScreen (with value of Delta from CurAtEdge
  1477.           as parameter Shift) to shift the Interior.
  1478.         Handles window commands cmNext and cmPrev.
  1479.             cmNext: SelectNext(False); (same as TV DeskTop)
  1480.             cmPrev: puts current view in front of foremost
  1481.                     non-selectable view. (usually the frame)
  1482.     function ShiftScreen(var Event : TEvent;
  1483.                       var Shift : TPoint) : boolean; virtual;
  1484.         Uses Shift to change VOffset by calling SetVOffset.
  1485.         Calls ShiftViewUpdate for vertical shifts.
  1486.         Draws the window with its interior in the new position.
  1487.         Moves the mouse cursor by the amount the Interior
  1488.         has shifted so it will be over the same spot of the
  1489.         Interior.
  1490.     procedure ShiftViewUpdate;
  1491.         Creates a Broadcast Event where Event.Command =
  1492.         cmScreenShifted and calls ShiftViewPtr^.HandleEvent;
  1493.     procedure SetState(AState : word; Enable : boolean); virtual;
  1494.         Calls ShiftViewUpDate if AState = sfSelected.
  1495.         Calls TWindow.SetState.
  1496.     procedure SetVOffset(VX,VY : integer); virtual;
  1497.         resets Vx,Vy to be multiples of the current mouse grid,
  1498.         then calls TGroup.SetVOffset.
  1499.     constructor Load(var S : TStream);
  1500.         loads the view from a stream
  1501.     procedure Store(var S : TStream);
  1502.         stores the view to a stream
  1503.   end;
  1504.  
  1505. ------------------------
  1506. + = emulates TV with exceptions noted
  1507.  
  1508. PgParamText = ^TgParamText
  1509. TgParamText = object(TgStaticText)
  1510.     +constructor Init(var Bounds: TRect; AText: String;
  1511.                      AParamCount: Integer; Opts : byte);
  1512.       Opts: added parameter - see TgStaticText description
  1513.  
  1514.     If Options has ofFramed set, then draws frame around itself.
  1515.   end;
  1516.  
  1517. ------------------------
  1518. * = unique to TVGraphic
  1519. + = emulates TV with exceptions noted
  1520.  
  1521. commands
  1522.     cmNew       = 30;
  1523.     cmOpen      = 31;
  1524.     cmSave      = 32;
  1525.     cmSaveAs    = 33;
  1526.     cmSaveAll   = 34;
  1527.     cmChangeDir = 35;
  1528.     cmDosShell  = 36;
  1529.     cmCloseAll  = 37;
  1530. help context
  1531.     hcNew        = $FF01;
  1532.     hcOpen       = $FF02;
  1533.     hcSave       = $FF03;
  1534.     hcSaveAs     = $FF04;
  1535.     hcSaveAll    = $FF05;
  1536.     hcChangeDir  = $FF06;
  1537.     hcDosShell   = $FF07;
  1538.     hcExit       = $FF08;
  1539.     hcUndo       = $FF10;
  1540.     hcCut        = $FF11;
  1541.     hcCopy       = $FF12;
  1542.     hcPaste      = $FF13;
  1543.     hcClear      = $FF14;
  1544.     hcTile       = $FF20;
  1545.     hcCascade    = $FF21;
  1546.     hcCloseAll   = $FF22;
  1547.     hcResize     = $FF23;
  1548.     hcZoom       = $FF24;
  1549.     hcNext       = $FF25;
  1550.     hcPrev       = $FF26;
  1551.     hcClose      = $FF27;
  1552.  
  1553. TProgram = object(TGroup)
  1554.     following three methods were not present in TV1.0
  1555.         function CanMoveFocus: Boolean;
  1556.         function InsertWindow(P: PWindow): PWindow;
  1557.         function ExecuteDialog(P: PDialog; Data: Pointer): Word;
  1558.  
  1559.     +constructor Init;
  1560.         size Program to full graphics screen.
  1561.         call order changed, call InitDeskTop after
  1562.         InitStatusLine,InitMenuBar
  1563.     +procedure InitDeskTop; virtual;
  1564.         Sizes DeskTop to fill space between the MenuBar and the StatusLine.
  1565.         {User does not have to have a MenuBar or StatusLine.}
  1566.     procedure InitMenuBar; virtual;
  1567.         never call - always override or don't call at all
  1568.     +procedure InitStatusLine; virtual;
  1569.         sets vertical size to MenuBoxheight. Usually overridden.
  1570.     *procedure SetPalette(Pal : TPalette);
  1571.        replaces the Application palette (the colors) for the
  1572.        current screen mode with palette Pal
  1573.     procedure SetScreenMode(Mode: Word);
  1574.         shortened to SetVideoMode(Mode);
  1575.                      DoneMemory;
  1576.                      InitScreen;
  1577.         Do not call this method while in BGI graphics mode!
  1578.   end;
  1579.  
  1580. ------------------------
  1581.  
  1582. TRadioButtons = object(TCluster)   unmodified
  1583.  
  1584. ------------------------
  1585. + = emulates TV with exceptions noted
  1586.  
  1587. TRect
  1588.   +procedure Intersect(R: TRect);
  1589.       adjust to match graphic coord system
  1590.   +function  Empty : boolean;
  1591.       adjust to match graphic coord system
  1592.       Note - a rectangle with all four coords equal is NOT empty
  1593.         in TVGraphic. It is a point.
  1594.       An empty rectangle is not set to all zeros -
  1595.         Always call Empty function to check for empty.
  1596.   +function Contains : boolean;
  1597.       adjust to match graphic coord system
  1598.  
  1599. ------------------------
  1600. * = unique to TVGraphic
  1601. + = emulates TV with exceptions noted
  1602.  
  1603. const for TScrollBar
  1604.   CharHt  = 14;   not user changable
  1605.     Scrollbars make alot of calculations based on assumptions
  1606.     about character size.  For these calculations, a scrollbar
  1607.     thinks in terms of characters that are 8 pixels wide by 14
  1608.     pixels tall. If your horizontal scrollbar Size is not a
  1609.     multiple of 8 pixels or vertical bar is not a multiple of
  1610.     14 pixels, then the indicator will not go all the way to
  1611.     the right/bottom of the bar.
  1612.     Things still work however.
  1613.     You will not normally have to think about this.
  1614.  
  1615. TScrollBar = object(TView)
  1616.     constructor Init(var Bounds: TRect);
  1617.         If Bounds is wider than it is tall, the scrollbar will be
  1618.         initialized as a horizontal scrollbar, otherwise as vertical.
  1619.         The thickness of the scrollbar is set using the constant
  1620.         ScrollBarWidth independent of Bounds or whether a vertical
  1621.         or horizontal bar. The actual thickness is ScrollBarWidth
  1622.         plus one pixels.
  1623.         The scrollbar moving indicator character has changed.
  1624.         Refer to TV documentation for the rest.
  1625.         VFont is set to Font8x8. Other fonts are not likely to work!
  1626.     procedure Draw; virtual;     unchanged
  1627.     *function Exposed : boolean; virtual;
  1628.         added to handle Panning windows.
  1629.     *procedure MakeLocal(Source: TPoint; var Dest: TPoint); virtual;
  1630.         added to handle Panning windows.
  1631.     *procedure SetState(AState: Word; Enable: Boolean); virtual;
  1632.         calls TView.SetState and then calls DrawView if AState=sfActive.
  1633.         Note that this means a scrollbar changes sfActive State
  1634.         independently and DOES NOT require a TScroller view be present.
  1635.   private
  1636.     procedure DrawPos(Pos: Integer);
  1637.         does the actual drawing, modified for graphics
  1638.         Draws only the scrollbar (blue) background if not Active.
  1639.   end;
  1640.  
  1641. + ScrollBar Palette
  1642.     overall background is drawn in background of entry 1
  1643.     crosshatch is drawn using foreground of entry 1
  1644.     indicators and arrows - same as TV
  1645.  
  1646. ------------------------
  1647. * = unique to TVGraphic
  1648. + = emulates TV with exceptions noted
  1649.  
  1650. TScroller = object(TView)
  1651.     procedure ChangeBounds(var Bounds: TRect); virtual;
  1652.         does NOT redraw the view
  1653. *   procedure PartOfSetLimit(X, Y : integer); virtual;
  1654.              {Important - New with version 1.5!}
  1655.       sets Limit field to X,Y and calls SetParams for vertical and
  1656.       horizontal scrollbars, if present. By overriding, the
  1657.       programmer can set up a scroller for ANY vertical and
  1658.       horizontal text spacing (or drawing grid spacing).
  1659.       See full example of this in Demo program.
  1660.       TScroller.PartOfSetLimit sets up a scroller and scrollbars
  1661.       to step pixel by pixel. It causes SetLimit to require parameters
  1662.       X and Y in screen (pixel) coords, not text coords.
  1663. +   procedure SetLimit(X, Y : integer); virtual;
  1664.       calls PartOfSetLimit to allow overriding of SetLimit code
  1665.       now transfered to PartOfSetLimit.
  1666.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  1667.         calls TView.SetState. Does not have any affect on
  1668.         any scrollbars pointed to by fields HScrollBar or VScrollBar.
  1669.         See TVGraphic's TScrollBar.SetState
  1670.   end;
  1671.  
  1672. ------------------------
  1673. * = unique to TVGraphic
  1674.  
  1675.   TShiftView, Unit GWindow
  1676.   Special view for sensing mouse position at top edge of screen
  1677.   and within the StatusLine, if one exists.
  1678.   If cursor enters these areas and the selected window is a
  1679.   TPanWindow and its interior can shift, then Shiftview uses
  1680.   the MessageBar to display message about panning to user.
  1681.   If right button is clicked in these areas, ShiftView issues
  1682.   commands targeted at TPanWindow. These commands will cause the
  1683.   TPanWindow's Interior to shift down if cursor is at top of
  1684.   screen or up if cursor is in StatusLine.
  1685.   ShiftView uses the MessageBar to display its messages -
  1686.     so application must initialize the MessageBar.
  1687.  
  1688. * PShiftView = ^TShiftView;
  1689. * TShiftView = object(TView)
  1690.     ScreenIsShiftedDown : boolean;   read only
  1691.     ScreenIsShiftedUp : boolean;     read only
  1692.     MessageDisplayed : boolean;      read only
  1693.     constructor Init(var Bounds: TRect);
  1694.         calls TView.Init whic sets the booleans fields false.
  1695.         then sets EventMask := EventMask or evMouseMove or evBroadcast;
  1696.     procedure HandleEvent(var Event : TEvent); virtual;
  1697.         responds to broadcasts of (Event.Command = cmScreenShifted)
  1698.         by checking the InfoWord. If upper or lower byte = 'T' then
  1699.         sets either ScreenIsShiftedDown,ScreenIsShiftedUp.
  1700.         MouseEvents
  1701.           evMousemove
  1702.             if cursor is at top of screen or in StatusLine,
  1703.             then displays message
  1704.                'CLICK RIGHT BUTTON TO PAN SCREEN'
  1705.             Clears the message if cursor moves out of these
  1706.             areas.
  1707.           evMouseDown and right button
  1708.             if cursor is at top of screen or in StatusLine,
  1709.             then issues a evCommand event with either
  1710.             Command = cmShiftScreenDown or cmShiftScreenUp
  1711.         Uses the MessageBar to display its messages.
  1712.     constructor Load(var S : TStream);
  1713.         loads the view from a stream
  1714.     procedure Store(var S : TStream);
  1715.         stores the view on a stream
  1716.   end;
  1717.  
  1718. ------------------------
  1719. * = unique to TVGraphic
  1720. + = emulates TV with exceptions noted
  1721.  
  1722. PgStaticText = ^TgStaticText
  1723. TgStaticText = object(TView)
  1724.     +constructor Init(var Bounds : TRect; AText : String; Opts : byte);
  1725.         OPts:  added parameter
  1726.            (examples:  OPts := DefaultOpts; DefaultOpts matches TV
  1727.                        Opts := txCentered + txDrawBackground)
  1728.         DefaultOpts -  no options
  1729.         txCentered - if width of AText will fit in the view's Bounds,
  1730.                    centers text horizontally in Bounds and then
  1731.                    shrinks Bounds.A.x,Bounds.B.x to just contain AText.
  1732.                    Works with any font.
  1733.         txAdjustSize - if width of AText will fit in the view's Bounds
  1734.                    adjusts Bounds.B.x to just contain AText. Works
  1735.                    with any font.
  1736.         txDrawBackground - for maximum speed and minimum flicker, StaticText
  1737.                    does Not normally draw a background in TVGraphic. This is
  1738.                    almost never a problem with the short strings in Dialogs.
  1739.                    If you use a StaticText view wider than the narrowest
  1740.                    window/dialog  you will ever drag across it, then you need
  1741.                    a background for partial screen redraws. Use this flag.
  1742.         
  1743.       VColor is set to TVColor which causes Draw to use the palette
  1744.           instead of VColor for color slection. To override, after Init
  1745.           set VColor to desired color pair (byte). Format is the same as
  1746.           Application palette entries.
  1747.       Font selection - if lower 4 bits of Opts are not 0, then VFont
  1748.           is set to equal to the lower four bits which represent a font
  1749.           number. If 0, then VFont is set to DefaultDialogFont.
  1750.           (Note this precludes your using the BGI DefaultFont which does
  1751.           not clip properly.)
  1752.       String Formating
  1753.               If multiple lines, view will draw them spaced Boxheight apart.
  1754.           AText may have the usual embedded formating characters ^M and ^C.
  1755.               ^C centers following text (up to a ^M) in the view.
  1756.               ^M causes following text to start on a new line.
  1757.            The automatic line wrapping at the right side of the view and
  1758.               the ^C centering of text assume the selected text font
  1759.               is 8 pixels wide/character.
  1760.  
  1761.     procedure Draw; virtual;
  1762.       If multiple lines, view will draw them spaced Boxheight apart.
  1763.       Uses the palette for colors unless VColor is not equal to TVColor.
  1764.         Then uses the color pair in the lower byte of VColor for
  1765.         text color and background.
  1766.       Uses the text font stored in VFont.
  1767.       Uses BYOffset in vertical positioning of text within the view.
  1768.       ! Text is indented 4 pixels from left edge of view.
  1769.       If Options has ofFramed set, then draws frame around itself.
  1770.   end;
  1771.  
  1772. ------------------------
  1773. * = unique to TVGraphic
  1774. + = emulates TV with exceptions noted
  1775.  
  1776. TgStatusLine = object(TView)
  1777.     +constructor Init(var Bounds: TRect; ADefs: PStatusDef);
  1778.         VFont := DefaultMenuFont;
  1779.     procedure Draw; virtual;      {unmodified - calls DrawSelect}
  1780.     +procedure HandleEvent(var Event: TEvent); virtual;
  1781.          passes right mouse button presses through with no action.
  1782.          NOTE: when the StatusLine issues a command due to keypress's and
  1783.            mouse buttons, TVGraphic sets the InfoPtr to Ptr(0000,0001)
  1784.            versus TV which sets it to nil.
  1785.            The change enables future implementation of TVGraphic features.
  1786.   private
  1787.     procedure DrawSelect(Selected: PStatusItem);   {rewritten for graphics}
  1788.   end;
  1789.  
  1790. ------------------------
  1791. * = unique to TVGraphic
  1792. + = emulates TV with exceptions noted
  1793.  
  1794.   Unit GWindow
  1795.   TSubWindow is an ordinary window except for its GetPalette function.
  1796.   Use TSubWindow (or a descendant) when inserting a window into another
  1797.   window to get correct drawing colors. TSubWindow will also work in
  1798.   any situation where a regular TWindow works.
  1799.  
  1800.   NOTE: With version 1.5, it is no longer necessary or desirable to
  1801.         override GetPalette if you create a descendent of TSubWindow.
  1802.         Previous overrides should be removed or modified.
  1803.  
  1804. * PSubWindow = ^TSubWindow;     {can be inserted into a window}
  1805. * TSubWindow = object(TWindow)
  1806.     +function GetPalette : PPalette; virtual;
  1807.         usual behavior unless window's owner is a TWindow or
  1808.         descendant (VOPtions and twIsWindow <> 0).
  1809.         In these cases, GetPalette returns nil.
  1810.   end;
  1811.  
  1812.  
  1813. ------------------------
  1814. * = unique to TVGraphic
  1815. + = emulates TV with exceptions noted
  1816.  
  1817.   In unit GObjects.
  1818.   A simple collection of strings using PString pointers.
  1819.   Use function NewStr(AString) to create a string and return
  1820.   a PString pointer. Insert the pointer into the collection.
  1821.   The collection knows how to store, load and dispose of strings.
  1822.  
  1823. * PUnSortedStringCollection = ^TUnSortedStringCollection;
  1824. * TUnSortedStringCollection = object(TCollection)
  1825.     +procedure FreeItem(Item : Pointer); virtual;
  1826.         same as TStringCollection
  1827.     +function GetItem(var S : TStream) : pointer; virtual;
  1828.         same as TStringCollection
  1829.     +procedure PutItem(var S : TStream; Item : pointer); virtual;
  1830.         same as TStringCollection
  1831.   end;
  1832.  
  1833. ------------------------
  1834. * = unique to TVGraphic
  1835. + = emulates TV with exceptions noted
  1836.  
  1837. TView = object(TObject)
  1838.     *Hook   : TUserRec;   {not used by TVGraphic - for users of TVGraphic}
  1839.     *VColor : word;       {color pair(s) if overriding palette selection}
  1840.     *VFont    : byte;     {for text font storage}
  1841.     *VOptions : byte;     {TVGraphics options}
  1842.     *VOffset : TPoint;    {used to offset the screen across a graphical
  1843.                             view that is larger then the screen.}
  1844.                           {Used by MakeLocal,MakeGlobal,Exposed}
  1845.     *ZoomLevel : byte;    {reserved by TVGraphics}
  1846.  
  1847.     +constructor Load(var S: TStream);
  1848.         loads added fields
  1849.     *function BackColor(Color: Word): byte;
  1850.         Expects Color to be a color pair from the palette.
  1851.         returns bits 4-7 of Color in lower 4 bits of the byte
  1852.  !  +procedure ChangeBounds(var Bounds: TRect); virtual;
  1853.         ChangeBounds does NOT redraw the view. Merely calls SetBounds.
  1854.     +procedure DragView(Event: TEvent; Mode: Byte;
  1855.         var Limits: TRect; MinSize, MaxSize: TPoint);
  1856.         Lock cursor while dragging,
  1857.         calls DrawView after dragging.
  1858.         when using arrow keys to move, jump is based on current mouse grid.
  1859.         Shift arrow keys change size.
  1860.         Bug if you move and resize and then hit escape to undo.
  1861.     +procedure Draw; virtual;
  1862.         does nothing
  1863.     +procedure DrawView;
  1864.         modified for blinking cursor
  1865.     +function Exposed: Boolean; virtual;
  1866.         made virtual;
  1867.         true if (Owner<>nil) and (sfExposed and sfVisible are set) and
  1868.            Owner^.LockFlag = 0 and
  1869.            intersection of view outline with Owner^.Clip <> empty.
  1870.     +procedure GetClipRect(var Clip: TRect);
  1871.         returns Clip in local coordinates,modified to work with VOffset.
  1872.     *function ForeColor(Color: Word): byte;
  1873.         Expects Color to be a color pair from the palette.
  1874.         returns bits 0-3 of Color in lower 4 bits of the byte
  1875.     *procedure GetScreenCoords(var R : TRect);
  1876.         sets R to the absolute screen coords of the outline of the view.
  1877.               (same coord system as BGI and mouse)
  1878.         Takes VOffset of all Owners in the view chain into account.
  1879.         R.A is upper left corner, R.B is lower right corner.
  1880.         These coords are useful for setting the viewport to match
  1881.         the outline of the view.
  1882.     *procedure GetVPRelCoords(var R : TRect);
  1883.         same as GetScreenCoords except R is Viewport relative.
  1884.         Example: Passing R to the Rectangle call will draw a
  1885.         rectangle outlining the view independent of the
  1886.         viewport setting. Of course if the viewport is too small,
  1887.         the rectangle will be clipped. If the viewport is
  1888.         set to full screen, GetVPRelCoords returns same numbers
  1889.         as GetScreenCoords.
  1890.     +procedure HandleEvent(var Event: TEvent);
  1891.         handles evTimerTick to blink the text cursor
  1892.     *function HorzTextOffset : integer; virtual;
  1893.         returns 0. Override if necessary in your descendants that
  1894.         use the blinking text cursor.
  1895.     procedure HideCursor;
  1896.         same code as TV but the effect is to erase the blinking
  1897.         cursor And Restore the Background Underneath It.
  1898.         See also ResetCursor.
  1899.     +procedure Locate(var Bounds: TRect);
  1900.         implements partial redraws, major design changes
  1901.     +procedure MakeGlobal(Source: TPoint; var Dest: TPoint);
  1902.         rewritten
  1903.         coordinate transformation Source to Dest.
  1904.         Source should be in view's local coordinate system -
  1905.         if view is a descendent of TGroup, then Source should be
  1906.           in the coordinate system of the view's Interior.
  1907.           (If VOffset = 0,0  local and Interior coords match.)
  1908.         Dest is in absolute screen coords (mouse coords)
  1909.         Takes VOffset of all Owners in the view chain into account.
  1910.     +procedure MakeLocal(Source: TPoint; var Dest: TPoint); Virtual;
  1911.         rewritten, made virtual;
  1912.         coordinate transformation Source to Dest.
  1913.         Source should be in absolute screen coords (mouse coords).
  1914.         Dest is in coordinate system of view or in coordinate
  1915.           system of view's Interior if view is TGroup descendent.
  1916.           (If VOffset = 0,0  local and Interior coords match.)
  1917.         Takes VOffset of all Owners in the view chain into account.
  1918.     +function MouseInView(Mouse: TPoint): Boolean; virtual;
  1919.         made virtual;
  1920.     +procedure PutInFrontOf(Target: PView);
  1921.         modified to work in graphic mode
  1922.     *procedure ResetCursor(EraseIt : boolean); virtual;
  1923.         was Private method, now public and virtual.
  1924.         prior to ver1.5, performed no action. Now in use.
  1925.         Parameter EraseIt added in ver 1.5
  1926.  
  1927.         IMPORTANT - if the cursor is visible and you are about to
  1928.           redraw your view so the background under the cursor will
  1929.           be different, AND you are not calling DrawView to redraw,
  1930.           then call ResetCursor(True). {Or call SetCursor}
  1931.           (HandleEvent will call ResetCursor(false) to draw the cursor
  1932.            at the next evTimerTick event if the view is focused.)
  1933.  
  1934.         Erases and Draws standard TV/TVGraphic blinking text cursor.
  1935.         Call with EraseIt = True to erase cursor just before redrawing.
  1936.  
  1937.         Calls new virtual functions VertTextOffset and VertTextSpacing
  1938.           to know how to position cursor vertically on screen.
  1939.         Calls HorzTextOffset to help position itself horizontally.
  1940.         Looks at the font name stored in VFont to determine the
  1941.           vertical size of the font you are using.
  1942.         Assumes horizontal spacing of 8 pixels/char.
  1943.         Will not draw unless view's EventMask includes evTimerTick.
  1944.     procedure Select;
  1945.         fix TV 1.0 bug, add test that view is selectable before selecting
  1946.     +procedure SetCursor(X, Y: Integer);
  1947.         Erases the blinking cursor at the current location (if visible)
  1948.           by calling ResetCursor(true).
  1949.         Sets the Cursor field (cursor position) to X,Y.
  1950.         See notes under ResetCursor.
  1951.     +procedure SetState(AState: Word; Enable: Boolean); virtual;
  1952.         calls when AState = sfVisible to ResetCurrent are modified
  1953.         to work in graphics mode.
  1954.     +procedure Store(var S: TStream);
  1955.         stores added fields
  1956.     *function  UserHook(var P : Pointer; var Hk : TUserRec):boolean; virtual;
  1957.         provided for TVGraphic users to override in descendents.
  1958.         TView version returns false and does not change its parameters.
  1959.     *function VertTextOffset : integer; virtual;
  1960.         Temporarily sets BGI TextStyle to font stored in field VFont
  1961.           by calling SetTextStyle(VFont, horizdir, 1),
  1962.           calls CalcVertTextOffset(VertTextSpacing) to find value,
  1963.           and restores previous font.
  1964.         For font8x8 and font8x14 used with VertTextSpacing = Boxheight,
  1965.           VertTextOffset returns the same value as global ByOffset.
  1966.         Used by the blinking cursor.
  1967.         Override if you need a different vertical offset for the cursor.
  1968.     *function VertTextSpacing : integer; virtual;
  1969.         returns constant Boxheight. Used by blinking cursor.
  1970.         Override if your view's vertical text spacing differs from
  1971.         Boxheight and you want cursor to match.
  1972.      {Following methods are not present in TVGraphic:
  1973.         procedure WriteBuf(X, Y, W, H: Integer; var Buf);
  1974.         procedure WriteChar(X, Y: Integer; C: Char; Color: Byte;
  1975.                              Count: Integer);
  1976.         procedure WriteLine(X, Y, W, H: Integer; var Buf);
  1977.         procedure WriteStr(X, Y: Integer; Str: String; Color: Byte); }
  1978.   private
  1979.     *procedure DrawUnderRect(var R: TRect; LastView: PView);
  1980.          totally different design. Minimizes number of redrawn views.
  1981.  
  1982.     made public - procedure ResetCursor;
  1983.   end;
  1984.  
  1985. ------------------------
  1986. * = unique to TVGraphic
  1987.  
  1988.   Unit GWindow
  1989.   TWinBackground is a simple view for providing a background
  1990.   in a window. It will work with or without a Frame in the window.
  1991.  
  1992. * PWinBackground = ^TWinBackground;
  1993. * TWinBackground = object(TView)
  1994.     constructor Init(var Bounds: TRect);
  1995.         calls TView.Init, then sets
  1996.           GrowMode := gfGrowHiX + gfGrowHiY;
  1997.           EventMask := 0;
  1998.           VColor := TVColor;
  1999.     procedure Draw; virtual;
  2000.         fills view with solid color.
  2001.         If VColor = TVColor then color from palette will match
  2002.         the color that TFrame will use (if one is present) for
  2003.         its background. Otherwise will use VColor as background color.
  2004.   end;
  2005.  
  2006. ------------------------
  2007. * = unique to TVGraphic
  2008. + = emulates TV with exceptions noted
  2009.  
  2010. TWindow = object(TGroup)
  2011.     +constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
  2012.         sfShadow flag in State is not set.
  2013.     *procedure Draw;  virtual;
  2014.         hides and locks the mouse cursor
  2015.         Sets viewport to the intersection of Clip and the window outline.
  2016.         Calls TFrame.Draw if dragging, otherwise TGroup.Draw.
  2017.         Restores the viewport to previous size and unlocks the mouse cursor.
  2018.     *procedure GetMaxSubViewSize(var R : TRect); virtual;
  2019.         {was named GetInteriorSize prior to ver1.5}
  2020.         if Frame <> nil then calls Frame^.GetInteriorSize(R),
  2021.         otherwise calls GetExtent(R) and then shrinks R by one pixel
  2022.         on all four sides to allow for an outline rectangle for the window.
  2023.     +procedure HandleEvent(var Event: TEvent); virtual;
  2024.         cmClose - also responds if Event.InfoPtr = Ptr(0000,0001) which
  2025.                   indicates sender was the scrollbar.
  2026.         cmZoom - did not check InfoPtr before ver1.5, now responds if
  2027.           InfoPtr is nil, @Self or Ptr(0000,0001).
  2028.     +procedure SetState(AState: Word; Enable: Boolean); virtual;
  2029.         rewritten for nested windows. Same behavior as TV except
  2030.         No action if AState = sfActive. Sets its own and its subview's
  2031.         sfActive bit to match window's sfSelected bit.
  2032.     +function StandardScrollBar(AOptions: Word): PScrollBar;
  2033.         if the window has a Frame then the Frame's VOption field
  2034.         is set with tfVScrollBar or tfHScrollBar depending on AOptions.
  2035.         Next the scrollbar is sized and its width is set using constant
  2036.         ScrollBarWidth. A new scrollbar is created and inserted into the
  2037.         window. If AOptions includes sbHandleKeyboard, the scrollbar
  2038.         Options are set to include ofPostProcess. Finally a pointer to
  2039.         the scrollbar is returned as the value of StandardScrollBar.
  2040.   end;
  2041.  
  2042. + Window Palettes
  2043.     Window palettes are extended to map TV1 (TV2 graydialog) dialog palette.
  2044.     These extensions are used by the modified TDialog.GetPalette and
  2045.       may change in the next revision of TVGraphic.
  2046.  
  2047.     CBlueWindow = #8#9#10#11#12#13#14#15 + CxDialog;
  2048.     CCyanWindow = #16#17#18#19#20#21#22#23 + CxDialog;
  2049.     CGrayWindow = #24#25#26#27#28#29#30#31  + CxDialog;
  2050.  
  2051.     CxDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47+
  2052.                #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
  2053.