From e9103a1af1d6ef61dca26f89a3ce918ba25ab411 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 20 May 2017 17:00:14 +0000 Subject: [PATCH] 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 --- .../examples/mormot/fulldemo/demo.lpi | 2 +- components/tvplanit/source/vpcanvasutils.pas | 2 +- .../tvplanit/source/vpcontacteditdlg.lfm | 2 +- .../tvplanit/source/vpcontacteditdlg.pas | 1 - components/tvplanit/source/vpedfmt.lfm | 318 +++++++++++------- components/tvplanit/source/vpedfmt.pas | 94 +----- components/tvplanit/source/vpevnteditdlg.lfm | 2 +- components/tvplanit/source/vpevnteditdlg.pas | 8 +- components/tvplanit/source/vpreseditdlg.lfm | 2 +- components/tvplanit/source/vpreseditdlg.pas | 1 - components/tvplanit/source/vpwavdlg.lfm | 2 +- components/tvplanit/source/vpwavdlg.pas | 1 - 12 files changed, 221 insertions(+), 214 deletions(-) diff --git a/components/tvplanit/examples/mormot/fulldemo/demo.lpi b/components/tvplanit/examples/mormot/fulldemo/demo.lpi index 3c791779e..ce3b06d43 100644 --- a/components/tvplanit/examples/mormot/fulldemo/demo.lpi +++ b/components/tvplanit/examples/mormot/fulldemo/demo.lpi @@ -1,7 +1,7 @@ - + diff --git a/components/tvplanit/source/vpcanvasutils.pas b/components/tvplanit/source/vpcanvasutils.pas index 6230f70c5..07462209a 100644 --- a/components/tvplanit/source/vpcanvasutils.pas +++ b/components/tvplanit/source/vpcanvasutils.pas @@ -1597,7 +1597,7 @@ var DC: HDC; begin DC := GetDC(0); - SavedFontHandle := SelectObject(DC, ACanvas.Font.Handle); + SavedFontHandle := SelectObject(DC, ACanvas.Font.Reference.Handle); try GetTextMetrics(DC, Metrics{%H-}); Result := Metrics.tmAveCharWidth; diff --git a/components/tvplanit/source/vpcontacteditdlg.lfm b/components/tvplanit/source/vpcontacteditdlg.lfm index 2eab06ac2..87f0ab70f 100644 --- a/components/tvplanit/source/vpcontacteditdlg.lfm +++ b/components/tvplanit/source/vpcontacteditdlg.lfm @@ -14,7 +14,7 @@ object ContactEditForm: TContactEditForm OnKeyDown = FormKeyDown OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.9.0.0' + LCLVersion = '1.6.4.0' object PageControl: TPageControl Left = 0 Height = 577 diff --git a/components/tvplanit/source/vpcontacteditdlg.pas b/components/tvplanit/source/vpcontacteditdlg.pas index ce308dcfb..31df9adc4 100644 --- a/components/tvplanit/source/vpcontacteditdlg.pas +++ b/components/tvplanit/source/vpcontacteditdlg.pas @@ -505,7 +505,6 @@ procedure TContactEditForm.PositionControls; type TLabelArray = array of TLabel; TComboboxArray = array of TCombobox; - TEditArray = array of TEdit; var Labels: TLabelArray; Comboboxes: TComboboxArray; diff --git a/components/tvplanit/source/vpedfmt.lfm b/components/tvplanit/source/vpedfmt.lfm index c4e10a199..668b85baa 100644 --- a/components/tvplanit/source/vpedfmt.lfm +++ b/components/tvplanit/source/vpedfmt.lfm @@ -1,125 +1,217 @@ object frmEditFormat: TfrmEditFormat - Left = 403 - Height = 193 - Top = 199 - Width = 329 + Left = 583 + Height = 199 + Top = 339 + Width = 347 HorzScrollBar.Page = 328 VertScrollBar.Page = 188 + AutoSize = True BorderStyle = bsDialog Caption = 'Edit Format' - ClientHeight = 193 - ClientWidth = 329 + ClientHeight = 199 + ClientWidth = 347 OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.7' - object LblIncrement: TLabel - Left = 16 - Height = 15 - Top = 72 - Width = 80 - Caption = 'Day Increment:' - FocusControl = edIncrement - ParentColor = False - end - object LblDescription: TLabel - Left = 16 - Height = 15 - Top = 44 - Width = 66 - Caption = 'Description: ' - FocusControl = edDescription - ParentColor = False - end - object LblName: TLabel - Left = 16 - Height = 15 - Top = 16 - Width = 38 - Caption = 'Name: ' - FocusControl = edName - ParentColor = False - end - object btnOk: TButton - Left = 157 - Height = 25 - Top = 160 - Width = 75 - Caption = 'OK' - Default = True - OnClick = btnOkClick - TabOrder = 5 - end - object btnCancel: TButton - Left = 237 - Height = 25 - Top = 160 - Width = 75 - Cancel = True - Caption = 'Cancel' - OnClick = btnCancelClick - TabOrder = 6 - end - object rgDayIncrement: TRadioGroup - Left = 16 - Height = 51 - Top = 101 - Width = 296 - AutoFill = True - Caption = ' Day Increment Unit ' - ChildSizing.LeftRightSpacing = 6 - ChildSizing.TopBottomSpacing = 6 - ChildSizing.EnlargeHorizontal = crsHomogenousChildResize - ChildSizing.EnlargeVertical = crsHomogenousChildResize - ChildSizing.ShrinkHorizontal = crsScaleChilds - ChildSizing.ShrinkVertical = crsScaleChilds - ChildSizing.Layout = cclLeftToRightThenTopToBottom - ChildSizing.ControlsPerLine = 4 - ClientHeight = 31 - ClientWidth = 292 - Columns = 4 - ItemIndex = 0 - Items.Strings = ( - 'Day' - 'Week' - 'Month' - 'Year' - ) - TabOrder = 4 - TabStop = True - end - object edDescription: TEdit - Left = 88 - Height = 23 - Top = 40 - Width = 224 - TabOrder = 1 - end - object edName: TEdit - Left = 64 - Height = 23 - Top = 12 - Width = 248 + LCLVersion = '1.6.4.0' + object Panel1: TPanel + 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 + 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 + Anchors = [akTop, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Right = 8 + Caption = 'Day Increment:' + FocusControl = edIncrement + ParentColor = False + end + object LblDescription: TLabel + AnchorSideTop.Control = edDescription + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = edDescription + Left = 49 + Height = 15 + Top = 35 + Width = 66 + Anchors = [akTop, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Right = 8 + Caption = 'Description: ' + FocusControl = edDescription + ParentColor = False + end + object edDescription: TEdit + AnchorSideLeft.Control = edName + AnchorSideTop.Control = edName + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + Left = 123 + Height = 23 + Top = 31 + Width = 208 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 + TabOrder = 0 + end + object edIncrement: TEdit + AnchorSideLeft.Control = edName + AnchorSideTop.Control = edDescription + AnchorSideTop.Side = asrBottom + Left = 123 + Height = 23 + Top = 62 + Width = 71 + Alignment = taRightJustify + BorderSpacing.Top = 8 + TabOrder = 1 + Text = '0' + end + object udIncrement: TUpDown + AnchorSideLeft.Control = edIncrement + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = edIncrement + AnchorSideTop.Side = asrCenter + AnchorSideRight.Side = asrBottom + Left = 194 + Height = 23 + 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 + object rgDayIncrement: TRadioGroup + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = edIncrement + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 51 + Top = 93 + Width = 331 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + AutoSize = True + BorderSpacing.Top = 8 + Caption = ' Day Increment Unit ' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 4 + ClientHeight = 31 + ClientWidth = 327 + Columns = 4 + ItemIndex = 0 + Items.Strings = ( + 'Day' + 'Week' + 'Month' + 'Year' + ) + TabOrder = 4 + TabStop = True + end end - object udIncrement: TUpDown - Left = 158 - Height = 23 - Top = 68 - Width = 12 - Associate = edIncrement - Max = 365 - Min = 0 - Position = 0 - TabOrder = 3 - Wrap = False - end - object edIncrement: TEdit - Left = 104 - Height = 23 - Top = 68 - Width = 54 - TabOrder = 2 - Text = '0' + object ButtonPanel: TPanel + Left = 0 + Height = 34 + Top = 165 + 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 + end + object btnCancel: TButton + AnchorSideTop.Control = ButtonPanel + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = ButtonPanel + AnchorSideRight.Side = asrBottom + Left = 277 + Height = 25 + Top = 5 + Width = 62 + Anchors = [akTop, akRight] + AutoSize = True + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 4 + Cancel = True + Caption = 'Cancel' + OnClick = btnCancelClick + TabOrder = 1 + end end end diff --git a/components/tvplanit/source/vpedfmt.pas b/components/tvplanit/source/vpedfmt.pas index 2c36f6652..22c36847d 100644 --- a/components/tvplanit/source/vpedfmt.pas +++ b/components/tvplanit/source/vpedfmt.pas @@ -54,6 +54,8 @@ type LblIncrement: TLabel; LblDescription: TLabel; LblName: TLabel; + Panel1: TPanel; + ButtonPanel: TPanel; rgDayIncrement: TRadioGroup; udIncrement: TUpDown; edIncrement: TEdit; @@ -82,7 +84,6 @@ implementation {$ENDIF} uses - Math, VpMisc, VpSR; { TfrmEditLayout } @@ -92,12 +93,12 @@ begin PositionControls; edName.SetFocus; end; -{=====} + procedure TfrmEditFormat.btnCancelClick(Sender: TObject); begin ModalResult := mrCancel; end; -{=====} + procedure TfrmEditFormat.btnOkClick(Sender: TObject); begin if Validate then @@ -108,7 +109,7 @@ begin Exit; end; end; -{=====} + function TfrmEditFormat.Execute(AFormat: TVpPrintFormatItem) : Boolean; begin SetData(AFormat); @@ -122,7 +123,6 @@ begin SetCaptions; end; -{=====} procedure TfrmEditFormat.SaveData(AFormat: TVpPrintFormatItem); var EnumVal : Integer; @@ -154,84 +154,9 @@ begin end; procedure TfrmEditFormat.PositionControls; -var - DELTA: integer = 8; - margin: Integer = 8; - vdist: Integer = 4; -var - w, h: Integer; - dummyRB: TRadioButton; - editHeight: Integer; - btnHeight: Integer; begin - // Fix edit and button heights at higher dpi - with TEdit.Create(self) do - 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; + AlignOKCancel(btnOK, btnCancel, ButtonPanel); + udIncrement.Width := udIncrement.Height div 2 + 1; end; procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem); @@ -249,14 +174,11 @@ begin else rgDayIncrement.ItemIndex := 0; end; -{=====} + function TfrmEditFormat.Validate : Boolean; begin Result := edName.Text <> ''; end; -{=====} - - end. diff --git a/components/tvplanit/source/vpevnteditdlg.lfm b/components/tvplanit/source/vpevnteditdlg.lfm index fe4dd89a1..917347856 100644 --- a/components/tvplanit/source/vpevnteditdlg.lfm +++ b/components/tvplanit/source/vpevnteditdlg.lfm @@ -11,7 +11,7 @@ object DlgEventEdit: TDlgEventEdit OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.9.0.0' + LCLVersion = '1.6.4.0' object ButtonPanel: TPanel Left = 0 Height = 37 diff --git a/components/tvplanit/source/vpevnteditdlg.pas b/components/tvplanit/source/vpevnteditdlg.pas index 6bf4a3f11..de4bcf0c1 100644 --- a/components/tvplanit/source/vpevnteditdlg.pas +++ b/components/tvplanit/source/vpevnteditdlg.pas @@ -180,7 +180,7 @@ type implementation uses - Math, DateUtils, + DateUtils, VpSR, VpMisc, VpWavDlg; {$IFDEF LCL} @@ -622,12 +622,8 @@ end; {=====} procedure TDlgEventEdit.PositionControls; -const - DELTA = 8; - VDELTA = 8; - VDIST = 5; var - w, h: Integer; + w: Integer; cnv: TControlCanvas; editHeight: Integer; begin diff --git a/components/tvplanit/source/vpreseditdlg.lfm b/components/tvplanit/source/vpreseditdlg.lfm index 8cb72d2b1..1ef45982c 100644 --- a/components/tvplanit/source/vpreseditdlg.lfm +++ b/components/tvplanit/source/vpreseditdlg.lfm @@ -12,7 +12,7 @@ object ResEditForm: TResEditForm Constraints.MinWidth = 400 OnCreate = FormCreate OnShow = FormShow - LCLVersion = '1.9.0.0' + LCLVersion = '1.6.4.0' object pnlBottom: TPanel Left = 0 Height = 33 diff --git a/components/tvplanit/source/vpreseditdlg.pas b/components/tvplanit/source/vpreseditdlg.pas index 6b9255dce..2423de899 100644 --- a/components/tvplanit/source/vpreseditdlg.pas +++ b/components/tvplanit/source/vpreseditdlg.pas @@ -100,7 +100,6 @@ implementation {$ENDIF} uses - Math, vpSR, vpMisc; function ExecuteResourceDlg(Resource: TVpResource): Boolean; diff --git a/components/tvplanit/source/vpwavdlg.lfm b/components/tvplanit/source/vpwavdlg.lfm index fbf8a68e5..058cdb3fe 100644 --- a/components/tvplanit/source/vpwavdlg.lfm +++ b/components/tvplanit/source/vpwavdlg.lfm @@ -12,7 +12,7 @@ object FrmSoundDialog: TFrmSoundDialog OnCreate = FormCreate OnShow = FormShow Position = poScreenCenter - LCLVersion = '1.9.0.0' + LCLVersion = '1.6.4.0' object PageControl1: TPageControl Left = 0 Height = 474 diff --git a/components/tvplanit/source/vpwavdlg.pas b/components/tvplanit/source/vpwavdlg.pas index e921d2b69..f4c092674 100644 --- a/components/tvplanit/source/vpwavdlg.pas +++ b/components/tvplanit/source/vpwavdlg.pas @@ -88,7 +88,6 @@ type implementation uses - Math, VpSR, VpMisc; {$IFDEF LCL}