| 1 |
# Copyright (c) 1990 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Tk_GetGC, Tk_FreeGC - maintain database of read-only graphics contexts |
| 11 |
|
| 12 |
=for category C Programming |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
B<#include E<lt>tk.hE<gt>> |
| 17 |
|
| 18 |
GC |
| 19 |
B<Tk_GetGC>(I<tkwin, valueMask, valuePtr>) |
| 20 |
|
| 21 |
B<Tk_FreeGC(>I<display, gc>) |
| 22 |
|
| 23 |
=head1 ARGUMENTS |
| 24 |
|
| 25 |
=over 4 |
| 26 |
|
| 27 |
=item Tk_Window tkwin (in) |
| 28 |
|
| 29 |
Token for window in which the graphics context will be used. |
| 30 |
|
| 31 |
=item "unsigned long" valueMask (in) |
| 32 |
|
| 33 |
Mask of bits (such as B<GCForeground> or B<GCStipple>) |
| 34 |
indicating which fields of I<*valuePtr> are valid. |
| 35 |
|
| 36 |
=item XGCValues *valuePtr (in) |
| 37 |
|
| 38 |
Pointer to structure describing the desired values for the |
| 39 |
graphics context. |
| 40 |
|
| 41 |
=item Display *display (in) |
| 42 |
|
| 43 |
Display for which I<gc> was allocated. |
| 44 |
|
| 45 |
=item GC gc (in) |
| 46 |
|
| 47 |
X identifier for graphics context that is no longer needed. |
| 48 |
Must have been allocated by B<Tk_GetGC>. |
| 49 |
|
| 50 |
=back |
| 51 |
|
| 52 |
=head1 DESCRIPTION |
| 53 |
|
| 54 |
B<Tk_GetGC> and B<Tk_FreeGC> manage a collection of graphics contexts |
| 55 |
being used by an application. The procedures allow graphics contexts to be |
| 56 |
shared, thereby avoiding the server overhead that would be incurred |
| 57 |
if a separate GC were created for each use. B<Tk_GetGC> takes arguments |
| 58 |
describing the desired graphics context and returns an X identifier |
| 59 |
for a GC that fits the description. The graphics context that is returned |
| 60 |
will have default values in all of the fields not specified explicitly |
| 61 |
by I<valueMask> and I<valuePtr>. |
| 62 |
|
| 63 |
B<Tk_GetGC> maintains a |
| 64 |
database of all the graphics contexts it has created. Whenever possible, |
| 65 |
a call to B<Tk_GetGC> will |
| 66 |
return an existing graphics context rather than creating a new one. This |
| 67 |
approach can substantially reduce server overhead, so B<Tk_GetGC> |
| 68 |
should generally be used in preference to the Xlib procedure |
| 69 |
B<XCreateGC>, which creates a new graphics context on each call. |
| 70 |
|
| 71 |
Since the return values of B<Tk_GetGC> |
| 72 |
are shared, callers should never modify the graphics contexts |
| 73 |
returned by B<Tk_GetGC>. |
| 74 |
If a graphics context must be modified dynamically, then it should be |
| 75 |
created by calling B<XCreateGC> instead of B<Tk_GetGC>. |
| 76 |
|
| 77 |
When a graphics context |
| 78 |
is no longer needed, B<Tk_FreeGC> should be called to release it. |
| 79 |
There should be exactly one call to B<Tk_FreeGC> for |
| 80 |
each call to B<Tk_GetGC>. |
| 81 |
When a graphics context is no longer in use anywhere (i.e. it has |
| 82 |
been freed as many times as it has been gotten) B<Tk_FreeGC> |
| 83 |
will release it to the X server and delete it from the database. |
| 84 |
|
| 85 |
=head1 KEYWORDS |
| 86 |
|
| 87 |
graphics context |