mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 21:18:01 +02:00
MG: added inputdialog.inc
git-svn-id: trunk@1325 -
This commit is contained in:
parent
4711a5aa61
commit
b80c81bf4f
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -416,6 +416,7 @@ lcl/include/hintwindow.inc svneol=native#text/pascal
|
||||
lcl/include/hkeys.inc svneol=native#text/pascal
|
||||
lcl/include/image.inc svneol=native#text/pascal
|
||||
lcl/include/imglist.inc svneol=native#text/pascal
|
||||
lcl/include/inputdialog.inc svneol=native#text/pascal
|
||||
lcl/include/interfacebase.inc svneol=native#text/pascal
|
||||
lcl/include/listitem.inc svneol=native#text/pascal
|
||||
lcl/include/listitems.inc svneol=native#text/pascal
|
||||
|
103
lcl/include/inputdialog.inc
Normal file
103
lcl/include/inputdialog.inc
Normal file
@ -0,0 +1,103 @@
|
||||
// included by dialogs.pp
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.LCL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
Function ShowInputDialog(const InputCaption, InputPrompt : String;
|
||||
MaskInput : Boolean; var Value : String) : Boolean;
|
||||
Const
|
||||
AVGBuffer : PChar = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890()|_ ';
|
||||
var
|
||||
Form : TForm;
|
||||
Prompt : TLabel;
|
||||
Edit : TEdit;
|
||||
ButtonTop, ButtonWidth, ButtonHeight : Integer;
|
||||
Avg : TPoint;
|
||||
begin
|
||||
Result := False;
|
||||
Form := TForm.CreateNew(nil, 0);
|
||||
With Form do begin
|
||||
BorderStyle := bsDialog;
|
||||
Caption := InputCaption;
|
||||
Prompt := TLabel.Create(Form);
|
||||
With Prompt do begin
|
||||
Parent := Form;
|
||||
Caption := InputPrompt;
|
||||
Visible := True;
|
||||
end;
|
||||
SelectObject(Canvas.Handle, GetStockObject(SYSTEM_FONT));
|
||||
GetTextExtentPoint(Canvas.Handle,AVGBuffer,StrLen(AVGBuffer),TSize(AVG));
|
||||
AVG.X := AVG.X div 52;
|
||||
Position := poScreenCenter;
|
||||
Prompt.Left := (7*AVG.X) div 4;
|
||||
Prompt.Top := (8*AVG.Y) div 8;
|
||||
Prompt.Width := AVG.X * Length(InputPrompt) + 1;
|
||||
ClientWidth := (172*AVG.X) div 4;
|
||||
ClientHeight := (58*AVG.Y) div 8;
|
||||
ButtonTop := (39*AVG.Y) div 8;
|
||||
ButtonWidth := (50*AVG.X) div 4;
|
||||
ButtonHeight := (13*AVG.Y) div 8;
|
||||
Edit := TEdit.Create(Form);
|
||||
With Edit do begin
|
||||
Parent := Form;
|
||||
Left := Prompt.Left;
|
||||
Top := (19*AVG.Y) div 8;
|
||||
Width := (160*AVG.X) div 4;
|
||||
Height := (7*AVG.Y) div 4;
|
||||
Text := Value;
|
||||
TabStop := True;
|
||||
Visible := True;
|
||||
If MaskInput then
|
||||
EchoMode := emPassword
|
||||
else
|
||||
EchoMode := emNormal;
|
||||
TabOrder := 0;
|
||||
end;
|
||||
With TBitBtn.Create(Form) do begin
|
||||
Parent := Form;
|
||||
Kind := bkOk;
|
||||
Default := True;
|
||||
ModalResult := mrOk;
|
||||
Left := (37*AVG.X) div 4;
|
||||
Top := ButtonTop;
|
||||
Height := ButtonHeight;
|
||||
Width := ButtonWidth;
|
||||
TabStop := True;
|
||||
Visible := True;
|
||||
TabOrder := 1;
|
||||
end;
|
||||
With TBitBtn.Create(Form) do begin
|
||||
Parent := Form;
|
||||
Kind := bkCancel;
|
||||
Cancel := True;
|
||||
Left := (92*AVG.X) div 4;
|
||||
Top := ButtonTop;
|
||||
Height := ButtonHeight;
|
||||
Width := ButtonWidth;
|
||||
TabStop := True;
|
||||
Visible := True;
|
||||
TabOrder := 2;
|
||||
end;
|
||||
Edit.SetFocus;
|
||||
If ShowModal = mrOk then
|
||||
begin
|
||||
Value := Edit.Text;
|
||||
Result := True;
|
||||
end;
|
||||
Form.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
// included by dialogs.pp
|
||||
|
@ -41,8 +41,8 @@ interface
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
SysUtils, LCLLinux, LCLType, VCLGlobals, Classes, LMessages, Controls,
|
||||
GraphType, GraphicsMath;
|
||||
SysUtils, LCLStrConsts, LCLLinux, LCLType, LCLProc, VCLGlobals, Classes,
|
||||
LMessages, Controls, GraphType, GraphicsMath;
|
||||
|
||||
type
|
||||
|
||||
@ -79,23 +79,35 @@ type
|
||||
{$I defaultbitbtnimages.inc}
|
||||
{$I messagedialogpixmaps.inc}
|
||||
|
||||
type
|
||||
TInputDialogFunction = Function (const InputCaption, InputPrompt : String;
|
||||
MaskInput : Boolean; var Value : String) : Boolean;
|
||||
|
||||
var
|
||||
InputDialogFunction: TInputDialogFunction;
|
||||
|
||||
implementation
|
||||
|
||||
Uses
|
||||
LCLStrConsts, Forms, StdCtrls, ExtCtrls, Graphics, Buttons;
|
||||
Forms, StdCtrls, Graphics, Buttons;
|
||||
|
||||
|
||||
{$I interfacebase.inc}
|
||||
|
||||
|
||||
initialization
|
||||
InputDialogFunction:=nil;
|
||||
|
||||
finalization
|
||||
InputDialogFunction:=nil;
|
||||
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.21 2002/10/25 09:47:37 lazarus
|
||||
MG: added inputdialog.inc
|
||||
|
||||
Revision 1.20 2002/10/24 22:10:39 lazarus
|
||||
AJ: More changes for better code reuse between gnome & gtk interfaces
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user