2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 #ifdef VERBOSE_REV_INFO
25 static char rcs_id[] = "$XConsortium: TermPrimRenderLineDraw.c /main/1 1996/04/21 19:18:59 drk $";
26 #endif /* VERBOSE_REV_INFO */
30 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
31 * (c) Copyright 1993, 1994 International Business Machines Corp. *
32 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
33 * (c) Copyright 1993, 1994 Novell, Inc. *
38 #include "TermHeader.h"
39 #include "TermPrimP.h"
40 #include "TermPrimDebug.h"
41 #include "TermPrimRenderP.h"
42 #include "TermPrimRenderLineDraw.h"
43 #include "TermPrimLineDrawP.h"
46 LineDrawRenderFunction(
54 unsigned char *rawString,
58 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
59 struct termData *tpd = tw->term.tpd;
61 unsigned long valueMask;
62 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
63 unsigned char *string;
65 if (tpd->mbCurMax > 1) {
66 /* we have a string of wide chars that need to be converted to
72 unsigned char mbChar[MB_LEN_MAX];
74 /* we will need to convert 2 column characters to 2 spaces in
75 * order to preserve character positions...
77 string = (unsigned char *) XtMalloc(2 * len);
78 for (ptr = string, wPtr = (wchar_t *) rawString, i1 = 0; i1 < len;
80 switch (wcwidth(*wPtr)) {
82 if (wctomb((char *) mbChar, *wPtr) == 1) {
105 /* set the renderGC... */
106 valueMask = (unsigned long) 0;
108 /* set the foreground... */
109 if (TermIS_SECURE(flags)) {
110 if (tpd->renderGC.foreground != bg) {
111 tpd->renderGC.foreground = bg;
112 values.foreground = bg;
113 valueMask |= GCForeground;
116 if (tpd->renderGC.foreground != fg) {
117 tpd->renderGC.foreground = fg;
118 values.foreground = fg;
119 valueMask |= GCForeground;
123 /* set background... */
124 if (tpd->renderGC.background != bg) {
125 tpd->renderGC.background = bg;
126 values.background = bg;
127 valueMask |= GCBackground;
131 (void) XChangeGC(XtDisplay(w), tpd->renderGC.gc, valueMask,
135 /* we need a clear GC as well...
137 valueMask = (unsigned long) 0;
138 if (tpd->renderReverseGC.foreground != bg) {
139 tpd->renderReverseGC.foreground = bg;
140 values.foreground = bg;
141 valueMask |= GCForeground;
144 (void) XChangeGC(XtDisplay(w),
145 tpd->renderReverseGC.gc, valueMask, &values);
148 /* line draw a line of text... */
149 if (isDebugFSet('t', 1)) {
153 /* Fill in the text area so we can see what is going to
156 (void) XFillRectangle(XtDisplay(w),
161 tpd->cellWidth * len,
163 (void) XSync(XtDisplay(w), False);
164 (void) shortSleep(100000);
167 (void) _DtTermPrimLineDrawImageString(
168 XtDisplay(w), /* Display */
169 XtWindow(w), /* Drawable */
170 lineDrawFont, /* LineDrawFont */
171 tpd->renderGC.gc, /* GC */
172 tpd->renderReverseGC.gc, /* clearGC */
174 y + lineDrawFont->ascent, /* y */
178 /* we don't support overstrike for line draw... */
180 /* handle the underline enhancement... */
181 /* draw the underline... */
182 if (TermIS_UNDERLINE(flags)) {
183 XDrawLine(XtDisplay(w), /* Display */
184 XtWindow(w), /* Window */
185 tpd->renderGC.gc, /* GC */
187 y + tpd->cellHeight - 1, /* Y1 */
188 x + len * tpd->cellWidth, /* X2 */
189 y + tpd->cellHeight - 1); /* Y2 */
192 if (rawString != string) {
193 (void) XtFree((char *) string);
198 LineDrawDestroyFunction(
203 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
205 (void) _DtTermPrimLineDrawFreeFont(lineDrawFont);
206 (void) XtFree((char *) font);
210 LineDrawExtentsFunction(
213 unsigned char *string,
220 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
223 *widthReturn = len * lineDrawFont->width;
226 *heightReturn = lineDrawFont->height;
229 *ascentReturn = lineDrawFont->ascent;
235 _DtTermPrimRenderLineDrawCreate(
246 termFont = (TermFont) XtMalloc(sizeof(TermFontRec));
247 termFont->renderFunction = LineDrawRenderFunction;
248 termFont->destroyFunction = LineDrawDestroyFunction;
249 termFont->extentsFunction = LineDrawExtentsFunction;
251 (XtPointer)_DtTermPrimLineDrawCreateFont(w, glyphInfo, numGlyphs,
252 width, ascent, descent);