Recent

Author Topic: Problem in drawing controls on TTabSheet  (Read 5976 times)

VTwin

  • Hero Member
  • *****
  • Posts: 785
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #30 on: August 16, 2018, 06:37:58 pm »
...and

http://forum.lazarus.freepascal.org/index.php?topic=4914.0

I guess I'll continue to use TPageControl, if I can, and try to submit bug reports.
« Last Edit: August 16, 2018, 06:41:51 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.4 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.4 (64 bit on VBox)
fpc 3.0.4

wp

  • Hero Member
  • *****
  • Posts: 6301
Re: Problem in drawing controls on TTabSheet
« Reply #31 on: August 16, 2018, 07:40:31 pm »
Well, it's your decision. But before making it final run the attached demo "tabless_pagecontrol". It contains a PageControl with 5 tabs having their TabVisible set to false. On each page there is a button. Outside the PageControl there is a listbox with 5 items each associated with a page. Clicking an item should show the corresponding page.

Run the demo on Windows and Linux/qt where it will perform correctly (well, there is the border of the tabless pagecontrol in Windows which may be annoying, though).

But if you run it on Linux/gtk2 you will not see any pages at all - I think because setting the property "TabVisible" to false means here "hide the tab together with the page", while in Windows and Linux/qt it means "hide the tab alone".

This inconsistency make the tabless TPageControl unusable for cross-platform projects.

The only disadvantage of TNotebook is that a new user finds it difficult to switch between pages. No, it's not difficult at all. In the object tree above the object inspecter each page has a node, and clicking on it brings the corresponding page to the top. As easy as clicking the tabs on the TPageControl!

Using TNotebook in Delphi 7 was a pain, and it still is in 10.2 Tokyo Community Edition because it does not show the nodes in the object tree and there is no feedback which page is currently visible.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

howardpc

  • Hero Member
  • *****
  • Posts: 3176
Re: Problem in drawing controls on TTabSheet
« Reply #32 on: August 16, 2018, 07:45:58 pm »
...but following the thread backwards, I find some suggestions that TNotebook should be dropped. Then at:

http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/multi-pagecontrols.html

I find:

Quote
TTabControl and TPageControl are both descended from TCustomNoteBook (which is in turn descended from TWinControl) and have many inherited properties in common. TPageControl has, in general, more advanced features and is probably intended to replace TNoteBook.

so I don't know exactly what to think now.

One person's opinion is an insufficient basis to discard TNoteBook. Perhaps the person who wrote that simply had not ever used TNoteBook, or prefers widgetset controls such as TPageControl for other unstated reasons.
"more advanced features" is rather tendentious.

The features are different, true, which is why the two controls exist in the first place, and one has not replaced the other. But TNotebook, for instance, offers properties such as
  • ActivePage
  • Page[aIndex]
  • PageIndex
  • Pages
  • PageCount
It is horses for courses.  Sometimes one control fits a task better, sometimes another.  It is misleading to generalise and promote one control as being always the better choice.
Far better to consider what your UI needs, and choose the control that best fits those needs.

VTwin

  • Hero Member
  • *****
  • Posts: 785
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #33 on: August 16, 2018, 10:08:51 pm »
Thanks, wp, I did indeed see the Linux behavior (bug) you noted.

I was very puzzled however, because I have been using PageControls for years as I described. I went back to see what I did that was different from your demo. I set:

PageControl1.ShowTabs := false;

and for each TabSheet (1 to 5):

TabSheet1.TabVisible := true;

This seems counter to the intended behavior, but seems to work the same on Carbon, Cocoa, Windows, and Linux gtk2. At the time I was a newbie, and paid it no mind as it seemed to work.

Thanks both, I will certainly keep in mind that Notebook is a perfectly valid option, whichever works best for a given situation.


Edit: I'll add that using the PageControl this way does make selection of the tabsheet in the editor more difficult. As you suggest, wp, the Notebook may have an edge there.
« Last Edit: August 16, 2018, 10:16:32 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.4 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.4 (64 bit on VBox)
fpc 3.0.4

wp

  • Hero Member
  • *****
  • Posts: 6301
Re: Problem in drawing controls on TTabSheet
« Reply #34 on: August 16, 2018, 10:45:06 pm »
Ah, I've never used the ShowTabs, probably because Delphi does not have it...

As for selection of pages with tabs hidden this way you still have the object tree where every page has its node, like with the TNotebook. The object tree is one of the most underrated features of the Lazarus IDE because it makes navigation through all controls on a form a snap.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

VTwin

  • Hero Member
  • *****
  • Posts: 785
  • Former Turbo Pascal 3 user
Re: Problem in drawing controls on TTabSheet
« Reply #35 on: August 16, 2018, 11:13:05 pm »
As for selection of pages with tabs hidden this way you still have the object tree where every page has its node, like with the TNotebook. The object tree is one of the most underrated features of the Lazarus IDE because it makes navigation through all controls on a form a snap.

Thanks, yes I realized what you meant after I posted the edit. I do use object tree a lot, it is great! I am careful to rename all the sheets with names that make sense (never TabSheet1, TabSheet2, etc., but tsPlotColors, tsPlotSymbols, etc.) so I can find them quickly.
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0 (2.0.7) fixes svn 62148 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.4 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.4 (64 bit on VBox)
fpc 3.0.4