Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TabCtrl » A few questions regarding TabCtrl
A few questions regarding TabCtrl [message #36744] Sat, 30 June 2012 17:19 Go to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Hello!
1) How do I use the same layout (created by Layout editor) to create multiple tabs?
* I tried tabctrl.Add(tab) but it only shows the contents 1 time, then I get empty tabs.

2) How do I add a close button to the tabs similar to what TheIde does?

Thanks
Re: A few questions regarding TabCtrl [message #36746 is a reply to message #36744] Sat, 30 June 2012 21:07 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

lectus wrote on Sat, 30 June 2012 11:19

2) How do I add a close button to the tabs similar to what TheIde does?


You don't Smile TabCtrl doesn't have such a feature. TheIde uses TabBar control. TabBar if far more advanced. You can add not only a close button but whatever you want. The goal was to integrate TabBar with TabCtrl but as usual there was something more important to do. But that would allow to have tabs on any side (not only on the top), one could also change tab position simply by dragging it.
Unfortunately this is still on to do list Smile

PS: It's quite easy to emulate tabctrl behavior with TabBar. Simply switch views on tab change event.
Re: A few questions regarding TabCtrl [message #36748 is a reply to message #36744] Sun, 01 July 2012 18:39 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

lectus wrote on Sat, 30 June 2012 17:19

1) How do I use the same layout (created by Layout editor) to create multiple tabs?
* I tried tabctrl.Add(tab) but it only shows the contents 1 time, then I get empty tabs.

Each widget can be added only once. Second call of Add() removes Ctrl from its previous parent before adding to a new one. This applies to all Ctrls, not only tabs. If you want to have the same thing in two locations, you have to create two instances of it. E.g.:
WithMyLayout<ParentCtrl> tab1;
WithMyLayout<ParentCtrl> tab1;

tabctrl.Add(tab1);
tabctrl.Add(tab2);


Best regards,
Honza
Re: A few questions regarding TabCtrl [message #36751 is a reply to message #36748] Mon, 02 July 2012 04:15 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
dolik.rce wrote on Sun, 01 July 2012 12:39

lectus wrote on Sat, 30 June 2012 17:19

1) How do I use the same layout (created by Layout editor) to create multiple tabs?
* I tried tabctrl.Add(tab) but it only shows the contents 1 time, then I get empty tabs.

Each widget can be added only once. Second call of Add() removes Ctrl from its previous parent before adding to a new one. This applies to all Ctrls, not only tabs. If you want to have the same thing in two locations, you have to create two instances of it. E.g.:
WithMyLayout<ParentCtrl> tab1;
WithMyLayout<ParentCtrl> tab1;

tabctrl.Add(tab1);
tabctrl.Add(tab2);


Best regards,
Honza


Thanks!
I got the behaviour I wanted with:
// init code
int tabcount = 0;
WithMyTabLayout<ParentCtrl> tab[5]; // here I set how many I want

// code to add:
tabctrl.Add(tab[tabcount], "Tab " + AsString(tabcount));
++tabcount;

//code to remove:
tabctrl.Remove(tab[tabcount]);
--tabcount;


Besides that I just add ifs to check if 0 >= tabcount < 5, so I don't go out of the array boundaries.

[Updated on: Mon, 02 July 2012 04:20]

Report message to a moderator

Re: A few questions regarding TabCtrl [message #36756 is a reply to message #36751] Mon, 02 July 2012 20:11 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Well I have to disagree with undogs,

TabCtrl can have buttons tied to them, all you have to do is the following:

Button closeButton;
...
tabs.Add( myTabInstance, img, "tabName").SetCtrl(closeButton);


All you have to do is set the correct style to the closeButton and you're done with it Wink

Re: A few questions regarding TabCtrl [message #36780 is a reply to message #36756] Wed, 04 July 2012 01:08 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Didier wrote on Mon, 02 July 2012 14:11

Well I have to disagree with undogs,


Sure, but it's not a "direct close button feature" Smile
Re: A few questions regarding TabCtrl [message #36783 is a reply to message #36780] Wed, 04 July 2012 20:55 Go to previous message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
unodgs wrote on Wed, 04 July 2012 01:08

Didier wrote on Mon, 02 July 2012 14:11

Well I have to disagree with undogs,


Sure, but it's not a "direct close button feature" Smile



Sure, but most users think that you can't add buttons to TabCtrl, so I thought a little reminder wouldn't do any harm Smile


Previous Topic: How to change Tab name
Next Topic: Why not drop ParentCtrl pane and add Ctrls directly to TabBarCtrl?
Goto Forum:
  


Current Time: Thu Mar 28 14:22:20 CET 2024

Total time taken to generate the page: 0.00884 seconds