You've already forked lazarus-ccr
tvplanit: Fix painting of GanttView events in hour mode.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8940 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -483,6 +483,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpGanttEventList.AddSingleEvent(AEvent: TVpEvent): PVpGanttEventRec;
|
function TVpGanttEventList.AddSingleEvent(AEvent: TVpEvent): PVpGanttEventRec;
|
||||||
|
const
|
||||||
|
EPS = 1e-9;
|
||||||
var
|
var
|
||||||
eventRec: PVpGanttEventRec;
|
eventRec: PVpGanttEventRec;
|
||||||
dt1, dt2: TDateTime;
|
dt1, dt2: TDateTime;
|
||||||
@ -491,7 +493,7 @@ begin
|
|||||||
if AEvent.AllDayEvent then
|
if AEvent.AllDayEvent then
|
||||||
begin
|
begin
|
||||||
dt1 := DatePart(AEvent.StartTime);
|
dt1 := DatePart(AEvent.StartTime);
|
||||||
dt2 := DatePart(AEvent.EndTime) + 1;
|
dt2 := DatePart(AEvent.EndTime) + 1 - EPS;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
dt1 := AEvent.StartTime;
|
dt1 := AEvent.StartTime;
|
||||||
@ -786,10 +788,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpGanttColHeaderAttributes.SetVisible(AValue: TVpGanttColHeaderKinds);
|
procedure TVpGanttColHeaderAttributes.SetVisible(AValue: TVpGanttColHeaderKinds);
|
||||||
|
var
|
||||||
|
HourModeChanged: Boolean;
|
||||||
|
d: TDateTime;
|
||||||
begin
|
begin
|
||||||
if FVisible <> AValue then
|
if FVisible <> AValue then
|
||||||
begin
|
begin
|
||||||
|
HourModeChanged := (gchHour in FVisible) <> (gchHour in AValue);
|
||||||
FVisible := AValue;
|
FVisible := AValue;
|
||||||
|
if HourModeChanged then
|
||||||
|
begin
|
||||||
|
d := FGanttView.ActiveDate;
|
||||||
|
FGanttView.Init;
|
||||||
|
FGanttView.FActiveDate := 0; // Enforce execution of SetActiveDate
|
||||||
|
FGanttView.SetActiveDate(d);
|
||||||
|
end;
|
||||||
UpdateGanttView;
|
UpdateGanttView;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1781,7 +1794,9 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
xh1, xh2, y1, xe1, xe2, y2: Integer;
|
xh1, xh2, y1, xe1, xe2, y2: Integer;
|
||||||
t1, t2: TDateTime;
|
t1, t2: TDateTime;
|
||||||
totalWidth: Integer;
|
startHr, endHr: TDateTime;
|
||||||
|
dayWidth, totalWidth: Integer;
|
||||||
|
dayFactor, hourFactor: Double;
|
||||||
begin
|
begin
|
||||||
if (Datastore = nil) or (DataStore.Resource = nil) then
|
if (Datastore = nil) or (DataStore.Resource = nil) then
|
||||||
exit;
|
exit;
|
||||||
@ -1817,6 +1832,11 @@ begin
|
|||||||
xh2 := FixedColWidth;
|
xh2 := FixedColWidth;
|
||||||
y1 := FTotalColHeaderHeight;
|
y1 := FTotalColHeaderHeight;
|
||||||
totalWidth := CalcDaysWidth(GetNumDays);
|
totalWidth := CalcDaysWidth(GetNumDays);
|
||||||
|
dayWidth := CalcDaysWidth(1);
|
||||||
|
startHr := ord(FStartHour) / 24;
|
||||||
|
endHr := (ord(FEndHour) + 1) / 24; // extend to the end of the endhour box
|
||||||
|
dayFactor := totalWidth / GetNumDays;
|
||||||
|
hourFactor := dayWidth / HoursPerDay * 24;
|
||||||
for i := 0 to FEventRecords.Count-1 do
|
for i := 0 to FEventRecords.Count-1 do
|
||||||
begin
|
begin
|
||||||
eventRec := FEventRecords[i];
|
eventRec := FEventRecords[i];
|
||||||
@ -1825,8 +1845,25 @@ begin
|
|||||||
|
|
||||||
// Store event rectangle coordinates in the EventRec
|
// Store event rectangle coordinates in the EventRec
|
||||||
y2 := y1 + FRowHeight;
|
y2 := y1 + FRowHeight;
|
||||||
|
if HourMode then
|
||||||
|
begin
|
||||||
|
// Visible beginning of day at which the event starts
|
||||||
|
xe1 := round((DatePart(t1) - FRealStartDate) * dayFactor) + FixedColWidth;
|
||||||
|
// Add time part if event starts after FStartHour
|
||||||
|
if TimePart(t1) >= startHr then
|
||||||
|
xe1 := xe1 + round((TimePart(t1) - startHr) * hourFactor);
|
||||||
|
// Visible beginning of day at which the event ends
|
||||||
|
xe2 := round((DatePart(t2) - FRealStartDate) * dayFactor) + FixedColWidth;
|
||||||
|
// Add time part of event end, clipped at end of EndHour.
|
||||||
|
if TimePart(t2) <= endHr then
|
||||||
|
xe2 := xe2 + round((TimePart(t2) - startHr) * hourFactor)
|
||||||
|
else
|
||||||
|
xe2 := xe2 + round((endHr - startHr) * hourFactor);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
xe1 := round((t1 - FRealStartDate) / numDays * totalWidth) + FixedColWidth;
|
xe1 := round((t1 - FRealStartDate) / numDays * totalWidth) + FixedColWidth;
|
||||||
xe2 := round((t2 - FRealStartDate) / numDays * totalWidth) + FixedColWidth;
|
xe2 := round((t2 - FRealStartDate) / numDays * totalWidth) + FixedColWidth;
|
||||||
|
end;
|
||||||
if xe1 = xe2 then xe2 := xe1 + 1;
|
if xe1 = xe2 then xe2 := xe1 + 1;
|
||||||
|
|
||||||
eventRec^.HeadRect := Rect(xh1, y1, xh2, y2);
|
eventRec^.HeadRect := Rect(xh1, y1, xh2, y2);
|
||||||
|
@ -113,9 +113,14 @@ begin
|
|||||||
);
|
);
|
||||||
OffsetRect(R, -dx, -dy);
|
OffsetRect(R, -dx, -dy);
|
||||||
|
|
||||||
|
if R.Right < FScaledFixedColWidth then
|
||||||
|
exit;
|
||||||
if R.Top < FScaledTotalColHeaderHeight then
|
if R.Top < FScaledTotalColHeaderHeight then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
if R.Left < FScaledFixedColWidth then
|
||||||
|
R.Left := FScaledFixedColWidth;
|
||||||
|
|
||||||
pw := RenderCanvas.Pen.Width;
|
pw := RenderCanvas.Pen.Width;
|
||||||
bs := RenderCanvas.Brush.Style;
|
bs := RenderCanvas.Brush.Style;
|
||||||
RenderCanvas.Pen.Width := 3;
|
RenderCanvas.Pen.Width := 3;
|
||||||
@ -350,7 +355,7 @@ var
|
|||||||
dx, dy: Integer;
|
dx, dy: Integer;
|
||||||
i, n, numEvents: Integer;
|
i, n, numEvents: Integer;
|
||||||
eventRec: PVpGanttEventRec;
|
eventRec: PVpGanttEventRec;
|
||||||
dayRec: TVpGanttDayRec;
|
// dayRec: TVpGanttDayRec;
|
||||||
monthRec: TVpGanttMonthRec;
|
monthRec: TVpGanttMonthRec;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
@ -394,6 +399,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Vertical lines
|
// Vertical lines
|
||||||
|
RenderCanvas.Brush.Style := bsClear;
|
||||||
if (gvoVertGrid in FGanttView.Options) then
|
if (gvoVertGrid in FGanttView.Options) then
|
||||||
begin
|
begin
|
||||||
y1 := RealTop + FScaledTotalColHeaderHeight;
|
y1 := RealTop + FScaledTotalColHeaderHeight;
|
||||||
@ -402,11 +408,20 @@ begin
|
|||||||
eventRec := FGanttView.EventRecords[numEvents-1];
|
eventRec := FGanttView.EventRecords[numEvents-1];
|
||||||
R := ScaleRect(eventRec^.EventRect);
|
R := ScaleRect(eventRec^.EventRect);
|
||||||
y2 := R.Bottom - dy;
|
y2 := R.Bottom - dy;
|
||||||
n := FGanttView.NumDays;
|
n := FGanttView.ColCount;
|
||||||
for i := 0 to n-1 do
|
for i := 0 to n-1 do
|
||||||
begin
|
begin
|
||||||
dayRec := FGanttView.DayRecords[i];
|
RenderCanvas.Pen.Style := psSolid;
|
||||||
R := ScaleRect(dayRec.Rect);
|
if FGanttView.HourMode then
|
||||||
|
begin
|
||||||
|
R := ScaleRect(FGanttView.HourRecords[i].Rect);
|
||||||
|
if (i+1) mod FGanttView.HoursPerDay <> 0 then
|
||||||
|
RenderCanvas.Pen.Style := psDot;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
R := ScaleRect(FGanttView.DayRecords[i].Rect);
|
||||||
|
// dayRec := FGanttView.DayRecords[i];
|
||||||
|
// R := ScaleRect(dayRec.Rect);
|
||||||
x1 := R.Right - dx;
|
x1 := R.Right - dx;
|
||||||
if x1 >= FScaledFixedColWidth then
|
if x1 >= FScaledFixedColWidth then
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user