omImText.c revision 1ab64890
11ab64890Smrg/* $Xorg: omImText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
21ab64890Smrg/*
31ab64890Smrg * Copyright 1992, 1993 by TOSHIBA Corp.
41ab64890Smrg *
51ab64890Smrg * Permission to use, copy, modify, and distribute this software and its
61ab64890Smrg * documentation for any purpose and without fee is hereby granted, provided
71ab64890Smrg * that the above copyright notice appear in all copies and that both that
81ab64890Smrg * copyright notice and this permission notice appear in supporting
91ab64890Smrg * documentation, and that the name of TOSHIBA not be used in advertising
101ab64890Smrg * or publicity pertaining to distribution of the software without specific,
111ab64890Smrg * written prior permission. TOSHIBA make no representations about the
121ab64890Smrg * suitability of this software for any purpose.  It is provided "as is"
131ab64890Smrg * without express or implied warranty.
141ab64890Smrg *
151ab64890Smrg * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
161ab64890Smrg * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
171ab64890Smrg * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
181ab64890Smrg * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
191ab64890Smrg * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
201ab64890Smrg * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
211ab64890Smrg * SOFTWARE.
221ab64890Smrg *
231ab64890Smrg * Author: Katsuhisa Yano	TOSHIBA Corp.
241ab64890Smrg *			   	mopi@osa.ilab.toshiba.co.jp
251ab64890Smrg */
261ab64890Smrg/* $XFree86: xc/lib/X11/omImText.c,v 1.5 2003/04/13 19:22:22 dawes Exp $ */
271ab64890Smrg
281ab64890Smrg#ifdef HAVE_CONFIG_H
291ab64890Smrg#include <config.h>
301ab64890Smrg#endif
311ab64890Smrg#include "Xlibint.h"
321ab64890Smrg#include "XomGeneric.h"
331ab64890Smrg
341ab64890Smrg#if 0
351ab64890Smrgextern int _XomGenericTextExtents(), _XomGenericDrawString();
361ab64890Smrg#endif
371ab64890Smrg
381ab64890Smrg#define GET_VALUE_MASK	(GCFunction | GCForeground | GCBackground | GCFillStyle)
391ab64890Smrg#define SET_VALUE_MASK	(GCFunction | GCForeground | GCFillStyle)
401ab64890Smrg
411ab64890Smrgstatic void
421ab64890Smrg_XomGenericDrawImageString(
431ab64890Smrg    Display *dpy,
441ab64890Smrg    Drawable d,
451ab64890Smrg    XOC oc,
461ab64890Smrg    GC gc,
471ab64890Smrg    int x, int y,
481ab64890Smrg    XOMTextType type,
491ab64890Smrg    XPointer text,
501ab64890Smrg    int length)
511ab64890Smrg{
521ab64890Smrg    XGCValues values;
531ab64890Smrg    XRectangle extent;
541ab64890Smrg
551ab64890Smrg    XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
561ab64890Smrg
571ab64890Smrg    XSetFunction(dpy, gc, GXcopy);
581ab64890Smrg    XSetForeground(dpy, gc, values.background);
591ab64890Smrg    XSetFillStyle(dpy, gc, FillSolid);
601ab64890Smrg
611ab64890Smrg    _XomGenericTextExtents(oc, type, text, length, 0, &extent);
621ab64890Smrg    XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
631ab64890Smrg		   extent.height);
641ab64890Smrg
651ab64890Smrg    XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
661ab64890Smrg
671ab64890Smrg    _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
681ab64890Smrg}
691ab64890Smrg
701ab64890Smrgvoid
711ab64890Smrg_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
721ab64890Smrg			   int y, _Xconst char *text, int length)
731ab64890Smrg{
741ab64890Smrg    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
751ab64890Smrg			       (XPointer) text, length);
761ab64890Smrg}
771ab64890Smrg
781ab64890Smrgvoid
791ab64890Smrg_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
801ab64890Smrg			   int y, _Xconst wchar_t *text, int length)
811ab64890Smrg{
821ab64890Smrg    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
831ab64890Smrg			       (XPointer) text, length);
841ab64890Smrg}
851ab64890Smrg
861ab64890Smrgvoid
871ab64890Smrg_Xutf8GenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
881ab64890Smrg			     int y, _Xconst char *text, int length)
891ab64890Smrg{
901ab64890Smrg    _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMUtf8String,
911ab64890Smrg			       (XPointer) text, length);
921ab64890Smrg}
93