tvplanit: Remove unnecessary routines. Improved HiDPI performance of TaskEdit dlg, Alarm dlg, and ExVpRptSetup (used by fulldemo).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5888 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-21 12:02:22 +00:00
parent c23870445e
commit b5d006373c
8 changed files with 224 additions and 209 deletions

View File

@@ -16,7 +16,7 @@ object AlarmNotifyForm: TAlarmNotifyForm
OnKeyDown = FormKeyDown
OnShow = FormShow
Position = poDefault
LCLVersion = '1.9.0.0'
LCLVersion = '1.6.4.0'
object SnoozeCaption: TLabel
AnchorSideLeft.Control = lTime
AnchorSideTop.Control = Bevel1

View File

@@ -69,8 +69,9 @@ type
private
SnoozeDelay: TDateTime;
ShowTime : TDateTime;
procedure CalcSnooze;
protected
procedure PositionControls;
public
Event: TVpEvent;
DataStore: TVpCustomDataStore;
@@ -299,6 +300,11 @@ end;
{=====}
procedure TAlarmNotifyForm.FormShow(Sender: TObject);
begin
PositionControls;
end;
procedure TAlarmNotifyForm.PositionControls;
var
w, h: Integer;
b: TButton;
@@ -317,21 +323,22 @@ begin
cnv.Free;
end;
b := SnoozeBtn;
if GetButtonWidth(b) > w then
w := GetButtonWidth(b);
if GetButtonWidth(OpenItemBtn) > w then begin
b := OpenItemBtn;
w := GetButtonWidth(b);
end;
if GetButtonWidth(DismissBtn) > w then begin
b := DismissBtn;
w := GetButtonWidth(b);
end;
b.AutoSize := true;
w := Max(w, b.Width);
h := b.Height;
b.AutoSize := false;
SnoozeBtn.AutoSize := true;
h := SnoozeBtn.Height;
if SnoozeBtn.Width > w then
w := SnoozeBtn.Width;
SnoozeBtn.AutoSize := false;
OpenItemBtn.AutoSize := true;
if OpenItemBtn.Width > w then
w := OpenItemBtn.Width;
OpenItemBtn.AutoSize := false;
DismissBtn.AutoSize := true;
if DismissBtn.Width > w then
w := DismissBtn.Width;
DismissBtn.AutoSize := false;
SnoozeBtn.Width := w;
SnoozeBtn.Height := h;
DismissBtn.Width := w;

View File

@@ -59,6 +59,9 @@ const
GranularityMinutes: Array[TVpGranularity] of Integer = (5, 6, 10, 15, 20, 30, 60);
DesignTimeDPI = 96;
function DefaultEpoch : Integer;
{-return the current century}
@@ -158,8 +161,8 @@ function GranularityToStr(Gran: TVpGranularity): string;
function TaskPriorityToStr(APriority: TVpTaskPriority): String;
function AutoHeight(ARadioGroup: TRadioGroup): Integer;
function GetButtonWidth(AButton: TButton): Integer;
//function AutoHeight(ARadioGroup: TRadioGroup): Integer;
//function GetButtonWidth(AButton: TButton): Integer;
function GetLabelWidth(ALabel: TLabel): Integer;
function GetRealFontHeight(AFont: TFont): Integer;
@@ -171,18 +174,11 @@ procedure AddResourceGroupMenu(AMenu: TMenuItem; AResource: TVpResource;
AEventHandler: TNotifyEvent);
function OverlayPatternToBrushStyle(APattern: TVpOverlayPattern): TBrushStyle;
{$IFDEF LCL}
procedure HighDPI(FromDPI: integer);
procedure ScaleDPI(Control: TControl; FromDPI: integer);
const
DesignTimeDPI = 96;
{$ENDIF}
procedure Unused(const A1); overload;
procedure Unused(const A1, A2); overload;
procedure Unused(const A1, A2, A3); overload;
implementation
uses
@@ -785,6 +781,7 @@ begin
end;
end;
(*
function AutoHeight(ARadioGroup: TRadioGroup): Integer;
var
w: Integer;
@@ -795,6 +792,7 @@ begin
ARadioGroup.AutoSize := false;
ARadioGroup.Width := w;
end;
*)
function GetLabelWidth(ALabel: TLabel): Integer;
var
@@ -807,6 +805,7 @@ begin
canvas.Free;
end;
(*
function GetButtonWidth(AButton: TButton): Integer;
const
MARGIN = 24;
@@ -819,7 +818,7 @@ begin
Result := canvas.TextWidth(AButton.Caption) + MARGIN * Screen.PixelsPerInch div DesignTimeDPI;
canvas.Free;
end;
*)
function GetRealFontHeight(AFont: TFont): Integer;
begin
if AFont.Size = 0 then
@@ -932,45 +931,6 @@ begin
Result := TBrushStyle(APattern);
end;
{$IFDEF LCL}
procedure HighDPI(FromDPI: integer);
var
i: integer;
begin
if Screen.PixelsPerInch = FromDPI then
exit;
for i := 0 to Screen.FormCount - 1 do
ScaleDPI(Screen.Forms[i], FromDPI);
end;
procedure ScaleDPI(Control: TControl; FromDPI: integer);
var
i: integer;
WinControl: TWinControl;
begin
if Screen.PixelsPerInch = FromDPI then
exit;
with Control do
begin
Left := ScaleX(Left, FromDPI);
Top := ScaleY(Top, FromDPI);
Width := ScaleX(Width, FromDPI);
Height := ScaleY(Height, FromDPI);
end;
if Control is TWinControl then
begin
WinControl := TWinControl(Control);
if WinControl.ControlCount = 0 then
exit;
for i := 0 to WinControl.ControlCount - 1 do
ScaleDPI(WinControl.Controls[i], FromDPI);
end;
end;
{$ENDIF}
{$PUSH}{$HINTS OFF}
procedure Unused(const A1);
begin

