Browse Source

* view redrawing and small cursor updates
* merged some more FV extensions

peter 24 years ago
parent
commit
9645de9a5c

+ 85 - 10
fv/app.pas

@@ -55,10 +55,12 @@ USES
    {$IFDEF OS_OS2}                                    { OS2 CODE }
      Os2Def, Os2Base, OS2PmApi,                       { Standard units }
    {$ENDIF}
-
+   Dos,
+   Video,
    GFVGraph,                                          { GFV standard unit }
    FVCommon, Memory,                                    { GFV standard units }
-   Objects, Drivers, Views, Menus, HistList, Dialogs; { GFV standard units }
+   Objects, Drivers, Views, Menus, HistList, Dialogs,
+   MsgBox;
 
 {***************************************************************************}
 {                              PUBLIC CONSTANTS                             }
@@ -227,11 +229,13 @@ TYPE
       PROCEDURE Run; Virtual;
       PROCEDURE Idle; Virtual;
       PROCEDURE InitScreen; Virtual;
+      procedure DoneScreen; virtual;
       PROCEDURE InitDeskTop; Virtual;
       PROCEDURE OutOfMemory; Virtual;
       PROCEDURE InitMenuBar; Virtual;
       PROCEDURE InitStatusLine; Virtual;
       PROCEDURE SetScreenMode (Mode: Word);
+      PROCEDURE SetScreenVideoMode(const Mode: TVideoMode);
       PROCEDURE PutEvent (Var Event: TEvent); Virtual;
       PROCEDURE GetEvent (Var Event: TEvent); Virtual;
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
@@ -250,6 +254,7 @@ TYPE
       PROCEDURE DosShell;
       PROCEDURE GetTileRect (Var R: TRect); Virtual;
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
+      procedure WriteShellMsg; virtual;
    END;
    PApplication = ^TApplication;                      { Application ptr }
 
@@ -346,7 +351,7 @@ CONST
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 
   uses
-    Video,Mouse;
+    Mouse,Resource;
 
 {***************************************************************************}
 {                        PRIVATE DEFINED CONSTANTS                          }
@@ -654,6 +659,7 @@ BEGIN
      -(GetMaxY(TextModeGFV)+1));                      { Full screen area }
    Inherited Init(R);                                 { Call ancestor }
    Application := @Self;                              { Set application ptr }
+   Drivers.InitVideo;
    InitScreen;                                        { Initialize screen }
    State := sfVisible + sfSelected + sfFocused +
       sfModal + sfExposed;                            { Deafult states }
@@ -662,12 +668,12 @@ BEGIN
    Size.Y := ScreenHeight;                            { Set y size value }
    RawSize.X := ScreenWidth * SysFontWidth - 1;       { Set rawsize x }
    RawSize.Y := ScreenHeight * SysFontHeight - 1;     { Set rawsize y }
-   InitStatusLine;                                    { Init status line }
-   If (StatusLine <> Nil) Then Insert(StatusLine);    { Insert status line }
-   InitMenuBar;                                       { Create a bar menu }
-   If (MenuBar <> Nil) Then Insert(MenuBar);          { Insert menu bar }
    InitDesktop;                                       { Create desktop }
+   InitStatusLine;                                    { Create status line }
+   InitMenuBar;                                       { Create a bar menu }
    If (Desktop <> Nil) Then Insert(Desktop);          { Insert desktop }
+   If (StatusLine <> Nil) Then Insert(StatusLine);    { Insert status line }
+   If (MenuBar <> Nil) Then Insert(MenuBar);          { Insert menu bar }
 END;
 
 {--TProgram-----------------------------------------------------------------}
@@ -802,6 +808,14 @@ BEGIN
   Buffer := Views.PVideoBuf(VideoBuf);
 END;
 
+
+procedure TProgram.DoneScreen;
+begin
+  DoneVideo;
+  Buffer:=nil;
+end;
+
+
 {--TProgram-----------------------------------------------------------------}
 {  InitDeskTop -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB       }
 {---------------------------------------------------------------------------}
@@ -850,8 +864,38 @@ END;
 {  SetScreenMode -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Oct99 LdB     }
 {---------------------------------------------------------------------------}
 PROCEDURE TProgram.SetScreenMode (Mode: Word);
-BEGIN                                                 { Compatability only }
-END;
+var
+  R: TRect;
+begin
+  if TextModeGFV then
+   begin
+     HideMouse;
+     DoneMemory;
+     InitMemory;
+     InitScreen;
+     Buffer := Views.PVideoBuf(VideoBuf);
+     R.Assign(0, 0, ScreenWidth, ScreenHeight);
+     ChangeBounds(R);
+     ShowMouse;
+   end;
+end;
+
+procedure TProgram.SetScreenVideoMode(const Mode: TVideoMode);
+var
+  R: TRect;
+begin
+  DoneMouse;
+  DoneMemory;
+  ScreenMode:=Mode;
+  Video.SetVideoMode(Mode);
+  InitMouse;
+  InitMemory;
+  InitScreen;
+  Buffer := Views.PVideoBuf(VideoBuf);
+  R.Assign(0, 0, ScreenWidth, ScreenHeight);
+  ChangeBounds(R);
+  ShowMouse;
+end;
 
 {--TProgram-----------------------------------------------------------------}
 {  PutEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB          }
@@ -928,7 +972,15 @@ BEGIN
    Drivers.InitEvents;                                        { Start event drive }
    Drivers.InitSysError;                                      { Start system error }
    InitHistory;                                       { Start history up }
+   InitResource;
+   InitMsgBox;
    Inherited Init;                                    { Call ancestor }
+   if (TextModeGFV) then
+    begin
+      { init mouse and cursor }
+      Video.SetCursorType(crHidden);
+      Mouse.SetMouseXY(1,1);
+    end;
 END;
 
 {--TApplication-------------------------------------------------------------}
@@ -969,6 +1021,19 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE TApplication.DosShell;
 BEGIN                                                 { Compatability only }
+  DoneSysError;
+  DoneEvents;
+  DoneScreen;
+  DoneDosMem;
+  WriteShellMsg;
+  SwapVectors;
+  Exec(GetEnv('COMSPEC'), '');
+  SwapVectors;
+  InitDosMem;
+  InitScreen;
+  InitEvents;
+  InitSysError;
+  Redraw;
 END;
 
 {--TApplication-------------------------------------------------------------}
@@ -997,6 +1062,12 @@ BEGIN
    End;
 END;
 
