TMSFMXPlanner header text alignment problem


I got a small but annoying problem in the FMXPlanner-component:
The planner is used in multiday-mode, depicting a single day, timeline only on the left and displays the current date in the header, right between the two navigator buttons.
The problem, which I only recognized after increasing the size of the navigator buttons, is, that the centered alignment of the header text (PositionsAppearance.TopHorizontalTextAlign := ptaCenter) doesn't take the right navigator-button into account.
Instead it seems to me, that the alignment only takes into account the timelines, which works fine, if you you use timelines on both sides, but doesn't work well with only one timeline on the left side, which causes the text to be displayed more or less off the center, depending on the size of the right navigator button, or in the worst case even cut off by the button.

It would be nice to know, whether I overlooked something, or, if not, whether there is an easy workaround for that.


We have investigated this here but aren't able to reproduce this issue.
Please provide a sample so we can investigate this here.

Allright, I have reproduced the issue in a new project by doing the following steps:

1. Put the TMSFMXPlanner on the form.
2. Set Positions.Count from 3 to 1.
3. Activate both TopNavigationButtons in Interaction.

If you now increase the TopRightNavigationButtonSize in PositionsAppearances you can see that the centered text (displaying the current day name) between them doesn´t adjust its position, because its alignment is tied to the timelines and not the buttons.
You can clearly see that behavior when you activate the timeline on the right as well or deactivate the left timeline or just play with the timeline-size, which causes the text alignment to adjust accordingly.

It might very well be that this is the intented way it was designed.
I would however in terms of optical appearance expect the text to adjust itself according to the buttons, when only one timeline is active, as the centered alignment looks odd when there is less space between the text and one button than between the text and the other.

In my case I also display the current day in the long date format, which can cause the text to be cut off by the right button on smaller displays.

It is, as said, not a big problem, as I can, if necessary, consider activating both timelines or aligning the text to the left, but I first wanted to ask, if there is maybe an easy way to keep my current design.


This is by design. The text is centered according to the width of the column. If you want to change this behaviour, you can use the following code, which can be applied if the navigation button size exceeds the time line left size or the width of the scroll bar

procedure TForm1.FormCreate(Sender: TObject);
  TMSFMXPlanner1.Positions.Count := 1;
  TMSFMXPlanner1.Interaction.TopNavigationButtons := [pnbPrevious, pnbNext];
  TMSFMXPlanner1.PositionsAppearance.TopLeftNavigationButtonSize := 100;
  TMSFMXPlanner1.PositionsAppearance.TopRightNavigationButtonSize := 200;

procedure TForm1.TMSFMXPlanner1BeforeDrawPositionText(Sender: TObject;
  ACanvas: TCanvas; ARect: TRectF; APosition: Integer;
  AKind: TTMSFMXPlannerCacheItemKind; AText: string; var AAllow: Boolean);
  r: TRectF;
  AAllow := False;
  r := ARect;
  r.Left := r.Left + TMSFMXPlanner1.PositionsAppearance.TopLeftNavigationButtonSize - TMSFMXPlanner1.TimeLineAppearance.LeftSize;
  r.Right := r.Right - TMSFMXPlanner1.PositionsAppearance.TopRightNavigationButtonSize + TMSFMXPlanner1.VerticalScrollBar.Width;
  ACanvas.FillText(r, AText, False, 1, [], TTextAlign.Center);

Thank you very much!

That was exactly what I was looking for.