1 /* Xaw3dXft.h,v 1.0 10/11/07 08:07:27 demailly Exp $ */
2 
3 /***********************************************************
4 
5 Copyright (c) 2010  J.-P. Demailly
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 
24 Permission to use, copy, modify, and distribute this software and its
25 documentation for any purpose and without fee is hereby granted,
26 provided that the above copyright notice appear in all copies and that
27 both that copyright notice and this permission notice appear in
28 supporting documentation, and that the name of Digital not be
29 used in advertising or publicity pertaining to distribution of the
30 software without specific, written prior permission.
31 
32 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
33 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
34 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
35 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
36 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
37 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
38 SOFTWARE.
39 
40 ******************************************************************/
41 
42 #include <X11/Xlib.h>
43 #include <X11/Xft/Xft.h>
44 #include <X11/Xaw3dxft/AsciiTextP.h>
45 #include <X11/Xaw3dxft/ScrollbarP.h>
46 #include <X11/Xaw3dxft/Xaw3dXftP.h>
47 
48 #define XAW3DXFT_DEFAULTFONT "Liberation-9"
49 
50 #ifndef Pixel
51 #endif
52 
53 Xaw3dXftData * _Xaw3dXft;
54 
Xaw3dXftSetDefaultHilitColor(void)55 void Xaw3dXftSetDefaultHilitColor(void)
56 {
57     _Xaw3dXft->hilit_color = strdup("#000000");
58 }
59 
Xaw3dXftSetHilitColor(char * value)60 void Xaw3dXftSetHilitColor(char * value)
61 {
62     if (_Xaw3dXft->hilit_color)
63         free(_Xaw3dXft->hilit_color);
64     _Xaw3dXft->hilit_color = strdup(value);
65 }
66 
Xaw3dXftSetDefaultFontName(char * name)67 void Xaw3dXftSetDefaultFontName(char *name)
68 {
69     if (_Xaw3dXft->default_fontname)
70         free(_Xaw3dXft->default_fontname);
71     _Xaw3dXft->default_fontname = strdup(name);
72 }
73 
hexa(char c)74 static int hexa(char c)
75 {
76     if (c>='0' && c<='9') return c-'0'; else
77     if (c>='a' && c<='f') return c-'a'+10; else
78     if (c>='A' && c<='F') return c-'A'+10; else
79     return 0;
80 }
81 
Xaw3dXftSetInsensitiveTwist(char * value)82 void Xaw3dXftSetInsensitiveTwist(char *value)
83 {
84     int i;
85     if (!value) return;
86     if (*value == '|')
87         _Xaw3dXft->insensitive_twist[0] = 1;
88     else
89     if (*value == '&')
90         _Xaw3dXft->insensitive_twist[0] = 2;
91     else
92     if (*value == '^')
93         _Xaw3dXft->insensitive_twist[0] = 3;
94     else
95     if (*value == '~') {
96         if (strlen(value)<3) return;
97         _Xaw3dXft->insensitive_twist[0] = 4;
98         _Xaw3dXft->insensitive_twist[1] = (hexa(value[1])*16+hexa(value[2]))*257;
99         return;
100     } else
101         _Xaw3dXft->insensitive_twist[0] = 0;
102     if (strlen(value)<7) return;
103     for (i=1; i<=3; i++)
104         _Xaw3dXft->insensitive_twist[i] = (hexa(value[2*i-1])*16+hexa(value[2*i]))*257;
105 }
106 
Xaw3dXftGetFont(Display * dpy,char * name)107 XftFont * Xaw3dXftGetFont(Display *dpy, char *name)
108 {
109     if (name) {
110         if (strncasecmp(name, "core:",5))
111             return XftFontOpenName(dpy, DefaultScreen(dpy), name);
112         else
113             return XftFontOpenXlfd(dpy, DefaultScreen(dpy), name+5);
114     }
115     if (!_Xaw3dXft->default_font) {
116         if (!_Xaw3dXft->default_fontname)
117 	    _Xaw3dXft->default_fontname = XAW3DXFT_DEFAULTFONT;
118         if (strncasecmp(_Xaw3dXft->default_fontname, "core:",5))
119             _Xaw3dXft->default_font =
120                 XftFontOpenName(dpy, DefaultScreen(dpy), _Xaw3dXft->default_fontname);
121         else
122             _Xaw3dXft->default_font =
123                 XftFontOpenXlfd(dpy, DefaultScreen(dpy), _Xaw3dXft->default_fontname+5);
124         if (!_Xaw3dXft->default_font)
125             _Xaw3dXft->default_font =
126                 XftFontOpenName(dpy, DefaultScreen(dpy), XAW3DXFT_DEFAULTFONT);
127     }
128     return _Xaw3dXft->default_font;
129 }
130 
131 int
Xaw3dXftTextWidth(Widget w,XftFont * font,char * str,int len)132 Xaw3dXftTextWidth(Widget w, XftFont *font, char *str, int len)
133 {
134     Display *dpy = XtDisplayOfObject(w);
135     XGlyphInfo extents = {};
136     if (_Xaw3dXft->encoding == -1) {
137         XftTextExtentsUtf8(dpy, font, (FcChar8*)str, len, (XGlyphInfo*)&extents);
138     } else
139     if (_Xaw3dXft->encoding == 8)
140         XftTextExtents8(dpy, font, (FcChar8*)str, len, (XGlyphInfo*)&extents);
141     else
142     if (_Xaw3dXft->encoding == 16)
143         XftTextExtents16(dpy, font, (FcChar16*)str, len/2,
144                          (XGlyphInfo*)&extents);
145 #ifdef DEBUG
146     str[len] = '\0';
147     printf("%s (%d)\n", str, extents.xOff);
148 #endif
149     return extents.xOff;
150 }
151 
152 static void
AdjustBackground(Widget ww,int x,int y,int w,int h)153 AdjustBackground(Widget ww, int x, int y, int w, int h)
154 {
155     Display *dpy = XtDisplayOfObject(ww);
156     Window win = XtWindowOfObject(ww);
157     Pixel bg, fg;
158     GC gc;
159     Colormap cmap = None;
160     XColor xcol;
161     static Pixel bg0 = -1, hc;
162     static Widget ww0 = None;
163 
164     if (_Xaw3dXft->text_bg_hilight == -1 && _Xaw3dXft->text_bg_hilight_color != -1) {
165         XtVaGetValues(ww, XtNbackground, &bg, XtNforeground, &fg, NULL);
166         if (ww != ww0 || bg != bg0) {
167 	    XtVaGetValues(ww, XtNcolormap, &cmap, NULL);
168             if (cmap==None) cmap = DefaultColormap(dpy, DefaultScreen(dpy));
169             xcol.pixel = bg;
170             xcol.flags = DoRed | DoGreen | DoBlue;
171             XQueryColor(dpy, cmap, &xcol);
172             xcol.red = xcol.red ^ ((_Xaw3dXft->text_bg_hilight_color&0xff0000)>>8);
173 	    xcol.green = xcol.green ^ (_Xaw3dXft->text_bg_hilight_color&0xff00);
174 	    xcol.blue = xcol.blue ^ ((_Xaw3dXft->text_bg_hilight_color&0xff) << 8);
175             XAllocColor(dpy, cmap, &xcol);
176             hc = xcol.pixel;
177 	}
178 	gc = XtGetGC(ww, 0, 0);
179         XSetForeground(dpy, gc, hc);
180         XFillRectangle(dpy, win, gc, x, y, w, h);
181         XSetForeground(dpy, gc, fg);
182     } else
183     if (!_Xaw3dXft->string_hilight)
184         XClearArea(dpy, win, x, y, w, h, False);
185 }
186 
187 void
Xaw3dXftDrawString(Widget w,XftFont * font,int x,int y,char * str,int len)188 Xaw3dXftDrawString(Widget w, XftFont *font, int x, int y, char *str, int len)
189 {
190     static XftDraw *draw = NULL;
191     static Pixmap pixmap = None;
192     static GC gc = None;
193     static Window win0 = None;
194     static int maxw=0, maxh = 0;
195     static Pixel bg0 = -1, bg1 = 0;
196 
197     Display *dpy;
198     Window win;
199     XftColor color;
200     XRenderColor xre_color;
201     XColor xcol, xhilit;
202     Pixel bg, fg;
203     Colormap cmap = None;
204     XGlyphInfo extents = {};
205     int i, j, d;
206 
207     if (!font) return;
208     if (!len) return;
209     dpy = XtDisplayOfObject(w);
210     win = XtWindowOfObject(w);
211     if (!win) return;
212 
213     fg = BlackPixel(dpy, DefaultScreen(dpy));
214     XtVaGetValues(w, XtNforeground, &fg, XtNcolormap, &cmap, NULL);
215 
216     if (_Xaw3dXft->text_fg_alternate_color != -1)
217         fg = _Xaw3dXft->text_fg_alternate_color;
218 
219     if (cmap==None) cmap = DefaultColormap(dpy, DefaultScreen(dpy));
220 
221     if (_Xaw3dXft->string_use_pixmap) goto use_pixmap;
222 
223     draw = XftDrawCreate(dpy, win,
224                          DefaultVisual(dpy, DefaultScreen(dpy)), cmap);
225 
226     xcol.pixel = fg;
227     xcol.flags = DoRed | DoGreen | DoBlue;
228     XQueryColor(dpy, cmap, &xcol);
229     xre_color.red = xcol.red;
230     xre_color.green = xcol.green;
231     xre_color.blue = xcol.blue;
232     xre_color.alpha = 0xffff;
233     if (!XtIsSensitive(w)) {
234         /* modify color for non sensitive items */
235         if (_Xaw3dXft->insensitive_twist[0] < 2) {
236             if (_Xaw3dXft->insensitive_twist[0] == 0) {
237                 xre_color.red = _Xaw3dXft->insensitive_twist[1];
238                 xre_color.green = _Xaw3dXft->insensitive_twist[2];
239                 xre_color.blue = _Xaw3dXft->insensitive_twist[3];
240 	    } else {
241                 xre_color.red = xcol.red | _Xaw3dXft->insensitive_twist[1];
242                 xre_color.green = xcol.green | _Xaw3dXft->insensitive_twist[2];
243                 xre_color.blue = xcol.blue | _Xaw3dXft->insensitive_twist[3];
244 	    }
245 	} else
246 	if (_Xaw3dXft->insensitive_twist[0] < 4) {
247 	    if (_Xaw3dXft->insensitive_twist[0] == 2) {
248                 xre_color.red = xcol.red & _Xaw3dXft->insensitive_twist[1];
249                 xre_color.green = xcol.green & _Xaw3dXft->insensitive_twist[2];
250                 xre_color.blue = xcol.blue & _Xaw3dXft->insensitive_twist[3];
251 	    } else {
252                 xre_color.red = xcol.red ^ _Xaw3dXft->insensitive_twist[1];
253                 xre_color.green = xcol.green ^ _Xaw3dXft->insensitive_twist[2];
254                 xre_color.blue = xcol.blue ^ _Xaw3dXft->insensitive_twist[3];
255 	    }
256 	} else
257 	    xre_color.alpha = _Xaw3dXft->insensitive_twist[1]*257;
258     }
259     XftColorAllocValue(dpy, DefaultVisual(dpy, DefaultScreen(dpy)),
260 		       cmap, &xre_color, &color);
261 
262     if (_Xaw3dXft->encoding == -1) {
263         XftTextExtentsUtf8(dpy, font, (FcChar8*)str, len, (XGlyphInfo*)&extents);
264         AdjustBackground(w, x, y-font->ascent, extents.xOff, font->height);
265         XftDrawStringUtf8(draw, &color, font, x, y, (FcChar8*)str, len);
266     } else
267     if (_Xaw3dXft->encoding == 8) {
268         XftTextExtents8(dpy, font, (FcChar8*)str, len, (XGlyphInfo*)&extents);
269         AdjustBackground(w, x, y-font->ascent, extents.xOff, font->height);
270         XftDrawString8(draw, &color, font, x, y, (FcChar8*)str, len);
271     } else
272     if (_Xaw3dXft->encoding == 16) {
273         XftTextExtents16(dpy, font, (FcChar16*)str, len/2,
274                          (XGlyphInfo*)&extents);
275         AdjustBackground(w, x, y-font->ascent, extents.xOff, font->height);
276         XftDrawString16(draw, &color, font, x, y, (FcChar16*)str, len/2);
277     }
278     if (DefaultDepth(dpy, DefaultScreen(dpy))>8)
279         XftColorFree(dpy, DefaultVisual(dpy, DefaultScreen(dpy)),
280 		     cmap, &color);
281     XftDrawDestroy(draw);
282     XFlush(dpy);
283     return;
284 
285  use_pixmap :
286 
287     if (win != win0 || font->max_advance_width>maxw ||
288         font->ascent + font->descent > maxh) {
289         if (draw) XftDrawDestroy(draw);
290         if (pixmap) XFreePixmap(dpy, pixmap);
291         if (gc) XFreeGC(dpy, gc);
292         draw = NULL;
293         win0 = win;
294         maxh = font->ascent + font->descent;
295         maxw = font->max_advance_width;
296     }
297 
298     bg = WhitePixel(dpy, DefaultScreen(dpy));
299     XtVaGetValues(w, XtNbackground, &bg, NULL);
300 
301     if (_Xaw3dXft->string_hilight && _Xaw3dXft->hilit_color && cmap) {
302         if (bg != bg0) {
303             xcol.pixel = bg;
304             xcol.flags = DoRed | DoGreen | DoBlue;
305             XQueryColor(dpy, cmap, &xcol);
306             XAllocNamedColor(dpy, cmap, _Xaw3dXft->hilit_color, &xhilit, &xhilit);
307             xcol.red = xcol.red ^ xhilit.red;
308             xcol.green = xcol.green ^ xhilit.green;
309             xcol.blue = xcol.blue ^ xhilit.blue;
310             XAllocColor(dpy, cmap, &xcol);
311 	    bg0 = bg;
312             bg1 = xcol.pixel;
313         }
314         bg = bg1;
315     }
316 
317     if (!draw) {
318         pixmap = XCreatePixmap(dpy, win, maxw, maxh,
319                                DefaultDepth(dpy, DefaultScreen(dpy)));
320         gc = XCreateGC(dpy, pixmap, 0, 0);
321         draw = XftDrawCreate(dpy, pixmap,
322 		   DefaultVisual(dpy, DefaultScreen(dpy)),
323                    cmap);
324     }
325 
326     xcol.pixel = fg;
327     xcol.flags = DoRed | DoGreen | DoBlue;
328     XQueryColor(dpy, cmap, &xcol);
329     xre_color.red = xcol.red;
330     xre_color.green = xcol.green;
331     xre_color.blue = xcol.blue;
332     xre_color.alpha = 0xffff;
333     if (!XtIsSensitive(w)) {
334         /* modify color for non sensitive items */
335         if (_Xaw3dXft->insensitive_twist[0] < 2) {
336             if (_Xaw3dXft->insensitive_twist[0] == 0) {
337                 xre_color.red = _Xaw3dXft->insensitive_twist[1];
338                 xre_color.green = _Xaw3dXft->insensitive_twist[2];
339                 xre_color.blue = _Xaw3dXft->insensitive_twist[3];
340 	    } else {
341                 xre_color.red = xcol.red | _Xaw3dXft->insensitive_twist[1];
342                 xre_color.green = xcol.green | _Xaw3dXft->insensitive_twist[2];
343                 xre_color.blue = xcol.blue | _Xaw3dXft->insensitive_twist[3];
344 	    }
345 	} else
346 	if (_Xaw3dXft->insensitive_twist[0] < 4) {
347 	    if (_Xaw3dXft->insensitive_twist[0] == 2) {
348                 xre_color.red = xcol.red & _Xaw3dXft->insensitive_twist[1];
349                 xre_color.green = xcol.green & _Xaw3dXft->insensitive_twist[2];
350                 xre_color.blue = xcol.blue & _Xaw3dXft->insensitive_twist[3];
351 	    } else {
352                 xre_color.red = xcol.red ^ _Xaw3dXft->insensitive_twist[1];
353                 xre_color.green = xcol.green ^ _Xaw3dXft->insensitive_twist[2];
354                 xre_color.blue = xcol.blue ^ _Xaw3dXft->insensitive_twist[3];
355 	    }
356 	} else
357 	    xre_color.alpha = _Xaw3dXft->insensitive_twist[1]*257;
358     }
359     XftColorAllocValue(dpy, DefaultVisual(dpy, DefaultScreen(dpy)),
360 		       cmap, &xre_color, &color);
361 
362     XSetForeground(dpy, gc, bg);
363     if (_Xaw3dXft->encoding == -1) {
364         i = 0;
365         while (i < len) {
366             j = i + 1;
367             /* find length of UTF8 character */
368             if ((str[i] & 0x80))
369 	        while (j < len && (str[j]&0xc0) == 0x80) j++;
370             d = j - i;
371             XftTextExtentsUtf8(dpy, font, (FcChar8*)(str+i), d,
372                                (XGlyphInfo*)&extents);
373             XFillRectangle(dpy, pixmap, gc, 0, 0, extents.xOff, maxh);
374             XftDrawStringUtf8(draw, &color, font, 0, font->ascent,
375                               (FcChar8*)(str+i), d);
376             XCopyArea(dpy, pixmap, win, gc, 0, 0, extents.xOff, maxh,
377                       x, y-font->ascent);
378             x += extents.xOff;
379             i = j;
380 	}
381     } else
382     if (_Xaw3dXft->encoding == 8) {
383         i = 0;
384         while (i < len) {
385             /* find length of 8bit character */
386             XftTextExtents8(dpy, font, (FcChar8*)(str+i), 1,
387                             (XGlyphInfo*)&extents);
388             XFillRectangle(dpy, pixmap, gc, 0, 0, extents.xOff, maxh);
389             XftDrawString8(draw, &color, font, 0, font->ascent,
390                            (FcChar8*)(str+i), 1);
391             XCopyArea(dpy, pixmap, win, gc, 0, 0, extents.xOff, maxh,
392                       x, y-font->ascent);
393             x += extents.xOff;
394             ++i;
395 	}
396     } else
397     if (_Xaw3dXft->encoding == 16) {
398         i = 0;
399         while (i < len) {
400             /* find length of 8bit character */
401             XftTextExtents16(dpy, font, (FcChar16*)(str+i), 2,
402                             (XGlyphInfo*)&extents);
403             XFillRectangle(dpy, pixmap, gc, 0, 0, extents.xOff, maxh);
404             XftDrawString16(draw, &color, font, 0, font->ascent,
405                            (FcChar16*)(str+i), 2);
406             XCopyArea(dpy, pixmap, win, gc, 0, 0, extents.xOff, maxh,
407                       x, y-font->ascent);
408             x += extents.xOff;
409             i += 2;
410 	}
411     }
412     if (DefaultDepth(dpy, DefaultScreen(dpy))>8)
413         XftColorFree(dpy, DefaultVisual(dpy, DefaultScreen(dpy)),
414 		     cmap, &color);
415     XFlush(dpy);
416 }
417 
418 #ifdef XAW_ARROW_SCROLLBARS
419 Widget
Xaw3dXftGetScrollbar(Widget w,XtPointer ptr)420 Xaw3dXftGetScrollbar(Widget w, XtPointer ptr)
421 {
422     Widget sb = None;
423     char *str = (char *)ptr;
424     int n;
425 
426     if (!w) return None;
427 
428     /* Vertical scrollbar of AsciiText/Text widget */
429     if (str[0] == 'T')
430         sb = (((AsciiWidget)w)->text.vbar);
431     else
432     /* Some Parent has vertical scrollbar */
433     if (str[0] == 'P') {
434         n = str[1] - '0';
435         while (n>0 && w) {
436 	    --n;
437 	    w = XtParent(w);
438 	}
439         if (n || !w) return None;
440         sb = XtNameToWidget(w, "vertical");
441     }
442     return sb;
443 }
444 
445 void
Xaw3dXftHandleMouseWheel(Widget w,XtPointer ptr,XEvent * event,Boolean * flg)446 Xaw3dXftHandleMouseWheel (Widget w, XtPointer ptr, XEvent *event, Boolean * flg)
447 {
448     ScrollbarWidget sbw = (ScrollbarWidget) Xaw3dXftGetScrollbar(w, ptr);
449     char *str;
450     int n = 0;
451     if (!sbw) return;
452     if (!(sbw->scrollbar.scroll_steps)) {
453 	str = strchr((char *)ptr, ':');
454 	if (str)
455 	    n = atoi(str+1);
456 	if (n >= 32767) n = 32767;
457 	if (n <= 0) n = 3;
458         sbw->scrollbar.scroll_steps = n;
459     }
460     XawHandleMouseWheel((Widget)sbw, event, NULL, NULL);
461 }
462 
463 void
Xaw3dXftSetMouseWheelHandler(Widget w,XtPointer ptr)464 Xaw3dXftSetMouseWheelHandler(Widget w, XtPointer ptr)
465 {
466     XtAddEventHandler(w, ButtonPressMask, False,
467 	(XtEventHandler) Xaw3dXftHandleMouseWheel, ptr);
468 }
469 
470 void
Xaw3dXftSetMouseWheelSteps(Widget w,XtPointer ptr,int n)471 Xaw3dXftSetMouseWheelSteps(Widget w, XtPointer ptr, int n)
472 {
473     ScrollbarWidget sbw = (ScrollbarWidget) Xaw3dXftGetScrollbar(w, ptr);
474     if (!sbw) return;
475     if (n>0 && n<32768)
476 	sbw->scrollbar.scroll_steps = n;
477 }
478 
479 #endif
480 
481 void
Xaw3dXftInitialize(void)482 Xaw3dXftInitialize(void)
483 {
484     Xaw3dXftProc *proc;
485     char *str;
486 
487     XftInitFtLibrary();
488 
489     str = (char *) XtMalloc(28);
490     _Xaw3dXft = (Xaw3dXftData *) XtMalloc(sizeof(Xaw3dXftData));
491     sprintf(str, "mem:%lu",  (unsigned long) _Xaw3dXft);
492     _Xaw3dXft->encoding  = 0;
493     _Xaw3dXft->string_hilight  = 0;
494     _Xaw3dXft->text_bg_hilight  = 0;
495     _Xaw3dXft->string_use_pixmap  = 0;
496     _Xaw3dXft->menu_spacing  = 1;
497     _Xaw3dXft->show_tips  = 1;
498     _Xaw3dXft->tip_do_grab  = 1;
499     _Xaw3dXft->border_hack  = 1;
500     _Xaw3dXft->no_hilit_reverse  = 0;
501     _Xaw3dXft->button_inverse  = 1;
502     _Xaw3dXft->button_dashed  = 0;
503     _Xaw3dXft->multi_column_menu  = 0;
504     _Xaw3dXft->edit_delete_alternative = 0;
505     _Xaw3dXft->text_sb_right = 0;
506     memset(_Xaw3dXft->insensitive_twist, 0, 4);
507     _Xaw3dXft->text_bg_hilight_color  = -1;
508     _Xaw3dXft->tip_background_color  = -1;
509     _Xaw3dXft->text_fg_alternate_color  = -1;
510     _Xaw3dXft->hilit_color  = NULL;
511     _Xaw3dXft->default_fontname  = NULL;
512     _Xaw3dXft->default_font  = NULL;
513 
514     proc = (Xaw3dXftProc *) XtMalloc(sizeof(Xaw3dXftProc));
515     _Xaw3dXft->proc = proc;
516     proc->set_default_hilit_color = Xaw3dXftSetDefaultHilitColor;
517     proc->set_hilit_color = Xaw3dXftSetHilitColor;
518     proc->set_default_fontname = Xaw3dXftSetDefaultFontName;
519     proc->set_insensitive_twist = Xaw3dXftSetInsensitiveTwist;
520     proc->get_font = Xaw3dXftGetFont;
521     proc->text_width = Xaw3dXftTextWidth;
522     proc->draw_string = Xaw3dXftDrawString;
523 #ifdef XAW_ARROW_SCROLLBARS
524     proc->get_scrollbar =  Xaw3dXftGetScrollbar;
525     proc->handle_mousewheel = Xaw3dXftHandleMouseWheel;
526     proc->set_mousewheel_handler = Xaw3dXftSetMouseWheelHandler;
527     proc->set_mousewheel_steps = Xaw3dXftSetMouseWheelSteps;
528 #endif
529     (void) XrmPermStringToQuark(strdup("Xaw3dXftData"));
530     (void) XrmPermStringToQuark(str);
531 }
532