Recent

Author Topic: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)  (Read 7049 times)

wp

  • Hero Member
  • *****
  • Posts: 13646
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #105 on: June 23, 2026, 10:21:29 am »
It happens occasionally that the event handler for OnDrawButton is lost after making some changes to the code. Not 100% sure but I think that the event setters are wrong: you have "if AValue <> FOnDrawButton then...", (which compares only pointers) but in TAChart there is on a similar occasion "if SameMethod(TMethod(FOnBeforeCustomDrawBackWall), TMethod(AValue)) then...". SameMethod is in unit LazMethodList (package LazUtils, required by LCL).


ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #106 on: June 23, 2026, 07:01:40 pm »
You can use widgetset defines:
Code: Pascal  [Select][+][-]
  1.       ACanvas.Pen.Color := FGColor;
  2.       ACanvas.Pen.Width := 2;
  3.      {$IFDEF LCLCocoa}
  4.       ACanvas.Line(CX-D, CY, CX+D+1, CY);
  5.       ACanvas.Line(CX, CY-D, CX, CY+D+1);
  6.      {$ELSE}  // Window; did not test Linux...
  7.       ACanvas.Line(CX-D, CY, CX + D, CY);
  8.       ACanvas.Line(CX, CY-D, CX, CY+D);
  9.      {$ENDIF}

BTW, regarding centering of lines, even pen widths are always some kind of gambling. Not tested, but maybe the issue does not occur when Pen.Width is 3?

Done! A pen width of 3 doesn't help.

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #107 on: June 23, 2026, 07:02:44 pm »
I am wondering, isn't it better to set Skip:=True by default? In this way, if a user accidentally assings a method to the OnDraw event the Tabs/Buttons will not appear empty. Then, the user that really wants to do the custom drawing is responsible for setting Skip:=False. What do you think?
Oh, i hadn't thought about yet at all what should be the default for this parameter, but as you mention it:
Yes, i'd see it the same way, with the same argument.

Done! Can you check that it works?

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #108 on: June 23, 2026, 07:04:09 pm »
It happens occasionally that the event handler for OnDrawButton is lost after making some changes to the code. Not 100% sure but I think that the event setters are wrong: you have "if AValue <> FOnDrawButton then...", (which compares only pointers) but in TAChart there is on a similar occasion "if SameMethod(TMethod(FOnBeforeCustomDrawBackWall), TMethod(AValue)) then...". SameMethod is in unit LazMethodList (package LazUtils, required by LCL).

I will look into this (I had noticed that the event was disappearing, but assumed that it was because I was changing the signature of the method).

d7_2_laz

  • Hero Member
  • *****
  • Posts: 696
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #109 on: June 23, 2026, 08:05:32 pm »
I am wondering, isn't it better to set Skip:=True by default? In this way, if a user accidentally assings a method to the OnDraw event the Tabs/Buttons will not appear empty. Then, the user that really wants to do the custom drawing is responsible for setting Skip:=False. What do you think?
Oh, i hadn't thought about yet at all what should be the default for this parameter, but as you mention it:
Yes, i'd see it the same way, with the same argument.

Done! Can you check that it works?
Yes, the mechanism itself does work fine and just as discussed.
The only mini-question from my side: i understood your last note so that you'd rather prefer to pass True as default value for the Skip parameter of the OnDrawButton event (for the reasons mentioned). I see False; did i misunerstand something?
Lazarus 4.8  FPC 3.2.2 Win11 64bit

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #110 on: June 23, 2026, 09:31:15 pm »
Yes, the mechanism itself does work fine and just as discussed.
The only mini-question from my side: i understood your last note so that you'd rather prefer to pass True as default value for the Skip parameter of the OnDrawButton event (for the reasons mentioned). I see False; did i misunerstand something?