View File

@@ -11,7 +11,7 @@ object TaskEditForm: TTaskEditForm
OnCreate = FormCreate
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.9.0.0'
LCLVersion = '1.6.4.0'
object ButtonPanel: TPanel
Left = 0
Height = 33
@@ -90,20 +90,25 @@ object TaskEditForm: TTaskEditForm
ClientHeight = 369
ClientWidth = 539
object DueDateLbl: TLabel
AnchorSideLeft.Control = imgCalendar
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrCenter
Left = 52
Left = 56
Height = 15
Top = 68
Width = 50
BorderSpacing.Left = 16
BorderSpacing.Right = 8
Caption = 'Due date:'
FocusControl = DueDateEdit
ParentColor = False
end
object LblCreatedOn: TLabel
AnchorSideLeft.Control = DueDateLbl
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrBottom
Left = 52
Left = 56
Height = 15
Top = 91
Width = 61
@@ -112,8 +117,9 @@ object TaskEditForm: TTaskEditForm
ParentColor = False
end
object LblCompletedOn: TLabel
AnchorSideLeft.Control = CbPriority
AnchorSideTop.Control = LblCreatedOn
Left = 333
Left = 326
Height = 15
Top = 91
Width = 79
@@ -133,6 +139,7 @@ object TaskEditForm: TTaskEditForm
Shape = bsTopLine
end
object imgCalendar: TImage
AnchorSideLeft.Control = tabTask
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 8
@@ -140,6 +147,7 @@ object TaskEditForm: TTaskEditForm
Top = 64
Width = 32
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 4
Picture.Data = {
07544269746D6170360C0000424D360C00000000000036000000280000002000
@@ -245,9 +253,10 @@ object TaskEditForm: TTaskEditForm
Transparent = True
end
object imgCompleted: TImage
AnchorSideLeft.Control = LblPriority
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 290
Left = 277
Height = 32
Top = 64
Width = 32
@@ -297,9 +306,10 @@ object TaskEditForm: TTaskEditForm
Text = 'DescriptionEdit'
end
object CbComplete: TCheckBox
AnchorSideLeft.Control = CbPriority
AnchorSideTop.Control = DueDateEdit
AnchorSideTop.Side = asrCenter
Left = 333
Left = 326
Height = 19
Top = 66
Width = 72
@@ -334,12 +344,14 @@ object TaskEditForm: TTaskEditForm
TabOrder = 3
end
object DueDateEdit: TDateEdit
AnchorSideLeft.Control = DueDateLbl
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom
Left = 128
Left = 114
Height = 23
Top = 64
Width = 120
Width = 110
CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames]
DateOrder = doNone
ButtonWidth = 23
@@ -352,21 +364,25 @@ object TaskEditForm: TTaskEditForm
object LblCategory: TLabel
AnchorSideTop.Control = CbCategory
AnchorSideTop.Side = asrCenter
Left = 62
AnchorSideRight.Control = CbCategory
Left = 55
Height = 15
Top = 35
Width = 51
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
Caption = 'Category:'
FocusControl = CbCategory
ParentColor = False
end
object CbCategory: TComboBox
AnchorSideLeft.Control = DueDateEdit
AnchorSideTop.Control = DescriptionEdit
AnchorSideTop.Side = asrBottom
Left = 128
Left = 114
Height = 23
Top = 31
Width = 120
Width = 139
BorderSpacing.Top = 4
ItemHeight = 15
ItemIndex = 0
@@ -382,23 +398,29 @@ object TaskEditForm: TTaskEditForm
Text = 'Business'
end
object LblPriority: TLabel
AnchorSideLeft.Control = CbCategory
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbPriority
AnchorSideTop.Side = asrCenter
Left = 281
Left = 277
Height = 15
Top = 35
Width = 41
BorderSpacing.Left = 24
Caption = 'Priority:'
FocusControl = CbPriority
ParentColor = False
end
object CbPriority: TComboBox
AnchorSideLeft.Control = LblPriority
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DescriptionEdit
AnchorSideTop.Side = asrBottom
Left = 333
Left = 326
Height = 23
Top = 31
Width = 120
BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 4
ItemHeight = 15

