1 /*
2 * $KK: SmeThreeD.c,v 0.3 92/11/04 xx:xx:xx keithley Exp $
3 */
4 /* MODIFIED FOR N*XTSTEP LOOK	 				*/
5 /* Modifications Copyright (c) 1996 by Alfredo Kojima		*/
6 /***********************************************************
7 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
8 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
9 Copyright 1992, 1993 by Kaleb Keithley
10 
11                         All Rights Reserved
12 
13 Permission to use, copy, modify, and distribute this software and its
14 documentation for any purpose and without fee is hereby granted,
15 provided that the above copyright notice appear in all copies and that
16 both that copyright notice and this permission notice appear in
17 supporting documentation, and that the names of Digital, MIT, or Kaleb
18 Keithley not be used in advertising or publicity pertaining to distribution
19 of the software without specific, written prior permission.
20 
21 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
22 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
23 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27 SOFTWARE.
28 
29 ******************************************************************/
30 
31 #include <X11/Xlib.h>
32 #include <X11/StringDefs.h>
33 #include <X11/IntrinsicP.h>
34 #include "XawInit.h"
35 #include "SmeThreeDP.h"
36 #include <X11/Xosdefs.h>
37 
38 /* Initialization of defaults */
39 
40 #define XtNtopShadowPixmap "topShadowPixmap"
41 #define XtCTopShadowPixmap "TopShadowPixmap"
42 #define XtNbottomShadowPixmap "bottomShadowPixmap"
43 #define XtCBottomShadowPixmap "BottomShadowPixmap"
44 #define XtNshadowed "shadowed"
45 #define XtCShadowed "Shadowed"
46 
47 #define offset(field) XtOffsetOf(SmeThreeDRec, field)
48 
49 static XtResource resources[] = {
50     {XtNshadowWidth, XtCShadowWidth, XtRDimension, sizeof(Dimension),
51 	offset(sme_threeD.shadow_width), XtRImmediate, (XtPointer) 2},
52     {XtNtopShadowPixel, XtCTopShadowPixel, XtRPixel, sizeof(Pixel),
53 	offset(sme_threeD.top_shadow_pixel), XtRString, XtDefaultForeground},
54     {XtNbottomShadowPixel, XtCBottomShadowPixel, XtRPixel, sizeof(Pixel),
55 	offset(sme_threeD.bot_shadow_pixel), XtRString, XtDefaultForeground},
56     {XtNtopShadowPixmap, XtCTopShadowPixmap, XtRPixmap, sizeof(Pixmap),
57 	offset(sme_threeD.top_shadow_pxmap), XtRImmediate, (XtPointer) NULL},
58     {XtNbottomShadowPixmap, XtCBottomShadowPixmap, XtRPixmap, sizeof(Pixmap),
59 	offset(sme_threeD.bot_shadow_pxmap), XtRImmediate, (XtPointer) NULL},
60     {XtNtopShadowContrast, XtCTopShadowContrast, XtRInt, sizeof(int),
61 	offset(sme_threeD.top_shadow_contrast), XtRImmediate, (XtPointer) 20},
62     {XtNbottomShadowContrast, XtCBottomShadowContrast, XtRInt, sizeof(int),
63 	offset(sme_threeD.bot_shadow_contrast), XtRImmediate, (XtPointer) 40},
64     {XtNuserData, XtCUserData, XtRPointer, sizeof(XtPointer),
65 	offset(sme_threeD.user_data), XtRPointer, (XtPointer) NULL},
66     {XtNbeNiceToColormap, XtCBeNiceToColormap, XtRBoolean, sizeof(Boolean),
67 	offset(sme_threeD.be_nice_to_cmap), XtRImmediate, (XtPointer) False},
68     {XtNshadowed, XtCShadowed, XtRBoolean, sizeof(Boolean),
69 	offset(sme_threeD.shadowed), XtRImmediate, (XtPointer) False},
70     {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
71 	XtOffsetOf(RectObjRec,rectangle.border_width), XtRImmediate,
72 	(XtPointer)0}
73 };
74 
75 #undef offset
76 
77 static void Initialize(), Destroy();
78 static void ClassPartInitialize(), _XawSme3dDrawShadows();
79 static Boolean SetValues();
80 
81 SmeThreeDClassRec smeThreeDClassRec = {
82     { /* core fields */
83     /* superclass		*/	(WidgetClass) &smeClassRec,
84     /* class_name		*/	"SmeThreeD",
85     /* widget_size		*/	sizeof(SmeThreeDRec),
86     /* class_initialize		*/	NULL,
87     /* class_part_initialize	*/	ClassPartInitialize,
88     /* class_inited		*/	FALSE,
89     /* initialize		*/	Initialize,
90     /* initialize_hook		*/	NULL,
91     /* realize			*/	NULL,
92     /* actions			*/	NULL,
93     /* num_actions		*/	0,
94     /* resources		*/	resources,
95     /* resource_count		*/	XtNumber(resources),
96     /* xrm_class		*/	NULLQUARK,
97     /* compress_motion		*/	TRUE,
98     /* compress_exposure	*/	TRUE,
99     /* compress_enterleave	*/	TRUE,
100     /* visible_interest		*/	FALSE,
101     /* destroy			*/	Destroy,
102     /* resize			*/	XtInheritResize,
103     /* expose			*/	NULL,
104     /* set_values		*/	SetValues,
105     /* set_values_hook		*/	NULL,
106     /* set_values_almost	*/	XtInheritSetValuesAlmost,
107     /* get_values_hook		*/	NULL,
108     /* accept_focus		*/	NULL,
109     /* version			*/	XtVersion,
110     /* callback_private		*/	NULL,
111     /* tm_table			*/	NULL,
112     /* query_geometry           */	XtInheritQueryGeometry,
113     /* display_accelerator      */	NULL,
114     /* extension                */	NULL
115     },
116     { /* Menu Entry fields */
117     /* highlight                */      XtInheritHighlight,
118     /* unhighlight              */      XtInheritUnhighlight,
119     /* notify                   */      XtInheritNotify,
120     /* extension                */      NULL
121     },
122     { /* threeD fields */
123     /* shadow draw              */      _XawSme3dDrawShadows
124     }
125 };
126 
127 WidgetClass smeThreeDObjectClass = (WidgetClass) &smeThreeDClassRec;
128 
129 /****************************************************************
130  *
131  * Private Procedures
132  *
133  ****************************************************************/
134 
135 
136 #define shadowpm_width 8
137 #define shadowpm_height 8
138 static char shadowpm_bits[] = {
139     0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55};
140 
141 static char mtshadowpm_bits[] = {
142     0x92, 0x24, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24};
143 
144 static char mbshadowpm_bits[] = {
145     0x6d, 0xdb, 0xb6, 0x6d, 0xdb, 0xb6, 0x6d, 0xdb};
146 
147 /* ARGSUSED */
AllocTopShadowGC(w)148 static void AllocTopShadowGC (w)
149     Widget w;
150 {
151     SmeThreeDObject	tdo = (SmeThreeDObject) w;
152     Screen		*scn = XtScreenOfObject (w);
153     XtGCMask		valuemask;
154     XGCValues		myXGCV;
155 
156     if (tdo->sme_threeD.be_nice_to_cmap || DefaultDepthOfScreen (scn) == 1) {
157 	valuemask = GCTile | GCFillStyle;
158 	myXGCV.tile = tdo->sme_threeD.top_shadow_pxmap;
159 	myXGCV.fill_style = FillTiled;
160     } else {
161 	valuemask = GCForeground;
162 	myXGCV.foreground = tdo->sme_threeD.top_shadow_pixel;
163     }
164     tdo->sme_threeD.top_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
165 }
166 
167 /* ARGSUSED */
AllocBotShadowGC(w)168 static void AllocBotShadowGC (w)
169     Widget w;
170 {
171     SmeThreeDObject	tdo = (SmeThreeDObject) w;
172     Screen		*scn = XtScreenOfObject (w);
173     XtGCMask		valuemask;
174     XGCValues		myXGCV;
175 
176     if (tdo->sme_threeD.be_nice_to_cmap || DefaultDepthOfScreen (scn) == 1) {
177 	valuemask = GCTile | GCFillStyle;
178 	myXGCV.tile = tdo->sme_threeD.bot_shadow_pxmap;
179 	myXGCV.fill_style = FillTiled;
180     } else {
181 	valuemask = GCForeground;
182 	myXGCV.foreground = tdo->sme_threeD.bot_shadow_pixel;
183     }
184     tdo->sme_threeD.bot_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
185 }
186 
187 /* ARGSUSED */
AllocEraseGC(w)188 static void AllocEraseGC (w)
189     Widget w;
190 {
191     Widget		parent = XtParent (w);
192     SmeThreeDObject	tdo = (SmeThreeDObject) w;
193     XtGCMask		valuemask;
194     XGCValues		myXGCV;
195 
196     valuemask = GCForeground;
197     myXGCV.foreground = parent->core.background_pixel;
198     tdo->sme_threeD.erase_GC = XtGetGC(w, valuemask, &myXGCV);
199 }
200 
201 /* ARGSUSED */
AllocTopShadowPixmap(new)202 static void AllocTopShadowPixmap (new)
203     Widget new;
204 {
205     SmeThreeDObject	tdo = (SmeThreeDObject) new;
206     Widget		parent = XtParent (new);
207     Display		*dpy = XtDisplayOfObject (new);
208     Screen		*scn = XtScreenOfObject (new);
209     unsigned long	top_fg_pixel = 0, top_bg_pixel = 0;
210     char		*pm_data = NULL;
211     Boolean		create_pixmap = FALSE;
212 
213     /*
214      * I know, we're going to create two pixmaps for each and every
215      * shadow'd widget.  Yeuck.  I'm semi-relying on server side
216      * pixmap cacheing.
217      */
218 
219     if (DefaultDepthOfScreen (scn) == 1) {
220 	top_fg_pixel = BlackPixelOfScreen (scn);
221 	top_bg_pixel = WhitePixelOfScreen (scn);
222 	pm_data = mtshadowpm_bits;
223 	create_pixmap = TRUE;
224     } else if (tdo->sme_threeD.be_nice_to_cmap) {
225 	if (parent->core.background_pixel == WhitePixelOfScreen (scn)) {
226 	    top_fg_pixel = WhitePixelOfScreen (scn);
227 	    top_bg_pixel = BlackPixelOfScreen (scn);
228 	} else if (parent->core.background_pixel == BlackPixelOfScreen (scn)) {
229 	    top_fg_pixel = BlackPixelOfScreen (scn);
230 	    top_bg_pixel = WhitePixelOfScreen (scn);
231 	} else {
232 	    top_fg_pixel = parent->core.background_pixel;
233 	    top_bg_pixel = WhitePixelOfScreen (scn);
234 	}
235 	if (parent->core.background_pixel == WhitePixelOfScreen (scn) ||
236 	    parent->core.background_pixel == BlackPixelOfScreen (scn))
237 	    pm_data = mtshadowpm_bits;
238 	else
239 	    pm_data = shadowpm_bits;
240 	create_pixmap = TRUE;
241     }
242     if (create_pixmap)
243 	tdo->sme_threeD.top_shadow_pxmap = XCreatePixmapFromBitmapData (dpy,
244 			RootWindowOfScreen (scn),
245 			pm_data,
246 			shadowpm_width,
247 			shadowpm_height,
248 			top_fg_pixel,
249 			top_bg_pixel,
250 			DefaultDepthOfScreen (scn));
251 }
252 
253 /* ARGSUSED */
AllocBotShadowPixmap(new)254 static void AllocBotShadowPixmap (new)
255     Widget new;
256 {
257     SmeThreeDObject	tdo = (SmeThreeDObject) new;
258     Widget		parent = XtParent (new);
259     Display		*dpy = XtDisplayOfObject (new);
260     Screen		*scn = XtScreenOfObject (new);
261     unsigned long	bot_fg_pixel = 0, bot_bg_pixel = 0;
262     char		*pm_data = NULL;
263     Boolean		create_pixmap = FALSE;
264 
265     if (DefaultDepthOfScreen (scn) == 1) {
266 	bot_fg_pixel = BlackPixelOfScreen (scn);
267 	bot_bg_pixel = WhitePixelOfScreen (scn);
268 	pm_data = mbshadowpm_bits;
269 	create_pixmap = TRUE;
270     } else if (tdo->sme_threeD.be_nice_to_cmap) {
271 	if (parent->core.background_pixel == WhitePixelOfScreen (scn)) {
272 	    bot_fg_pixel = WhitePixelOfScreen (scn);
273 	    bot_bg_pixel = BlackPixelOfScreen (scn);
274 	} else if (parent->core.background_pixel == BlackPixelOfScreen (scn)) {
275 	    bot_fg_pixel = BlackPixelOfScreen (scn);
276 	    bot_bg_pixel = WhitePixelOfScreen (scn);
277 	} else {
278 	    bot_fg_pixel = parent->core.background_pixel;
279 	    bot_bg_pixel = BlackPixelOfScreen (scn);
280 	}
281 	if (parent->core.background_pixel == WhitePixelOfScreen (scn) ||
282 	    parent->core.background_pixel == BlackPixelOfScreen (scn))
283 	    pm_data = mbshadowpm_bits;
284 	else
285 	    pm_data = shadowpm_bits;
286 	create_pixmap = TRUE;
287     }
288     if (create_pixmap)
289 	tdo->sme_threeD.bot_shadow_pxmap = XCreatePixmapFromBitmapData (dpy,
290 			RootWindowOfScreen (scn),
291 			pm_data,
292 			shadowpm_width,
293 			shadowpm_height,
294 			bot_fg_pixel,
295 			bot_bg_pixel,
296 			DefaultDepthOfScreen (scn));
297 }
298 
299 /* ARGSUSED */
XawSme3dComputeTopShadowRGB(new,xcol_out)300 void XawSme3dComputeTopShadowRGB (new, xcol_out)
301     Widget new;
302     XColor *xcol_out;
303 {
304     if (XtIsSubclass (new, smeThreeDObjectClass)) {
305 	SmeThreeDObject tdo = (SmeThreeDObject) new;
306 	Widget w = XtParent (new);
307 	XColor get_c;
308 	double contrast;
309 	Display *dpy = XtDisplayOfObject (new);
310 	Screen *scn = XtScreenOfObject (new);
311 	Colormap cmap = DefaultColormapOfScreen (scn);
312 
313 	get_c.pixel = w->core.background_pixel;
314 	if (get_c.pixel == WhitePixelOfScreen (scn) ||
315 	    get_c.pixel == BlackPixelOfScreen (scn)) {
316 	    contrast = (100 - tdo->sme_threeD.top_shadow_contrast) / 100.0;
317 	    xcol_out->red   = contrast * 65535.0;
318 	    xcol_out->green = contrast * 65535.0;
319 	    xcol_out->blue  = contrast * 65535.0;
320 	} else {
321 	    contrast = 1.0 + tdo->sme_threeD.top_shadow_contrast / 100.0;
322 	    XQueryColor (dpy, cmap, &get_c);
323 #define MIN(x,y) (unsigned short) (x < y) ? x : y
324 	    xcol_out->red   = MIN (65535, (int) (contrast * (double) get_c.red));
325 	    xcol_out->green = MIN (65535, (int) (contrast * (double) get_c.green));
326 	    xcol_out->blue  = MIN (65535, (int) (contrast * (double) get_c.blue));
327 #undef MIN
328 	}
329     } else
330 	xcol_out->red = xcol_out->green = xcol_out->blue = 0;
331 }
332 
333 /* ARGSUSED */
AllocTopShadowPixel(new)334 static void AllocTopShadowPixel (new)
335     Widget new;
336 {
337     XColor set_c;
338     SmeThreeDObject tdo = (SmeThreeDObject) new;
339     Display *dpy = XtDisplayOfObject (new);
340     Screen *scn = XtScreenOfObject (new);
341     Colormap cmap = DefaultColormapOfScreen (scn);
342 
343     XawSme3dComputeTopShadowRGB (new, &set_c);
344     (void) XAllocColor (dpy, cmap, &set_c);
345     tdo->sme_threeD.top_shadow_pixel = set_c.pixel;
346 }
347 
348 
349 /* ARGSUSED */
XawSme3dComputeBottomShadowRGB(new,xcol_out)350 void XawSme3dComputeBottomShadowRGB (new, xcol_out)
351     Widget new;
352     XColor *xcol_out;
353 {
354     if (XtIsSubclass (new, smeThreeDObjectClass)) {
355 	SmeThreeDObject tdo = (SmeThreeDObject) new;
356 	Widget w = XtParent (new);
357 	XColor get_c;
358 	double contrast;
359 	Display *dpy = XtDisplayOfObject (new);
360 	Screen *scn = XtScreenOfObject (new);
361 	Colormap cmap = DefaultColormapOfScreen (scn);
362 
363 	get_c.pixel = w->core.background_pixel;
364 	if (get_c.pixel == WhitePixelOfScreen (scn) ||
365 	    get_c.pixel == BlackPixelOfScreen (scn)) {
366 	    contrast = tdo->sme_threeD.bot_shadow_contrast / 100.0;
367 	    xcol_out->red   = contrast * 65535.0;
368 	    xcol_out->green = contrast * 65535.0;
369 	    xcol_out->blue  = contrast * 65535.0;
370 	} else {
371 	    XQueryColor (dpy, cmap, &get_c);
372 	    contrast = (100 - tdo->sme_threeD.bot_shadow_contrast) / 100.0;
373 	    xcol_out->red   = contrast * get_c.red;
374 	    xcol_out->green = contrast * get_c.green;
375 	    xcol_out->blue  = contrast * get_c.blue;
376 	}
377     } else
378 	xcol_out->red = xcol_out->green = xcol_out->blue = 0;
379 }
380 
381 /* ARGSUSED */
AllocBotShadowPixel(new)382 static void AllocBotShadowPixel (new)
383     Widget new;
384 {
385     XColor set_c;
386     SmeThreeDObject tdo = (SmeThreeDObject) new;
387     Display *dpy = XtDisplayOfObject (new);
388     Screen *scn = XtScreenOfObject (new);
389     Colormap cmap = DefaultColormapOfScreen (scn);
390 
391     XawSme3dComputeBottomShadowRGB (new, &set_c);
392     (void) XAllocColor (dpy, cmap, &set_c);
393     tdo->sme_threeD.bot_shadow_pixel = set_c.pixel;
394 }
395 
396 
397 /* ARGSUSED */
ClassPartInitialize(wc)398 static void ClassPartInitialize (wc)
399     WidgetClass	wc;
400 {
401     SmeThreeDClassRec *tdwc = (SmeThreeDClassRec *) wc;
402     SmeThreeDClassRec *super =
403 	(SmeThreeDClassRec *) tdwc->rect_class.superclass;
404 
405     if (tdwc->sme_threeD_class.shadowdraw == XtInheritXawSme3dShadowDraw)
406 	tdwc->sme_threeD_class.shadowdraw = super->sme_threeD_class.shadowdraw;
407 }
408 
409 /* ARGSUSED */
Initialize(request,new,args,num_args)410 static void Initialize (request, new, args, num_args)
411     Widget request, new;
412     ArgList args;
413     Cardinal *num_args;
414 {
415     SmeThreeDObject 	w = (SmeThreeDObject) new;
416     Screen		*scr = XtScreenOfObject (new);
417     XGCValues		gcv;
418 
419     if (w->sme_threeD.be_nice_to_cmap || DefaultDepthOfScreen (scr) == 1) {
420 	AllocTopShadowPixmap (new);
421 	AllocBotShadowPixmap (new);
422     } else {
423 	if (w->sme_threeD.top_shadow_pixel == w->sme_threeD.bot_shadow_pixel) {
424 	    AllocTopShadowPixel (new);
425 	    AllocBotShadowPixel (new);
426 	}
427 	w->sme_threeD.top_shadow_pxmap = w->sme_threeD.bot_shadow_pxmap = 0;
428     }
429     AllocTopShadowGC (new);
430     AllocBotShadowGC (new);
431     AllocEraseGC (new);
432     /* alloc highlight back (move this out from here if it get's bigger) */
433     w->sme_threeD.top_half_shadow_pixel=WhitePixelOfScreen(XtScreen(new));
434     gcv.foreground = w->sme_threeD.top_half_shadow_pixel;
435     w->sme_threeD.top_half_shadow_GC=XtGetGC(new,GCForeground,&gcv);
436 }
437 
Destroy(gw)438 static void Destroy (gw)
439      Widget gw;
440 {
441     SmeThreeDObject w = (SmeThreeDObject) gw;
442     XtReleaseGC (gw, w->sme_threeD.top_shadow_GC);
443     XtReleaseGC (gw, w->sme_threeD.top_half_shadow_GC);
444     XtReleaseGC (gw, w->sme_threeD.bot_shadow_GC);
445     XtReleaseGC (gw, w->sme_threeD.erase_GC);
446     if (w->sme_threeD.top_shadow_pxmap)
447 	XFreePixmap (XtDisplayOfObject (gw), w->sme_threeD.top_shadow_pxmap);
448     if (w->sme_threeD.bot_shadow_pxmap)
449 	XFreePixmap (XtDisplayOfObject (gw), w->sme_threeD.bot_shadow_pxmap);
450 }
451 
452 /* ARGSUSED */
SetValues(gcurrent,grequest,gnew,args,num_args)453 static Boolean SetValues (gcurrent, grequest, gnew, args, num_args)
454     Widget gcurrent, grequest, gnew;
455     ArgList args;
456     Cardinal *num_args;
457 {
458     SmeThreeDObject current = (SmeThreeDObject) gcurrent;
459     SmeThreeDObject new = (SmeThreeDObject) gnew;
460     Boolean redisplay = FALSE;
461     Boolean alloc_top_pixel = FALSE;
462     Boolean alloc_bot_pixel = FALSE;
463     Boolean alloc_top_pixmap = FALSE;
464     Boolean alloc_bot_pixmap = FALSE;
465 
466 #if 0
467     (*threeDWidgetClass->core_class.superclass->core_class.set_values)
468 	(gcurrent, grequest, gnew, NULL, 0);
469 #endif
470     if (new->sme_threeD.shadow_width != current->sme_threeD.shadow_width)
471 	redisplay = TRUE;
472     if (new->sme_threeD.be_nice_to_cmap != current->sme_threeD.be_nice_to_cmap) {
473 	if (new->sme_threeD.be_nice_to_cmap) {
474 	    alloc_top_pixmap = TRUE;
475 	    alloc_bot_pixmap = TRUE;
476 	} else {
477 	    alloc_top_pixel = TRUE;
478 	    alloc_bot_pixel = TRUE;
479 	}
480 	redisplay = TRUE;
481     }
482     if (!new->sme_threeD.be_nice_to_cmap &&
483 	new->sme_threeD.top_shadow_contrast != current->sme_threeD.top_shadow_contrast)
484 	alloc_top_pixel = TRUE;
485     if (!new->sme_threeD.be_nice_to_cmap &&
486 	new->sme_threeD.bot_shadow_contrast != current->sme_threeD.bot_shadow_contrast)
487 	alloc_bot_pixel = TRUE;
488     if (alloc_top_pixel)
489 	AllocTopShadowPixel (gnew);
490     if (alloc_bot_pixel)
491 	AllocBotShadowPixel (gnew);
492     if (alloc_top_pixmap)
493 	AllocTopShadowPixmap (gnew);
494     if (alloc_bot_pixmap)
495 	AllocBotShadowPixmap (gnew);
496     if (!new->sme_threeD.be_nice_to_cmap &&
497 	new->sme_threeD.top_shadow_pixel != current->sme_threeD.top_shadow_pixel)
498 	alloc_top_pixel = TRUE;
499     if (!new->sme_threeD.be_nice_to_cmap &&
500 	new->sme_threeD.bot_shadow_pixel != current->sme_threeD.bot_shadow_pixel)
501 	alloc_bot_pixel = TRUE;
502     if (new->sme_threeD.be_nice_to_cmap) {
503 	if (alloc_top_pixmap) {
504 	    XtReleaseGC (gcurrent, current->sme_threeD.top_shadow_GC);
505 	    AllocTopShadowGC (gnew);
506 	    redisplay = True;
507 	}
508 	if (alloc_bot_pixmap) {
509 	    XtReleaseGC (gcurrent, current->sme_threeD.bot_shadow_GC);
510 	    AllocBotShadowGC (gnew);
511 	    redisplay = True;
512 	}
513     } else {
514 	if (alloc_top_pixel) {
515 	    if (new->sme_threeD.top_shadow_pxmap) {
516 		XFreePixmap (XtDisplayOfObject (gnew), new->sme_threeD.top_shadow_pxmap);
517 		new->sme_threeD.top_shadow_pxmap = (Pixmap) NULL;
518 	    }
519 	    XtReleaseGC (gcurrent, current->sme_threeD.top_shadow_GC);
520 	    AllocTopShadowGC (gnew);
521 	    redisplay = True;
522 	}
523 	if (alloc_bot_pixel) {
524 	    if (new->sme_threeD.bot_shadow_pxmap) {
525 		XFreePixmap (XtDisplayOfObject (gnew), new->sme_threeD.bot_shadow_pxmap);
526 		new->sme_threeD.bot_shadow_pxmap = (Pixmap) NULL;
527 	    }
528 	    XtReleaseGC (gcurrent, current->sme_threeD.bot_shadow_GC);
529 	    AllocBotShadowGC (gnew);
530 	    redisplay = True;
531 	}
532     }
533     return (redisplay);
534 }
535 
536 /* ARGSUSED */
537 static void
_XawSme3dDrawShadows(gw)538 _XawSme3dDrawShadows (gw)
539     Widget gw;
540 {
541     SmeThreeDObject tdo = (SmeThreeDObject) gw;
542     Dimension	s = tdo->sme_threeD.shadow_width;
543 
544 
545     /*
546      * draw the shadows using the core part width and height,
547      * and the threeD part shadow_width.
548      *
549      *	no point to do anything if the shadow_width is 0 or the
550      *	widget has not been realized.
551      */
552     if((s > 0) && XtIsRealized (gw)){
553 
554 	Dimension	h = tdo->rectangle.height;
555 	Dimension	w = tdo->rectangle.width;
556 	Dimension	x = tdo->rectangle.x;
557 	Dimension	y = tdo->rectangle.y;
558 	Display		*dpy = XtDisplayOfObject (gw);
559 	Window		win = XtWindowOfObject (gw);
560 
561 	/* draw only the background */
562 	XFillRectangle(dpy, win, tdo->sme_threeD.top_half_shadow_GC,
563 		       x,y,w,h);
564        return;
565 #if 0
566 	if (tdo->sme_threeD.shadowed) {
567 	    top = tdo->sme_threeD.top_shadow_GC;
568 	    bot = tdo->sme_threeD.bot_shadow_GC;
569 	} else
570 	    top = bot = tdo->sme_threeD.erase_GC;
571 
572 	/* top-left shadow */
573 	pt[0].x = x;		pt[0].y = y + h;
574 	pt[1].x = x;		pt[1].y = y;
575 	pt[2].x = w;		pt[2].y = y;
576 	pt[3].x = w - s;	pt[3].y = y + s;
577 	pt[4].x = s;		pt[4].y = y + s;
578 	pt[5].x = s;		pt[5].y = y + h - s;
579 	XFillPolygon (dpy, win, top, pt, 6,Complex,CoordModeOrigin);
580 
581 	/* bottom-right shadow */
582      /* pt[0].x = x;		pt[0].y = y + h;	*/
583 	pt[1].x = w;		pt[1].y = y + h;
584      /* pt[2].x = w;		pt[2].y = y;		*/
585      /* pt[3].x = w - s;	pt[3].y = y + s;	*/
586 	pt[4].x = w - s;	pt[4].y = y + h - s;
587      /* pt[5].x = s;		pt[5].y = y + h - s;	*/
588 	XFillPolygon (dpy, win, bot, pt,6, Complex,CoordModeOrigin);
589 #endif
590     }
591 }
592 
593