.upptst: DDARasterizer

git-svn-id: svn://ultimatepp.org/upp/trunk@6062 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-05-13 08:15:18 +00:00
parent 7ab4b5b0bf
commit f710616c12
4 changed files with 113 additions and 0 deletions

View file

@ -0,0 +1,93 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define IMAGECLASS TestImg
#define IMAGEFILE <DDARasterizer/test.iml>
#include <Draw/iml_header.h>
#define IMAGECLASS TestImg
#define IMAGEFILE <DDARasterizer/test.iml>
#include <Draw/iml_source.h>
struct ColorRenderer : DDARasterizer {
Draw *draw;
Color color;
virtual void PutHorz(int x, int y, int cx) {
draw->DrawRect(x, y, cx, 1, color);
}
virtual void PutVert(int x, int y, int cy) {
draw->DrawRect(x, y, 1, cy, color);
}
};
struct MyApp : TopWindow {
Point p;
int width;
virtual void Paint(Draw& w);
virtual void MouseMove(Point p, dword keyflags);
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
virtual Image CursorImage(Point p, dword keyflags);
MyApp() { width = 2; p = Point(0, 0); Sizeable().Zoomable(); }
};
Image MyApp::CursorImage(Point p, dword keyflags)
{
return TestImg::cursor1();
}
void MyApp::MouseMove(Point p_, dword keyflags)
{
p = p_;
Refresh();
}
void MyApp::MouseWheel(Point p, int zdelta, dword keyflags)
{
width = minmax(1, 1000, width + sgn(zdelta));
Title(AsString(width));
Refresh();
}
void MyApp::Paint(Draw& w)
{
Size sz = GetSize();
w.DrawRect(GetSize(), Gray());
Point p0(10, 10);
Vector< Vector<Point> > pgs;
ColorRenderer r;
r.Cy(sz.cy);
r.draw = &w;
r.color = Green();
r.color = Black();
r.Polygon();
r.Move(p0);
r.Line(p);
r.Line(Point(700, 400));
r.Fill();
w.DrawRect(p.x, p.y, 1, 1, White());
r.color = LtRed();
r.Width(width);
r.Move(p0);
r.Line(p);
w.DrawRect(p0.x, p0.y, 1, 1, White());
w.DrawRect(700, 400, 1, 1, White());
r.color = LtBlue();
}
GUI_APP_MAIN
{
MyApp().Run();
}