GetGCVals.c revision 1ab64890
1/* $Xorg: GetGCVals.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
2
3/*
4
5Copyright 1989, 1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27*/
28
29#ifdef HAVE_CONFIG_H
30#include <config.h>
31#endif
32#include "Xlibint.h"
33
34/*
35 * All gc fields except GCClipMask and GCDashList
36 */
37#define ValidGCValuesBits (GCFunction | GCPlaneMask | GCForeground | \
38			   GCBackground | GCLineWidth | GCLineStyle | \
39			   GCCapStyle | GCJoinStyle | GCFillStyle | \
40			   GCFillRule | GCTile | GCStipple | \
41			   GCTileStipXOrigin | GCTileStipYOrigin | \
42			   GCFont | GCSubwindowMode | GCGraphicsExposures | \
43			   GCClipXOrigin | GCClipYOrigin | GCDashOffset | \
44			   GCArcMode)
45
46/*ARGSUSED*/
47Status XGetGCValues (
48    Display *dpy,
49    GC gc,
50    unsigned long valuemask,
51    XGCValues *values)
52{
53    if (valuemask == ValidGCValuesBits) {
54	char dashes = values->dashes;
55	Pixmap clip_mask = values->clip_mask;
56	*values = gc->values;
57	values->dashes = dashes;
58	values->clip_mask = clip_mask;
59	return True;
60    }
61
62    if (valuemask & ~ValidGCValuesBits) return False;
63
64    if (valuemask & GCFunction)
65      values->function = gc->values.function;
66
67    if (valuemask & GCPlaneMask)
68      values->plane_mask = gc->values.plane_mask;
69
70    if (valuemask & GCForeground)
71      values->foreground = gc->values.foreground;
72
73    if (valuemask & GCBackground)
74      values->background = gc->values.background;
75
76    if (valuemask & GCLineWidth)
77      values->line_width = gc->values.line_width;
78
79    if (valuemask & GCLineStyle)
80      values->line_style = gc->values.line_style;
81
82    if (valuemask & GCCapStyle)
83      values->cap_style = gc->values.cap_style;
84
85    if (valuemask & GCJoinStyle)
86      values->join_style = gc->values.join_style;
87
88    if (valuemask & GCFillStyle)
89      values->fill_style = gc->values.fill_style;
90
91    if (valuemask & GCFillRule)
92      values->fill_rule = gc->values.fill_rule;
93
94    if (valuemask & GCTile)
95      values->tile = gc->values.tile;
96
97    if (valuemask & GCStipple)
98      values->stipple = gc->values.stipple;
99
100    if (valuemask & GCTileStipXOrigin)
101      values->ts_x_origin = gc->values.ts_x_origin;
102
103    if (valuemask & GCTileStipYOrigin)
104      values->ts_y_origin = gc->values.ts_y_origin;
105
106    if (valuemask & GCFont)
107      values->font = gc->values.font;
108
109    if (valuemask & GCSubwindowMode)
110      values->subwindow_mode = gc->values.subwindow_mode;
111
112    if (valuemask & GCGraphicsExposures)
113      values->graphics_exposures = gc->values.graphics_exposures;
114
115    if (valuemask & GCClipXOrigin)
116      values->clip_x_origin = gc->values.clip_x_origin;
117
118    if (valuemask & GCClipYOrigin)
119      values->clip_y_origin = gc->values.clip_y_origin;
120
121    if (valuemask & GCDashOffset)
122
123      values->dash_offset = gc->values.dash_offset;
124
125    if (valuemask & GCArcMode)
126      values->arc_mode = gc->values.arc_mode;
127
128    return True;
129}
130