#include "area.h" #include "listobj.h" #include "drawing.h" Drawing* Area::find( int x, int y ) { ListIter it(&objs); it.first(); while (! it.end() ) { Drawing* o = (Drawing*)it.next(); if ( o->pick(x,y) ) return o; } return 0; } void Area::redraw() { dgSetColor(dgLIGHT_GRAY); dgFill(0,0,dgWidth(), dgHeight()); ListIter it(&objs); it.last(); while (! it.end() ) { Drawing* o = (Drawing*)it.prev(); o->draw(); } } void Area::click1(int x, int y) { Drawing* d = find(x,y); if ( d ) { d->click1(x,y); current = d; ox = x; oy = y; dgSetMode(dgXOR); d->draft(); } else emptyclick(x,y); } void Area::unclick1(int x, int y) { if (current) { dgSetMode(dgCOPY); redraw(); current->unclick1(x,y); current = 0; } } void Area::click2 (int x, int y) { Drawing* d = find(x,y); if ( d ) d->click2(x,y); } void Area::unclick2(int x, int y) { Drawing* d = find(x,y); if ( d ) d->unclick2(x,y); } void Area::motion (int x, int y) { if (current) { current->draft(); current->move(x-ox, y-oy); current->draft(); ox = x; oy = y; } else { Drawing* d = find(x,y); if ( d ) d->motion(x,y); } }