home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / tvision / gravis / gv / gvstddlg.int < prev    next >
Encoding:
Text File  |  1994-05-23  |  9.1 KB  |  296 lines

  1. Unit GVStdDlg;
  2.  
  3.  
  4. Interface
  5.  
  6. uses Objects, Drivers, Views, GVViews, GVDialog, GVMsgBox, Dos;
  7.  
  8. Const
  9.  
  10. { Palettes }
  11.  
  12.   CFileInfoPane = #141#140;
  13.  
  14. { Commands }
  15.  
  16.   cmFileOpen    = 800;   { Returned from TFileDialog when Open pressed }
  17.   cmFileReplace = 801;   { Returned from TFileDialog when Replace pressed }
  18.   cmFileClear   = 802;   { Returned from TFileDialog when Clear pressed }
  19.   cmFileInit    = 803;   { Used by TFileDialog internally }
  20.   cmChangeDir   = 804;   { Used by TChDirDialog internally }
  21.   cmRevert      = 805;   { Used by TChDirDialog internally }
  22.  
  23. { Messages }
  24.  
  25.   cmFileFocused = 806;    { A new file was focused in the TFileList }
  26.   cmFileDoubleClicked     { A file was selected in the TFileList }
  27.                 = 807;
  28.  
  29. Type
  30.  
  31. { TSearchRec record }
  32.  
  33.   {  Record used to store directory information by TFileDialog }
  34.  
  35.   TSearchRec = record
  36.     Attr: Byte;
  37.     Time: LongInt;
  38.     Size: LongInt;
  39.     Name: String[12];
  40.   end;
  41.  
  42. Type
  43.  
  44. { TFileInputLine object }
  45.  
  46.   { TFileInputLine is a special input line that is used by      }
  47.   { TFileDialog that will update its contents in response to a  }
  48.   { cmFileFocused command from a TFileList.                     }
  49.  
  50.   PFileInputLine = ^TFileInputLine;
  51.   TFileInputLine = Object (TInputLine)
  52.     constructor Init(var Bounds: TRect; AMaxLen: Integer);
  53.     procedure HandleEvent(var Event: TEvent); virtual;
  54.   end;
  55.  
  56. { TFileCollection object }
  57.  
  58.   { TFileCollection is a collection of TSearchRec's.            }
  59.  
  60.   PFileCollection = ^TFileCollection;
  61.   TFileCollection = Object (TSortedCollection)
  62.     function Compare (Key1, Key2: Pointer): Integer; virtual;
  63.     procedure FreeItem (Item: Pointer); virtual;
  64.     function GetItem (var S: TStream): Pointer; virtual;
  65.     procedure PutItem (var S: TStream; Item: Pointer); virtual;
  66.   end;
  67.  
  68. { TSortedListBox object }
  69.  
  70.   { TSortedListBox is a TListBox that assumes it has a          }
  71.   { TSortedCollection instead of just a TCollection.  It will   }
  72.   { perform an incremental search on the contents.              }
  73.  
  74.   PSortedListBox = ^TSortedListBox;
  75.   TSortedListBox = Object (TListBox)
  76.     SearchPos: Word;
  77.     ShiftState: Byte;
  78.     constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
  79.     procedure HandleEvent (var Event: TEvent); virtual;
  80.     function GetKey (var S: String): Pointer; virtual;
  81.     procedure NewList (AList: PCollection); virtual;
  82.   end;
  83.  
  84. { TFileList object }
  85.  
  86.   { TFileList is a TSortedList box that assumes it contains     }
  87.   { a TFileCollection as its collection.  It also communicates  }
  88.   { through broadcast messages to TFileInput and TInfoPane      }
  89.   { what file is currently selected.                            }
  90.  
  91.   PFileList = ^TFileList;
  92.   TFileList = Object (TSortedListBox)
  93.     constructor Init (var Bounds: TRect; AWildCard: PathStr;
  94.       AScrollBar: PScrollBar);
  95.     destructor Done; virtual;
  96.     function DataSize: Word; virtual;
  97.     procedure FocusItem (Item: Integer); virtual;
  98.     procedure GetData (var Rec); virtual;
  99.     function GetText (Item: Integer; MaxLen: Integer): String; virtual;
  100.     function GetKey (var S: String): Pointer; virtual;
  101.     procedure HandleEvent (var Event: TEvent); virtual;
  102.     procedure ReadDirectory (AWildCard: PathStr);
  103.     procedure SetData (var Rec); virtual;
  104.   end;
  105.  
  106. { TFileInfoPane object }
  107.  
  108.   { Palette layout }
  109.   { 1 = Background }
  110.   { 2 = Text       }
  111.  
  112.   { TFileInfoPane is a TView that displays the information      }
  113.   { about the currently selected file in the TFileList          }
  114.   { of a TFileDialog.                                           }
  115.  
  116.   PFileInfoPane = ^TFileInfoPane;
  117.   TFileInfoPane = Object (TGView)
  118.     S: TSearchRec;
  119.     constructor Init(var Bounds: TRect);
  120.     constructor Load(var Str: TStream);
  121.     procedure ChangeBounds (var Bounds: TRect); virtual;
  122.     procedure Draw; virtual;
  123.     function GetPalette: PPalette; virtual;
  124.     procedure HandleEvent (var Event: TEvent); virtual;
  125.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  126.   private
  127.     Flag: Boolean;
  128.     Path: PathStr;
  129.   end;
  130.  
  131.   { TFileDialog is a standard file name input dialog            }
  132.  
  133.   TWildStr = PathStr;
  134.  
  135. const
  136.  
  137.   fdOkButton      = $0001;      { Put an OK button in the dialog }
  138.   fdOpenButton    = $0002;      { Put an Open button in the dialog }
  139.   fdReplaceButton = $0004;      { Put a Replace button in the dialog }
  140.   fdClearButton   = $0008;      { Put a Clear button in the dialog }
  141.   fdHelpButton    = $0010;      { Put a Help button in the dialog }
  142.   fdNoLoadDir     = $0100;      { Do not load the current directory }
  143.                                 { contents into the dialog at Init. }
  144.                                 { This means you intend to change the }
  145.                                 { WildCard by using SetData or store }
  146.                                 { the dialog on a stream. }
  147.  
  148. type
  149.  
  150. { TFileDialog object }
  151.  
  152.   PFileDialog = ^TFileDialog;
  153.   TFileDialog = Object (TDialog)
  154.     FileName: PFileInputLine;
  155.     FileList: PFileList;
  156.     WildCard: TWildStr;
  157.     Directory: PString;
  158.     constructor Init (AWildCard: TWildStr; ATitle: String;
  159.       InputName: String; AOptions: Word; HistoryId: Byte);
  160.     constructor Load (var S: TStream);
  161.     destructor Done; virtual;
  162.     procedure GetData (var Rec); virtual;
  163.     procedure GetFileName (var S: PathStr);
  164.     procedure HandleEvent (var Event: TEvent); virtual;
  165.     procedure SetData (var Rec); virtual;
  166.     procedure Store (var S: TStream);
  167.     function Valid (Command: Word): Boolean; virtual;
  168.   private
  169.     procedure ReadDirectory;
  170.   end;
  171.  
  172. { TDirEntry record }
  173.  
  174.   PDirEntry = ^TDirEntry;
  175.   TDirEntry = Record
  176.     DisplayText: PString;
  177.     Directory: PString;
  178.   end;
  179.  
  180. { TDirCollection object }
  181.  
  182.   { TDirCollection is a collection of TDirEntry's used by       }
  183.   { TDirListBox.                                                }
  184.  
  185.   PDirCollection = ^TDirCollection;
  186.   TDirCollection = Object (TCollection)
  187.     function GetItem (var S: TStream): Pointer; virtual;
  188.     procedure FreeItem (Item: Pointer); virtual;
  189.     procedure PutItem (var S: TStream; Item: Pointer); virtual;
  190.   end;
  191.  
  192. { TDirListBox object }
  193.  
  194.   { TDirListBox displays a tree of directories for use in the }
  195.   { TChDirDialog.                                               }
  196.  
  197.   PDirListBox = ^TDirListBox;
  198.   TDirListBox = Object (TListBox)
  199.     Dir: DirStr;
  200.     Cur: Word;
  201.     constructor Init (var Bounds: TRect; AScrollBar: PScrollBar);
  202.     destructor Done; virtual;
  203.     procedure DrawItem (Item: Integer); virtual;
  204.     function GetText (Item: Integer; MaxLen: Integer): String; virtual;
  205.     procedure HandleEvent (var Event: TEvent); virtual;
  206.     function IsSelected (Item: Integer): Boolean; virtual;
  207.     procedure NewDirectory (var ADir: DirStr);
  208.     procedure SetState (AState: Word; Enable: Boolean); virtual;
  209.   end;
  210.  
  211. { TChDirDialog object }
  212.  
  213.   { TChDirDialog is a standard change directory dialog.         }
  214.  
  215. Const
  216.  
  217.   cdNormal     = $0000; { Option to use dialog immediately }
  218.   cdNoLoadDir  = $0001; { Option to init the dialog to store on a stream }
  219.   cdHelpButton = $0002; { Put a help button in the dialog }
  220.  
  221. Type
  222.  
  223.   PChDirDialog = ^TChDirDialog;
  224.   TChDirDialog = object(TDialog)
  225.     DirInput: PInputLine;
  226.     DirList: PDirListBox;
  227.     OkButton: PButton;
  228.     ChDirButton: PButton;
  229.     constructor Init (AOptions: Word; HistoryId: Byte);
  230.     constructor Load (var S: TStream);
  231.     function DataSize: Word; virtual;
  232.     procedure GetData (var Rec); virtual;
  233.     procedure HandleEvent (var Event: TEvent); virtual;
  234.     procedure SetData (var Rec); virtual;
  235.     procedure Store (var S: TStream);
  236.     function Valid (Command: Word): Boolean; virtual;
  237.   private
  238.     procedure SetUpDialog;
  239.   end;
  240.  
  241. Const
  242.  
  243. { TStream registration records }
  244.  
  245.   RFileInputLine: TStreamRec = (
  246.      ObjType: 60;
  247.      VmtLink: Ofs(TypeOf(TFileInputLine)^);
  248.      Load:    @TFileInputLine.Load;
  249.      Store:   @TFileInputLine.Store);
  250.  
  251.   RFileCollection: TStreamRec = (
  252.      ObjType: 61;
  253.      VmtLink: Ofs(TypeOf(TFileCollection)^);
  254.      Load:    @TFileCollection.Load;
  255.      Store:   @TFileCollection.Store);
  256.  
  257.   RFileList: TStreamRec = (
  258.      ObjType: 62;
  259.      VmtLink: Ofs(TypeOf(TFileList)^);
  260.      Load:    @TFileList.Load;
  261.      Store:   @TFileList.Store);
  262.  
  263.   RFileInfoPane: TStreamRec = (
  264.      ObjType: 63;
  265.      VmtLink: Ofs(TypeOf(TFileInfoPane)^);
  266.      Load:    @TFileInfoPane.Load;
  267.      Store:   @TFileInfoPane.Store);
  268.  
  269.   RFileDialog: TStreamRec = (
  270.      ObjType: 64;
  271.      VmtLink: Ofs(TypeOf(TFileDialog)^);
  272.      Load:    @TFileDialog.Load;
  273.      Store:   @TFileDialog.Store);
  274.  
  275.   RDirCollection: TStreamRec = (
  276.      ObjType: 65;
  277.      VmtLink: Ofs(TypeOf(TDirCollection)^);
  278.      Load:    @TDirCollection.Load;
  279.      Store:   @TDirCollection.Store);
  280.  
  281.   RDirListBox: TStreamRec = (
  282.      ObjType: 66;
  283.      VmtLink: Ofs(TypeOf(TDirListBox)^);
  284.      Load:    @TDirListBox.Load;
  285.      Store:   @TDirListBox.Store);
  286.  
  287.   RChDirDialog: TStreamRec = (
  288.      ObjType: 67;
  289.      VmtLink: Ofs(TypeOf(TChDirDialog)^);
  290.      Load:    @TChDirDialog.Load;
  291.      Store:   @TChDirDialog.Store);
  292.  
  293. procedure RegisterGVStdDlg;
  294.  
  295. Implementation
  296.