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 begin
if Value <> FTopLine then begin if Value <> FTopLine then begin
if Value + VisibleLines >= pred(LineCount) 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 } { prevent the control from hanging at the bottom }
if (Value < FTopLine) and (Value > 0) then if (Value < FTopLine) and (Value > 0) then
FTopLine := Value; FTopLine := Value;
@ -1488,8 +1490,12 @@ end;
procedure TVpDayView.SetGranularity(Value: TVpGranularity); procedure TVpDayView.SetGranularity(Value: TVpGranularity);
begin begin
FGranularity := Value; FGranularity := Value;
SetTimeIntervals (FGranularity); SetTimeIntervals(FGranularity);
FTopLine := HourToLine(FTopHour, 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; Invalidate;
end; end;
{=====} {=====}
@ -2050,7 +2056,7 @@ begin
nPos := FTopLine; nPos := FTopLine;
nTrackPos := nPos; nTrackPos := nPos;
end; end;
SetScrollInfo (Handle, SB_VERT, SI, True); SetScrollInfo(Handle, SB_VERT, SI, True);
end; end;
{=====} {=====}

View File

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

View File

@ -445,72 +445,29 @@ end;
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer; function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
begin begin
Result := Ord(Value) * 60 div GranularityMinutes[Granularity]; 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; end;
{=====} {=====}
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer; function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
var var
LineDuration: Double; { the percentage of a day covered by each line } LineDuration: Double; // percentage of a day covered by each line
Time: Double; Time: Double;
begin begin
{ remove the date part, and add one minute to the time } { remove the date part, and add one minute to the time }
// Time := StartTime - trunc(StartTime) + (1 / MinutesInDay);
Time := frac(StartTime) + 1 / MinutesInDay; Time := frac(StartTime) + 1 / MinutesInDay;
LineDuration := GranularityMinutes[Granularity] / 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); result := trunc(Time / LineDuration);
end; end;
{=====} {=====}
function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer; function GetEndLine(EndTime: TDateTime; Granularity: TVpGranularity): Integer;
var var
LineDuration: Double; { the percentage of a day covered by each line } LineDuration: Double; // percentage of a day covered by each line
Time: Double; Time: Double;
begin begin
{ remove the date part, and subtract one minute from the time } { remove the date part, and subtract one minute from the time }
Time := frac(EndTime) - 1 / MinutesInDay; Time := frac(EndTime) - 1 / MinutesInDay;
// Time := EndTime - trunc(EndTime) - (1 / MinutesInDay);
LineDuration := GranularityMinutes[Granularity] / 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); result := trunc(Time / LineDuration);
end; end;
{=====} {=====}