mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 12:20:38 +02:00
AJ: made InputQuery Interface Dependant
git-svn-id: trunk@3499 -
This commit is contained in:
parent
53e90eeb49
commit
711f18100c
@ -243,8 +243,10 @@ type
|
||||
procedure ShowMessageFmt(const aMsg: string; Params: array of const);
|
||||
procedure ShowMessagePos(const aMsg: string; X, Y: Integer);
|
||||
|
||||
Function InputQuery(const ACaption, APrompt : String; MaskInput : Boolean; var Value : String) : Boolean;
|
||||
Function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
||||
Function InputBox(const ACaption, APrompt, ADefault : String) : String;
|
||||
Function PasswordBox(const ACaption, APrompt : String) : String;
|
||||
|
||||
implementation
|
||||
|
||||
@ -292,6 +294,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.20 2002/10/11 16:00:39 lazarus
|
||||
AJ: made InputQuery Interface Dependant
|
||||
|
||||
Revision 1.19 2002/10/10 13:29:08 lazarus
|
||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||
|
||||
|
@ -513,89 +513,28 @@ begin
|
||||
InputQuery(ACaption, APrompt, Result);
|
||||
end;
|
||||
|
||||
Function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
||||
var
|
||||
Form : TForm;
|
||||
Prompt : TLabel;
|
||||
Edit : TEdit;
|
||||
T : String;
|
||||
ButtonTop, ButtonWidth, ButtonHeight : Integer;
|
||||
Avg : TPoint;
|
||||
Function PasswordBox(const ACaption, APrompt : String) : String;
|
||||
begin
|
||||
Result := False;
|
||||
Form := TForm.CreateNew(nil, 0);
|
||||
With Form do begin
|
||||
BorderStyle := bsDialog;
|
||||
Caption := ACaption;
|
||||
Prompt := TLabel.Create(Form);
|
||||
With Prompt do begin
|
||||
Parent := Form;
|
||||
Caption := APrompt;
|
||||
Visible := True;
|
||||
end;
|
||||
SelectObject(Canvas.Handle, GetStockObject(SYSTEM_FONT));
|
||||
AVG := GetAvgCharSize(Canvas.Handle);
|
||||
Position := poScreenCenter;
|
||||
Prompt.Left := (7*AVG.X) div 4;
|
||||
Prompt.Top := (8*AVG.Y) div 8;
|
||||
Prompt.Width := AVG.X * Length(APrompt) + 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;
|
||||
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;
|
||||
Show;
|
||||
Edit.SetFocus;
|
||||
Hide;
|
||||
If ShowModal = mrOk then
|
||||
begin
|
||||
T := Edit.Text;
|
||||
Result := True;
|
||||
End;
|
||||
Form.Close;
|
||||
end;
|
||||
Value := T;
|
||||
Result := '';
|
||||
InputQuery(ACaption, APrompt, True, Result);
|
||||
end;
|
||||
|
||||
Function InputQuery(const ACaption, APrompt : String; MaskInput : Boolean;
|
||||
var Value : String) : Boolean;
|
||||
begin
|
||||
Result := LCLLinux.RequestInput(ACaption, APrompt, MaskInput, Value);
|
||||
end;
|
||||
|
||||
Function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
||||
begin
|
||||
Result := InputQuery(ACaption, APrompt, False, Value);
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002/10/11 16:00:39 lazarus
|
||||
AJ: made InputQuery Interface Dependant
|
||||
|
||||
Revision 1.15 2002/10/10 13:29:08 lazarus
|
||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||
|
||||
|
@ -54,6 +54,64 @@ begin
|
||||
Result := HBitmap(Pixmap);
|
||||
end;
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//-------------------------TGnomeObject.RequestInput--------------------------//
|
||||
Type
|
||||
PRequestInputObject = ^TRequestInputObject;
|
||||
TRequestInputObject = Record
|
||||
Finished : Boolean;
|
||||
NewValue : String;
|
||||
end;
|
||||
|
||||
procedure RequestInputFinishCallback(NewString:PChar; data: PRequestInputObject);cdecl;
|
||||
var
|
||||
I, Len : Longint;
|
||||
begin
|
||||
If Data <> nil then
|
||||
with Data^ do begin
|
||||
If NewString = nil then
|
||||
NewValue := ''
|
||||
else begin
|
||||
Len := StrLen(NewString);
|
||||
SetLength(NewValue, Len);
|
||||
For I := 0 to Len - 1 do
|
||||
NewValue[I + 1] := NewString[I];
|
||||
end;
|
||||
Finished := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TGnomeObject.RequestInput(const InputCaption, InputPrompt : String;
|
||||
MaskInput : Boolean; var Value : String) : Boolean;
|
||||
var
|
||||
MainWidget,
|
||||
RequestWidget : Pointer;
|
||||
RequestObject : TRequestInputObject;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
If (Application.MainForm <> nil) and
|
||||
(Application.MainForm.HandleAllocated)
|
||||
then
|
||||
MainWidget := Pointer(Application.MainForm.Handle);
|
||||
|
||||
With RequestObject do begin
|
||||
Finished := False;
|
||||
NewValue := Value;
|
||||
end;
|
||||
|
||||
RequestWidget := gnome_request_dialog(MaskInput, PChar(InputPrompt), PChar(Value), 256,
|
||||
TGnomeStringCallback(@RequestInputFinishCallback), @RequestObject, MainWidget);
|
||||
|
||||
gtk_window_set_title(RequestWidget,PChar(InputCaption));
|
||||
|
||||
If gnome_dialog_run_and_close(RequestWidget) = 0 then
|
||||
If RequestObject.Finished then begin
|
||||
Result := True;
|
||||
Value := RequestObject.NewValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IfDef ASSERT_IS_ON}
|
||||
{$UNDEF ASSERT_IS_ON}
|
||||
{$C-}
|
||||
@ -61,6 +119,9 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2002/10/11 16:00:39 lazarus
|
||||
AJ: made InputQuery Interface Dependant
|
||||
|
||||
Revision 1.2 2002/10/10 13:29:08 lazarus
|
||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||
|
||||
|
@ -18,10 +18,15 @@
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
Function LoadStockPixmap(StockID: longint) : HBitmap; override;
|
||||
Function LoadStockPixmap(StockID: longint) : HBitmap; override;
|
||||
|
||||
Function RequestInput(const InputCaption, InputPrompt : String; MaskInput : Boolean; var Value : String) : Boolean; override;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2002/10/11 16:00:39 lazarus
|
||||
AJ: made InputQuery Interface Dependant
|
||||
|
||||
Revision 1.2 2002/10/10 13:29:08 lazarus
|
||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user