FNC Planner (FireMonkey) Need method to get Positions/Resource rectangles

I use this to draw above and under the planner, some custom info panels, now i use the OnAfterDrawPosition event, but this does not always fire, so sometimes i'm behind with the correct left,right of my own panels.
Would be nice to have a method to retrieve the current correct Rect for a position. (One at a time or all at once in an array/list)

Hi,

You could use the following approach with a protected class wrapper:

type
  TTMSFNCPlannerOpen = class(TTMSFNCPlanner);

procedure TForm1.TMSFNCPlanner1AfterDraw(Sender: TObject;
  AGraphics: TTMSFNCGraphics; ARect: TRectF);
var
  w, p: Single;
  c: Integer;
  I: Integer;
  pr: TRectF;
  pl: TTMSFNCPlannerOpen;
  tr: TRectF;
  x: Single;
begin
  pl := TTMSFNCPlannerOpen(TMSFNCPlanner1);
  tr := pl.GetPositionsTopRect;
  x := -pl.GetHorizontalScrollPosition + tr.Left;
  c := pl.ColumnCount;
  for I := 0 to c - 1 do
  begin
    w := pl.ColumnWidths[I];
    p := pl.ColumnPositions[I];
    pr := RectF(x + p, tr.Top, x + p + w, tr.Bottom);
    AGraphics.Stroke.Color := gcRed;
    AGraphics.DrawRectangle(pr);
  end;
end;

Ok, gonna try that.
I now have this hack

    if Assigned(Planner.PositionsTopCache) then
       for item in Planner.PositionsTopCache do
       begin
          custom := FetchCustom(item.Position);
          PositionItem(custom, item.DrawRect);
       end;

Hacked the PositionsTopCache to public :slight_smile:
gonna try your method now.

1 Like