Sorry, I forgot to push the changes. Now you should see them.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 696
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #111 on: June 23, 2026, 10:24:23 pm »
Yes, right; -> ok!
Lazarus 4.8  FPC 3.2.2 Win11 64bit

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #112 on: June 24, 2026, 09:18:24 am »
It happens occasionally that the event handler for OnDrawButton is lost after making some changes to the code. Not 100% sure but I think that the event setters are wrong: you have "if AValue <> FOnDrawButton then...", (which compares only pointers) but in TAChart there is on a similar occasion "if SameMethod(TMethod(FOnBeforeCustomDrawBackWall), TMethod(AValue)) then...". SameMethod is in unit LazMethodList (package LazUtils, required by LCL).

You are right. According to Free Pascal's documentation (https://www.freepascal.org/docs-html/ref/refse17.html): "When comparing two variables of type method, only the method’s address is compared, not the instance pointer". I have updated the code, to use SameMethod.

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #113 on: June 27, 2026, 07:57:04 am »
Hi. I have started working on the new component, combining `TExtTabCtrl` with a `TNotebook`, but so far I haven't been able to make it work. No matter what I try, the designer doesn't recognize the `TNotebook` pages as valid containers for components. Does anybody know of any similar component that does this, so I could take a look at how it is implemented?

wp

  • Hero Member
  • *****
  • Posts: 13646
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #114 on: June 27, 2026, 01:45:14 pm »
I know of two controls which combine different controls:
- TLabeledEdit is still a TCustomEdit and has a label under its hood, but the combination has the disadvantage that several typical LCL properties (Align, Anchoring, AutoSize) are not working as expected.
- TButtonEdit and its descendants TFileNameEdit, TDirectoryEdit, etc inherit only from TCustomControl and combine a TCustomMaskEdit and a "Buddy" control as a button.

Never tried something like this, but both look very complicated.

In your specific case, TNotebook seems to be rather simple - there are only 7 private and 4 public methods, and most them are needed to handle the tab list which is already available in your TExtTabCtrl. Therefore I would suggest to just inherit TExtPageCtrl from TExtTabCtrl and add adjusted methods of TNotebook to it rather than creating an instance of TNotebook within TExtPageCtrl.

For accepting other controls as children of notebook pages the pages must be created with ControlStyle csAcceptsControls (see TPage.Create, in (lazarus)/lcl/include/page.inc)

d7_2_laz

  • Hero Member
  • *****
  • Posts: 696
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #115 on: June 27, 2026, 02:20:17 pm »
There's also the TExtendedNotebook (and a TExtendedTabControl) from the LazControls which appear to combine the tab and containers elements, see https://wiki.lazarus.freepascal.org/Differences_between_multi-page_controls

Lazarus 4.8  FPC 3.2.2 Win11 64bit

wp

  • Hero Member
  • *****
  • Posts: 13646
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #116 on: June 27, 2026, 02:32:38 pm »
Are you sure? TExtendedNotebook inherits directly from TPageControl and thus has combined tabs and pagesheets automatically. And TExtendedTabControl, likewise, descends from TTabControl and therefore has only a single page.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 696
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #117 on: June 27, 2026, 02:59:32 pm »
Not sure wp., I don't know them myself, but from the statement:
Quote
The TExtendedNotebook however provides an integrated tab header again. In fact making it the same as a TPageControl. It even exposes TTabSheets and not TPage subpage elements.
i thought it could be at least worthy to share the link.
Lazarus 4.8  FPC 3.2.2 Win11 64bit

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #118 on: June 28, 2026, 07:23:31 pm »
Thank you both. I'm reviewing these components and trying to implement the new one, but so far I haven't had any luck. I'll keep you updated if I make any progress.

ovidio

  • Jr. Member
  • **
  • Posts: 70
Re: [New Component] ExtTabCtrl - A custom, feature-rich tab control (LGPL)
« Reply #119 on: June 30, 2026, 09:45:51 am »
I finally got the component working! In the end, the solution was to avoid using TNotebook directly and instead inherit from TNotebook's page class. The component is functional now, although it's still far from polished. I've pushed it to a branch called ExtPageCtrl.

If you have a chance, could you give it a try? I'd really appreciate your feedback, both your overall impressions and any suggestions you have for improving the component.

 

TinyPortal © 2005-2018