Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / dmx / config / Canvas.c
CommitLineData
a09e091a
JB
1/*
2 * Copyright 1987, 1998 The Open Group
3 *
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
8 * documentation.
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
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.
19 *
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.
23 */
24
25/*
26 * Copyright 2002 Red Hat Inc., Durham, North Carolina.
27 *
28 * All Rights Reserved.
29 *
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:
37 *
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.
41 *
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
49 * SOFTWARE.
50 */
51
52/*
53 * Authors:
54 * Rickard E. (Rik) Faith <faith@redhat.com>
55 *
56 * This file was originally taken from xc/lib/Xaw/Template.c
57 */
58
59#include <X11/IntrinsicP.h>
60#include <X11/StringDefs.h>
61#include "CanvasP.h"
62
63static void
64CanvasInitialize(Widget request, Widget w, ArgList args, Cardinal * num_args)
65{
66}
67
68static void
69CanvasExpose(Widget w, XEvent * event, Region region)
70{
71 CanvasExposeDataRec data;
72
73 data.w = w;
74 data.event = event;
75 data.region = region;
76
77 if (!XtIsRealized(w))
78 return;
79 XtCallCallbacks(w, XtNcanvasExposeCallback, (XtPointer) &data);
80}
81
82static void
83CanvasResize(Widget w)
84{
85 if (!XtIsRealized(w))
86 return;
87 XtCallCallbacks(w, XtNcanvasResizeCallback, (XtPointer) w);
88}
89
90static void
91CanvasAction(Widget w, XEvent * event, String * params, Cardinal * num_params)
92{
93 XtCallCallbacks(w, XtNcallback, (XtPointer) event);
94}
95
96#define offset(field) XtOffsetOf(CanvasRec, canvas.field)
97static XtResource resources[] = {
98 {XtNcallback, XtCCallback, XtRCallback,
99 sizeof(XtCallbackList), offset(input_callback), XtRCallback, NULL}
100 ,
101 {XtNcanvasExposeCallback, XtCcanvasExposeCallback, XtRCallback,
102 sizeof(XtCallbackList), offset(expose_callback), XtRCallback, NULL}
103 ,
104 {XtNcanvasResizeCallback, XtCcanvasResizeCallback, XtRCallback,
105 sizeof(XtCallbackList), offset(resize_callback), XtRCallback, NULL}
106 ,
107};
108
109#undef offset
110
111static XtActionsRec actions[] = {
112 {"canvas", CanvasAction},
113};
114
115static char translations[] = "<Key>: canvas()\n\
116<Motion>: canvas()\n\
117<BtnDown>: canvas()\n\
118<BtnUp>: canvas()\n\
119";
120
121#define Superclass (&widgetClassRec)
122CanvasClassRec canvasClassRec = {
123 /* core */
124 {
125 (WidgetClass) Superclass, /* superclass */
126 "Canvas", /* class_name */
127 sizeof(CanvasRec), /* widget_size */
128 NULL, /* class_initialize */
129 NULL, /* class_part_initialize */
130 False, /* class_inited */
131 CanvasInitialize, /* initialize */
132 NULL, /* initialize_hook */
133 XtInheritRealize, /* realize */
134 actions, /* actions */
135 XtNumber(actions), /* num_actions */
136 resources, /* resources */
137 XtNumber(resources), /* num_resources */
138 NULLQUARK, /* xrm_class */
139 True, /* compress_motion */
140 True, /* compress_exposure */
141 True, /* compress_enterleave */
142 False, /* visible_interest */
143 NULL, /* destroy */
144 CanvasResize, /* resize */
145 CanvasExpose, /* expose */
146 NULL, /* set_values */
147 NULL, /* set_values_hook */
148 XtInheritSetValuesAlmost, /* set_values_almost */
149 NULL, /* get_values_hook */
150 NULL, /* accept_focus */
151 XtVersion, /* version */
152 NULL, /* callback_private */
153 translations, /* tm_table */
154 XtInheritQueryGeometry, /* query_geometry */
155 XtInheritDisplayAccelerator, /* display_accelerator */
156 NULL, /* extension */
157 }
158 ,
159 /* canvas */
160 {
161 NULL, /* extension */
162 }
163};
164
165WidgetClass canvasWidgetClass = (WidgetClass) &canvasClassRec;