Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-07

New TTabControl

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho
to Hans-Peter Diettrich: Thanks for the attempt to replace the old TTabControl by the new implementation :-) There…

Hello,

Hans-Peter Diettrich wrote
There seem to exist some issues with the new implementation, so that I'll give some background information, about the new TCustomTabControl and descendants.

Your implementation did not work, so I deleted most of it's code and now TTabControl basically works as a TPageControl until the implementation is finished.

The basic TCustomTabControl does not have pages any more,

I think that it has in the current Lazarus svn.

Show quoted text 5 lines
The new TCustomTabControl has been implemented and tested *only* with the Win32 widgetset, because I don't know about implementation details of other widgetsets. When an AV occurs in an widgetset, due to improper use of an TCustomPage parameter, the related code should be skipped when tabctrl.IsUnpaged is True.

Are you sure? I think that it shouldn't give any AVs now, and it works in all widgetsets. I did not commit exactly your changes.

It also may be a good idea to move the ChildClassAllowed method from TCustomTabControl into TPageControl, because the basic control is not restricted to TTabSheet descendants for its child controls.

I think that the priority should be getting the widgetsets to be able to implement IsUnpaged.

For now I'd suggest to restore the TTabControl to its prior version, before SVN 31782, and to successively fix the other (non-Win32) widgetsets.

Fix what? AFAIK the latest svn works fine everywhere. Maybe you need to update your svn, because there were some problems after my initial commits, but then I fixed some things.

Plus, the old TTabControl was completely broken and had a completely wrong class hierarchy, so reverting it doesn't fix anything.

Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich

Thanks for the attempt to replace the old TTabControl by the new implementation :-)

There seem to exist some issues with the new implementation, so that I'll give some background information, about the new TCustomTabControl and descendants.

The basic TCustomTabControl does not have pages any more, these are added only in derived controls (TPageControl). Instead any kind of controls can be shown with a tab, as implemented in TTabControl. While tabs can be added at design time to a TTabControl, associated controls (currently) have to be assigned at runtime, to
tabctl.Tabs.Objects[tabindex]. These controls can have any parent, and can be used for any purpose. The current TTabControl default is to show an associated control when a tab is selected, and to hide all other associated controls, so that the behaviour is very close to a TPageControl. This behaviour can be overriden by an OnChange handler, and should be made optional by a property (e.g. ShowPages) in the next version.

A TPageControl only adds support for constructing and adding pages at designtime, and allows to hide single tabs programmatically. Docking features are not really new in the TPageControl, the EasyDockManager already uses something like a TTabControl internally, for notebook docking.

Unfortunately the widgetset interface uses TCustomPage parameters to transfer arguments to the widgetsets. I don't understand why the widgetsets have to bother with pages at all, when associated controls can be shown without any special widgetset support, as demonstrated in the new TTabControl (see above). All these problems would disappear, when the support for associated pages would be removed from the widgetset interface. At least the Win32 native tabbed control has no idea of associated pages, so that all support for pages can (and should) be implemented in TPageControl.

But as long as the interface is as it currently is, we'll have to live with all the page-related problems. All widgetsets have to distinguish between basic unpaged controls (TCustomTabControl) paged controls (TPageControl). For that distinction a property IsUnpaged has been added to the TCustomTabControl. When IsUnpaged is True, a widgetset should *never* try to treat an TCustomPage parameter as a visible control, instead it only should read the properties of that control, as required. E.g. the text of an tab can be retrieved from page.Caption.

The new TCustomTabControl has been implemented and tested *only* with the Win32 widgetset, because I don't know about implementation details of other widgetsets. When an AV occurs in an widgetset, due to improper use of an TCustomPage parameter, the related code should be skipped when tabctrl.IsUnpaged is True.

It also may be a good idea to move the ChildClassAllowed method from TCustomTabControl into TPageControl, because the basic control is not restricted to TTabSheet descendants for its child controls.

For now I'd suggest to restore the TTabControl to its prior version, before SVN 31782, and to successively fix the other (non-Win32) widgetsets.

In the long run I'd suggest to simplify the widgetset interface, by removing all page related functionality from it, and replacing the TCustomPage parameters by the really required information, e.g. by an string for the tab title in AddPage. For the implementation of the TPageControl functionality its perfectly sufficient, when every widgetset can add (remove...) tabs, and can report the size of its client area. The implementation of hidden pages, with the consequently required mapping between tab and page indices, as well as the handling of the visibility of the currently seleced/unselected page, can be implemented easier in the TPageControl, independent from any widgetset.

DoDi

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho: On Sun, Jul 24, 2011 at 7:16 PM, Hans-Peter Diettrich Your implementation did not work,…
Show quoted text 6 lines
wrote: > There seem to exist some issues with the new implementation, so that I'll > give some background information, about the new TCustomTabControl and > descendants. Your implementation did not work,

Which widgetset?

so I deleted most of it's code and now TTabControl basically works as a TPageControl until the implementation is finished.

The implementation was finished.

You should have removed the buggy widgetset implementation, if ever ;-)

