home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Pascal V7.0 / TVFM.ZIP / INFOVIEW.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-30  |  2.6 KB  |  126 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Vision File Manager Demo               }
  4. {   Copyright (c) 1992 by Borland International  }
  5. {                                                }
  6. {************************************************}
  7.  
  8. unit InfoView;
  9.  
  10. interface
  11.  
  12. uses Objects, Drivers, Views;
  13.  
  14. type
  15.   PCntView = ^TCntView;
  16.   TCntView = object(TView)
  17.     Bytes: LongInt;
  18.     Count: LongInt;
  19.     constructor Init(var Bounds: TRect);
  20.     procedure Draw; virtual;
  21.     procedure HandleEvent(var Event: TEvent); virtual;
  22.   private
  23.     function GetText: String; virtual;
  24.   end;
  25.  
  26.   PTagView = ^TTagView;
  27.   TTagView = object(TCntView)
  28.     procedure HandleEvent(var Event: TEvent); virtual;
  29.   private
  30.     function GetText: String; virtual;
  31.   end;
  32.  
  33.  
  34. implementation
  35.  
  36. uses Equ, FileView, Globals;
  37.  
  38. constructor TCntView.Init(var Bounds: TRect);
  39. begin
  40.   inherited Init(Bounds);
  41.   Count := 0;
  42.   Bytes := 0;
  43.   GrowMode := gfGrowHiY + gfGrowLoY + gfGrowHiX;
  44.   EventMask := evBroadcast;
  45. end;
  46.  
  47. procedure TCntView.Draw;
  48. var
  49.   B: TDrawBuffer;
  50.   Color: Byte;
  51. begin
  52.   Color := GetColor(6);
  53.   MoveChar(B, ' ', Color, Size.X);
  54.   MoveStr(B, GetText, Color);
  55.   WriteLine(0, 0, Size.X, Size.Y, B);
  56. end;
  57.  
  58. function TCntView.GetText: String;
  59. var
  60.   Str: String;
  61. begin
  62.   FormatStr(Str, '%d bytes in %d files', Bytes);
  63.   GetText := Str;
  64. end;
  65.  
  66. procedure TCntView.HandleEvent(var Event: TEvent);
  67. begin
  68.   inherited HandleEvent(Event);
  69.   if (Event.What = evBroadcast) and (Event.Command = cmScanComplete) then
  70.   begin
  71.     with PScanInfo(Event.InfoPtr)^ do
  72.     begin
  73.       Bytes := ScanBytes;
  74.       Count := ScanCount;
  75.       DrawView;
  76.     end;
  77.   end;
  78. end;
  79.  
  80. { TTagView }
  81. function TTagView.GetText: String;
  82. var
  83.   Str: String;
  84. begin
  85.   FormatStr(Str, '%d bytes in %d tagged files', Bytes);
  86.   GetText := Str;
  87. end;
  88.  
  89. procedure TTagView.HandleEvent(var Event: TEvent);
  90. var
  91.   F: PFileRec;
  92. begin
  93.   { don't execute the directly inherited HandleEvent }
  94.   TView.HandleEvent(Event);
  95.   if Event.What = evBroadcast then
  96.   begin
  97.     case Event.Command of
  98.       cmNewDir,
  99.       cmRescan :
  100.         begin
  101.           Bytes := 0;
  102.           Count := 0;
  103.           DrawView;
  104.         end;
  105.       cmTagChanged :
  106.         begin
  107.           F := Event.InfoPtr;
  108.           if F^.Tagged then
  109.           begin
  110.             Inc(Count);
  111.             Inc(Bytes, F^.Size);
  112.           end
  113.           else
  114.           begin
  115.             Dec(Count);
  116.             Dec(Bytes, F^.Size);
  117.           end;
  118.           DrawView;
  119.           ClearEvent(Event);
  120.         end;
  121.     end;
  122.   end;
  123. end;
  124.  
  125.  
  126. end.