Recent

Author Topic: [solved] TPageControl - Format Captions of Tabsheets  (Read 820 times)

Nicole

  • Sr. Member
  • ****
  • Posts: 331
[solved] TPageControl - Format Captions of Tabsheets
« on: July 28, 2022, 08:00:27 am »
The captions of my tabsheets look very narrow. I would like the words to have more inner space.
So there shall not be
|myCaption|

but

|  myCaption  |

Theoretically, I can do this by the space bar. Practically this is ugly, because the space would depend on the fonts-type and will not help me for top and bottom.
« Last Edit: July 29, 2022, 09:15:26 am by Nicole »

dje

  • Full Member
  • ***
  • Posts: 107
Re: TPageControl - Format Captions of Tabsheets
« Reply #1 on: July 28, 2022, 10:38:17 am »
What os/widget interface are you using? Have you tried TabWidth?

Its doesn't work for me, since as far as I can see, the nbcTabsSizeable capability is only implemented for Windows and QT. (Im using GTK)

Apart from that, you either have to "roll your own" control, or use another control with TNoteBook, or find a custom TPageControl that supports tab resizing, or (if you using GTK) try to implement nbcTabsSizeable.

Nicole

  • Sr. Member
  • ****
  • Posts: 331
Re: TPageControl - Format Captions of Tabsheets
« Reply #2 on: July 28, 2022, 12:07:59 pm »
Thank you so much for the hint.
It works and does not.

Tabwith sets all Tabs to the same widths (0 does an autosize).
This means, my short captions are sized nicely, my long captions are capped on both sides.

I will think about generating captions about the same length to solve it in a quick way.

wp

  • Hero Member
  • *****
  • Posts: 10030
Re: TPageControl - Format Captions of Tabsheets
« Reply #3 on: July 28, 2022, 12:59:20 pm »
TPageControl is drawn by the widgetset, i.e. by Windows (I suppose you are on Windows). If the tabs are too narrow for you, the pagecontrol tabs in other programs will be too narrow as well. So, when you accept the tabs in other programs then why don't you accept the tabs in your application, too? If you cannot accept this, then you could only
- increase the tab width by adding spaces to the Caption (Tabsheet1.Caption := '   Raw data   ') (I would not consider this to be "ugly").
- switch to some third-party pagecontrol which gives you more control over the tab width or tab caption margin.

Nicole

  • Sr. Member
  • ****
  • Posts: 331
Re: TPageControl - Format Captions of Tabsheets
« Reply #4 on: July 28, 2022, 01:15:18 pm »
Yes, Windows.

Code: Diff  [Select][+][-]
  1.  If the tabs are too narrow for you, the pagecontrol tabs in other programs will be too narrow as well. So, when you accept the tabs

I do not accept this, I do not know, how to change!
Would be nice to have more space around in some cases.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5119
Re: TPageControl - Format Captions of Tabsheets
« Reply #5 on: July 28, 2022, 02:33:09 pm »
Theoretically, I can do this by the space bar. Practically this is ugly, because the space would depend on the fonts-type and will not help me for top and bottom.

Try using a Unicode em-space character, or a nonbreaking space. Please report back if these aren't handled properly, or if Trim() etc. subsequently return unexpected results.

Edited: there's a list of the various kinds of spaces at https://en.wikipedia.org/wiki/Whitespace_characters , you should find that the IDE can insert them (see bottom of edit menu, and look for the "General Punctuation" block) even though they're not well labelled.

MarkMLl
« Last Edit: July 28, 2022, 02:47:54 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dje

  • Full Member
  • ***
  • Posts: 107
Re: TPageControl - Format Captions of Tabsheets
« Reply #6 on: July 29, 2022, 08:07:22 am »
Yes, Windows.

Ok, so, if you check though the Windows implementation for SetTabSize you will find:
Code: Pascal  [Select][+][-]
  1. class procedure TWin32WSCustomTabControl.SetTabSize(
  2.   const ATabControl: TCustomTabControl;
  3.   const ATabWidth, ATabHeight: integer);
  4. begin
  5.   if ATabControl is TTabControl then
  6.     exit;
  7.   Windows.SendMessage(ATabControl.Handle, TCM_SETITEMSIZE,
  8.     0, MakeLParam(ATabWidth, ATabHeight));
  9. end;  

If you look up the documentation for TCM_SETITEMSIZE you find:
https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setitemsize

You then see a Windows Vista (minimum) feature called TCM_SETPADDING
https://docs.microsoft.com/en-us/windows/win32/controls/tcm-setpadding

TCM_SETPADDING isn't used anywhere in Lazarus 2.0.10, but is defined in FreePascal. ie: Windows unit contains TabCtrl_SetPadding()

So, you could go with a Windows Vista (minimum) implementation by sending this message explicitly. I'm not on a Windows machine anymore, so I can't help you with that. Ideally, if all Widget sets supported such a feature, it might get included in LCL. I also don't know if Delphi supports such a feature, which would give the LCL developers a "standard" way to add the property to Lazarus.

Either way, Hope that helps.

Nicole

  • Sr. Member
  • ****
  • Posts: 331
Re: TPageControl - Format Captions of Tabsheets
« Reply #7 on: July 29, 2022, 09:15:04 am »
Thank you so much for this verbose and interesting answer (saved in my records)

 

TinyPortal © 2005-2018