> The basic TCustomTabControl does not have pages any more, I think that it has in the current Lazarus svn.

After my implementation was completely removed :-(

Show quoted text 8 lines
> The new TCustomTabControl has been implemented and tested *only* with the > Win32 widgetset, because I don't know about implementation details of other > widgetsets. When an AV occurs in an widgetset, due to improper use of an > TCustomPage parameter, the related code should be skipped when > tabctrl.IsUnpaged is True. Are you sure? I think that it shouldn't give any AVs now, and it works in all widgetsets. I did not commit exactly your changes.

The current implementation reverted TTabControl into a paged control. This step is useless, because it now is a crippled TPageControl with no designer, and incompatible with the Delphi implementation :-(

Show quoted text 6 lines
> It also may be a good idea to move the ChildClassAllowed method from > TCustomTabControl into TPageControl, because the basic control is not > restricted to TTabSheet descendants for its child controls. I think that the priority should be getting the widgetsets to be able to implement IsUnpaged.

ACK

Show quoted text 6 lines
> For now I'd suggest to restore the TTabControl to its prior version, before > SVN 31782, and to successively fix the other (non-Win32) widgetsets. Fix what? AFAIK the latest svn works fine everywhere. Maybe you need to update your svn, because there were some problems after my initial commits, but then I fixed some things.

Nothing really new after 31782 :-(

Plus, the old TTabControl was completely broken and had a completely wrong class hierarchy, so reverting it doesn't fix anything.

Which SVN revision are you talking about?

DoDi

Reply by email

Felipe Monteiro de Carvalho
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
> Your implementation did not work, Which widgetset?

I think that all of them, or at least gtk2 and carbon. These steps failed for me:

1> Drop a TTabControl in the form
2> Right-click it and select AddTab

Result: Access Violation

The current implementation reverted TTabControl into a paged control. This step is useless, because it now is a crippled TPageControl with no designer, and incompatible with the Delphi implementation :-(

My main objective here was fixing the class hierarchy, and that got fixed.

And for me it works in the designer.

As for further improving it, one key element here is that the Delphi TTabControl is able to receive child elements, so it's not really that TTabControl has no sheets, but rather that it always has 1 sheet and child controls can be placed on it and clicking in the tabs doesn't change which sheet is visible. So that's what Unpaged should implement in the widgetsets.

And we should also add a AutoSize property, so that people can use the TTabControl as a list of tabs without a client area. The AutoSize would reduce it's Height to the necessary to show the tabs.

Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho
Show quoted text 12 lines
On Mon, Jul 25, 2011 at 12:35 AM, Hans-Peter Diettrich wrote: >> Your implementation did not work, > Which widgetset? I think that all of them, or at least gtk2 and carbon. These steps failed for me: 1> Drop a TTabControl in the form 2> Right-click it and select AddTab Result: Access Violation

That's why I wrote the note, how to update the widgetsets. When you find the place in the source code, where the AV happens, I can try to figure out what to do. Or have a look at the places, where I already updated the Win32 widgetset.

Show quoted text 7 lines
> The current implementation reverted TTabControl into a paged control. This > step is useless, because it now is a crippled TPageControl with no designer, > and incompatible with the Delphi implementation :-( My main objective here was fixing the class hierarchy, and that got fixed. And for me it works in the designer.

My version also works, including its designer. It also is Delphi compatible, in contrast to the paged version. I wanted to use it in the EasyDockManager, but now it's as useless as the old implementation :-(

Show quoted text 6 lines
As for further improving it, one key element here is that the Delphi TTabControl is able to receive child elements, so it's not really that TTabControl has no sheets, but rather that it always has 1 sheet and child controls can be placed on it and clicking in the tabs doesn't change which sheet is visible. So that's what Unpaged should implement in the widgetsets.

The widgetsets already handle the client area of the native control, no need to add any "sheet". Controls of any type can be put into the TabControl, when the check for ChildClassAllowed is moved into TPageControl.

As outlined before, a control added to the Tabs.Objects[] will become visible when its tab is selected, so that even an unpaged control can have individual pages - they only are not restricted to TTabSheet descendants.

And we should also add a AutoSize property, so that people can use the TTabControl as a list of tabs without a client area. The AutoSize would reduce it's Height to the necessary to show the tabs.

Good idea, but I couldn't find any documentation about implementing AutoSize, so I left this to the gurus.

DoDi

Reply by email

Mattias Gaertner
to Hans-Peter Diettrich

?
?

Hans-Peter Diettrich hat am 25. Juli 2011 um 17:36 geschrieben:

Show quoted text 7 lines
[...] > And we should also add a AutoSize property, so that people can use the > TTabControl as a list of tabs without a client area. The AutoSize > would reduce it's Height to the necessary to show the tabs. Good idea, but I couldn't find any documentation about implementing AutoSize, so I left this to the gurus.

http://lmgtfy.com/?q=lazarus+autosize&l=1

See chapter "Own Autosize".

Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110725/9ad03e5b/attachment-0001.html>

Reply by email