NAME
XCreateGC − create a new graphics context for a given screen with the depth of the specified drawable.
Synopsis
GC XCreateGC(display, drawable, valuemask, values)
Display *display;
Drawable drawable;
unsigned long valuemask;
XGCValues *values;
Arguments
displaySpecifies a connection to an X server; returned from XOpenDisplay().
drawableSpecifies a drawable. The created GC can only be used to draw in drawables of the same depth as this drawable.
valuemaskSpecifies which members of the GC are to be set using information in the values structure. valuemask is made by combining any number of the mask symbols listed in the Structures section.
valuesSpecifies a pointer to an XGCValues structure which will provide components for the new GC.
Description
XCreateGC() creates a new graphics context resource in the server. The returned GC can be used in subsequent drawing requests, but only on drawables on the same screen and of the same depth as the drawable specified in the drawable argument. The specified components of the new graphics context in valuemask are set to the values passed in the values argument. Unset components default as follows:
| Component | Value | ||
| function | GX copy | ||
| plane_mask | all 1’s | ||
| foreground | 0 | ||
| background | 1 | ||
| line_width | 0 | ||
| line_style | LineSolid | ||
| cap_style | CapButt | ||
| join_style | JoinMiter | ||
| fill_style | FillSolid | ||
| fill_rule | EvenOddRule | ||
| arc_mode | ArcPieSlice | ||
| tile | Pixmap filled with foreground pixel | ||
| stipple | Pixmap filled with 1’s |
| Component | Value | ||
| ts_x_origin | 0 | ||
| ts_y_origin | 0 | ||
| font | (implementation dependent) | ||
| subwindow_mode | ClipByChildren | ||
| graphics_exposures | True | ||
| clip_x_origin | 0 | ||
| clip_y_origin | 0 | ||
| clip_mask | None | ||
| dash_offset | 0 | ||
| dashes | 4 (i.e., the list [4, 4]) |
An application should minimize the number of GCs it creates, because some servers cache a limited number of GCs in the display hardware, and can attain better performance with a small number of GCs. For more information, see Volume One, Chapter 5, The Graphics Context.
Errors
BadAllocServer could not allocate memory for GC.
BadDrawable
Specified drawable is invalid.
BadFontFont specified for font component of GC has not been loaded.
BadMatchPixmap specified for tile component has different depth or is on different screen from the specified drawable. Or pixmap specified for stipple or clip_mask component has depth other than 1.
BadPixmapPixmap specified for tile, stipple, or clip_mask components is invalid.
BadValueValues specified for function, line_style, cap_style, join_style, fill_style, fill_rule, subwindow_mode, graphics_exposures, dashes, or arc_mode are invalid, or invalid mask specified for valuemask argument.
Structures
typedef struct {
int function;/* logical operation */
unsigned long plane_mask;/* plane mask */
unsigned long foreground;/* foreground pixel */
unsigned long background;/* background pixel */
int line_width;/* line width */
int line_style;/* LineSolid, LineOnOffDash, LineDoubleDash */
int cap_style;/* CapNotLast, CapButt, CapRound, CapProjecting */
int join_style;/* JoinMiter, JoinRound, JoinBevel */
int fill_style;/* FillSolid, FillTiled, FillStippled */
int fill_rule;/* EvenOddRule, WindingRule */
int arc_mode;/* ArcPieSlice, ArcChord */
Pixmap tile;/* tile pixmap for tiling operations */
Pixmap stipple;/* stipple 1 plane pixmap for stipping */
int ts_x_origin;/* offset for tile or stipple operations */
int ts_y_origin;
Font font;/* default text font for text operations */
int subwindow_mode;/* ClipByChildren, IncludeInferiors */
Bool graphics_exposures;/* generate events on XCopyArea, XCopyPlane */
int clip_x_origin;/* origin for clipping */
int clip_y_origin;
Pixmap clip_mask;/* bitmap clipping; other calls for rects */
int dash_offset;/* patterned/dashed line information */
char dashes;
} XGCValues;
#define GCFunction (1L<<0)
#define GCPlaneMask (1L<<1)
#define GCForeground (1L<<2)
#define GCBackground (1L<<3)
#define GCLineWidth (1L<<4)
#define GCLineStyle (1L<<5)
#define GCCapStyle (1L<<6)
#define GCJoinStyle (1L<<7)
#define GCFillStyle (1L<<8)
#define GCFillRule (1L<<9)
#define GCTile (1L<<10)
#define GCStipple (1L<<11)
#define GCTileStipXOrigin (1L<<12)
#define GCTileStipYOrigin (1L<<13)
#define GCFont (1L<<14)
#define GCSubwindowMode (1L<<15)
#define GCGraphicsExposures (1L<<16)
#define GCClipXOrigin (1L<<17)
#define GCClipYOrigin (1L<<18)
#define GCClipMask (1L<<19)
#define GCDashOffset (1L<<20)
#define GCDashList (1L<<21)
#define GCArcMode (1L<<22)
See Also
DefaultGC(), XChangeGC(), XCopyGC(), XFreeGC(), XGContextFromGC(), XGetGCValues(), XSetArcMode(), XSetBackground(), XSetClipMask(), XSetClipOrigin(), XSetClipRectangles(), XSetDashes(), XSetFillRule(), XSetFillStyle(), XSetForeground(), XSetFunction(), XSetGraphicsExposures(), XSetLineAttributes(), XSetPlaneMask(), XSetState(), XSetStipple(), XSetSubwindowMode(), XSetTSOrigin().
Copyright O’Reilly & Assoc. —