class drawtool : public canvas {
public:
drawtool() : canvas() { } // no widget
drawtool(char* p, char* opts="") : canvas(p,0) {
top = new frame(path(),"-class Drawtool"); // outer frame
init(opts);
redirect(c); // redirect to tablet
alias( top ); // to declare widget command
}
// Define the semantics of the drawtool command
int operator()(){
if (!strcmp("self",argv[1]) ) // self
tk->result(self()->path());
else if ( !strcmp( "drawtool" ,*argv) ) // create
create(--argc,++argv);
else // eval
self()->eval( flatten(--argc,++argv) );
return OK;
}
protected:
wiget* top; // outer frame
tablet* c; // inner component
void init(char* options);
// To create a new drawtool widget and corresponding command
void create(int argc, char* argv[]) {
char* name = *argv;
new drawtool(name, flatten(--argc,++argv));
}
};
slide: The drawtool class