tvplanit: Fix DayView scrollbar error if Granularity is 60min.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4878 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-07-01 13:21:43 +00:00
parent cd128df0b6
commit 7cb2fd3d88
3 changed files with 18 additions and 49 deletions

View File

@ -1416,7 +1416,9 @@ procedure TVpDayView.SetTopLine(Value: Integer);
begin
if Value <> FTopLine then begin
if Value + VisibleLines >= pred(LineCount) then begin
FTopLine := pred(LineCount) - VisibleLines + 2;
// FTopLine := pred(LineCount) - VisibleLines + 2; // why +2?
FTopLine := pred(LineCount) - VisibleLines;
if FTopLine < 0 then FTopLine := 0;
{ prevent the control from hanging at the bottom }
if (Value < FTopLine) and (Value > 0) then
FTopLine := Value;
@ -1490,6 +1492,10 @@ begin
FGranularity := Value;
SetTimeIntervals(FGranularity);
FTopLine := HourToLine(FTopHour, FGranularity);
if dvRowHeight <> 0 then
dvCalcVisibleLines(Height, dvColHeadHeight, dvRowHeight, 1, FTopLine, -1);
if (FGranularity = gr60Min) and (FVisibleLines = LineCount) then
FTopLine := 0;
Invalidate;
end;
{=====}

View File

@ -1531,12 +1531,18 @@ begin
if StartLine < 0 then
StartLine := FDayView.TopLine;
{
if DisplayOnly then
ScrollBarOffset := 2
else
ScrollBarOffset := 14;
}
if FDayView.VisibleLines < FDayView.LineCount then
ScrollbarOffset := 14 else
ScrollbarOffset := 0;
Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom);
try
SelectClipRgn(RenderCanvas.Handle, Rgn);

View File

@ -445,72 +445,29 @@ end;
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
begin
Result := Ord(Value) * 60 div GranularityMinutes[Granularity];
(*
case Granularity of
gr60Min : Result := Ord (Value);
gr30Min : Result := Ord (Value) * 2;
gr20Min : Result := Ord (Value) * 3;
gr15Min : Result := Ord (Value) * 4;
gr10Min : Result := Ord (Value) * 6;
gr06Min : Result := Ord (Value) * 10;
gr05Min : Result := Ord (Value) * 12;
else
Result := Ord (Value) * 2; { Default to 30 minutes }
end;
*)
end;
{=====}
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
var
LineDuration: Double; { the percentage of a day covered by each line }
LineDuration: Double; // percentage of a day covered by each line
Time: Double;
begin
{ remove the date part, and add one minute to the time }
// Time := StartTime - trunc(StartTime) + (1 / MinutesInDay);
Time := frac(StartTime) + 1 / MinutesInDay;
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
(*
case Granularity of
gr60Min : LineDuration := 60 / MinutesInDay;
gr30Min : LineDuration := 30 / MinutesInDay;
gr20Min : LineDuration := 20 / MinutesInDay;
gr15Min : LineDuration := 15 / MinutesInDay;
gr10Min : LineDuration := 10 / MinutesInDay;
gr06Min : LineDuration := 6 / MinutesInDay;
gr05Min : LineDuration := 5 / MinutesInDay;
else
LineDuration := 30 / MinutesInDay;
end;
*)
result := trunc(Time / LineDuration);
end;
{=====}
function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer;
var
LineDuration: Double; { the percentage of a day covered by each line }
LineDuration: Double; // percentage of a day covered by each line
Time: Double;
begin
{ remove the date part, and subtract one minute from the time }
Time := frac(EndTime) - 1 / MinutesInDay;
// Time := EndTime - trunc(EndTime) - (1 / MinutesInDay);
LineDuration := GranularityMinutes[Granularity] / MinutesInDay;
{
case Granularity of
gr60Min : LineDuration := 60 / MinutesInDay;
gr30Min : LineDuration := 30 / MinutesInDay;
gr20Min : LineDuration := 20 / MinutesInDay;
gr15Min : LineDuration := 15 / MinutesInDay;
gr10Min : LineDuration := 10 / MinutesInDay;
gr06Min : LineDuration := 6 / MinutesInDay;
gr05Min : LineDuration := 5 / MinutesInDay;
else
LineDuration := 30 / MinutesInDay;
end;
}
result := trunc(Time / LineDuration);
end;
{=====}