|
/* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tk_base/xgc.c,v 1.1.1.1 2001/06/13 05:15:43 dtashley Exp $ */ |
|
|
|
|
|
/* |
|
|
* xgc.c -- |
|
|
* |
|
|
* This file contains generic routines for manipulating X graphics |
|
|
* contexts. |
|
|
* |
|
|
* Copyright (c) 1995-1996 Sun Microsystems, Inc. |
|
|
* |
|
|
* 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.1.1.1 2001/06/13 05:15:43 dtashley Exp $ |
|
|
*/ |
|
|
|
|
|
#include "tkInt.h" |
|
|
|
|
|
#ifdef MAC_TCL |
|
|
# include <Xlib.h> |
|
|
# include <X.h> |
|
|
# define Cursor XCursor |
|
|
# define Region XRegion |
|
|
#else |
|
|
# include "Xlib.h" |
|
|
#endif |
|
|
|
|
|
|
|
|
/* |
|
|
*---------------------------------------------------------------------- |
|
|
* |
|
|
* XCreateGC -- |
|
|
* |
|
|
* Allocate a new GC, and initialize the specified fields. |
|
|
* |
|
|
* Results: |
|
|
* Returns a newly allocated GC. |
|
|
* |
|
|
* Side effects: |
|
|
* None. |
|
|
* |
|
|
*---------------------------------------------------------------------- |
|
|
*/ |
|
|
|
|
|
GC |
|
|
XCreateGC(display, d, mask, values) |
|
|
Display* display; |
|
|
Drawable d; |
|
|
unsigned long mask; |
|
|
XGCValues* values; |
|
|
{ |
|
|
GC gp; |
|
|
|
|
|
/* |
|
|
* 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; |
|
|
} |
|
|
|
|
|
gp->function = (mask & GCFunction) ?values->function :GXcopy; |
|
|
gp->plane_mask = (mask & GCPlaneMask) ?values->plane_mask :~0; |
|
|
gp->foreground = (mask & GCForeground) ?values->foreground :0; |
|
|
gp->background = (mask & GCBackground) ?values->background :0xffffff; |
|
|
gp->line_width = (mask & GCLineWidth) ?values->line_width :0; |
|
|
gp->line_style = (mask & GCLineStyle) ?values->line_style :LineSolid; |
|
|
gp->cap_style = (mask & GCCapStyle) ?values->cap_style :0; |
|
|
gp->join_style = (mask & GCJoinStyle) ?values->join_style :0; |
|
|
gp->fill_style = (mask & GCFillStyle) ?values->fill_style :FillSolid; |
|
|
gp->fill_rule = (mask & GCFillRule) ?values->fill_rule :WindingRule; |
|
|
gp->arc_mode = (mask & GCArcMode) ?values->arc_mode :ArcPieSlice; |
|
|
gp->tile = (mask & GCTile) ?values->tile :None; |
|
|
gp->stipple = (mask & GCStipple) ?values->stipple :None; |
|
|
gp->ts_x_origin = (mask & GCTileStipXOrigin) ?values->ts_x_origin:0; |
|
|
gp->ts_y_origin = (mask & GCTileStipYOrigin) ?values->ts_y_origin:0; |
|
|
gp->font = (mask & GCFont) ?values->font :None; |
|
|
gp->subwindow_mode = (mask & GCSubwindowMode)?values->subwindow_mode:ClipByChildren; |
|
|
gp->graphics_exposures = (mask & GCGraphicsExposures)?values->graphics_exposures:True; |
|
|
gp->clip_x_origin = (mask & GCClipXOrigin) ?values->clip_x_origin :0; |
|
|
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)); |
|
|
((TkpClipMask*)gp->clip_mask)->type = TKP_CLIP_PIXMAP; |
|
|
((TkpClipMask*)gp->clip_mask)->value.pixmap = values->clip_mask; |
|
|
} else { |
|
|
gp->clip_mask = None; |
|
|
} |
|
|
|
|
|
return gp; |
|
|
} |
|
|
|
|
|
/* |
|
|
*---------------------------------------------------------------------- |
|
|
* |
|
|
* XChangeGC -- |
|
|
* |
|
|
* Changes the GC components specified by valuemask for the |
|
|
* specified GC. |
|
|
* |
|
|
* Results: |
|
|
* None. |
|
|
* |
|
|
* Side effects: |
|
|
* Updates the specified GC. |
|
|
* |
|
|
*---------------------------------------------------------------------- |
|
|
*/ |
|
|
|
|
|
void |
|
|
XChangeGC(d, gc, mask, values) |
|
|
Display * d; |
|
|
GC gc; |
|
|
unsigned long mask; |
|
|
XGCValues *values; |
|
|
{ |
|
|
if (mask & GCFunction) { gc->function = values->function; } |
|
|
if (mask & GCPlaneMask) { gc->plane_mask = values->plane_mask; } |
|
|
if (mask & GCForeground) { gc->foreground = values->foreground; } |
|
|
if (mask & GCBackground) { gc->background = values->background; } |
|
|
if (mask & GCLineWidth) { gc->line_width = values->line_width; } |
|
|
if (mask & GCLineStyle) { gc->line_style = values->line_style; } |
|
|
if (mask & GCCapStyle) { gc->cap_style = values->cap_style; } |
|
|
if (mask & GCJoinStyle) { gc->join_style = values->join_style; } |
|
|
if (mask & GCFillStyle) { gc->fill_style = values->fill_style; } |
|
|
if (mask & GCFillRule) { gc->fill_rule = values->fill_rule; } |
|
|
if (mask & GCArcMode) { gc->arc_mode = values->arc_mode; } |
|
|
if (mask & GCTile) { gc->tile = values->tile; } |
|
|
if (mask & GCStipple) { gc->stipple = values->stipple; } |
|
|
if (mask & GCTileStipXOrigin) { gc->ts_x_origin = values->ts_x_origin; } |
|
|
if (mask & GCTileStipYOrigin) { gc->ts_y_origin = values->ts_y_origin; } |
|
|
if (mask & GCFont) { gc->font = values->font; } |
|
|
if (mask & GCSubwindowMode) { gc->subwindow_mode = values->subwindow_mode; } |
|
|
if (mask & GCGraphicsExposures) { gc->graphics_exposures = values->graphics_exposures; } |
|
|
if (mask & GCClipXOrigin) { gc->clip_x_origin = values->clip_x_origin; } |
|
|
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; (&(gc->dashes))[1] = 0;} |
|
|
} |
|
|
|
|
|
/* |
|
|
*---------------------------------------------------------------------- |
|
|
* |
|
|
* XFreeGC -- |
|
|
* |
|
|
* Deallocates the specified graphics context. |
|
|
* |
|
|
* Results: |
|
|
* None. |
|
|
* |
|
|
* Side effects: |
|
|
* None. |
|
|
* |
|
|
*---------------------------------------------------------------------- |
|
|
*/ |
|
|
|
|
|
void XFreeGC(d, gc) |
|
|
Display * d; |
|
|
GC gc; |
|
|
{ |
|
|
if (gc != None) { |
|
|
if (gc->clip_mask != None) { |
|
|
ckfree((char*) gc->clip_mask); |
|
|
} |
|
|
ckfree((char *) gc); |
|
|
} |
|
|
} |
|
|
|
|
|
/* |
|
|
*---------------------------------------------------------------------- |
|
|
* |
|
|
* XSetForeground, etc. -- |
|
|
* |
|
|
* The following functions are simply accessor functions for |
|
|
* the GC slots. |
|
|
* |
|
|
* Results: |
|
|
* None. |
|
|
* |
|
|
* Side effects: |
|
|
* Each function sets some slot in the GC. |
|
|
* |
|
|
*---------------------------------------------------------------------- |
|
|
*/ |
|
|
|
|
|
void |
|
|
XSetForeground(display, gc, foreground) |
|
|
Display *display; |
|
|
GC gc; |
|
|
unsigned long foreground; |
|
|
{ |
|
|
gc->foreground = foreground; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetBackground(display, gc, background) |
|
|
Display *display; |
|
|
GC gc; |
|
|
unsigned long background; |
|
|
{ |
|
|
gc->background = 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; |
|
|
int function; |
|
|
{ |
|
|
gc->function = function; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetFillRule(display, gc, fill_rule) |
|
|
Display *display; |
|
|
GC gc; |
|
|
int fill_rule; |
|
|
{ |
|
|
gc->fill_rule = fill_rule; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetFillStyle(display, gc, fill_style) |
|
|
Display *display; |
|
|
GC gc; |
|
|
int fill_style; |
|
|
{ |
|
|
gc->fill_style = fill_style; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetTSOrigin(display, gc, x, y) |
|
|
Display *display; |
|
|
GC gc; |
|
|
int x, y; |
|
|
{ |
|
|
gc->ts_x_origin = x; |
|
|
gc->ts_y_origin = y; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetFont(display, gc, font) |
|
|
Display *display; |
|
|
GC gc; |
|
|
Font font; |
|
|
{ |
|
|
gc->font = font; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetArcMode(display, gc, arc_mode) |
|
|
Display *display; |
|
|
GC gc; |
|
|
int arc_mode; |
|
|
{ |
|
|
gc->arc_mode = arc_mode; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetStipple(display, gc, stipple) |
|
|
Display *display; |
|
|
GC gc; |
|
|
Pixmap stipple; |
|
|
{ |
|
|
gc->stipple = stipple; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetLineAttributes(display, gc, line_width, line_style, cap_style, |
|
|
join_style) |
|
|
Display *display; |
|
|
GC gc; |
|
|
unsigned int line_width; |
|
|
int line_style; |
|
|
int cap_style; |
|
|
int join_style; |
|
|
{ |
|
|
gc->line_width = line_width; |
|
|
gc->line_style = line_style; |
|
|
gc->cap_style = cap_style; |
|
|
gc->join_style = join_style; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin) |
|
|
Display* display; |
|
|
GC gc; |
|
|
int clip_x_origin; |
|
|
int clip_y_origin; |
|
|
{ |
|
|
gc->clip_x_origin = clip_x_origin; |
|
|
gc->clip_y_origin = clip_y_origin; |
|
|
} |
|
|
|
|
|
/* |
|
|
*---------------------------------------------------------------------- |
|
|
* |
|
|
* TkSetRegion, XSetClipMask -- |
|
|
* |
|
|
* Sets the clipping region/pixmap for a GC. |
|
|
* |
|
|
* Note that unlike the Xlib equivalent, it is not safe to delete |
|
|
* the region after setting it into the GC. The only use of |
|
|
* TkSetRegion is currently in ImgPhotoDisplay, which uses the GC |
|
|
* immediately. |
|
|
* |
|
|
* Results: |
|
|
* None. |
|
|
* |
|
|
* Side effects: |
|
|
* Allocates or dealloates a TkpClipMask. |
|
|
* |
|
|
*---------------------------------------------------------------------- |
|
|
*/ |
|
|
|
|
|
void |
|
|
TkSetRegion(display, gc, r) |
|
|
Display* display; |
|
|
GC gc; |
|
|
TkRegion r; |
|
|
{ |
|
|
if (r == None) { |
|
|
if (gc->clip_mask) { |
|
|
ckfree((char*) gc->clip_mask); |
|
|
gc->clip_mask = None; |
|
|
} |
|
|
return; |
|
|
} |
|
|
|
|
|
if (gc->clip_mask == None) { |
|
|
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
|
|
} |
|
|
((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_REGION; |
|
|
((TkpClipMask*)gc->clip_mask)->value.region = r; |
|
|
} |
|
|
|
|
|
void |
|
|
XSetClipMask(display, gc, pixmap) |
|
|
Display* display; |
|
|
GC gc; |
|
|
Pixmap pixmap; |
|
|
{ |
|
|
if (pixmap == None) { |
|
|
if (gc->clip_mask) { |
|
|
ckfree((char*) gc->clip_mask); |
|
|
gc->clip_mask = None; |
|
|
} |
|
|
return; |
|
|
} |
|
|
|
|
|
if (gc->clip_mask == None) { |
|
|
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
|
|
} |
|
|
((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<npoints; i++) { |
|
|
XDrawPoint(display, d, gc, points[i].x, points[i].y); |
|
|
} |
|
|
} |
|
|
|
|
|
#ifndef MAC_TCL |
|
|
void |
|
|
XDrawSegments(display, d, gc, segments, nsegments) |
|
|
Display* display; |
|
|
Drawable d; |
|
|
GC gc; |
|
|
XSegment* segments; |
|
|
int nsegments; |
|
|
{ |
|
|
} |
|
|
#endif |
|
|
|
|
|
char * |
|
|
XFetchBuffer(display, nbytes_return, buffer) |
|
|
Display* display; |
|
|
int* nbytes_return; |
|
|
int buffer; |
|
|
{ |
|
|
return (char *) 0; |
|
|
} |
|
|
|
|
|
Status XFetchName(display, w, window_name_return) |
|
|
Display* display; |
|
|
Window w; |
|
|
char** window_name_return; |
|
|
{ |
|
|
return (Status) 0; |
|
|
} |
|
|
|
|
|
Atom *XListProperties(display, w, num_prop_return) |
|
|
Display* display; |
|
|
Window w; |
|
|
int* num_prop_return; |
|
|
{ |
|
|
return (Atom *) 0; |
|
|
} |
|
|
|
|
|
void |
|
|
XMapRaised(display, w) |
|
|
Display* display; |
|
|
Window w; |
|
|
{ |
|
|
} |
|
|
|
|
|
void |
|
|
XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height) |
|
|
Display* display; |
|
|
Drawable d; |
|
|
GC gc; |
|
|
XImage* image; |
|
|
int src_x; |
|
|
int src_y; |
|
|
int dest_x; |
|
|
int dest_y; |
|
|
unsigned int width; |
|
|
unsigned int height; |
|
|
{ |
|
|
} |
|
|
|
|
|
void XQueryTextExtents(display, font_ID, string, nchars, direction_return, |
|
|
font_ascent_return, font_descent_return, overall_return) |
|
|
Display* display; |
|
|
XID font_ID; |
|
|
_Xconst char* string; |
|
|
int nchars; |
|
|
int* direction_return; |
|
|
int* font_ascent_return; |
|
|
int* font_descent_return; |
|
|
XCharStruct* overall_return; |
|
|
{ |
|
|
} |
|
|
|
|
|
void |
|
|
XReparentWindow(display, w, parent, x, y) |
|
|
Display* display; |
|
|
Window w; |
|
|
Window parent; |
|
|
int x; |
|
|
int y; |
|
|
{ |
|
|
} |
|
|
|
|
|
void |
|
|
XRotateBuffers(display, rotate) |
|
|
Display* display; |
|
|
int rotate; |
|
|
{ |
|
|
} |
|
|
|
|
|
void |
|
|
XStoreBuffer(display, bytes, nbytes, buffer) |
|
|
Display* display; |
|
|
_Xconst char* bytes; |
|
|
int nbytes; |
|
|
int buffer; |
|
|
{ |
|
|
} |
|
|
|
|
|
void |
|
|
XUndefineCursor(display, w) |
|
|
Display* display; |
|
|
Window w; |
|
|
{ |
|
|
} |
|
|
|
|
|
|
|
|
/* $History: xgc.c $ |
|
|
* |
|
|
* ***************** Version 1 ***************** |
|
|
* User: Dtashley Date: 1/02/01 Time: 3:21a |
|
|
* Created in $/IjuScripter, IjuConsole/Source/Tk Base |
|
|
* Initial check-in. |
|
|
*/ |
|
|
|
|
|
/* End of XGC.C */ |
|
1 |
|
/* $Header$ */ |
2 |
|
|
3 |
|
/* |
4 |
|
* xgc.c -- |
5 |
|
* |
6 |
|
* This file contains generic routines for manipulating X graphics |
7 |
|
* contexts. |
8 |
|
* |
9 |
|
* Copyright (c) 1995-1996 Sun Microsystems, Inc. |
10 |
|
* |
11 |
|
* See the file "license.terms" for information on usage and redistribution |
12 |
|
* of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
13 |
|
* |
14 |
|
* RCS: @(#) $Id: xgc.c,v 1.1.1.1 2001/06/13 05:15:43 dtashley Exp $ |
15 |
|
*/ |
16 |
|
|
17 |
|
#include "tkInt.h" |
18 |
|
|
19 |
|
#ifdef MAC_TCL |
20 |
|
# include <Xlib.h> |
21 |
|
# include <X.h> |
22 |
|
# define Cursor XCursor |
23 |
|
# define Region XRegion |
24 |
|
#else |
25 |
|
# include "Xlib.h" |
26 |
|
#endif |
27 |
|
|
28 |
|
|
29 |
|
/* |
30 |
|
*---------------------------------------------------------------------- |
31 |
|
* |
32 |
|
* XCreateGC -- |
33 |
|
* |
34 |
|
* Allocate a new GC, and initialize the specified fields. |
35 |
|
* |
36 |
|
* Results: |
37 |
|
* Returns a newly allocated GC. |
38 |
|
* |
39 |
|
* Side effects: |
40 |
|
* None. |
41 |
|
* |
42 |
|
*---------------------------------------------------------------------- |
43 |
|
*/ |
44 |
|
|
45 |
|
GC |
46 |
|
XCreateGC(display, d, mask, values) |
47 |
|
Display* display; |
48 |
|
Drawable d; |
49 |
|
unsigned long mask; |
50 |
|
XGCValues* values; |
51 |
|
{ |
52 |
|
GC gp; |
53 |
|
|
54 |
|
/* |
55 |
|
* In order to have room for a dash list, MAX_DASH_LIST_SIZE extra chars are |
56 |
|
* defined, which is invisible from the outside. The list is assumed to end |
57 |
|
* with a 0-char, so this must be set explicitely during initialization. |
58 |
|
*/ |
59 |
|
|
60 |
|
#define MAX_DASH_LIST_SIZE 10 |
61 |
|
|
62 |
|
gp = (XGCValues *)ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); |
63 |
|
if (!gp) { |
64 |
|
return None; |
65 |
|
} |
66 |
|
|
67 |
|
gp->function = (mask & GCFunction) ?values->function :GXcopy; |
68 |
|
gp->plane_mask = (mask & GCPlaneMask) ?values->plane_mask :~0; |
69 |
|
gp->foreground = (mask & GCForeground) ?values->foreground :0; |
70 |
|
gp->background = (mask & GCBackground) ?values->background :0xffffff; |
71 |
|
gp->line_width = (mask & GCLineWidth) ?values->line_width :0; |
72 |
|
gp->line_style = (mask & GCLineStyle) ?values->line_style :LineSolid; |
73 |
|
gp->cap_style = (mask & GCCapStyle) ?values->cap_style :0; |
74 |
|
gp->join_style = (mask & GCJoinStyle) ?values->join_style :0; |
75 |
|
gp->fill_style = (mask & GCFillStyle) ?values->fill_style :FillSolid; |
76 |
|
gp->fill_rule = (mask & GCFillRule) ?values->fill_rule :WindingRule; |
77 |
|
gp->arc_mode = (mask & GCArcMode) ?values->arc_mode :ArcPieSlice; |
78 |
|
gp->tile = (mask & GCTile) ?values->tile :None; |
79 |
|
gp->stipple = (mask & GCStipple) ?values->stipple :None; |
80 |
|
gp->ts_x_origin = (mask & GCTileStipXOrigin) ?values->ts_x_origin:0; |
81 |
|
gp->ts_y_origin = (mask & GCTileStipYOrigin) ?values->ts_y_origin:0; |
82 |
|
gp->font = (mask & GCFont) ?values->font :None; |
83 |
|
gp->subwindow_mode = (mask & GCSubwindowMode)?values->subwindow_mode:ClipByChildren; |
84 |
|
gp->graphics_exposures = (mask & GCGraphicsExposures)?values->graphics_exposures:True; |
85 |
|
gp->clip_x_origin = (mask & GCClipXOrigin) ?values->clip_x_origin :0; |
86 |
|
gp->clip_y_origin = (mask & GCClipYOrigin) ?values->clip_y_origin :0; |
87 |
|
gp->dash_offset = (mask & GCDashOffset) ?values->dash_offset :0; |
88 |
|
gp->dashes = (mask & GCDashList) ?values->dashes :4; |
89 |
|
(&(gp->dashes))[1] = 0; |
90 |
|
|
91 |
|
if (mask & GCClipMask) { |
92 |
|
gp->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
93 |
|
((TkpClipMask*)gp->clip_mask)->type = TKP_CLIP_PIXMAP; |
94 |
|
((TkpClipMask*)gp->clip_mask)->value.pixmap = values->clip_mask; |
95 |
|
} else { |
96 |
|
gp->clip_mask = None; |
97 |
|
} |
98 |
|
|
99 |
|
return gp; |
100 |
|
} |
101 |
|
|
102 |
|
/* |
103 |
|
*---------------------------------------------------------------------- |
104 |
|
* |
105 |
|
* XChangeGC -- |
106 |
|
* |
107 |
|
* Changes the GC components specified by valuemask for the |
108 |
|
* specified GC. |
109 |
|
* |
110 |
|
* Results: |
111 |
|
* None. |
112 |
|
* |
113 |
|
* Side effects: |
114 |
|
* Updates the specified GC. |
115 |
|
* |
116 |
|
*---------------------------------------------------------------------- |
117 |
|
*/ |
118 |
|
|
119 |
|
void |
120 |
|
XChangeGC(d, gc, mask, values) |
121 |
|
Display * d; |
122 |
|
GC gc; |
123 |
|
unsigned long mask; |
124 |
|
XGCValues *values; |
125 |
|
{ |
126 |
|
if (mask & GCFunction) { gc->function = values->function; } |
127 |
|
if (mask & GCPlaneMask) { gc->plane_mask = values->plane_mask; } |
128 |
|
if (mask & GCForeground) { gc->foreground = values->foreground; } |
129 |
|
if (mask & GCBackground) { gc->background = values->background; } |
130 |
|
if (mask & GCLineWidth) { gc->line_width = values->line_width; } |
131 |
|
if (mask & GCLineStyle) { gc->line_style = values->line_style; } |
132 |
|
if (mask & GCCapStyle) { gc->cap_style = values->cap_style; } |
133 |
|
if (mask & GCJoinStyle) { gc->join_style = values->join_style; } |
134 |
|
if (mask & GCFillStyle) { gc->fill_style = values->fill_style; } |
135 |
|
if (mask & GCFillRule) { gc->fill_rule = values->fill_rule; } |
136 |
|
if (mask & GCArcMode) { gc->arc_mode = values->arc_mode; } |
137 |
|
if (mask & GCTile) { gc->tile = values->tile; } |
138 |
|
if (mask & GCStipple) { gc->stipple = values->stipple; } |
139 |
|
if (mask & GCTileStipXOrigin) { gc->ts_x_origin = values->ts_x_origin; } |
140 |
|
if (mask & GCTileStipYOrigin) { gc->ts_y_origin = values->ts_y_origin; } |
141 |
|
if (mask & GCFont) { gc->font = values->font; } |
142 |
|
if (mask & GCSubwindowMode) { gc->subwindow_mode = values->subwindow_mode; } |
143 |
|
if (mask & GCGraphicsExposures) { gc->graphics_exposures = values->graphics_exposures; } |
144 |
|
if (mask & GCClipXOrigin) { gc->clip_x_origin = values->clip_x_origin; } |
145 |
|
if (mask & GCClipYOrigin) { gc->clip_y_origin = values->clip_y_origin; } |
146 |
|
if (mask & GCClipMask) { XSetClipMask(d, gc, values->clip_mask); } |
147 |
|
if (mask & GCDashOffset) { gc->dash_offset = values->dash_offset; } |
148 |
|
if (mask & GCDashList) { gc->dashes = values->dashes; (&(gc->dashes))[1] = 0;} |
149 |
|
} |
150 |
|
|
151 |
|
/* |
152 |
|
*---------------------------------------------------------------------- |
153 |
|
* |
154 |
|
* XFreeGC -- |
155 |
|
* |
156 |
|
* Deallocates the specified graphics context. |
157 |
|
* |
158 |
|
* Results: |
159 |
|
* None. |
160 |
|
* |
161 |
|
* Side effects: |
162 |
|
* None. |
163 |
|
* |
164 |
|
*---------------------------------------------------------------------- |
165 |
|
*/ |
166 |
|
|
167 |
|
void XFreeGC(d, gc) |
168 |
|
Display * d; |
169 |
|
GC gc; |
170 |
|
{ |
171 |
|
if (gc != None) { |
172 |
|
if (gc->clip_mask != None) { |
173 |
|
ckfree((char*) gc->clip_mask); |
174 |
|
} |
175 |
|
ckfree((char *) gc); |
176 |
|
} |
177 |
|
} |
178 |
|
|
179 |
|
/* |
180 |
|
*---------------------------------------------------------------------- |
181 |
|
* |
182 |
|
* XSetForeground, etc. -- |
183 |
|
* |
184 |
|
* The following functions are simply accessor functions for |
185 |
|
* the GC slots. |
186 |
|
* |
187 |
|
* Results: |
188 |
|
* None. |
189 |
|
* |
190 |
|
* Side effects: |
191 |
|
* Each function sets some slot in the GC. |
192 |
|
* |
193 |
|
*---------------------------------------------------------------------- |
194 |
|
*/ |
195 |
|
|
196 |
|
void |
197 |
|
XSetForeground(display, gc, foreground) |
198 |
|
Display *display; |
199 |
|
GC gc; |
200 |
|
unsigned long foreground; |
201 |
|
{ |
202 |
|
gc->foreground = foreground; |
203 |
|
} |
204 |
|
|
205 |
|
void |
206 |
|
XSetBackground(display, gc, background) |
207 |
|
Display *display; |
208 |
|
GC gc; |
209 |
|
unsigned long background; |
210 |
|
{ |
211 |
|
gc->background = background; |
212 |
|
} |
213 |
|
|
214 |
|
void |
215 |
|
XSetDashes(display, gc, dash_offset, dash_list, n) |
216 |
|
Display* display; |
217 |
|
GC gc; |
218 |
|
int dash_offset; |
219 |
|
_Xconst char* dash_list; |
220 |
|
int n; |
221 |
|
{ |
222 |
|
char *p = &(gc->dashes); |
223 |
|
|
224 |
|
#ifdef TkWinDeleteBrush |
225 |
|
TkWinDeleteBrush(gc->fgBrush); |
226 |
|
TkWinDeletePen(gc->fgPen); |
227 |
|
TkWinDeleteBrush(gc->bgBrush); |
228 |
|
TkWinDeletePen(gc->fgExtPen); |
229 |
|
#endif |
230 |
|
gc->dash_offset = dash_offset; |
231 |
|
if (n > MAX_DASH_LIST_SIZE) n = MAX_DASH_LIST_SIZE; |
232 |
|
while (n-- > 0) { |
233 |
|
*p++ = *dash_list++; |
234 |
|
} |
235 |
|
*p = 0; |
236 |
|
} |
237 |
|
|
238 |
|
void |
239 |
|
XSetFunction(display, gc, function) |
240 |
|
Display *display; |
241 |
|
GC gc; |
242 |
|
int function; |
243 |
|
{ |
244 |
|
gc->function = function; |
245 |
|
} |
246 |
|
|
247 |
|
void |
248 |
|
XSetFillRule(display, gc, fill_rule) |
249 |
|
Display *display; |
250 |
|
GC gc; |
251 |
|
int fill_rule; |
252 |
|
{ |
253 |
|
gc->fill_rule = fill_rule; |
254 |
|
} |
255 |
|
|
256 |
|
void |
257 |
|
XSetFillStyle(display, gc, fill_style) |
258 |
|
Display *display; |
259 |
|
GC gc; |
260 |
|
int fill_style; |
261 |
|
{ |
262 |
|
gc->fill_style = fill_style; |
263 |
|
} |
264 |
|
|
265 |
|
void |
266 |
|
XSetTSOrigin(display, gc, x, y) |
267 |
|
Display *display; |
268 |
|
GC gc; |
269 |
|
int x, y; |
270 |
|
{ |
271 |
|
gc->ts_x_origin = x; |
272 |
|
gc->ts_y_origin = y; |
273 |
|
} |
274 |
|
|
275 |
|
void |
276 |
|
XSetFont(display, gc, font) |
277 |
|
Display *display; |
278 |
|
GC gc; |
279 |
|
Font font; |
280 |
|
{ |
281 |
|
gc->font = font; |
282 |
|
} |
283 |
|
|
284 |
|
void |
285 |
|
XSetArcMode(display, gc, arc_mode) |
286 |
|
Display *display; |
287 |
|
GC gc; |
288 |
|
int arc_mode; |
289 |
|
{ |
290 |
|
gc->arc_mode = arc_mode; |
291 |
|
} |
292 |
|
|
293 |
|
void |
294 |
|
XSetStipple(display, gc, stipple) |
295 |
|
Display *display; |
296 |
|
GC gc; |
297 |
|
Pixmap stipple; |
298 |
|
{ |
299 |
|
gc->stipple = stipple; |
300 |
|
} |
301 |
|
|
302 |
|
void |
303 |
|
XSetLineAttributes(display, gc, line_width, line_style, cap_style, |
304 |
|
join_style) |
305 |
|
Display *display; |
306 |
|
GC gc; |
307 |
|
unsigned int line_width; |
308 |
|
int line_style; |
309 |
|
int cap_style; |
310 |
|
int join_style; |
311 |
|
{ |
312 |
|
gc->line_width = line_width; |
313 |
|
gc->line_style = line_style; |
314 |
|
gc->cap_style = cap_style; |
315 |
|
gc->join_style = join_style; |
316 |
|
} |
317 |
|
|
318 |
|
void |
319 |
|
XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin) |
320 |
|
Display* display; |
321 |
|
GC gc; |
322 |
|
int clip_x_origin; |
323 |
|
int clip_y_origin; |
324 |
|
{ |
325 |
|
gc->clip_x_origin = clip_x_origin; |
326 |
|
gc->clip_y_origin = clip_y_origin; |
327 |
|
} |
328 |
|
|
329 |
|
/* |
330 |
|
*---------------------------------------------------------------------- |
331 |
|
* |
332 |
|
* TkSetRegion, XSetClipMask -- |
333 |
|
* |
334 |
|
* Sets the clipping region/pixmap for a GC. |
335 |
|
* |
336 |
|
* Note that unlike the Xlib equivalent, it is not safe to delete |
337 |
|
* the region after setting it into the GC. The only use of |
338 |
|
* TkSetRegion is currently in ImgPhotoDisplay, which uses the GC |
339 |
|
* immediately. |
340 |
|
* |
341 |
|
* Results: |
342 |
|
* None. |
343 |
|
* |
344 |
|
* Side effects: |
345 |
|
* Allocates or dealloates a TkpClipMask. |
346 |
|
* |
347 |
|
*---------------------------------------------------------------------- |
348 |
|
*/ |
349 |
|
|
350 |
|
void |
351 |
|
TkSetRegion(display, gc, r) |
352 |
|
Display* display; |
353 |
|
GC gc; |
354 |
|
TkRegion r; |
355 |
|
{ |
356 |
|
if (r == None) { |
357 |
|
if (gc->clip_mask) { |
358 |
|
ckfree((char*) gc->clip_mask); |
359 |
|
gc->clip_mask = None; |
360 |
|
} |
361 |
|
return; |
362 |
|
} |
363 |
|
|
364 |
|
if (gc->clip_mask == None) { |
365 |
|
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
366 |
|
} |
367 |
|
((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_REGION; |
368 |
|
((TkpClipMask*)gc->clip_mask)->value.region = r; |
369 |
|
} |
370 |
|
|
371 |
|
void |
372 |
|
XSetClipMask(display, gc, pixmap) |
373 |
|
Display* display; |
374 |
|
GC gc; |
375 |
|
Pixmap pixmap; |
376 |
|
{ |
377 |
|
if (pixmap == None) { |
378 |
|
if (gc->clip_mask) { |
379 |
|
ckfree((char*) gc->clip_mask); |
380 |
|
gc->clip_mask = None; |
381 |
|
} |
382 |
|
return; |
383 |
|
} |
384 |
|
|
385 |
|
if (gc->clip_mask == None) { |
386 |
|
gc->clip_mask = (Pixmap)ckalloc(sizeof(TkpClipMask)); |
387 |
|
} |
388 |
|
((TkpClipMask*)gc->clip_mask)->type = TKP_CLIP_PIXMAP; |
389 |
|
((TkpClipMask*)gc->clip_mask)->value.pixmap = pixmap; |
390 |
|
} |
391 |
|
|
392 |
|
/* |
393 |
|
* Some additional dummy functions (hopefully implemented soon). |
394 |
|
*/ |
395 |
|
|
396 |
|
Cursor |
397 |
|
XCreateFontCursor(display, shape) |
398 |
|
Display* display; |
399 |
|
unsigned int shape; |
400 |
|
{ |
401 |
|
return (Cursor) 0; |
402 |
|
} |
403 |
|
|
404 |
|
void |
405 |
|
XDrawImageString(display, d, gc, x, y, string, length) |
406 |
|
Display* display; |
407 |
|
Drawable d; |
408 |
|
GC gc; |
409 |
|
int x; |
410 |
|
int y; |
411 |
|
_Xconst char* string; |
412 |
|
int length; |
413 |
|
{ |
414 |
|
} |
415 |
|
|
416 |
|
void |
417 |
|
XDrawPoint(display, d, gc, x, y) |
418 |
|
Display* display; |
419 |
|
Drawable d; |
420 |
|
GC gc; |
421 |
|
int x; |
422 |
|
int y; |
423 |
|
{ |
424 |
|
XDrawLine(display, d, gc, x, y, x, y); |
425 |
|
} |
426 |
|
|
427 |
|
void |
428 |
|
XDrawPoints(display, d, gc, points, npoints, mode) |
429 |
|
Display* display; |
430 |
|
Drawable d; |
431 |
|
GC gc; |
432 |
|
XPoint* points; |
433 |
|
int npoints; |
434 |
|
int mode; |
435 |
|
{ |
436 |
|
int i; |
437 |
|
|
438 |
|
for (i=0; i<npoints; i++) { |
439 |
|
XDrawPoint(display, d, gc, points[i].x, points[i].y); |
440 |
|
} |
441 |
|
} |
442 |
|
|
443 |
|
#ifndef MAC_TCL |
444 |
|
void |
445 |
|
XDrawSegments(display, d, gc, segments, nsegments) |
446 |
|
Display* display; |
447 |
|
Drawable d; |
448 |
|
GC gc; |
449 |
|
XSegment* segments; |
450 |
|
int nsegments; |
451 |
|
{ |
452 |
|
} |
453 |
|
#endif |
454 |
|
|
455 |
|
char * |
456 |
|
XFetchBuffer(display, nbytes_return, buffer) |
457 |
|
Display* display; |
458 |
|
int* nbytes_return; |
459 |
|
int buffer; |
460 |
|
{ |
461 |
|
return (char *) 0; |
462 |
|
} |
463 |
|
|
464 |
|
Status XFetchName(display, w, window_name_return) |
465 |
|
Display* display; |
466 |
|
Window w; |
467 |
|
char** window_name_return; |
468 |
|
{ |
469 |
|
return (Status) 0; |
470 |
|
} |
471 |
|
|
472 |
|
Atom *XListProperties(display, w, num_prop_return) |
473 |
|
Display* display; |
474 |
|
Window w; |
475 |
|
int* num_prop_return; |
476 |
|
{ |
477 |
|
return (Atom *) 0; |
478 |
|
} |
479 |
|
|
480 |
|
void |
481 |
|
XMapRaised(display, w) |
482 |
|
Display* display; |
483 |
|
Window w; |
484 |
|
{ |
485 |
|
} |
486 |
|
|
487 |
|
void |
488 |
|
XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height) |
489 |
|
Display* display; |
490 |
|
Drawable d; |
491 |
|
GC gc; |
492 |
|
XImage* image; |
493 |
|
int src_x; |
494 |
|
int src_y; |
495 |
|
int dest_x; |
496 |
|
int dest_y; |
497 |
|
unsigned int width; |
498 |
|
unsigned int height; |
499 |
|
{ |
500 |
|
} |
501 |
|
|
502 |
|
void XQueryTextExtents(display, font_ID, string, nchars, direction_return, |
503 |
|
font_ascent_return, font_descent_return, overall_return) |
504 |
|
Display* display; |
505 |
|
XID font_ID; |
506 |
|
_Xconst char* string; |
507 |
|
int nchars; |
508 |
|
int* direction_return; |
509 |
|
int* font_ascent_return; |
510 |
|
int* font_descent_return; |
511 |
|
XCharStruct* overall_return; |
512 |
|
{ |
513 |
|
} |
514 |
|
|
515 |
|
void |
516 |
|
XReparentWindow(display, w, parent, x, y) |
517 |
|
Display* display; |
518 |
|
Window w; |
519 |
|
Window parent; |
520 |
|
int x; |
521 |
|
int y; |
522 |
|
{ |
523 |
|
} |
524 |
|
|
525 |
|
void |
526 |
|
XRotateBuffers(display, rotate) |
527 |
|
Display* display; |
528 |
|
int rotate; |
529 |
|
{ |
530 |
|
} |
531 |
|
|
532 |
|
void |
533 |
|
XStoreBuffer(display, bytes, nbytes, buffer) |
534 |
|
Display* display; |
535 |
|
_Xconst char* bytes; |
536 |
|
int nbytes; |
537 |
|
int buffer; |
538 |
|
{ |
539 |
|
} |
540 |
|
|
541 |
|
void |
542 |
|
XUndefineCursor(display, w) |
543 |
|
Display* display; |
544 |
|
Window w; |
545 |
|
{ |
546 |
|
} |
547 |
|
|
548 |
|
/* End of xgc.c */ |