2 * Copyright 1987, 1998 The Open Group
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 * Except as contained in this notice, the name of The Open Group shall not be
21 * used in advertising or otherwise to promote the sale, use or other dealings
22 * in this Software without prior written authorization from The Open Group.
26 * Copyright 2002 Red Hat Inc., Durham, North Carolina.
28 * All Rights Reserved.
30 * Permission is hereby granted, free of charge, to any person obtaining
31 * a copy of this software and associated documentation files (the
32 * "Software"), to deal in the Software without restriction, including
33 * without limitation on the rights to use, copy, modify, merge,
34 * publish, distribute, sublicense, and/or sell copies of the Software,
35 * and to permit persons to whom the Software is furnished to do so,
36 * subject to the following conditions:
38 * The above copyright notice and this permission notice (including the
39 * next paragraph) shall be included in all copies or substantial
40 * portions of the Software.
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
43 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
45 * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
46 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
47 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54 * Rickard E. (Rik) Faith <faith@redhat.com>
56 * This file was originally taken from xc/lib/Xaw/Template.c
59 #include <X11/IntrinsicP.h>
60 #include <X11/StringDefs.h>
63 static void CanvasInitialize(Widget request
, Widget w
,
64 ArgList args
, Cardinal
*num_args
)
68 static void CanvasExpose(Widget w
, XEvent
*event
, Region region
)
70 CanvasExposeDataRec data
;
76 if (!XtIsRealized(w
)) return;
77 XtCallCallbacks(w
, XtNcanvasExposeCallback
, (XtPointer
)&data
);
80 static void CanvasResize(Widget w
)
82 if (!XtIsRealized(w
)) return;
83 XtCallCallbacks(w
, XtNcanvasResizeCallback
, (XtPointer
)w
);
86 static void CanvasAction(Widget w
, XEvent
*event
,
87 String
*params
, Cardinal
*num_params
)
89 XtCallCallbacks(w
, XtNcallback
, (XtPointer
)event
);
92 #define offset(field) XtOffsetOf(CanvasRec, canvas.field)
93 static XtResource resources
[] = {
94 { XtNcallback
, XtCCallback
, XtRCallback
,
95 sizeof(XtCallbackList
), offset(input_callback
), XtRCallback
, NULL
},
96 { XtNcanvasExposeCallback
, XtCcanvasExposeCallback
, XtRCallback
,
97 sizeof(XtCallbackList
), offset(expose_callback
), XtRCallback
, NULL
},
98 { XtNcanvasResizeCallback
, XtCcanvasResizeCallback
, XtRCallback
,
99 sizeof(XtCallbackList
), offset(resize_callback
), XtRCallback
, NULL
},
103 static XtActionsRec actions
[] =
105 {"canvas", CanvasAction
},
108 static char translations
[] =
110 <Motion>: canvas()\n\
111 <BtnDown>: canvas()\n\
116 #define Superclass (&widgetClassRec)
117 CanvasClassRec canvasClassRec
= {
120 (WidgetClass
)Superclass
, /* superclass */
121 "Canvas", /* class_name */
122 sizeof(CanvasRec
), /* widget_size */
123 NULL
, /* class_initialize */
124 NULL
, /* class_part_initialize */
125 False
, /* class_inited */
126 CanvasInitialize
, /* initialize */
127 NULL
, /* initialize_hook */
128 XtInheritRealize
, /* realize */
129 actions
, /* actions */
130 XtNumber(actions
), /* num_actions */
131 resources
, /* resources */
132 XtNumber(resources
), /* num_resources */
133 NULLQUARK
, /* xrm_class */
134 True
, /* compress_motion */
135 True
, /* compress_exposure */
136 True
, /* compress_enterleave */
137 False
, /* visible_interest */
139 CanvasResize
, /* resize */
140 CanvasExpose
, /* expose */
141 NULL
, /* set_values */
142 NULL
, /* set_values_hook */
143 XtInheritSetValuesAlmost
, /* set_values_almost */
144 NULL
, /* get_values_hook */
145 NULL
, /* accept_focus */
146 XtVersion
, /* version */
147 NULL
, /* callback_private */
148 translations
, /* tm_table */
149 XtInheritQueryGeometry
, /* query_geometry */
150 XtInheritDisplayAccelerator
, /* display_accelerator */
151 NULL
, /* extension */
155 NULL
, /* extension */
159 WidgetClass canvasWidgetClass
= (WidgetClass
)&canvasClassRec
;