diff --git a/components/tvplanit/source/vpdayview.pas b/components/tvplanit/source/vpdayview.pas index 9c8eb6ef7..c9ceeb0d2 100644 --- a/components/tvplanit/source/vpdayview.pas +++ b/components/tvplanit/source/vpdayview.pas @@ -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; @@ -1488,8 +1490,12 @@ end; procedure TVpDayView.SetGranularity(Value: TVpGranularity); begin FGranularity := Value; - SetTimeIntervals (FGranularity); + 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; {=====} @@ -2050,7 +2056,7 @@ begin nPos := FTopLine; nTrackPos := nPos; end; - SetScrollInfo (Handle, SB_VERT, SI, True); + SetScrollInfo(Handle, SB_VERT, SI, True); end; {=====} diff --git a/components/tvplanit/source/vpdayviewpainter.pas b/components/tvplanit/source/vpdayviewpainter.pas index 192185b4d..ac86b6244 100644 --- a/components/tvplanit/source/vpdayviewpainter.pas +++ b/components/tvplanit/source/vpdayviewpainter.pas @@ -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); diff --git a/components/tvplanit/source/vpmisc.pas b/components/tvplanit/source/vpmisc.pas index 6f18063da..304cedd93 100644 --- a/components/tvplanit/source/vpmisc.pas +++ b/components/tvplanit/source/vpmisc.pas @@ -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; {=====}