tvplanit: Update VpEdFmt to scale correctly in the HighDpi mode of Lazarus 1.8. Less hints.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5884 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-20 17:00:14 +00:00
parent 70be970745
commit e9103a1af1
12 changed files with 221 additions and 214 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="9"/> <Version Value="10"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>

View File

@ -1597,7 +1597,7 @@ var
DC: HDC; DC: HDC;
begin begin
DC := GetDC(0); DC := GetDC(0);
SavedFontHandle := SelectObject(DC, ACanvas.Font.Handle); SavedFontHandle := SelectObject(DC, ACanvas.Font.Reference.Handle);
try try
GetTextMetrics(DC, Metrics{%H-}); GetTextMetrics(DC, Metrics{%H-});
Result := Metrics.tmAveCharWidth; Result := Metrics.tmAveCharWidth;

View File

@ -14,7 +14,7 @@ object ContactEditForm: TContactEditForm
OnKeyDown = FormKeyDown OnKeyDown = FormKeyDown
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object PageControl: TPageControl object PageControl: TPageControl
Left = 0 Left = 0
Height = 577 Height = 577

View File

@ -505,7 +505,6 @@ procedure TContactEditForm.PositionControls;
type type
TLabelArray = array of TLabel; TLabelArray = array of TLabel;
TComboboxArray = array of TCombobox; TComboboxArray = array of TCombobox;
TEditArray = array of TEdit;
var var
Labels: TLabelArray; Labels: TLabelArray;
Comboboxes: TComboboxArray; Comboboxes: TComboboxArray;

View File

@ -1,71 +1,147 @@
object frmEditFormat: TfrmEditFormat object frmEditFormat: TfrmEditFormat
Left = 403 Left = 583
Height = 193 Height = 199
Top = 199 Top = 339
Width = 329 Width = 347
HorzScrollBar.Page = 328 HorzScrollBar.Page = 328
VertScrollBar.Page = 188 VertScrollBar.Page = 188
AutoSize = True
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Edit Format' Caption = 'Edit Format'
ClientHeight = 193 ClientHeight = 199
ClientWidth = 329 ClientWidth = 347
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.7' LCLVersion = '1.6.4.0'
object LblIncrement: TLabel object Panel1: TPanel
Left = 16 Left = 8
Height = 157
Top = 8
Width = 331
Align = alClient
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BevelOuter = bvNone
ClientHeight = 157
ClientWidth = 331
TabOrder = 0
object LblName: TLabel
AnchorSideTop.Control = edName
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edName
Left = 77
Height = 15 Height = 15
Top = 72 Top = 4
Width = 38
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Name: '
FocusControl = edName
ParentColor = False
end
object LblIncrement: TLabel
AnchorSideTop.Control = edIncrement
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edIncrement
Left = 35
Height = 15
Top = 66
Width = 80 Width = 80
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Day Increment:' Caption = 'Day Increment:'
FocusControl = edIncrement FocusControl = edIncrement
ParentColor = False ParentColor = False
end end
object LblDescription: TLabel object LblDescription: TLabel
Left = 16 AnchorSideTop.Control = edDescription
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edDescription
Left = 49
Height = 15 Height = 15
Top = 44 Top = 35
Width = 66 Width = 66
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Description: ' Caption = 'Description: '
FocusControl = edDescription FocusControl = edDescription
ParentColor = False ParentColor = False
end end
object LblName: TLabel object edDescription: TEdit
Left = 16 AnchorSideLeft.Control = edName
Height = 15 AnchorSideTop.Control = edName
Top = 16 AnchorSideTop.Side = asrBottom
Width = 38 AnchorSideRight.Control = Panel1
Caption = 'Name: ' AnchorSideRight.Side = asrBottom
FocusControl = edName Left = 123
ParentColor = False Height = 23
Top = 31
Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 0
end end
object btnOk: TButton object edIncrement: TEdit
Left = 157 AnchorSideLeft.Control = edName
Height = 25 AnchorSideTop.Control = edDescription
Top = 160 AnchorSideTop.Side = asrBottom
Width = 75 Left = 123
Caption = 'OK' Height = 23
Default = True Top = 62
OnClick = btnOkClick Width = 71
TabOrder = 5 Alignment = taRightJustify
BorderSpacing.Top = 8
TabOrder = 1
Text = '0'
end end
object btnCancel: TButton object udIncrement: TUpDown
Left = 237 AnchorSideLeft.Control = edIncrement
Height = 25 AnchorSideLeft.Side = asrBottom
Top = 160 AnchorSideTop.Control = edIncrement
Width = 75 AnchorSideTop.Side = asrCenter
Cancel = True AnchorSideRight.Side = asrBottom
Caption = 'Cancel' Left = 194
OnClick = btnCancelClick Height = 23
TabOrder = 6 Top = 62
Width = 12
Associate = edIncrement
Max = 365
Min = 0
Position = 0
TabOrder = 2
Wrap = False
end
object edName: TEdit
AnchorSideTop.Control = Panel1
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 123
Height = 23
Top = 0
Width = 208
Anchors = [akTop, akRight]
TabOrder = 3
end end
object rgDayIncrement: TRadioGroup object rgDayIncrement: TRadioGroup
Left = 16 AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = edIncrement
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 0
Height = 51 Height = 51
Top = 101 Top = 93
Width = 296 Width = 331
Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
AutoSize = True
BorderSpacing.Top = 8
Caption = ' Day Increment Unit ' Caption = ' Day Increment Unit '
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
@ -76,7 +152,7 @@ object frmEditFormat: TfrmEditFormat
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 4 ChildSizing.ControlsPerLine = 4
ClientHeight = 31 ClientHeight = 31
ClientWidth = 292 ClientWidth = 327
Columns = 4 Columns = 4
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
@ -88,38 +164,54 @@ object frmEditFormat: TfrmEditFormat
TabOrder = 4 TabOrder = 4
TabStop = True TabStop = True
end end
object edDescription: TEdit
Left = 88
Height = 23
Top = 40
Width = 224
TabOrder = 1
end end
object edName: TEdit object ButtonPanel: TPanel
Left = 64 Left = 0
Height = 23 Height = 34
Top = 12 Top = 165
Width = 248 Width = 347
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 34
ClientWidth = 347
TabOrder = 1
object btnOk: TButton
AnchorSideTop.Control = ButtonPanel
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnCancel
Left = 231
Height = 25
Top = 5
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Caption = 'OK'
Default = True
OnClick = btnOkClick
TabOrder = 0 TabOrder = 0
end end
object udIncrement: TUpDown object btnCancel: TButton
Left = 158 AnchorSideTop.Control = ButtonPanel
Height = 23 AnchorSideTop.Side = asrCenter
Top = 68 AnchorSideRight.Control = ButtonPanel
Width = 12 AnchorSideRight.Side = asrBottom
Associate = edIncrement Left = 277
Max = 365 Height = 25
Min = 0 Top = 5
Position = 0 Width = 62
TabOrder = 3 Anchors = [akTop, akRight]
Wrap = False AutoSize = True
BorderSpacing.Top = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 4
Cancel = True
Caption = 'Cancel'
OnClick = btnCancelClick
TabOrder = 1
end end
object edIncrement: TEdit
Left = 104
Height = 23
Top = 68
Width = 54
TabOrder = 2
Text = '0'
end end
end end

