-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXpmButton.c
More file actions
641 lines (584 loc) · 19.1 KB
/
XpmButton.c
File metadata and controls
641 lines (584 loc) · 19.1 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
/*
* (C) 1997 by Marcin Dalecki <dalecki@math.uni-goettingen.de>
*
* This file is part of the Motif Info browser.
*
* The MInfo program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/*
* Convenience routines to add pixmaps to buttons.
* The following color names will be treat specially in the pixmaps we are
* using:
*
* "none", "shade0", "shade1", "shade2" are simbolic names for colors which
* will be substitued with corresponding motif runtime color values.
*/
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/LabelG.h>
#include <Xm/PushBG.h>
#include <X11/xpm.h>
#include "XpmButton.h"
#include "resource.h"
#define NOPIXMAP 0
/* To prevent overload of the X11-server with pixmap duplications we are
* establishing an corresponding cache here. It isn't that fast but
* compleatly sufficient for most of the applications.
*/
typedef struct _CacheEntry CacheEntry;
struct _CacheEntry {
CacheEntry *Next;
Display *Dsp; /* the display where the pixmap will
appear */
int Depth; /* depth of the pixmap */
Pixel Background; /* background color */
char **XpmData; /* data in xpm format */
int Type; /* type of cached value */
Pixmap Pixels; /* X11 server ident of the pixmap */
int RefCount; /* number of refferences */
};
/* Definitions for contents of the Type field in CacheEntry
* TYPE_ORIGINAL: This entry was generated from the given Pixmap or through
* the resource mechanism. In the second case the bit
* TYPE_FROMRESOURCE is set too.
* TYPE_ARMED: The pixmap came from an loaded image.
* TYPE_INSENSITIVE: dito....
*/
#define TYPE_ORIGINAL 0
#define TYPE_ARMED 1
#define TYPE_INSENSITIVE 2
#define TYPE_FROMRESOURCE 0x80
static CacheEntry *PixmapCache = NULL; /* main cache anchor */
/*
* Lookup the corresponding pixmap in the cache. If it's allready there, the
* existing pixmap code from the server will be returned. Otherwise we will
* create it and return the corresponding new id back.
*
* Dsp display for the pixmap
* Scr corresponing screen
* Depth necessary depth of the pixmap
* XpmData pixmap data in the portable xpm format
* XpmAttr attributes for creation
* ResourceXpmData data from resource
* Type makes it possible to pass allready existent
* Pixmap data. But int this case there must be an
* valid XpmData too, to prevent duplication.
* Default Fallback pixmap value
* JustLookup Don't add to cache it set.
*/
static Pixmap AddXpmToCache(Display * Dsp, Screen * Scr,
int Depth, Pixel Background,
char **XpmData, XpmAttributes * XpmAttr,
char *ResourceXpmData,
int Type, Pixmap Default,
Boolean JustLookup)
{
CacheEntry *pCache = PixmapCache;
if (ResourceXpmData)
Type = Type | TYPE_FROMRESOURCE;
/*
* Lookup cache
*/
while ((pCache != NULL) &&
((pCache->Dsp != Dsp) ||
(pCache->Depth != Depth) ||
(pCache->Background != Background) ||
(pCache->XpmData != XpmData) ||
(pCache->Type != Type)
))
pCache = pCache->Next;
/*
* Create and add to cache if neccessary
*/
if (pCache == NULL) {
int Error;
Pixmap Pixels;
if (JustLookup)
return NOPIXMAP;
/*
* If no default specified, create the pixmap or just return the
* default otherwise.
*/
if (Default == NOPIXMAP) {
if (ResourceXpmData)
Error = XpmCreatePixmapFromBuffer(Dsp, RootWindowOfScreen(Scr),
ResourceXpmData, &Pixels, NULL, XpmAttr);
else
Error = XpmCreatePixmapFromData(Dsp, RootWindowOfScreen(Scr),
XpmData, &Pixels, NULL, XpmAttr);
if (Error != XpmSuccess)
return NOPIXMAP;
XpmFreeAttributes(XpmAttr);
} else
Pixels = Default;
pCache = (CacheEntry *) XtMalloc(sizeof(CacheEntry));
if (pCache == NULL) {
XFreePixmap(Dsp, Pixels);
return NOPIXMAP;
}
pCache->Dsp = Dsp;
pCache->Depth = Depth;
pCache->Background = Background;
pCache->XpmData = XpmData;
pCache->Type = Type;
pCache->Pixels = Pixels;
pCache->RefCount = 1;
pCache->Next = PixmapCache;
PixmapCache = pCache;
return Pixels;
} else {
/* return the allready cached value */
++(pCache->RefCount);
return pCache->Pixels;
}
}
static void FreeXpmFromCache(Display * Dsp, Pixmap Pixels)
{
CacheEntry *pCache = PixmapCache;
CacheEntry *pPrev = NULL;
while ((pCache != NULL) &&
((pCache->Dsp != Dsp) ||
(pCache->Pixels != Pixels)
)) {
pPrev = pCache;
pCache = pCache->Next;
}
if (pCache == NULL)
XtWarningMsg("PixmapCache", "pixmapcache", "UnknownPixmap",
"Pixmap to be freed not found in pixmap cache",
NULL, 0);
else {
if (--(pCache->RefCount) == 0) {
/* remove the pixmap from the X11 server */
XFreePixmap(Dsp, pCache->Pixels);
if (pPrev == NULL)
/* it's the first cache entry */
PixmapCache = pCache->Next;
else
pPrev->Next = pCache->Next;
XtFree((char *) pCache);
}
}
}
/*
* This will trigger the garbage collecting for our cache.
*/
static void DestroyCallback(Widget w, XtPointer ClientData,
XtPointer CallData)
{
Display *Dsp;
Pixmap NormalPixmap, ArmedPixmap, InsensitivePixmap;
Boolean IsButton;
/* shouldn't happen */
if (ClientData == NULL)
return;
IsButton = XmIsPushButton(w) || XmIsPushButtonGadget(w);
NormalPixmap = ((Pixmap *) ClientData)[0];
InsensitivePixmap = ((Pixmap *) ClientData)[1];
Dsp = XtDisplay(w);
FreeXpmFromCache(Dsp, NormalPixmap);
FreeXpmFromCache(Dsp, InsensitivePixmap);
if (IsButton) {
ArmedPixmap = ((Pixmap *) ClientData)[2];
FreeXpmFromCache(Dsp, ArmedPixmap);
}
XtFree((char *) ClientData);
}
static void CreateButtonPixmaps(Widget PushButton,
char **Normal, char **Armed,
char **Insensitive)
{
Display *Dsp;
Screen *Scr;
int Depth;
Pixel bg; /* normal background */
Pixel abg; /* armed background */
Pixel bsc; /* bottom shadow color */
Pixel tsc; /* top shadow color */
int PixmapX, PixmapY;
unsigned int PixmapHeight, PixmapWidth, PixmapBorder, PixmapDepth;
Window RootWindow;
Pixmap NormalPixmap, ArmedPixmap, InsensitivePixmap = 0;
XpmAttributes XpmAttr;
Boolean RecomputeSize;
char *ResourceData;
Boolean HasResourceData;
Pixmap *PixmapReminder;
/*
* Predefined color names which will adjust to the usage context
*/
XpmColorSymbol color[4] =
{
{"mask", NULL, 0},
{"shade0", NULL, 0},
{"shade1", NULL, 0},
{"shade2", NULL, 0}
};
/*
* We need to be carefull here, since in case of gadgets, there is
* no way to get the background color directly from the widget itself.
* In such cases we get it from The Core part of his parent instead.
*/
Dsp = XtDisplayOfObject(PushButton);
Scr = XtScreenOfObject(PushButton);
XtVaGetValues(XtIsSubclass(PushButton, coreWidgetClass) ?
PushButton : XtParent(PushButton),
XmNdepth, &Depth,
XmNbackground, &bg,
XmNarmColor, &abg,
XmNbottomShadowColor, &bsc,
XmNtopShadowColor, &tsc,
NULL);
color[1].pixel = tsc;
color[2].pixel = bg;
color[3].pixel = bsc;
/* First we create the pixmap for the normal , active atate of the button.
*/
ResourceData = XmLoadStringResource(PushButton, "normalFace",
NULL, NULL);
HasResourceData = ResourceData != NULL;
color[0].pixel = bg;
XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
XpmAttr.colorsymbols = color;
XpmAttr.numsymbols = 4;
XpmAttr.closeness = 65535;
XpmAttr.depth = Depth;
NormalPixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Normal, &XpmAttr, ResourceData,
TYPE_ORIGINAL, NOPIXMAP, False);
if (NormalPixmap == NOPIXMAP)
return;
/* now for the pressed state... */
ResourceData = XmLoadStringResource(PushButton, "armedFace",
NULL, NULL);
if ((Armed && !HasResourceData) ||
(ResourceData && HasResourceData)) {
color[0].pixel = abg;
XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
XpmAttr.colorsymbols = color;
XpmAttr.numsymbols = 4;
XpmAttr.closeness = 65535;
XpmAttr.depth = Depth;
ArmedPixmap = AddXpmToCache(Dsp, Scr, Depth, abg,
Armed, &XpmAttr, ResourceData,
TYPE_ORIGINAL, NOPIXMAP, False);
if (ArmedPixmap == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
return;
}
} else {
/* If there wasn't any pixmap specified for the state, we will
* create our own one here. For this we move the image on the normal
* pixmap by the shadw size top down.
*/
GC gc;
XGCValues GCValues;
Dimension ShadowThickness;
ArmedPixmap = AddXpmToCache(Dsp, Scr, Depth, abg,
Normal, &XpmAttr, NULL,
TYPE_ARMED, NOPIXMAP, True);
if (ArmedPixmap == NOPIXMAP) {
XtVaGetValues(PushButton,
XmNshadowThickness, &ShadowThickness, NULL);
GCValues.foreground = abg;
gc = XtGetGC(PushButton, GCForeground, &GCValues);
XGetGeometry(Dsp, NormalPixmap, &RootWindow,
&PixmapX, &PixmapY, &PixmapWidth, &PixmapHeight,
&PixmapBorder, &PixmapDepth);
ArmedPixmap = XCreatePixmap(Dsp, RootWindowOfScreen(Scr),
PixmapWidth, PixmapHeight,
PixmapDepth);
XCopyArea(Dsp, NormalPixmap, ArmedPixmap, gc,
0, 0,
PixmapWidth - ShadowThickness,
PixmapHeight - ShadowThickness,
ShadowThickness, ShadowThickness);
XFillRectangle(Dsp, ArmedPixmap, gc, 0, 0,
PixmapWidth, ShadowThickness);
XFillRectangle(Dsp, ArmedPixmap, gc, 0, 0,
ShadowThickness, PixmapHeight);
XtReleaseGC(PushButton, gc);
if (AddXpmToCache(Dsp, Scr, Depth, bg, Normal,
&XpmAttr, NULL, TYPE_ARMED, ArmedPixmap,
False) == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
XFreePixmap(Dsp, ArmedPixmap);
return;
}
}
}
/* And now for the insensitive state.
*/
ResourceData = XmLoadStringResource(PushButton, "insensitiveFace",
NULL, NULL);
if ((Insensitive && !HasResourceData) ||
(ResourceData && HasResourceData)) {
color[0].pixel = bg;
XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
XpmAttr.colorsymbols = color;
XpmAttr.numsymbols = 4;
XpmAttr.closeness = 65535;
XpmAttr.depth = Depth;
InsensitivePixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Insensitive, &XpmAttr,
ResourceData,
TYPE_ORIGINAL, NOPIXMAP, False);
if (InsensitivePixmap == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
FreeXpmFromCache(Dsp, ArmedPixmap);
return;
}
} else {
/* Once again we will create our own one by stippling the original
* pixmap.
*/
GC gc;
XGCValues GCValues;
Pixmap Stipple;
static char StippleBitmap[8] =
{0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA};
InsensitivePixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Normal, &XpmAttr, NULL,
TYPE_INSENSITIVE,
InsensitivePixmap, True);
if (InsensitivePixmap == NOPIXMAP) {
Stipple = XCreateBitmapFromData(Dsp, RootWindowOfScreen(Scr),
StippleBitmap, 8, 8);
GCValues.foreground = bg;
GCValues.fill_style = FillStippled;
GCValues.stipple = Stipple;
gc = XtGetGC(PushButton,
GCForeground | GCFillStyle | GCStipple,
&GCValues);
XGetGeometry(Dsp, NormalPixmap, &RootWindow,
&PixmapX, &PixmapY, &PixmapWidth, &PixmapHeight,
&PixmapBorder, &PixmapDepth);
InsensitivePixmap = XCreatePixmap(Dsp, RootWindowOfScreen(Scr),
PixmapWidth, PixmapHeight,
PixmapDepth);
XCopyArea(Dsp, NormalPixmap, InsensitivePixmap, gc,
0, 0, PixmapWidth, PixmapHeight, 0, 0);
XFillRectangle(Dsp, InsensitivePixmap, gc,
0, 0, PixmapWidth, PixmapHeight);
XtReleaseGC(PushButton, gc);
XFreePixmap(Dsp, Stipple);
if (AddXpmToCache(Dsp, Scr, Depth, bg, Normal,
&XpmAttr, NULL, TYPE_INSENSITIVE,
InsensitivePixmap, False) == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
FreeXpmFromCache(Dsp, ArmedPixmap);
XFreePixmap(Dsp, InsensitivePixmap);
return;
}
}
}
/* If anything went well, we can pass all the data to our button.
*/
XtVaGetValues(PushButton,
XmNrecomputeSize, &RecomputeSize, NULL);
XtVaSetValues(PushButton, XmNrecomputeSize, True, NULL);
XtVaSetValues(PushButton,
XmNlabelType, XmPIXMAP,
XmNlabelPixmap, NormalPixmap,
XmNarmPixmap, ArmedPixmap,
XmNlabelInsensitivePixmap, InsensitivePixmap,
NULL);
XtVaSetValues(PushButton, XmNrecomputeSize, RecomputeSize, NULL);
/* Here we install the garbage collecting callback.
*/
PixmapReminder = (Pixmap *) XtMalloc(sizeof(Pixmap) * 3);
if (PixmapReminder != NULL) {
PixmapReminder[0] = NormalPixmap;
PixmapReminder[1] = InsensitivePixmap;
PixmapReminder[2] = ArmedPixmap;
}
XtAddCallback(PushButton, XmNdestroyCallback,
(XtCallbackProc) DestroyCallback,
(XtPointer) PixmapReminder);
}
Widget XmCreatePixmapPushButton(Widget Parent, String Name,
char **Normal, char **Armed,
char **Insensitive,
ArgList Args, Cardinal ArgCount)
{
Widget ButtonWidget;
ButtonWidget = XmCreatePushButton(Parent, Name, Args, ArgCount);
if (ButtonWidget == NULL)
return NULL;
CreateButtonPixmaps(ButtonWidget, Normal, Armed, Insensitive);
return ButtonWidget;
}
Widget XmCreatePixmapPushButtonGadget(Widget Parent, String Name,
char **Normal, char **Armed,
char **Insensitive,
ArgList Args, Cardinal ArgCount)
{
Widget ButtonWidget;
ButtonWidget = XmCreatePushButtonGadget(Parent, Name, Args, ArgCount);
if (ButtonWidget == NULL)
return NULL;
CreateButtonPixmaps(ButtonWidget, Normal, Armed, Insensitive);
return ButtonWidget;
}
static void CreatePixmapLabel(Widget LabelWidget,
char **Normal, char **Insensitive)
{
Display *Dsp;
Screen *Scr;
int Depth;
int PixmapX, PixmapY;
unsigned int PixmapHeight, PixmapWidth, PixmapBorder, PixmapDepth;
Window RootWindow;
Pixmap NormalPixmap, InsensitivePixmap = 0;
XpmAttributes XpmAttr;
Boolean RecomputeSize;
Pixel bg, bsc, tsc;
char *ResourceData;
Boolean HasResourceData;
Pixmap *PixmapReminder;
XpmColorSymbol color[4] =
{
{"mask", NULL, 0},
{"shade0", NULL, 0},
{"shade1", NULL, 0},
{"shade2", NULL, 0}
};
/*
* We need to be carefull here, since in case of gadgets, there is
* no way to get the background color directly from the widget itself.
* In such cases we get it from The Core part of his parent instead.
*/
Dsp = XtDisplayOfObject(LabelWidget);
Scr = XtScreenOfObject(LabelWidget);
XtVaGetValues(XtIsSubclass(LabelWidget, coreWidgetClass) ?
LabelWidget : XtParent(LabelWidget),
XmNdepth, &Depth,
XmNbackground, &bg,
XmNbottomShadowColor, &bsc,
XmNtopShadowColor, &tsc,
NULL);
color[1].pixel = tsc;
color[2].pixel = bg;
color[3].pixel = bsc;
ResourceData = XmLoadStringResource(LabelWidget, "normalFace",
NULL, NULL);
HasResourceData = ResourceData != NULL;
color[0].pixel = bg;
XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
XpmAttr.colorsymbols = color;
XpmAttr.numsymbols = 4;
XpmAttr.closeness = 65535;
XpmAttr.depth = Depth;
NormalPixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Normal, &XpmAttr, ResourceData,
TYPE_ORIGINAL, NOPIXMAP, False);
if (NormalPixmap == NOPIXMAP)
return;
ResourceData = XmLoadStringResource(LabelWidget, "insensitiveFace",
NULL, NULL);
if ((Insensitive && !HasResourceData) ||
(ResourceData && HasResourceData)) {
XpmAttr.valuemask = XpmColorSymbols | XpmCloseness | XpmDepth;
XpmAttr.closeness = 65535;
XpmAttr.depth = Depth;
InsensitivePixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Insensitive, &XpmAttr,
ResourceData,
TYPE_ORIGINAL, NOPIXMAP, False);
if (InsensitivePixmap == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
return;
}
} else {
GC gc;
XGCValues GCValues;
Pixmap Stipple;
static char StippleBitmap[8] =
{0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA};
InsensitivePixmap = AddXpmToCache(Dsp, Scr, Depth, bg,
Normal, &XpmAttr, NULL,
TYPE_INSENSITIVE,
InsensitivePixmap, True);
if (InsensitivePixmap == NOPIXMAP) {
Stipple = XCreateBitmapFromData(Dsp, RootWindowOfScreen(Scr),
StippleBitmap, 8, 8);
GCValues.foreground = bg;
GCValues.fill_style = FillStippled;
GCValues.stipple = Stipple;
gc = XtGetGC(LabelWidget,
GCForeground | GCFillStyle | GCStipple,
&GCValues);
XGetGeometry(Dsp, NormalPixmap, &RootWindow,
&PixmapX, &PixmapY, &PixmapWidth, &PixmapHeight,
&PixmapBorder, &PixmapDepth);
InsensitivePixmap = XCreatePixmap(Dsp, RootWindowOfScreen(Scr),
PixmapWidth, PixmapHeight,
PixmapDepth);
XCopyArea(Dsp, NormalPixmap, InsensitivePixmap, gc,
0, 0, PixmapWidth, PixmapHeight, 0, 0);
XFillRectangle(Dsp, InsensitivePixmap, gc,
0, 0, PixmapWidth, PixmapHeight);
XtReleaseGC(LabelWidget, gc);
XFreePixmap(Dsp, Stipple);
if (AddXpmToCache(Dsp, Scr, Depth, bg, Normal,
&XpmAttr, NULL, TYPE_INSENSITIVE,
InsensitivePixmap, False) == NOPIXMAP) {
FreeXpmFromCache(Dsp, NormalPixmap);
XFreePixmap(Dsp, InsensitivePixmap);
return;
}
}
}
XtVaGetValues(LabelWidget,
XmNrecomputeSize, &RecomputeSize, NULL);
XtVaSetValues(LabelWidget, XmNrecomputeSize, True, NULL);
XtVaSetValues(LabelWidget,
XmNlabelType, XmPIXMAP,
XmNlabelPixmap, NormalPixmap,
XmNlabelInsensitivePixmap, InsensitivePixmap,
NULL);
XtVaSetValues(LabelWidget, XmNrecomputeSize, RecomputeSize, NULL);
PixmapReminder = (Pixmap *) XtMalloc(sizeof(Pixmap) * 2);
if (PixmapReminder != NULL) {
PixmapReminder[0] = NormalPixmap;
PixmapReminder[1] = InsensitivePixmap;
}
XtAddCallback(LabelWidget, XmNdestroyCallback,
(XtCallbackProc) DestroyCallback,
(XtPointer) PixmapReminder);
}
Widget XmCreatePixmapLabel(Widget Parent, String Name,
char **Normal, char **Insensitive,
ArgList Args, Cardinal ArgCount)
{
Widget LabelWidget;
LabelWidget = XmCreateLabel(Parent, Name, Args, ArgCount);
if (LabelWidget == NULL)
return NULL;
CreatePixmapLabel(LabelWidget, Normal, Insensitive);
return LabelWidget;
}
Widget XmCreatePixmapLabelGadget(Widget Parent, String Name,
char **Normal, char **Insensitive,
ArgList Args, Cardinal ArgCount)
{
Widget LabelWidget;
LabelWidget = XmCreateLabelGadget(Parent, Name, Args, ArgCount);
if (LabelWidget == NULL)
return NULL;
CreatePixmapLabel(LabelWidget, Normal, Insensitive);
return LabelWidget;
}