View File

@@ -82,7 +82,7 @@ type
FResource: TVpResource;
// FBtnHeight: Integer;
// FBtnWidth: Integer;
FEditHeight: Integer;
// FEditHeight: Integer;
procedure PositionControls;
procedure SetCaptions;
public
@@ -128,7 +128,7 @@ procedure TTaskEditForm.FormCreate(Sender: TObject);
begin
FReturnCode := rtAbandon;
// FBtnHeight := ScaleY(OKBtn.Height, DesignTimeDPI);
FEditHeight := ScaleY(DueDateEdit.Height, DesignTimeDPI);
// FEditHeight := ScaleY(DueDateEdit.Height, DesignTimeDPI);
end;
procedure TTaskEditForm.DePopulateSelf;
@@ -184,72 +184,48 @@ end;
procedure TTaskEditForm.PositionControls;
var
VBevelDist: Integer = 8; // Distance bevel-to-control
VDist: Integer = 8; // Vertical distance between controls
HDist: Integer = 8; // Horizontal distance between controls:
w: Integer;
i, 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;
AutoSize := false;
DueDateEdit.ButtonWidth := DueDateEdit.Height;
CbCategory.Height := FEditHeight;
CbPriority.Height := FEditHeight;
ResourceNameLbl.Font.Size := ScaleY(ResourceNameLbl.Font.Size, DesignTimeDPI);
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + HDist;
cnv := TControlCanvas.Create;
try
cnv.Control := DueDateEdit;
cnv.Font.Assign(DueDateEdit.Font);
w := cnv.TextWidth(' 99-99-9999 ') + DueDateEdit.ButtonWidth + 10;
DueDateEdit.Width := w;
finally
cnv.Free;
end;
DueDateEdit.Width := w;
if RightOf(DueDateEdit) + 3*HDist > ImgCompleted.Left then begin
ImgCompleted.Left := RightOf(DueDateEdit) + 3*HDist;
CbComplete.Left := RightOf(ImgCompleted) + HDist;
LblCompletedOn.Left := CbComplete.Left;
cnv := TControlCanvas.Create;
try
cnv.Control := CbComplete;
cnv.Font.Assign(CbComplete.Font);
w := cnv.TextWidth(CbComplete.Caption) + GetSystemMetrics(SM_CXMENUCHECK);
finally
cnv.Free;
end;
w := Max(GetlabelWidth(LblCompletedOn), w);
ClientWidth := ClientWidth - tabTask.ClientWidth +
Max(CbComplete.Left + w, RightOf(CbPriority)) +
HDist*2;
cnv := TControlCanvas.Create;
try
cnv.Control := CbCategory;
cnv.Font.Assign(CbCategory.Font);
w := 0;
for i :=0 to CbCategory.Items.Count - 1 do
w := max(w, cnv.TextWidth(CbCategory.Items[i]));
inc(w, GetSystemMetrics(SM_CXVSCROLL)*2);
w := Max(w, DueDateEdit.Width);
CbCategory.Width := w;
finally
cnv.Free;
end;
CbCategory.Left := DueDateEdit.Left;
LblCategory.Left := CbCategory.Left - HDist - GetLabelWidth(LblCategory);
if RightOf(CbCategory) + 3*HDist + GetLabelWidth(LblPriority) + HDist > CbComplete.Left then
CbPriority.Left := CbPriority.Parent.ClientWidth - HDist - CbPriority.Width
else
CbPriority.Left := CbComplete.Left;
LblPriority.Left := CbPriority.Left - HDist - GetLabelWidth(LblPriority);
cnv := TControlCanvas.Create;
try
cnv.Control := CbPriority;
cnv.Font.Assign(CbPriority.Font);
w := 0;
for i :=0 to CbPriority.Items.Count - 1 do
w := max(w, cnv.TextWidth(CbPriority.Items[i]));
inc(w, GetSystemMetrics(SM_CXVSCROLL)*2);
CbPriority.Width := w;
finally
cnv.Free;
end;
AlignOKCancel(OKBtn, CancelBtn, ButtonPanel);