View File

@ -54,6 +54,8 @@ type
LblIncrement: TLabel; LblIncrement: TLabel;
LblDescription: TLabel; LblDescription: TLabel;
LblName: TLabel; LblName: TLabel;
Panel1: TPanel;
ButtonPanel: TPanel;
rgDayIncrement: TRadioGroup; rgDayIncrement: TRadioGroup;
udIncrement: TUpDown; udIncrement: TUpDown;
edIncrement: TEdit; edIncrement: TEdit;
@ -82,7 +84,6 @@ implementation
{$ENDIF} {$ENDIF}
uses uses
Math,
VpMisc, VpSR; VpMisc, VpSR;
{ TfrmEditLayout } { TfrmEditLayout }
@ -92,12 +93,12 @@ begin
PositionControls; PositionControls;
edName.SetFocus; edName.SetFocus;
end; end;
{=====}
procedure TfrmEditFormat.btnCancelClick(Sender: TObject); procedure TfrmEditFormat.btnCancelClick(Sender: TObject);
begin begin
ModalResult := mrCancel; ModalResult := mrCancel;
end; end;
{=====}
procedure TfrmEditFormat.btnOkClick(Sender: TObject); procedure TfrmEditFormat.btnOkClick(Sender: TObject);
begin begin
if Validate then if Validate then
@ -108,7 +109,7 @@ begin
Exit; Exit;
end; end;
end; end;
{=====}
function TfrmEditFormat.Execute(AFormat: TVpPrintFormatItem) : Boolean; function TfrmEditFormat.Execute(AFormat: TVpPrintFormatItem) : Boolean;
begin begin
SetData(AFormat); SetData(AFormat);
@ -122,7 +123,6 @@ begin
SetCaptions; SetCaptions;
end; end;
{=====}
procedure TfrmEditFormat.SaveData(AFormat: TVpPrintFormatItem); procedure TfrmEditFormat.SaveData(AFormat: TVpPrintFormatItem);
var var
EnumVal : Integer; EnumVal : Integer;
@ -154,84 +154,9 @@ begin
end; end;
procedure TfrmEditFormat.PositionControls; procedure TfrmEditFormat.PositionControls;
var
DELTA: integer = 8;
margin: Integer = 8;
vdist: Integer = 4;
var
w, h: Integer;
dummyRB: TRadioButton;
editHeight: Integer;
btnHeight: Integer;
begin begin
// Fix edit and button heights at higher dpi AlignOKCancel(btnOK, btnCancel, ButtonPanel);
with TEdit.Create(self) do udIncrement.Width := udIncrement.Height div 2 + 1;
try
Parent := self;
editHeight := Height;
finally
Free;
end;
btnHeight := ScaleY(btnOK.Height, DesignTimeDPI);
DELTA := ScaleX(DELTA, DesignTimeDPI);
MARGIN := ScaleX(MARGIN, DesignTimeDPI);
VDIST := ScaleY(VDIST, DesignTimeDPI);
w := MaxValue([GetLabelWidth(LblName), GetLabelWidth(LblDescription), GetLabelWidth(LblIncrement)]);
edName.Left := margin + w + DELTA;
edDescription.Left := edName.Left;
edDescription.Width := edName.Width;
edIncrement.Left := edName.Left;
udIncrement.Left := edIncrement.Left + edIncrement.Width;
LblName.Left := edName.Left - GetLabelWidth(LblName) - DELTA;
LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - DELTA;
lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - DELTA;
ClientWidth := MARGIN + w + DELTA + edName.Width + MARGIN;
rgDayIncrement.Left := MARGIN;
rgDayIncrement.Width := ClientWidth - 2*MARGIN;
w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel));
btnOK.Width := w;
btnCancel.Width := w;
{$IFDEF MSWINDOWS}
btnCancel.Left := RightOf(rgDayIncrement) - btnCancel.Width;
btnOK.Left := btnCancel.Left - DELTA - btnOK.Width;
btnOK.TabOrder := rgDayIncrement.TabOrder + 1;
btnCancel.TabOrder := btnOK.TabOrder + 1;
{$ELSE}
btnOK.Left := RightOf(rgDayIncrement) - btnOK.Width;
btnCancel.Left := btnOK.Left - DELTA - btnCancel.Width;
btnCancel.TabOrder := rgDayIncrement.TabOrder + 1;
btnOK.TabOrder := btnCancel.TabOrder + 1;
{$ENDIF}
edName.Height := editHeight;
edDescription.Height := editHeight;
edIncrement.Height := editHeight;
udIncrement.Height := editHeight;
edDescription.Top := BottomOf(edName) + VDIST;
lblDescription.Top := edDescription.Top + (edDescription.Height - lblDescription.Height) div 2;
edIncrement.Top := BottomOf(edDescription) + VDIST;
udIncrement.Top := edIncrement.Top;
lblIncrement.top := edIncrement.Top + (edIncrement.Height - lblIncrement.Height) div 2;
rgDayIncrement.Top := BottomOf(edIncrement) + VDISt + VDIST;
DummyRB := TRadioButton.Create(self);
DummyRB.Parent := self;
h := DummyRB.Height;
DummyRB.Free;
rgdayIncrement.Height := h + 2*LblName.Height;
btnOK.Height := btnHeight;
btnCancel.Height := btnHeight;
btnOK.Top := Bottomof(rgDayIncrement) + MARGIN;
btnCancel.Top := btnOK.Top;
ClientHeight := Bottomof(btnOK) + VDIST*2;
end; end;
procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem); procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem);
@ -249,14 +174,11 @@ begin
else else
rgDayIncrement.ItemIndex := 0; rgDayIncrement.ItemIndex := 0;
end; end;
{=====}
function TfrmEditFormat.Validate : Boolean; function TfrmEditFormat.Validate : Boolean;
begin begin
Result := edName.Text <> ''; Result := edName.Text <> '';
end; end;
{=====}
end. end.