+procedure TApplication.WriteShellMsg;
+begin
+  PrintStr(Strings^.Get(sTypeExitOnReturn));
+end;
+
+
 {***************************************************************************}
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
@@ -1088,7 +1159,11 @@ END;
 END.
 {
  $Log$
- Revision 1.12  2001-08-04 19:14:32  peter
+ Revision 1.13  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.12  2001/08/04 19:14:32  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 7 - 1
fv/buildfv.pas

@@ -8,6 +8,7 @@ interface
 uses
   fvcommon,
   objects,
+  callspec,
   drivers,
   fileio,
   memory,
@@ -27,6 +28,7 @@ uses
   statuses,
   histlist,
   inplong,
+  editors,
   gadgets,
   time;
 
@@ -35,7 +37,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.1  2001-08-04 19:14:32  peter
+  Revision 1.2  2001-08-05 02:03:13  peter
+    * view redrawing and small cursor updates
+    * merged some more FV extensions
+
+  Revision 1.1  2001/08/04 19:14:32  peter
     * Added Makefiles
     * added FV specific units and objects from old FV
 

+ 14 - 2
fv/dialogs.pas

@@ -2056,6 +2056,12 @@ BEGIN
      AStrings := AStrings^.Next;                      { Move to next item }
      Dispose(P);                                      { Dispose prior item }
    End;
+   Sel := 0;
+   if TextModeGFV then
+    begin
+      SetCursor(2,0);
+      ShowCursor;
+    end;
    EnableMask := $FFFFFFFF;                           { Enable bit masks }
 END;
 
@@ -2223,6 +2229,8 @@ BEGIN
      End;
      WriteBuf(K, K+I, Size.X-K-K, 1, B);              { Write buffer }
    End;
+  if TextModeGFV then
+    SetCursor(Column(Sel)+2,Row(Sel));
 END;
 
 {--TCluster-----------------------------------------------------------------}
@@ -2481,7 +2489,7 @@ PROCEDURE TRadioButtons.DrawFocus;
 CONST Button = ' ( ) ';
 BEGIN
    Inherited DrawFocus;
-   DrawMultiBox(Button, #32#7);                       { Redraw the text }
+   DrawMultiBox(Button, ' *');                       { Redraw the text }
 END;
 
 {--TRadioButtons------------------------------------------------------------}
@@ -4171,7 +4179,11 @@ END;
 END.
 {
  $Log$
- Revision 1.11  2001-08-04 19:14:32  peter
+ Revision 1.12  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.11  2001/08/04 19:14:32  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 7 - 3
fv/drivers.pas

@@ -240,7 +240,7 @@ TYPE
           Where: TPoint);                             { Mouse position }
         evKeyDown: (                                  { ** KEY EVENT ** }
           Case Sw_Integer Of
-            0: (KeyCode: Sw_Word);                       { Full key code }
+            0: (KeyCode:  Word);                       { Full key code }
             1: (CharCode: Char;                       { Char code }
                 ScanCode: Byte;                       { Scan code }
                 KeyShift: byte));                     { Shift states }
@@ -351,7 +351,7 @@ Returns the ascii character for the Ctrl+Key scancode that was given.
 FUNCTION GetCtrlChar (KeyCode: Word): Char;
 
 {-CtrlToArrow--------------------------------------------------------
-Converts a Sw_WordStar-compatible control key code to the corresponding
+Converts a WordStar-compatible control key code to the corresponding
 cursor key code.
 25May96 LdB
 ---------------------------------------------------------------------}
@@ -1474,7 +1474,11 @@ BEGIN
 END.
 {
  $Log$
- Revision 1.11  2001-08-04 19:14:33  peter
+ Revision 1.12  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.11  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 6 - 2
fv/fvcommon.pas

@@ -130,7 +130,7 @@ TYPE
    Sw_Integer = Integer;                              { Standard integer }
 {$ENDIF}
 {$IFDEF BIT_32}                                       { 32 BIT DEFINITIONS }
-   Sw_Word    = LongInt;                              { Long integer now }
+   Sw_Word    = Cardinal;                             { Long integer now }
    Sw_Integer = LongInt;                              { Long integer now }
 {$ENDIF}
 
@@ -416,7 +416,11 @@ END;
 END.
 {
  $Log$
- Revision 1.1  2001-08-04 19:14:33  peter
+ Revision 1.2  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.1  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 6 - 2
fv/fvconsts.pas

@@ -63,7 +63,7 @@ const
   idBrowseButton = 24;
   idEditListBox = 25;
   idModalInputLine = 26;
-  idListDlg = 27;
+  idListDlg = 28;
 
   { App Unit }
   idBackground = 30;
@@ -624,7 +624,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.1  2001-08-04 19:14:33  peter
+  Revision 1.2  2001-08-05 02:03:13  peter
+    * view redrawing and small cursor updates
+    * merged some more FV extensions
+
+  Revision 1.1  2001/08/04 19:14:33  peter
     * Added Makefiles
     * added FV specific units and objects from old FV
 

+ 89 - 8
fv/gadgets.pas

@@ -105,10 +105,18 @@ USES FVConsts, Time, Objects, Drivers, Views, App;      { Standard GFV units }
 {                  THeapView OBJECT - ANCESTOR VIEW OBJECT                  }
 {---------------------------------------------------------------------------}
 TYPE
+   THeapViewMode=(HVNormal,HVComma,HVKb,HVMb);
+
    THeapView = OBJECT (TView)
+         Mode   : THeapViewMode;
          OldMem: LongInt;                             { Last memory count }
+      constructor Init(var Bounds: TRect);
+      constructor InitComma(var Bounds: TRect);
+      constructor InitKb(var Bounds: TRect);
+      constructor InitMb(var Bounds: TRect);
       PROCEDURE Update;
       PROCEDURE DrawBackGround; Virtual;
+      Function  Comma ( N : LongInt ) : String;
    END;
    PHeapView = ^THeapView;                            { Heapview pointer }
 
@@ -117,6 +125,7 @@ TYPE
 {---------------------------------------------------------------------------}
 TYPE
    TClockView = OBJECT (TView)
+         am : Char;
          Refresh : Byte;                              { Refresh rate }
          LastTime: Longint;                           { Last time displayed }
          TimeStr : String[10];                        { Time string }
@@ -139,6 +148,34 @@ TYPE
 {                          THeapView OBJECT METHODS                         }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 
+constructor THeapView.Init(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVNormal;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitComma(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVComma;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitKb(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVKb;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitMb(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVMb;
+  OldMem := 0;
+end;
+
 {--THeapView----------------------------------------------------------------}
 {  Update -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Nov99 LdB            }
 {---------------------------------------------------------------------------}
@@ -156,15 +193,55 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE THeapView.DrawBackGround;
 VAR HOfs: Integer; S: String;
-BEGIN
-   Str(OldMem, S);                                    { Convert to string }
-   HOfs := ColourOfs;                                 { Hold any offset }
-   ColourOfs := 2;                                    { Set colour offset }
-   Inherited DrawBackGround;                          { Clear the backgound }
-   ColourOfs := HOfs;                                 { Reset any offset }
-   WriteStr(-(RawSize.X-TextWidth(S)+1), 0, S, 2);    { Write the string }
+begin
+  case mode of
+    HVNormal :
+      Str(OldMem:Size.X, S);
+    HVComma :
+      S:=Comma(OldMem);
+    HVKb :
+      begin
+        Str(OldMem shr 10:Size.X-1, S);
+        S:=S+'K';
+      end;
+    HVMb :
+      begin
+        Str(OldMem shr 20:Size.X-1, S);
+        S:=S+'M';
+      end;
+  end;
+  HOfs := ColourOfs;                                 { Hold any offset }
+  ColourOfs := 2;                                    { Set colour offset }
+  Inherited DrawBackGround;                          { Clear the backgound }
+  ColourOfs := HOfs;                                 { Reset any offset }
+  WriteStr(-(RawSize.X-TextWidth(S)+1), 0, S, 2);    { Write the string }
 END;
 
+Function THeapView.Comma ( n : LongInt) : String;
+Var
+  num, loc : Byte;
+  s : String;
+  t : String;
+Begin
+  Str (n,s);
+  Str (n:Size.X,t);
+
+  num := length(s) div 3;
+  if (length(s) mod 3) = 0 then dec (num);
+
+  delete (t,1,num);
+  loc := length(t)-2;
+
+  while num > 0 do
+  Begin
+    Insert (',',t,loc);
+    dec (num);
+    dec (loc,3);
+  End;
+
+  Comma := t;
+End;
+
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {                        TClockView OBJECT METHODS                          }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
@@ -226,7 +303,11 @@ END;
 END.
 {
  $Log$
- Revision 1.3  2001-08-04 19:14:33  peter
+ Revision 1.4  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.3  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 21 - 7
fv/menus.pas

@@ -1048,7 +1048,7 @@ END;
 {  Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11May98 LdB              }
 {---------------------------------------------------------------------------}
 PROCEDURE TMenuBox.Draw;
-VAR CNormal, CSelect, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
+VAR CNormal, CSelect, CSelectDisabled, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
     S: String; P: PMenuItem; B: TDrawBuffer;
 Type
    FrameLineType = (UpperLine,NormalLine,SeparationLine,LowerLine);
@@ -1070,8 +1070,10 @@ BEGIN
    CNormal := GetColor($0301);                        { Normal colour }
    CSelect := GetColor($0604);                        { Selected colour }
    CDisabled := GetColor($0202);                      { Disabled colour }
+   CSelectDisabled := GetColor($0505);                { Selected, but disabled }
    If TextModeGFV then
      Begin
+       Color := CNormal;                              { Normal colour }
        CreateBorder(UpperLine);
        WriteBuf(0, 0, Size.X, 1, B);                  { Write the line }
      End;
@@ -1081,8 +1083,15 @@ BEGIN
      While (P <> Nil) Do Begin                        { Valid menu item }
        Color := CNormal;                              { Normal colour }
        If (P^.Name <> Nil) Then Begin                 { Item has text }
-         If P^.Disabled Then Color := CDisabled       { Is item disabled }
-         Else If (P = Current) Then Color := CSelect; { Select colour }
+         If P^.Disabled Then
+           begin
+             if (P = Current) then
+               Color := CSelectDisabled
+             else
+               Color := CDisabled; { Is item disabled }
+           end
+         else
+           If (P = Current) Then Color := CSelect;    { Select colour }
          If TextModeGFV then
            Begin
              CreateBorder(NormalLine);
@@ -1097,9 +1106,10 @@ BEGIN
          MoveCStr(B[Index], S, Color);                { Transfer string }
          If (P^.Command <> 0) AND(P^.Param <> Nil)
          Then Begin
-           MoveCStr(B[CStrLen(S)+Index], ' - ' + P^.Param^,
-             Color);                                  { Add param chars }
-           S := S + ' - ' + P^.Param^;                { Add to string }
+           if TextModeGFV then
+            MoveCStr(B[Size.X - 3 - Length(P^.Param^)], P^.Param^, Color)  { Add param chars }
+           else
+            S := S + ' - ' + P^.Param^;                { Add to string }
          End;
          If (OldItem = Nil) OR (OldItem = P) OR
          (Current = P) Then Begin                     { We need to fix draw }
@@ -1711,7 +1721,11 @@ END;
 END.
 {
  $Log$
- Revision 1.8  2001-05-30 13:26:17  pierre
+ Revision 1.9  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.8  2001/05/30 13:26:17  pierre
   * fix border problems for views and menus
 
  Revision 1.7  2001/05/07 22:22:03  pierre

+ 36 - 5
fv/msgbox.pas

@@ -111,6 +111,12 @@ CONST
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
 
+procedure InitMsgBox;
+procedure DoneMsgBox;
+  { Init initializes the message box display system's text strings.  Init is
+    called by TApplication.Init after a successful call to Resource.Init or
+    Resource.Load. }
+
 {-MessageBox---------------------------------------------------------
 MessageBox displays the given string in a standard sized dialog box.
 Before the dialog is displayed the Msg and Params are passed to FormatStr.
@@ -146,12 +152,19 @@ FUNCTION InputBoxRect (Var Bounds: TRect; Const Title, ALabel: String;
                                 IMPLEMENTATION
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 
-USES Drivers, Views, App, Dialogs;                    { Standard GFV units }
+USES Drivers, Views, App, Dialogs, Resource;           { Standard GFV units }
 
 {***************************************************************************}
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
 
+const
+  Commands: array[0..3] of word =
+    (cmYes, cmNo, cmOK, cmCancel);
+var
+  ButtonName: array[0..3] of string[40];
+  Titles: array[0..3] of string[40];
+
 {---------------------------------------------------------------------------}
 {  MessageBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB        }
 {---------------------------------------------------------------------------}
@@ -173,9 +186,6 @@ END;
 {---------------------------------------------------------------------------}
 FUNCTION MessageBoxRect(Var R: TRect; Const Msg: String; Params: Pointer;
   AOptions: Word): Word;
-CONST ButtonName: Array[0..3] Of String[6] = ('~Y~es', '~N~o', 'O~K~', 'Cancel');
-      Commands: Array[0..3] Of Word = (cmYes, cmNo, cmOK, cmCancel);
-      Titles: Array[0..3] Of String[11] = ('Warning','Error','Information','Confirm');
 VAR I, X, ButtonCount: Integer; S: String; Dialog: PDialog; Control: PView;
     ButtonList: Array[0..4] Of PView;
 BEGIN
@@ -260,11 +270,32 @@ BEGIN
    InputBoxRect := C;                                 { Return execute result }
 END;
 
+
+procedure InitMsgBox;
+begin
+  ButtonName[0] := Labels^.Get(slYes);
+  ButtonName[1] := Labels^.Get(slNo);
+  ButtonName[2] := Labels^.Get(slOk);
+  ButtonName[3] := Labels^.Get(slCancel);
+  Titles[0] := Labels^.Get(sWarning);
+  Titles[1] := Labels^.Get(sError);
+  Titles[2] := Labels^.Get(sInformation);
+  Titles[3] := Labels^.Get(sConfirm);
+end;
+
+procedure DoneMsgBox;
+begin
+end;
+
 END.
 
 {
  $Log$
- Revision 1.2  2000-08-24 12:00:22  marco
+ Revision 1.3  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.2  2000/08/24 12:00:22  marco
   * CVS log and ID tags
 
 

+ 2 - 2
fv/statuses.pas

@@ -64,7 +64,7 @@ interface
 
 uses
 
-  ObjTypes, Objects, Drivers, Views, Dialogs,
+  FVCommon, FVConsts, Objects, Drivers, Views, Dialogs,
   Resource;
 
 const
@@ -675,7 +675,7 @@ procedure RegisterStatuses;
 implementation
 
 uses
-  FVConsts, MsgBox, App;
+  MsgBox, App;
 
 {****************************************************************************}
 {                    Local procedures and functions                          }

+ 2 - 2
fv/stddlg.pas

@@ -61,7 +61,7 @@ unit StdDlg;
 interface
 
 uses
-  ObjTypes, Objects, Drivers, Views, Dialogs, Validate, Dos;
+  FVConsts, Objects, Drivers, Views, Dialogs, Validate, Dos;
 
 const
 {$ifdef PPC_FPC}
@@ -565,7 +565,7 @@ implementation
 {****************************************************************************}
 
 uses
-  FVConsts, App, Memory, HistList, MsgBox, Resource;
+  App, Memory, HistList, MsgBox, Resource;
 
 type
 

+ 289 - 40
fv/views.pas

@@ -75,7 +75,7 @@ USES
    {$ENDIF}
 
    GFVGraph,                                          { GFV standard unit }
-   FVCommon, Objects, Drivers;                          { GFV standard units }
+   Objects, FVCommon, Drivers;                          { GFV standard units }
 
 {***************************************************************************}
 {                              PUBLIC CONSTANTS                             }
@@ -396,6 +396,7 @@ TYPE
       PROCEDURE Hide;
       PROCEDURE Show;
       PROCEDURE Draw; Virtual;
+      PROCEDURE ResetCursor; Virtual;
       PROCEDURE Select;
       PROCEDURE Awaken; Virtual;
       PROCEDURE DrawView;
@@ -420,7 +421,7 @@ TYPE
       PROCEDURE PutInFrontOf (Target: PView);
       PROCEDURE DisplaceBy (Dx, Dy: Sw_Integer); Virtual;
       PROCEDURE SetCommands (Commands: TCommandSet);
-      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
+      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
       PROCEDURE EnableCommands (Commands: TCommandSet);
       PROCEDURE DisableCommands (Commands: TCommandSet);
       PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
@@ -460,6 +461,7 @@ TYPE
       PROCEDURE MakeLocal (Source: TPoint; Var Dest: TPoint);
       PROCEDURE MakeGlobal (Source: TPoint; Var Dest: TPoint);
       PROCEDURE WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
+      PROCEDURE WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
       PROCEDURE WriteChar (X, Y: Sw_Integer; C: Char; Color: Byte;
         Count: Sw_Integer);
       PROCEDURE DragView (Event: TEvent; Mode: Byte; Var Limits: TRect;
@@ -499,6 +501,7 @@ TYPE
       PROCEDURE UnLock;
       PROCEDURE Awaken; Virtual;
       PROCEDURE ReDraw;
+      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
       PROCEDURE SelectDefaultView;
       PROCEDURE Insert (P: PView);
       PROCEDURE Delete (P: PView);
@@ -627,7 +630,6 @@ TYPE
       PROCEDURE Store (Var S: TStream);
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
       PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
-      PRIVATE
       PROCEDURE FocusItemNum (Item: Sw_Integer); Virtual;
    END;
    PListViewer = ^TListViewer;
@@ -877,6 +879,37 @@ CONST
 {                          PRIVATE INTERNAL ROUTINES                        }
 {***************************************************************************}
 
+    function posidx(const substr,s : string;idx:sw_integer):sw_integer;
+      var
+        i,j : sw_integer;
+        e   : boolean;
+      begin
+        i:=idx;
+        j:=0;
+        e:=(length(SubStr)>0);
+        while e and (i<=Length(s)-Length(SubStr)) do
+         begin
+           inc(i);
+           if (SubStr[1]=s[i]) and (Substr=Copy(s,i,Length(SubStr))) then
+            begin
+              j:=i;
+              e:=false;
+            end;
+         end;
+        PosIdx:=j;
+      end;
+
+
+procedure DrawScreenBuf;
+begin
+  if (LockUpdateScreen=0) then
+   begin
+     HideMouse;
+     UpdateScreen(false);
+     ShowMouse;
+   end;
+end;
+
 {***************************************************************************}
 {                              OBJECT METHODS                               }
 {***************************************************************************}
@@ -1206,6 +1239,75 @@ PROCEDURE TView.Draw;
 BEGIN                                                 { Abstract method }
 END;
 
+
+procedure TView.ResetCursor;
+const
+  sfV_CV_F:word = sfVisible + sfCursorVis + sfFocused;
+var
+  p,p2 : PView;
+  G : PGroup;
+  cur : TPoint;
+
+  function Check0:boolean;
+  var
+    res : byte;
+  begin
+    res:=0;
+    while res=0 do
+     begin
+       p:=p^.next;
+       if p=p2 then
+        begin
+          p:=P^.owner;
+          res:=1
+        end
+       else
+        if ((p^.state and sfVisible)<>0) and
+           (cur.x>=p^.origin.x) and
+           (cur.x<p^.size.x+p^.origin.x) and
+           (cur.y>=p^.origin.y) and
+           (cur.y<p^.size.y+p^.origin.y) then
+          res:=2;
+     end;
+    Check0:=res=2;
+  end;
+
+begin
+  if (not TextModeGFV) then
+   exit;
+  if ((state and sfV_CV_F) = sfV_CV_F) then
+   begin
+     p:=@Self;
+     cur:=cursor;
+     while true do
+      begin
+        if (cur.x<0) or (cur.x>=p^.size.x) or
+           (cur.y<0) or (cur.y>=p^.size.y) then
+          break;
+        inc(cur.X,p^.origin.X);
+        inc(cur.Y,p^.origin.Y);
+        p2:=p;
+        G:=p^.owner;
+        if G=Nil then { top view }
+         begin
+           Video.SetCursorPos(cur.x,cur.y);
+           if (state and sfCursorIns)<>0 then
+            Video.SetCursorType(crBlock)
+           else
+            Video.SetCursorType(crUnderline);
+           exit;
+         end;
+        if (G^.state and sfVisible)=0 then
+         break;
+        p:=G^.Last;
+        if Check0 then
+         break;
+      end; { while }
+   end; { if }
+  Video.SetCursorType(crHidden);
+end;
+
+
 {--TView--------------------------------------------------------------------}
 {  Select -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB            }
 {---------------------------------------------------------------------------}
@@ -1237,7 +1339,8 @@ BEGIN
      SetViewLimits;                                   { Set view limits }
      GetViewSettings(ViewPort, TextModeGFV);          { Get set viewport }
      If OverlapsArea(ViewPort.X1, ViewPort.Y1,
-     ViewPort.X2, ViewPort.Y2) Then Begin             { Must be in area }
+                     ViewPort.X2, ViewPort.Y2) Then
+      Begin             { Must be in area }
          Parent:=Owner;
          While Assigned(Parent) do Begin
            If (Parent^.LockFlag>0) then
@@ -1248,6 +1351,7 @@ BEGIN
              End;
            Parent:=Parent^.Owner;
          End;
+         inc(LockUpdateScreen); { don't update the screen yet }
          HideMouseCursor;                             { Hide mouse cursor }
          If (DrawMask = 0) OR (DrawMask = vdNoChild)  { No special masks set }
             { OR Assigned(LimitsLocked) }
@@ -1256,8 +1360,8 @@ BEGIN
            Draw;                                      { Draw interior }
            If (GOptions AND goDrawFocus <> 0) Then
              DrawFocus;                               { Draw focus }
-           If (State AND sfCursorVis <> 0)
-             Then DrawCursor;                         { Draw any cursor }
+           If (State AND sfCursorVis <> 0) Then
+             DrawCursor;                              { Draw any cursor }
            If (Options AND ofFramed <> 0) OR
            (GOptions AND goThickFramed <> 0)          { View has border }
              Then DrawBorder;                         { Draw border }
@@ -1283,11 +1387,14 @@ BEGIN
                DrawMask := DrawMask and Not vdFocus;
                DrawFocus;                          { Check focus mask }
              End;
-           If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
-             Begin
-               DrawMask := DrawMask and Not vdCursor;
-               DrawCursor;                              { Draw any cursor }
-             End;
+           if not TextModeGFV then
+            begin
+              If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
+               Begin
+                 DrawMask := DrawMask and Not vdCursor;
+                 DrawCursor;                              { Draw any cursor }
+               End;
+            end;
            If (DrawMask AND vdBorder <> 0) Then       { Check border mask }
              Begin
                DrawMask := DrawMask and Not vdBorder;
@@ -1305,6 +1412,16 @@ BEGIN
 {$endif ndef NoShadow}
          End;
          ShowMouseCursor;                             { Show mouse cursor }
+     dec(LockUpdateScreen);
+     if TextModeGFV then
+      begin
+        DrawScreenBuf;
+        If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
+          Begin
+            DrawMask := DrawMask and Not vdCursor;
+            DrawCursor;                              { Draw any cursor }
+          End;
+      end;
      End;
      ReleaseViewLimits;                               { Release the limits }
    End;
@@ -1333,6 +1450,8 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE TView.DrawCursor;
 BEGIN                                                 { Abstract method }
+  if State and sfFocused <> 0 then
+   ResetCursor;
 END;
 
 {--TView--------------------------------------------------------------------}
@@ -1440,7 +1559,10 @@ END;
 PROCEDURE TView.SetViewLimits;
 VAR X1, Y1, X2, Y2: Sw_Integer; P: PGroup; ViewPort: ViewPortType; Ca: PComplexArea;
 BEGIN
-   If (MaxAvail >= SizeOf(TComplexArea)) Then Begin   { Check enough memory }
+{$ifndef PPC_FPC}
+   If (MaxAvail >= SizeOf(TComplexArea)) Then
+{$endif}
+    Begin   { Check enough memory }
      GetMem(Ca, SizeOf(TComplexArea));                { Allocate memory }
      GetViewSettings(ViewPort, TextModeGFV);          { Fetch view port }
      Ca^.X1 := ViewPort.X1;                           { Hold current X1 }
@@ -1535,8 +1657,7 @@ BEGIN
          For Y := Y1 To Y2 Do Begin
            WriteAbs(X1,Y, X2-X1, Buf);
          End;
-         { FIXME: we shouldn't update always here }
-         UpdateScreen(false);
+         DrawScreenBuf;
        End;
    End;
 END;
@@ -1614,8 +1735,13 @@ BEGIN
    Cursor.X := X;                                     { New x position }
    Cursor.Y := Y;                                     { New y position }
    If (State AND sfCursorVis <> 0) Then Begin         { Cursor visible }
-     SetDrawMask(vdCursor);                           { Set draw mask }
-     DrawView;                                        { Draw the cursor }
+     if TextModeGFV then
+      ResetCursor
+     else
+      begin
+        SetDrawMask(vdCursor);                           { Set draw mask }
+        DrawView;                                        { Draw the cursor }
+      end;
    End;
 END;
 
@@ -1642,8 +1768,8 @@ BEGIN
        State := State AND NOT sfVisible;              { Temp stop drawing }
        If (LastView = Target) Then
          If (Owner <> Nil) Then Owner^.ReDrawArea(
-           RawOrigin.X, RawOrigin.Y, RawOrigin.X +
-           RawSize.X, RawOrigin.Y + RawSize.Y);       { Redraw old area }
+           RawOrigin.X, RawOrigin.Y, RawOrigin.X + RawSize.X,
+           RawOrigin.Y + RawSize.Y);       { Redraw old area }
        Owner^.Lock;
        Owner^.RemoveView(@Self);                      { Remove from list }
        Owner^.InsertView(@Self, Target);              { Insert into list }
@@ -1752,8 +1878,9 @@ BEGIN
        Then SetState(sfExposed, Enable);              { Expose this view }
      If Enable Then DrawView Else                     { Draw the view }
        If (Owner <> Nil) Then Owner^.ReDrawArea(      { Owner valid }
-         RawOrigin.X, RawOrigin.Y, RawOrigin.X +
-         RawSize.X, RawOrigin.Y + RawSize.Y);         { Owner redraws area }
+         RawOrigin.X, RawOrigin.Y,
+         RawOrigin.X + RawSize.X + ShadowSize.X*SysFontWidth,
+         RawOrigin.Y + RawSize.Y + ShadowSize.Y*SysFontHeight);         { Owner redraws area }
      If (Options AND ofSelectable <> 0) Then          { View is selectable }
        If (Owner <> Nil) Then Owner^.ResetCurrent;    { Reset selected }
    End;
@@ -1773,8 +1900,13 @@ BEGIN
    End;
    If (AState AND (sfCursorVis + sfCursorIns) <> 0)   { Change cursor state }
    Then Begin
-     SetDrawMask(vdCursor);                           { Set cursor draw mask }
-     ShouldDraw:=true;
+     if TextModeGFV then
+      ResetCursor
+     else
+      begin
+        SetDrawMask(vdCursor);                           { Set cursor draw mask }
+        ShouldDraw:=true;
+      end;
    End;
    If ShouldDraw then
        DrawView;                                      { Redraw the border }
@@ -2370,6 +2502,24 @@ BEGIN
    End;
 END;
 
+{--TGroup-------------------------------------------------------------------}
+{  ReDraw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB              }
+{---------------------------------------------------------------------------}
+PROCEDURE TGroup.ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
+VAR P: PView;
+BEGIN
+   { redraw this }
+   inherited RedrawArea(X1,Y1,X2,Y2);
+   { redraw group members }
+   If (DrawMask AND vdNoChild = 0) Then Begin         { No draw child clear }
+     P := Last;                                       { Start on Last }
+     While (P <> Nil) Do Begin
+       P^.ReDrawArea(X1, Y1, X2, Y2);                 { Redraw each subview }
+       P := P^.PrevView;                              { Move to prior view }
+     End;
+   End;
+END;
+
 {--TGroup-------------------------------------------------------------------}
 {  Awaken -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB            }
 {---------------------------------------------------------------------------}
@@ -2924,18 +3074,21 @@ END;
 {  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB              }
 {---------------------------------------------------------------------------}
 CONSTRUCTOR TScrollBar.Init (Var Bounds: TRect);
-CONST VChars: TScrollChars = (#30, #31, #177, #254, #178);
-      HChars: TScrollChars = (#17, #16, #177, #254, #178);
+const
+  VChars: array[boolean] of TScrollChars =
+     (('^','V', #177, #254, #178),(#30, #31, #177, #254, #178));
+  HChars: array[boolean] of TScrollChars =
+     (('<','>', #177, #254, #178),(#17, #16, #177, #254, #178));
 BEGIN
    Inherited Init(Bounds);                            { Call ancestor }
    PgStep := 1;                                       { Page step size = 1 }
    ArStep := 1;                                       { Arrow step sizes = 1 }
    If (Size.X = 1) Then Begin                         { Vertical scrollbar }
      GrowMode := gfGrowLoX + gfGrowHiX + gfGrowHiY;   { Grow vertically }
-     Chars := VChars;                                 { Vertical chars }
+     Chars := VChars[LowAscii];                       { Vertical chars }
    End Else Begin                                     { Horizontal scrollbar }
      GrowMode := gfGrowLoY + gfGrowHiX + gfGrowHiY;   { Grow horizontal }
-     Chars := HChars;                                 { Horizontal chars }
+     Chars := HChars[LowAscii];                       { Horizontal chars }
    End;
 END;
 
@@ -4247,7 +4400,7 @@ BEGIN
      End;
      For Y := Y1 To Y2 Do
        WriteAbs(X1,Y, X2-X1, Buf);
-     UpdateScreen(false);
+     DrawScreenBuf;
    End;
 END;
 
@@ -4414,7 +4567,7 @@ BEGIN
          End;
          Y := Y + SysFontHeight;                        { Next line down }
        end;
-     Video.UpdateScreen(false);
+       DrawScreenBuf;
      End;
    end;
 END;
@@ -4462,7 +4615,8 @@ BEGIN
          Y := Y + SysFontHeight;                       { Next line down }
        End;
      end;
-     Video.UpdateScreen(false);
+     If TextModeGFV then
+       DrawScreenBuf;
    End;
 END;
 
@@ -4494,6 +4648,86 @@ BEGIN
    End;
 END;
 
+PROCEDURE TView.WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
+VAR I, J, Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
+    Xw, Yw, TiBuf, Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
+    Buf : TDrawBuffer;
+    FoundSwap : boolean;
+BEGIN
+   If (State AND sfVisible <> 0) AND                  { View is visible }
+   (State AND sfExposed <> 0) AND                     { View is exposed }
+   (State AND sfIconised = 0) AND                     { View not iconized }
+   (Length(Str) > 0) Then Begin                       { String is valid }
+
+     j:=1;
+     repeat
+       FoundSwap:=false;
+       i:=PosIdx('~',Str,j);
+       if i>0 then
+        FoundSwap:=true
+       else
+        i:=Length(Str)+1;
+
+        Fc := GetColor(Color1);                          { Get view color }
+        Bc := Fc AND $F0 SHR 4;                          { Calc back colour }
+        Fc := Fc AND $0F;                                { Calc text colour }
+
+        If RevCol Then Begin
+          B := Bc;
+          Bc := Fc;
+          Fc := B;
+        End;
+
+        If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then Begin
+          Xw := RawOrigin.X+X*FontWidth;                    { X position }
+          Yw := RawOrigin.Y+Y*FontHeight;                   { Y position }
+        End Else Begin
+          Xw := RawOrigin.X + Abs(X);
+          Yw := RawOrigin.Y + Abs(Y);
+        End;
+        GetViewSettings(ViewPort, TextModeGFV);
+
+       If (TextModeGFV <> TRUE) Then Begin              { GRAPHICAL MODE GFV }
+         SetFillStyle(SolidFill, Bc);                   { Set fill style }
+         Bar(Xw-ViewPort.X1, Yw-ViewPort.Y1,
+           Xw-ViewPort.X1+Length(Str)*FontWidth,
+           Yw-ViewPort.Y1+FontHeight-1);
+         SetColor(Fc);
+         OutTextXY(Xw-ViewPort.X1, Yw-ViewPort.Y1+2, Copy(Str,j,i-j));{ Write text char }
+       End Else Begin                                   { TEXT MODE GFV }
+         Tix := Xw DIV SysFontWidth;
+         Tiy := Yw DIV SysFontHeight;
+         TiBuf := 0;
+         For Ti := j To i-1 Do Begin
+           Buf[TiBuf]:=((Fc or (Bc shl 4)) shl 8) or Ord(Str[Ti]);
+           inc(TiBuf);
+         end;
+         WriteAbs(Tix,TiY,i-j,Buf);
+       End;
+
+      { increase position on screen }
+      inc(X,(i-j));
+
+      { Swap colors }
+      if FoundSwap then
+       begin
+         { Swap color1 and color2 }
+         B := Color1;
+         Color1 := Color2;
+         Color2 := B;
+         { increase position in string }
+         j:=i+1;
+         { we're at the last char }
+         if (j>length(Str)) then
+          break;
+       end;
+
+     until not FoundSwap;
+     If TextModeGFV then
+       DrawScreenBuf;
+   End;
+END;
+
 PROCEDURE TView.WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
 VAR Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
     Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
@@ -4537,7 +4771,8 @@ BEGIN
        end;
        WriteAbs(Tix,TiY,Length(Str),Buf);
      End;
-     UpdateScreen(false);
+     If TextModeGFV then
+       DrawScreenBuf;
    End;
 END;
 
@@ -4585,7 +4820,7 @@ BEGIN
          X := X + I*FontWidth;                          { Move x position }
      End;
      If TextModeGFV then
-       UpdateScreen(false);
+       DrawScreenBuf;
    End;
 END;
 
@@ -4887,10 +5122,9 @@ END;
 
 
 
-{ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
-{Þ                        TScroller OBJECT METHODS                         Ý}
-{ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
-
+{***************************************************************************}
+{                         TScroller OBJECT METHODS                          }
+{***************************************************************************}
 
 PROCEDURE TScroller.ScrollDraw;
 VAR D: TPoint;
@@ -4979,7 +5213,12 @@ BEGIN
 {$endif UseLock}
 END;
 
+
 PROCEDURE TWindow.DrawBorder;
+const
+  LargeC:array[boolean] of char=('^',#24);
+  RestoreC:array[boolean] of char=('|',#18);
+  ClickC:array[boolean] of char=('*',#15);
 VAR Fc, Bc: Byte; X, Y: Sw_Integer; S: String;
     ViewPort: ViewPortType;
     I : Sw_Integer;
@@ -4988,9 +5227,10 @@ VAR Fc, Bc: Byte; X, Y: Sw_Integer; S: String;
     HorizontalBar,
     VerticalBar,
     LeftLowCorner,
-    RightLowCorner : Char;
+    RightLowCorner,C : Char;
     Color : Byte;
     Focused : Boolean;
+    Min, Max: TPoint;
 BEGIN
    Fc := GetColor(2) AND $0F;                        { Foreground colour }
    Bc := (GetColor(2) AND $70) SHR 4;                { Background colour }
@@ -5071,16 +5311,21 @@ BEGIN
        OutTextXY(RawOrigin.X+Y+FontWidth-ViewPort.X1,
          RawOrigin.Y+Y+1-ViewPort.Y1+2, '[*]');       { Write close icon }
      End Else Begin                                   { LEON??? }
-       WriteStr(2,0,'[*]',2);
+       WriteCStr(2,0,'[~'+ClickC[LowAscii]+'~]', 2, 3);
      End;
    End;
    If (Flags AND wfZoom<>0) Then Begin
+     if assigned(Owner) and
+        (Size.X=Owner^.Size.X) and (Size.Y=Owner^.Size.Y) then
+      C:=RestoreC[LowAscii]
+     else
+      C:=LargeC[LowAscii];
      If (TextModeGFV <> True) Then Begin              { GRAPHICS MODE GFV }
        SetColor(GetColor(2) AND $0F);
        OutTextXY(RawOrigin.X+RawSize.X-4*FontWidth-Y-ViewPort.X1,
-         RawOrigin.Y+Y+1-ViewPort.Y1+2, '['+#24+']'); { Write zoom icon }
+         RawOrigin.Y+Y+1-ViewPort.Y1+2, '['+C+']'); { Write zoom icon }
      End Else Begin                                   { LEON??? }
-       WriteStr(Size.X-5,0,'['+#24+']',2);
+       WriteCStr(Size.X-5,0,'[~'+C+'~]', 2, 3);
      End;
    End;
    If not TextModeGFV then
@@ -5183,7 +5428,11 @@ END.
 
 {
  $Log$
- Revision 1.15  2001-08-04 19:14:33  peter
+ Revision 1.16  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.15  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 85 - 10
fvision/app.pas

@@ -55,10 +55,12 @@ USES
    {$IFDEF OS_OS2}                                    { OS2 CODE }
      Os2Def, Os2Base, OS2PmApi,                       { Standard units }
    {$ENDIF}
-
+   Dos,
+   Video,
    GFVGraph,                                          { GFV standard unit }
    FVCommon, Memory,                                    { GFV standard units }
-   Objects, Drivers, Views, Menus, HistList, Dialogs; { GFV standard units }
+   Objects, Drivers, Views, Menus, HistList, Dialogs,
+   MsgBox;
 
 {***************************************************************************}
 {                              PUBLIC CONSTANTS                             }
@@ -227,11 +229,13 @@ TYPE
       PROCEDURE Run; Virtual;
       PROCEDURE Idle; Virtual;
       PROCEDURE InitScreen; Virtual;
+      procedure DoneScreen; virtual;
       PROCEDURE InitDeskTop; Virtual;
       PROCEDURE OutOfMemory; Virtual;
       PROCEDURE InitMenuBar; Virtual;
       PROCEDURE InitStatusLine; Virtual;
       PROCEDURE SetScreenMode (Mode: Word);
+      PROCEDURE SetScreenVideoMode(const Mode: TVideoMode);
       PROCEDURE PutEvent (Var Event: TEvent); Virtual;
       PROCEDURE GetEvent (Var Event: TEvent); Virtual;
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
@@ -250,6 +254,7 @@ TYPE
       PROCEDURE DosShell;
       PROCEDURE GetTileRect (Var R: TRect); Virtual;
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
+      procedure WriteShellMsg; virtual;
    END;
    PApplication = ^TApplication;                      { Application ptr }
 
@@ -346,7 +351,7 @@ CONST
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 
   uses
-    Video,Mouse;
+    Mouse,Resource;
 
 {***************************************************************************}
 {                        PRIVATE DEFINED CONSTANTS                          }
@@ -654,6 +659,7 @@ BEGIN
      -(GetMaxY(TextModeGFV)+1));                      { Full screen area }
    Inherited Init(R);                                 { Call ancestor }
    Application := @Self;                              { Set application ptr }
+   Drivers.InitVideo;
    InitScreen;                                        { Initialize screen }
    State := sfVisible + sfSelected + sfFocused +
       sfModal + sfExposed;                            { Deafult states }
@@ -662,12 +668,12 @@ BEGIN
    Size.Y := ScreenHeight;                            { Set y size value }
    RawSize.X := ScreenWidth * SysFontWidth - 1;       { Set rawsize x }
    RawSize.Y := ScreenHeight * SysFontHeight - 1;     { Set rawsize y }
-   InitStatusLine;                                    { Init status line }
-   If (StatusLine <> Nil) Then Insert(StatusLine);    { Insert status line }
-   InitMenuBar;                                       { Create a bar menu }
-   If (MenuBar <> Nil) Then Insert(MenuBar);          { Insert menu bar }
    InitDesktop;                                       { Create desktop }
+   InitStatusLine;                                    { Create status line }
+   InitMenuBar;                                       { Create a bar menu }
    If (Desktop <> Nil) Then Insert(Desktop);          { Insert desktop }
+   If (StatusLine <> Nil) Then Insert(StatusLine);    { Insert status line }
+   If (MenuBar <> Nil) Then Insert(MenuBar);          { Insert menu bar }
 END;
 
 {--TProgram-----------------------------------------------------------------}
@@ -802,6 +808,14 @@ BEGIN
   Buffer := Views.PVideoBuf(VideoBuf);
 END;
 
+
+procedure TProgram.DoneScreen;
+begin
+  DoneVideo;
+  Buffer:=nil;
+end;
+
+
 {--TProgram-----------------------------------------------------------------}
 {  InitDeskTop -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB       }
 {---------------------------------------------------------------------------}
@@ -850,8 +864,38 @@ END;
 {  SetScreenMode -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 25Oct99 LdB     }
 {---------------------------------------------------------------------------}
 PROCEDURE TProgram.SetScreenMode (Mode: Word);
-BEGIN                                                 { Compatability only }
-END;
+var
+  R: TRect;
+begin
+  if TextModeGFV then
+   begin
+     HideMouse;
+     DoneMemory;
+     InitMemory;
+     InitScreen;
+     Buffer := Views.PVideoBuf(VideoBuf);
+     R.Assign(0, 0, ScreenWidth, ScreenHeight);
+     ChangeBounds(R);
+     ShowMouse;
+   end;
+end;
+
+procedure TProgram.SetScreenVideoMode(const Mode: TVideoMode);
+var
+  R: TRect;
+begin
+  DoneMouse;
+  DoneMemory;
+  ScreenMode:=Mode;
+  Video.SetVideoMode(Mode);
+  InitMouse;
+  InitMemory;
+  InitScreen;
+  Buffer := Views.PVideoBuf(VideoBuf);
+  R.Assign(0, 0, ScreenWidth, ScreenHeight);
+  ChangeBounds(R);
+  ShowMouse;
+end;
 
 {--TProgram-----------------------------------------------------------------}
 {  PutEvent -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Sep97 LdB          }
@@ -928,7 +972,15 @@ BEGIN
    Drivers.InitEvents;                                        { Start event drive }
    Drivers.InitSysError;                                      { Start system error }
    InitHistory;                                       { Start history up }
+   InitResource;
+   InitMsgBox;
    Inherited Init;                                    { Call ancestor }
+   if (TextModeGFV) then
+    begin
+      { init mouse and cursor }
+      Video.SetCursorType(crHidden);
+      Mouse.SetMouseXY(1,1);
+    end;
 END;
 
 {--TApplication-------------------------------------------------------------}
@@ -969,6 +1021,19 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE TApplication.DosShell;
 BEGIN                                                 { Compatability only }
+  DoneSysError;
+  DoneEvents;
+  DoneScreen;
+  DoneDosMem;
+  WriteShellMsg;
+  SwapVectors;
+  Exec(GetEnv('COMSPEC'), '');
+  SwapVectors;
+  InitDosMem;
+  InitScreen;
+  InitEvents;
+  InitSysError;
+  Redraw;
 END;
 
 {--TApplication-------------------------------------------------------------}
@@ -997,6 +1062,12 @@ BEGIN
    End;
 END;
 
+procedure TApplication.WriteShellMsg;
+begin
+  PrintStr(Strings^.Get(sTypeExitOnReturn));
+end;
+
+
 {***************************************************************************}
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
@@ -1088,7 +1159,11 @@ END;
 END.
 {
  $Log$
- Revision 1.12  2001-08-04 19:14:32  peter
+ Revision 1.13  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.12  2001/08/04 19:14:32  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 7 - 1
fvision/buildfv.pas

@@ -8,6 +8,7 @@ interface
 uses
   fvcommon,
   objects,
+  callspec,
   drivers,
   fileio,
   memory,
@@ -27,6 +28,7 @@ uses
   statuses,
   histlist,
   inplong,
+  editors,
   gadgets,
   time;
 
@@ -35,7 +37,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.1  2001-08-04 19:14:32  peter
+  Revision 1.2  2001-08-05 02:03:13  peter
+    * view redrawing and small cursor updates
+    * merged some more FV extensions
+
+  Revision 1.1  2001/08/04 19:14:32  peter
     * Added Makefiles
     * added FV specific units and objects from old FV
 

+ 14 - 2
fvision/dialogs.pas

@@ -2056,6 +2056,12 @@ BEGIN
      AStrings := AStrings^.Next;                      { Move to next item }
      Dispose(P);                                      { Dispose prior item }
    End;
+   Sel := 0;
+   if TextModeGFV then
+    begin
+      SetCursor(2,0);
+      ShowCursor;
+    end;
    EnableMask := $FFFFFFFF;                           { Enable bit masks }
 END;
 
@@ -2223,6 +2229,8 @@ BEGIN
      End;
      WriteBuf(K, K+I, Size.X-K-K, 1, B);              { Write buffer }
    End;
+  if TextModeGFV then
+    SetCursor(Column(Sel)+2,Row(Sel));
 END;
 
 {--TCluster-----------------------------------------------------------------}
@@ -2481,7 +2489,7 @@ PROCEDURE TRadioButtons.DrawFocus;
 CONST Button = ' ( ) ';
 BEGIN
    Inherited DrawFocus;
-   DrawMultiBox(Button, #32#7);                       { Redraw the text }
+   DrawMultiBox(Button, ' *');                       { Redraw the text }
 END;
 
 {--TRadioButtons------------------------------------------------------------}
@@ -4171,7 +4179,11 @@ END;
 END.
 {
  $Log$
- Revision 1.11  2001-08-04 19:14:32  peter
+ Revision 1.12  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.11  2001/08/04 19:14:32  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 7 - 3
fvision/drivers.pas

@@ -240,7 +240,7 @@ TYPE
           Where: TPoint);                             { Mouse position }
         evKeyDown: (                                  { ** KEY EVENT ** }
           Case Sw_Integer Of
-            0: (KeyCode: Sw_Word);                       { Full key code }
+            0: (KeyCode:  Word);                       { Full key code }
             1: (CharCode: Char;                       { Char code }
                 ScanCode: Byte;                       { Scan code }
                 KeyShift: byte));                     { Shift states }
@@ -351,7 +351,7 @@ Returns the ascii character for the Ctrl+Key scancode that was given.
 FUNCTION GetCtrlChar (KeyCode: Word): Char;
 
 {-CtrlToArrow--------------------------------------------------------
-Converts a Sw_WordStar-compatible control key code to the corresponding
+Converts a WordStar-compatible control key code to the corresponding
 cursor key code.
 25May96 LdB
 ---------------------------------------------------------------------}
@@ -1474,7 +1474,11 @@ BEGIN
 END.
 {
  $Log$
- Revision 1.11  2001-08-04 19:14:33  peter
+ Revision 1.12  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.11  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 6 - 2
fvision/fvcommon.pas

@@ -130,7 +130,7 @@ TYPE
    Sw_Integer = Integer;                              { Standard integer }
 {$ENDIF}
 {$IFDEF BIT_32}                                       { 32 BIT DEFINITIONS }
-   Sw_Word    = LongInt;                              { Long integer now }
+   Sw_Word    = Cardinal;                             { Long integer now }
    Sw_Integer = LongInt;                              { Long integer now }
 {$ENDIF}
 
@@ -416,7 +416,11 @@ END;
 END.
 {
  $Log$
- Revision 1.1  2001-08-04 19:14:33  peter
+ Revision 1.2  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.1  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 6 - 2
fvision/fvconsts.pas

@@ -63,7 +63,7 @@ const
   idBrowseButton = 24;
   idEditListBox = 25;
   idModalInputLine = 26;
-  idListDlg = 27;
+  idListDlg = 28;
 
   { App Unit }
   idBackground = 30;
@@ -624,7 +624,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.1  2001-08-04 19:14:33  peter
+  Revision 1.2  2001-08-05 02:03:13  peter
+    * view redrawing and small cursor updates
+    * merged some more FV extensions
+
+  Revision 1.1  2001/08/04 19:14:33  peter
     * Added Makefiles
     * added FV specific units and objects from old FV
 

+ 89 - 8
fvision/gadgets.pas

@@ -105,10 +105,18 @@ USES FVConsts, Time, Objects, Drivers, Views, App;      { Standard GFV units }
 {                  THeapView OBJECT - ANCESTOR VIEW OBJECT                  }
 {---------------------------------------------------------------------------}
 TYPE
+   THeapViewMode=(HVNormal,HVComma,HVKb,HVMb);
+
    THeapView = OBJECT (TView)
+         Mode   : THeapViewMode;
          OldMem: LongInt;                             { Last memory count }
+      constructor Init(var Bounds: TRect);
+      constructor InitComma(var Bounds: TRect);
+      constructor InitKb(var Bounds: TRect);
+      constructor InitMb(var Bounds: TRect);
       PROCEDURE Update;
       PROCEDURE DrawBackGround; Virtual;
+      Function  Comma ( N : LongInt ) : String;
    END;
    PHeapView = ^THeapView;                            { Heapview pointer }
 
@@ -117,6 +125,7 @@ TYPE
 {---------------------------------------------------------------------------}
 TYPE
    TClockView = OBJECT (TView)
+         am : Char;
          Refresh : Byte;                              { Refresh rate }
          LastTime: Longint;                           { Last time displayed }
          TimeStr : String[10];                        { Time string }
@@ -139,6 +148,34 @@ TYPE
 {                          THeapView OBJECT METHODS                         }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 
+constructor THeapView.Init(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVNormal;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitComma(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVComma;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitKb(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVKb;
+  OldMem := 0;
+end;
+
+constructor THeapView.InitMb(var Bounds: TRect);
+begin
+  inherited Init(Bounds);
+  mode:=HVMb;
+  OldMem := 0;
+end;
+
 {--THeapView----------------------------------------------------------------}
 {  Update -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 12Nov99 LdB            }
 {---------------------------------------------------------------------------}
@@ -156,15 +193,55 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE THeapView.DrawBackGround;
 VAR HOfs: Integer; S: String;
-BEGIN
-   Str(OldMem, S);                                    { Convert to string }
-   HOfs := ColourOfs;                                 { Hold any offset }
-   ColourOfs := 2;                                    { Set colour offset }
-   Inherited DrawBackGround;                          { Clear the backgound }
-   ColourOfs := HOfs;                                 { Reset any offset }
-   WriteStr(-(RawSize.X-TextWidth(S)+1), 0, S, 2);    { Write the string }
+begin
+  case mode of
+    HVNormal :
+      Str(OldMem:Size.X, S);
+    HVComma :
+      S:=Comma(OldMem);
+    HVKb :
+      begin
+        Str(OldMem shr 10:Size.X-1, S);
+        S:=S+'K';
+      end;
+    HVMb :
+      begin
+        Str(OldMem shr 20:Size.X-1, S);
+        S:=S+'M';
+      end;
+  end;
+  HOfs := ColourOfs;                                 { Hold any offset }
+  ColourOfs := 2;                                    { Set colour offset }
+  Inherited DrawBackGround;                          { Clear the backgound }
+  ColourOfs := HOfs;                                 { Reset any offset }
+  WriteStr(-(RawSize.X-TextWidth(S)+1), 0, S, 2);    { Write the string }
 END;
 
+Function THeapView.Comma ( n : LongInt) : String;
+Var
+  num, loc : Byte;
+  s : String;
+  t : String;
+Begin
+  Str (n,s);
+  Str (n:Size.X,t);
+
+  num := length(s) div 3;
+  if (length(s) mod 3) = 0 then dec (num);
+
+  delete (t,1,num);
+  loc := length(t)-2;
+
+  while num > 0 do
+  Begin
+    Insert (',',t,loc);
+    dec (num);
+    dec (loc,3);
+  End;
+
+  Comma := t;
+End;
+
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {                        TClockView OBJECT METHODS                          }
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
@@ -226,7 +303,11 @@ END;
 END.
 {
  $Log$
- Revision 1.3  2001-08-04 19:14:33  peter
+ Revision 1.4  2001-08-05 02:03:13  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.3  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV
 

+ 21 - 7
fvision/menus.pas

@@ -1048,7 +1048,7 @@ END;
 {  Draw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 11May98 LdB              }
 {---------------------------------------------------------------------------}
 PROCEDURE TMenuBox.Draw;
-VAR CNormal, CSelect, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
+VAR CNormal, CSelect, CSelectDisabled, CDisabled, Color: Word; Index, Tx, Ty, Y: Integer;
     S: String; P: PMenuItem; B: TDrawBuffer;
 Type
    FrameLineType = (UpperLine,NormalLine,SeparationLine,LowerLine);
@@ -1070,8 +1070,10 @@ BEGIN
    CNormal := GetColor($0301);                        { Normal colour }
    CSelect := GetColor($0604);                        { Selected colour }
    CDisabled := GetColor($0202);                      { Disabled colour }
+   CSelectDisabled := GetColor($0505);                { Selected, but disabled }
    If TextModeGFV then
      Begin
+       Color := CNormal;                              { Normal colour }
        CreateBorder(UpperLine);
        WriteBuf(0, 0, Size.X, 1, B);                  { Write the line }
      End;
@@ -1081,8 +1083,15 @@ BEGIN
      While (P <> Nil) Do Begin                        { Valid menu item }
        Color := CNormal;                              { Normal colour }
        If (P^.Name <> Nil) Then Begin                 { Item has text }
-         If P^.Disabled Then Color := CDisabled       { Is item disabled }
-         Else If (P = Current) Then Color := CSelect; { Select colour }
+         If P^.Disabled Then
+           begin
+             if (P = Current) then
+               Color := CSelectDisabled
+             else
+               Color := CDisabled; { Is item disabled }
+           end
+         else
+           If (P = Current) Then Color := CSelect;    { Select colour }
          If TextModeGFV then
            Begin
              CreateBorder(NormalLine);
@@ -1097,9 +1106,10 @@ BEGIN
          MoveCStr(B[Index], S, Color);                { Transfer string }
          If (P^.Command <> 0) AND(P^.Param <> Nil)
          Then Begin
-           MoveCStr(B[CStrLen(S)+Index], ' - ' + P^.Param^,
-             Color);                                  { Add param chars }
-           S := S + ' - ' + P^.Param^;                { Add to string }
+           if TextModeGFV then
+            MoveCStr(B[Size.X - 3 - Length(P^.Param^)], P^.Param^, Color)  { Add param chars }
+           else
+            S := S + ' - ' + P^.Param^;                { Add to string }
          End;
          If (OldItem = Nil) OR (OldItem = P) OR
          (Current = P) Then Begin                     { We need to fix draw }
@@ -1711,7 +1721,11 @@ END;
 END.
 {
  $Log$
- Revision 1.8  2001-05-30 13:26:17  pierre
+ Revision 1.9  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.8  2001/05/30 13:26:17  pierre
   * fix border problems for views and menus
 
  Revision 1.7  2001/05/07 22:22:03  pierre

+ 36 - 5
fvision/msgbox.pas

@@ -111,6 +111,12 @@ CONST
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
 
+procedure InitMsgBox;
+procedure DoneMsgBox;
+  { Init initializes the message box display system's text strings.  Init is
+    called by TApplication.Init after a successful call to Resource.Init or
+    Resource.Load. }
+
 {-MessageBox---------------------------------------------------------
 MessageBox displays the given string in a standard sized dialog box.
 Before the dialog is displayed the Msg and Params are passed to FormatStr.
@@ -146,12 +152,19 @@ FUNCTION InputBoxRect (Var Bounds: TRect; Const Title, ALabel: String;
                                 IMPLEMENTATION
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 
-USES Drivers, Views, App, Dialogs;                    { Standard GFV units }
+USES Drivers, Views, App, Dialogs, Resource;           { Standard GFV units }
 
 {***************************************************************************}
 {                            INTERFACE ROUTINES                             }
 {***************************************************************************}
 
+const
+  Commands: array[0..3] of word =
+    (cmYes, cmNo, cmOK, cmCancel);
+var
+  ButtonName: array[0..3] of string[40];
+  Titles: array[0..3] of string[40];
+
 {---------------------------------------------------------------------------}
 {  MessageBox -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB        }
 {---------------------------------------------------------------------------}
@@ -173,9 +186,6 @@ END;
 {---------------------------------------------------------------------------}
 FUNCTION MessageBoxRect(Var R: TRect; Const Msg: String; Params: Pointer;
   AOptions: Word): Word;
-CONST ButtonName: Array[0..3] Of String[6] = ('~Y~es', '~N~o', 'O~K~', 'Cancel');
-      Commands: Array[0..3] Of Word = (cmYes, cmNo, cmOK, cmCancel);
-      Titles: Array[0..3] Of String[11] = ('Warning','Error','Information','Confirm');
 VAR I, X, ButtonCount: Integer; S: String; Dialog: PDialog; Control: PView;
     ButtonList: Array[0..4] Of PView;
 BEGIN
@@ -260,11 +270,32 @@ BEGIN
    InputBoxRect := C;                                 { Return execute result }
 END;
 
+
+procedure InitMsgBox;
+begin
+  ButtonName[0] := Labels^.Get(slYes);
+  ButtonName[1] := Labels^.Get(slNo);
+  ButtonName[2] := Labels^.Get(slOk);
+  ButtonName[3] := Labels^.Get(slCancel);
+  Titles[0] := Labels^.Get(sWarning);
+  Titles[1] := Labels^.Get(sError);
+  Titles[2] := Labels^.Get(sInformation);
+  Titles[3] := Labels^.Get(sConfirm);
+end;
+
+procedure DoneMsgBox;
+begin
+end;
+
 END.
 
 {
  $Log$
- Revision 1.2  2000-08-24 12:00:22  marco
+ Revision 1.3  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.2  2000/08/24 12:00:22  marco
   * CVS log and ID tags
 
 

+ 2 - 2
fvision/statuses.pas

@@ -64,7 +64,7 @@ interface
 
 uses
 
-  ObjTypes, Objects, Drivers, Views, Dialogs,
+  FVCommon, FVConsts, Objects, Drivers, Views, Dialogs,
   Resource;
 
 const
@@ -675,7 +675,7 @@ procedure RegisterStatuses;
 implementation
 
 uses
-  FVConsts, MsgBox, App;
+  MsgBox, App;
 
 {****************************************************************************}
 {                    Local procedures and functions                          }

+ 2 - 2
fvision/stddlg.pas

@@ -61,7 +61,7 @@ unit StdDlg;
 interface
 
 uses
-  ObjTypes, Objects, Drivers, Views, Dialogs, Validate, Dos;
+  FVConsts, Objects, Drivers, Views, Dialogs, Validate, Dos;
 
 const
 {$ifdef PPC_FPC}
@@ -565,7 +565,7 @@ implementation
 {****************************************************************************}
 
 uses
-  FVConsts, App, Memory, HistList, MsgBox, Resource;
+  App, Memory, HistList, MsgBox, Resource;
 
 type
 

+ 289 - 40
fvision/views.pas

@@ -75,7 +75,7 @@ USES
    {$ENDIF}
 
    GFVGraph,                                          { GFV standard unit }
-   FVCommon, Objects, Drivers;                          { GFV standard units }
+   Objects, FVCommon, Drivers;                          { GFV standard units }
 
 {***************************************************************************}
 {                              PUBLIC CONSTANTS                             }
@@ -396,6 +396,7 @@ TYPE
       PROCEDURE Hide;
       PROCEDURE Show;
       PROCEDURE Draw; Virtual;
+      PROCEDURE ResetCursor; Virtual;
       PROCEDURE Select;
       PROCEDURE Awaken; Virtual;
       PROCEDURE DrawView;
@@ -420,7 +421,7 @@ TYPE
       PROCEDURE PutInFrontOf (Target: PView);
       PROCEDURE DisplaceBy (Dx, Dy: Sw_Integer); Virtual;
       PROCEDURE SetCommands (Commands: TCommandSet);
-      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
+      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
       PROCEDURE EnableCommands (Commands: TCommandSet);
       PROCEDURE DisableCommands (Commands: TCommandSet);
       PROCEDURE SetState (AState: Word; Enable: Boolean); Virtual;
@@ -460,6 +461,7 @@ TYPE
       PROCEDURE MakeLocal (Source: TPoint; Var Dest: TPoint);
       PROCEDURE MakeGlobal (Source: TPoint; Var Dest: TPoint);
       PROCEDURE WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
+      PROCEDURE WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
       PROCEDURE WriteChar (X, Y: Sw_Integer; C: Char; Color: Byte;
         Count: Sw_Integer);
       PROCEDURE DragView (Event: TEvent; Mode: Byte; Var Limits: TRect;
@@ -499,6 +501,7 @@ TYPE
       PROCEDURE UnLock;
       PROCEDURE Awaken; Virtual;
       PROCEDURE ReDraw;
+      PROCEDURE ReDrawArea (X1, Y1, X2, Y2: Sw_Integer); Virtual;
       PROCEDURE SelectDefaultView;
       PROCEDURE Insert (P: PView);
       PROCEDURE Delete (P: PView);
@@ -627,7 +630,6 @@ TYPE
       PROCEDURE Store (Var S: TStream);
       PROCEDURE HandleEvent (Var Event: TEvent); Virtual;
       PROCEDURE ChangeBounds (Var Bounds: TRect); Virtual;
-      PRIVATE
       PROCEDURE FocusItemNum (Item: Sw_Integer); Virtual;
    END;
    PListViewer = ^TListViewer;
@@ -877,6 +879,37 @@ CONST
 {                          PRIVATE INTERNAL ROUTINES                        }
 {***************************************************************************}
 
+    function posidx(const substr,s : string;idx:sw_integer):sw_integer;
+      var
+        i,j : sw_integer;
+        e   : boolean;
+      begin
+        i:=idx;
+        j:=0;
+        e:=(length(SubStr)>0);
+        while e and (i<=Length(s)-Length(SubStr)) do
+         begin
+           inc(i);
+           if (SubStr[1]=s[i]) and (Substr=Copy(s,i,Length(SubStr))) then
+            begin
+              j:=i;
+              e:=false;
+            end;
+         end;
+        PosIdx:=j;
+      end;
+
+
+procedure DrawScreenBuf;
+begin
+  if (LockUpdateScreen=0) then
+   begin
+     HideMouse;
+     UpdateScreen(false);
+     ShowMouse;
+   end;
+end;
+
 {***************************************************************************}
 {                              OBJECT METHODS                               }
 {***************************************************************************}
@@ -1206,6 +1239,75 @@ PROCEDURE TView.Draw;
 BEGIN                                                 { Abstract method }
 END;
 
+
+procedure TView.ResetCursor;
+const
+  sfV_CV_F:word = sfVisible + sfCursorVis + sfFocused;
+var
+  p,p2 : PView;
+  G : PGroup;
+  cur : TPoint;
+
+  function Check0:boolean;
+  var
+    res : byte;
+  begin
+    res:=0;
+    while res=0 do
+     begin
+       p:=p^.next;
+       if p=p2 then
+        begin
+          p:=P^.owner;
+          res:=1
+        end
+       else
+        if ((p^.state and sfVisible)<>0) and
+           (cur.x>=p^.origin.x) and
+           (cur.x<p^.size.x+p^.origin.x) and
+           (cur.y>=p^.origin.y) and
+           (cur.y<p^.size.y+p^.origin.y) then
+          res:=2;
+     end;
+    Check0:=res=2;
+  end;
+
+begin
+  if (not TextModeGFV) then
+   exit;
+  if ((state and sfV_CV_F) = sfV_CV_F) then
+   begin
+     p:=@Self;
+     cur:=cursor;
+     while true do
+      begin
+        if (cur.x<0) or (cur.x>=p^.size.x) or
+           (cur.y<0) or (cur.y>=p^.size.y) then
+          break;
+        inc(cur.X,p^.origin.X);
+        inc(cur.Y,p^.origin.Y);
+        p2:=p;
+        G:=p^.owner;
+        if G=Nil then { top view }
+         begin
+           Video.SetCursorPos(cur.x,cur.y);
+           if (state and sfCursorIns)<>0 then
+            Video.SetCursorType(crBlock)
+           else
+            Video.SetCursorType(crUnderline);
+           exit;
+         end;
+        if (G^.state and sfVisible)=0 then
+         break;
+        p:=G^.Last;
+        if Check0 then
+         break;
+      end; { while }
+   end; { if }
+  Video.SetCursorType(crHidden);
+end;
+
+
 {--TView--------------------------------------------------------------------}
 {  Select -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 05May98 LdB            }
 {---------------------------------------------------------------------------}
@@ -1237,7 +1339,8 @@ BEGIN
      SetViewLimits;                                   { Set view limits }
      GetViewSettings(ViewPort, TextModeGFV);          { Get set viewport }
      If OverlapsArea(ViewPort.X1, ViewPort.Y1,
-     ViewPort.X2, ViewPort.Y2) Then Begin             { Must be in area }
+                     ViewPort.X2, ViewPort.Y2) Then
+      Begin             { Must be in area }
          Parent:=Owner;
          While Assigned(Parent) do Begin
            If (Parent^.LockFlag>0) then
@@ -1248,6 +1351,7 @@ BEGIN
              End;
            Parent:=Parent^.Owner;
          End;
+         inc(LockUpdateScreen); { don't update the screen yet }
          HideMouseCursor;                             { Hide mouse cursor }
          If (DrawMask = 0) OR (DrawMask = vdNoChild)  { No special masks set }
             { OR Assigned(LimitsLocked) }
@@ -1256,8 +1360,8 @@ BEGIN
            Draw;                                      { Draw interior }
            If (GOptions AND goDrawFocus <> 0) Then
              DrawFocus;                               { Draw focus }
-           If (State AND sfCursorVis <> 0)
-             Then DrawCursor;                         { Draw any cursor }
+           If (State AND sfCursorVis <> 0) Then
+             DrawCursor;                              { Draw any cursor }
            If (Options AND ofFramed <> 0) OR
            (GOptions AND goThickFramed <> 0)          { View has border }
              Then DrawBorder;                         { Draw border }
@@ -1283,11 +1387,14 @@ BEGIN
                DrawMask := DrawMask and Not vdFocus;
                DrawFocus;                          { Check focus mask }
              End;
-           If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
-             Begin
-               DrawMask := DrawMask and Not vdCursor;
-               DrawCursor;                              { Draw any cursor }
-             End;
+           if not TextModeGFV then
+            begin
+              If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
+               Begin
+                 DrawMask := DrawMask and Not vdCursor;
+                 DrawCursor;                              { Draw any cursor }
+               End;
+            end;
            If (DrawMask AND vdBorder <> 0) Then       { Check border mask }
              Begin
                DrawMask := DrawMask and Not vdBorder;
@@ -1305,6 +1412,16 @@ BEGIN
 {$endif ndef NoShadow}
          End;
          ShowMouseCursor;                             { Show mouse cursor }
+     dec(LockUpdateScreen);
+     if TextModeGFV then
+      begin
+        DrawScreenBuf;
+        If (DrawMask AND vdCursor <> 0) Then       { Check cursor mask }
+          Begin
+            DrawMask := DrawMask and Not vdCursor;
+            DrawCursor;                              { Draw any cursor }
+          End;
+      end;
      End;
      ReleaseViewLimits;                               { Release the limits }
    End;
@@ -1333,6 +1450,8 @@ END;
 {---------------------------------------------------------------------------}
 PROCEDURE TView.DrawCursor;
 BEGIN                                                 { Abstract method }
+  if State and sfFocused <> 0 then
+   ResetCursor;
 END;
 
 {--TView--------------------------------------------------------------------}
@@ -1440,7 +1559,10 @@ END;
 PROCEDURE TView.SetViewLimits;
 VAR X1, Y1, X2, Y2: Sw_Integer; P: PGroup; ViewPort: ViewPortType; Ca: PComplexArea;
 BEGIN
-   If (MaxAvail >= SizeOf(TComplexArea)) Then Begin   { Check enough memory }
+{$ifndef PPC_FPC}
+   If (MaxAvail >= SizeOf(TComplexArea)) Then
+{$endif}
+    Begin   { Check enough memory }
      GetMem(Ca, SizeOf(TComplexArea));                { Allocate memory }
      GetViewSettings(ViewPort, TextModeGFV);          { Fetch view port }
      Ca^.X1 := ViewPort.X1;                           { Hold current X1 }
@@ -1535,8 +1657,7 @@ BEGIN
          For Y := Y1 To Y2 Do Begin
            WriteAbs(X1,Y, X2-X1, Buf);
          End;
-         { FIXME: we shouldn't update always here }
-         UpdateScreen(false);
+         DrawScreenBuf;
        End;
    End;
 END;
@@ -1614,8 +1735,13 @@ BEGIN
    Cursor.X := X;                                     { New x position }
    Cursor.Y := Y;                                     { New y position }
    If (State AND sfCursorVis <> 0) Then Begin         { Cursor visible }
-     SetDrawMask(vdCursor);                           { Set draw mask }
-     DrawView;                                        { Draw the cursor }
+     if TextModeGFV then
+      ResetCursor
+     else
+      begin
+        SetDrawMask(vdCursor);                           { Set draw mask }
+        DrawView;                                        { Draw the cursor }
+      end;
    End;
 END;
 
@@ -1642,8 +1768,8 @@ BEGIN
        State := State AND NOT sfVisible;              { Temp stop drawing }
        If (LastView = Target) Then
          If (Owner <> Nil) Then Owner^.ReDrawArea(
-           RawOrigin.X, RawOrigin.Y, RawOrigin.X +
-           RawSize.X, RawOrigin.Y + RawSize.Y);       { Redraw old area }
+           RawOrigin.X, RawOrigin.Y, RawOrigin.X + RawSize.X,
+           RawOrigin.Y + RawSize.Y);       { Redraw old area }
        Owner^.Lock;
        Owner^.RemoveView(@Self);                      { Remove from list }
        Owner^.InsertView(@Self, Target);              { Insert into list }
@@ -1752,8 +1878,9 @@ BEGIN
        Then SetState(sfExposed, Enable);              { Expose this view }
      If Enable Then DrawView Else                     { Draw the view }
        If (Owner <> Nil) Then Owner^.ReDrawArea(      { Owner valid }
-         RawOrigin.X, RawOrigin.Y, RawOrigin.X +
-         RawSize.X, RawOrigin.Y + RawSize.Y);         { Owner redraws area }
+         RawOrigin.X, RawOrigin.Y,
+         RawOrigin.X + RawSize.X + ShadowSize.X*SysFontWidth,
+         RawOrigin.Y + RawSize.Y + ShadowSize.Y*SysFontHeight);         { Owner redraws area }
      If (Options AND ofSelectable <> 0) Then          { View is selectable }
        If (Owner <> Nil) Then Owner^.ResetCurrent;    { Reset selected }
    End;
@@ -1773,8 +1900,13 @@ BEGIN
    End;
    If (AState AND (sfCursorVis + sfCursorIns) <> 0)   { Change cursor state }
    Then Begin
-     SetDrawMask(vdCursor);                           { Set cursor draw mask }
-     ShouldDraw:=true;
+     if TextModeGFV then
+      ResetCursor
+     else
+      begin
+        SetDrawMask(vdCursor);                           { Set cursor draw mask }
+        ShouldDraw:=true;
+      end;
    End;
    If ShouldDraw then
        DrawView;                                      { Redraw the border }
@@ -2370,6 +2502,24 @@ BEGIN
    End;
 END;
 
+{--TGroup-------------------------------------------------------------------}
+{  ReDraw -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 17Sep97 LdB              }
+{---------------------------------------------------------------------------}
+PROCEDURE TGroup.ReDrawArea (X1, Y1, X2, Y2: Sw_Integer);
+VAR P: PView;
+BEGIN
+   { redraw this }
+   inherited RedrawArea(X1,Y1,X2,Y2);
+   { redraw group members }
+   If (DrawMask AND vdNoChild = 0) Then Begin         { No draw child clear }
+     P := Last;                                       { Start on Last }
+     While (P <> Nil) Do Begin
+       P^.ReDrawArea(X1, Y1, X2, Y2);                 { Redraw each subview }
+       P := P^.PrevView;                              { Move to prior view }
+     End;
+   End;
+END;
+
 {--TGroup-------------------------------------------------------------------}
 {  Awaken -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 15Sep97 LdB            }
 {---------------------------------------------------------------------------}
@@ -2924,18 +3074,21 @@ END;
 {  Init -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 22May98 LdB              }
 {---------------------------------------------------------------------------}
 CONSTRUCTOR TScrollBar.Init (Var Bounds: TRect);
-CONST VChars: TScrollChars = (#30, #31, #177, #254, #178);
-      HChars: TScrollChars = (#17, #16, #177, #254, #178);
+const
+  VChars: array[boolean] of TScrollChars =
+     (('^','V', #177, #254, #178),(#30, #31, #177, #254, #178));
+  HChars: array[boolean] of TScrollChars =
+     (('<','>', #177, #254, #178),(#17, #16, #177, #254, #178));
 BEGIN
    Inherited Init(Bounds);                            { Call ancestor }
    PgStep := 1;                                       { Page step size = 1 }
    ArStep := 1;                                       { Arrow step sizes = 1 }
    If (Size.X = 1) Then Begin                         { Vertical scrollbar }
      GrowMode := gfGrowLoX + gfGrowHiX + gfGrowHiY;   { Grow vertically }
-     Chars := VChars;                                 { Vertical chars }
+     Chars := VChars[LowAscii];                       { Vertical chars }
    End Else Begin                                     { Horizontal scrollbar }
      GrowMode := gfGrowLoY + gfGrowHiX + gfGrowHiY;   { Grow horizontal }
-     Chars := HChars;                                 { Horizontal chars }
+     Chars := HChars[LowAscii];                       { Horizontal chars }
    End;
 END;
 
@@ -4247,7 +4400,7 @@ BEGIN
      End;
      For Y := Y1 To Y2 Do
        WriteAbs(X1,Y, X2-X1, Buf);
-     UpdateScreen(false);
+     DrawScreenBuf;
    End;
 END;
 
@@ -4414,7 +4567,7 @@ BEGIN
          End;
          Y := Y + SysFontHeight;                        { Next line down }
        end;
-     Video.UpdateScreen(false);
+       DrawScreenBuf;
      End;
    end;
 END;
@@ -4462,7 +4615,8 @@ BEGIN
          Y := Y + SysFontHeight;                       { Next line down }
        End;
      end;
-     Video.UpdateScreen(false);
+     If TextModeGFV then
+       DrawScreenBuf;
    End;
 END;
 
@@ -4494,6 +4648,86 @@ BEGIN
    End;
 END;
 
+PROCEDURE TView.WriteCStr (X, Y: Sw_Integer; Str: String; Color1, Color2 : Byte);
+VAR I, J, Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
+    Xw, Yw, TiBuf, Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
+    Buf : TDrawBuffer;
+    FoundSwap : boolean;
+BEGIN
+   If (State AND sfVisible <> 0) AND                  { View is visible }
+   (State AND sfExposed <> 0) AND                     { View is exposed }
+   (State AND sfIconised = 0) AND                     { View not iconized }
+   (Length(Str) > 0) Then Begin                       { String is valid }
+
+     j:=1;
+     repeat
+       FoundSwap:=false;
+       i:=PosIdx('~',Str,j);
+       if i>0 then
+        FoundSwap:=true
+       else
+        i:=Length(Str)+1;
+
+        Fc := GetColor(Color1);                          { Get view color }
+        Bc := Fc AND $F0 SHR 4;                          { Calc back colour }
+        Fc := Fc AND $0F;                                { Calc text colour }
+
+        If RevCol Then Begin
+          B := Bc;
+          Bc := Fc;
+          Fc := B;
+        End;
+
+        If (X >= 0) AND (Y >= 0) AND ((GOptions and goGraphView)=0) Then Begin
+          Xw := RawOrigin.X+X*FontWidth;                    { X position }
+          Yw := RawOrigin.Y+Y*FontHeight;                   { Y position }
+        End Else Begin
+          Xw := RawOrigin.X + Abs(X);
+          Yw := RawOrigin.Y + Abs(Y);
+        End;
+        GetViewSettings(ViewPort, TextModeGFV);
+
+       If (TextModeGFV <> TRUE) Then Begin              { GRAPHICAL MODE GFV }
+         SetFillStyle(SolidFill, Bc);                   { Set fill style }
+         Bar(Xw-ViewPort.X1, Yw-ViewPort.Y1,
+           Xw-ViewPort.X1+Length(Str)*FontWidth,
+           Yw-ViewPort.Y1+FontHeight-1);
+         SetColor(Fc);
+         OutTextXY(Xw-ViewPort.X1, Yw-ViewPort.Y1+2, Copy(Str,j,i-j));{ Write text char }
+       End Else Begin                                   { TEXT MODE GFV }
+         Tix := Xw DIV SysFontWidth;
+         Tiy := Yw DIV SysFontHeight;
+         TiBuf := 0;
+         For Ti := j To i-1 Do Begin
+           Buf[TiBuf]:=((Fc or (Bc shl 4)) shl 8) or Ord(Str[Ti]);
+           inc(TiBuf);
+         end;
+         WriteAbs(Tix,TiY,i-j,Buf);
+       End;
+
+      { increase position on screen }
+      inc(X,(i-j));
+
+      { Swap colors }
+      if FoundSwap then
+       begin
+         { Swap color1 and color2 }
+         B := Color1;
+         Color1 := Color2;
+         Color2 := B;
+         { increase position in string }
+         j:=i+1;
+         { we're at the last char }
+         if (j>length(Str)) then
+          break;
+       end;
+
+     until not FoundSwap;
+     If TextModeGFV then
+       DrawScreenBuf;
+   End;
+END;
+
 PROCEDURE TView.WriteStr (X, Y: Sw_Integer; Str: String; Color: Byte);
 VAR Fc, Bc, B: Byte; X1, Y1, X2, Y2: Sw_Integer;
     Tix, Tiy, Ti: Sw_Integer; ViewPort: ViewPortType;
@@ -4537,7 +4771,8 @@ BEGIN
        end;
        WriteAbs(Tix,TiY,Length(Str),Buf);
      End;
-     UpdateScreen(false);
+     If TextModeGFV then
+       DrawScreenBuf;
    End;
 END;
 
@@ -4585,7 +4820,7 @@ BEGIN
          X := X + I*FontWidth;                          { Move x position }
      End;
      If TextModeGFV then
-       UpdateScreen(false);
+       DrawScreenBuf;
    End;
 END;
 
@@ -4887,10 +5122,9 @@ END;
 
 
 
-{ÞßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÝ}
-{Þ                        TScroller OBJECT METHODS                         Ý}
-{ÞÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÝ}
-
+{***************************************************************************}
+{                         TScroller OBJECT METHODS                          }
+{***************************************************************************}
 
 PROCEDURE TScroller.ScrollDraw;
 VAR D: TPoint;
@@ -4979,7 +5213,12 @@ BEGIN
 {$endif UseLock}
 END;
 
+
 PROCEDURE TWindow.DrawBorder;
+const
+  LargeC:array[boolean] of char=('^',#24);
+  RestoreC:array[boolean] of char=('|',#18);
+  ClickC:array[boolean] of char=('*',#15);
 VAR Fc, Bc: Byte; X, Y: Sw_Integer; S: String;
     ViewPort: ViewPortType;
     I : Sw_Integer;
@@ -4988,9 +5227,10 @@ VAR Fc, Bc: Byte; X, Y: Sw_Integer; S: String;
     HorizontalBar,
     VerticalBar,
     LeftLowCorner,
-    RightLowCorner : Char;
+    RightLowCorner,C : Char;
     Color : Byte;
     Focused : Boolean;
+    Min, Max: TPoint;
 BEGIN
    Fc := GetColor(2) AND $0F;                        { Foreground colour }
    Bc := (GetColor(2) AND $70) SHR 4;                { Background colour }
@@ -5071,16 +5311,21 @@ BEGIN
        OutTextXY(RawOrigin.X+Y+FontWidth-ViewPort.X1,
          RawOrigin.Y+Y+1-ViewPort.Y1+2, '[*]');       { Write close icon }
      End Else Begin                                   { LEON??? }
-       WriteStr(2,0,'[*]',2);
+       WriteCStr(2,0,'[~'+ClickC[LowAscii]+'~]', 2, 3);
      End;
    End;
    If (Flags AND wfZoom<>0) Then Begin
+     if assigned(Owner) and
+        (Size.X=Owner^.Size.X) and (Size.Y=Owner^.Size.Y) then
+      C:=RestoreC[LowAscii]
+     else
+      C:=LargeC[LowAscii];
      If (TextModeGFV <> True) Then Begin              { GRAPHICS MODE GFV }
        SetColor(GetColor(2) AND $0F);
        OutTextXY(RawOrigin.X+RawSize.X-4*FontWidth-Y-ViewPort.X1,
-         RawOrigin.Y+Y+1-ViewPort.Y1+2, '['+#24+']'); { Write zoom icon }
+         RawOrigin.Y+Y+1-ViewPort.Y1+2, '['+C+']'); { Write zoom icon }
      End Else Begin                                   { LEON??? }
-       WriteStr(Size.X-5,0,'['+#24+']',2);
+       WriteCStr(Size.X-5,0,'[~'+C+'~]', 2, 3);
      End;
    End;
    If not TextModeGFV then
@@ -5183,7 +5428,11 @@ END.
 
 {
  $Log$
- Revision 1.15  2001-08-04 19:14:33  peter
+ Revision 1.16  2001-08-05 02:03:14  peter
+   * view redrawing and small cursor updates
+   * merged some more FV extensions
+
+ Revision 1.15  2001/08/04 19:14:33  peter
    * Added Makefiles
    * added FV specific units and objects from old FV