2
* Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
4
* Permission to use, copy, modify and distribute this material for
5
* any purpose and without fee is hereby granted, provided that the
6
* above copyright notice and this permission notice appear in all
7
* copies, and that the name of Bellcore not be used in advertising
8
* or publicity pertaining to this material without the specific,
9
* prior written permission of an authorized representative of
12
* BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
13
* PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
14
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
* FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
16
* FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE
17
* SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
18
* ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
19
* LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
20
* ING TO THE SOFTWARE.
22
* ClipWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com
28
* Clip.c - private child of Matrix - used to clip Matrix's textField child
35
#include <X11/StringDefs.h>
40
static char defaultTranslations[] =
41
"<FocusIn>: FocusIn()";
43
static XtResource resources[] = {
44
{ XmNexposeProc, XmCFunction, XtRFunction, sizeof(XtExposeProc),
45
XtOffsetOf(XbaeClipRec, clip.expose_proc),
46
XtRFunction, (XtPointer) NULL },
47
{ XmNfocusCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
48
XtOffsetOf(XbaeClipRec, clip.focus_callback),
49
XtRImmediate, (XtPointer) NULL },
53
* Declaration of methods
55
static void ClassPartInitialize P((XbaeClipWidgetClass));
56
static void Realize P((XbaeClipWidget, XtValueMask *,
57
XSetWindowAttributes *));
58
static void Redisplay P((XbaeClipWidget, XEvent *, Region));
59
static void Resize P((Widget));
60
static void Redraw P((XbaeClipWidget));
63
* Public convenience function
65
void XbaeClipRedraw P((Widget w));
70
static void FocusInACT P((XbaeClipWidget, XEvent *, String *, Cardinal *));
72
static XtActionsRec actions[] =
74
{"FocusIn", (XtActionProc)FocusInACT},
77
XbaeClipClassRec xbaeClipClassRec = {
79
/* core_class fields */
80
/* superclass */ (WidgetClass) &xmPrimitiveClassRec,
81
/* class_name */ "XbaeClip",
82
/* widget_size */ sizeof(XbaeClipRec),
83
/* class_initialize */ NULL,
84
/* class_part_initialize*/ (XtWidgetClassProc)ClassPartInitialize,
85
/* class_inited */ False,
86
/* initialize */ NULL,
87
/* initialize_hook */ NULL,
88
/* realize */ (XtRealizeProc)Realize,
89
/* actions */ actions,
90
/* num_actions */ XtNumber(actions),
91
/* resources */ resources,
92
/* num_resources */ XtNumber(resources),
93
/* xrm_class */ NULLQUARK,
94
/* compress_motion */ True,
95
/* compress_exposure */ XtExposeCompressSeries |
96
XtExposeGraphicsExpose |
98
/* compress_enterleave */ True,
99
/* visible_interest */ False,
102
/* expose */ (XtExposeProc)Redisplay,
103
/* set_values */ NULL,
104
/* set_values_hook */ NULL,
105
/* set_values_almost */ XtInheritSetValuesAlmost,
106
/* get_values_hook */ NULL,
107
/* accept_focus */ NULL,
108
/* version */ XtVersion,
109
/* callback_private */ NULL,
110
/* tm_table */ defaultTranslations,
111
/* query_geometry */ NULL,
112
/* display_accelerator */ NULL,
115
/* primitive_class fields */
117
/* border_highlight */ NULL,
118
/* border_unhighlight */ NULL,
119
/* translations */ NULL,
120
/* arm_and_activate */ NULL,
121
/* syn_resources */ NULL,
122
/* num_syn_resources */ 0,
125
/* clip_class fields */
127
/* redraw */ (XbaeClipRedrawProc)Redraw,
128
/* extension */ NULL,
132
WidgetClass xbaeClipWidgetClass = (WidgetClass) & xbaeClipClassRec;
136
ClassPartInitialize(cwc)
137
XbaeClipWidgetClass cwc;
139
register XbaeClipWidgetClass super =
140
(XbaeClipWidgetClass) cwc->core_class.superclass;
143
* Allow subclasses to inherit our redraw method
145
if (cwc->clip_class.redraw == XbaeInheritRedraw)
146
cwc->clip_class.redraw = super->clip_class.redraw;
150
Realize(cw, valueMask, attributes)
152
XtValueMask *valueMask;
153
XSetWindowAttributes *attributes;
156
* Don't call our superclasses realize method, because Primitive sets
157
* bit_gravity and do_not_propagate
159
XtCreateWindow((Widget)cw, InputOutput, CopyFromParent,
160
*valueMask, attributes);
165
Redisplay(cw, event, region)
170
if (cw->clip.expose_proc)
171
cw->clip.expose_proc((Widget)cw, event, region);
180
* Xt will call the expose method when this method returns.
181
* So we won't have to do any exposure stuff here, which
182
* means the Matrix's SetValues method only needs to force a
183
* redraw when a redisplay is needed, not when a relayout is performed.
195
if (XtIsRealized((Widget)cw))
196
XClearArea(XtDisplay(cw), XtWindow(cw), 0, 0, 0, 0, True);
200
* Public interface to redraw method
207
* Make sure w is a Clip or a subclass
209
XtCheckSubclass(w, xbaeClipWidgetClass, NULL);
212
* Call the redraw method
215
(*((XbaeClipWidgetClass) XtClass(w))->clip_class.redraw)
221
FocusInACT(cw, event, params, nparams)
227
if (event->xany.type != FocusIn || !event->xfocus.send_event)
230
if (cw->clip.focus_callback)
231
XtCallCallbackList((Widget)cw, cw->clip.focus_callback, NULL);