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 » Slider&ProgressIndicator » Please, add SetColor function to ProgressIndicator
Please, add SetColor function to ProgressIndicator [message #12278] Tue, 23 October 2007 13:09 Go to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
In one of my projects I need to change the color of a ProgressIndicator.

So, I added few things to Progress.h and Progress.cpp:
1) in Progress.h in the
class ProgressIndicator : public Ctrl {

1a) under protected:

Color SColor;


1b) under public:

void  SetColor(Color& color) { SColor = color; }


2) in Progress.cpp
2a) in Constructor:
SetColor(SColorHighlight());

2b) in function
void ProgressIndicator::Paint(Draw& w)
I replaced
w.DrawRect(r1, SColorHighlight());
with
w.DrawRect(r1, SColor);


and (I think) that's all folks Wink

Can you include it to UPPSrc?

Best regards,
Tomek


Re: Please, add SetColor function to ProgressIndicator [message #12289 is a reply to message #12278] Tue, 23 October 2007 18:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, but that does not really work in XP (where chameleonized value is used to draw it using ChPaint).

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12294 is a reply to message #12289] Tue, 23 October 2007 20:08 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
Thank you Mirek.

Quote:

Yes, but that does not really work in XP (where chameleonized value is used to draw it using ChPaint)


Well, I use XP and it works for me, but I don't use chameleon technology for now... mainly because I don't understand what is a "chameleon technology" Rolling Eyes

Can you direct me to a manual about it?

Maybe you say, that I can change it by "chameleonized value"?

One personal question - have you made UPP mainly by yourself? It's quite huge amount of work! Great job!

Best regards,
Tomek

[Updated on: Tue, 23 October 2007 20:09]

Report message to a moderator

Re: Please, add SetColor function to ProgressIndicator [message #12296 is a reply to message #12294] Tue, 23 October 2007 21:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
spidertp wrote on Tue, 23 October 2007 14:08

Thank you Mirek.

Quote:

Yes, but that does not really work in XP (where chameleonized value is used to draw it using ChPaint)


Well, I use XP and it works for me, but I don't use chameleon technology for now... mainly because I don't understand what is a "chameleon technology" Rolling Eyes



Interesting, do you use XP ("Luna") theme or classic look?

Quote:


Can you direct me to a manual about it?



I guess just see the code carefully Smile

OTOH, it can be easily fixed to show the color you want.

Quote:


Maybe you say, that I can change it by "chameleonized value"?



Well, that is another possibility...

Quote:


One personal question - have you made UPP mainly by yourself? It's quite huge amount of work! Great job!



See the About in TheIDE. There is a lot of people involved over years.

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12301 is a reply to message #12296] Wed, 24 October 2007 07:41 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
Hello,

Quote:

Interesting, do you use XP ("Luna") theme or classic look?


I'm using classic look of XP (and I'm proud of it Very Happy)

Quote:

OTOH, it can be easily fixed to show the color you want.
Maybe you say, that I can change it by "chameleonized value"?
Well, that is another possibility...



Can you tell me how?

Best regards,
Tomek
Re: Please, add SetColor function to ProgressIndicator [message #12304 is a reply to message #12301] Wed, 24 October 2007 13:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
spidertp wrote on Wed, 24 October 2007 01:41

Hello,

Quote:

Interesting, do you use XP ("Luna") theme or classic look?


I'm using classic look of XP (and I'm proud of it Very Happy)



That is OK, but try your patch with Luna Smile (And yes, I think these things should work no matter what Smile

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12305 is a reply to message #12304] Wed, 24 October 2007 13:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, anyway, ProgressIndicator now supports SetColor (fallbacks to "classic" look if color is set).

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12307 is a reply to message #12304] Wed, 24 October 2007 14:04 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
Quote:

Well, anyway, ProgressIndicator now supports SetColor (fallbacks to "classic" look if color is set).

Thanks. Do I understand it correctly, that in a function SetColor you change style to classic automatically? If yes, that's good.

Quote:


That is OK, but try your patch with Luna Smile (And yes, I think these things should work no matter what Smile


So, as far I can see, I need to make my own pictures for:

hlook = CtrlsImg::PI();
hchunk = CtrlsImg::PIC();
vlook = CtrlsImg::VPI();
vchunk = CtrlsImg::VPIC();


in every color?? Pfffff...

Or write a function to copy image and change color palette to desired color?

Well, I've copied CtrlsImg::VPIC() and changed pallete to blue, but...

I changed style of ProgressIndicator and it looks ugly...

I made it with:
ProgressIndicator::Style style; // in main class declaration
style.hlook = CtrlsImg::PI();
style.hchunk = CtrlsImg::PIC();
style.vlook = CtrlsImg::VPI();
style.vchunk = Images::VPICblue();
	
Prog1.SetStyle(style);


What's the problem?


Best regards,
Tomek

[Updated on: Fri, 26 October 2007 12:37]

Report message to a moderator

Re: Please, add SetColor function to ProgressIndicator [message #12315 is a reply to message #12307] Wed, 24 October 2007 16:37 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
ChPaint uses two 'HotSpots' to determine how to stretch the image. These can be set in the image editor by selecting the little orange dot on the second row of tools, then using the right and left mouse buttons to place them. If you duplicate the positioning in the original image it should work.

Also, you can set styles more easily if you copy the default style and just change what you need:

style = ProgressIndicator::DefaultStyle();
style.vchunk = Images::VPICblue();

This method will also addapt better to different global Chameleon styles.

Hope that helped,
James
Re: Please, add SetColor function to ProgressIndicator [message #12327 is a reply to message #12315] Thu, 25 October 2007 08:16 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
Quote:

ChPaint uses two 'HotSpots' to determine how to stretch the image. These can be set in the image editor by selecting the little orange dot on the second row of tools, then using the right and left mouse buttons to place them. If you duplicate the positioning in the original image it should work.

Also, you can set styles more easily if you copy the default style and just change what you need:

style = ProgressIndicator::DefaultStyle();
style.vchunk = Images::VPICblue();

This method will also addapt better to different global Chameleon styles.


Thanks James. Without your help I think I would be not able to find the meaning of those hotspots.

But I still don't understand the difference between blue hotspot and orange one (e.g. why the blue one is before the orange one?).

I copied the hotspots from Ctrls.iml but ProgressIndicator doesn't look equally.

Can anybody explain to me the use of hotspots a little bit more (especially, how can I change their position by code)?

Best regards,
Tomek
  • Attachment: Chameleon.jpg
    (Size: 11.36KB, Downloaded 528 times)

[Updated on: Fri, 26 October 2007 12:38]

Report message to a moderator

Re: Please, add SetColor function to ProgressIndicator [message #12329 is a reply to message #12327] Thu, 25 October 2007 08:24 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
Maybe this is a little bit better, but it's still too thin...
  • Attachment: Chameleon.jpg
    (Size: 47.39KB, Downloaded 514 times)

[Updated on: Fri, 26 October 2007 12:38]

Report message to a moderator

Re: Please, add SetColor function to ProgressIndicator [message #12356 is a reply to message #12278] Fri, 26 October 2007 11:07 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
So, I changed a little bit the ProgressIndicator class to change the color even in Xp Style.

The changes are?
1) in Progress.h
1a) added two more variables in protected:
	Style XPstyle;
	Image img;

1b) i made only the declaration of SetColor
	void  SetColor(Color& color);

1c) added two more functions in protected
	void ChangeVChunk(Color& color);
	void ChangeHChunk(Color& color);

2) in Progress.cpp
2a) added definition of SetColor:

	if(GUI_GlobalStyle() >= GUISTYLE_XP && !percent) {
		Size sz = GetSize();
		if(sz.cy > sz.cx) {
			ChangeVChunk(color);
		}
		else {
			ChangeHChunk(color);
		}
		SetStyle(XPstyle);
	}
	else {
		SColor = color;
	}

2b) added definition of ChangeVChunk
void ProgressIndicator::ChangeVChunk(Color& color)
{
	ImageBuffer ib(11,8);
	// draw points in an ImageBuffer with specified color
	for(int y=0; y<8; y++)
	{
		RGBA *l = ib[y];
		for(int x=0; x<11; x++)
		{
			// the first and the last row must be white
			if(y == 0 || y == 7)
			{
				*l = SWhite();
			}
			else if(x == 0 || x == 10) // the first and the last column must have alfa = 150
			{
				*l = color;
				l->a = 150;
			}
			else // everything else must be set to user color with alfa = 200
			{
				*l = color;
				l->a = 200;
			}
			l++;
		}
	}


	// HotSpots - coordinates best for me
	ib.SetHotSpot(Point(0,7));
	ib.Set2ndSpot(Point(10,0));

	// changing vchunk
	Premultiply(ib);
	img = ib;
	XPstyle = ProgressIndicator::StyleDefault();

	XPstyle.vchunk = img;
}

