home *** CD-ROM | disk | FTP | other *** search
- Unit GVStdDlg;
-
-
- Interface
-
- uses Objects, Drivers, Views, GVViews, GVDialog, GVMsgBox, Dos;
-
- Const
-
- { Palettes }
-
- CFileInfoPane = #141#140;
-
- { Commands }
-
- cmFileOpen = 800; { Returned from TFileDialog when Open pressed }
- cmFileReplace = 801; { Returned from TFileDialog when Replace pressed }
- cmFileClear = 802; { Returned from TFileDialog when Clear pressed }
- cmFileInit = 803; { Used by TFileDialog internally }
- cmChangeDir = 804; { Used by TChDirDialog internally }
- cmRevert = 805; { Used by TChDirDialog internally }
-
- { Messages }
-
- cmFileFocused = 806; { A new file was focused in the TFileList }
- cmFileDoubleClicked { A file was selected in the TFileList }
- = 807;
-
- Type
-
- { TSearchRec record }
-
- { Record used to store directory information by TFileDialog }
-
- TSearchRec = record
- Attr: Byte;
- Time: LongInt;
- Size: LongInt;
- Name: String[12];
- end;
-
- Type
-
- { TFileInputLine object }
-
- { TFileInputLine is a special input line that is used by }
- { TFileDialog that will update its contents in response to a }
- { cmFileFocused command from a TFileList. }
-
- PFileInputLine = ^TFileInputLine;
- TFileInputLine = Object (TInputLine)
- constructor Init(var Bounds: TRect; AMaxLen: Integer);
- procedure HandleEvent(var Event: TEvent); virtual;
- end;
-
- { TFileCollection object }
-
- { TFileCollection is a collection of TSearchRec's. }
-
- PFileCollection = ^TFileCollection;
- TFileCollection = Object (TSortedCollection)
- function Compare (Key1, Key2: Pointer): Integer; virtual;
- procedure FreeItem (Item: Pointer); virtual;
- function GetItem (var S: TStream): Pointer; virtual;
- procedure PutItem (var S: TStream; Item: Pointer); virtual;
- end;
-
- { TSortedListBox object }
-
- { TSortedListBox is a TListBox that assumes it has a }
- { TSortedCollection instead of just a TCollection. It will }
- { perform an incremental search on the contents. }
-
- PSortedListBox = ^TSortedListBox;
- TSortedListBox = Object (TListBox)
- SearchPos: Word;
- ShiftState: Byte;
- constructor Init(var Bounds: TRect; AScrollBar: PScrollBar);
- procedure HandleEvent (var Event: TEvent); virtual;
- function GetKey (var S: String): Pointer; virtual;
- procedure NewList (AList: PCollection); virtual;
- end;
-
- { TFileList object }
-
- { TFileList is a TSortedList box that assumes it contains }
- { a TFileCollection as its collection. It also communicates }
- { through broadcast messages to TFileInput and TInfoPane }
- { what file is currently selected. }
-
- PFileList = ^TFileList;
- TFileList = Object (TSortedListBox)
- constructor Init (var Bounds: TRect; AWildCard: PathStr;
- AScrollBar: PScrollBar);
- destructor Done; virtual;
- function DataSize: Word; virtual;
- procedure FocusItem (Item: Integer); virtual;
- procedure GetData (var Rec); virtual;
- function GetText (Item: Integer; MaxLen: Integer): String; virtual;
- function GetKey (var S: String): Pointer; virtual;
- procedure HandleEvent (var Event: TEvent); virtual;
- procedure ReadDirectory (AWildCard: PathStr);
- procedure SetData (var Rec); virtual;
- end;
-
- { TFileInfoPane object }
-
- { Palette layout }
- { 1 = Background }
- { 2 = Text }
-
- { TFileInfoPane is a TView that displays the information }
- { about the currently selected file in the TFileList }
- { of a TFileDialog. }
-
- PFileInfoPane = ^TFileInfoPane;
- TFileInfoPane = Object (TGView)
- S: TSearchRec;
- constructor Init(var Bounds: TRect);
- constructor Load(var Str: TStream);
- procedure ChangeBounds (var Bounds: TRect); virtual;
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent (var Event: TEvent); virtual;
- procedure SetState (AState: Word; Enable: Boolean); virtual;
- private
- Flag: Boolean;
- Path: PathStr;
- end;
-
- { TFileDialog is a standard file name input dialog }
-
- TWildStr = PathStr;
-
- const
-
- fdOkButton = $0001; { Put an OK button in the dialog }
- fdOpenButton = $0002; { Put an Open button in the dialog }
- fdReplaceButton = $0004; { Put a Replace button in the dialog }
- fdClearButton = $0008; { Put a Clear button in the dialog }
- fdHelpButton = $0010; { Put a Help button in the dialog }
- fdNoLoadDir = $0100; { Do not load the current directory }
- { contents into the dialog at Init. }
- { This means you intend to change the }
- { WildCard by using SetData or store }
- { the dialog on a stream. }
-
- type
-
- { TFileDialog object }
-
- PFileDialog = ^TFileDialog;
- TFileDialog = Object (TDialog)
- FileName: PFileInputLine;
- FileList: PFileList;
- WildCard: TWildStr;
- Directory: PString;
- constructor Init (AWildCard: TWildStr; ATitle: String;
- InputName: String; AOptions: Word; HistoryId: Byte);
- constructor Load (var S: TStream);
- destructor Done; virtual;
- procedure GetData (var Rec); virtual;
- procedure GetFileName (var S: PathStr);
- procedure HandleEvent (var Event: TEvent); virtual;
- procedure SetData (var Rec); virtual;
- procedure Store (var S: TStream);
- function Valid (Command: Word): Boolean; virtual;
- private
- procedure ReadDirectory;
- end;
-
- { TDirEntry record }
-
- PDirEntry = ^TDirEntry;
- TDirEntry = Record
- DisplayText: PString;
- Directory: PString;
- end;
-
- { TDirCollection object }
-
- { TDirCollection is a collection of TDirEntry's used by }
- { TDirListBox. }
-
- PDirCollection = ^TDirCollection;
- TDirCollection = Object (TCollection)
- function GetItem (var S: TStream): Pointer; virtual;
- procedure FreeItem (Item: Pointer); virtual;
- procedure PutItem (var S: TStream; Item: Pointer); virtual;
- end;
-
- { TDirListBox object }
-
- { TDirListBox displays a tree of directories for use in the }
- { TChDirDialog. }
-
- PDirListBox = ^TDirListBox;
- TDirListBox = Object (TListBox)
- Dir: DirStr;
- Cur: Word;
- constructor Init (var Bounds: TRect; AScrollBar: PScrollBar);
- destructor Done; virtual;
- procedure DrawItem (Item: Integer); virtual;
- function GetText (Item: Integer; MaxLen: Integer): String; virtual;
- procedure HandleEvent (var Event: TEvent); virtual;
- function IsSelected (Item: Integer): Boolean; virtual;
- procedure NewDirectory (var ADir: DirStr);
- procedure SetState (AState: Word; Enable: Boolean); virtual;
- end;
-
- { TChDirDialog object }
-
- { TChDirDialog is a standard change directory dialog. }
-
- Const
-
- cdNormal = $0000; { Option to use dialog immediately }
- cdNoLoadDir = $0001; { Option to init the dialog to store on a stream }
- cdHelpButton = $0002; { Put a help button in the dialog }
-
- Type
-
- PChDirDialog = ^TChDirDialog;
- TChDirDialog = object(TDialog)
- DirInput: PInputLine;
- DirList: PDirListBox;
- OkButton: PButton;
- ChDirButton: PButton;
- constructor Init (AOptions: Word; HistoryId: Byte);
- constructor Load (var S: TStream);
- function DataSize: Word; virtual;
- procedure GetData (var Rec); virtual;
- procedure HandleEvent (var Event: TEvent); virtual;
- procedure SetData (var Rec); virtual;
- procedure Store (var S: TStream);
- function Valid (Command: Word): Boolean; virtual;
- private
- procedure SetUpDialog;
- end;
-
- Const
-
- { TStream registration records }
-
- RFileInputLine: TStreamRec = (
- ObjType: 60;
- VmtLink: Ofs(TypeOf(TFileInputLine)^);
- Load: @TFileInputLine.Load;
- Store: @TFileInputLine.Store);
-
- RFileCollection: TStreamRec = (
- ObjType: 61;
- VmtLink: Ofs(TypeOf(TFileCollection)^);
- Load: @TFileCollection.Load;
- Store: @TFileCollection.Store);
-
- RFileList: TStreamRec = (
- ObjType: 62;
- VmtLink: Ofs(TypeOf(TFileList)^);
- Load: @TFileList.Load;
- Store: @TFileList.Store);
-
- RFileInfoPane: TStreamRec = (
- ObjType: 63;
- VmtLink: Ofs(TypeOf(TFileInfoPane)^);
- Load: @TFileInfoPane.Load;
- Store: @TFileInfoPane.Store);
-
- RFileDialog: TStreamRec = (
- ObjType: 64;
- VmtLink: Ofs(TypeOf(TFileDialog)^);
- Load: @TFileDialog.Load;
- Store: @TFileDialog.Store);
-
- RDirCollection: TStreamRec = (
- ObjType: 65;
- VmtLink: Ofs(TypeOf(TDirCollection)^);
- Load: @TDirCollection.Load;
- Store: @TDirCollection.Store);
-
- RDirListBox: TStreamRec = (
- ObjType: 66;
- VmtLink: Ofs(TypeOf(TDirListBox)^);
- Load: @TDirListBox.Load;
- Store: @TDirListBox.Store);
-
- RChDirDialog: TStreamRec = (
- ObjType: 67;
- VmtLink: Ofs(TypeOf(TChDirDialog)^);
- Load: @TChDirDialog.Load;
- Store: @TChDirDialog.Store);
-
- procedure RegisterGVStdDlg;
-
- Implementation
-