tvplanit: Update VpEdFmtLst to scale correctly in the HighDpi mode of Lazarus 1.8.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5879 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-19 23:17:29 +00:00
parent a6f1c69218
commit fdcc9c7e3c
4 changed files with 209 additions and 216 deletions

View File

@ -9,10 +9,6 @@
<Title Value="demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<TextName Value="CompanyName.ProductName.AppName"/>
<TextDesc Value="Your application description."/>
</XPManifest>
</General>
<i18n>
<EnableI18N Value="True"/>

View File

@ -1,5 +1,5 @@
object MainForm: TMainForm
Left = 368
Left = 227
Height = 596
Top = 134
Width = 959
@ -9,7 +9,7 @@ object MainForm: TMainForm
Menu = MainMenu1
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
LCLVersion = '1.7'
LCLVersion = '1.9.0.0'
object Panel1: TPanel
Left = 125
Height = 576
@ -57,7 +57,7 @@ object MainForm: TMainForm
Height = 528
Top = 48
Width = 834
PageIndex = 4
PageIndex = 0
Align = alClient
TabOrder = 1
TabStop = True

View File

@ -1,42 +1,55 @@
object frmPrnFormat: TfrmPrnFormat
Left = 250
Height = 471
Top = 165
Left = 517
Height = 490
Top = 274
Width = 694
HorzScrollBar.Page = 639
VertScrollBar.Page = 479
ActiveControl = lbFormats
Caption = 'Print Format Designer'
ClientHeight = 471
ClientHeight = 490
ClientWidth = 694
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.7'
LCLVersion = '1.9.0.0'
object LblFormats: TLabel
Left = 8
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 15
Top = 5
Top = 8
Width = 46
BorderSpacing.Left = 6
BorderSpacing.Top = 8
Caption = '&Formats:'
FocusControl = lbFormats
ParentColor = False
end
object LblElements: TLabel
Left = 8
AnchorSideLeft.Control = LblFormats
AnchorSideTop.Control = Owner
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 225
Top = 238
Width = 51
BorderSpacing.Top = 8
Caption = 'Ele&ments:'
FocusControl = lbElements
ParentColor = False
end
object btnMoveElementUp: TSpeedButton
Left = 305
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = LblPrintOrder
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = btnMoveElementDn
Left = 336
Height = 22
Top = 375
Top = 409
Width = 23
Anchors = [akLeft, akBottom]
BorderSpacing.Top = 4
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
0400000000000001000000000000000000001000000010000000000000000000
@ -55,10 +68,18 @@ object frmPrnFormat: TfrmPrnFormat
OnClick = btnMoveElementUpClick
end
object btnMoveElementDn: TSpeedButton
Left = 304
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = btnMoveElementUp
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = lbElements
AnchorSideBottom.Side = asrBottom
Left = 336
Height = 22
Top = 403
Top = 435
Width = 23
Anchors = [akLeft, akBottom]
BorderSpacing.Top = 4
Glyph.Data = {
76010000424D7601000000000000760000002800000020000000100000000100
0400000000000001000000000000000000001000000010000000000000000000
@ -77,101 +98,110 @@ object frmPrnFormat: TfrmPrnFormat
OnClick = btnMoveElementDnClick
end
object LblPrintOrder: TLabel
Left = 289
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideBottom.Control = btnMoveElementUp
Left = 318
Height = 15
Top = 355
Top = 390
Width = 58
Alignment = taCenter
Anchors = [akLeft, akBottom]
Caption = 'Print Order'
ParentColor = False
WordWrap = True
end
object btnNewFormat: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = lbFormats
Left = 310
Height = 25
Top = 25
Top = 27
Width = 75
Caption = '&New'
Enabled = False
OnClick = btnNewFormatClick
TabOrder = 1
end
object PrintPreviewPanel: TPanel
Left = 368
Height = 430
Top = 0
Width = 320
Align = alRight
BevelOuter = bvNone
ClientHeight = 430
ClientWidth = 320
TabOrder = 8
object PrintPreview: TVpPrintPreview
Left = 0
Height = 401
Top = 21
Width = 320
CurPage = 0
DrawingStyle = dsFlat
EndDate = 37377.6447728357
StartDate = 37370.6447728357
Parent = PrintPreviewPanel
TabOrder = 0
end
object LblPrintPreview: TLabel
Left = 1
Height = 15
Top = 2
Width = 44
Caption = 'Preview:'
ParentColor = False
end
end
object lbFormats: TListBox
Left = 8
Height = 191
Top = 25
Width = 257
AnchorSideLeft.Control = LblFormats
AnchorSideTop.Control = LblFormats
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnNewFormat
AnchorSideBottom.Control = LblElements
Left = 6
Height = 203
Top = 27
Width = 300
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 4
BorderSpacing.Right = 4
Columns = 1
ItemHeight = 0
OnClick = lbFormatsClick
Options = [lboDrawFocusRect]
Sorted = True
TabOrder = 0
end
object lbElements: TListBox
Left = 8
Height = 179
Top = 246
Width = 257
AnchorSideLeft.Control = LblFormats
AnchorSideTop.Control = LblElements
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = lbFormats
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel
Left = 6
Height = 200
Top = 257
Width = 300
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 4
ItemHeight = 0
OnClick = lbElementsClick
OnDragDrop = lbElementsDragDrop
OnDragOver = lbElementsDragOver
OnMouseDown = lbElementsMouseDown
Options = [lboDrawFocusRect]
TabOrder = 4
end
object btnEditFormat: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = btnNewFormat
AnchorSideTop.Side = asrBottom
Left = 310
Height = 25
Top = 56
Width = 75
BorderSpacing.Top = 4
Caption = '&Edit'
Enabled = False
OnClick = btnEditFormatClick
TabOrder = 2
end
object btnDeleteFormat: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = btnEditFormat
AnchorSideTop.Side = asrBottom
Left = 310
Height = 25
Top = 88
Top = 85
Width = 75
BorderSpacing.Top = 4
Caption = '&Delete'
Enabled = False
OnClick = btnDeleteFormatClick
TabOrder = 3
end
object btnNewElement: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = lbElements
Left = 310
Height = 25
Top = 246
Top = 257
Width = 75
Caption = 'Ne&w'
Enabled = False
@ -179,20 +209,30 @@ object frmPrnFormat: TfrmPrnFormat
TabOrder = 5
end
object btnEditElement: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = btnNewElement
AnchorSideTop.Side = asrBottom
Left = 310
Height = 25
Top = 280
Top = 286
Width = 75
BorderSpacing.Top = 4
Caption = 'E&dit'
Enabled = False
OnClick = btnEditElementClick
TabOrder = 6
end
object btnDeleteElement: TButton
Left = 280
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = btnEditElement
AnchorSideTop.Side = asrBottom
Left = 310
Height = 25
Top = 312
Top = 315
Width = 75
BorderSpacing.Top = 4
Caption = 'De&lete'
Enabled = False
OnClick = btnDeleteElementClick
@ -200,47 +240,77 @@ object frmPrnFormat: TfrmPrnFormat
end
object ButtonPanel: TPanel
Left = 0
Height = 41
Top = 430
Height = 33
Top = 457
Width = 694
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 41
ClientHeight = 33
ClientWidth = 694
TabOrder = 9
TabOrder = 8
object btnLoadFile: TButton
Left = 88
AnchorSideLeft.Control = btnNewFile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnOk
AnchorSideBottom.Control = btnOk
AnchorSideBottom.Side = asrBottom
Left = 81
Height = 25
Top = 8
Width = 75
Top = 4
Width = 82
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 4
Caption = 'L&oad File...'
OnClick = btnLoadFileClick
TabOrder = 1
end
object btnSaveFile: TButton
Left = 168
AnchorSideLeft.Control = btnLoadFile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnOk
AnchorSideBottom.Control = btnOk
AnchorSideBottom.Side = asrBottom
Left = 167
Height = 25
Top = 8
Width = 75
Top = 4
Width = 80
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 4
Caption = '&Save File...'
OnClick = btnSaveFileClick
TabOrder = 2
end
object btnNewFile: TButton
Left = 8
AnchorSideLeft.Control = ButtonPanel
AnchorSideTop.Control = btnOk
AnchorSideBottom.Control = btnOk
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 25
Top = 8
Width = 75
Top = 4
Width = 71
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 6
Caption = 'New &File'
OnClick = btnNewFileClick
TabOrder = 0
end
object btnOk: TButton
Left = 610
AnchorSideRight.Control = ButtonPanel
AnchorSideRight.Side = asrBottom
Left = 646
Height = 25
Top = 8
Width = 75
Top = 4
Width = 42
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 4
BorderSpacing.Right = 6
BorderSpacing.Bottom = 4
Caption = 'OK'
Default = True
OnClick = btnOkClick
@ -249,12 +319,44 @@ object frmPrnFormat: TfrmPrnFormat
end
object Bevel1: TBevel
Left = 688
Height = 430
Height = 457
Top = 0
Width = 6
Align = alRight
Shape = bsSpacer
end
object LblPrintPreview: TLabel
AnchorSideLeft.Control = btnNewFormat
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = LblFormats
Left = 389
Height = 15
Top = 8
Width = 44
BorderSpacing.Left = 4
Caption = 'Preview:'
ParentColor = False
end
object PrintPreview: TVpPrintPreview
AnchorSideLeft.Control = LblPrintPreview
AnchorSideTop.Control = lbFormats
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = lbElements
AnchorSideBottom.Side = asrBottom
Left = 389
Height = 430
Top = 27
Width = 305
CurPage = 0
DrawingStyle = dsFlat
EndDate = 37377.6447728357
StartDate = 37370.6447728357
Anchors = [akTop, akLeft, akRight, akBottom]
Parent = Owner
TabStop = True
TabOrder = 9
end
object OpenDialog1: TOpenDialog
Title = 'Open filter file'
DefaultExt = '.xml'

View File

@ -70,7 +70,6 @@ type
lbElements: TListBox;
lbFormats: TListBox;
OpenDialog1: TOpenDialog;
PrintPreviewPanel: TPanel;
ButtonPanel: TPanel;
PrintPreview: TVpPrintPreview;
SaveDialog1: TSaveDialog;
@ -178,7 +177,7 @@ procedure TfrmPrnFormat.FormShow(Sender: TObject);
begin
PositionControls;
PrintPreview.Parent := PrintPreviewPanel;
PrintPreview.Parent := Self; //PrintPreviewPanel;
if ControlLink.Printer.PrintFormats.Count > 0 then begin
UpdateFormats;
@ -674,141 +673,37 @@ end;
procedure TfrmPrnFormat.PositionControls;
var
w: Integer;
HDist: Integer = 8;
VDist: Integer = 8;
hBtn: Integer;
begin
HDist := ScaleX(HDist, DesignTimeDPI);
VDist := ScaleY(VDist, DesignTimeDPI);
hBtn := ScaleY(btnOK.Height, DesignTimeDPI);
btnNewFormat.AutoSize := true;
btnEditFormat.AutoSize := true;
btnDeleteFormat.AutoSize := true;
btnNewElement.AutoSize := true;
btnEditElement.AutoSize := true;
btnDeleteElement.AutoSize := true;
btnNewFormat.Height := hBtn;
btnEditFormat.Height := hBtn;
btnDeleteFormat.Height := hBtn;
btnNewElement.Height := hBtn;
btnEditElement.Height := hbtn;
btnDeleteElement.Height := hBtn;
btnMoveElementUp.Height := hBtn; btnMoveElementUp.Width := hBtn;
btnMoveElementDn.Height := hBtn; btnMoveElementDn.Width := hBtn;
btnNewFile.Height := hBtn;
btnLoadFile.Height := hBtn;
btnSaveFile.Height := hBtn;
btnOK.Height := hBtn;
w := MaxValue([
btnNewFormat.Width, btnEditFormat.Width, btnDeleteFormat.Width,
btnNewElement.Width, btnEditElement.Width, btnDeleteElement.Width,
LblPrintOrder.Width
]);
LblFormats.Top := VDist div 2;
lbFormats.Top := BottomOf(LblFormats) + VDist div 2;
lbFormats.Height := 5*hBtn + lblPrintOrder.Height + 3*VDist; //ScaleY(lbFormats.Height, DesignTimeDPI);
LblElements.Top := BottomOf(lbFormats) + VDist;
lbElements.Top := Bottomof(LblElements) + VDist div 2;
lbElements.Height := lbFormats.Height;
btnNewFormat.AutoSize := false;
btnEditFormat.AutoSize := false;
btnDeleteFormat.AutoSize := false;
btnNewElement.AutoSize := false;
btnEditElement.AutoSize := false;
btnDeleteElement.AutoSize := false;
btnNewFormat.Top := lbFormats.Top;
btnEditFormat.Top := BottomOf(btnNewFormat) + VDist div 2;
btnDeleteFormat.Top := BottomOf(btnEditFormat) + VDist div 2;
btnNewElement.Top := lbElements.Top;
btnEditElement.Top := BottomOf(btnNewElement) + VDist div 2;
btnDeleteElement.Top := BottomOf(btnEditElement) + VDist div 2;
w := MaxValue([GetButtonWidth(btnNewFile), GetButtonWidth(btnLoadFile), GetButtonWidth(btnSaveFile)]);
btnNewFile.Width := w;
btnLoadFile.Width := w;
btnSaveFile.Width := w;
btnLoadFile.Left := RightOf(btnNewFile) + HDist;
btnSaveFile.Left := RightOf(btnLoadFile) + HDist;
w := MaxValue([GetButtonWidth(btnNewFormat), GetButtonWidth(btnEditFormat), GetButtonWidth(btnDeleteFormat)]);
btnNewFormat.Width := w;
btnEditFormat.Width := w;
btnDeleteFormat.Width := w;
btnNewElement.Width := w;
btnEditElement.Width := w;
btnDeleteElement.Width := w;
w := Max(w, GetLabelWidth(LblPrintOrder));
btnNewFormat.Left := RightOf(lbFormats) + HDist + (w - btnNewFormat.Width) div 2;
btnEditFormat.Left := btnNewFormat.Left;
btnDeleteFormat.Left := btnNewFormat.Left;
btnNewElement.Left := btnNewFormat.Left;
btnEditElement.Left := btnNewFormat.Left;
btnDeleteElement.Left := btnNewFormat.Left;
LblPrintOrder.Left := BtnNewFormat.Left + (BtnNewFormat.Width - GetLabelWidth(LblPrintOrder)) div 2;
btnMoveElementUp.Left := BtnNewFormat.Left + (BtnNewFormat.Width - btnMoveElementUp.Width) div 2;
btnMoveElementDn.Left := btnMoveElementUp.Left;
LblPrintOrder.Top := BottomOf(BtnDeleteElement) + VDist;
btnMoveElementUp.Top := BottomOf(LblPrintOrder) + VDist div 2;
btnMoveElementDn.Top := BottomOf(BtnMoveElementUp) + VDist div 2;
btnOK.Top := VDist;
btnNewFile.Top := VDist;
btnSaveFile.Top := VDist;
btnLoadFile.Top := VDist;
ButtonPanel.ClientHeight := VDist + hBtn + VDist;
ClientHeight := BottomOf(lbElements) + ButtonPanel.Height;
Bevel1.Width := lbFormats.Left;
PrintPreview.Top := lbFormats.Top;
LblPrintPreview.Top := LblFormats.Top;
PrintPreview.Height := PrintPreviewPanel.ClientHeight - PrintPreview.Top;
PrintPreviewPanel.Width := Round(PrintPreview.Height * 210 / 297); // size ratio of A4 paper
PrintPreview.Width := PrintPreviewPanel.ClientWidth;
ClientWidth := Max(RightOf(btnNewFormat), RightOf(LblPrintOrder) + HDist) + PrintPreviewPanel.Width + Bevel1.Width;
PrintPreviewPanel.Left := 0; // make sure that spacer is at right
Position := poDefault;
Position := poScreenCenter;
if LblPrintOrder.Top < BottomOf(btnDeleteElement) + 16 then
Height := Height + BottomOf(btnDeleteElement) + 16 - LblPrintOrder.Top;
end;
{
w := 0;
cnv := TControlCanvas.Create;
try
cnv.Control := btnNewFile;
cnv.Font.Assign(btnNewFile.Font);
w := Max(w, cnv.TextWidth(RSNewFileBtn));
w := Max(w, cnv.TextWidth(RSLoadFileBtn));
w := Max(w, cnv.TextWidth(RSSaveFileBtn));
btnNewFile.Width := w + 16;
btnLoadFile.Left := btnNewFile.Left + btnNewFile.Width + 8;
btnLoadFile.Width := btnNewFile.Width;
btnSaveFile.Left := btnLoadFile.Left + btnLoadFile.Width + 8;
btnSaveFile.Width := btnNewFile.Width;
w := 0;
w := Max(w, cnv.TextWidth(RSNewBtn) + 8);
w := Max(w, cnv.TextWidth(RSEditBtn) + 8);
w := Max(w, cnv.TextWidth(RSDeleteBtn) + 8);
w := Max(w, GetLabelWidth(LblPrintOrder));
BtnNewFormat.Left := lbFormats.Left + lbFormats.Width + 16;
BtnEditFormat.Left := BtnNewFormat.Left;
BtnDeleteFormat.Left := BtnNewFormat.Left;
BtnNewElement.Left := BtnNewFormat.Left;
BtnEditElement.Left := BtnNewFormat.Left;
BtnDeleteElement.Left := BtnNewFormat.Left;
BtnNewFormat.Width := w;
BtnEditFormat.Width := w;
BtnDeleteFormat.Width := w;
BtnNewElement.Width := w;
BtnEditElement.Width := w;
BtnDeleteElement.Width := w;
LblPrintOrder.Left := BtnNewFormat.Left + (BtnNewFormat.Width - GetLabelWidth(LblPrintOrder)) div 2;
btnMoveElementUp.Left := BtnNewFormat.Left + (BtnNewFormat.Width - btnMoveElementUp.Width) div 2;
btnMoveElementDn.Left := btnMoveElementUp.Left;
PrintPreviewPanel.Left := BtnNewFormat.Left + BtnNewFormat.Width + 16;
ClientWidth := PrintPreviewPanel.Left + PrintPreviewPanel.Width + 8;
finally
cnv.Free;
end;
end;
}
procedure TfrmPrnFormat.SetDrawingStyle(const v: TVpDrawingStyle);
begin