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 » U++ Widgets - General questions or Mixed problems » How to implent a rubber band Class in u++
Re: How to implent a rubber band Class in u++ [message #12340 is a reply to message #12330] Thu, 25 October 2007 16:44 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Easy Smile

RubberBand class:
class RubberBand : public LocalLoop
{
public:
	virtual void MouseMove(Point p, dword keyflags) 	{ points.Add(p); GetMaster().Refresh(); }
	virtual void LeftUp(Point p, dword keyflags)    	{ EndLoop(); }
	virtual void RightUp(Point p, dword keyflags)   	{ EndLoop(); }

	const Vector<Point> &	GetPoints()					{ return points; }
	void 					Clear()						{ points.Clear(); }
private:
	Vector<Point> points;
};

Test code (band is member variable of type RubberBand):
void AWindow::LeftDown(Point p, dword keyflags)
{
	band.Clear();
	band.SetMaster(*this);
	band.Run();
	Refresh();
}

void AWindow::Paint(Draw& w)
{
	const Vector<Point> &p = band.GetPoints();
	
	w.DrawRect(GetSize(), SColorFace);
	
	for (int i = 0; i < p.GetCount()-1; i++)
		w.DrawLine(p[i], p[i+1]);
	if (!band.InLoop() && p.GetCount() > 1)
		w.DrawLine(p[p.GetCount()-1], p[0]);
	w.DrawText(4, 4, AsString(p.GetCount()));
}

Hope that helps.

Btw, this is in the wrong forum. General widget forum would have been better.
 
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
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FileList problems with extensions and pop-ups
Next Topic: How to turn off special chars in RichEdit?
Goto Forum:
  


Current Time: Mon Jun 17 06:05:12 CEST 2024

Total time taken to generate the page: 0.01891 seconds