jvcllaz: Add property IconDayDistance to TJvTMTimeline

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6624 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-29 17:05:20 +00:00
parent 6e80a21dd4
commit 1cb22c365b
3 changed files with 102 additions and 5 deletions

View File

@ -634,13 +634,13 @@ object TMTimeLineMainForm: TTMTimeLineMainForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = LblImages AnchorSideTop.Control = LblImages
Left = 92 Left = 92
Height = 161 Height = 192
Top = 8 Top = 8
Width = 191 Width = 191
AutoSize = True AutoSize = True
BorderSpacing.Left = 12 BorderSpacing.Left = 12
Caption = ' Widths and sizes: ' Caption = ' Widths and sizes: '
ClientHeight = 141 ClientHeight = 172
ClientWidth = 187 ClientWidth = 187
TabOrder = 0 TabOrder = 0
object Label1: TLabel object Label1: TLabel
@ -923,6 +923,63 @@ object TMTimeLineMainForm: TTMTimeLineMainForm
Position = 12 Position = 12
TabOrder = 9 TabOrder = 9
end end
object Label21: TLabel
AnchorSideTop.Control = edIconDayDist
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Label9
AnchorSideRight.Side = asrBottom
Left = 14
Height = 15
Top = 145
Width = 72
Anchors = [akTop, akRight]
BorderSpacing.Left = 8
Caption = 'Icon-day dist.'
ParentColor = False
end
object edIconDayDist: TEdit
AnchorSideLeft.Control = edScrollSmall
AnchorSideTop.Control = edButtonWidth
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edScrollSmall
AnchorSideRight.Side = asrBottom
Left = 90
Height = 23
Hint = 'Sets the width of the scrollbuttons'
Top = 141
Width = 33
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
BorderSpacing.Bottom = 8
TabOrder = 10
Text = '4'
end
object udIconDayDist: TUpDown
AnchorSideRight.Control = udScrollSmall
AnchorSideRight.Side = asrBottom
Left = 127
Height = 23
Top = 141
Width = 15
Anchors = [akTop, akRight]
Associate = edIconDayDist
Max = 35
Min = 0
OnClick = udIconDayDistClick
Position = 4
TabOrder = 11
end
object Label22: TLabel
AnchorSideLeft.Control = Label15
AnchorSideTop.Control = edIconDayDist
AnchorSideTop.Side = asrCenter
Left = 146
Height = 15
Top = 145
Width = 29
Caption = 'pixels'
ParentColor = False
end
end end
object LbImages: TListBox object LbImages: TListBox
AnchorSideLeft.Control = Panel1 AnchorSideLeft.Control = Panel1

View File

@ -41,9 +41,12 @@ type
{ TTMTimeLineMainForm } { TTMTimeLineMainForm }
TTMTimeLineMainForm = class(TForm) TTMTimeLineMainForm = class(TForm)
edIconDayDist: TEdit;
Images: TImageList; Images: TImageList;
Images_150: TImageList; Images_150: TImageList;
Images_200: TImageList; Images_200: TImageList;
Label21: TLabel;
Label22: TLabel;
LbImages: TListBox; LbImages: TListBox;
Panel1: TPanel; Panel1: TPanel;
LblImages: TLabel; LblImages: TLabel;
@ -74,6 +77,7 @@ type
Label4: TLabel; Label4: TLabel;
Label5: TLabel; Label5: TLabel;
edImageNo: TEdit; edImageNo: TEdit;
udIconDayDist: TUpDown;
udImageNo: TUpDown; udImageNo: TUpDown;
dtpImageDate: TDateTimePicker; dtpImageDate: TDateTimePicker;
btnAdd: TButton; btnAdd: TButton;
@ -128,6 +132,7 @@ type
procedure LbImagesDrawItem(Control: TWinControl; Index: Integer; procedure LbImagesDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState); ARect: TRect; State: TOwnerDrawState);
procedure LbImagesSelectionChange(Sender: TObject; User: boolean); procedure LbImagesSelectionChange(Sender: TObject; User: boolean);
procedure udIconDayDistClick(Sender: TObject; Button: TUDBtnType);
procedure udDayWidthClick(Sender: TObject; Button: TUDBtnType); procedure udDayWidthClick(Sender: TObject; Button: TUDBtnType);
procedure btnColorClick(Sender: TObject); procedure btnColorClick(Sender: TObject);
procedure chkFlatClick(Sender: TObject); procedure chkFlatClick(Sender: TObject);
@ -437,6 +442,12 @@ begin
udImageNo.Position := LbImages.ItemIndex; udImageNo.Position := LbImages.ItemIndex;
end; end;
procedure TTMTimeLineMainForm.udIconDayDistClick(Sender: TObject;
Button: TUDBtnType);
begin
JvTimeLine1.IconDayDistance := udIconDayDist.Position;
end;
procedure TTMTimeLineMainForm.FormShow(Sender: TObject); procedure TTMTimeLineMainForm.FormShow(Sender: TObject);
var var
ex: TSize; ex: TSize;

