Recent

Author Topic: TreeNode with caption containing "Tab" character  (Read 823 times)

flowCRANE

  • Hero Member
  • *****
  • Posts: 926
TreeNode with caption containing "Tab" character
« on: January 25, 2024, 02:50:24 pm »
I wanted the nodes in the TTreeView control to have a caption containing a numeric font ID, then a horizontal tab, followed by the font name. Thanks to the tabulator, font names would be aligned and thus more readable. Unfortunately, from what I can see, the tab character is ignored, in addition, not only when it comes to tree nodes, but also other controls (e.g. TButton).


1. Is there any specific reason why the horizontal tab character is ignored when rendering text in standard controls?

2. Is there any way to force the horizontal tab to be respected and thus have the caption auto-aligned in TTreeNode (and other standard controls)? Of course other than manually rendering node content or making wider spaces using space characters.
Lazarus 4.0 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

Zvoni

  • Hero Member
  • *****
  • Posts: 2964
Re: TreeNode with caption containing "Tab" character
« Reply #1 on: January 25, 2024, 04:52:38 pm »
At a guess:
because the Caption itself doesn't know where the Tab-Stop is.
A Tab is usually a (predefined) sequence of spaces.
Say 1 Tab = 4 Spaces
IIRC, in the Lazarus-IDe you can change the "width" of a Tab (say, from 4 to 8, or whatever)

That said: From where is the Caption going to know how many "spaces" to jump forward?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

flowCRANE

  • Hero Member
  • *****
  • Posts: 926
Re: TreeNode with caption containing "Tab" character
« Reply #2 on: January 25, 2024, 05:22:51 pm »
For example, in Win32 interface, if the control caption is rendered using the DrawText function, it can contain tab characters and they will be expanded if the DT_EXPANDTABS flag is used. The caption of the TLabel control is rendered using this flag, thanks to which labels can contain tabulators and have adjustable text. But for some reason, text in controls of other types is either not rendered using this function or the mentioned flag is not used.
« Last Edit: January 25, 2024, 05:27:54 pm by furious programming »
Lazarus 4.0 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

 

TinyPortal © 2005-2018