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

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5870 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-05-19 12:36:30 +00:00
parent 35dece7bf0
commit 366928a565
2 changed files with 158 additions and 66 deletions

View File

@ -1,84 +1,127 @@
object AlarmNotifyForm: TAlarmNotifyForm object AlarmNotifyForm: TAlarmNotifyForm
Left = 490 Left = 490
Height = 215 Height = 220
Top = 253 Top = 253
Width = 410 Width = 351
HorzScrollBar.Page = 399 HorzScrollBar.Page = 399
VertScrollBar.Page = 196 VertScrollBar.Page = 196
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Reminder' Caption = 'Reminder'
ClientHeight = 215 ClientHeight = 220
ClientWidth = 410 ClientWidth = 351
Color = clWindow Color = clWindow
DesignTimePPI = 144
KeyPreview = True KeyPreview = True
OnCreate = FormCreate OnCreate = FormCreate
OnKeyDown = FormKeyDown OnKeyDown = FormKeyDown
OnShow = FormShow OnShow = FormShow
Position = poDefault Position = poDefault
LCLVersion = '1.7' LCLVersion = '1.9.0.0'
object SnoozeCaption: TLabel object SnoozeCaption: TLabel
Left = 16 AnchorSideLeft.Control = lTime
Height = 57 AnchorSideTop.Control = Bevel1
Top = 136 AnchorSideTop.Side = asrBottom
Width = 152 AnchorSideRight.Control = SnoozeCombo
AutoSize = False Left = 8
Height = 25
Top = 110
Width = 215
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'SnoozeCaption' Caption = 'SnoozeCaption'
Constraints.MinWidth = 200
ParentColor = False ParentColor = False
WordWrap = True
end end
object lSubject: TLabel object lSubject: TLabel
Left = 16 AnchorSideLeft.Control = lTime
Height = 15 AnchorSideTop.Control = lTime
Top = 32 AnchorSideTop.Side = asrBottom
Width = 45 Left = 8
Height = 25
Top = 37
Width = 68
BorderSpacing.Top = 4
Caption = 'lSubject' Caption = 'lSubject'
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end end
object lTime: TLabel object lTime: TLabel
Left = 16 AnchorSideLeft.Control = Owner
Height = 15 AnchorSideTop.Control = Owner
Left = 8
Height = 25
Top = 8 Top = 8
Width = 30 Width = 42
BorderSpacing.Left = 8
BorderSpacing.Top = 8
Caption = 'lTime' Caption = 'lTime'
ParentColor = False ParentColor = False
end end
object DismissBtn: TButton object DismissBtn: TButton
Left = 176 AnchorSideTop.Control = SnoozeCombo
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = SnoozeBtn
Left = 124
Height = 32 Height = 32
Top = 170 Top = 147
Width = 112 Width = 112
Anchors = [akTop, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'DismissBtn' Caption = 'DismissBtn'
OnClick = DismissBtnClick OnClick = DismissBtnClick
TabOrder = 0 TabOrder = 3
end end
object SnoozeBtn: TButton object SnoozeBtn: TButton
Left = 296 AnchorSideTop.Control = DismissBtn
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 244
Height = 32 Height = 32
Top = 136 Top = 147
Width = 99 Width = 99
Anchors = [akTop, akRight]
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'SnoozeBtn' Caption = 'SnoozeBtn'
OnClick = SnoozeBtnClick OnClick = SnoozeBtnClick
TabOrder = 1 TabOrder = 1
end end
object OpenItemBtn: TButton object OpenItemBtn: TButton
Left = 296 AnchorSideTop.Control = DismissBtn
AnchorSideRight.Control = DismissBtn
Left = 17
Height = 32 Height = 32
Top = 170 Top = 147
Width = 99 Width = 99
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'OpenItemBtn' Caption = 'OpenItemBtn'
Default = True Default = True
OnClick = OpenItemBtnClick OnClick = OpenItemBtnClick
TabOrder = 2 TabOrder = 2
end end
object SnoozeCombo: TComboBox object SnoozeCombo: TComboBox
Left = 176 AnchorSideTop.Control = Bevel1
Height = 23 AnchorSideTop.Side = asrBottom
Top = 136 AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 231
Height = 33
Top = 106
Width = 112 Width = 112
ItemHeight = 15 Anchors = [akTop, akRight]
BorderSpacing.Top = 4
BorderSpacing.Right = 8
DropDownCount = 24
ItemHeight = 25
Items.Strings = ( Items.Strings = (
'5 Minutes' '5 Minutes'
'10 Minutes' '10 Minutes'
@ -104,32 +147,41 @@ object AlarmNotifyForm: TAlarmNotifyForm
OnChange = SnoozeComboChange OnChange = SnoozeComboChange
ParentColor = True ParentColor = True
Style = csDropDownList Style = csDropDownList
TabOrder = 3 TabOrder = 0
end end
object Panel1: TPanel object lNotes: TLabel
Left = 16 AnchorSideLeft.Control = lTime
Height = 72 AnchorSideTop.Control = lSubject
Top = 56 AnchorSideTop.Side = asrBottom
Width = 379 AnchorSideRight.Control = Owner
BevelInner = bvRaised AnchorSideRight.Side = asrBottom
BevelOuter = bvLowered Left = 8
ClientHeight = 72 Height = 25
ClientWidth = 379 Top = 70
TabOrder = 4 Width = 335
object lNotes: TLabel Anchors = [akTop, akLeft, akRight]
Left = 2 BorderSpacing.Top = 8
Height = 68 BorderSpacing.Right = 8
Top = 2 Caption = 'lNotes'
Width = 375 ParentColor = False
Align = alClient WordWrap = True
AutoSize = False end
Caption = 'lNotes' object Bevel1: TBevel
ParentColor = False AnchorSideLeft.Control = lNotes
WordWrap = True AnchorSideTop.Control = lNotes
end AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = lNotes
AnchorSideRight.Side = asrBottom
Left = 8
Height = 3
Top = 99
Width = 335
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
Shape = bsTopLine
end end
object EventDialog: TVpEventEditDialog object EventDialog: TVpEventEditDialog
Version = 'v1.04' Version = 'v1.05'
TimeFormat = tf24Hour TimeFormat = tf24Hour
Options = [] Options = []
Placement.Position = mpCenterTop Placement.Position = mpCenterTop
@ -137,7 +189,7 @@ object AlarmNotifyForm: TAlarmNotifyForm
Placement.Left = 10 Placement.Left = 10
Placement.Height = 412 Placement.Height = 412
Placement.Width = 705 Placement.Width = 705
left = 360 left = 224
top = 8 top = 16
end end
end end

View File

@ -49,13 +49,13 @@ type
{ TAlarmNotifyForm } { TAlarmNotifyForm }
TAlarmNotifyForm = class(TForm) TAlarmNotifyForm = class(TForm)
Bevel1: TBevel;
DismissBtn: TButton; DismissBtn: TButton;
EventDialog: TVpEventEditDialog; EventDialog: TVpEventEditDialog;
lTime: TLabel; lTime: TLabel;
lSubject: TLabel; lSubject: TLabel;
lNotes: TLabel; lNotes: TLabel;
OpenItemBtn: TButton; OpenItemBtn: TButton;
Panel1: TPanel;
SnoozeBtn: TButton; SnoozeBtn: TButton;
SnoozeCaption: TLabel; SnoozeCaption: TLabel;
SnoozeCombo: TComboBox; SnoozeCombo: TComboBox;
@ -102,7 +102,7 @@ implementation
{$ENDIF} {$ENDIF}
uses uses
StrUtils, StrUtils, Math,
VpMisc, VpSR; VpMisc, VpSR;
{ TVpNotificationDialog } { TVpNotificationDialog }
@ -204,13 +204,13 @@ end;
procedure TAlarmNotifyForm.SnoozeComboChange(Sender: TObject); procedure TAlarmNotifyForm.SnoozeComboChange(Sender: TObject);
begin begin
case SnoozeCombo.ItemIndex of case SnoozeCombo.ItemIndex of
0 : SnoozeDelay := 1 / MinutesInDay; { 1 minute } 0 : SnoozeDelay := 1 / MinutesInDay; { 1 minute }
1 : SnoozeDelay := 5 / MinutesInDay; { 5 minutes } 1 : SnoozeDelay := 5 / MinutesInDay; { 5 minutes }
2 : SnoozeDelay := 10 / MinutesInDay; {10 Minutes } 2 : SnoozeDelay := 10 / MinutesInDay; {10 Minutes }
3 : SnoozeDelay := 15 / MinutesInDay; {15 Minutes } 3 : SnoozeDelay := 15 / MinutesInDay; {15 Minutes }
4 : SnoozeDelay := 30 / MinutesInDay; {30 Minutes } 4 : SnoozeDelay := 30 / MinutesInDay; {30 Minutes }
5 : SnoozeDelay := 45 / MinutesInDay; {45 Minutes } 5 : SnoozeDelay := 45 / MinutesInDay; {45 Minutes }
6 : SnoozeDelay := 60 / MinutesInDay; {1 Hour } 6 : SnoozeDelay := 60 / MinutesInDay; {1 Hour }
7 : SnoozeDelay := 120 / MinutesInDay; {2 Hours } 7 : SnoozeDelay := 120 / MinutesInDay; {2 Hours }
8 : SnoozeDelay := 180 / MinutesInDay; {3 Hours } 8 : SnoozeDelay := 180 / MinutesInDay; {3 Hours }
9 : SnoozeDelay := 240 / MinutesInDay; {4 Hours } 9 : SnoozeDelay := 240 / MinutesInDay; {4 Hours }
@ -267,7 +267,7 @@ end;
procedure TAlarmNotifyForm.FormCreate(Sender: TObject); procedure TAlarmNotifyForm.FormCreate(Sender: TObject);
begin begin
SnoozeCombo.Top := SnoozeBtn.Top + (SnoozeBtn.Height - SnoozeCombo.Height) div 2; // SnoozeCombo.Top := SnoozeBtn.Top + (SnoozeBtn.Height - SnoozeCombo.Height) div 2;
end; end;
{=====} {=====}
@ -299,9 +299,49 @@ end;
{=====} {=====}
procedure TAlarmNotifyForm.FormShow(Sender: TObject); procedure TAlarmNotifyForm.FormShow(Sender: TObject);
var
w, h: Integer;
b: TButton;
i: Integer;
cnv: TControlCanvas;
begin begin
Self.Width := 410; cnv := TControlCanvas.Create;
Self.Height := 210; try
cnv.Control := SnoozeCombo;
cnv.Font.Assign(SnoozeCombo.Font);
w := 0;
for i:=0 to SnoozeCombo.Items.Count-1 do
w := Max(w, cnv.TextWidth(SnoozeCombo.Items[i]));
w := w + GetSystemMetrics(SM_CXVSCROLL);
finally
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.Width := w;
SnoozeBtn.Height := h;
DismissBtn.Width := w;
DismissBtn.Height := h;
OpenItemBtn.Width := w;
OpenItemBtn.Height := h;
SnoozeCombo.Width := w;
AutoSize := true;
OpenItemBtn.SetFocus; OpenItemBtn.SetFocus;
end; end;