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. *
36 #include "TermHeader.h"
37 #include "TermPrimP.h"
38 #include "TermPrimDebug.h"
39 #include "TermPrimRenderP.h"
40 #include "TermPrimRenderLineDraw.h"
41 #include "TermPrimLineDrawP.h"
44 LineDrawRenderFunction(
52 unsigned char *rawString,
56 DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w;
57 struct termData *tpd = tw->term.tpd;
59 unsigned long valueMask;
60 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
61 unsigned char *string;
63 if (tpd->mbCurMax > 1) {
64 /* we have a string of wide chars that need to be converted to
70 unsigned char mbChar[MB_LEN_MAX];
72 /* we will need to convert 2 column characters to 2 spaces in
73 * order to preserve character positions...
75 string = (unsigned char *) XtMalloc(2 * len);
76 for (ptr = string, wPtr = (wchar_t *) rawString, i1 = 0; i1 < len;
78 switch (wcwidth(*wPtr)) {
80 if (wctomb((char *) mbChar, *wPtr) == 1) {
103 /* set the renderGC... */
104 valueMask = (unsigned long) 0;
106 /* set the foreground... */
107 if (TermIS_SECURE(flags)) {
108 if (tpd->renderGC.foreground != bg) {
109 tpd->renderGC.foreground = bg;
110 values.foreground = bg;
111 valueMask |= GCForeground;
114 if (tpd->renderGC.foreground != fg) {
115 tpd->renderGC.foreground = fg;
116 values.foreground = fg;
117 valueMask |= GCForeground;
121 /* set background... */
122 if (tpd->renderGC.background != bg) {
123 tpd->renderGC.background = bg;
124 values.background = bg;
125 valueMask |= GCBackground;
129 (void) XChangeGC(XtDisplay(w), tpd->renderGC.gc, valueMask,
133 /* we need a clear GC as well...
135 valueMask = (unsigned long) 0;
136 if (tpd->renderReverseGC.foreground != bg) {
137 tpd->renderReverseGC.foreground = bg;
138 values.foreground = bg;
139 valueMask |= GCForeground;
142 (void) XChangeGC(XtDisplay(w),
143 tpd->renderReverseGC.gc, valueMask, &values);
146 /* line draw a line of text... */
147 if (isDebugFSet('t', 1)) {
151 /* Fill in the text area so we can see what is going to
154 (void) XFillRectangle(XtDisplay(w),
159 tpd->cellWidth * len,
161 (void) XSync(XtDisplay(w), False);
162 (void) shortSleep(100000);
165 (void) _DtTermPrimLineDrawImageString(
166 XtDisplay(w), /* Display */
167 XtWindow(w), /* Drawable */
168 lineDrawFont, /* LineDrawFont */
169 tpd->renderGC.gc, /* GC */
170 tpd->renderReverseGC.gc, /* clearGC */
172 y + lineDrawFont->ascent, /* y */
176 /* we don't support overstrike for line draw... */
178 /* handle the underline enhancement... */
179 /* draw the underline... */
180 if (TermIS_UNDERLINE(flags)) {
181 XDrawLine(XtDisplay(w), /* Display */
182 XtWindow(w), /* Window */
183 tpd->renderGC.gc, /* GC */
185 y + tpd->cellHeight - 1, /* Y1 */
186 x + len * tpd->cellWidth, /* X2 */
187 y + tpd->cellHeight - 1); /* Y2 */
190 if (rawString != string) {
191 (void) XtFree((char *) string);
196 LineDrawDestroyFunction(
201 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
203 (void) _DtTermPrimLineDrawFreeFont(lineDrawFont);
204 (void) XtFree((char *) font);
208 LineDrawExtentsFunction(
211 unsigned char *string,
218 LineDrawFont lineDrawFont = (LineDrawFont) font->fontInfo;
221 *widthReturn = len * lineDrawFont->width;
224 *heightReturn = lineDrawFont->height;
227 *ascentReturn = lineDrawFont->ascent;
233 _DtTermPrimRenderLineDrawCreate(
244 termFont = (TermFont) XtMalloc(sizeof(TermFontRec));
245 termFont->renderFunction = LineDrawRenderFunction;
246 termFont->destroyFunction = LineDrawDestroyFunction;
247 termFont->extentsFunction = LineDrawExtentsFunction;
249 (XtPointer)_DtTermPrimLineDrawCreateFont(w, glyphInfo, numGlyphs,
250 width, ascent, descent);