diff --git a/components/tvplanit/source/vpprtfmt.pas b/components/tvplanit/source/vpprtfmt.pas index 782230af5..b5c1e4cab 100644 --- a/components/tvplanit/source/vpprtfmt.pas +++ b/components/tvplanit/source/vpprtfmt.pas @@ -83,17 +83,18 @@ } {$I vp.inc} +{$DEFINE DEBUG_VP_PRINTER} unit VpPrtFmt; interface uses - {$IFDEF LCL} - LCLProc, LCLType, LCLIntf, - {$ELSE} + {$IFDEF LCL} + {$IFDEF DEBUG_VP_PRINTER}LazLogger,{$ENDIF} LCLProc, LCLType, LCLIntf, + {$ELSE} Windows, - {$ENDIF} + {$ENDIF} Classes, Dialogs, SysUtils, Graphics, Forms, Printers, VpBase, VpData, VpXParsr, VpCanvasUtils, VpSR, VpException; @@ -1679,6 +1680,9 @@ var True ); FLastTask := RenderControl.GetLastPrintLine; + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.PaintToCanvasRect.RenderItem] FLastTask = %d', [FLastTask]); + {$ENDIF} end; itContacts: @@ -1696,6 +1700,9 @@ var True ); FLastContact := RenderControl.GetLastPrintLine; + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.PaintToCanvasRect.RenderItem] FLastContact = %d', [FLastContact]); + {$ENDIF} end; itGanttView: @@ -1745,6 +1752,10 @@ var elem: TVpPrintFormatElementItem; begin + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.PaintToCanvas] ENTER'); + {$ENDIF} + CheckPrintFormat; if not FPrintJob then begin @@ -1767,6 +1778,10 @@ begin if elem.ItemType = itGanttView then elem.DayOffsetUnits := duDay; + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TvpPrinter.PaintToCanvasRect] i = %d, elem.ElementName = %s', [i, elem.ElementName]); + {$ENDIF} + GetPrintRectangle(elem); if elem.ItemType = itCaption then begin @@ -1796,6 +1811,10 @@ begin end else RenderItem(elem); end; + + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.PaintToCanvas] EXIT'); + {$ENDIF} end; {=====} @@ -1883,6 +1902,10 @@ var Done: Boolean; begin + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.Print] ENTER'); + {$ENDIF} + CheckPrintFormat; FHaveDate := False; @@ -1939,7 +1962,7 @@ begin This is a bit involved. If only dates, captions and shapes are in the print format, doneness is determined when the date passes the end date. If task lists or contact grids are on the format, then doneness occurs - when the date has bumped pass the last date and all the tasks and + when the date has bumped past the last date and all the tasks and contacts have been printed. } Done := True; if FHaveDate and (CurDate <= RealEndDate) then @@ -1953,6 +1976,12 @@ begin with FOwner as TVpControlLink do TriggerOnPageEnd(Self, PageNum, CurDate, Done); + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.Print] CurDate = %s (%.2f), LastTask = %d, LastContact = %d, Done = %s', [ + DateToStr(CurDate), CurDate, FLastTask, FLastContact, BoolToStr(Done, true) + ]); + {$ENDIF} + { Go to the next page if not done } if not Done then begin Printer.NewPage; @@ -1962,8 +1991,11 @@ begin finally FPrintJob := False; end; + + {$IFDEF DEBUG_VP_PRINTER} + DebugLn('[TVpPrinter.Print] EXIT'); + {$ENDIF} end; -{=====} procedure TVpPrinter.RegisterWatcher(Watcher: THandle); var diff --git a/components/tvplanit/source/vptasklistpainter.pas b/components/tvplanit/source/vptasklistpainter.pas index 06185cd34..1508d6e97 100644 --- a/components/tvplanit/source/vptasklistpainter.pas +++ b/components/tvplanit/source/vptasklistpainter.pas @@ -1,10 +1,12 @@ unit VpTasklistPainter; {$I vp.inc} +{$DEFINE DEBUG_VP_TASKLISTPAINTER} interface uses + {$IFDEF DEBUG_VP_TASKLISTPAINTER}LazLogger{$ENDIF}, SysUtils, LCLType, LCLIntf, Classes, Graphics, Types, VpConst, VpBase, VpTaskList, VpBasePainter; @@ -330,8 +332,13 @@ var CheckRect: TRect; DisplayStr: string; begin + {$IFDEF DEBUG_VP_TASKLISTPAINTER} + DebugLn('[TVpTaskListPainter.DrawTasks] ENTER: StartLine = %d', [StartLine]); + {$ENDIF} + xLeft := RealLeft + 2; xRight := xLeft + RealWidth - 3; + with TVpTaskListOpener(FTaskList) do begin if (DataStore = nil) or (DataStore.Resource = nil) or @@ -374,8 +381,10 @@ begin {$IF VP_LCL_SCALING = 0} RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI); {$ENDIF} + for I := StartLine to pred(tlAllTaskList.Count) do begin task := tlAllTaskList[I]; + // if (LineRect.Top + round(0.5 * RowHeight) <= RealBottom) then begin // wp: here the last row of the page could be truncated in height. if (LineRect.Bottom <= RealBottom) then begin // If this is the selected task and we are not in edit mode, // then set background selection. @@ -446,18 +455,31 @@ begin Break; end; end; - if tlVisibleItems + tlItemsBefore = tlAllTaskList.Count then begin + + {$IFDEF DEBUG_VP_TASKLISTPAINTER} + DebugLn('[TVpTaskListPainter.DrawTasks] tlVisibleItems = %d, tlItemsBefore = %d, tlAllTaskList.Count = %d', [ + tlVisibleItems, tlItemsBefore, tlAllTaskList.Count + ]); + {$ENDIF} + +// if tlVisibleItems + tlItemsBefore = tlAllTaskList.Count then begin // wp: here the last page would be duplicate + if Startline + tlVisibleItems >= tlAllTaskList.Count then begin FLastPrintLine := -2; tlItemsAfter := 0; end else begin tlItemsAfter := tlAllTaskList.Count - tlItemsBefore - tlVisibleItems; end; - { these are for the syncing the scrollbar } + // These are for syncing the scrollbar if StartLine < 0 then tlItemsBefore := 0 else tlItemsBefore := StartLine; + + {$IFDEF DEBUG_VP_TASKLISTPAINTER} + DebugLn('[TVpTaskListPainter.DrawTasks] EXIT: StartLine = %d, LastPrintLine = %d', [StartLine, FLastPrintLine]); + {$ENDIF} + end; // with TVpTaskListOpener(FTaskList)... end;