LCL: Adjust edit widths in InputQuery. Issue #28176, patch from Alexey Torgashin.

git-svn-id: trunk@49173 -
This commit is contained in:
juha 2015-05-25 22:30:55 +00:00
parent b8503e1976
commit cf63e6850c
3 changed files with 20 additions and 16 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);