summaryrefslogtreecommitdiff
path: root/mbone/vat/patches/patch-ad
blob: 845472ac3c259c6aacd4ba4bb46acf9078d31e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$NetBSD: patch-ad,v 1.3 2002/08/16 16:25:14 agc Exp $

--- sitebox.cc.orig	Tue Sep  9 11:24:41 1997
+++ sitebox.cc	Tue Sep  9 11:24:43 1997
@@ -112,7 +112,7 @@
 	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 @@
 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 @@
 	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,8 +221,9 @@
 
 		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;
 }
@@ -292,7 +294,7 @@
  */
 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 +452,7 @@
 			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 +638,8 @@
 	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()? strdup("black") : (char*)tcl.attr("foreground");
+	Tk_Uid bg = mono()? strdup("white") : (char*)tcl.attr("background");
 	fg_ = lookup_gc(0, fg, bg);
 	bg_ = lookup_gc(0, bg, bg);
 }