class drawmode {\fbox{drawmode}
public: enum { move, box, circle, arrow, lastmode }; }; class tablet : public canvas {\fbox{tablet}
public: tablet(widget* w, char* options=""); int operator()() {\fbox{}
return handlers[ mode] ->dispatch(tk,argc,argv); } void mode(char* m); protected: void init(char* options); int _mode; class handler* handlers[drawmode::lastmode]; canvas* c; };
tablet::tablet(widget* w, char* options)\fbox{tablet}
: canvas(w,"tablet",0) {(a)
widget* top = new frame(path()); init(options); redirect(c);(b)
handler(this);(c)
handlers[drawmode::move] = new move_handler(this); handlers[drawmode::box] = new box_handler(this); handlers[drawmode::circle] = new circle_handler(this); handlers[drawmode::arrow]=new arrow_handler(this); _mode = drawmode::move; }