$OpenBSD: patch-sitebox_cc,v 1.1 2001/07/30 15:33:22 espie Exp $ --- sitebox.cc.orig Mon Jul 30 17:26:00 2001 +++ sitebox.cc Mon Jul 30 17:25:38 2001 @@ -112,7 +112,7 @@ class Site : public TclObject { static Drawable pixmap_; static int pixw_; static int pixh_; - static XFontStruct* fs_; /* font metrics */ + static Tk_Font fs_; /* font metrics */ }; class SiteBox : public TkWidget, public IdleCallback { @@ -160,7 +160,7 @@ class SiteBox : public TkWidget, public GC Site::copy_gc_; GC Site::fg_[4]; GC Site::bg_[4]; -XFontStruct* Site::fs_; +Tk_Font Site::fs_; XColor* Site::fc_; XColor* Site::bc_; XColor* Site::ac_; @@ -190,15 +190,16 @@ Site::Site(Tk_Window tk, SiteBox& sb) : sitebox_(sb) { Tcl& tcl = Tcl::instance(); + Tk_FontMetrics fm; if (fs_ == 0) { const char* font = tcl.attr("siteFont"); - fs_ = Tk_GetFontStruct(tcl.interp(), tk_, (char*)font); + fs_ = Tk_GetFont(tcl.interp(), tk_, (char*)font); if (fs_ == 0) { fprintf(stderr, "vat: couldn't find font: %s\n", font); - fs_ = Tk_GetFontStruct(tcl.interp(), tk_, "screen"); + fs_ = Tk_GetFont(tcl.interp(), tk_, "screen"); if (fs_ == 0) - fs_ = Tk_GetFontStruct(tcl.interp(), tk_, + fs_ = Tk_GetFont(tcl.interp(), tk_, "fixed"); if (fs_ == 0) { fprintf(stderr, @@ -220,14 +221,19 @@ Site::Site(Tk_Window tk, SiteBox& sb) : copy_gc_ = sitebox_.lookup_gc(0, 0, 0); } - descent_ = fs_->descent; - ascent_ = fs_->ascent; + Tk_GetFontMetrics(fs_, &fm); + descent_ = fm.descent; + ascent_ = fm.ascent; major_ = ascent_; minor_ = major_ / 2; } Site::~Site() { + if (text_) + delete text_; + if (tag_) + delete tag_; } int Site::command(int argc, const char*const* argv) @@ -292,7 +298,7 @@ int Site::command(int argc, const char*c */ inline int Site::textwidth(const char* s) { - return (XTextWidth(fs_, s, strlen(s))); + return (Tk_TextWidth(fs_, s, strlen(s))); } inline void Site::square(Display* dpy, Drawable window, GC gc, @@ -450,7 +456,7 @@ void Site::place(int x, int y, int w, in free_gc(bg_[0]); free_gc(bg_[1]); } - Font fid = fs_->fid; + Font fid = Tk_FontId(fs_); fg_[0] = raw_gc(fid, fc_, bc_, pixmap_); fg_[2] = raw_gc(fid, dc_, bc_, pixmap_); bg_[0] = raw_gc(fid, bc_, bc_, pixmap_); @@ -636,8 +642,8 @@ SiteBox::SiteBox(const char* path) need_sort_ = 0; Tcl& tcl = Tcl::instance(); - Tk_Uid fg = mono()? "black" : (char*)tcl.attr("foreground"); - Tk_Uid bg = mono()? "white" : (char*)tcl.attr("background"); + Tk_Uid fg = mono()? (char *)"black" : (char*)tcl.attr("foreground"); + Tk_Uid bg = mono()? (char *) "white" : (char*)tcl.attr("background"); fg_ = lookup_gc(0, fg, bg); bg_ = lookup_gc(0, bg, bg); }