You've already forked lazarus-ccr
tvplanit: Improvements of event and contact editor at high-dpi, but still issues.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4951 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -58,6 +58,9 @@
|
|||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Linking>
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<UseExternalDbgSyms Value="True"/>
|
||||||
|
</Debugging>
|
||||||
<Options>
|
<Options>
|
||||||
<Win32>
|
<Win32>
|
||||||
<GraphicApplication Value="True"/>
|
<GraphicApplication Value="True"/>
|
||||||
|
@ -374,9 +374,6 @@ const
|
|||||||
// FormHeightOffset = 103;
|
// FormHeightOffset = 103;
|
||||||
// MinFormHeight = 250;
|
// MinFormHeight = 250;
|
||||||
TopField = 8;
|
TopField = 8;
|
||||||
DIST = 4; // distance between label and edit/combo
|
|
||||||
HBORDER = 8; // distance between container border and label
|
|
||||||
VDIST = 2; // vertical distance between edits
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TLabelArray = array of TLabel;
|
TLabelArray = array of TLabel;
|
||||||
@ -395,8 +392,16 @@ var
|
|||||||
delta: Integer;
|
delta: Integer;
|
||||||
corr: Integer; // difference between form's client width and tabsheet width
|
corr: Integer; // difference between form's client width and tabsheet width
|
||||||
editHeight: Integer; // Height of an edit control
|
editHeight: Integer; // Height of an edit control
|
||||||
|
vDist: Integer; // Vertical distance between edits
|
||||||
|
hBorder: Integer; // Distance between container border and label
|
||||||
|
dist: Integer; // distance between label and edit/combo
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
dist := round(4 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
vdist := round(2 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
hBorder := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
editHeight := LastNameEdit.Height * Screen.PixelsPerInch div DesignTimeDPI;
|
||||||
|
|
||||||
{ Note: The resizing algorithm is dependent upon the labels having their
|
{ Note: The resizing algorithm is dependent upon the labels having their
|
||||||
FocusControl property set to the corresponding edit field or combobox. }
|
FocusControl property set to the corresponding edit field or combobox. }
|
||||||
|
|
||||||
@ -466,8 +471,6 @@ begin
|
|||||||
cboxState.Width := widestField;
|
cboxState.Width := widestField;
|
||||||
|
|
||||||
{ Vertically arrange the fields. }
|
{ Vertically arrange the fields. }
|
||||||
editHeight := LastNameEdit.Height;
|
|
||||||
|
|
||||||
delta := (Labels[0].FocusControl.Height - labels[0].Height) div 2;
|
delta := (Labels[0].FocusControl.Height - labels[0].Height) div 2;
|
||||||
FieldTop := TopField;
|
FieldTop := TopField;
|
||||||
for i := Low(Labels) to High(Labels) do
|
for i := Low(Labels) to High(Labels) do
|
||||||
@ -661,6 +664,11 @@ procedure TContactEditForm.FormShow(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
if tsContacts.ActivePage = tabMain then
|
if tsContacts.ActivePage = tabMain then
|
||||||
LastNameEdit.SetFocus;
|
LastNameEdit.SetFocus;
|
||||||
|
(*
|
||||||
|
{$IFDEF LCL}
|
||||||
|
ScaleDPI(Self, DesigntimeDPI);
|
||||||
|
{$ENDIF}
|
||||||
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -606,6 +606,11 @@ end;
|
|||||||
procedure TDlgEventEdit.FormShow(Sender: TObject);
|
procedure TDlgEventEdit.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
PositionControls;
|
PositionControls;
|
||||||
|
(*
|
||||||
|
{$IFDEF LCL}
|
||||||
|
ScaleDPI(Self, DesigntimeDPI);
|
||||||
|
{$ENDIF}
|
||||||
|
*)
|
||||||
DescriptionEdit.SetFocus;
|
DescriptionEdit.SetFocus;
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
@ -138,6 +138,14 @@ function GetRealFontHeight(AFont: TFont): Integer;
|
|||||||
function DecodeLineEndings(const AText: String): String;
|
function DecodeLineEndings(const AText: String): String;
|
||||||
function EncodeLineEndings(const AText: String): String;
|
function EncodeLineEndings(const AText: String): String;
|
||||||
|
|
||||||
|
{$IFDEF LCL}
|
||||||
|
procedure HighDPI(FromDPI: integer);
|
||||||
|
procedure ScaleDPI(Control: TControl; FromDPI: integer);
|
||||||
|
|
||||||
|
const
|
||||||
|
DesignTimeDPI = 96;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure Unused(const A1); overload;
|
procedure Unused(const A1); overload;
|
||||||
procedure Unused(const A1, A2); overload;
|
procedure Unused(const A1, A2); overload;
|
||||||
procedure Unused(const A1, A2, A3); overload;
|
procedure Unused(const A1, A2, A3); overload;
|
||||||
@ -586,6 +594,7 @@ var
|
|||||||
begin
|
begin
|
||||||
canvas := TControlCanvas.Create;
|
canvas := TControlCanvas.Create;
|
||||||
canvas.Control := ALabel;
|
canvas.Control := ALabel;
|
||||||
|
canvas.Font.Assign(ALabel.Font);
|
||||||
Result := canvas.TextWidth(ALabel.Caption);
|
Result := canvas.TextWidth(ALabel.Caption);
|
||||||
canvas.Free;
|
canvas.Free;
|
||||||
end;
|
end;
|
||||||
@ -594,7 +603,7 @@ function GetRealFontHeight(AFont: TFont): Integer;
|
|||||||
begin
|
begin
|
||||||
if AFont.Size = 0 then
|
if AFont.Size = 0 then
|
||||||
{$IFDEF LCL}
|
{$IFDEF LCL}
|
||||||
Result := GetFontData(AFont.Reference.Handle).Height
|
Result := GetFontData(AFont.Reference.Handle).Height * Screen.PixelsPerInch div DesignTimeDPI
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := GetFontData(AFont.Handle).Height
|
Result := GetFontData(AFont.Handle).Height
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -645,6 +654,45 @@ begin
|
|||||||
Result := StringReplace(AText, LineEnding, '\n', [rfReplaceAll]);
|
Result := StringReplace(AText, LineEnding, '\n', [rfReplaceAll]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF LCL}
|
||||||
|
procedure HighDPI(FromDPI: integer);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
if Screen.PixelsPerInch = FromDPI then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
for i := 0 to Screen.FormCount - 1 do
|
||||||
|
ScaleDPI(Screen.Forms[i], FromDPI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure ScaleDPI(Control: TControl; FromDPI: integer);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
WinControl: TWinControl;
|
||||||
|
begin
|
||||||
|
if Screen.PixelsPerInch = FromDPI then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
with Control do
|
||||||
|
begin
|
||||||
|
Left := ScaleX(Left, FromDPI);
|
||||||
|
Top := ScaleY(Top, FromDPI);
|
||||||
|
Width := ScaleX(Width, FromDPI);
|
||||||
|
Height := ScaleY(Height, FromDPI);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Control is TWinControl then
|
||||||
|
begin
|
||||||
|
WinControl := TWinControl(Control);
|
||||||
|
if WinControl.ControlCount = 0 then
|
||||||
|
exit;
|
||||||
|
for i := 0 to WinControl.ControlCount - 1 do
|
||||||
|
ScaleDPI(WinControl.Controls[i], FromDPI);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{$PUSH}{$HINTS OFF}
|
{$PUSH}{$HINTS OFF}
|
||||||
procedure Unused(const A1);
|
procedure Unused(const A1);
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user