[Lazarus] TTabControl (d)evolution

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sun Jul 31 18:37:33 CEST 2011


On Sun, Jul 31, 2011 at 6:49 PM, Hans-Peter Diettrich
<DrDiettrich1 at aol.com> wrote:
> IMO we should accept that a Delphi compatible TTabControl doesn't exist yet,
> for widgetsets other than Win32. What can/should we do, when it turns out
> that such a control can not be implemented in all widgetsets?

I bet that it can be implemented in all widgetsets. I don't use
TTabControl, so I could be wrong, but I think that you could implement
it like this in Gtk2:

gtk_widget
->gtk_notebook
->gtk_widget

3 widgets put together. This should work fine if you can make
gtk_notebook show only the tabs without a client area.

Another idea: Override all methods which use WS routines and create a
handle for TCustomControl instead and custom draw the entire control.

> Why not offer the new implementation (TTabs/TNewTabControl) as TTabControl,
> to make Delphi migrants happy, and restrict its use to only the supported
> widgetsets? At the same time the old implementation can be renamed into
> TLazTabControl, that is not fully Delphi compatible, but immediately usable
> with all widgetsets?

We cannot have a control in the LCL which works in only 1 platform, if
it is really like that, then the current implementation is better.

> And since the old TTabControl and TNotebook effectively share the same code,
> except for the control that shows the tabs, it would be a good idea to merge
> both into a common base class.

A very bad idea, they are not even located in the same unit... plus
their class hierarchy is not even remotely similar. In fact, I don't
see anything common between them. TNotebook many pages and no tabs and
no border. TTabControl has 1 page, has border and has tabs.

Making unrelated stuff together because they look similar from a first
view to save code duplication can bring a heavy penalty in terms of
code stability and maintenability. Just think that someone tryes in
the future to fix TTabControl and by accident breaks TNotebook... This
lesson was learned with the gtk1/gtk2 mess.

In fact, I already predict that even sharing code between TTabControl
and TPageControl is a huge risk, changes could break TPageControl. The
safest would be starting a new WS object for TTabControl ...

> More things can be simplified, in detail the difference between visible and
> invisible pages, which applies *only* to the TPageControl.
> part out of the widgetsets into TPageControl, the implementation of the
> widgetsets and all TCustomTabControl descendants could be simplified a lot.
> Then also the restrictions would become more obvious, introduced by the
> various widgetsets.

Why *only* in bold. TCustomTabControl has only 2 descendents, so
TPageControl is 50% of it's descendents.

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list