2c) added definition of ChangeHChunk
void ProgressIndicator::ChangeHChunk(Color& color)
{
	ImageBuffer ib(8,11);
	// draw points in an ImageBuffer with specified color
	for(int y=0; y<11; y++)
	{
		RGBA *l = ib[y];
		for(int x=0; x<8; x++)
		{
			// the first and the last row must be white
			if(x == 0 || x == 7)
			{
				*l = SWhite();
			}
			else if(y == 0 || y == 10) // the first and the last column must have alfa = 150
			{
				*l = color;
				l->a = 150;
			}
			else // everything else must be set to user color with alfa = 200
			{
				*l = color;
				l->a = 200;
			}
			l++;
		}
	}


	// HotSpots - coordinates best for me
	ib.SetHotSpot(Point(7,0));
	ib.Set2ndSpot(Point(0,10));

	// changing hchunk
	Premultiply(ib);
	img = ib;
	XPstyle = ProgressIndicator::StyleDefault();

	XPstyle.hchunk = img;
}


The only thing is that bars are still too thin for me. Also, differences between ChangeVChunk and ChangeHChunk are very small and they can be merged.
What do you think?

Best regards,
Tomek

index.php?t=getfile&id=802&private=0
  • Attachment: Chameleon.jpg
    (Size: 83.29KB, Downloaded 815 times)

