class move_handler : public handler {\fbox{move_handler}
public: move_handler( canvas* cv ) : c(cv) { dragging = 0; } void press( event& e ) { x = e.x(); y = e.y(); id = c->overlapping(x, y); if (id) dragging = 1; } void motion( event& e ) { if (dragging) { id.move( e.x() - x, e.y() - y ); x = e.x(); y = e.y(); } } void release( event& ) { dragging = 0; } protected: canvas* c; int dragging; item id; int x,y; };