home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { Turbo Pascal Version 6.0 }
- { Turbo Vision Unit }
- { }
- { Copyright (c) 1990 Borland International }
- { }
- {*******************************************************}
-
- unit Dialogs;
-
- {$O+,F+,S-,X+}
-
- interface
-
- uses Objects, Drivers, Views;
-
- const
-
- { Color palettes }
-
- CDialog = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
- #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
- CStaticText = #6;
- CLabel = #7#8#9#9;
- CButton = #10#11#12#13#14#14#14#15;
- CCluster = #16#17#18#18;
- CInputLine = #19#19#20#21;
- CHistory = #22#23;
- CHistoryWindow = #19#19#21#24#25#19#20;
- CHistoryViewer = #6#6#7#6#6;
-
- { TButton flags }
-
- bfNormal = $00;
- bfDefault = $01;
- bfLeftJust = $02;
- bfBroadcast = $04;
-
- type
-
- { TDialog object }
-
- { Palette layout }
- { 1 = Frame passive }
- { 2 = Frame active }
- { 3 = Frame icon }
- { 4 = ScrollBar page area }
- { 5 = ScrollBar controls }
- { 6 = StaticText }
- { 7 = Label normal }
- { 8 = Label selected }
- { 9 = Label shortcut }
- { 10 = Button normal }
- { 11 = Button default }
- { 12 = Button selected }
- { 13 = Button disabled }
- { 14 = Button shortcut }
- { 15 = Button shadow }
- { 16 = Cluster normal }
- { 17 = Cluster selected }
- { 18 = Cluster shortcut }
- { 19 = InputLine normal text }
- { 20 = InputLine selected text }
- { 21 = InputLine arrows }
- { 22 = History arrow }
- { 23 = History sides }
- { 24 = HistoryWindow scrollbar page area }
- { 25 = HistoryWindow scrollbar controls }
- { 26 = ListViewer normal }
- { 27 = ListViewer focused }
- { 28 = ListViewer selected }
- { 29 = ListViewer divider }
- { 30 = InfoPane }
- { 31 = Reserved }
- { 32 = Reserved }
-
- PDialog = ^TDialog;
- TDialog = object(TWindow)
- constructor Init(var Bounds: TRect; ATitle: TTitleStr);
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function Valid(Command: Word): Boolean; virtual;
- end;
-
- { TSItem }
-
- PSItem = ^TSItem;
- TSItem = record
- Value: PString;
- Next: PSItem;
- end;
-
- { TInputLine object }
-
- { Palette layout }
- { 1 = Passive }
- { 2 = Active }
- { 3 = Selected }
- { 4 = Arrows }
-
- PInputLine = ^TInputLine;
- TInputLine = object(TView)
- Data: PString;
- MaxLen: Integer;
- CurPos: Integer;
- FirstPos: Integer;
- SelStart: Integer;
- SelEnd: Integer;
- constructor Init(var Bounds: TRect; AMaxLen: Integer);
- constructor Load(var S: TStream);
- destructor Done; virtual;
- function DataSize: Word; virtual;
- procedure Draw; virtual;
- procedure GetData(var Rec); virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- procedure SelectAll(Enable: Boolean);
- procedure SetData(var Rec); virtual;
- procedure SetState(AState: Word; Enable: Boolean); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TButton object }
-
- { Palette layout }
- { 1 = Normal text }
- { 2 = Default text }
- { 3 = Selected text }
- { 4 = Disabled text }
- { 5 = Normal shortcut }
- { 6 = Default shortcut }
- { 7 = Selected shortcut }
- { 8 = Shadow }
-
- PButton = ^TButton;
- TButton = object(TView)
- Title: PString;
- Command: Word;
- Flags: Byte;
- AmDefault: Boolean;
- constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
- AFlags: Word);
- constructor Load(var S: TStream);
- destructor Done; virtual;
- procedure Draw; virtual;
- procedure DrawState(Down: Boolean);
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- procedure MakeDefault(Enable: Boolean);
- procedure Press; virtual;
- procedure SetState(AState: Word; Enable: Boolean); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TCluster }
-
- { Palette layout }
- { 1 = Normal text }
- { 2 = Selected text }
- { 3 = Normal shortcut }
- { 4 = Selected shortcut }
-
- PCluster = ^TCluster;
- TCluster = object(TView)
- Value: Word;
- Sel: Integer;
- Strings: TStringCollection;
- constructor Init(var Bounds: TRect; AStrings: PSItem);
- constructor Load(var S: TStream);
- destructor Done; virtual;
- function DataSize: Word; virtual;
- procedure DrawBox(Icon: String; Marker: Char);
- procedure GetData(var Rec); virtual;
- function GetHelpCtx: Word; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function Mark(Item: Integer): Boolean; virtual;
- procedure Press(Item: Integer); virtual;
- procedure MovedTo(Item: Integer); virtual;
- procedure SetData(var Rec); virtual;
- procedure SetState(AState: Word; Enable: Boolean); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TRadioButtons }
-
- { Palette layout }
- { 1 = Normal text }
- { 2 = Selected text }
- { 3 = Normal shortcut }
- { 4 = Selected shortcut }
-
- PRadioButtons = ^TRadioButtons;
- TRadioButtons = object(TCluster)
- procedure Draw; virtual;
- function Mark(Item: Integer): Boolean; virtual;
- procedure MovedTo(Item: Integer); virtual;
- procedure Press(Item: Integer); virtual;
- procedure SetData(var Rec); virtual;
- end;
-
- { TCheckBoxes }
-
- { Palette layout }
- { 1 = Normal text }
- { 2 = Selected text }
- { 3 = Normal shortcut }
- { 4 = Selected shortcut }
-
- PCheckBoxes = ^TCheckBoxes;
- TCheckBoxes = object(TCluster)
- procedure Draw; virtual;
- function Mark(Item: Integer): Boolean; virtual;
- procedure Press(Item: Integer); virtual;
- end;
-
- { TListBox }
-
- { Palette layout }
- { 1 = Active }
- { 2 = Inactive }
- { 3 = Focused }
- { 4 = Selected }
- { 5 = Divider }
-
- PListBox = ^TListBox;
- TListBox = object(TListViewer)
- List: PCollection;
- constructor Init(var Bounds: TRect; ANumCols: Word;
- AScrollBar: PScrollBar);
- constructor Load(var S: TStream);
- function DataSize: Word; virtual;
- procedure GetData(var Rec); virtual;
- function GetText(Item: Integer; MaxLen: Integer): String; virtual;
- procedure NewList(AList: PCollection); virtual;
- procedure SetData(var Rec); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TStaticText }
-
- { Palette layout }
- { 1 = Text }
-
- PStaticText = ^TStaticText;
- TStaticText = object(TView)
- Text: PString;
- constructor Init(var Bounds: TRect; AText: String);
- constructor Load(var S: TStream);
- destructor Done; virtual;
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure GetText(var S: String); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TParamText }
-
- { Palette layout }
- { 1 = Text }
-
- PParamText = ^TParamText;
- TParamText = object(TStaticText)
- ParamCount: Integer;
- ParamList: Pointer;
- constructor Init(var Bounds: TRect; AText: String;
- AParamCount: Integer);
- constructor Load(var S: TStream);
- function DataSize: Word; virtual;
- procedure GetText(var S: String); virtual;
- procedure SetData(var Rec); virtual;
- procedure Store(var S: TStream);
- end;
-
- { TLabel }
-
- { Palette layout }
- { 1 = Normal text }
- { 2 = Selected text }
- { 3 = Normal shortcut }
- { 4 = Selected shortcut }
-
- PLabel = ^TLabel;
- TLabel = object(TStaticText)
- Link: PView;
- Light: Boolean;
- constructor Init(var Bounds: TRect; AText: String; ALink: PView);
- constructor Load(var S: TStream);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- procedure Store(var S: TStream);
- end;
-
- { THistoryViewer }
-
- { Palette layout }
- { 1 = Active }
- { 2 = Inactive }
- { 3 = Focused }
- { 4 = Selected }
- { 5 = Divider }
-
- PHistoryViewer = ^THistoryViewer;
- THistoryViewer = object(TListViewer)
- HistoryId: Word;
- constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
- AHistoryId: Word);
- function GetPalette: PPalette; virtual;
- function GetText(Item: Integer; MaxLen: Integer): String; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function HistoryWidth: Integer;
- end;
-
- { THistoryWindow }
-
- { Palette layout }
- { 1 = Frame passive }
- { 2 = Frame active }
- { 3 = Frame icon }
- { 4 = ScrollBar page area }
- { 5 = ScrollBar controls }
- { 6 = HistoryViewer normal text }
- { 7 = HistoryViewer selected text }
-
- PHistoryWindow = ^THistoryWindow;
- THistoryWindow = object(TWindow)
- Viewer: PListViewer;
- constructor Init(var Bounds: TRect; HistoryId: Word);
- function GetPalette: PPalette; virtual;
- function GetSelection: String; virtual;
- procedure InitViewer(HistoryId: Word); virtual;
- end;
-
- { THistory }
-
- { Palette layout }
- { 1 = Arrow }
- { 2 = Sides }
-
- PHistory = ^THistory;
- THistory = object(TView)
- Link: PInputLine;
- HistoryId: Word;
- constructor Init(var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
- constructor Load(var S: TStream);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function InitHistoryWindow(var Bounds: TRect): PHistoryWindow; virtual;
- procedure Store(var S: TStream);
- end;
-
- { SItem routines }
-
- function NewSItem(Str: String; ANext: PSItem): PSItem;
-
- { Dialogs registration procedure }
-
- procedure RegisterDialogs;
-
- { Stream Registration Records }
-
- const
- RDialog: TStreamRec = (
- ObjType: 10;
- VmtLink: Ofs(TypeOf(TDialog)^);
- Load: @TDialog.Load;
- Store: @TDialog.Store
- );
- RInputLine: TStreamRec = (
- ObjType: 11;
- VmtLink: Ofs(TypeOf(TInputLine)^);
- Load: @TInputLine.Load;
- Store: @TInputLine.Store
- );
- RButton: TStreamRec = (
- ObjType: 12;
- VmtLink: Ofs(TypeOf(TButton)^);
- Load: @TButton.Load;
- Store: @TButton.Store
- );
- RCluster: TStreamRec = (
- ObjType: 13;
- VmtLink: Ofs(TypeOf(TCluster)^);
- Load: @TCluster.Load;
- Store: @TCluster.Store
- );
- RRadioButtons: TStreamRec = (
- ObjType: 14;
- VmtLink: Ofs(TypeOf(TRadioButtons)^);
- Load: @TRadioButtons.Load;
- Store: @TRadioButtons.Store
- );
- RCheckBoxes: TStreamRec = (
- ObjType: 15;
- VmtLink: Ofs(TypeOf(TCheckBoxes)^);
- Load: @TCheckBoxes.Load;
- Store: @TCheckBoxes.Store
- );
- RListBox: TStreamRec = (
- ObjType: 16;
- VmtLink: Ofs(TypeOf(TListBox)^);
- Load: @TListBox.Load;
- Store: @TListBox.Store
- );
- RStaticText: TStreamRec = (
- ObjType: 17;
- VmtLink: Ofs(TypeOf(TStaticText)^);
- Load: @TStaticText.Load;
- Store: @TStaticText.Store
- );
- RLabel: TStreamRec = (
- ObjType: 18;
- VmtLink: Ofs(TypeOf(TLabel)^);
- Load: @TLabel.Load;
- Store: @TLabel.Store
- );
- RHistory: TStreamRec = (
- ObjType: 19;
- VmtLink: Ofs(TypeOf(THistory)^);
- Load: @THistory.Load;
- Store: @THistory.Store
- );
- RParamText: TStreamRec = (
- ObjType: 20;
- VmtLink: Ofs(TypeOf(TParamText)^);
- Load: @TParamText.Load;
- Store: @TParamText.Store
- );
-
- const
-
- { Dialog broadcast commands }
-
- cmRecordHistory = 60;
-