jvcllaz: Improved layout of TJvTMTimeLine demo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6623 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-29 16:42:47 +00:00
parent c045853084
commit 6e80a21dd4
2 changed files with 17 additions and 12 deletions

View File

@ -207,7 +207,7 @@ begin
else else
JvTimeLine1.Images := Images_200; JvTimeLine1.Images := Images_200;
JvTimeLine1.Align := alClient; JvTimeLine1.Align := alClient;
JvTimeLine1.Constraints.MinHeight := Scale96ToFont(60); JvTimeLine1.Constraints.MinHeight := Scale96ToFont(64);
JvTimeLine1.Hint := JvTimeLine1.Hint :=
'Double-click a date to edit it''s memo content.' + 'Double-click a date to edit it''s memo content.' +
LineEnding + LineEnding +
@ -219,14 +219,10 @@ begin
udButtonWidth.Position := JvTimeLine1.ButtonWidth; udButtonWidth.Position := JvTimeLine1.ButtonWidth;
chkReadOnly.Checked := JvTimeLine1.ReadOnly; chkReadOnly.Checked := JvTimeLine1.ReadOnly;
lbObjFontStyle.Checked[2] := true; lbObjFontStyle.Checked[2] := true;
LblKeyboardNavigation.Font.Style := [fsBold]; LblKeyboardNavigation.Font.Style := [fsBold];
h := abs(Screen.SystemFont.Height);
for i := 0 to JvTimeLine1.Images.Count - 1 do for i := 0 to JvTimeLine1.Images.Count - 1 do
LbImages.Items.Add(IntToStr(i)); LbImages.Items.Add(IntToStr(i));
LbImages.ItemHeight := Max(JvTimeLine1.Images.Height, h + 2 * Scale96ToFont(IMAGE_DIST));
LbImages.Width := JvTimeLine1.Images.Width + 2* h + 2 * Scale96ToFont(IMAGE_DIST);
Statusbar.Panels[0].Width := Scale96ToFont(120); Statusbar.Panels[0].Width := Scale96ToFont(120);
Statusbar.Panels[1].Width := Scale96ToFont(220); Statusbar.Panels[1].Width := Scale96ToFont(220);
@ -412,7 +408,7 @@ var
h: Integer; h: Integer;
begin begin
LbImages.Canvas.Font.Assign(LbImages.Font); LbImages.Canvas.Font.Assign(LbImages.Font);
h := LbImages.Canvas.TextHeight('Tg'); h := LbImages.Canvas.TextHeight('99');
if State * [odSelected, odFocused] <> [] then begin if State * [odSelected, odFocused] <> [] then begin
LbImages.Canvas.Brush.Color := clHighlight; LbImages.Canvas.Brush.Color := clHighlight;
LbImages.Canvas.font.Color := clHighlightText; LbImages.Canvas.font.Color := clHighlightText;
@ -421,14 +417,14 @@ begin
LbImages.Canvas.Font.Color := clWindowText; LbImages.Canvas.Font.Color := clWindowText;
end; end;
LbImages.Canvas.FillRect(ARect); LbImages.Canvas.FillRect(ARect);
InflateRect(ARect, -IMAGE_DIST, 0); InflateRect(ARect, -Scale96ToFont(IMAGE_DIST), 0);
JvTimeLine1.Images.Draw( JvTimeLine1.Images.Draw(
LbImages.Canvas, ARect.Left, LbImages.Canvas, ARect.Left,
(ARect.Top + ARect.Bottom - JvTimeLine1.Images.Height) div 2, (ARect.Top + ARect.Bottom - JvTimeLine1.Images.Height) div 2,
Index Index
); );
LbImages.Canvas.TextOut( LbImages.Canvas.TextOut(
ARect.Left + JvTimeLine1.Images.Width + IMAGE_DIST, ARect.Left + JvTimeLine1.Images.Width + Scale96ToFont(IMAGE_DIST),
(ARect.Top + ARect.Bottom - h) div 2, (ARect.Top + ARect.Bottom - h) div 2,
IntToStr(Index) IntToStr(Index)
); );
@ -442,7 +438,13 @@ begin
end; end;
procedure TTMTimeLineMainForm.FormShow(Sender: TObject); procedure TTMTimeLineMainForm.FormShow(Sender: TObject);
var
ex: TSize;
begin begin
ex := LbImages.Canvas.TextExtent('99');
LbImages.ItemHeight := Max(JvTimeLine1.Images.Height, ex.CY + 2 * Scale96ToFont(IMAGE_DIST));
LbImages.ClientWidth := JvTimeLine1.Images.Width + ex.CX + 3 * Scale96ToFont(IMAGE_DIST);
Constraints.MinWidth := GbDates.Left + GbDates.Width; Constraints.MinWidth := GbDates.Left + GbDates.Width;
AutoSize := true; AutoSize := true;
AutoSize := false; AutoSize := false;

View File

@ -496,7 +496,7 @@ begin
end; end;
FLeftBtn.SetSubComponent(True); FLeftBtn.SetSubComponent(True);
FRightBtn.SetSubComponent(True); FRightBtn.SetSubComponent(True);
Height := 56; Height := 64;
BevelInner := bvNone; BevelInner := bvNone;
BevelOuter := bvNone; BevelOuter := bvNone;
Color := clWindow; Color := clWindow;
@ -660,6 +660,8 @@ begin
end; end;
procedure TJvCustomTMTimeline.DrawDates(ACanvas: TCanvas); procedure TJvCustomTMTimeline.DrawDates(ACanvas: TCanvas);
const
TOP_MARGIN = 2;
var var
I, FirstOffset: Integer; I, FirstOffset: Integer;
Y, M, D: Word; Y, M, D: Word;
@ -668,6 +670,7 @@ var
S: string; S: string;
FTmpStyle: TFontStyles; FTmpStyle: TFontStyles;
AContinue: Boolean; AContinue: Boolean;
h: Integer;
begin begin
AContinue := True; AContinue := True;
// DoBeforeDraw(ACanvas); // DoBeforeDraw(ACanvas);
@ -679,15 +682,15 @@ begin
FirstOffset := 1; FirstOffset := 1;
// first loop: draw dates, today and images // first loop: draw dates, today and images
FTmpStyle := Font.Style; FTmpStyle := Font.Style;
h := Canvas.TextHeight('Tg');
for I := 0 to Width div DayWidth do for I := 0 to Width div DayWidth do
begin begin
R := GetRectForDate(Self.Date + I); R := GetRectForDate(Self.Date + I);
if Self.Date + I = SysUtils.Date then if Self.Date + I = SysUtils.Date then
DrawToday(ACanvas, R); DrawToday(ACanvas, R);
DecodeDate(Self.Date + I, Y, M, D); DecodeDate(Self.Date + I, Y, M, D);
R := Classes.Rect(I * DayWidth, 8, I * DayWidth + DayWidth, Font.Size+8); R := Classes.Rect(I * DayWidth, 0, I * DayWidth + DayWidth, h);
OffsetRect(R, FirstOffset, 0); OffsetRect(R, FirstOffset, TOP_MARGIN);
S := Format('%.2d', [D]); S := Format('%.2d', [D]);
SetBkMode(ACanvas.Handle, TRANSPARENT); SetBkMode(ACanvas.Handle, TRANSPARENT);
if Objects[Self.Date + I] <> nil then if Objects[Self.Date + I] <> nil then