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"/> <OtherUnitFiles Value="source"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\run"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\run"/>
</SearchPaths> </SearchPaths>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>
</Debugging>
</Linking>
</CompilerOptions> </CompilerOptions>
<Description Value="Lazarus Port of Turbo Power's VisualPlanIt components based on version 1.0.3. <Description Value="Lazarus Port of Turbo Power's VisualPlanIt components based on version 1.0.3.
(Runtime package)"/> (Runtime package)"/>

View File

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

View File

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