'\" '\" Copyright (c) 1990 The Regents of the University of California. '\" Copyright (c) 1994-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: GetGC.3,v 1.1.4.1 1998/09/30 02:15:55 stanton Exp $ '\" .so man.macros .TH Tk_GetGC 3 "" Tk "Tk Library Procedures" .BS .SH NAME Tk_GetGC, Tk_FreeGC \- maintain database of read-only graphics contexts .SH SYNOPSIS .nf \fB#include \fR .sp GC \fBTk_GetGC\fR(\fItkwin, valueMask, valuePtr\fR) .sp \fBTk_FreeGC(\fIdisplay, gc\fR) .SH ARGUMENTS .AS "unsigned long" valueMask .AP Tk_Window tkwin in Token for window in which the graphics context will be used. .AP "unsigned long" valueMask in Mask of bits (such as \fBGCForeground\fR or \fBGCStipple\fR) indicating which fields of \fI*valuePtr\fR are valid. .AP XGCValues *valuePtr in Pointer to structure describing the desired values for the graphics context. .AP Display *display in Display for which \fIgc\fR was allocated. .AP GC gc in X identifier for graphics context that is no longer needed. Must have been allocated by \fBTk_GetGC\fR. .BE .SH DESCRIPTION .PP \fBTk_GetGC\fR and \fBTk_FreeGC\fR manage a collection of graphics contexts being used by an application. The procedures allow graphics contexts to be shared, thereby avoiding the server overhead that would be incurred if a separate GC were created for each use. \fBTk_GetGC\fR takes arguments describing the desired graphics context and returns an X identifier for a GC that fits the description. The graphics context that is returned will have default values in all of the fields not specified explicitly by \fIvalueMask\fR and \fIvaluePtr\fR. .PP \fBTk_GetGC\fR maintains a database of all the graphics contexts it has created. Whenever possible, a call to \fBTk_GetGC\fR will return an existing graphics context rather than creating a new one. This approach can substantially reduce server overhead, so \fBTk_GetGC\fR should generally be used in preference to the Xlib procedure \fBXCreateGC\fR, which creates a new graphics context on each call. .PP Since the return values of \fBTk_GetGC\fR are shared, callers should never modify the graphics contexts returned by \fBTk_GetGC\fR. If a graphics context must be modified dynamically, then it should be created by calling \fBXCreateGC\fR instead of \fBTk_GetGC\fR. .PP When a graphics context is no longer needed, \fBTk_FreeGC\fR should be called to release it. There should be exactly one call to \fBTk_FreeGC\fR for each call to \fBTk_GetGC\fR. When a graphics context is no longer in use anywhere (i.e. it has been freed as many times as it has been gotten) \fBTk_FreeGC\fR will release it to the X server and delete it from the database. .SH KEYWORDS graphics context