home *** CD-ROM | disk | FTP | other *** search
- {*
- * TvDialog.pas
- *
- * Enhancements to Turbo Vision dialog boxes.
- *
- * Copyright 1992 by Richard W. Hansen
- *
- *}
-
- UNIT TvDialog;
- {$X+}
- {$V-}
-
- {$I TVDEFS.INC}
-
- INTERFACE
-
-
- USES
- Dos,
- TvColl, TvConst, TvString, TvType, TvViews,
- {$IFDEF TVSCROLL}
- TvScroll,
- {$ENDIF}
- App, Dialogs, Drivers, Memory, MsgBox, Objects, StdDlg, Views;
-
-
- CONST
- { 3D Button Palette }
- { 1 = Button normal }
- { 2 = Button shaded }
- { 3 = Button text }
- { 4 = Button disabled text}
- { 5 = Button shortcut text}
- { 6 = Button default text }
- C3DButton = #37#41#38#39#40#42;
-
- { 3D Dialog Palette - additions to normal dialog palette }
- { 33 = Frame normal }
- { 34 = Frame shaded }
- { 35 = Frame passive }
- { 36 = Frame Icon/Frame dragging }
- { 37 = Button normal }
- { 38 = Button text }
- { 39 = Button disabled text }
- { 40 = Button shortcut text }
- { 41 = Button shaded }
- { 42 = Button default text }
- { 43 = Outline normal }
- { 44 = Outline shaded }
- { 45 = Inputline normal }
- { 46 = Inputline selected text }
- { 47 = Inputline arrow }
- { 48 = ListViewer normal }
- { 49 = ListViewer focused }
- { 50 = ListViewer selected }
- { 51 = ListViewer divider }
- { 52 = Reserved }
- { 53 = Reserved }
- { 54 = Reserved }
- { 55 = Reserved }
- { 56 = Reserved }
- { 57 = Reserved }
- { 58 = Reserved }
- { 59 = Reserved }
- { 60 = Reserved }
- { 61 = Reserved }
- C3DDialog = CDialog + #72#73#74#75#76#77#78#79#80#81#82#83#84#85#86#87;
-
- { 3D Outline Palette }
- { 1 = Outline normal }
- { 2 = Outline shaded }
- C3DOutline = #43#44;
-
- { 3D ListViewer Palette }
- { 1 = Active }
- { 2 = Inactive }
- { 3 = Focused }
- { 4 = Selected }
- { 5 = Divider }
- C3DListViewer = #48#48#49#50#51;
-
-
- BarChar : Char = '▒';
- BarFillChar : Char = '█';
-
- ButtonSelect : FrameArray = '╔╗╚╝║║══';
- ButtonNormal1 : FrameArray = '┌┐└┘││──';
- ButtonNormal2 : FrameArray = '┌╖╘╝│║─═';
- ButtonPress : FrameArray = '┌┐└┘││──';
- BorderNormal : FrameArray = '╔╗╚╝║║══';
-
-
- Buttons : Array[0..3] of String[8] =
- ('~Y~es', '~N~o', 'O~K~', '~C~ancel');
- Commands : Array[0..3] of Word =
- (cmYes, cmNo, cmOK, cmCancel);
- Titles : Array[0..3] of String[11] =
- ('Warning', 'Error', 'Information', 'Confirm');
-
- {---- These are in defined in MSGBOX.PAS -------------------------
-
- Message box classes
-
- mfWarning = $0000; < Display a Warning box >
- mfError = $0001; < Dispaly a Error box >
- mfInformation = $0002; < Display an Information Box >
- mfConfirmation = $0003; < Display a Confirmation Box >
-
- Message box button flags
-
- mfYesButton = $0100; < Put a Yes button into the dialog >
- mfNoButton = $0200; < Put a No button into the dialog >
- mfOKButton = $0400; < Put an OK button into the dialog >
- mfCancelButton = $0800; < Put a Cancel button into the dialog >
-
- mfYesNoCancel = mfYesButton + mfNoButton + mfCancelButton;
- < Standard Yes, No, Cancel dialog >
- mfOKCancel = mfOKButton + mfCancelButton;
- < Standard OK, Cancel dialog >
- ------------------------------------------------------------------}
-
- mfMessageLine = $1000;
- mfPauseButton = $2000;
- mfPauseCancel = mfPauseButton + mfCancelButton;
- mfOKPauseCancel= mfOKCancel + mfPauseButton;
-
-
- TYPE
- PSearchRec = ^TSearchRec; {why isn't this public in StdDlg?}
- DriveLetters = 'A'..'Z';
- DriveSet = Set of DriveLetters;
-
-
- TYPE
- { TRunDialog is the base a object used to create progress display
- dialogs. TRunDialogs do some work, while allowing the user to abort.
- It was used to create the TPercentDialog and TPrintDialogs.
- To use a TRunDialog you must provide a Process method. The Process
- method is where the work will get done. TRunDialog.Execute will
- repeated call your Process method, until there is nothing left to do.
- Your Process needs to do the work in small bits, so that Execute can
- run and check for user input. When all the work is done, set RunState to
- pfJobComplete and Execute will terminate. If RunState is ever set to
- pfJobCancel, that means the user aborted, and your Process must close
- done. When you init a TRunDialog, you can choose several different
- combinations of buttons. If AOptions is mfCancel only a cancel button
- will be added, mfCancel and mfOk get a start and a cancel buttons. If
- mfPause is added to AOptions, the dialog will also have pause
- capabilities. You can display a changeable message to the user by
- including mfMessageLine in AOptions. After the dialog is inited, call
- SetMessage to display or change the message line.
- }
- PRunDialog = ^TRunDialog;
- TRunDialog = Object(TDialog)
- Msg : PStaticText;
- RunState: Word;
- pfFlags : Word;
- BtnRow : Byte;
- SButton : PButton;
- CButton : PButton;
-
- Constructor Init(var Bounds : TRect;
- ATitle : TTitleStr;
- AMessage : String;
- AOptions : Word;
- ButtonRow: Byte);
- Function Execute: Word; Virtual;
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure Process; Virtual;
- Procedure ChangeMessage(AMessage : String);
- end;
-
-
- { TPercentDialog is a descendant of TRunDialog for displaying percent
- done and a progress bar. In Init AStep and ATotal are the size to
- increase the completion counter by and the max (or finished) size for
- the counter. Each time you want to indicate some progress, call
- Increment to change the completion counter by AStep size. Alternately,
- you can call IncrementBy supplying the amount to increment the count.
- }
- PPercentDialog = ^TPercentDialog;
- TPercentDialog = Object(TRunDialog)
- Total : LongInt;
- Count : LongInt;
- Step : Word;
- Pct : PStaticText;
- Bar : PStaticText;
-
- Constructor Init(ATitle : TTitleStr;
- AMessage : String;
- ATotal : LongInt;
- AOptions : Word
- );
- Procedure Increment;
- Procedure IncrementBy(AStep : Word);
- end;
-
-
- { TPrintDialog is useful for printing. You must declare a Process method
- to handle the actual output.
- }
- PPrintDialog = ^TPrintDialog;
- TPrintDialog = Object(TRunDialog)
- Constructor Init(ATitle : TTitleStr;
- AMessage : String;
- AOptions : Word
- );
-
- end;
-
-
- { PMessageDialog takes the same parameters as the MsgBox function for
- displaying Title and Buttons. It does not handle formatting parameters
- for strings. You can add multiple strings through multiple calls to
- AddMessage. The dialog will size itself based on the text to be
- displayed. There is checking in the X axis, but none in the Y axis. Just
- be careful not to add to many strings.
- Call Process to display the dialog.
- }
- PMessageDialog = ^TMessageDialog;
- TMessageDialog = Object(TDialog)
- SList : TUnsortedStringCollection;
- DOptions: Word;
-
- Constructor Init(AOptions : Word);
- Procedure AddMessage(St : String);
- Function Process: Word;
- Destructor Done; Virtual;
- end;
-
-
- {$IFDEF NEW_FILE_DIALOG}
- PNewFileCollection = ^TNewFileCollection;
- TNewFileCollection = object(TFileCollection)
- Function Compare(Key1, Key2: Pointer): Integer; Virtual;
- end;
-
-
- PNewFileList = ^TNewFileList;
- TNewFileList = object(TFileList)
- Constructor Init(var Bounds : TRect;
- AWildCard : PathStr;
- AScrollBar : PScrollBar);
-
- Procedure HandleEvent(var Event: TEvent); Virtual;
- Procedure FocusItem(Item: Integer); Virtual;
-
- { **************************************************
- NOTE: The following method must be made virtual in
- the TFileList object in the file STDDLG.PAS unit.
- At line # 102 add a "virtual" declaration.
- ************************************************** }
- Procedure ReadDirectory(AWildCard : PathStr); Virtual;
- end;
-
-
- PDriveList = ^TDriveList;
- TDriveList = object(TNewFileList)
- Constructor Init(var Bounds : TRect;
- AScrollBar : PScrollBar);
- Procedure GetDrives(var Drives : DriveSet);
- Procedure ReadDirectory(AWildCard : PathStr); Virtual;
- Function GetKey(var S : String): Pointer; Virtual;
- end;
-
-
- PNewFileInputLine = ^TNewFileInputLine;
- TNewFileInputLine = object(TFileInputLine)
- Procedure HandleEvent(var Event : TEvent); Virtual;
- end;
-
-
- PNewFileInfoPane = ^TNewFileInfoPane;
- TNewFileInfoPane = object(TFileInfoPane)
- Procedure Draw; Virtual;
- end;
-
-
- PDirectoryInfoPane = ^TDirectoryInfoPane;
- TDirectoryInfoPane = object(TView)
- Constructor Init(var Bounds: TRect);
- Function GetPalette: PPalette; Virtual;
- Procedure HandleEvent(var Event: TEvent); Virtual;
- Procedure Draw; Virtual;
- end;
-
-
- { TNewFileDialog is a new file list dialog that implements a look that
- is much closer to the "Windows" file dialog. It displays directories
- and drives in a separate window from the files list. TNewFileDialog
- has a display line that shows the statistics for the current file. Any
- file that is opened with a double click in the file list will also be
- added to the file history box, unlike the normal TV file dialog.
- }
- PNewFileDialog = ^TNewFileDialog;
- TNewFileDialog = object(TFileDialog)
- DriveList : PDriveList;
-
- Constructor Init(AWildCard : TWildStr;
- ATitle : String;
- InputName : String;
- AOptions : Word;
- HistoryId : Byte);
-
- { **************************************************
- NOTE: In TFileDialog in the unit STDDLG.PAS the
- method ReadDirectory must be made PUBLIC.
- At line # 153 remove the "private" declaration.
- ************************************************** }
- end;
- {$ENDIF}
-
-
- { TLinkedInputLine is for linking an input lines to a ListBox, like the
- file name input in the file dialog box. It is just like an ordinary
- input line, except that it works in conjunction with a TLinkedListBox
- to update its contents whenever the focus of the list box changes.
- You assign a unique command to link the input and ListBox as a parameter
- to the Init constructors of each object. Each ListBox and input line must
- be assigned a unique command. The default HandleEvent expects the event
- InfoPtr field to be a PString, this is the default for standard list
- boxes.
- }
- PLinkedInputLine = ^TLinkedInputLine;
- TLinkedInputLine = Object(TInputLine)
- LinkEvent : Word;
-
- Constructor Init(var Bounds : TRect;
- AMaxLen : Integer;
- EventCode: Word);
- Procedure HandleEvent(var Event : TEvent); Virtual;
- end;
-
-
- { TLinkedListBox is for linking a ListBox to an input line. TLinkedListBox
- works together with the TLinkedInputLine. Each time the focus in the list
- changes, the ListBox will generate an event using the unique link command
- assigned with Init. The event will include a pointer to the focused item
- in the InfoPtr field. The TLinkedInputLine will handle the event and
- extract the data it needs from the focused item and update its display.
- You assign a unique command to link the input and ListBox as a parameter
- to the Init constructors of each object. Each ListBox and input line must
- be assigned a unique command.
- }
- PLinkedListBox = ^TLinkedListBox;
- TLinkedListBox = object(TListBox)
- LinkEvent : Word;
-
- Constructor Init(var Bounds : TRect;
- ANumCols : Word;
- AScrollBar : PScrollBar;
- EventCode : Word);
- Procedure FocusItem(Item: Integer); virtual;
- end;
-
-
- P3DButton = ^T3DButton;
- T3DButton = Object(TButton)
- Down : Boolean;
-
- Constructor Init(var Bounds : TRect;
- ATitle : TTitleStr;
- ACommand : Word;
- AFlags : Word);
- Procedure Draw; Virtual;
- Procedure HandleEvent(var Event : TEvent); Virtual;
- Procedure DrawTitle(ATitle: TTitleStr;
- Color : Word;
- Row : Word);
- Function GetPalette: PPalette; Virtual;
- Procedure GetFrame(var F : FrameArray); Virtual;
- end;
-
-
- PToolButton = ^TToolButton;
- TToolButton = Object(T3DButton)
- Procedure GetFrame(var F : FrameArray); Virtual;
- end;
-
-
- P3DDialog = ^T3DDialog;
- T3DDialog = Object(TDialog)
- Procedure InitFrame; Virtual;
- Function GetPalette: PPalette; Virtual;
- end;
-
-
- P3DOutline = ^T3DOutline;
- T3DOutline = Object(TView)
- Constructor Init(var Bounds : TRect);
- Procedure Draw; Virtual;
- Function GetPalette: PPalette; Virtual;
- Procedure GetFrame(var F : FrameArray); Virtual;
- end;
-
-
- PToolBar = ^TToolBar;
- TToolBar = Object(T3DDialog)
- IsVertical : Boolean;
- LastX : Word;
- LastY : Word;
-
- Constructor Init(var Bounds : TRect;
- Vertical: Boolean);
- Procedure AddTool(ATitle : TTitleStr;
- ACommand : Word);
- Procedure SizeLimits(var Min, Max : TPoint); Virtual;
- Procedure InitFrame; Virtual;
- end;
-
-
- P3DListViewer = ^T3DListViewer;
- T3DListViewer = Object(TView)
- Function GetPalette: PPalette; Virtual;
- end;
-
-
-