tvplanit: Update TTaskEditForm to scale correctly in the HiDPI mode of Lazarus 1.8

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5869 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-19 10:40:32 +00:00
parent 89134ba0c5
commit 35dece7bf0
3 changed files with 137 additions and 77 deletions

View File

@ -12,6 +12,11 @@
<OtherUnitFiles Value="source"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\run"/>
</SearchPaths>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions>
<Description Value="Lazarus Port of Turbo Power's VisualPlanIt components based on version 1.0.3.
(Runtime package)"/>

View File

@ -1,58 +1,72 @@
object TaskEditForm: TTaskEditForm
Left = 284
Height = 411
Top = 253
Height = 433
Top = 231
Width = 547
HorzScrollBar.Page = 545
VertScrollBar.Page = 339
Caption = 'TaskEditForm'
ClientHeight = 411
ClientHeight = 433
ClientWidth = 547
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.7'
LCLVersion = '1.9.0.0'
object ButtonPanel: TPanel
Left = 0
Height = 37
Top = 374
Height = 33
Top = 400
Width = 547
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 37
ClientHeight = 33
ClientWidth = 547
TabOrder = 1
object ResourceNameLbl: TLabel
Left = 6
Height = 16
AnchorSideLeft.Control = ButtonPanel
AnchorSideTop.Control = ButtonPanel
AnchorSideTop.Side = asrCenter
Left = 4
Height = 17
Top = 8
Width = 100
Width = 108
BorderSpacing.Left = 4
Caption = 'Resource Name'
Font.CharSet = ANSI_CHARSET
Font.Color = clMaroon
Font.Height = -13
Font.Height = -14
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object OKBtn: TButton
Left = 388
AnchorSideTop.Control = CancelBtn
AnchorSideBottom.Control = CancelBtn
AnchorSideBottom.Side = asrBottom
Left = 376
Height = 25
Top = 6
Width = 75
Anchors = [akTop, akRight]
Top = 4
Width = 86
Anchors = [akTop, akRight, akBottom]
BorderSpacing.Right = 4
Caption = 'OK'
Default = True
OnClick = OKBtnClick
TabOrder = 0
end
object CancelBtn: TButton
Left = 466
AnchorSideRight.Side = asrBottom
Left = 479
Height = 25
Top = 6
Width = 75
Top = 4
Width = 62
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Cancel = True
Caption = 'Cancel'
OnClick = CancelBtnClick
@ -61,7 +75,7 @@ object TaskEditForm: TTaskEditForm
end
object PageControl1: TPageControl
Left = 0
Height = 374
Height = 400
Top = 0
Width = 547
TabStop = False
@ -71,47 +85,60 @@ object TaskEditForm: TTaskEditForm
TabOrder = 0
object tabTask: TTabSheet
Caption = 'Task'
ClientHeight = 346
ClientHeight = 372
ClientWidth = 539
object DueDateLbl: TLabel
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrCenter
Left = 52
Height = 15
Top = 78
Top = 68
Width = 50
Caption = 'Due date:'
FocusControl = DueDateEdit
ParentColor = False
end
object LblCreatedOn: TLabel
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrBottom
Left = 52
Height = 15
Top = 103
Top = 91
Width = 61
BorderSpacing.Top = 4
Caption = 'Created on:'
ParentColor = False
end
object LblCompletedOn: TLabel
AnchorSideTop.Control = LblCreatedOn
Left = 333
Height = 15
Top = 103
Top = 91
Width = 79
BorderSpacing.Right = 4
Caption = 'Completed on:'
ParentColor = False
end
object Bevel1: TBevel
AnchorSideTop.Control = CbCategory
AnchorSideTop.Side = asrBottom
Left = 4
Height = 2
Top = 64
Top = 58
Width = 529
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
Shape = bsTopLine
end
object imgCalendar: TImage
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 8
Height = 32
Top = 72
Top = 64
Width = 32
AutoSize = True
BorderSpacing.Top = 4
Picture.Data = {
07544269746D6170360C0000424D360C00000000000036000000280000002000
0000200000000100180000000000000C00000000000000000000000000000000
@ -216,11 +243,14 @@ object TaskEditForm: TTaskEditForm
Transparent = True
end
object imgCompleted: TImage
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 290
Height = 32
Top = 72
Top = 64
Width = 32
AutoSize = True
BorderSpacing.Top = 4
Picture.Data = {
07544269746D617076020000424D760200000000000076000000280000002000
0000200000000100040000000000000200000000000000000000100000001000
@ -247,30 +277,52 @@ object TaskEditForm: TTaskEditForm
Transparent = True
end
object DescriptionEdit: TEdit
AnchorSideLeft.Control = tabTask
AnchorSideTop.Control = tabTask
AnchorSideRight.Control = tabTask
AnchorSideRight.Side = asrBottom
Left = 4
Height = 23
Top = 5
Width = 529
Top = 4
Width = 531
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 4
BorderSpacing.Top = 4
BorderSpacing.Right = 4
MaxLength = 255
OnChange = OnChange
TabOrder = 0
Text = 'DescriptionEdit'
end
object CbComplete: TCheckBox
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrCenter
Left = 333
Height = 19
Top = 77
Top = 66
Width = 72
BorderSpacing.Right = 4
Caption = 'Complete'
TabOrder = 2
end
object DetailsMemo: TMemo
AnchorSideLeft.Control = tabTask
AnchorSideTop.Control = LblCreatedOn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = tabTask
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = tabTask
AnchorSideBottom.Side = asrBottom
Left = 4
Height = 209
Top = 128
Width = 529
Height = 258
Top = 110
Width = 531
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4
BorderSpacing.Top = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
Constraints.MinHeight = 200
Lines.Strings = (
'DetailsMemo'
)
@ -280,13 +332,16 @@ object TaskEditForm: TTaskEditForm
TabOrder = 3
end
object DueDateEdit: TDateEdit
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 128
Height = 23
Top = 75
Top = 64
Width = 120
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
DateOrder = doNone
ButtonWidth = 23
BorderSpacing.Top = 4
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
@ -329,19 +384,24 @@ object TaskEditForm: TTaskEditForm
Text = 'DueDateEdit'
end
object LblCategory: TLabel
AnchorSideTop.Control = CbCategory
AnchorSideTop.Side = asrCenter
Left = 62
Height = 15
Top = 36
Top = 35
Width = 51
Caption = 'Category:'
FocusControl = CbCategory
ParentColor = False
end
object CbCategory: TComboBox
AnchorSideTop.Control = DescriptionEdit
AnchorSideTop.Side = asrBottom
Left = 128
Height = 23
Top = 32
Top = 31
Width = 120
BorderSpacing.Top = 4
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
@ -356,19 +416,25 @@ object TaskEditForm: TTaskEditForm
Text = 'Business'
end
object LblPriority: TLabel
AnchorSideTop.Control = CbPriority
AnchorSideTop.Side = asrCenter
Left = 281
Height = 15
Top = 36
Top = 35
Width = 41
Caption = 'Priority:'
FocusControl = CbPriority
ParentColor = False
end
object CbPriority: TComboBox
AnchorSideTop.Control = DescriptionEdit
AnchorSideTop.Side = asrBottom
Left = 333
Height = 23
Top = 32
Top = 31
Width = 120
BorderSpacing.Top = 4
BorderSpacing.Right = 4
ItemHeight = 15
ItemIndex = 1
Items.Strings = (

View File

@ -71,16 +71,17 @@ type
Bevel1: TBevel;
imgCalendar: TImage;
imgCompleted: TImage;
procedure CancelBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure OnChange(Sender: TObject);
procedure OKBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
FReturnCode: TVpEditorReturnCode;
FTask: TVpTask;
FResource: TVpResource;
FBtnHeight: Integer;
// FBtnHeight: Integer;
// FBtnWidth: Integer;
FEditHeight: Integer;
procedure PositionControls;
procedure SetCaptions;
@ -126,7 +127,7 @@ uses
procedure TTaskEditForm.FormCreate(Sender: TObject);
begin
FReturnCode := rtAbandon;
FBtnHeight := ScaleY(OKBtn.Height, DesignTimeDPI);
// FBtnHeight := ScaleY(OKBtn.Height, DesignTimeDPI);
FEditHeight := ScaleY(DueDateEdit.Height, DesignTimeDPI);
end;
@ -174,10 +175,7 @@ begin
DetailsMemo.Text := Task.Details;
CbComplete.Checked := Task.Complete;
if Task.CompletedOn <> 0 then
LblCompletedOn.Caption := RSCompletedOn + ' ' + FormatDateTime('ddddd', Task.CompletedOn)
// 'ddddd' = DefaultFormatSettings.ShortDateFormat
else
LblCompletedOn.Visible := False;
LblCompletedOn.Caption := RSCompletedOn + ' ' + FormatDateTime('ddddd', Task.CompletedOn);
LblCompletedOn.Visible := CbComplete.Checked;
LblCreatedOn.Caption := RSCreatedOn + ' ' + FormatDateTime('ddddd', Task.CreatedOn);
CbPriority.ItemIndex := Task.Priority + 1;
@ -193,24 +191,29 @@ var
HDist: Integer = 8; // Horizontal distance between controls:
w: Integer;
cnv: TControlCanvas;
i: Integer;
begin
VBevelDist := ScaleY(VBevelDist, DesignTimeDPI);
VDist := ScaleY(VDist, DesignTimeDPI);
HDist := ScaleX(HDist, DesignTimeDPI);
for i := 0 to ComponentCount-1 do
if Components[i] is TControl then
with TControl(Components[i]) do begin
if BorderSpacing.Left <> 0 then BorderSpacing.Left := HDist;
if BorderSpacing.Right <> 0 then BorderSpacing.Right := HDist;
if BorderSpacing.Top <> 0 then BorderSpacing.Top := VDist;
if BorderSpacing.Bottom <> 0 then BorderSpacing.Bottom := VDist;
end;
DescriptionEdit.Height := FEditHeight;
DueDateEdit.Height := FEditHeight;
DueDateEdit.ButtonWidth := FEditHeight;
CbCategory.Height := FEditHeight;
CbPriority.Height := FEditHeight;
OKBtn.Height := FBtnHeight;
OKBtn.Top := VDist;
CancelBtn.Height := OKBtn.Height;
CancelBtn.Top := OKBtn.Top;
ButtonPanel.Height := OKBtn.Height + VDIST*2;
OKBtn.Width := CancelBtn.Width;
ResourceNameLbl.Font.Size := ScaleY(ResourceNameLbl.Font.Size, DesignTimeDPI);
ResourceNameLbl.Top := OKBtn.Top + (OKBtn.Height - ScaleY(ResourceNameLbl.Height, DesignTimeDPI)) div 2;
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + HDist;
cnv := TControlCanvas.Create;
@ -237,7 +240,9 @@ begin
cnv.Free;
end;
w := Max(GetlabelWidth(LblCompletedOn), w);
ClientWidth := ClientWidth - tabTask.ClientWidth + CbComplete.Left + w + HDist*2;
ClientWidth := ClientWidth - tabTask.ClientWidth +
Max(CbComplete.Left + w, RightOf(CbPriority)) +
HDist*2;
end;
CbCategory.Left := DueDateEdit.Left;
@ -249,38 +254,22 @@ begin
CbPriority.Left := CbComplete.Left;
LblPriority.Left := CbPriority.Left - HDist - GetLabelWidth(LblPriority);
OKBtn.Width := Max(GetButtonWidth(OKBtn), GetButtonWidth(CancelBtn));
CancelBtn.Width := OKBtn.Width;
{$IFDEF MSWINDOWS}
CancelBtn.Left := ButtonPanel.ClientWidth - ResourcenameLbl.Left - CancelBtn.Width;
OKBtn.Left := CancelBtn.Left - HDist - OKBtn.Width;
CancelBtn.AnchorSideRight.Control := ButtonPanel;
CancelBtn.AnchorSideRight.Side := asrRight;
OKBtn.AnchorSideRight.Control := CancelBtn;
OKBtn.AnchorSideRight.Side := asrLeft;
OKBtn.TabOrder := 0;
CancelBtn.TabOrder := 1;
{$ELSE}
OKBtn.Left := ButtonPanel.ClientWidth - ResourcenameLbl.Left - OKBtn.Width;
CancelBtn.Left := OKBtn.Left - HDist - CancelBtn.Width;
OKBtn.AnchorSideRight.Control := ButtonPanel;
OKBtn.AnchorSideRight.Side := asrRight;
CancelBtn.AnchorSideRight.Control := OKBtn;
CancelBtn.AnchorSideRight.Side := asrLeft;
CancelBtn.TabOrder := 0;
OKBtn.TabOrder := 1;
{$ENDIF}
CbCategory.Top := BottomOf(DescriptionEdit) + VDist;
LblCategory.Top := CbCategory.Top + (CbCategory.Height - LblCategory.Height) div 2;
CbPriority.Top := CbCategory.Top;
LblPriority.Top := LblCategory.Top;
//Bevel1.Top := DescriptionEdit.Top + editHeight + VBevelDist; //BottomOf(DescriptionEdit) + VBevelDist;
ImgCalendar.Top := Bevel1.Top + 2 + VBevelDist;
ImgCompleted.Top := ImgCalendar.Top;
DueDateEdit.Top := ImgCalendar.Top; // + (ImgCalendar.Height - DueDateEdit.Height) div 2;
DueDateLbl.Top := DueDateEdit.Top + (DueDateEdit.Height - DueDateLbl.Height) div 2;
CbComplete.Top := ImgCompleted.Top; // + (ImgCompleted.Height - CbComplete.Height) div 2;
LblCreatedOn.Top := DueDateEdit.Top + FEditHeight + VDist; //BottomOf(DueDateEdit) + VDist;
LblCompletedOn.Top := LblCreatedOn.Top;
DetailsMemo.Top := BottomOf(LblCreatedOn) + VBevelDist;
DetailsMemo.Height := tabTask.ClientHeight - DetailsMemo.Top - DescriptionEdit.Top;
AutoSize := true;
end;
{=====}