#ifndef HYPERTEXT_H
#define HYPERTEXT_H

class hypertext : public widget {
public:
char* type() { return "hypertext"; }

hypertext(char* p, char* options = "", int fl=1) : widget(p) { if(fl) init(options); }
hypertext(widget* w, char* p, char* options = "",int fl=1) : widget(w,p) { if(fl) init(options); }

void file(char* f) {
	sprintf(buf,"%s.f.h configure -file %s", path(), f);
	tk->eval( buf );
	}


virtual void configure(char* s) { 
	sprintf(buf,"%s.h.f configure %s",path(),s);
	tk->eval( buf );
	}

private:
void init(char* options) {
	sprintf(buf,"frame %s",path());
	tk->eval( buf );
	sprintf(buf,"frame %s.f -relief sunken -borderwidth 2 -geometry 500x500",path());
	tk->eval( buf );
	sprintf(buf,"hypertext %s.f.h %s", path(), options);
	tk->eval( buf );
	sprintf(buf,"scrollbar %s.vs -command { %s.f.h yview } -orient vertical", path(), path() );
	tk->eval( buf );
	sprintf(buf,"scrollbar %s.hs -command { %s.f.h xview } -orient horizontal", path(), path() );
	tk->eval( buf );
	sprintf(buf,"%s.f.h configure -yscrollcommand { %s.vs set } -xscrollcommand { %s.hs set } -yscrollunits 10m xscrollunits 1i ", path(), path(), path() );
	tk->eval( buf );
	sprintf(buf,"pack append %s %s.f top", path(), path() );
	tk->eval( buf );
	sprintf(buf,"pack append %s.f %s.f.h { expand padx 2 pady 2 }",path(), path());
	tk->eval( buf );
	sprintf(buf,"pack before %s.f %s.vs { right filly }", path(), path());
	tk->eval( buf );
	sprintf(buf,"pack after %s.f %s.hs { bottom fillx }", path(), path());
	tk->eval( buf );
	}
	
};

#endif
