1 | {$INCLUDE Switches.inc}
|
---|
2 | unit Inp;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | ScreenTools, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
|
---|
8 | DrawDlg, ButtonA, StdCtrls;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TInputDlg = class(TDrawDlg)
|
---|
12 | OKBtn: TButtonA;
|
---|
13 | EInput: TEdit;
|
---|
14 | procedure OKBtnClick(Sender: TObject);
|
---|
15 | procedure FormPaint(Sender: TObject);
|
---|
16 | procedure FormCreate(Sender: TObject);
|
---|
17 | procedure EInputKeyPress(Sender: TObject; var Key: Char);
|
---|
18 | procedure FormShow(Sender: TObject);
|
---|
19 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
20 | public
|
---|
21 | procedure CenterToRect(Rect: TRect);
|
---|
22 | private
|
---|
23 | Center: boolean;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | var
|
---|
27 | InputDlg: TInputDlg;
|
---|
28 |
|
---|
29 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | {$R *.lfm}
|
---|
33 |
|
---|
34 | procedure TInputDlg.FormCreate(Sender: TObject);
|
---|
35 | begin
|
---|
36 | Canvas.Font.Assign(UniFont[ftNormal]);
|
---|
37 | Canvas.Brush.Style := bsClear;
|
---|
38 | TitleHeight := Height;
|
---|
39 | InitButtons;
|
---|
40 | Center := True;
|
---|
41 | end;
|
---|
42 |
|
---|
43 | procedure TInputDlg.FormPaint(Sender: TObject);
|
---|
44 | begin
|
---|
45 | PaintBackground(self, 3, 3, ClientWidth - 6, ClientHeight - 6);
|
---|
46 | Frame(Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
|
---|
47 | Frame(Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
|
---|
48 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
49 | Frame(Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
|
---|
50 | MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
|
---|
51 | EditFrame(Canvas, EInput.BoundsRect, MainTexture);
|
---|
52 | BtnFrame(Canvas, OKBtn.BoundsRect, MainTexture);
|
---|
53 | RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, Caption)) div 2,
|
---|
54 | 9, Caption);
|
---|
55 | { Corner(canvas,1,1,0,MainTexture);
|
---|
56 | Corner(canvas,ClientWidth-9,1,1,MainTexture);
|
---|
57 | Corner(canvas,1,ClientHeight-9,2,MainTexture);
|
---|
58 | Corner(canvas,ClientWidth-9,ClientHeight-9,3,MainTexture); }
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TInputDlg.OKBtnClick(Sender: TObject);
|
---|
62 | begin
|
---|
63 | if EInput.Text = '' then
|
---|
64 | ModalResult := mrCancel
|
---|
65 | else
|
---|
66 | ModalResult := mrOK;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TInputDlg.EInputKeyPress(Sender: TObject; var Key: Char);
|
---|
70 | begin
|
---|
71 | if (Key = #13) and (EInput.Text <> '') then
|
---|
72 | begin
|
---|
73 | Key := #0;
|
---|
74 | ModalResult := mrOK;
|
---|
75 | end
|
---|
76 | else if Key = #27 then
|
---|
77 | begin
|
---|
78 | Key := #0;
|
---|
79 | ModalResult := mrCancel;
|
---|
80 | end;
|
---|
81 | end;
|
---|
82 |
|
---|
83 | procedure TInputDlg.FormShow(Sender: TObject);
|
---|
84 | begin
|
---|
85 | OKBtn.Caption := Phrases.Lookup('BTN_OK');
|
---|
86 | EInput.Font.Color := MainTexture.ColorMark;
|
---|
87 | EInput.SelStart := 0;
|
---|
88 | EInput.SelLength := Length(EInput.Text);
|
---|
89 | if Center then
|
---|
90 | CenterToRect(Rect(0, 0, Screen.Width, Screen.Height));
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TInputDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
94 | begin
|
---|
95 | Center := True;
|
---|
96 | end;
|
---|
97 |
|
---|
98 | procedure TInputDlg.CenterToRect(Rect: TRect);
|
---|
99 | begin
|
---|
100 | Center := False;
|
---|
101 | Left := Rect.Left + (Rect.Right - Rect.Left - Width) div 2;
|
---|
102 | Top := Rect.Top + (Rect.Bottom - Rect.Top - Height) div 2;
|
---|
103 | end;
|
---|
104 |
|
---|
105 | end.
|
---|