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   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Easy
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.
|
|
|
 |
|
How to implent a rubber band Class in u++
|
 |
|
Re: How to implent a rubber band Class in u++
By: mrjt on Thu, 25 October 2007 16:44
|
 |
|
Re: How to implent a rubber band Class in u++
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Mon, 07 July 2008 18:35
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Fri, 25 July 2008 20:02
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Sat, 26 July 2008 12:03
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Sat, 26 July 2008 16:18
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Sat, 26 July 2008 16:49
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Sat, 26 July 2008 22:45
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Sun, 27 July 2008 01:02
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Fri, 01 August 2008 08:53
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Fri, 01 August 2008 22:33
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Sat, 02 August 2008 09:49
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Mon, 04 August 2008 18:56
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Mon, 04 August 2008 19:39
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Mon, 04 August 2008 22:33
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Tue, 05 August 2008 15:44
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Tue, 05 August 2008 17:37
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Tue, 05 August 2008 19:54
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Wed, 06 August 2008 00:29
|
 |
|
Re: How to implent a rubber band Class in u++
By: mirek on Wed, 06 August 2008 08:34
|
 |
|
Re: How to implent a rubber band Class in u++
By: mrjt on Wed, 06 August 2008 11:04
|
 |
|
Re: How to implent a rubber band Class in u++
By: tojocky on Sat, 09 August 2008 18:43
|
Goto Forum:
Current Time: Wed Jun 11 12:45:59 CEST 2025
Total time taken to generate the page: 0.03782 seconds
|