omImText.c revision b4ee4795
1/*
2 * Copyright 1992, 1993 by TOSHIBA Corp.
3 *
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of TOSHIBA not be used in advertising
9 * or publicity pertaining to distribution of the software without specific,
10 * written prior permission. TOSHIBA make no representations about the
11 * suitability of this software for any purpose.  It is provided "as is"
12 * without express or implied warranty.
13 *
14 * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 * SOFTWARE.
21 *
22 * Author: Katsuhisa Yano	TOSHIBA Corp.
23 *			   	mopi@osa.ilab.toshiba.co.jp
24 */
25
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
29#include "Xlibint.h"
30#include "XomGeneric.h"
31
32#if 0
33extern int _XomGenericTextExtents(), _XomGenericDrawString();
34#endif
35
36#define GET_VALUE_MASK	(GCFunction | GCForeground | GCBackground | GCFillStyle)
37#define SET_VALUE_MASK	(GCFunction | GCForeground | GCFillStyle)
38
39static void
40_XomGenericDrawImageString(
41    Display *dpy,
42    Drawable d,
43    XOC oc,
44    GC gc,
45    int x, int y,
46    XOMTextType type,
47    XPointer text,
48    int length)
49{
50    XGCValues values;
51    XRectangle extent;
52
53    XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
54
55    XSetFunction(dpy, gc, GXcopy);
56    XSetForeground(dpy, gc, values.background);
57    XSetFillStyle(dpy, gc, FillSolid);
58
59    _XomGenericTextExtents(oc, type, text, length, 0, &extent);
60    XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
61		   extent.height);
62
63    XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
64
65    _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
66}
67
68void
69_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
70			   int y, _Xconst char *text, int length)
71{
72    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
73			       (XPointer) text, length);
74}
75
76void
77_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
78			   int y, _Xconst wchar_t *text, int length)
79{
80    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
81			       (XPointer) text, length);
82}
83
84void
85_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
86			     int y, _Xconst char *text, int length)
87{
88    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
89			       (XPointer) text, length);
90}
91