[Updated on: Fri, 26 October 2007 11:35]

Report message to a moderator

Re: Please, add SetColor function to ProgressIndicator [message #12364 is a reply to message #12356] Fri, 26 October 2007 13:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
spidertp wrote on Fri, 26 October 2007 05:07


What do you think?



Well, I think you are really quite good Smile

Anyway, this thing is supposed to work (and indeed does work) even if you switch the theme in XP (e.g. to make XP look like MacOS X). And on linux too (where, admitedly, the real meat is now still missing). And in Vista.

I know, adding SetColor slightly spoils it anyway, but IMO simple uniform color bar is acceptable everywhere.

In the same time, I think your code could easily be turned in external function (or utility class). No need to change uppsrc.

Which reminds me the persistent topic, to introduce "art" or "theme" package group that would contain all visual enhancements...

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12365 is a reply to message #12364] Fri, 26 October 2007 13:19 Go to previous messageGo to next message
spidertp is currently offline  spidertp
Messages: 16
Registered: October 2007
Location: Poland
Promising Member
luzr wrote on Fri, 26 October 2007 13:07

spidertp wrote on Fri, 26 October 2007 05:07


What do you think?



Anyway, this thing is supposed to work (and indeed does work) even if you switch the theme in XP (e.g. to make XP look like MacOS X). And on linux too (where, admitedly, the real meat is now still missing). And in Vista.

I know, adding SetColor slightly spoils it anyway, but IMO simple uniform color bar is acceptable everywhere.

In the same time, I think your code could easily be turned in external function (or utility class). No need to change uppsrc.

Which reminds me the persistent topic, to introduce "art" or "theme" package group that would contain all visual enhancements...

Mirek



Well, I still need to learn a lot. But I admit, that UPP gives me a real programming pleasure Cool

I'm trying to make a little visualization for automation process and I'd to enhance ProgressIndicator a little bit.

Concerning new packages, maybe it's a good idea.

If you doesn't want to include my enhancements to UPPsrc, then tell me the name of a new utility class, and I wil make it.

I don't want to change my code every new version of UPP...

Best regards Smile
Tomek
Re: Please, add SetColor function to ProgressIndicator [message #12369 is a reply to message #12365] Fri, 26 October 2007 14:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
spidertp wrote on Fri, 26 October 2007 07:19

luzr wrote on Fri, 26 October 2007 13:07

spidertp wrote on Fri, 26 October 2007 05:07


What do you think?



Anyway, this thing is supposed to work (and indeed does work) even if you switch the theme in XP (e.g. to make XP look like MacOS X). And on linux too (where, admitedly, the real meat is now still missing). And in Vista.

I know, adding SetColor slightly spoils it anyway, but IMO simple uniform color bar is acceptable everywhere.

In the same time, I think your code could easily be turned in external function (or utility class). No need to change uppsrc.

Which reminds me the persistent topic, to introduce "art" or "theme" package group that would contain all visual enhancements...

Mirek



Well, I still need to learn a lot. But I admit, that UPP gives me a real programming pleasure Cool

I'm trying to make a little visualization for automation process and I'd to enhance ProgressIndicator a little bit.

Concerning new packages, maybe it's a good idea.

If you doesn't want to include my enhancements to UPPsrc, then tell me the name of a new utility class, and I wil make it.

I don't want to change my code every new version of UPP...

Best regards Smile
Tomek


Do you need a class for it?

I am not 100% sure, but I think it should be possible to make simple

void SetProgressXPColor(ProgressIndicator& pi, Color c);

function (perhaps with some static ArrayMap<Color, ProgressIndicator::Style> inside).

Mirek
Re: Please, add SetColor function to ProgressIndicator [message #12370 is a reply to message #12369] Fri, 26 October 2007 17:54 Go to previous messageGo to next message
piratalp is currently offline  piratalp
Messages: 26
Registered: September 2007
Location: Argentina
Promising Member
I have already chameleonized both progressindicator and progressinfo while in the road to ribbonize upp, so all this thing will for sure break my work and viceversa.

I'm very busy ATM with tons of things to do so ribbon skin was frozen about 2 weeks ago and I don't know exactly when I'll return to it but I see it's becoming more difficult to sync with fresh code, all this because contributors don't have cvs/svn/uvs write access.. (really the first time I see this way of updating an OpenSource project..)

Regards
Re: Please, add SetColor function to ProgressIndicator [message #12394 is a reply to message #12370] Sat, 27 October 2007 15:14 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
piratalp wrote on Fri, 26 October 2007 11:54

I have already chameleonized both progressindicator and progressinfo while in the road to ribbonize upp, so all this thing will for sure break my work and viceversa.



Yes, unfortunately, you are right.

Quote:


I'm very busy ATM with tons of things to do so ribbon skin was frozen about 2 weeks ago and I don't know exactly when I'll return to it but I see it's becoming more difficult to sync with fresh code, all this because contributors don't have cvs/svn/uvs write access.. (really the first time I see this way of updating an OpenSource project..)



I am not sure how is the policy of other projects, but I do not think that anybody with sf.net account has a write access to the repository...

Mirek
Previous Topic: ProgressIndicator in StatusBar
Next Topic: ProgressIndicator in ArrayCtrl
Goto Forum:
  


Current Time: Thu Mar 28 11:55:34 CET 2024

Total time taken to generate the page: 0.01298 seconds