View File

@ -11,7 +11,7 @@ object DlgEventEdit: TDlgEventEdit
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object ButtonPanel: TPanel object ButtonPanel: TPanel
Left = 0 Left = 0
Height = 37 Height = 37

View File

@ -180,7 +180,7 @@ type
implementation implementation
uses uses
Math, DateUtils, DateUtils,
VpSR, VpMisc, VpWavDlg; VpSR, VpMisc, VpWavDlg;
{$IFDEF LCL} {$IFDEF LCL}
@ -622,12 +622,8 @@ end;
{=====} {=====}
procedure TDlgEventEdit.PositionControls; procedure TDlgEventEdit.PositionControls;
const
DELTA = 8;
VDELTA = 8;
VDIST = 5;
var var
w, h: Integer; w: Integer;
cnv: TControlCanvas; cnv: TControlCanvas;
editHeight: Integer; editHeight: Integer;
begin begin

View File

@ -12,7 +12,7 @@ object ResEditForm: TResEditForm
Constraints.MinWidth = 400 Constraints.MinWidth = 400
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object pnlBottom: TPanel object pnlBottom: TPanel
Left = 0 Left = 0
Height = 33 Height = 33

View File

@ -100,7 +100,6 @@ implementation
{$ENDIF} {$ENDIF}
uses uses
Math,
vpSR, vpMisc; vpSR, vpMisc;
function ExecuteResourceDlg(Resource: TVpResource): Boolean; function ExecuteResourceDlg(Resource: TVpResource): Boolean;

View File

@ -12,7 +12,7 @@ object FrmSoundDialog: TFrmSoundDialog
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 0 Left = 0
Height = 474 Height = 474

View File

@ -88,7 +88,6 @@ type
implementation implementation
uses uses
Math,
VpSR, VpMisc; VpSR, VpMisc;
{$IFDEF LCL} {$IFDEF LCL}