2
* Motif Tools Library, Version 3.1
5
* Written by David Flanagan.
6
* Copyright (c) 1992-2001 by David Flanagan.
7
* All Rights Reserved. See the file COPYRIGHT for details.
8
* This is open source software. See the file LICENSE for details.
9
* There is no warranty for this software. See NO_WARRANTY for details.
12
* Revision 1.1.1.1 2001/07/18 11:06:02 root
15
* Revision 1.2 2001/06/12 16:25:28 andre
16
* *** empty log message ***
22
#include <Xmt/LayoutGP.h>
23
#include <Xmt/Converters.h> /* for definition of XmtRBitmask */
25
#define offset(field) XtOffsetOf(XmtLayoutPixmapRec, layout_pixmap.field)
26
static XtResource resources[] = {
27
{XmtNpixmap, XmtCPixmap, XtRPixmap,
28
sizeof(Pixmap), offset(pixmap),
29
XtRImmediate, (XtPointer) None},
30
{XmtNbitmap, XmtCBitmap, XtRBitmap,
31
sizeof(Pixmap), offset(bitmap),
32
XtRImmediate, (XtPointer) None},
33
{XmtNbitmask, XmtCBitmask, XmtRBitmask,
34
sizeof(Pixmap), offset(bitmask),
35
XtRImmediate, (XtPointer) None},
36
{XmtNforeground, XtCForeground, XtRPixel,
37
sizeof(Pixel), offset(foreground),
38
XtRImmediate, (XtPointer) -1},
39
{XmtNbackground, XtCBackground, XtRPixel,
40
sizeof(Pixel), offset(background),
41
XtRImmediate, (XtPointer) -1}
45
#if NeedFunctionPrototypes
46
static void Initialize(Widget, Widget, ArgList, Cardinal *);
47
static void Destroy(Widget);
48
static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
49
static void Redisplay(Widget, XEvent *, Region);
50
static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
53
static void Initialize();
54
static void Destroy();
55
static Boolean SetValues();
56
static void Redisplay();
57
static XtGeometryResult QueryGeometry();
60
#define superclass (&xmtLayoutGadgetClassRec)
62
externaldef(xmtlayoutpixmapclassrec)
63
XmtLayoutPixmapClassRec xmtLayoutPixmapClassRec = {
64
{ /* rect_class fields */
65
/* superclass */ (WidgetClass)superclass,
66
/* class_name */ "XmtLayoutPixmap",
67
/* widget_size */ sizeof(XmtLayoutPixmapRec),
68
/* class_initialize */ NULL,
69
/* class_part_initialize*/ NULL,
70
/* class_inited */ FALSE,
71
/* initialize */ Initialize,
72
/* initialize_hook */ NULL,
76
/* resources */ resources,
77
/* num_resources */ XtNumber(resources),
78
/* xrm_class */ NULLQUARK,
83
/* destroy */ Destroy,
85
/* expose */ Redisplay,
86
/* set_values */ SetValues,
87
/* set_values_hook */ NULL,
88
/* set_values_almost */ XtInheritSetValuesAlmost,
89
/* get_values_hook */ NULL,
91
/* version */ XtVersion,
92
/* callback_offsets */ NULL,
94
/* query_geometry */ QueryGeometry,
98
{ /* XmtLayoutGadget field */
99
/* change_font */ NULL
101
{ /* XmtLayoutPixmap fields */
106
externaldef(xmtlayoutpixmapgadgetclass)
107
WidgetClass xmtLayoutPixmapGadgetClass = (WidgetClass)&xmtLayoutPixmapClassRec;
109
#if NeedFunctionPrototypes
110
static void GetGC(XmtLayoutWidget lw, XmtLayoutPixmapGadget lp)
112
static void GetGC(lw, lp)
114
XmtLayoutPixmapGadget lp;
118
long flags = GCForeground | GCBackground | GCGraphicsExposures;
120
if ((lp->layout_pixmap.foreground == -1) &&
121
(lp->layout_pixmap.background == -1) &&
122
(lp->layout_pixmap.bitmask == None)) {
123
lp->layout_pixmap.gc = NULL;
127
if (lp->layout_pixmap.foreground != -1)
128
gcv.foreground = lp->layout_pixmap.foreground;
130
gcv.foreground = lw->manager.foreground;
132
if (lp->layout_pixmap.background != -1)
133
gcv.background = lp->layout_pixmap.background;
135
gcv.background = lw->core.background_pixel;
137
gcv.graphics_exposures = False;
139
if (lp->layout_pixmap.bitmask != None) {
140
gcv.clip_mask = lp->layout_pixmap.bitmask;
144
lp->layout_pixmap.gc = XtGetGC((Widget)lp, flags, &gcv);
147
#if NeedFunctionPrototypes
148
static void MeasurePixmap(XmtLayoutWidget lw, XmtLayoutPixmapGadget lp)
150
static void MeasurePixmap(lw, lp)
152
XmtLayoutPixmapGadget lp;
155
unsigned width, height, depth, border;
159
if (lp->layout_pixmap.pixmap || lp->layout_pixmap.bitmap) {
160
(void)XGetGeometry(lw->core.screen->display,
161
(lp->layout_pixmap.pixmap
162
?lp->layout_pixmap.pixmap
163
:lp->layout_pixmap.bitmap),
164
&dummywin, &x, &y, &width, &height, &border,&depth);
165
lp->layout_pixmap.width = width;
166
lp->layout_pixmap.height = height;
167
lp->layout_pixmap.depth = depth;
170
lp->layout_pixmap.width = lp->layout_pixmap.height = 0;
175
#if NeedFunctionPrototypes
176
static void Initialize(Widget request, Widget init,
177
ArgList arglist, Cardinal *num_args)
179
static void Initialize(request, init, arglist, num_args)
186
XmtLayoutPixmapGadget lp = (XmtLayoutPixmapGadget) init;
187
XmtLayoutWidget lw = (XmtLayoutWidget) XtParent(init);
189
Constraint(lp, type) = XmtLayoutPixmap;
191
MeasurePixmap(lw, lp);
195
#if NeedFunctionPrototypes
196
static void Destroy(Widget w)
198
static void Destroy(w)
202
XmtLayoutPixmapGadget lp = (XmtLayoutPixmapGadget) w;
204
if (lp->layout_pixmap.gc)
205
XtReleaseGC(w, lp->layout_pixmap.gc);
209
#if NeedFunctionPrototypes
210
static Boolean SetValues(Widget current, Widget request, Widget set,
211
ArgList arglist, Cardinal *num_args)
213
static Boolean SetValues(current, request, set, arglist, num_args)
221
XmtLayoutPixmapGadget cp = (XmtLayoutPixmapGadget) current;
222
XmtLayoutPixmapGadget sp = (XmtLayoutPixmapGadget) set;
223
XmtLayoutWidget lw = (XmtLayoutWidget) XtParent(set);
224
Boolean redisplay = False;
225
Boolean relayout = False;
227
if ((sp->layout_pixmap.pixmap != cp->layout_pixmap.pixmap) ||
228
(sp->layout_pixmap.bitmap != cp->layout_pixmap.bitmap)) {
229
MeasurePixmap(lw, sp);
230
sp->rectangle.width = sp->layout_pixmap.width;
231
sp->rectangle.height = sp->layout_pixmap.height;
232
if (!sp->rectangle.width) sp->rectangle.width++;
233
if (!sp->rectangle.height) sp->rectangle.height++;
237
if ((sp->layout_pixmap.foreground != cp->layout_pixmap.foreground) ||
238
(sp->layout_pixmap.background != cp->layout_pixmap.background)||
239
(sp->layout_pixmap.bitmask != cp->layout_pixmap.bitmask)) {
240
if (sp->layout_pixmap.gc) XtReleaseGC(set, sp->layout_pixmap.gc);
245
if ((redisplay | relayout) && XtIsRealized((Widget)lw))
246
XClearArea(XtDisplay((Widget)lw), XtWindow((Widget)lw),
247
cp->rectangle.x, cp->rectangle.y,
248
cp->rectangle.width, cp->rectangle.height,
255
#if NeedFunctionPrototypes
256
static XtGeometryResult QueryGeometry(Widget w,
257
XtWidgetGeometry *request,
258
XtWidgetGeometry *reply)
260
static XtGeometryResult QueryGeometry(w, request, reply)
262
XtWidgetGeometry *request;
263
XtWidgetGeometry *reply;
266
XmtLayoutPixmapGadget lp = (XmtLayoutPixmapGadget) w;
268
reply->request_mode = CWWidth | CWHeight;
269
reply->width = lp->layout_pixmap.width;
270
reply->height = lp->layout_pixmap.height;
271
return XtGeometryYes;
275
#if NeedFunctionPrototypes
276
static void Redisplay(Widget w, XEvent *event, Region region)
278
static void Redisplay(w, event, region)
284
XmtLayoutPixmapGadget lp = (XmtLayoutPixmapGadget) w;
285
XmtLayoutWidget lw = (XmtLayoutWidget) XtParent(w);
287
if (lw->core.window == None) return;
288
if ((lp->layout_pixmap.pixmap == None) && (lp->layout_pixmap.bitmap==None))
291
if (lp->layout_pixmap.bitmask)
292
XSetClipOrigin(XtDisplay((Widget)lw), lp->layout_pixmap.gc,
293
lp->rectangle.x, lp->rectangle.y);
296
* pixmap should be multi-plane, and bitmap should be single-plane,
297
* but we don't assume that. We depend on the queried depth.
299
if ((lp->layout_pixmap.pixmap == None) ||
300
(lp->layout_pixmap.depth != lw->core.depth))
301
XCopyPlane(XtDisplay((Widget)lw),
302
(lp->layout_pixmap.pixmap
303
?lp->layout_pixmap.pixmap
304
:lp->layout_pixmap.bitmap),
305
XtWindow((Widget)lw),
306
(lp->layout_pixmap.gc?lp->layout_pixmap.gc:lw->layout.gc),
307
0, 0, lp->layout_pixmap.width, lp->layout_pixmap.height,
308
lp->rectangle.x, lp->rectangle.y, (unsigned long) 1);
310
XCopyArea(XtDisplay((Widget)lw),
311
(lp->layout_pixmap.pixmap
312
?lp->layout_pixmap.pixmap
313
:lp->layout_pixmap.bitmap),
314
XtWindow((Widget)lw),
315
(lp->layout_pixmap.gc?lp->layout_pixmap.gc:lw->layout.gc),
316
0, 0, lp->layout_pixmap.width, lp->layout_pixmap.height,
317
lp->rectangle.x, lp->rectangle.y);
319
if (lp->layout_pixmap.bitmask)
320
XSetClipOrigin(XtDisplay((Widget)lw), lp->layout_pixmap.gc, 0, 0);
323
#if NeedFunctionPrototypes
324
Widget XmtCreateLayoutPixmap(Widget parent, String name,
325
ArgList arglist, Cardinal num_args)
327
Widget XmtCreateLayoutPixmap(parent, name, arglist, num_args)
334
return XtCreateWidget(name, xmtLayoutPixmapGadgetClass, parent,