File: Clip.c

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (232 lines) | stat: -rw-r--r-- 7,011 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
 * Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
 *                        All rights reserved
 * Permission to use, copy, modify and distribute this material for
 * any purpose and without fee is hereby granted, provided that the
 * above copyright notice and this permission notice appear in all
 * copies, and that the name of Bellcore not be used in advertising
 * or publicity pertaining to this material without the specific,
 * prior written permission of an authorized representative of
 * Bellcore.
 *
 * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
 * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
 * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
 * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
 * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
 * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
 * ING TO THE SOFTWARE.
 *
 * ClipWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com
 *
 * $Id: Clip.c,v 1.1 2001-07-18 11:05:59 root Exp $
 */

/*
 * Clip.c - private child of Matrix - used to clip Matrix's textField child
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <X11/StringDefs.h>
#include <Xm/XmP.h>
#include "Macros.h"
#include "ClipP.h"

static char defaultTranslations[] =
    "<FocusIn>:                        FocusIn()";

static XtResource resources[] = {
    { XmNexposeProc, XmCFunction, XtRFunction, sizeof(XtExposeProc),
      XtOffsetOf(XbaeClipRec, clip.expose_proc),
      XtRFunction, (XtPointer) NULL },
    { XmNfocusCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
      XtOffsetOf(XbaeClipRec, clip.focus_callback),
      XtRImmediate, (XtPointer) NULL },
};

/*
 * Declaration of methods
 */
static void ClassPartInitialize P((XbaeClipWidgetClass));
static void Realize P((XbaeClipWidget, XtValueMask *,
                        XSetWindowAttributes *));
static void Redisplay P((XbaeClipWidget, XEvent *, Region));
static void Resize P((Widget));
static void Redraw P((XbaeClipWidget));

/*
 * Public convenience function
 */
void XbaeClipRedraw P((Widget w));

/*
 * Clip actions
 */
static void FocusInACT P((XbaeClipWidget, XEvent *, String *, Cardinal *));

static XtActionsRec actions[] =
{
    {"FocusIn", (XtActionProc)FocusInACT},
};

XbaeClipClassRec xbaeClipClassRec = {
    {
    /* core_class fields */
        /* superclass                */ (WidgetClass) &xmPrimitiveClassRec,
        /* class_name                */ "XbaeClip",
        /* widget_size                */ sizeof(XbaeClipRec),
        /* class_initialize        */ NULL,
        /* class_part_initialize*/ (XtWidgetClassProc)ClassPartInitialize,
        /* class_inited                */ False,
        /* initialize                */ NULL,
        /* initialize_hook        */ NULL,
        /* realize                */ (XtRealizeProc)Realize,
        /* actions                */ actions,
        /* num_actions                */ XtNumber(actions),
        /* resources                */ resources,
        /* num_resources        */ XtNumber(resources),
        /* xrm_class                */ NULLQUARK,
        /* compress_motion        */ True,
        /* compress_exposure        */ XtExposeCompressSeries |
                                       XtExposeGraphicsExpose |
                                       XtExposeNoExpose,
        /* compress_enterleave        */ True,
        /* visible_interest        */ False,
        /* destroy                */ NULL,
        /* resize                */ Resize,
        /* expose                */ (XtExposeProc)Redisplay,
        /* set_values                */ NULL,
        /* set_values_hook        */ NULL,
        /* set_values_almost        */ XtInheritSetValuesAlmost,
        /* get_values_hook        */ NULL,
        /* accept_focus                */ NULL,
        /* version                */ XtVersion,
        /* callback_private        */ NULL,
        /* tm_table                */ defaultTranslations,
        /* query_geometry        */ NULL,
        /* display_accelerator        */ NULL,
        /* extension                */ NULL
    },
    /* primitive_class fields */
    {
        /* border_highlight        */ NULL,
        /* border_unhighlight        */ NULL,
        /* translations                */ NULL,
        /* arm_and_activate        */ NULL,
        /* syn_resources        */ NULL,
        /* num_syn_resources        */ 0,
        /* extension                */ NULL
    },
    /* clip_class fields */
    {
        /* redraw                */ (XbaeClipRedrawProc)Redraw,
        /* extension                */ NULL,
    }
};

WidgetClass xbaeClipWidgetClass = (WidgetClass) & xbaeClipClassRec;


static void
ClassPartInitialize(cwc)
XbaeClipWidgetClass cwc;
{
    register XbaeClipWidgetClass super =
        (XbaeClipWidgetClass) cwc->core_class.superclass;

    /*
     * Allow subclasses to inherit our redraw method
     */
    if (cwc->clip_class.redraw == XbaeInheritRedraw)
        cwc->clip_class.redraw = super->clip_class.redraw;
}

static void
Realize(cw, valueMask, attributes)
XbaeClipWidget cw;
XtValueMask *valueMask;
XSetWindowAttributes *attributes;
{
    /*
     * Don't call our superclasses realize method, because Primitive sets
     * bit_gravity and do_not_propagate
     */
    XtCreateWindow((Widget)cw, InputOutput, CopyFromParent,
                   *valueMask, attributes);
}

/* ARGSUSED */
static void
Redisplay(cw, event, region)
XbaeClipWidget cw;
XEvent *event;
Region region;
{
    if (cw->clip.expose_proc)
        cw->clip.expose_proc((Widget)cw, event, region);
}

/* ARGSUSED */
static void
Resize(w)
Widget w;
{
    /*
     * Xt will call the expose method when this method returns.
     * So we won't have to do any exposure stuff here, which 
     * means the Matrix's  SetValues method only needs to force a
     * redraw when a redisplay is needed, not when a relayout is performed.
     */
}

/*
 * Clip redraw method
 */
/* ARGSUSED */
static void
Redraw(cw)
XbaeClipWidget cw;
{
    if (XtIsRealized((Widget)cw))
        XClearArea(XtDisplay(cw), XtWindow(cw), 0, 0, 0, 0, True);
}

/*
 * Public interface to redraw method
 */
void
XbaeClipRedraw(w)
Widget w;
{
    /*
     * Make sure w is a Clip or a subclass
     */
    XtCheckSubclass(w, xbaeClipWidgetClass, NULL);

    /*
     * Call the redraw method
     */
    if (XtIsRealized(w))
        (*((XbaeClipWidgetClass) XtClass(w))->clip_class.redraw)
            ((Widget)w);
}

/* ARGSUSED */
static void
FocusInACT(cw, event, params, nparams)
XbaeClipWidget cw;
XEvent *event;
String *params;
Cardinal *nparams;
{
    if (event->xany.type != FocusIn || !event->xfocus.send_event)
        return;

    if (cw->clip.focus_callback)
        XtCallCallbackList((Widget)cw, cw->clip.focus_callback, NULL);
}