mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 15:03:35 +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 ShowMessageFmt(const aMsg: string; Params: array of const);
|
||||||
procedure ShowMessagePos(const aMsg: string; X, Y: Integer);
|
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 InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
||||||
Function InputBox(const ACaption, APrompt, ADefault : String) : String;
|
Function InputBox(const ACaption, APrompt, ADefault : String) : String;
|
||||||
|
Function PasswordBox(const ACaption, APrompt : String) : String;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -292,6 +294,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$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
|
Revision 1.19 2002/10/10 13:29:08 lazarus
|
||||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||||
|
|
||||||
|
@ -513,89 +513,28 @@ begin
|
|||||||
InputQuery(ACaption, APrompt, Result);
|
InputQuery(ACaption, APrompt, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
Function PasswordBox(const ACaption, APrompt : String) : String;
|
||||||
var
|
|
||||||
Form : TForm;
|
|
||||||
Prompt : TLabel;
|
|
||||||
Edit : TEdit;
|
|
||||||
T : String;
|
|
||||||
ButtonTop, ButtonWidth, ButtonHeight : Integer;
|
|
||||||
Avg : TPoint;
|
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := '';
|
||||||
Form := TForm.CreateNew(nil, 0);
|
InputQuery(ACaption, APrompt, True, Result);
|
||||||
With Form do begin
|
end;
|
||||||
BorderStyle := bsDialog;
|
|
||||||
Caption := ACaption;
|
Function InputQuery(const ACaption, APrompt : String; MaskInput : Boolean;
|
||||||
Prompt := TLabel.Create(Form);
|
var Value : String) : Boolean;
|
||||||
With Prompt do begin
|
begin
|
||||||
Parent := Form;
|
Result := LCLLinux.RequestInput(ACaption, APrompt, MaskInput, Value);
|
||||||
Caption := APrompt;
|
end;
|
||||||
Visible := True;
|
|
||||||
end;
|
Function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;
|
||||||
SelectObject(Canvas.Handle, GetStockObject(SYSTEM_FONT));
|
begin
|
||||||
AVG := GetAvgCharSize(Canvas.Handle);
|
Result := InputQuery(ACaption, APrompt, False, Value);
|
||||||
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;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
Revision 1.15 2002/10/10 13:29:08 lazarus
|
||||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||||
|
|
||||||
|
@ -54,6 +54,64 @@ begin
|
|||||||
Result := HBitmap(Pixmap);
|
Result := HBitmap(Pixmap);
|
||||||
end;
|
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}
|
{$IfDef ASSERT_IS_ON}
|
||||||
{$UNDEF ASSERT_IS_ON}
|
{$UNDEF ASSERT_IS_ON}
|
||||||
{$C-}
|
{$C-}
|
||||||
@ -61,6 +119,9 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$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
|
Revision 1.2 2002/10/10 13:29:08 lazarus
|
||||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
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$
|
$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
|
Revision 1.2 2002/10/10 13:29:08 lazarus
|
||||||
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
AJ: added LoadStockPixmap routine & minor fixes to/for GNOMEInt
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user