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
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 previous 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 832 times)

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

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ProgressIndicator in StatusBar
Next Topic: ProgressIndicator in ArrayCtrl
Goto Forum:
  


Current Time: Tue May 21 09:22:14 CEST 2024

Total time taken to generate the page: 0.02055 seconds