You've already forked lazarus-ccr
tvplanit: Improved and more stable layout of print preview related dialogs at higher dpi.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5012 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -91,15 +91,15 @@ type
|
|||||||
procedure PosEditEnter(Sender: TObject);
|
procedure PosEditEnter(Sender: TObject);
|
||||||
procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
|
procedure UpDownClick(Sender: TObject; Button: TUDBtnType);
|
||||||
private
|
private
|
||||||
procedure RepositionControls;
|
procedure PositionControls;
|
||||||
procedure SetCaptions;
|
procedure SetCaptions;
|
||||||
procedure SetMaxSpin(Spin: Integer);
|
procedure SetMaxSpin(Spin: Integer);
|
||||||
protected
|
protected
|
||||||
TheShape : TVpPrintShape;
|
TheShape: TVpPrintShape;
|
||||||
TheCaption : TVpPrintCaption;
|
TheCaption: TVpPrintCaption;
|
||||||
CurEdit : TEdit;
|
CurEdit: TEdit;
|
||||||
|
|
||||||
MaxSpin : Integer;
|
MaxSpin: Integer;
|
||||||
procedure SaveData(AnElement: TVpPrintFormatElementItem);
|
procedure SaveData(AnElement: TVpPrintFormatElementItem);
|
||||||
procedure SetData(AnElement: TVpPrintFormatElementItem);
|
procedure SetData(AnElement: TVpPrintFormatElementItem);
|
||||||
procedure SetItemType(Index: Integer);
|
procedure SetItemType(Index: Integer);
|
||||||
@ -141,6 +141,7 @@ end;
|
|||||||
{=====}
|
{=====}
|
||||||
procedure TfrmEditElement.FormShow(Sender: TObject);
|
procedure TfrmEditElement.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
PositionControls;
|
||||||
edName.SetFocus;
|
edName.SetFocus;
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
@ -286,11 +287,9 @@ begin
|
|||||||
btnShape.Caption := RSShapeBtn;
|
btnShape.Caption := RSShapeBtn;
|
||||||
btnOK.Caption := RSOKBtn;
|
btnOK.Caption := RSOKBtn;
|
||||||
btnCancel.Caption := RSCancelBtn;
|
btnCancel.Caption := RSCancelBtn;
|
||||||
|
|
||||||
RepositionControls;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmEditElement.RepositionControls;
|
procedure TfrmEditElement.PositionControls;
|
||||||
const
|
const
|
||||||
MARGIN = 16;
|
MARGIN = 16;
|
||||||
DELTA = 8;
|
DELTA = 8;
|
||||||
@ -299,10 +298,44 @@ const
|
|||||||
GROUPBOX_CORRECTION = 16;
|
GROUPBOX_CORRECTION = 16;
|
||||||
GROUPBOX_DISTANCE = 16;
|
GROUPBOX_DISTANCE = 16;
|
||||||
var
|
var
|
||||||
i, w, h: Integer;
|
i, w, h, hEd, hBtn: Integer;
|
||||||
cnv: TControlCanvas;
|
cnv: TControlCanvas;
|
||||||
rb: TRadioButton;
|
rb: TRadioButton;
|
||||||
begin
|
begin
|
||||||
|
// Fix edit heights at higher dpi
|
||||||
|
with TEdit.Create(self) do
|
||||||
|
try
|
||||||
|
Parent := self;
|
||||||
|
hEd := Height;
|
||||||
|
finally
|
||||||
|
free;
|
||||||
|
end;
|
||||||
|
edName.Height := hEd;
|
||||||
|
edOffset.Height := hEd;
|
||||||
|
udOffset.Height := hEd;
|
||||||
|
edTop.Height := hEd;
|
||||||
|
edLeft.Height := hEd;
|
||||||
|
edHeight.Height := hEd;
|
||||||
|
edWidth.Height := hEd;
|
||||||
|
udTop.Height := hEd;
|
||||||
|
udLeft.Height := hEd;
|
||||||
|
udHeight.Height := hEd;
|
||||||
|
udWidth.Height := hEd;
|
||||||
|
edCaptionText.Height := hEd;
|
||||||
|
|
||||||
|
// Fix button heights a higher dpi
|
||||||
|
with TButton.Create(self) do
|
||||||
|
try
|
||||||
|
Parent := self;
|
||||||
|
hBtn := Height;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
btnOK.Height := hBtn;
|
||||||
|
btnCancel.Height := hBtn;
|
||||||
|
btnShape.Height := hBtn;
|
||||||
|
btnCaptionFont.Height := hBtn;
|
||||||
|
|
||||||
cnv := TControlCanvas.Create;
|
cnv := TControlCanvas.Create;
|
||||||
try
|
try
|
||||||
cnv.Control := rgItemType;
|
cnv.Control := rgItemType;
|
||||||
|
@ -88,6 +88,7 @@ uses
|
|||||||
|
|
||||||
procedure TfrmEditFormat.FormShow(Sender: TObject);
|
procedure TfrmEditFormat.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
PositionControls;
|
||||||
edName.SetFocus;
|
edName.SetFocus;
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
@ -149,48 +150,70 @@ begin
|
|||||||
rgDayIncrement.Items[3] := RSYears;
|
rgDayIncrement.Items[3] := RSYears;
|
||||||
btnOK.Caption := RSOKBtn;
|
btnOK.Caption := RSOKBtn;
|
||||||
btnCancel.Caption := RSCancelBtn;
|
btnCancel.Caption := RSCancelBtn;
|
||||||
|
|
||||||
PositionControls;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmEditFormat.PositionControls;
|
procedure TfrmEditFormat.PositionControls;
|
||||||
var
|
var
|
||||||
delta: integer = 8;
|
DELTA: integer = 8;
|
||||||
margin: Integer = 16;
|
margin: Integer = 16;
|
||||||
vdist: Integer = 4;
|
vdist: Integer = 4;
|
||||||
var
|
var
|
||||||
w, h: Integer;
|
w, h: Integer;
|
||||||
dummyRB: TRadioButton;
|
dummyRB: TRadioButton;
|
||||||
|
editHeight: Integer;
|
||||||
|
btnHeight: Integer;
|
||||||
begin
|
begin
|
||||||
delta := Round(delta * Screen.PixelsPerInch / DesignTimeDPI);
|
// Fix edit and button heights at higher dpi
|
||||||
margin := Round(margin * Screen.PixelsPerInch / DesignTimeDPI);
|
with TEdit.Create(self) do
|
||||||
vdist := Round(vdist * Screen.PixelsPerInch / DesignTimeDPI);
|
try
|
||||||
|
Parent := self;
|
||||||
|
editHeight := Height;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
with TButton.Create(self) do
|
||||||
|
try
|
||||||
|
Parent := self;
|
||||||
|
btnHeight := Height;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
DELTA := Round(DELTA * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
MARGIN := Round(MARGIN * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
VDIST := Round(VDIST * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
|
||||||
w := MaxValue([GetLabelWidth(LblName), GetLabelWidth(LblDescription), GetLabelWidth(LblIncrement)]);
|
w := MaxValue([GetLabelWidth(LblName), GetLabelWidth(LblDescription), GetLabelWidth(LblIncrement)]);
|
||||||
edName.Left := margin + w + delta;
|
edName.Left := margin + w + DELTA;
|
||||||
edDescription.Left := edName.Left;
|
edDescription.Left := edName.Left;
|
||||||
edDescription.Width := edName.Width;
|
edDescription.Width := edName.Width;
|
||||||
edIncrement.Left := edName.Left;
|
edIncrement.Left := edName.Left;
|
||||||
udIncrement.Left := edIncrement.Left + edIncrement.Width;
|
udIncrement.Left := edIncrement.Left + edIncrement.Width;
|
||||||
LblName.Left := edName.Left - GetLabelWidth(LblName) - delta;
|
LblName.Left := edName.Left - GetLabelWidth(LblName) - DELTA;
|
||||||
LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - delta;
|
LblDescription.Left := edDescription.Left - GetLabelWidth(lblDescription) - DELTA;
|
||||||
lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - delta;
|
lblIncrement.Left := edIncrement.Left - GetLabelWidth(lblIncrement) - DELTA;
|
||||||
|
|
||||||
ClientWidth := MARGIN + w + delta + edName.Width + margin;
|
ClientWidth := MARGIN + w + DELTA + edName.Width + MARGIN;
|
||||||
rgDayIncrement.Width := ClientWidth - 2*margin;
|
rgDayIncrement.Width := ClientWidth - 2*MARGIN;
|
||||||
|
|
||||||
w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel));
|
w := Max(GetButtonWidth(btnOK), GetButtonWidth(btnCancel));
|
||||||
btnOK.Width := w;
|
btnOK.Width := w;
|
||||||
btnCancel.Width := w;
|
btnCancel.Width := w;
|
||||||
btnCancel.Left := RightOf(rgDayIncrement) - btnCancel.Width;
|
btnCancel.Left := RightOf(rgDayIncrement) - btnCancel.Width;
|
||||||
btnOK.Left := btnCancel.Left - delta - btnOK.Width;
|
btnOK.Left := btnCancel.Left - DELTA - btnOK.Width;
|
||||||
|
|
||||||
edDescription.Top := BottomOf(edName) + vDist;
|
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;
|
lblDescription.Top := edDescription.Top + (edDescription.Height - lblDescription.Height) div 2;
|
||||||
edIncrement.Top := BottomOf(edDescription) + vDist;
|
edIncrement.Top := BottomOf(edDescription) + VDIST;
|
||||||
udIncrement.Top := edIncrement.Top;
|
udIncrement.Top := edIncrement.Top;
|
||||||
lblIncrement.top := edIncrement.Top + (edIncrement.Height - lblIncrement.Height) div 2;
|
lblIncrement.top := edIncrement.Top + (edIncrement.Height - lblIncrement.Height) div 2;
|
||||||
rgDayIncrement.Top := BottomOf(edIncrement) + vDist + vDist;
|
rgDayIncrement.Top := BottomOf(edIncrement) + VDISt + VDIST;
|
||||||
|
|
||||||
DummyRB := TRadioButton.Create(self);
|
DummyRB := TRadioButton.Create(self);
|
||||||
DummyRB.Parent := self;
|
DummyRB.Parent := self;
|
||||||
@ -198,10 +221,12 @@ begin
|
|||||||
DummyRB.Free;
|
DummyRB.Free;
|
||||||
|
|
||||||
rgdayIncrement.Height := h + 2*LblName.Height;
|
rgdayIncrement.Height := h + 2*LblName.Height;
|
||||||
btnOK.Top := Bottomof(rgDayIncrement) + vDist;
|
btnOK.Height := btnHeight;
|
||||||
|
btnCancel.Height := btnHeight;
|
||||||
|
btnOK.Top := Bottomof(rgDayIncrement) + VDIST;
|
||||||
btnCancel.Top := btnOK.Top;
|
btnCancel.Top := btnOK.Top;
|
||||||
|
|
||||||
ClientHeight := Bottomof(btnOK) + vDist*2;
|
ClientHeight := Bottomof(btnOK) + VDIST*2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem);
|
procedure TfrmEditFormat.SetData(AFormat: TVpPrintFormatItem);
|
||||||
|
@ -2,12 +2,12 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
Left = 250
|
Left = 250
|
||||||
Height = 480
|
Height = 480
|
||||||
Top = 165
|
Top = 165
|
||||||
Width = 693
|
Width = 694
|
||||||
HorzScrollBar.Page = 639
|
HorzScrollBar.Page = 639
|
||||||
VertScrollBar.Page = 479
|
VertScrollBar.Page = 479
|
||||||
Caption = 'Print Format Designer'
|
Caption = 'Print Format Designer'
|
||||||
ClientHeight = 480
|
ClientHeight = 480
|
||||||
ClientWidth = 693
|
ClientWidth = 694
|
||||||
OnCloseQuery = FormCloseQuery
|
OnCloseQuery = FormCloseQuery
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnShow = FormShow
|
OnShow = FormShow
|
||||||
@ -98,8 +98,8 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
Height = 439
|
Height = 439
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 320
|
Width = 320
|
||||||
Align = alRight
|
BorderSpacing.Top = 4
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 4
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 439
|
ClientHeight = 439
|
||||||
ClientWidth = 320
|
ClientWidth = 320
|
||||||
@ -145,7 +145,7 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
object btnEditFormat: TButton
|
object btnEditFormat: TButton
|
||||||
Left = 280
|
Left = 280
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 61
|
Top = 56
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = '&Edit'
|
Caption = '&Edit'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
@ -155,7 +155,7 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
object btnDeleteFormat: TButton
|
object btnDeleteFormat: TButton
|
||||||
Left = 280
|
Left = 280
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 97
|
Top = 88
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = '&Delete'
|
Caption = '&Delete'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
@ -175,7 +175,7 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
object btnEditElement: TButton
|
object btnEditElement: TButton
|
||||||
Left = 280
|
Left = 280
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 282
|
Top = 280
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'E&dit'
|
Caption = 'E&dit'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
@ -185,7 +185,7 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
object btnDeleteElement: TButton
|
object btnDeleteElement: TButton
|
||||||
Left = 280
|
Left = 280
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 318
|
Top = 312
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'De&lete'
|
Caption = 'De&lete'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
@ -196,11 +196,11 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 41
|
Height = 41
|
||||||
Top = 439
|
Top = 439
|
||||||
Width = 693
|
Width = 694
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 41
|
ClientHeight = 41
|
||||||
ClientWidth = 693
|
ClientWidth = 694
|
||||||
TabOrder = 9
|
TabOrder = 9
|
||||||
object btnLoadFile: TButton
|
object btnLoadFile: TButton
|
||||||
Left = 88
|
Left = 88
|
||||||
@ -230,7 +230,7 @@ object frmPrnFormat: TfrmPrnFormat
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object btnOk: TButton
|
object btnOk: TButton
|
||||||
Left = 609
|
Left = 610
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
|
@ -173,6 +173,8 @@ end;
|
|||||||
{=====}
|
{=====}
|
||||||
procedure TfrmPrnFormat.FormShow(Sender: TObject);
|
procedure TfrmPrnFormat.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
PositionControls;
|
||||||
|
|
||||||
PrintPreview.Parent := PrintPreviewPanel;
|
PrintPreview.Parent := PrintPreviewPanel;
|
||||||
|
|
||||||
if ControlLink.Printer.PrintFormats.Count > 0 then begin
|
if ControlLink.Printer.PrintFormats.Count > 0 then begin
|
||||||
@ -663,28 +665,53 @@ begin
|
|||||||
btnNewFile.Caption := RSNewFileBtn;
|
btnNewFile.Caption := RSNewFileBtn;
|
||||||
btnLoadFile.Caption := RSLoadFileBtn;
|
btnLoadFile.Caption := RSLoadFileBtn;
|
||||||
btnSaveFile.Caption := RSSaveFileBtn;
|
btnSaveFile.Caption := RSSaveFileBtn;
|
||||||
|
|
||||||
PositionControls;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmPrnFormat.PositionControls;
|
procedure TfrmPrnFormat.PositionControls;
|
||||||
var
|
var
|
||||||
w: Integer;
|
w: Integer;
|
||||||
dist: Integer;
|
DIST: Integer = 8;
|
||||||
btndist: Integer;
|
btndist: Integer;
|
||||||
|
hBtn: Integer;
|
||||||
begin
|
begin
|
||||||
dist := round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
DIST := round(DIST * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
btnDist := btnEditFormat.Top - BottomOf(btnNewFormat);
|
btnDist := btnEditFormat.Top - BottomOf(btnNewFormat);
|
||||||
|
|
||||||
|
// Fix button height at higher dpi
|
||||||
|
with TButton.Create(self) do
|
||||||
|
try
|
||||||
|
Parent := self;
|
||||||
|
hBtn := Height;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
btnNewFormat.Height := hBtn;
|
||||||
|
btnEditFormat.Height := hBtn;
|
||||||
|
btnDeleteFormat.Height := hBtn;
|
||||||
|
btnNewElement.Height := hBtn;
|
||||||
|
btnEditElement.Height := hbtn;
|
||||||
|
btnDeleteElement.Height := hBtn;
|
||||||
|
btnNewFile.Height := hBtn;
|
||||||
|
btnLoadFile.Height := hBtn;
|
||||||
|
btnSaveFile.Height := hBtn;
|
||||||
|
btnOK.Height := hBtn;
|
||||||
|
|
||||||
w := MaxValue([GetButtonWidth(btnNewFile), GetButtonWidth(btnLoadFile), GetButtonWidth(btnSaveFile)]);
|
w := MaxValue([GetButtonWidth(btnNewFile), GetButtonWidth(btnLoadFile), GetButtonWidth(btnSaveFile)]);
|
||||||
btnNewFile.Width := w;
|
btnNewFile.Width := w;
|
||||||
btnLoadFile.Width := w;
|
btnLoadFile.Width := w;
|
||||||
btnSaveFile.Width := w;
|
btnSaveFile.Width := w;
|
||||||
btnLoadFile.Left := RightOf(btnNewFile) + dist;
|
btnLoadFile.Left := RightOf(btnNewFile) + DIST;
|
||||||
btnSaveFile.Left := RightOf(btnLoadFile) + dist;
|
btnSaveFile.Left := RightOf(btnLoadFile) + DIST;
|
||||||
|
|
||||||
w := MaxValue([GetButtonWidth(btnNewFormat), GetButtonWidth(btnEditFormat), GetButtonWidth(btnDeleteFormat)]);
|
w := MaxValue([GetButtonWidth(btnNewFormat), GetButtonWidth(btnEditFormat), GetButtonWidth(btnDeleteFormat)]);
|
||||||
btnNewFormat.Left := RightOf(lbFormats) + dist;
|
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) + DIST + (w - btnNewFormat.Width) div 2;
|
||||||
btnEditFormat.Left := btnNewFormat.Left;
|
btnEditFormat.Left := btnNewFormat.Left;
|
||||||
btnDeleteFormat.Left := btnNewFormat.Left;
|
btnDeleteFormat.Left := btnNewFormat.Left;
|
||||||
btnNewElement.Left := btnNewFormat.Left;
|
btnNewElement.Left := btnNewFormat.Left;
|
||||||
@ -698,9 +725,11 @@ begin
|
|||||||
btnMoveElementUp.Top := BottomOf(LblPrintOrder) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
btnMoveElementUp.Top := BottomOf(LblPrintOrder) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
btnMoveElementDn.Top := BottomOf(BtnMoveElementUp) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
btnMoveElementDn.Top := BottomOf(BtnMoveElementUp) + Round(8 * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
|
|
||||||
PrintPreviewPanel.Left := BtnNewFormat.Left + BtnNewFormat.Width + dist;
|
PrintPreviewPanel.Left := Max(RightOf(btnNewFormat), RightOf(LblPrintOrder)) + DIST; //RightOf(lbFormats) + DIST + w + DIST;
|
||||||
|
PrintPreviewPanel.Width := round(PrintPreview.Height * 210 / 297); // size ratio of A4 paper
|
||||||
|
|
||||||
ClientWidth := PrintPreviewPanel.Left + PrintPreviewPanel.Width + 8;
|
ButtonPanel.ClientHeight := BottomOf(btnOK) + btnOK.Top;
|
||||||
|
ClientWidth := PrintPreviewPanel.Left + PrintPreviewPanel.Width + 4; // + DIST;
|
||||||
end;
|
end;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ object frmEditShape: TfrmEditShape
|
|||||||
ClientWidth = 426
|
ClientWidth = 426
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
LCLVersion = '1.7'
|
LCLVersion = '1.7'
|
||||||
@ -63,7 +64,7 @@ object frmEditShape: TfrmEditShape
|
|||||||
end
|
end
|
||||||
object cbBrushStyle: TComboBox
|
object cbBrushStyle: TComboBox
|
||||||
Left = 52
|
Left = 52
|
||||||
Height = 23
|
Height = 21
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 129
|
Width = 129
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
@ -71,6 +72,7 @@ object frmEditShape: TfrmEditShape
|
|||||||
ItemHeight = 15
|
ItemHeight = 15
|
||||||
OnChange = cbBrushStyleChange
|
OnChange = cbBrushStyleChange
|
||||||
OnDrawItem = cbBrushStyleDrawItem
|
OnDrawItem = cbBrushStyleDrawItem
|
||||||
|
Style = csOwnerDrawFixed
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object lblBrushColor: TLabel
|
object lblBrushColor: TLabel
|
||||||
@ -138,13 +140,15 @@ object frmEditShape: TfrmEditShape
|
|||||||
end
|
end
|
||||||
object cbPenStyle: TComboBox
|
object cbPenStyle: TComboBox
|
||||||
Left = 52
|
Left = 52
|
||||||
Height = 23
|
Height = 21
|
||||||
Top = 32
|
Top = 32
|
||||||
Width = 124
|
Width = 124
|
||||||
BorderSpacing.Right = 8
|
BorderSpacing.Right = 8
|
||||||
ItemHeight = 15
|
ItemHeight = 15
|
||||||
OnChange = cbPenStyleChange
|
OnChange = cbPenStyleChange
|
||||||
OnDrawItem = cbPenStyleDrawItem
|
OnDrawItem = cbPenStyleDrawItem
|
||||||
|
ReadOnly = True
|
||||||
|
Style = csOwnerDrawFixed
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object cbPenMode: TComboBox
|
object cbPenMode: TComboBox
|
||||||
|
@ -86,6 +86,7 @@ type
|
|||||||
procedure edPenWidthChange(Sender: TObject);
|
procedure edPenWidthChange(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
|
|
||||||
private
|
private
|
||||||
FShapeButtons: array[TVpShapeType] of TSpeedButton;
|
FShapeButtons: array[TVpShapeType] of TSpeedButton;
|
||||||
@ -233,6 +234,11 @@ begin
|
|||||||
DestroyBitmaps;
|
DestroyBitmaps;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmEditShape.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
PositionControls;
|
||||||
|
end;
|
||||||
|
|
||||||
{=====}
|
{=====}
|
||||||
function TfrmEditShape.Execute(AShape: TVpPrintShape): Boolean;
|
function TfrmEditShape.Execute(AShape: TVpPrintShape): Boolean;
|
||||||
begin
|
begin
|
||||||
@ -298,7 +304,7 @@ end;
|
|||||||
{=====}
|
{=====}
|
||||||
procedure TfrmEditShape.PositionControls;
|
procedure TfrmEditShape.PositionControls;
|
||||||
var
|
var
|
||||||
w, h: Integer;
|
w, hc, hb: Integer;
|
||||||
shape: TVpShapeType;
|
shape: TVpShapeType;
|
||||||
DELTA: Integer = 8;
|
DELTA: Integer = 8;
|
||||||
VDIST: Integer = 4;
|
VDIST: Integer = 4;
|
||||||
@ -307,15 +313,29 @@ begin
|
|||||||
gbPen.AutoSize := false;
|
gbPen.AutoSize := false;
|
||||||
gbBrush.AutoSize := false;
|
gbBrush.AutoSize := false;
|
||||||
|
|
||||||
// This is needed as workaround for the combobox height at higher dpi.
|
// A workaround for the combobox height issue at higher dpi values:
|
||||||
// We design it with Style csDropdown where the height is correct, and then
|
// Create a combobox at runtime, it has the correct height, and apply its
|
||||||
// use the corresponding, correct ItemHeight after switching to csOwnerDrawFixed
|
// ItemHeight to the other comboboxes.
|
||||||
// (which is needed to draw the icons).
|
with TCombobox.Create(self) do
|
||||||
h := cbPenStyle.ItemHeight;
|
try
|
||||||
cbPenStyle.Style := csOwnerDrawFixed;
|
Parent := self;
|
||||||
cbPenStyle.ItemHeight := h+1;
|
hc := ItemHeight;
|
||||||
cbBrushStyle.Style := csOwnerDrawFixed;
|
finally
|
||||||
cbBrushStyle.ItemHeight := h+1;
|
Free;
|
||||||
|
end;
|
||||||
|
cbPenStyle.ItemHeight := hc;
|
||||||
|
cbPenColor.ItemHeight := hc;
|
||||||
|
cbBrushStyle.ItemHeight := hc;
|
||||||
|
cbBrushColor.ItemHeight := hc;
|
||||||
|
|
||||||
|
// Fix button hight at higher dpi.
|
||||||
|
with TButton.Create(self) do
|
||||||
|
try
|
||||||
|
Parent := self;
|
||||||
|
hb := Height;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
DELTA := round(DELTA * Screen.PixelsPerInch / DesignTimeDPI);
|
DELTA := round(DELTA * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
VDIST := round(VDIST * Screen.PixelsPerInch / DesignTimeDPI);
|
VDIST := round(VDIST * Screen.PixelsPerInch / DesignTimeDPI);
|
||||||
@ -375,6 +395,8 @@ begin
|
|||||||
btnOK.Left := btnCancel.Left - DELTA - btnOK.Width;
|
btnOK.Left := btnCancel.Left - DELTA - btnOK.Width;
|
||||||
|
|
||||||
{ Buttons - vert }
|
{ Buttons - vert }
|
||||||
|
btnOK.Height := hb;
|
||||||
|
btnCancel.Height := hb;
|
||||||
btnOK.Top := BottomOf(gbPen) - btnOK.Height;
|
btnOK.Top := BottomOf(gbPen) - btnOK.Height;
|
||||||
btnCancel.Top := btnOK.Top;
|
btnCancel.Top := btnOK.Top;
|
||||||
|
|
||||||
@ -423,8 +445,6 @@ begin
|
|||||||
lblBrushStyle.Caption := RSStyleLbl;
|
lblBrushStyle.Caption := RSStyleLbl;
|
||||||
btnOK.Caption := RSOKBtn;
|
btnOK.Caption := RSOKBtn;
|
||||||
btnCancel.Caption := RSCancelBtn;
|
btnCancel.Caption := RSCancelBtn;
|
||||||
|
|
||||||
PositionControls;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmEditShape.SetData(AShape: TVpPrintShape);
|
procedure TfrmEditShape.SetData(AShape: TVpPrintShape);
|
||||||
|
Reference in New Issue
Block a user