home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************}
- { }
- { PC-X User Dialogs for Turbo Vision }
- { Copyright (c) 1997 By PC-X User and Bérczi László }
- { }
- { Portions Copyright (c) 1990 by Borland Int. }
- {*******************************************************}
- {Last Edit: 1997 II 15. 21:00}
- {$X+,V-,F+,O-,S+,Q-}
-
- {Lásd a file végét a szerzô megállapodás véget ! - Licens agreements.}
-
- unit PCX_Dlg;
-
- INTERFACE
- uses Objects, Dialogs, Drivers, Menus, Views, Editors, StdDlg, DOS;
-
-
- const
-
- GFrameCornerLU = #193; {┌} {Corner=Sarok }
- GFrameCornerRU = #194; {┐} {L=Left;R=Right}
- GFrameCornerLD = #195; {└} {U=Up ;D=Down }
- GFrameCornerRD = #197; {┘}
- GFrameSummitU = #198; {─} {Summit=Tetô }
- GFrameSummitD = #199; {─}
- GFrameEdgeL = #200; {│} {Edge=Szél(e) }
- GFrameEdgeR = #201; {│}
-
- CheckBoxCenterN = #203; {' '}
- CheckBoxCenterX = #204; {'X'}
- CheckBoxLeft = #202; {'['}
- CheckBoxRight = #181; {']'}
- RadioButtonCenterN = #207; {' '}
- RadioButtonCenterX = #206; { #7}
- RadioButtonLeft = #205; {'('}
- RadioButtonRight = #182; {')'}
-
- cmMouseChanged = 1003;
- cmCheckBoxChanged = 1004;
- cmRadioButtonChanged = 1005;
- cmViewChanged = 1006;
- cmMove = 1007;
- cmRefresh = 1008;
- cmPCXFrameChanged = 1009;
-
- { Color palettes }
-
- {CPCXDialogs}
- CPCXBlueDialog =
- #64#65#66#67#68#69#70#71#72#73#74#75#76#77#78#79+ { 1- 16}
- #80#81#82#83#84#85#86#87#88#89#90#91#92#92#94#95+ { 17- 32}
- #96#97#98#99#100; { 33- 37}
- {#64-#100}
- CPCXRedDialog =
- #101#102#103#104#105#106#107#108#109#110#111#112#113#114#115#116+{ 1- 16}
- #117#118#119#120#121#122#123#124#125#126#127#128#129#130#131#132+{ 17- 32}
- #133#134#135#136#137; { 33- 37}
- {#101-#137}
- CPCXGrayDialog =
- #138#139#140#141#142#143#144#145#146#147#148#149#150#151#152#153+{ 1- 16}
- #154#155#156#157#158#159#160#161#162#163#164#165#166#167#168#169+{ 17- 32}
- #170#171#172#173#174; { 33- 37}
- {#138-#174}
- CPCXDialog = CGrayDialog+#170#171#172#173#174;
-
- {CPCXWindows}
- CPCXWindow = CPCXDialog;
- CPCXBlueWindow = CPCXBlueDialog;
- CPCXRedWindow = CPCXRedDialog;
- CPCXGrayWindow = CPCXGrayDialog;
-
- CPCXIndicator = #2#37#3#37;
- CPCXFileEditor = #6#4;
-
- CPCXTitleBar = #175;
- CPCXControlBoxApp = #175;
- CPCXControlBoxDlg = #34;
- CPCXControlBoxWin = #34;
-
- CPCXFrame = #1#33#2#34#36#37#35; {CFrame + DragWindow + DragTitle}
- CPCXFrame3D = #15#8; {CFrame3D + CFrame3DTitle}
- CPCXScrollBar = #4#5#4#5; {CSrollBar + CMyScroolBox}
-
- CPCXCheckBoxes = #8#9#9#9;
- CPCXRadioButtons = #8#9#9#9;
-
- {FrameType}
- AllGraphFrame = 1;
- HalfGraphFrame = 2;
- TextFrame = 3;
- {FrameColor}
- FrameBlack = 1;
- FrameWhite = 2;
-
- type
- PString = OBJECTS.PString;
-
- PPCXPoint = ^TPCXPoint;
- TPCXPoint = Object(TPoint)
- procedure Assign(XA, YA: Integer);
- end;
-
- PPCXMenuBox = ^TPCXMenuBox;
- TPCXMenuBox = Object(TMenuBox)
- procedure Draw; virtual;
- end;
-
- PPCXControlBox = ^TPCXControlBox;
- TPCXControlBox = Object(TStaticText)
- constructor Init(P: TPCXPoint);
- procedure HandleEvent(var Event: TEvent); virtual;
- procedure ExecControlMenuBox; virtual;
- private
- ControlMenuBox: PPCXMenuBox;
- end;
-
- PPCXControlBoxApp = ^TPCXControlBoxApp;
- TPCXControlBoxApp = Object(TPCXControlBox)
- function GetPalette: PPalette; virtual;
- procedure ExecControlMenuBox; virtual;
- end;
-
- PPCXControlBoxDlg = ^TPCXControlBoxDlg;
- TPCXControlBoxDlg = Object(TPCXControlBox)
- function GetPalette: PPalette; virtual;
- procedure ExecControlMenuBox; virtual;
- end;
-
- PPCXControlBoxWin = ^TPCXControlBoxWin;
- TPCXControlBoxWin = Object(TPCXControlBox)
- function GetPalette: PPalette; virtual;
- procedure ExecControlMenuBox; virtual;
- end;
-
- PPCXMenuBar = ^TPCXMenuBar;
- TPCXMenuBar = Object(TMenuBar)
- function NewSubView(var Bounds: TRect; AMenu: PMenu;
- AParentMenu: PMenuView): PMenuView; virtual;
- end;
-
- TPCXScrollChars = Array[0..5] of Char;
-
- PPCXScrollBar = ^TPCXScrollBar;
- TPCXScrollBar = Object(TScrollBar)
- constructor Init(var Bounds: TRect);
- procedure Draw; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function GetPalette: PPalette; virtual;
- private
- Chars: TPCXScrollChars;
- TempB: Byte;
- IsHorizontal: Boolean;
- procedure DrawPos(Pos: Integer);
- function GetPos: Integer;
- function GetSize: Integer;
- end;
-
- PPCXFrame = ^TPCXFrame;
- TPCXFrame = Object(TFrame)
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- private
- FrameMode: Word;
- end;
-
- PPCXWindow = ^TPCXWindow;
- TPCXWindow = Object(TWindow)
- constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
- procedure InitFrame; virtual;
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- function StandardScrollBar(AOptions: Word): PPCXScrollBar;
- private
- ControlBoxWin: PPCXControlBoxWin;
- end;
-
- PPCXBlueWindow = ^TPCXBlueWindow;
- TPCXBlueWindow = Object(TPCXWindow)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXRedWindow = ^TPCXRedWindow;
- TPCXRedWindow = Object(TPCXWindow)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXGrayWindow = ^TPCXGrayWindow;
- TPCXGrayWindow = Object(TPCXWindow)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXDialog = ^TPCXDialog;
- TPCXDialog = Object(TDialog)
- constructor Init(var Bounds: TRect; ATitle: TTitleStr);
- procedure InitFrame; virtual;
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- private
- ControlBoxDlg: PPCXControlBoxDlg;
- end;
-
- PPCXBlueDialog = ^TPCXBlueDialog;
- TPCXBlueDialog = Object(TPCXDialog)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXRedDialog = ^TPCXRedDialog;
- TPCXRedDialog = Object(TPCXDialog)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXGrayDialog = ^TPCXGrayDialog;
- TPCXGrayDialog = Object(TPCXDialog)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXIndicator = ^TPCXIndicator;
- TPCXIndicator = Object(TIndicator)
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXFileEditor = ^TPCXFileEditor;
- TPCXFileEditor = Object(TFileEditor)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXEditWindow = ^TPCXEditWindow;
- TPCXEditWindow = Object(TEditWindow)
- constructor Init(var Bounds: TRect; FileName: FNameStr; ANumber: Integer);
- procedure InitFrame; virtual;
- function GetPalette: PPalette; virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- private
- ControlBoxWin: PPCXControlBoxWin;
- end;
-
- PPCXEditBlueWindow = ^TPCXEditBlueWindow;
- TPCXEditBlueWindow = Object(TPCXEditWindow)
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXStaticText = ^TPCXStaticText;
- TPCXStaticText = Object(TStaticText)
- procedure SetText(AText: String); virtual;
- end;
-
- PPCXButton = ^TPCXButton;
- TPCXButton = Object(TButton)
- procedure Draw; virtual;
- procedure DrawView;
- procedure DrawState(Down: Boolean); virtual;
- procedure HandleEvent(var Event: TEvent); virtual;
- private
- procedure DrawCursor;
- procedure ResetCursor; virtual;
- end;
-
- PPCXFrame3D = ^TPCXFrame3D;
- TPCXFrame3D = Object(TView)
- Title : String;
- Frametype,
- Color : Byte;
- constructor Init(var Bounds: TRect; ATitle: String; AFrameType, AColor: Byte);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- end;
-
- PPCXFileDialog = ^TPCXFileDialog;
- TPCXFileDialog = Object(TFileDialog)
- constructor Init(AWildCard: TWildStr; const ATitle,
- InputName: String; AOptions: Word; HistoryId: Byte);
- function GetPalette: PPalette; virtual;
- procedure InitFrame; virtual;
- private
- procedure ReadDirectory;
- end;
-
- PPCXCheckBoxes = ^TPCXCheckBoxes;
- TPCXCheckBoxes = Object(TCheckBoxes)
- constructor Init(var Bounds: TRect; AStrings: PSItem; IsRightOn: Boolean);
- procedure DrawMultiBox(const Icon, Marker: String);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure Press(Item: Integer); virtual;
- private
- IsRight: Boolean;
- function Column(Item: Integer): Integer;
- function FindSel(P: TPoint): Integer;
- function Row(Item: Integer): Integer;
- end;
-
- PPCXRadioButtons = ^TPCXRadioButtons;
- TPCXRadioButtons = Object(TRadioButtons)
- constructor Init(var Bounds: TRect; AStrings: PSItem; IsRightOn: Boolean);
- procedure DrawMultiBox(const Icon, Marker: String);
- procedure Draw; virtual;
- function GetPalette: PPalette; virtual;
- procedure Press(Item: Integer); virtual;
- private
- IsRight: Boolean;
- function Column(Item: Integer): Integer;
- function FindSel(P: TPoint): Integer;
- function Row(Item: Integer): Integer;
- end;
-
-
- function PCXMsgBox(const Msg: String; Params: Pointer; AOptions: Word): Word;
- function PCXMsgBoxRect(var R: TRect; const Msg: String; Params: Pointer; AOptions: Word): Word;
-
- const
- IsMagyarul : Boolean = False;
- IsIntensity: Boolean = False;
- ShowMouseOn: Boolean = True;
- IsHomokOra : Boolean = False;
- On = True;
- Off = False;
- Be = True;
- Ki = False;
-
- {Bit flags to determine how to draw the frame icons}
- fmCloseClicked = $0001;
- fmZoomClicked = $0002;
-
- {PCXScrollBar}
- sbGraphLike = $0004;
- sbTextLike = $0008;
-
- IMPLEMENTATION
- uses App, PCX_Util, MsgBox;
-
- const
- FrameEmpty: String[80] = ' '+
- ' ';
- FrameFull : String[80] = '████████████████████████████████████████'+
- '████████████████████████████████████████';
- GFrameUp : String[80] = '╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞'+
- '╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞╞';
- FrameUp : String[80] = '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀'+
- '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀';
- GFrameDown: String[80] = '╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟'+
- '╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟╟';
- FrameDown : String[80] = '████████████████████████████████████████'+
- '████████████████████████████████████████';
-
- WindowSizer: String[2] = #210#14; {'─┘'}
- ControlBox : String[2] = #209#180;{'[■]'}
- UpWin : String[2] = #214#11;
- RestoreWin : String[2] = #9#10;
- GFrame3DConers: Array[0..1] of Char = #221#222;
- PasswordChar : Byte = 42; {'*' = #42}
-
- {TPCXPoint}
- procedure TPCXPoint.Assign(XA, YA: Integer);
- begin
- X:=XA; Y:=YA;
- end;
-
- {TPCXMenuBox}
- procedure TPCXMenuBox.Draw;
- var
- CNormal, CSelect, CNormDisabled, CSelDisabled, Color: Word;
- Y: Integer;
- P: PMenuItem;
- B: TDrawBuffer;
-
- procedure FrameLine(N: Integer);
- const
- FrameChars: Array[0..19] of Char = ' ┌─┐ └─┘ │ │ ├─┤ ';
- PCXFrameChars: Array[0..19] of Char =
- GFrameCornerLU+GFrameSummitU+GFrameSummitU+GFrameSummitU+GFrameCornerRU+
- GFrameCornerLD+GFrameSummitD+GFrameSummitD+GFrameSummitD+GFrameCornerRD+
- GFrameEdgeL+#32#32#32+GFrameEdgeR+
- GFrameEdgeL+#32#196#32+GFrameEdgeR; {'┴╞╞╞┬├╟╟╟┼╚ ╔╚ ─ ╔'}
- begin
- if IsPCXGraphCharsOn
- then begin
- MoveBuf(B[0], PCXFrameChars[N], Byte(CNormal), 2);
- MoveChar(B[2], PCXFrameChars[N + 2], Byte(Color), Size.X - 4);
- MoveBuf(B[Size.X - 2], PCXFrameChars[N + 3], Byte(CNormal), 2);
- end
- else begin
- MoveBuf(B[0], FrameChars[N], Byte(CNormal), 2);
- MoveChar(B[2], FrameChars[N + 2], Byte(Color), Size.X - 4);
- MoveBuf(B[Size.X - 2], FrameChars[N + 3], Byte(CNormal), 2);
- end;
- end;
-
- procedure DrawLine;
- begin
- WriteBuf(0, Y, Size.X, 1, B);
- Inc(Y);
- end;
-
- begin
- CNormal := GetColor($0301);
- CSelect := GetColor($0604);
- CNormDisabled := GetColor($0202);
- CSelDisabled := GetColor($0505);
- Y := 0;
- Color := CNormal;
- FrameLine(0);
- DrawLine;
- if Menu <> nil then
- begin
- P := Menu^.Items;
- while P <> nil do
- begin
- Color := CNormal;
- if P^.Name = nil then FrameLine(15) else
- begin
- if P^.Disabled then
- if P = Current then
- Color := CSelDisabled else
- Color := CNormDisabled else
- if P = Current then Color := CSelect;
- FrameLine(10);
- MoveCStr(B[3], P^.Name^, Color);
- if P^.Command = 0 then
- MoveChar(B[Size.X - 4], #16, Byte(Color), 1) else
- if P^.Param <> nil then
- MoveStr(B[Size.X - 3 - Length(P^.Param^)],
- P^.Param^, Byte(Color));
- end;
- DrawLine;
- P := P^.Next;
- end;
- end;
- Color := CNormal;
- FrameLine(5);
- DrawLine;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- {TPCXControlBox}
- constructor TPCXControlBox.Init(P: TPCXPoint);
- var
- R : TRect;
- TempS: String;
- begin
- ControlMenuBox:=nil;
- R.A.X:=P.X; R.A.Y:=P.Y;
- R.B.Y:=R.A.Y+1;
- if IsPCXGraphCharsOn
- then begin
- R.B.X:=2;
- TempS:=ControlBox;
- end
- else begin
- R.B.X:=3;
- TempS:='[■]';
- end;
- Inherited Init(R, TempS);
- end;
-
- procedure TPCXControlBox.HandleEvent(var Event: TEvent);
- begin
- ExecControlMenuBox;
- Inherited HandleEvent(Event);
- end;
-
- procedure TPCXControlBox.ExecControlMenuBox;
- begin
- Abstract;
- end;
-
- procedure TPCXControlBoxApp.ExecControlMenuBox;
- var
- R : TRect;
- O : TPCXPoint;
- C : Word;
- Event: TEvent;
- begin
- O.Assign(0,0);
- MakeGlobal(O, O);
- R.Assign(O.X,O.Y+1,O.X+18,O.Y+7);
- if IsMagyarul then
- begin
- Inc(R.A.X, 2);
- Inc(R.B.X, 2);
- end;
- if Not IsMagyarul then
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ove', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~Q~uit', 'Alt- X', kbAltQ, cmQuit, hcNoContext,
- NewLine(
- NewItem('~R~efresh', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil)) else
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ozgat', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~K~ilépés', 'Alt- X', kbAltQ, cmQuit, hcNoContext,
- NewLine(
- NewItem('~F~rissítés', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil));
- C:=Application^.ExecView(ControlMenuBox);
- if C<>cmCancel then
- begin
- case C of cmMove:
- begin
- {Application^.GetEvent(Event);
- Event.What:=evKeyboard;
- Application^.PutEvent(Event);}
- KeyStrokeToKeyboardBuffer(0, $62);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
- cmRefresh: Application^.ReDraw;
- cmQuit: {if AreYouSureToQuit then} Message(Application, evCommand, cmQuit, @Self);
- {javit!}
-
-
- end;
- end;
- end;
-
- function TPCXControlBoxApp.GetPalette: PPalette;
- const P: String[Length(CPCXControlBoxApp)] = CPCXControlBoxApp;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXControlBoxDlg.ExecControlMenuBox;
- var
- R : TRect;
- O : TPCXPoint;
- C : Word;
- Event: TEvent;
- begin
- O.Assign(1,0);
- MakeGlobal(O, O);
- R.Assign(O.X,O.Y+1,O.X+18,O.Y+7);
- if IsMagyarul then
- begin
- Inc(R.A.X);
- Inc(R.B.X);
- end;
- if IsMagyarul then
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ozgat', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~B~ezár', 'Alt-F3', kbAltF3, cmClose, hcNoContext,
- NewLine(
- NewItem('~F~rissít', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil)) else
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ove', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~C~lose', 'Alt-F3', kbAltF3, cmClose, hcNoContext,
- NewLine(
- NewItem('~R~efresh', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil));
- C:=Application^.ExecView(ControlMenuBox);
- Owner^.EnableCommands([cmClose]);
- EnableCommands([cmClose]);
- if C<>cmCancel then
- begin
- case C of cmMove:
- begin
- {Application^.GetEvent(Event);
- Event.What:=evKeyboard;
- Application^.PutEvent(Event);}
- KeyStrokeToKeyboardBuffer(0, $62);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
- cmRefresh: Application^.ReDraw;
- cmClose: begin
- KeyStrokeToKeyboardBuffer(0, $6A);
- Message(Application, evBroadcast, cmClose, @Self);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
- end;
- end;
- end;
-
- function TPCXControlBoxDlg.GetPalette: PPalette;
- const P: String[Length(CPCXControlBoxDlg)] = CPCXControlBoxDlg;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXControlBoxWin.ExecControlMenuBox;
- var
- R : TRect;
- O : TPCXPoint;
- C : Word;
- begin
- O.Assign(1,0);
- MakeGlobal(O, O);
- R.Assign(O.X,O.Y+1,O.X+18,O.Y+7);
- Owner^.EnableCommands([cmClose]);
- EnableCommands([cmClose]);
- if IsMagyarul then
- begin
- Inc(R.A.X);
- Inc(R.B.X);
- end;
- if IsMagyarul then
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ozgat', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~B~ezár', 'Alt-F3', kbAltF3, cmClose, hcNoContext,
- NewLine(
- NewItem('~F~rissít', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil)) else
- New(ControlMenuBox, Init(R, NewMenu(
- NewItem('~M~ove', 'Crt-F5', kbCtrlF5, cmMove, hcNoContext,
- NewItem('~C~lose', 'Alt-F3', kbAltF3, cmClose, hcNoContext,
- NewLine(
- NewItem('~R~efresh', '', kbNoKey, cmRefresh, hcNoContext, nil))))),
- nil));
- C:=Application^.ExecView(ControlMenuBox);
- if C<>cmCancel then
- begin
- case C of cmMove:
- begin
- KeyStrokeToKeyboardBuffer(0, $62);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
- cmRefresh: Application^.ReDraw;
- cmClose:
- begin
- KeyStrokeToKeyboardBuffer(0, $6A);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- end;
- end;
- end;
-
- function TPCXControlBoxWin.GetPalette: PPalette;
- const P: String[Length(CPCXControlBoxWin)] = CPCXControlBoxWin;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXMenuBar}
- function TPCXMenuBar.NewSubView(var Bounds: TRect; AMenu: PMenu;
- AParentMenu: PMenuView): PMenuView;
- begin
- NewSubView := New(PPCXMenuBox, Init(Bounds, AMenu, AParentMenu));
- end;
-
- {TPCXScrollBar}
- constructor TPCXScrollBar.Init(var Bounds: TRect);
- const
- { felb felj leb lej }
- GVChars: TPCXScrollChars = (#212, #183, #213, #184, GFrameEdgeL, GFrameEdgeR);
- {╘ ╖ ╒ ╕}
- GHChars: TPCXScrollChars = (#217, #21, #218, #185, #215, #215);
- {┘ ┌ ╣ ╫ ╫}
- VChars : TPCXScrollChars = (#30, #31, #177, #254, #178, #32); {Text, it's }
- HChars : TPCXScrollChars = (#17, #16, #177, #254, #178, #32); {the original}
- begin
- TView.Init(Bounds);
- if IsPCXGraphCharsOn then TempB:=2
- else TempB:=1;
- Value := 0;
- Min := 0;
- Max := 0;
- PgStep := 1;
- ArStep := 1;
- if Size.X = TempB then
- begin
- GrowMode := gfGrowLoX + gfGrowHiX + gfGrowHiY;
- if IsPCXGraphCharsOn then Chars := GVChars
- else Chars := VChars;
- IsHorizontal:=False;
- end else
- begin
- GrowMode := gfGrowLoY+ gfGrowHiX + gfGrowHiY;
- if IsPCXGraphCharsOn then Chars := GHChars
- else Chars := HChars;
- IsHorizontal:=True;
- end;
- end;
-
- procedure TPCXScrollBar.Draw;
- begin
- DrawPos(GetPos);
- Message(Application, evCommand, cmMouseChanged, @Self);
-
- { Include it to evIdle in HandleEvent for make realtime show|hide scrollbars
- if HScrollBar <> nil then
- if HScrollBar^.Min = HScrollBar^.Max
- then HScrollBar^.Hide
- else HScrollBar^.Show;
- }
- end;
-
- procedure TPCXScrollBar.DrawPos(Pos: Integer);
- var
- S: Integer;
- B: TDrawBuffer;
- i: Word;
- begin
- if IsPCXGraphCharsOn then
- begin
- if Not IsHorizontal then
- begin
- S := GetSize - 1;
- MoveCStr(B[0], Chars[0], GetColor(2));
- MoveCStr(B[1], Chars[1], SwapHighAndLowAreaOfByte(GetColor(2)));
- if Max = Min then
- begin
- i:=0;
- while i<(S*2)-1 do
- begin
- Inc(I,2);
- MoveCStr(B[i], ''+Chars[4]+Chars[5]+'', GetColor(1));
- end;
- end
- else
- begin
- i:=0;
- while i<(S*2)-1 do
- begin
- Inc(i,2);
- MoveCStr(B[i], ''+Chars[4]+Chars[5]+'', GetColor(3));
- MoveCStr(B[Pos*2], ''+Chars[4]+Chars[5]+'', GetColor(4));
- end;
- end;
- MoveCStr(B[S*2], Chars[2], GetColor(2));
- MoveCStr(B[(S*2)+1], Chars[3], SwapHighAndLowAreaOfByte(GetColor(2)));
- WriteBuf(0, 0, Size.X, Size.Y, B);
- end
- else
- begin
- S := GetSize - 1;
- if Pos=1 then Inc(Pos);
- if Pos+1=S then Pos:=S-3;
- MoveCStr(B[0], Chars[0], GetColor(2));
- MoveCStr(B[1], Chars[1], SwapHighAndLowAreaOfByte(GetColor(2)));
- if Max = Min then
- MoveChar(B[2], Chars[4], GetColor(1), S - 2)
- else
- begin
- MoveChar(B[2], Chars[4], GetColor(3), S - 2);
- MoveCStr(B[Pos], Chars[5]+Chars[5], GetColor(4));
- end;
- MoveCStr(B[S-1], Chars[2], GetColor(2));
- MoveCStr(B[S], Chars[3], SwapHighAndLowAreaOfByte(GetColor(2)));
- WriteBuf(0, 0, Size.X, Size.Y, B);
- end;
- end
- else
- begin
- S := GetSize - 1;
- MoveChar(B[0], Chars[0], GetColor(2), 1);
- if Max = Min then
- MoveChar(B[1], Chars[4], GetColor(1), S - 1)
- else
- begin
- MoveChar(B[1], Chars[2], GetColor(1), S - 1);
- MoveChar(B[Pos], Chars[3], GetColor(3), 1);
- end;
- MoveChar(B[S], Chars[1], GetColor(2), 1);
- WriteBuf(0, 0, Size.X, Size.Y, B);
- end;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- procedure TPCXScrollBar.HandleEvent(var Event: TEvent);
- var
- Tracking : Boolean;
- I, P,
- S,
- ClickPart: Integer;
- Mouse : TPoint;
- Extent : TRect;
- function GetPartCode: Integer;
- var
- Mark, Part: Integer;
- begin
- Part := -1;
- if Extent.Contains(Mouse) then
- begin
- if Size.X = TempB then Mark := Mouse.Y else Mark := Mouse.X;
- if Mark = P then Part := sbIndicator else
- begin
- if Mark < TempB then Part := sbLeftArrow else
- if Mark < P then Part := sbPageLeft else
- if Mark < S then Part := sbPageRight else
- Part := sbRightArrow;
- if Size.X = TempB then Inc(Part, 4);
- end;
- end;
- GetPartCode := Part;
- end;
-
- procedure Clicked;
- begin
- Message(Owner, evCommand, cmViewChanged, @Self);
- end;
-
- begin
- TView.HandleEvent(Event);
- case Event.What of
- evMouseDown:
- begin
- Clicked;
- MakeLocal(Event.Where, Mouse);
- GetExtent(Extent);
- Extent.Grow(1, 1);
- P := GetPos;
- S := GetSize - 1;
- ClickPart := GetPartCode;
- if ClickPart <> sbIndicator then
- begin
- repeat
- MakeLocal(Event.Where, Mouse);
- if GetPartCode = ClickPart then
- SetValue(Value + ScrollStep(ClickPart));
- until not MouseEvent(Event, evMouseAuto);
- end else
- begin
- repeat
- MakeLocal(Event.Where, Mouse);
- Tracking := Extent.Contains(Mouse);
- if Tracking then
- begin
- if Size.X = TempB then I := Mouse.Y else I := Mouse.X;
- if I <= 0 then I := 1;
- if I >= S then I := S - 1;
- end else I := GetPos;
- if I <> P then
- begin
- DrawPos(I);
- P := I;
- end;
- until not MouseEvent(Event, evMouseMove);
- if Tracking and (S > 2) then
- begin
- Dec(S, 2);
- SetValue(LongDiv(LongMul(P - 1, Max - Min) + S shr 1, S) + Min);
- end;
- end;
- ClearEvent(Event);
- end;
- evKeyDown:
- if State and sfVisible <> 0 then
- begin
- ClickPart := sbIndicator;
- if Size.Y = 1 then
- case CtrlToArrow(Event.KeyCode) of
- kbLeft: ClickPart := sbLeftArrow;
- kbRight: ClickPart := sbRightArrow;
- kbCtrlLeft: ClickPart := sbPageLeft;
- kbCtrlRight: ClickPart := sbPageRight;
- kbHome: I := Min;
- kbEnd: I := Max;
- else
- Exit;
- end
- else
- case CtrlToArrow(Event.KeyCode) of
- kbUp: ClickPart := sbUpArrow;
- kbDown: ClickPart := sbDownArrow;
- kbPgUp: ClickPart := sbPageUp;
- kbPgDn: ClickPart := sbPageDown;
- kbCtrlPgUp: I := Min;
- kbCtrlPgDn: I := Max;
- else
- Exit;
- end;
- Clicked;
- if ClickPart <> sbIndicator then I := Value + ScrollStep(ClickPart);
- SetValue(I);
- ClearEvent(Event);
- end;
- end;
- end;
-
- function TPCXScrollBar.GetPalette: PPalette;
- const P: String[Length(CPCXScrollBar)] = CPCXScrollBar;
- begin
- GetPalette:=@P;
- end;
-
- function TPCXScrollBar.GetPos: Integer;
- var
- R: Integer;
- begin
- R := Max - Min;
- if R = 0 then
- GetPos := 1 else
- GetPos := LongDiv(LongMul(Value - Min, GetSize - 3) + R shr 1, R) + 1;
- end;
-
- function TPCXScrollBar.GetSize: Integer;
- var
- S: Integer;
- begin
- if Size.X = TempB then S := Size.Y else S := Size.X;
- if S < 2+TempB then GetSize := 2+TempB else GetSize := S;
- end;
-
- {TPCXFrame}
- procedure TPCXFrame.Draw;
- var
- CFrame, CTitle: Word;
- F, I, L, Width: Integer;
- B: TDrawBuffer;
- Title: TTitleStr;
- Min, Max: TPoint;
- begin
- if State and sfDragging <> 0 then
- begin
- CFrame := $0706;
- CTitle := $0007;
- F := 0;
- end else if State and sfActive = 0 then
- begin
- CFrame := $0101;
- CTitle := $0002;
- F := 0;
- end else
- begin
- CFrame := $0503;
- CTitle := $0004;
- F := 9;
- end;
- CFrame := GetColor(CFrame);
- CTitle := GetColor(CTitle);
- Width := Size.X;
- L := Width - 10;
- if PWindow(Owner)^.Flags and (wfClose+wfZoom) <> 0 then Dec(L,6);
- if IsPCXGraphCharsOn then MoveCStr(B, Copy(FrameEmpty, 1, Size.X), CTitle)
- else MoveCStr(B, Copy(FrameEmpty, 1, Size.X), CTitle);
- if (PWindow(Owner)^.Number <> wnNoNumber) and
- (PWindow(Owner)^.Number < 10) then
- begin
- Dec(L,4);
- if PWindow(Owner)^.Flags and wfZoom <> 0 then I := 7
- else I := 3;
- WordRec(B[Width - I]).Lo := PWindow(Owner)^.Number + $30;
- end;
- if Owner <> nil then Title := PWindow(Owner)^.GetTitle(L)
- else Title := '';
- if Title <> '' then
- begin
- L := Length(Title);
- if L > Width - 10 then L := Width - 10;
- if L < 0 then L := 0;
- I := (Width - L) shr 1;
- MoveChar(B[I - 1], ' ', CTitle, 1);
- MoveBuf(B[I], Title[1], CTitle, L);
- MoveChar(B[I + L], ' ', CTitle, 1);
- end;
- if State and sfActive <> 0 then
- begin
- if PWindow(Owner)^.Flags and wfClose <> 0 then
- if FrameMode and fmCloseClicked = 0 then
- if IsPCXGraphCharsOn then MoveCStr(B[0], '~'+ControlBox+'~', CFrame) {#209#180}
- else MoveCStr(B[1], '', CFrame) {~[■]~}
- else MoveCStr(B[2], '[~'#15'~]', CFrame);
- if PWindow(Owner)^.Flags and wfZoom <> 0 then
- begin
- if IsPCXGraphCharsOn then MoveCStr(B[Width - 4], '~'+UpWin+'~', CFrame)
- else MoveCStr(B[Width - 4], '~['#24']~', CFrame);
- Owner^.SizeLimits(Min, Max);
- if FrameMode and fmZoomClicked <> 0 then
- WordRec(B[Width - 4]).Lo := 15
- else if Longint(Owner^.Size) = Longint(Max) then
- begin
- if IsPCXGraphCharsOn then MoveCStr(B[Width - 4], '~'+RestoreWin+'~', CFrame)
- else MoveCStr(B[Width - 4], '~['#18']~', CFrame);
- end;
- end;
- end;
- WriteLine(0, 0, Size.X, 1, B);
- for I := 1 to Size.Y - 2 do
- begin
- if IsPCXGraphCharsOn then MoveCStr(B, GFrameEdgeL+Copy(FrameEmpty, 1, Size.X-2)+GFrameEdgeR, CFrame)
- else MoveCStr(B, #221+Copy(FrameEmpty, 1, Size.X-2)+#222, CFrame);
- WriteLine(0, I, Size.X, 1, B);
- end;
- if IsPCXGraphCharsOn then MoveCStr(B, GFrameCornerLD+Copy(GFrameDown, 1, Size.X-2)+GFrameCornerRD, CFrame)
- else MoveCStr(B, {#221+} Copy(FrameDown{FrameFull}, 1, Size.X) {+#222}, CFrame);
- if State and sfActive <> 0 then
- if PWindow(Owner)^.Flags and wfGrow <> 0 then
- if IsPCXGraphCharsOn then MoveCStr(B[Width - 2], WindowSizer, CFrame) {#210#211}
- else MoveCStr(B[Width - 2], '~─┘~', CFrame);
- WriteLine(0, Size.Y - 1, Size.X, 1, B);
- Message(Application, evCommand, cmMouseChanged, @Self);
- Message(Application, evCommand, cmPCXFrameChanged, @Self);
- Message(Application, evBroadcast, cmPCXFrameChanged, @Self);
- end;
-
- function TPCXFrame.GetPalette: PPalette;
- const P: String[Length(CPCXFrame)] = CPCXFrame;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXWindow}
- constructor TPCXWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
- var P: TPCXPoint;
- begin
- Inherited Init(Bounds, ATitle, ANumber);
- P.Assign(0, 0);
- New(ControlBoxWin, Init(P));
- Insert(ControlBoxWin);
- end;
-
- procedure TPCXWindow.InitFrame;
- var R: TRect;
- begin
- GetExtent(R);
- Frame := New(PPCXFrame, Init(R));
- end;
-
- procedure TPCXWindow.Draw;
- begin
- Inherited Draw;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXWindow.GetPalette: PPalette;
- const P: String[Length(CPCXWindow)] = CPCXWindow;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXWindow.HandleEvent(var Event: TEvent);
- begin
- if Event.KeyCode=kbAltSpace then
- begin
- ControlBoxWin^.ExecControlMenuBox;
- Event.KeyCode:=Event.KeyCode and Not kbAltSpace;
- end;
- Inherited HandleEvent(Event);
- end;
-
- function TPCXWindow.StandardScrollBar(AOptions: Word): PPCXScrollBar;
- var
- R: TRect;
- S: PPCXScrollBar;
- begin
- GetExtent(R);
- if AOptions and sbGraphLike = 0
- then if AOptions and sbVertical = 0
- then R.Assign(R.A.X + 2, R.B.Y-1, R.B.X-2, R.B.Y)
- else R.Assign(R.B.X-1,R.A.Y+1,R.B.X,R.B.Y-1)
- else if AOptions and sbVertical = 0
- then R.Assign(R.A.X + 2, R.B.Y-1, R.B.X-2, R.B.Y)
- else R.Assign(R.B.X-2,R.A.Y+1,R.B.X,R.B.Y-1);
- S := New(PPCXScrollBar, Init(R));
- Insert(S);
- if AOptions and sbHandleKeyboard <> 0
- then S^.Options := S^.Options or ofPostProcess;
- StandardScrollBar := S;
- end;
-
- {TPCXXXXXWindows}
- function TPCXBlueWindow.GetPalette: PPalette;
- const P: String[Length(CPCXBlueWindow)] = CPCXBlueWindow;
- begin
- GetPalette:=@P;
- end;
-
- function TPCXRedWindow.GetPalette: PPalette;
- const P: String[Length(CPCXRedWindow)] = CPCXRedWindow;
- begin
- GetPalette:=@P;
- end;
-
- function TPCXGrayWindow.GetPalette: PPalette;
- const P: String[Length(CPCXGrayWindow)] = CPCXGrayWindow;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXDialog}
- constructor TPCXDialog.Init(var Bounds: TRect; ATitle: TTitleStr);
- var P: TPCXPoint;
- begin
- Inherited Init(Bounds, ATitle);
- P.Assign(0,0);
- New(ControlBoxDlg, Init(P));
- Insert(ControlBoxDlg);
- end;
-
- procedure TPCXDialog.InitFrame;
- var
- R: TRect;
- begin
- GetExtent(R);
- Frame := New(PPCXFrame, Init(R));
- end;
-
- procedure TPCXDialog.Draw;
- begin
- Inherited Draw;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXDialog.GetPalette: PPalette;
- const P: String[Length(CPCXDialog)] = CPCXDialog;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXDialog.HandleEvent(var Event: TEvent);
- begin
- if Event.KeyCode=kbAltSpace then
- begin
- ControlBoxDlg^.ExecControlMenuBox;
- Event.KeyCode:=Event.KeyCode and Not kbAltSpace;
- end;
- Inherited HandleEvent(Event);
- end;
-
- function TPCXBlueDialog.GetPalette: PPalette;
- const P: String[Length(CPCXBlueDialog)] = CPCXBlueDialog;
- begin
- GetPalette:=@P;
- end;
-
- function TPCXRedDialog.GetPalette: PPalette;
- const P: String[Length(CPCXRedDialog)] = CPCXRedDialog;
- begin
- GetPalette:=@P;
- end;
-
- function TPCXGrayDialog.GetPalette: PPalette;
- const P: String[Length(CPCXGrayDialog)] = CPCXGrayDialog;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXIndicator}
- procedure TPCXIndicator.Draw;
- var
- Color, Color2: Byte;
- Frame: Char;
- L: Array[0..1] of Longint;
- S: String[15];
- B: TDrawBuffer;
- begin
- if State and sfDragging = 0 then
- begin
- Color := GetColor(1);
- Color2:= GetColor(3);
- if IsPCXGraphCharsOn
- then Frame := GFrameSummitD
- else Frame := #219;
- end else
- begin
- Color := GetColor(2);
- Color2:= SwapHighAndLowAreaOfByte(GetColor(4));
- if IsPCXGraphCharsOn
- then Frame := GFrameSummitD
- else Frame := #219;
- end;
- MoveChar(B, Frame, Color, Size.X);
- if Modified
- then if IsPCXGraphCharsOn
- then WordRec(B[0]).Lo := 210
- else WordRec(B[0]).Lo := 220;
- L[0] := Location.Y + 1;
- L[1] := Location.X + 1;
- FormatStr(S, ' %d:%d ', L);
- MoveStr(B[8 - Pos(':', S)], S, Color2);
- WriteBuf(0, 0, Size.X, 1, B);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXIndicator.GetPalette: PPalette;
- const P: String[Length(CPCXIndicator)] = CPCXIndicator;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXFileEditor}
- function TPCXFileEditor.GetPalette: PPalette;
- const P: String[Length(CPCXFileEditor)] = CPCXFileEditor;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXEditWindow}
- constructor TPCXEditWindow.Init(var Bounds: TRect; FileName: FNameStr; ANumber: Integer);
- var
- P: TPCXPoint;
- HScrollBar, VScrollBar: PPCXScrollBar;
- Indicator: PPCXIndicator;
- R: TRect;
- begin
- Inherited Init(Bounds, '', ANumber);
- Options := Options or ofTileable;
- R.Assign(18, Size.Y - 1, Size.X - 2, Size.Y);
- HScrollBar := New(PPCXScrollBar, Init(R));
- HScrollBar^.Hide;
- Insert(HScrollBar);
- if IsPCXGraphCharsOn
- then R.Assign(Size.X - 2, 1, Size.X, Size.Y - 1)
- else R.Assign(Size.X - 1, 1, Size.X, Size.Y - 1);
- VScrollBar := New(PPCXScrollBar, Init(R));
- VScrollBar^.Hide;
- Insert(VScrollBar);
- R.Assign(2, Size.Y - 1, 16, Size.Y);
- Indicator := New(PPCXIndicator, Init(R));
- Indicator^.Hide;
- Insert(Indicator);
- GetExtent(R);
- R.Grow(-2, -1);
- Editor := New(PPCXFileEditor, Init(R, HScrollBar, VScrollBar, Indicator, FileName));
- Insert(Editor);
-
- P.Assign(0,0);
- New(ControlBoxWin, Init(P));
- Insert(ControlBoxWin);
- end;
-
- procedure TPCXEditWindow.InitFrame;
- var
- R: TRect;
- begin
- GetExtent(R);
- Frame := New(PPCXFrame, Init(R));
- end;
-
- function TPCXEditWindow.GetPalette: PPalette;
- const P: String[Length(CPCXWindow)] = CPCXWindow;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXEditWindow.HandleEvent(var Event: TEvent);
- begin
- if Event.KeyCode=kbAltSpace then ControlBoxWin^.ExecControlMenuBox;
- Inherited HandleEvent(Event);
- if Event.Command = cmNewLine then
- begin
- Event.KeyCode:=Event.KeyCode and (Not kbAltSpace);
- Event.Command:= Event.Command and (Not cmNewLine);
- end;
- end;
-
- function TPCXEditBlueWindow.GetPalette: PPalette;
- const P: String[Length(CPCXBlueWindow)] = CPCXBlueWindow;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXStaticText}
- procedure TPCXStaticText.SetText(AText: String);
- begin
- if Text<>nil then DisposeStr(Text); {Idea: By Bérczi Gábor, Power INC.}
- if AText<>'' then Text:=NewStr(AText) { TOO . . . }
- else Text:=Nil; { TOO . . . }
- Draw;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- {TPCXButton}
- procedure TPCXButton.Draw;
- begin
- DrawState(False);
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- procedure TPCXButton.DrawState(Down: Boolean);
- var
- CButton, CShadow: Word;
- Ch: Char;
- I, S, Y, T: Integer;
- B: TDrawBuffer;
-
- procedure DrawTitle;
- var
- L, SCOff: Integer;
- begin
- if Flags and bfLeftJust <> 0 then L := 1 else
- begin
- L := (S - CStrLen(Title^) - 1) div 2;
- if L < 1 then L := 1;
- end;
- MoveCStr(B[I + L], Title^, CButton);
- if ShowMarkers and not Down then
- begin
- if State and sfSelected <> 0 then SCOff := 0 else
- if AmDefault then SCOff := 2 else SCOff := 4;
- WordRec(B[0]).Lo := Byte(SpecialChars[SCOff]);
- WordRec(B[S]).Lo := Byte(SpecialChars[SCOff + 1]);
- end;
- end;
-
- begin
- if State and sfDisabled <> 0 then CButton := GetColor($0404) else
- begin
- CButton := GetColor($0501);
- if State and sfActive <> 0 then
- if State and sfSelected <> 0 then CButton := GetColor($0703) else
- if AmDefault then CButton := GetColor($0602);
- end;
- CShadow := GetColor(8);
- S := Size.X - 1;
- T := Size.Y div 2 - 1;
- for Y := 0 to Size.Y - 2 do
- begin
- MoveChar(B, ' ', Byte(CButton), Size.X);
- WordRec(B[0]).Hi := CShadow;
- if Down then
- begin
- WordRec(B[1]).Hi := CShadow;
- Ch := ' ';
- I := 2;
- end else
- begin
- if ShowMarkers then WordRec(B[S]).Hi := Byte(CShadow)
- else WordRec(B[S]).Hi := SwapHighAndLowAreaOfByte(Byte(CShadow)); {from PCX_Util}
- if ShowMarkers then Ch := ' ' else
- begin
- if Y = 0 then
- WordRec(B[S]).Lo := Byte('▀') else {#223 invert = #220}
- WordRec(B[S]).Lo := Byte('█');
- Ch := '▀';
- end;
- I := 1;
- end;
- if (Y = T) and (Title <> nil) then DrawTitle;
- if ShowMarkers and not Down then
- begin
- WordRec(B[1]).Lo := Byte('[');
- WordRec(B[S - 1]).Lo := Byte(']');
- end;
- WriteLine(0, Y, Size.X, 1, B);
- end;
- MoveChar(B[0], ' ', Byte(CShadow), 2);
- MoveChar(B[2], Ch, Byte(CShadow), S - 1);
- WriteLine(0, Size.Y - 1, Size.X, 1, B);
- end;
-
- function HotKey(const S: String): Char;
- var
- P: Word;
- begin
- P := Pos('~',S);
- if P <> 0 then HotKey := UpCase(S[P+1])
- else HotKey := #0;
- end;
-
- const
-
- { TButton messages }
-
- cmGrabDefault = 61;
- cmReleaseDefault = 62;
-
- procedure TPCXButton.HandleEvent(var Event: TEvent);
- var
- Down: Boolean;
- C: Char;
- Mouse: TPoint;
- ClickRect: TRect;
- begin
- GetExtent(ClickRect);
- Inc(ClickRect.A.X);
- Dec(ClickRect.B.X);
- Dec(ClickRect.B.Y);
- if Event.What = evMouseDown then
- begin
- MakeLocal(Event.Where, Mouse);
- if not ClickRect.Contains(Mouse) then ClearEvent(Event);
- end;
- if Flags and bfGrabFocus <> 0 then
- TView.HandleEvent(Event);
- case Event.What of
- evMouseDown:
- begin
- if State and sfDisabled = 0 then
- begin
- Inc(ClickRect.B.X);
- Down := False;
- repeat
- MakeLocal(Event.Where, Mouse);
- if Down <> ClickRect.Contains(Mouse) then
- begin
- Down := not Down;
- DrawState(Down);
- end;
- until not MouseEvent(Event, evMouseMove);
- if Down then
- begin
- Press;
- DrawState(False);
- end;
- end;
- ClearEvent(Event);
- end;
- evKeyDown:
- begin
- C := HotKey(Title^);
- if (Event.KeyCode = GetAltCode(C)) or
- (Owner^.Phase = phPostProcess) and (C <> #0) and
- (Upcase(Event.CharCode) = C) or
- (State and sfFocused <> 0) and (Event.CharCode = ' ') then
- begin
- Press;
- ClearEvent(Event);
- end;
- end;
- evBroadcast:
- case Event.Command of
- cmDefault:
- if AmDefault then
- begin
- Press;
- ClearEvent(Event);
- end;
- cmGrabDefault, cmReleaseDefault:
- if Flags and bfDefault <> 0 then
- begin
- AmDefault := Event.Command = cmReleaseDefault;
- DrawView;
- end;
- cmCommandSetChanged:
- begin
- SetState(sfDisabled, not CommandEnabled(Command));
- DrawView;
- end;
- end;
- end;
- end;
-
- procedure TPCXButton.ResetCursor; assembler;
- asm
- LES DI,Self
- MOV AX,ES:[DI].TPCXButton.State
- NOT AX
- TEST AX,sfVisible+sfCursorVis+sfFocused
- JNE @@4
- MOV AX,ES:[DI].TView.Cursor.Y
- MOV DX,ES:[DI].TView.Cursor.X
- @@1: OR AX,AX
- JL @@4
- CMP AX,ES:[DI].TPCXButton.Size.Y
- JGE @@4
- OR DX,DX
- JL @@4
- CMP DX,ES:[DI].TPCXButton.Size.X
- JGE @@4
- ADD AX,ES:[DI].TPCXButton.Origin.Y
- ADD DX,ES:[DI].TPCXButton.Origin.X
- MOV CX,DI
- MOV BX,ES
- LES DI,ES:[DI].TPCXButton.Owner
- MOV SI,ES
- OR SI,DI
- JE @@5
- TEST ES:[DI].TPCXButton.State,sfVisible
- JE @@4
- LES DI,ES:[DI].TGroup.Last
- @@2: LES DI,ES:[DI].TPCXButton.Next
- CMP CX,DI
- JNE @@3
- MOV SI,ES
- CMP BX,SI
- JNE @@3
- LES DI,ES:[DI].TPCXButton.Owner
- JMP @@1
- @@3: TEST ES:[DI].TPCXButton.State,sfVisible
- JE @@2
- MOV SI,ES:[DI].TPCXButton.Origin.Y
- CMP AX,SI
- JL @@2
- ADD SI,ES:[DI].TPCXButton.Size.Y
- CMP AX,SI
- JGE @@2
- MOV SI,ES:[DI].TPCXButton.Origin.X
- CMP DX,SI
- JL @@2
- ADD SI,ES:[DI].TPCXButton.Size.X
- CMP DX,SI
- JGE @@2
- @@4: MOV CX,2000H
- JMP @@6
- @@5: MOV DH,AL
- XOR BH,BH
- MOV AH,2
- INT 10H
- MOV CX,CursorLines
- LES DI,Self
- TEST ES:[DI].TPCXButton.State,sfCursorIns
- JE @@6
- MOV CH,0
- OR CL,CL
- JNE @@6
- MOV CL,7
- @@6: MOV AH,1
- INT 10H
- end;
-
- procedure TPCXButton.DrawCursor;
- begin
- if State and sfFocused <> 0 then ResetCursor;
- end;
-
-
- procedure TPCXButton.DrawView;
- begin
- if Exposed then
- begin
- Draw;
- DrawCursor;
- end;
- end;
-
- {TPCXFrame3D}
- constructor TPCXFrame3D.Init(var Bounds: TRect; ATitle: String; AFrametype, AColor: Byte);
- begin
- Inherited Init(Bounds);
- Title:=ATitle;
- Frametype:=AFrametype;
- Color:=AColor;
- end;
-
- procedure TPCXFrame3D.Draw;
- var
- B: TDrawBuffer;
- i: Word;
- S: String;
- C: Word;
- begin
- if Color = FrameWhite then C:=GetColor(2)
- else C:=GetColor(1);
- case Frametype of
- 2:
- begin
-
- end;
- end;
- if IsPCXGraphCharsOn then
- begin
- FillChar(S, Size.X-1, #196);
- S[0]:=Chr(Size.X-2);
- if Title<>'' then MoveCStr(B, GFrame3DConers[0]+S+GFrame3DConers[1], C)
- else MoveChar(B, GFrameSummitD, C, Size.X);
- WriteLine(0,0,Size.X,Size.Y, B);
- {for i:=1 to Size.Y-2 do
- begin}
- MoveCStr(B, GFrameEdgeL+Copy(FrameEmpty, 1, Size.X-2)+GFrameEdgeR, C);
- WriteLine(0,1,Size.X,Size.Y, B);
- {end;}
- MoveChar(B, GFrameSummitU, C, Size.X);
- WriteLine(0,Size.Y-1,Size.X,Size.Y, B);
- end
- else
- begin
- FillChar(S, Size.X-1, #196);
- S[0]:=Chr(Size.X-2);
- MoveCStr(B, #218+S+#191, C);
- WriteLine(0,0,Size.X,Size.Y, B);
- {for i:=1 to Size.Y-2 do
- begin}
- MoveCStr(B, #179+Copy(FrameEmpty, 1, Size.X-2)+#179, C);
- WriteLine(0,1,Size.X,Size.Y, B);
- {end;}
- FillChar(S, Size.X-1, #196);
- S[0]:=Chr(Size.X-2);
- MoveCStr(B, #192+S+#217, C);
- WriteLine(0,Size.Y-1,Size.X,Size.Y, B);
- end;
- {end;}
- if Title<>'' then
- begin
- if Title[1]<>#3
- then begin
- MoveCStr(B, #32+Title+#32, GetColor(2));
- WriteLine(1, 0, Length(Title)+2, 1, B);
- end
- else begin
- Delete(Title, 1, 1);
- MoveCStr(B, #32+Title+#32, GetColor(2));
- WriteLine(1+((Size.X-Length(Title)-2) div 2), 0, Length(Title)+2, 1, B);
- end;
- end;
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXFrame3D.GetPalette: PPalette;
- const P: String[Length(CPCXFrame3D)] = CPCXFrame3D;
- begin
- GetPalette:=@P;
- end;
-
- {TPCXFileDialog}
- constructor TPCXFileDialog.Init(AWildCard: TWildStr; const ATitle,
- InputName: String; AOptions: Word; HistoryId: Byte);
- var
- Control: PView;
- R: TRect;
- Opt: Word;
- begin
- R.Assign(15,1,64,20);
- TDialog.Init(R, ATitle);
- Options := Options or ofCentered;
- WildCard := AWildCard;
-
- R.Assign(3,3,34,4);
- FileName := New(PFileInputLine, Init(R, 79));
- FileName^.Data^ := WildCard;
- Insert(FileName);
- R.Assign(2,2,3+CStrLen(InputName),3);
- Control := New(PLabel, Init(R, InputName, FileName));
- Insert(Control);
- (* R.Assign(31,3,34,4);
- Control := New(PHistory, Init(R, FileName, HistoryId));
- Insert(Control);*)
-
- R.Assign(2,5,35,16);
- Insert(New(PPCXFrame3D, Init(R, ' ', AllGraphFrame, FrameBlack)));
- R.Assign(2,14,35,15);
- Control := New(PPCXScrollBar, Init(R));
- Insert(Control);
- R.Assign(3,6,34,14);
- FileList := New(PFileList, Init(R, PPCXScrollBar(Control)));
- Insert(FileList);
- R.Assign(3,5,10,6);
- Control := New(PLabel, Init(R, '~F~iles ', FileList));
- Insert(Control);
-
- R.Assign(35,3,46,5);
- Opt := bfDefault;
- if AOptions and fdOpenButton <> 0 then
- begin
- Insert(New(PPCXButton, Init(R, '~O~pen', cmFileOpen, Opt)));
- Opt := bfNormal;
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- end;
- if AOptions and fdOkButton <> 0 then
- begin
- Insert(New(PPCXButton, Init(R, 'O~K~', cmFileOpen, Opt)));
- Opt := bfNormal;
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- end;
- if AOptions and fdReplaceButton <> 0 then
- begin
- Insert(New(PPCXButton, Init(R, '~R~eplace',cmFileReplace, Opt)));
- Opt := bfNormal;
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- end;
- if AOptions and fdClearButton <> 0 then
- begin
- Insert(New(PPCXButton, Init(R, '~C~lear',cmFileClear, Opt)));
- Opt := bfNormal;
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- end;
- Insert(New(PPCXButton, Init(R, 'Cancel', cmCancel, bfNormal)));
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- if AOptions and fdHelpButton <> 0 then
- begin
- Insert(New(PPCXButton, Init(R, 'Help',cmHelp, bfNormal)));
- Inc(R.A.Y,3); Inc(R.B.Y,3);
- end;
-
- R.Assign(1,16,48,18);
- Control := New(PFileInfoPane, Init(R));
- Insert(Control);
-
- SelectNext(False);
-
- if AOptions and fdNoLoadDir = 0 then ReadDirectory;
- end;
-
- function TPCXFileDialog.GetPalette: PPalette;
- const P: String[Length(CPCXBlueDialog)] = CPCXBlueDialog;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXFileDialog.InitFrame;
- var R: TRect;
- begin
- GetExtent(R);
- Frame:=New(PPCXFrame, Init(R));
- end;
-
- function GetCurDir: DirStr;
- var
- CurDir: DirStr;
- begin
- GetDir(0, CurDir);
- if Length(CurDir) > 3 then
- begin
- Inc(CurDir[0]);
- CurDir[Length(CurDir)] := '\';
- end;
- GetCurDir := CurDir;
- end;
-
- procedure TPCXFileDialog.ReadDirectory;
- begin
- FileList^.ReadDirectory(WildCard);
- Directory := NewStr(GetCurDir);
- end;
-
- {TPCXCheckBoxes}
- constructor TPCXCheckBoxes.Init(var Bounds: TRect; AStrings: PSItem; IsRightOn: Boolean);
- begin
- inherited Init(Bounds, AStrings);
- IsRight:=IsRightOn;
- end;
-
- procedure TPCXCheckBoxes.DrawMultiBox(const Icon, Marker: String);
- var
- I,J,Cur,Col: Integer;
- CNorm, CSel, CDis, Color: Word;
- B: TDrawBuffer;
- SCOff: Byte;
- begin
- CNorm := GetColor($0301);
- CSel := GetColor($0402);
- CDis := GetColor($0505);
- for I := 0 to Size.Y do
- begin
- MoveChar(B, ' ', Byte(CNorm), Size.X);
- for J := 0 to (Strings.Count - 1) div Size.Y + 1 do
- begin
- Cur := J*Size.Y + I;
- if Cur < Strings.Count then
- begin
- Col := Column(Cur);
- if (Col + CStrLen(PString(Strings.At(Cur))^) + 5 <
- Sizeof(TDrawBuffer) div SizeOf(Word)) and (Col < Size.X) then
- begin
- if not ButtonState(Cur) then
- Color := CDis
- else if (Cur = Sel) and (State and sfFocused <> 0) then
- Color := CSel
- else
- Color := CNorm;
- if not IsRight then
- begin
- MoveChar(B[Col], ' ', Byte(Color), Size.X - Col);
- MoveStr(B[Col], Icon, Byte(Color));
- WordRec(B[Col+2]).Lo := Byte(Marker[MultiMark(Cur) + 1]);
- MoveCStr(B[Col+5], PString(Strings.At(Cur))^, Color);
- end
- else
- begin
- MoveChar(B[Col], ' ', Byte(Color), Size.X - Col);
- MoveStr(B[Size.X-4], Icon, Byte(Color));
- WordRec(B[Size.X-2]).Lo := Byte(Marker[MultiMark(Cur) + 1]);
- MoveCStr(B[Col+2], PString(Strings.At(Cur))^, Color);
- end;
- if ShowMarkers and (State and sfFocused <> 0) and (Cur = Sel) then
- begin
- WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
- WordRec(B[Column(Cur+Size.Y)-1]).Lo := Byte(SpecialChars[1]);
- end;
- end;
- end;
- end;
- WriteBuf(0, I, Size.X, 1, B);
- end;
- if IsRight then SetCursor(Column(Sel)+Size.X-2,Row(Sel))
- else SetCursor(Column(Sel)+2,Row(Sel));
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXCheckBoxes.Column(Item: Integer): Integer;
- var
- I, Col, Width, L: Integer;
- begin
- if Item < Size.Y then Column := 0
- else
- begin
- Width := 0;
- Col := -6;
- for I := 0 to Item do
- begin
- if I mod Size.Y = 0 then
- begin
- Inc(Col, Width + 6);
- Width := 0;
- end;
- if I < Strings.Count then
- L := CStrLen(PString(Strings.At(I))^);
- if L > Width then Width := L;
- end;
- Column := Col;
- end;
- end;
-
- function TPCXCheckBoxes.FindSel(P: TPoint): Integer;
- var
- I, S: Integer;
- R: TRect;
- begin
- GetExtent(R);
- if not R.Contains(P) then FindSel := -1
- else
- begin
- I := 0;
- while P.X >= Column(I+Size.Y) do
- Inc(I, Size.Y);
- S := I + P.Y;
- if S >= Strings.Count then
- FindSel := -1 else
- FindSel := S;
- end;
- end;
-
- function TPCXCheckBoxes.Row(Item: Integer): Integer;
- begin
- Row := Item mod Size.Y;
- end;
-
- procedure TPCXCheckBoxes.Draw;
- const
- GraphButton = #32+CheckBoxLeft+#32+CheckBoxRight+#32; {' [ ] '}
- TextButton = ' [ ] ';
- begin
- if IsPCXGraphCharsOn
- then DrawMultiBox(GraphButton, CheckBoxCenterN+CheckBoxCenterX) {' X'}
- else DrawMultiBox(TextButton, ' X');
- end;
-
- function TPCXCheckBoxes.GetPalette: PPalette;
- const P: String[Length(CPCXCheckBoxes)] = CPCXCheckBoxes;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXCheckBoxes.Press(Item: Integer);
- begin
- Inherited Press(Item);
- Message(Owner, evCommand, cmCheckBoxChanged, @Self);
- end;
-
- {TPCXRadioButtons}
- constructor TPCXRadioButtons.Init(var Bounds: TRect; AStrings: PSItem; IsRightOn: Boolean);
- begin
- inherited Init(Bounds, AStrings);
- IsRight:=IsRightOn;
- end;
-
- procedure TPCXRadioButtons.DrawMultiBox(const Icon, Marker: String);
- var
- I,J,Cur,Col: Integer;
- CNorm, CSel, CDis, Color: Word;
- B: TDrawBuffer;
- SCOff: Byte;
- begin
- CNorm := GetColor($0301);
- CSel := GetColor($0402);
- CDis := GetColor($0505);
- for I := 0 to Size.Y do
- begin
- MoveChar(B, ' ', Byte(CNorm), Size.X);
- for J := 0 to (Strings.Count - 1) div Size.Y + 1 do
- begin
- Cur := J*Size.Y + I;
- if Cur < Strings.Count then
- begin
- Col := Column(Cur);
- if (Col + CStrLen(PString(Strings.At(Cur))^) + 5 <
- Sizeof(TDrawBuffer) div SizeOf(Word)) and (Col < Size.X) then
- begin
- if not ButtonState(Cur) then
- Color := CDis
- else if (Cur = Sel) and (State and sfFocused <> 0) then
- Color := CSel
- else
- Color := CNorm;
- if not IsRight then
- begin
- MoveChar(B[Col], ' ', Byte(Color), Size.X - Col);
- MoveStr(B[Col], Icon, Byte(Color));
- WordRec(B[Col+2]).Lo := Byte(Marker[MultiMark(Cur) + 1]);
- MoveCStr(B[Col+5], PString(Strings.At(Cur))^, Color);
- end
- else
- begin
- MoveChar(B[Col], ' ', Byte(Color), Size.X - Col);
- MoveStr(B[Size.X-4], Icon, Byte(Color));
- WordRec(B[Size.X-2]).Lo := Byte(Marker[MultiMark(Cur) + 1]);
- MoveCStr(B[Col+2], PString(Strings.At(Cur))^, Color);
- end;
- if ShowMarkers and (State and sfFocused <> 0) and (Cur = Sel) then
- begin
- WordRec(B[Col]).Lo := Byte(SpecialChars[0]);
- WordRec(B[Column(Cur+Size.Y)-1]).Lo := Byte(SpecialChars[1]);
- end;
- end;
- end;
- end;
- WriteBuf(0, I, Size.X, 1, B);
- end;
- if IsRight then SetCursor(Column(Sel)+Size.X-2,Row(Sel))
- else SetCursor(Column(Sel)+2,Row(Sel));
- Message(Application, evCommand, cmMouseChanged, @Self);
- end;
-
- function TPCXRadioButtons.Column(Item: Integer): Integer;
- var
- I, Col, Width, L: Integer;
- begin
- if Item < Size.Y then Column := 0
- else
- begin
- Width := 0;
- Col := -6;
- for I := 0 to Item do
- begin
- if I mod Size.Y = 0 then
- begin
- Inc(Col, Width + 6);
- Width := 0;
- end;
- if I < Strings.Count then
- L := CStrLen(PString(Strings.At(I))^);
- if L > Width then Width := L;
- end;
- Column := Col;
- end;
- end;
-
- function TPCXRadioButtons.FindSel(P: TPoint): Integer;
- var
- I, S: Integer;
- R: TRect;
- begin
- GetExtent(R);
- if not R.Contains(P) then FindSel := -1
- else
- begin
- I := 0;
- while P.X >= Column(I+Size.Y) do
- Inc(I, Size.Y);
- S := I + P.Y;
- if S >= Strings.Count then
- FindSel := -1 else
- FindSel := S;
- end;
- end;
-
- function TPCXRadioButtons.Row(Item: Integer): Integer;
- begin
- Row := Item mod Size.Y;
- end;
-
- procedure TPCXRadioButtons.Draw;
- const
- GraphButton = #32+RadioButtonLeft+#32+RadioButtonRight+#32; {' ( ) '}
- TextButton = ' ( ) ';
- begin
- if IsPCXGraphCharsOn
- then DrawMultiBox(GraphButton, RadioButtonCenterN+RadioButtonCenterX) {#32#7}
- else DrawMultiBox(TextButton, #32#7);
- end;
-
- function TPCXRadioButtons.GetPalette: PPalette;
- const P: String[Length(CPCXRadioButtons)] = CPCXRadioButtons;
- begin
- GetPalette:=@P;
- end;
-
- procedure TPCXRadioButtons.Press(Item: Integer);
- begin
- Inherited Press(Item);
- Message(Owner, evCommand, cmRadioButtonChanged, @Self);
- end;
-
-
- {PCXMsgBox}
- function PCXMsgBoxRect(var R: TRect; const Msg: String; Params: Pointer;
- AOptions: Word): Word;
- {const
- ButtonName: Array[0..3] of String[6] =
- ('~Y~es', '~N~o', 'O~K~', 'Cancel');
- Commands: Array[0..3] of word =
- (cmYes, cmNo, cmOK, cmCancel);
- Titles: Array[0..3] of String[11] =
- ('Warning','Error','Information','Confirm');}
- var
- I, X, ButtonCount: Integer;
- Dialog: PDialog;
- Control: PView;
- ButtonList: Array[0..4] of PView;
- S: String;
- ButtonName: Array[0..3] of String[6];
- Commands: Array[0..3] of word;
- Titles: Array[0..3] of String[11];
- begin
- if Not IsMagyarul then
- begin
- ButtonName[0]:='~Y~es';
- ButtonName[1]:='~N~o';
- ButtonName[2]:='O~K~';
- ButtonName[3]:='Cancel';
-
- Commands[0]:=cmYes;
- Commands[1]:=cmNo;
- Commands[2]:=cmOK;
- Commands[3]:=cmCancel;
-
- Titles[0]:='Warning';
- Titles[1]:='Error';
- Titles[2]:='Information';
- Titles[3]:='Confirm';
- end
- else
- begin
- ButtonName[0]:='~I~gen';
- ButtonName[1]:='~N~em';
- ButtonName[2]:='O~K~';
- ButtonName[3]:='Mégsem';
-
- Commands[0]:=cmYes;
- Commands[1]:=cmNo;
- Commands[2]:=cmOK;
- Commands[3]:=cmCancel;
-
- Titles[0]:='Vigyázat';
- Titles[1]:='Hiba';
- Titles[2]:='Információ';
- Titles[3]:='Konfirmáció';
- end;
- {Special Thanks o Bérczi Gábor for: if mfError or mfWarning then RedDialog}
- if ((AOptions and 3)<>mfError) and ((AOptions and 3)<>mfWarning)
- then Dialog := New(PPCXBlueDialog,Init(R, Titles[AOptions and $3]))
- else Dialog := New(PPCXRedDialog,Init(R, Titles[AOptions and $3]));
- {End Thanks}
- with Dialog^ do
- begin
- R.Assign(3, 2, Size.X - 2, Size.Y - 3);
- FormatStr(S, Msg, Params^);
- Control := New(PStaticText, Init(R, S));
- Insert(Control);
- X := -2;
- ButtonCount := 0;
- for I := 0 to 3 do
- if AOptions and ($0100 shl I) <> 0 then
- begin
- R.Assign(0, 0, 10, 2);
- Control := New(PPCXButton, Init(R, ButtonName[I], Commands[i],
- bfNormal));
- Inc(X, Control^.Size.X + 2);
- ButtonList[ButtonCount] := Control;
- Inc(ButtonCount);
- end;
- X := (Size.X - X) shr 1;
- for I := 0 to ButtonCount - 1 do
- begin
- Control := ButtonList[I];
- Insert(Control);
- Control^.MoveTo(X, Size.Y - 3);
- Inc(X, Control^.Size.X + 2);
- end;
- SelectNext(False);
- end;
- if AOptions and mfInsertInApp = 0 then
- PCXMsgBoxRect := DeskTop^.ExecView(Dialog)
- else PCXMsgBoxRect := Application^.ExecView(Dialog);
- Dispose(Dialog, Done);
- end;
-
- function PCXMsgBox(const Msg: String; Params: Pointer; AOptions: Word): Word;
- var
- R: TRect;
- begin
- R.Assign(0, 0, 40, 9);
- if AOptions and mfInsertInApp = 0 then
- R.Move((Desktop^.Size.X - R.B.X) div 2, (Desktop^.Size.Y - R.B.Y) div 2)
- else R.Move((Application^.Size.X - R.B.X) div 2, (Application^.Size.Y - R.B.Y) div 2);
- PCXMsgBox := PCXMsgBoxRect(R, Msg, Params, AOptions);
- end;
-
- END.