mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 18:19:22 +02:00
LCL: Adjust edit widths in InputQuery. Issue #28176, patch from Alexey Torgashin.
git-svn-id: trunk@49173 -
This commit is contained in:
parent
b8503e1976
commit
cf63e6850c
@ -525,7 +525,8 @@ function InputBox(const ACaption, APrompt, ADefault : String) : String;
|
||||
function PasswordBox(const ACaption, APrompt : String) : String;
|
||||
|
||||
const
|
||||
cInputQueryEditSize: integer = 320;
|
||||
cInputQueryEditSizePixels: integer = 260; // Edit size in pixels
|
||||
cInputQueryEditSizePercents: integer = 25; // Edit size in % of monitor width
|
||||
cInputQuerySpacingSize: integer = 6;
|
||||
|
||||
type
|
||||
|
@ -8,20 +8,19 @@
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
function _InputQueryActiveMonitor: TMonitor;
|
||||
begin
|
||||
if Screen.ActiveCustomForm <> nil then
|
||||
Result := Screen.ActiveCustomForm.Monitor
|
||||
else
|
||||
if Application.MainForm <> nil then
|
||||
Result := Application.MainForm.Monitor
|
||||
else
|
||||
Result := Screen.PrimaryMonitor;
|
||||
end;
|
||||
|
||||
function ShowInputDialog(const InputCaption, InputPrompt : String;
|
||||
MaskInput : Boolean; var Value : String) : Boolean;
|
||||
|
||||
function ActiveMonitor: TMonitor; inline;
|
||||
begin
|
||||
if Screen.ActiveCustomForm <> nil then
|
||||
Result := Screen.ActiveCustomForm.Monitor
|
||||
else
|
||||
if Application.MainForm <> nil then
|
||||
Result := Application.MainForm.Monitor
|
||||
else
|
||||
Result := Screen.PrimaryMonitor;
|
||||
end;
|
||||
|
||||
var
|
||||
Form: TForm;
|
||||
Prompt: TLabel;
|
||||
@ -54,10 +53,12 @@ begin
|
||||
Top := Prompt.Height;
|
||||
Align := alTop;
|
||||
BorderSpacing.Top := 3;
|
||||
AMonitor := ActiveMonitor;
|
||||
AMonitor := _InputQueryActiveMonitor;
|
||||
// check that edit is smaller than our monitor, it must be smaller at least
|
||||
// by 6 * 2 pixels (spacing from window borders) + window border
|
||||
MinEditWidth := Min(AMonitor.Width - 20, Max(260, AMonitor.Width div 4));
|
||||
MinEditWidth := Min(AMonitor.Width - 20,
|
||||
Max(cInputQueryEditSizePixels,
|
||||
AMonitor.Width * cInputQueryEditSizePercents div 100));
|
||||
Constraints.MinWidth := MinEditWidth;
|
||||
Text := Value;
|
||||
TabStop := True;
|
||||
|
@ -379,7 +379,9 @@ begin
|
||||
FEdits[i]:= TEdit.Create(FForm);
|
||||
FEdits[i].Parent:= FPanels[i];
|
||||
FEdits[i].Align:= alRight;
|
||||
FEdits[i].Width:= cInputQueryEditSize;
|
||||
FEdits[i].Width:= Max(
|
||||
cInputQueryEditSizePixels,
|
||||
_InputQueryActiveMonitor.Width * cInputQueryEditSizePercents div 100);
|
||||
FEdits[i].Text:= AValues[i];
|
||||
|
||||
FLabels[i]:= TPanel.Create(FForm);
|
||||
|
Loading…
Reference in New Issue
Block a user