View File

@ -40,6 +40,7 @@ uses
const const
cTMTimeLineDayWidth = 19; cTMTimeLineDayWidth = 19;
cTMTimeLineButtonWidth = 16; cTMTimeLineButtonWidth = 16;
cTMTimeLineIconDayDist = 4;
type type
TJvTLSelFrame = class(TPersistent) TJvTLSelFrame = class(TPersistent)
@ -81,6 +82,7 @@ type
FRightClickSelect: Boolean; FRightClickSelect: Boolean;
FDayWidth: Integer; FDayWidth: Integer;
FButtonWidth: Integer; FButtonWidth: Integer;
FIconDayDist: Integer;
FDate: TDate; FDate: TDate;
FSelDate: TDate; FSelDate: TDate;
FMinDate: TDate; FMinDate: TDate;
@ -103,8 +105,10 @@ type
FShowTodayIcon: Boolean; FShowTodayIcon: Boolean;
function ButtonWidthStored: Boolean; function ButtonWidthStored: Boolean;
function DayWidthStored: Boolean; function DayWidthStored: Boolean;
function IconDayDistStored: Boolean;
function GetButtonWidth: Integer; function GetButtonWidth: Integer;
function GetDayWidth: Integer; function GetDayWidth: Integer;
function GetIconDayDist: Integer;
function GetRectForDate(ADate: TDate): TRect; function GetRectForDate(ADate: TDate): TRect;
function DateFromPos(APos: Integer): TDate; function DateFromPos(APos: Integer): TDate;
procedure DoTimer(Sender: TObject); procedure DoTimer(Sender: TObject);
@ -143,6 +147,7 @@ type
function GetObjects(ADate: TDate): TObject; function GetObjects(ADate: TDate): TObject;
procedure SetObjects(ADate: TDate; const Value: TObject); procedure SetObjects(ADate: TDate; const Value: TObject);
procedure SetButtonWidth(const Value: Integer); procedure SetButtonWidth(const Value: Integer);
procedure SetIconDayDist(const Value: Integer);
procedure SetObjectsFontStyle(const Value: TFontStyles); procedure SetObjectsFontStyle(const Value: TFontStyles);
procedure SetShowMonths(const Value: Boolean); procedure SetShowMonths(const Value: Boolean);
procedure SetShowToday(const Value: Boolean); procedure SetShowToday(const Value: Boolean);
@ -181,6 +186,7 @@ type
property Cursor; property Cursor;
property DayWidth: Integer read GetDayWidth write SetDayWidth stored DayWidthStored; property DayWidth: Integer read GetDayWidth write SetDayWidth stored DayWidthStored;
property ObjectsFontStyle: TFontStyles read FObjectsFontStyle write SetObjectsFontStyle default [fsUnderline]; property ObjectsFontStyle: TFontStyles read FObjectsFontStyle write SetObjectsFontStyle default [fsUnderline];
property IconDayDistance: Integer read GetIconDayDist write SetIconDayDist stored IconDayDistStored;
property ImageCursor: TCursor read FImageCursor write SetImageCursor default crHandPoint; property ImageCursor: TCursor read FImageCursor write SetImageCursor default crHandPoint;
property Images: TImageList read FImages write SetImages; property Images: TImageList read FImages write SetImages;
property LargeChange: Word read FLargeChange write SetLargeChange default 30; property LargeChange: Word read FLargeChange write SetLargeChange default 30;
@ -247,6 +253,8 @@ type
property SelDate; property SelDate;
// gets / sets the width of each day // gets / sets the width of each day
property DayWidth; property DayWidth;
// gets / sets the distance between days and associated icons
property IconDayDistance;
// gets / sets the cursor to use when a date has an image associated // gets / sets the cursor to use when a date has an image associated
property ImageCursor; property ImageCursor;
// sets / gets the imagelist associated with the control // sets / gets the imagelist associated with the control
@ -438,6 +446,7 @@ begin
FObjectsFontStyle := [fsUnderline]; FObjectsFontStyle := [fsUnderline];
FButtonWidth := -1; FButtonWidth := -1;
FDayWidth := -1; FDayWidth := -1;
FIconDayDist := -1;
FDate := SysUtils.Date - 7; FDate := SysUtils.Date - 7;
FSelDate := FDate - 1; FSelDate := FDate - 1;
FImageCursor := crHandPoint; FImageCursor := crHandPoint;
@ -647,7 +656,7 @@ begin
resname := 'jvcustomtmtimelinemilestonelarge' + HighDpi_Suffix; resname := 'jvcustomtmtimelinemilestonelarge' + HighDpi_Suffix;
png.LoadFromResourceName(HInstance, resname); png.LoadFromResourceName(HInstance, resname);
x := (ARect.Left + ARect.Right - png.Width) div 2; x := (ARect.Left + ARect.Right - png.Width) div 2;
y := ARect.Top + CanvasMaxTextHeight(ACanvas) + 4; y := ARect.Top + CanvasMaxTextHeight(ACanvas) + IconDayDistance;
R := Classes.Rect(x, y, x + png.Width, y + png.Height); R := Classes.Rect(x, y, x + png.Width, y + png.Height);
ACanvas.Draw(R.Left, R.Top, png); ACanvas.Draw(R.Left, R.Top, png);
finally finally
@ -811,8 +820,7 @@ begin
begin begin
I := ImageIndex[ADate]; I := ImageIndex[ADate];
X := ARect.Left + (DayWidth - Images.Width) div 2; X := ARect.Left + (DayWidth - Images.Width) div 2;
// Y := Max((Height - Images.Height) div 4, CanvasMaxTextHeight(ACanvas) + 2); Y := CanvasMaxTextHeight(ACanvas) + IconDayDistance;
Y := CanvasMaxTextHeight(ACanvas) + 2;
Images.Draw(ACanvas, X, Y, I); Images.Draw(ACanvas, X, Y, I);
end; end;
end; end;
@ -924,6 +932,19 @@ begin
Result := Scale96ToFont(cTMTimeLineDayWidth); Result := Scale96ToFont(cTMTimeLineDayWidth);
end; end;
function TJvCustomTMTimeLine.GetIconDayDist: Integer;
begin
if IconDayDistStored then
Result := FIconDayDist
else
Result := Scale96ToFont(cTMTimelineIconDayDist);
end;
function TJvCustomTMTimeLine.IconDayDistStored: Boolean;
begin
Result := FIconDayDist >= 0;
end;
procedure TJvCustomTMTimeline.SetDayWidth(const Value: Integer); procedure TJvCustomTMTimeline.SetDayWidth(const Value: Integer);
begin begin
if (FDayWidth <> Value) and (Value <> 0) and (Value >= -1) then if (FDayWidth <> Value) and (Value <> 0) and (Value >= -1) then
@ -1230,6 +1251,14 @@ begin
end; end;
end; end;
procedure TJvCustomTMTimeLine.SetIconDayDist(const Value: Integer);
begin
if (FIconDayDist <> Value) and (Value >= -1) then begin
FIconDayDist := Value;
Invalidate;
end;
end;
procedure TJvCustomTMTimeline.LoadFromFile(const Filename: string); procedure TJvCustomTMTimeline.LoadFromFile(const Filename: string);
var var
F: TFileStream; F: TFileStream;