From 5963e1aa4cf83e65e54d4c2d5d6e60e63edb9ff1 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 14 Dec 1999 06:55:39 +0000 Subject: added recognition of tiling in GC --- xlib/xgc.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 3 deletions(-) diff --git a/xlib/xgc.c b/xlib/xgc.c index 6dea7be..d50acea 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: xgc.c,v 1.3 1999/04/16 01:51:55 stanton Exp $ + * RCS: @(#) $Id: xgc.c,v 1.4 1999/12/14 06:55:39 hobbs Exp $ */ #include @@ -46,7 +46,15 @@ XCreateGC(display, d, mask, values) { GC gp; - gp = (XGCValues *)ckalloc(sizeof(XGCValues)); +/* + * In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars are + * defined, which is invisible from the outside. The list is assumed to end + * with a 0-char, so this must be set explicitely during initialization. + */ + +#define MAX_DASH_LIST_SIZE 10 + + gp = (XGCValues *)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); if (!gp) { return None; } @@ -73,6 +81,7 @@ XCreateGC(display, d, mask, values) gp->clip_y_origin = (mask & GCClipYOrigin) ?values->clip_y_origin :0; gp->dash_offset = (mask & GCDashOffset) ?values->dash_offset :0; gp->dashes = (mask & GCDashList) ?values->dashes :4; + (&(gp->dashes))[1] = 0; if (mask & GCClipMask) { gp->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); @@ -131,7 +140,7 @@ XChangeGC(d, gc, mask, values) if (mask & GCClipYOrigin) { gc->clip_y_origin = values->clip_y_origin; } if (mask & GCClipMask) { XSetClipMask(d, gc, values->clip_mask); } if (mask & GCDashOffset) { gc->dash_offset = values->dash_offset; } - if (mask & GCDashList) { gc->dashes = values->dashes; } + if (mask & GCDashList) { gc->dashes = values->dashes; (&(gc->dashes))[1] = 0;} } /* @@ -198,6 +207,30 @@ XSetBackground(display, gc, background) } void +XSetDashes(display, gc, dash_offset, dash_list, n) + Display* display; + GC gc; + int dash_offset; + _Xconst char* dash_list; + int n; +{ + char *p = &(gc->dashes); + +#ifdef TkWinDeleteBrush + TkWinDeleteBrush(gc->fgBrush); + TkWinDeletePen(gc->fgPen); + TkWinDeleteBrush(gc->bgBrush); + TkWinDeletePen(gc->fgExtPen); +#endif + gc->dash_offset = dash_offset; + if (n > MAX_DASH_LIST_SIZE) n = MAX_DASH_LIST_SIZE; + while (n-- > 0) { + *p++ = *dash_list++; + } + *p = 0; +} + +void XSetFunction(display, gc, function) Display *display; GC gc; @@ -350,3 +383,157 @@ XSetClipMask(display, gc, pixmap) ((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_PIXMAP; ((TkpClipMask*)gc->clip_mask)->value.pixmap = pixmap; } + +/* + * Some additional dummy functions (hopefully implemented soon). + */ + +Cursor +XCreateFontCursor(display, shape) + Display* display; + unsigned int shape; +{ + return (Cursor) 0; +} + +void +XDrawImageString(display, d, gc, x, y, string, length) + Display* display; + Drawable d; + GC gc; + int x; + int y; + _Xconst char* string; + int length; +{ +} + +void +XDrawPoint(display, d, gc, x, y) + Display* display; + Drawable d; + GC gc; + int x; + int y; +{ + XDrawLine(display, d, gc, x, y, x, y); +} + +void +XDrawPoints(display, d, gc, points, npoints, mode) + Display* display; + Drawable d; + GC gc; + XPoint* points; + int npoints; + int mode; +{ + int i; + + for (i=0; i