jvcllaz: Improved cross-platform layout of TimeLineDemo. Fix some issues in TJvTimeLine.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6959 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-05-27 16:34:26 +00:00
parent 7e09fbeea1
commit 1208e21319
4 changed files with 259 additions and 146 deletions

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="TimeLineDemo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>

View File

@ -1,12 +1,12 @@
object TimelineMainForm: TTimelineMainForm
Left = 357
Height = 607
Height = 640
Top = 104
Width = 731
Width = 752
ActiveControl = TimeLine1
Caption = 'Test program for TJvTimeLine'
ClientHeight = 607
ClientWidth = 731
ClientHeight = 640
ClientWidth = 752
Color = clSilver
Constraints.MinHeight = 500
Constraints.MinWidth = 700
@ -14,23 +14,24 @@ object TimelineMainForm: TTimelineMainForm
Font.Color = clWindowText
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '1.9.0.0'
LCLVersion = '2.1.0.0'
Scaled = False
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 3
Top = 0
Width = 731
Width = 752
Align = alTop
ResizeAnchor = akTop
end
object StatusBar1: TStatusBar
Left = 0
Height = 23
Top = 584
Width = 731
Top = 617
Width = 752
Panels = <
item
Width = 50
@ -39,36 +40,19 @@ object TimelineMainForm: TTimelineMainForm
end
object TimeLine1: TJvTimeLine
Left = 0
Height = 293
Height = 358
Top = 3
Width = 731
Width = 752
Align = alClient
Color = clCream
HelperYears = False
PopupMenu = PopupMenu1
ParentShowHint = False
ShowHint = True
DragCursor = crDefault
FirstVisibleDate = 35400
Font.CharSet = ANSI_CHARSET
Font.Color = clMaroon
TabStop = True
TabOrder = 0
OnMouseDown = TimeLine1MouseDown
OnMouseMove = TimeLine1MouseMove
OnClick = TimeLine1Click
DragCursor = crDefault
OnDragOver = TimeLine1DragOver
OnDragDrop = TimeLine1DragDrop
YearFont.CharSet = ANSI_CHARSET
YearFont.Color = clPurple
YearFont.Height = -29
YearFont.Name = 'Lucida Sans Unicode'
YearFont.Style = [fsBold]
YearWidth = 600
ShowDays = True
ShowItemHint = True
ShowMonthNames = False
FirstVisibleDate = 35400
HelperYears = False
HorzSupports = True
Images = ImageList1
ItemHeight = 40
Items = <
item
Left = 53
@ -144,37 +128,37 @@ object TimelineMainForm: TTimelineMainForm
end
item
Left = 233
Top = 211
Top = 251
Caption = ' Simons birthday'
Color = 8404992
Date = 35539
Hint = 'Simons birthday'
ImageIndex = 8
Level = 2
Level = 3
TextColor = 16777088
Width = 85
end
item
Left = 361
Top = 171
Top = 291
Caption = ' Elias birthday'
Color = clMaroon
Date = 35617
Hint = 'Elias birthday'
ImageIndex = 8
Level = 1
Level = 4
TextColor = clWhite
Width = 70
end
item
Left = 206
Top = 171
Top = 291
Caption = ' Majas birthday'
Color = 8388863
Date = 35523
Hint = 'Majas birthday'
ImageIndex = 8
Level = 1
Level = 4
TextColor = clWhite
Width = 85
end
@ -238,44 +222,77 @@ object TimelineMainForm: TTimelineMainForm
Level = 1
TextColor = clAqua
end>
ItemHeight = 40
HorzSupports = True
PopupMenu = PopupMenu1
ParentShowHint = False
ShowDays = True
ShowHint = True
ShowItemHint = True
ShowMonthNames = False
SupportsColor = clSilver
OnItemClick = TimeLine1ItemClick
TabOrder = 0
TabStop = True
YearFont.CharSet = ANSI_CHARSET
YearFont.Color = clPurple
YearFont.Height = -29
YearFont.Name = 'Lucida Sans Unicode'
YearFont.Style = [fsBold]
YearWidth = 600
OnClick = TimeLine1Click
OnDragDrop = TimeLine1DragDrop
OnDragOver = TimeLine1DragOver
OnDrawItem = TimeLine1DrawItem
OnSaveItem = TimeLine1SaveItem
OnLoadItem = TimeLine1LoadItem
OnItemClick = TimeLine1ItemClick
OnItemMoved = TimeLine1ItemMoved
OnLoadItem = TimeLine1LoadItem
OnMouseDown = TimeLine1MouseDown
OnMouseMove = TimeLine1MouseMove
OnSaveItem = TimeLine1SaveItem
end
object Panel2: TPanel
Left = 0
Height = 288
Top = 296
Width = 731
Height = 256
Top = 361
Width = 752
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 288
ClientWidth = 731
ClientHeight = 256
ClientWidth = 752
Color = clForm
ParentColor = False
TabOrder = 2
object Label6: TLabel
Left = 8
AnchorSideLeft.Control = GroupBox1
AnchorSideTop.Control = GroupBox3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnSave
Left = 12
Height = 30
Top = 216
Width = 565
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 10
BorderSpacing.Right = 8
BorderSpacing.Bottom = 10
Caption = 'Scrolling is done one month at a time: hold down the Ctrl key when clicking to skip ahead one year instead.'#13#10'Right-click any item to see its actions, check and uncheck boxes to see the properties at work.'
ParentColor = False
WordWrap = True
end
object GroupBox1: TGroupBox
Left = 8
Height = 193
Top = 16
Width = 196
AnchorSideLeft.Control = Panel2
AnchorSideTop.Control = GroupBox3
AnchorSideBottom.Control = GroupBox3
AnchorSideBottom.Side = asrBottom
Left = 12
Height = 198
Top = 8
Width = 212
Anchors = [akTop, akLeft, akBottom]
BorderSpacing.Left = 12
Caption = ' New item: '
ClientHeight = 173
ClientWidth = 192
ClientHeight = 178
ClientWidth = 208
Constraints.MinWidth = 212
TabOrder = 0
object lblCaption: TLabel
AnchorSideLeft.Control = GroupBox1
@ -318,7 +335,7 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblImIndex
Left = 104
Left = 112
Height = 15
Top = 64
Width = 30
@ -330,10 +347,15 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = Bevel1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnColor
Left = 104
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Side = asrBottom
Left = 112
Height = 25
Top = 134
Width = 75
Top = 133
Width = 84
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Right = 12
Caption = '&Add'
OnClick = btnAddClick
TabOrder = 5
@ -342,16 +364,15 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = lblCaption
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox1
AnchorSideRight.Control = GroupBox1
AnchorSideRight.Control = btnAdd
AnchorSideRight.Side = asrBottom
Left = 65
Height = 23
Top = 2
Width = 115
Width = 131
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 12
TabOrder = 0
Text = 'New item'
end
@ -383,21 +404,22 @@ object TimelineMainForm: TTimelineMainForm
end
object edLevel: TEdit
AnchorSideLeft.Control = lblLevel
AnchorSideTop.Control = CbImgIndex
AnchorSideRight.Control = udLevel
Left = 104
Left = 112
Height = 23
Top = 81
Width = 61
Top = 83
Width = 69
Anchors = [akTop, akLeft, akRight]
TabOrder = 1
Text = '0'
end
object udLevel: TUpDown
AnchorSideRight.Control = edCaption
AnchorSideRight.Control = btnAdd
AnchorSideRight.Side = asrBottom
Left = 165
Left = 181
Height = 23
Top = 81
Top = 83
Width = 15
Anchors = [akTop, akRight]
Associate = edLevel
@ -405,16 +427,20 @@ object TimelineMainForm: TTimelineMainForm
Min = 0
Position = 0
TabOrder = 2
Wrap = False
end
object btnColor: TButton
AnchorSideLeft.Control = GroupBox1
AnchorSideRight.Control = Bevel1
Left = 13
AnchorSideBottom.Control = GroupBox1
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 25
Top = 134
Width = 75
Anchors = [akTop, akRight]
Top = 133
Width = 80
Anchors = [akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Bottom = 20
Caption = 'Color...'
OnClick = btnColorClick
TabOrder = 3
@ -422,7 +448,7 @@ object TimelineMainForm: TTimelineMainForm
object Bevel1: TBevel
AnchorSideLeft.Control = GroupBox1
AnchorSideLeft.Side = asrCenter
Left = 88
Left = 96
Height = 50
Top = 64
Width = 16
@ -434,11 +460,11 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Bevel1
Left = 12
Height = 24
Top = 81
Width = 76
Height = 22
Top = 83
Width = 84
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
BorderSpacing.Top = 4
DropDownCount = 24
Images = ImageList1
ItemHeight = 16
@ -447,13 +473,21 @@ object TimelineMainForm: TTimelineMainForm
end
end
object GroupBox2: TGroupBox
Left = 240
Height = 193
Top = 16
Width = 256
AnchorSideLeft.Control = GroupBox1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox3
AnchorSideBottom.Control = GroupBox3
AnchorSideBottom.Side = asrBottom
Left = 248
Height = 198
Top = 8
Width = 258
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 24
Caption = ' Options: '
ClientHeight = 173
ClientWidth = 252
ClientHeight = 178
ClientWidth = 254
TabOrder = 1
object chkMonths: TCheckBox
AnchorSideLeft.Control = GroupBox2
@ -505,13 +539,14 @@ object TimelineMainForm: TTimelineMainForm
TabOrder = 3
end
object chkAutosize: TCheckBox
AnchorSideLeft.Control = Bevel2
AnchorSideLeft.Control = chkWidthAs
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = GroupBox2
Left = 128
Left = 121
Height = 19
Top = 2
Width = 65
BorderSpacing.Left = 16
BorderSpacing.Top = 2
Caption = 'Autosi&ze'
OnClick = chkAutosizeClick
@ -521,7 +556,7 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = chkAutosize
AnchorSideTop.Control = chkAutosize
AnchorSideTop.Side = asrBottom
Left = 128
Left = 121
Height = 19
Top = 21
Width = 89
@ -533,7 +568,7 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = chkAutosize
AnchorSideTop.Control = chkSupport
AnchorSideTop.Side = asrBottom
Left = 128
Left = 121
Height = 19
Top = 40
Width = 90
@ -545,7 +580,7 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = chkAutosize
AnchorSideTop.Control = chkLarge
AnchorSideTop.Side = asrBottom
Left = 128
Left = 121
Height = 19
Top = 59
Width = 81
@ -555,11 +590,17 @@ object TimelineMainForm: TTimelineMainForm
end
object btnAuto: TButton
AnchorSideLeft.Control = GroupBox2
AnchorSideTop.Control = chkReset
AnchorSideBottom.Control = GroupBox2
AnchorSideBottom.Side = asrBottom
Left = 12
Height = 25
Top = 120
Width = 75
Top = 121
Width = 84
AutoSize = True
BorderSpacing.Left = 12
BorderSpacing.Top = 6
BorderSpacing.Bottom = 12
Caption = 'A&utoLevels'
OnClick = btnAutoClick
TabOrder = 10
@ -567,11 +608,15 @@ object TimelineMainForm: TTimelineMainForm
object chkReset: TCheckBox
AnchorSideLeft.Control = btnAuto
AnchorSideLeft.Side = asrBottom
Left = 103
AnchorSideTop.Control = chkFlat
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrCenter
Left = 112
Height = 19
Top = 112
Top = 115
Width = 103
BorderSpacing.Left = 16
BorderSpacing.Top = 18
Caption = 'Reset levels &first'
TabOrder = 11
end
@ -579,11 +624,13 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = chkReset
AnchorSideTop.Control = chkReset
AnchorSideTop.Side = asrBottom
Left = 103
Left = 112
Height = 19
Top = 133
Top = 136
Width = 130
BorderSpacing.Top = 2
BorderSpacing.Right = 12
BorderSpacing.Bottom = 12
Caption = '&Complete evaluation'
TabOrder = 12
end
@ -591,7 +638,7 @@ object TimelineMainForm: TTimelineMainForm
AnchorSideLeft.Control = chkAutosize
AnchorSideTop.Control = chkOwnerDraw
AnchorSideTop.Side = asrBottom
Left = 128
Left = 121
Height = 19
Top = 78
Width = 39
@ -611,24 +658,23 @@ object TimelineMainForm: TTimelineMainForm
OnClick = chkHelpYearClick
TabOrder = 4
end
object Bevel2: TBevel
AnchorSideLeft.Control = GroupBox2
AnchorSideLeft.Side = asrCenter
Left = 124
Height = 50
Top = 64
Width = 4
Shape = bsSpacer
end
end
object GroupBox3: TGroupBox
Left = 528
Height = 193
Top = 16
Width = 193
AnchorSideLeft.Control = GroupBox2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel2
AnchorSideBottom.Side = asrBottom
Left = 530
Height = 198
Top = 8
Width = 187
AutoSize = True
BorderSpacing.Left = 24
BorderSpacing.Top = 8
BorderSpacing.Right = 12
Caption = ' Sizing: '
ClientHeight = 173
ClientWidth = 189
ClientHeight = 178
ClientWidth = 183
TabOrder = 2
object lblYrSize: TLabel
AnchorSideLeft.Control = GroupBox3
@ -644,8 +690,9 @@ object TimelineMainForm: TTimelineMainForm
ParentColor = False
end
object lblItemHeight: TLabel
AnchorSideLeft.Control = edItemHeight
AnchorSideTop.Control = lblYrSize
Left = 111
Left = 101
Height = 15
Top = 2
Width = 61
@ -667,21 +714,34 @@ object TimelineMainForm: TTimelineMainForm
ParentColor = False
end
object btnYrFont: TButton
Left = 97
AnchorSideLeft.Control = btnFont
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = btnFont
Left = 83
Height = 25
Top = 104
Width = 75
Top = 110
Width = 85
AutoSize = True
BorderSpacing.Left = 16
BorderSpacing.Bottom = 12
Caption = 'Yea&r Font...'
OnClick = btnYrFontClick
TabOrder = 6
end
object btnFont: TButton
AnchorSideLeft.Control = GroupBox3
AnchorSideTop.Control = dtpFirstDate
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ColorBtn
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25
Top = 104
Width = 75
Top = 110
Width = 59
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 16
BorderSpacing.Bottom = 6
Caption = '&Font...'
OnClick = btnFontClick
TabOrder = 4
@ -699,6 +759,8 @@ object TimelineMainForm: TTimelineMainForm
Text = '600'
end
object udYrSize: TUpDown
AnchorSideLeft.Control = edYrSize
AnchorSideLeft.Side = asrBottom
Left = 62
Height = 23
Top = 21
@ -710,20 +772,23 @@ object TimelineMainForm: TTimelineMainForm
OnClick = udYrSizeClick
Position = 600
TabOrder = 1
Wrap = False
end
object edItemHeight: TEdit
AnchorSideLeft.Control = lblItemHeight
AnchorSideLeft.Control = udYrSize
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edYrSize
Left = 111
Left = 101
Height = 23
Top = 21
Width = 50
BorderSpacing.Left = 24
TabOrder = 2
Text = '36'
end
object udItemHeight: TUpDown
Left = 161
AnchorSideLeft.Control = edItemHeight
AnchorSideLeft.Side = asrBottom
Left = 151
Height = 23
Top = 21
Width = 15
@ -732,7 +797,6 @@ object TimelineMainForm: TTimelineMainForm
OnClick = udItemHeightClick
Position = 36
TabOrder = 3
Wrap = False
end
object dtpFirstDate: TDateTimePicker
AnchorSideLeft.Control = lblFirstVisibleDate
@ -763,19 +827,35 @@ object TimelineMainForm: TTimelineMainForm
end
object ColorBtn: TButton
AnchorSideLeft.Control = btnFont
AnchorSideTop.Control = btnFont
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnFont
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 25
Top = 136
Width = 75
Top = 141
Width = 59
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Bottom = 12
Caption = 'Color...'
OnClick = ColorBtnClick
TabOrder = 7
end
object cbDragging: TComboBox
Left = 97
AnchorSideLeft.Control = ColorBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ColorBtn
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = btnYrFont
AnchorSideRight.Side = asrBottom
Left = 83
Height = 23
Top = 136
Width = 76
Top = 142
Width = 85
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 16
ItemHeight = 15
Items.Strings = (
'No dragging'
@ -788,19 +868,32 @@ object TimelineMainForm: TTimelineMainForm
end
end
object btnSave: TButton
Left = 536
AnchorSideTop.Control = GroupBox3
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnLoad
Left = 585
Height = 25
Top = 254
Width = 75
Top = 216
Width = 59
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 10
BorderSpacing.Right = 12
Caption = 'Save...'
OnClick = btnSaveClick
TabOrder = 3
end
object btnLoad: TButton
Left = 624
AnchorSideTop.Control = btnSave
AnchorSideRight.Control = GroupBox3
AnchorSideRight.Side = asrBottom
Left = 656
Height = 25
Top = 254
Width = 75
Top = 216
Width = 61
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Bottom = 12
Caption = 'Load...'
OnClick = btnLoadClick
TabOrder = 4

View File

@ -41,7 +41,6 @@ type
TTimelineMainForm = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
CbImgIndex: TComboBoxEx;
ImageList1: TImageList;
Splitter1: TSplitter;
@ -105,6 +104,7 @@ type
procedure chkMultiClick(Sender: TObject);
procedure btnFontClick(Sender: TObject);
procedure btnYrFontClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TimeLine1Click(Sender: TObject);
procedure Changecaption1Click(Sender: TObject);
procedure remove1Click(Sender: TObject);
@ -218,6 +218,18 @@ begin
end;
end;
procedure TTimelineMainForm.FormShow(Sender: TObject);
var
h: Integer;
begin
h := Height;
AutoSize := true;
AutoSize := false;
Constraints.MinWidth := Width;
Constraints.MinHeight := Height;
Height := h;
end;
procedure TTimelineMainForm.TimeLine1Click(Sender: TObject);
begin
if TimeLine1.Selected <> nil then
@ -279,8 +291,8 @@ begin
if chkNoImages.Checked then
begin
TimeLine1.Images := nil;
TimeLine1.ItemHeight := 16;
udItemHeight.Position := 16;
TimeLine1.ItemHeight := 17;
udItemHeight.Position := 17;
end
else
chkLargeClick(nil);
@ -312,14 +324,14 @@ begin
if chkLarge.Checked then
begin
TimeLine1.Images := ImageList2;
TimeLine1.ItemHeight := 50;
udItemHeight.Position := 50;
TimeLine1.ItemHeight := 60;
udItemHeight.Position := 60;
end
else
begin
TimeLine1.Images := ImageList1;
TimeLine1.ItemHeight := 36;
udItemHeight.Position := 36;
TimeLine1.ItemHeight := 40;
udItemHeight.Position := 40;
end;
end;

View File

@ -420,8 +420,10 @@ type
published
property Align;
property AutoSize;
property BorderSpacing;
property BorderStyle;
property Color;
property Constraints;
property Cursor;
property DragCursor;
property DragLine;
@ -493,6 +495,7 @@ implementation
{$R ..\..\resource\jvtimeline.res}
uses
InterfaceBase, LCLPlatformDef,
Math, Types, DateUtils, Themes,
JvJCLUtils, JvJVCLUtils;
@ -831,13 +834,16 @@ const
var
Button: TThemedScrollBar;
Details: TThemedElementDetails;
useThemedBtn: Boolean;
begin
if TimeLine = nil then
Exit;
if not Visible then
Exit;
if ThemeServices.ThemesEnabled then
useThemedBtn := ThemeServices.ThemesEnabled and not (WidgetSet.LCLPlatform in [lpQT, lpGTK2]);
if useThemedBtn then
begin
if FPushed then
Button := tsArrowBtnLeftPressed
@ -1155,7 +1161,8 @@ begin
else
FArrows[I].UpdatePlacement;
end;
FItemHeight := Canvas.TextHeight('Tg') + ITEM_MARGIN;
if FItemHeight = 0 then
FItemHeight := Canvas.TextHeight('Tg') + ITEM_MARGIN;
end;
procedure TJvCustomTimeLine.UpdateOffset;
@ -2033,8 +2040,7 @@ begin
ACanvas.Pen.Color := Item.TextColor;
if (Length(Item.Caption) > 0) then
begin
R.Bottom := Min(R.Top + ACanvas.TextHeight(Item.Caption), R.Bottom);
R.Bottom := R.Top + ACanvas.TextHeight(Item.Caption) + 2;
ACanvas.Rectangle(R);
R.Left := R.Left + 2;
SetBkMode(ACanvas.Handle, TRANSPARENT);