source: branches/AlphaChannel/Inp.pas

Last change on this file was 111, checked in by chronos, 6 years ago
  • Modified: Custom defined form dialogs moved to CevoComponents so they can be correctly opened in IDE.
  • Modified: Moved Sound, StringTables and Directories to CevoComponents as dependency for custom form dialogs.
File size: 2.8 KB
Line 
1{$INCLUDE Switches.inc}
2unit Inp;
3
4interface
5
6uses
7 ScreenTools, Messg,
8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, DrawDlg,
9 ButtonA, StdCtrls;
10
11type
12 TInputDlg = class(TDrawDlg)
13 OKBtn: TButtonA;
14 EInput: TEdit;
15 procedure OKBtnClick(Sender: TObject);
16 procedure FormPaint(Sender: TObject);
17 procedure FormCreate(Sender: TObject);
18 procedure EInputKeyPress(Sender: TObject; var Key: Char);
19 procedure FormShow(Sender: TObject);
20 procedure FormClose(Sender: TObject; var Action: TCloseAction);
21 public
22 procedure CenterToRect(Rect: TRect);
23 private
24 Center: boolean;
25 end;
26
27var
28 InputDlg: TInputDlg;
29
30implementation
31
32{$R *.lfm}
33
34procedure TInputDlg.FormCreate(Sender: TObject);
35begin
36 Canvas.Font.Assign(UniFont[ftNormal]);
37 Canvas.Brush.Style := bsClear;
38 TitleHeight := Height;
39 InitButtons();
40 Center := true;
41end;
42
43procedure TInputDlg.FormPaint(Sender: TObject);
44begin
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.clBevelLight, MainTexture.clBevelShade);
49 Frame(Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
50 MainTexture.clBevelLight, MainTexture.clBevelShade);
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); }
59end;
60
61procedure TInputDlg.OKBtnClick(Sender: TObject);
62begin
63 if EInput.Text = '' then
64 ModalResult := mrCancel
65 else
66 ModalResult := mrOK
67end;
68
69procedure TInputDlg.EInputKeyPress(Sender: TObject; var Key: Char);
70begin
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
81end;
82
83procedure TInputDlg.FormShow(Sender: TObject);
84begin
85 OKBtn.Caption := Phrases.Lookup('BTN_OK');
86 EInput.Font.Color := MainTexture.clMark;
87 EInput.SelStart := 0;
88 EInput.SelLength := Length(EInput.Text);
89 if Center then
90 CenterToRect(Rect(0, 0, Screen.Width, Screen.Height));
91end;
92
93procedure TInputDlg.FormClose(Sender: TObject; var Action: TCloseAction);
94begin
95 Center := true
96end;
97
98procedure TInputDlg.CenterToRect(Rect: TRect);
99begin
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;
103end;
104
105end.
Note: See TracBrowser for help on using the repository browser.