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 » How to change tabctrl background color ?
How to change tabctrl background color ? [message #26175] Thu, 08 April 2010 08:49 Go to next message
SIGEAL is currently offline  SIGEAL
Messages: 3
Registered: March 2010
Location: France
Junior Member
Hi,

Well, the title says it all... What I want to achieve is to have different background colors for each tab of a tabctrl.

Any hint appreciated. Thanks.

--
Christophe
Re: How to change tabctrl background color ? [message #26176 is a reply to message #26175] Thu, 08 April 2010 12:41 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
It is not possible to do this while retaining OS theming. The reason for this is that the background color of the tab is baked into the theme image that Upp receives from the OS, and so cannot be replaced.

Even disregarding theming it's not easy, mainly due to the way TabCtrl is constructed:
1- Create versions of the theme images (see CtrlLib/Ctrls.iml for copies of these) with a semi transparent background.
2- Duplicate TabCtrl code and alter PaintTabs so that it paints a background color on the tab before the ChPaint that draws the tab style (it's the second, complex one).

It would be nice if 2 didn't require complete code duplication, if you can fix that with a patch it would probably be accepted and then you wouldn't have to worry about code syncing to future Upp revisions.
Re: How to change tabctrl background color ? [message #26180 is a reply to message #26176] Thu, 08 April 2010 21:01 Go to previous messageGo to next message
SIGEAL is currently offline  SIGEAL
Messages: 3
Registered: March 2010
Location: France
Junior Member
Thank you for your quick answer.

I had a look at your suggestion, and I think I was not precise enough : what I want to change is the background color of the tabs content, not the background color of the tabs themselves. Is there a way for that ?

--
Christophe
Re: How to change tabctrl background color ? [message #26186 is a reply to message #26180] Fri, 09 April 2010 11:07 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Like this?
#include "CtrlLib/CtrlLib.h"
using namespace Upp;

GUI_APP_MAIN
{
	TopWindow wnd;
	TabCtrl tab;
	StaticRect a, b;
	Button button;
	DropList list;
	
	a.Color(Red());
	a.Add(button.LeftPosZ(4, 64).BottomPosZ(4, 24));

	b.Color(Blue());
	b.Add(list.LeftPosZ(4, 88).TopPosZ(4, 24));
	list.Add(1, "Option 1").Add(2, "Option 2");
	
	tab.Add(a.SizePos(), "Red");
	tab.Add(b.SizePos(), "Blue");
	
	wnd.Add(tab.SizePos());
	wnd.CenterScreen().SetRect(0, 0, 200, 200);
	
	wnd.Run();
}
Re: How to change tabctrl background color ? [message #26187 is a reply to message #26186] Fri, 09 April 2010 12:20 Go to previous message
SIGEAL is currently offline  SIGEAL
Messages: 3
Registered: March 2010
Location: France
Junior Member
Thank you again, that's exactly what I am trying to do.
Have a nice day !

--
Christophe
Previous Topic: Hide tab in TabCtrl
Next Topic: Question and problems around TabCtrl
Goto Forum:
  


Current Time: Thu Mar 28 17:04:36 CET 2024

Total time taken to generate the page: 0.01848 seconds