Grip.c revision 7a84e134
1/* $Xorg: Grip.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
2
3/***********************************************************
4
5Copyright 1987, 1988, 1994, 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
28Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30                        All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49/* $XFree86: xc/lib/Xaw/Grip.c,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
50
51/*
52 * Grip.c - Grip Widget (Used by Paned Widget)
53 *
54 */
55#ifdef HAVE_CONFIG_H
56#include <config.h>
57#endif
58#include <X11/IntrinsicP.h>
59#include <X11/StringDefs.h>
60#include <X11/Xaw/GripP.h>
61#include <X11/Xaw/XawInit.h>
62
63/*
64 * Prototypes
65 */
66static void
67GripAction(Widget, XEvent*, String*, Cardinal*);
68
69/*
70 * Initialization
71 */
72static XtResource resources[] = {
73  {
74    XtNwidth,
75    XtCWidth,
76    XtRDimension,
77    sizeof(Dimension),
78    XtOffsetOf(GripRec, core.width),
79    XtRImmediate,
80    (XtPointer)DEFAULT_GRIP_SIZE
81  },
82  {
83    XtNheight,
84    XtCHeight,
85    XtRDimension,
86    sizeof(Dimension),
87    XtOffsetOf(GripRec, core.height),
88    XtRImmediate,
89    (XtPointer)DEFAULT_GRIP_SIZE
90  },
91  {
92    XtNforeground,
93    XtCForeground,
94    XtRPixel,
95    sizeof(Pixel),
96    XtOffsetOf(GripRec, core.background_pixel),
97    XtRString,
98    XtDefaultForeground
99  },
100  {
101    XtNborderWidth,
102    XtCBorderWidth,
103    XtRDimension,
104    sizeof(Dimension),
105    XtOffsetOf(GripRec, core.border_width),
106    XtRImmediate,
107    (XtPointer)0
108  },
109  {
110    XtNcallback,
111    XtCCallback,
112    XtRCallback,
113    sizeof(XtPointer),
114    XtOffsetOf(GripRec, grip.grip_action),
115    XtRCallback,
116    NULL
117  },
118};
119
120static XtActionsRec actionsList[] =
121{
122  {"GripAction",      GripAction},
123};
124
125#define Superclass	(&simpleClassRec)
126
127GripClassRec gripClassRec = {
128  /* core */
129   {
130     (WidgetClass)Superclass,		/* superclass */
131     "Grip",				/* class name */
132     sizeof(GripRec),			/* size */
133     XawInitializeWidgetSet,		/* class initialize */
134     NULL,				/* class_part_init */
135     False,				/* class_inited */
136     NULL,				/* initialize */
137     NULL,				/* initialize_hook */
138     XtInheritRealize,			/* realize */
139     actionsList,			/* actions */
140     XtNumber(actionsList),		/* num_actions */
141     resources,				/* resources */
142     XtNumber(resources),		/* num_resources */
143     NULLQUARK,				/* xrm_class */
144     True,				/* compress_motion */
145     True,				/* compress_exposure */
146     True,				/* compress_enterleave */
147     False,				/* visible_interest */
148     NULL,				/* destroy */
149     NULL,				/* resize */
150     XtInheritExpose,			/* expose */
151     NULL,				/* set_values */
152     NULL,				/* set_values_hook */
153     XtInheritSetValuesAlmost,		/* set_values_almost */
154     NULL,				/* get_values_hook */
155     NULL,				/* accept_focus */
156     XtVersion,				/* version */
157     NULL,				/* callback_private */
158     NULL,				/* tm_table */
159     XtInheritQueryGeometry,		/* query_geometry */
160     XtInheritDisplayAccelerator,	/* display_accelerator */
161     NULL,				/* extension */
162   },
163   /* simple */
164   {
165     XtInheritChangeSensitive,		/* change_sensitive */
166   },
167   /* grip */
168   {
169     NULL,				/* extension */
170   }
171};
172
173WidgetClass gripWidgetClass = (WidgetClass)&gripClassRec;
174
175/*
176 * Implementation
177 */
178static void
179GripAction(Widget widget, XEvent *event, String *params, Cardinal *num_params)
180{
181    XawGripCallDataRec call_data;
182
183    call_data.event = event;
184    call_data.params = params;
185    call_data.num_params = *num_params;
186
187    XtCallCallbacks(widget, XtNcallback, (XtPointer)&call_data);
188}
189