1 /* $TOG: Obso2_0.c /main/10 1998/08/18 18:59:44 samborn $ */
2 /*
3  * Motif
4  *
5  * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6  *
7  * These libraries and programs are free software; you can
8  * redistribute them and/or modify them under the terms of the GNU
9  * Lesser General Public License as published by the Free Software
10  * Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * These libraries and programs are distributed in the hope that
14  * they will be useful, but WITHOUT ANY WARRANTY; without even the
15  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU Lesser General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with these librararies and programs; if not, write
21  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22  * Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 /*
26  * HISTORY
27  */
28 
29 
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 
35 #include <ctype.h>
36 #ifndef X_NOT_STDC_ENV
37 #include <stdlib.h>
38 #include <unistd.h>
39 #endif
40 
41 #include <X11/Intrinsic.h>
42 #include <Xm/BaseClassP.h>
43 #include <Xm/ColorP.h>
44 #include <Xm/DesktopP.h>
45 #include <Xm/DisplayP.h>
46 #include <Xm/DrawingAP.h>
47 #include <Xm/FileSBP.h>
48 #include <Xm/GadgetP.h>
49 #include <Xm/List.h>
50 #include <Xm/ManagerP.h>
51 #include <Xm/MenuShellP.h>
52 #include <Xm/MenuStateP.h>
53 #include <Xm/PrimitiveP.h>
54 #include <Xm/PushBGP.h>
55 #include <Xm/PushBP.h>
56 #include <Xm/RowColumnP.h>
57 #include <Xm/ScaleP.h>
58 #include <Xm/ScreenP.h>
59 #include <Xm/ScrolledWP.h>
60 #include <Xm/Text.h>
61 #include <Xm/TextF.h>
62 #include <Xm/TextInP.h>
63 #include <Xm/TextP.h>
64 #include <Xm/TransltnsP.h>
65 #include <Xm/VendorSEP.h>
66 #include <Xm/XmP.h>
67 #include <Xm/XmosP.h>
68 #include "BaseClassI.h"
69 #include "BulletinBI.h"
70 #include "ColorI.h"
71 #include "ExtObjectI.h"
72 #include "ImageCachI.h"
73 #include "MapEventsI.h"
74 #include "MenuStateI.h"
75 #include "MessagesI.h"
76 #include "PixConvI.h"
77 #include "ReadImageI.h"
78 #include "ResConverI.h"
79 #include "TextOutI.h"
80 #include "TravActI.h"
81 #include "TraversalI.h"
82 #include "XmI.h"
83 
84 /********    Static Function Declarations    ********/
85 
86 /********    End Static Function Declarations    ********/
87 
88 /* Exported variables that are now static. */
89 
90 XmPrimitiveClassExtRec _XmLabelPrimClassExtRec = {
91   NULL, NULLQUARK, 1L, sizeof(XmPrimitiveClassExtRec), NULL, NULL, NULL
92 };
93 
94 XmPrimitiveClassExtRec _XmTextPrimClassExtRec = {
95   NULL, NULLQUARK, 1L, sizeof(XmPrimitiveClassExtRec),
96   _XmTextGetBaselines, _XmTextGetDisplayRect, _XmTextMarginsProc
97 };
98 
99 XmPrimitiveClassExtRec _XmTextFPrimClassExtRec = {
100   NULL, NULLQUARK, 1L, sizeof(XmPrimitiveClassExtRec), NULL, NULL, NULL
101 };
102 
103 
104 XmGadgetClassExtRec _XmGadClassExtRec = {
105   NULL, NULLQUARK, 1L, sizeof(XmGadgetClassExtRec), NULL, NULL
106 };
107 
108 XmGadgetClassExtRec _XmLabelGadClassExtRec = {
109   NULL, NULLQUARK, 1L, sizeof(XmGadgetClassExtRec), NULL, NULL
110 };
111 
112 XmGadgetClassExtRec _XmPushBGadClassExtRec = {
113   NULL, NULLQUARK, 1L, sizeof(XmGadgetClassExtRec),
114   XmInheritBaselineProc, XmInheritDisplayRectProc
115 };
116 
117 XmGadgetClassExtRec _XmToggleBGadClassExtRec = {
118   NULL, NULLQUARK, 1L, sizeof(XmGadgetClassExtRec),
119   XmInheritBaselineProc, XmInheritDisplayRectProc
120 };
121 
122 /* XmWorld is defunct. */
123 
124 typedef struct _XmWorldClassPart {
125   XtPointer		extension;
126 } XmWorldClassPart;
127 
128 typedef struct _XmWorldClassRec {
129   ObjectClassPart	object_class;
130   XmExtClassPart	ext_class;
131   XmDesktopClassPart 	desktop_class;
132   XmWorldClassPart	world_class;
133 } XmWorldClassRec;
134 
135 typedef struct {
136   int			foo;
137 } XmWorldPart;
138 
139 typedef struct _XmWorldRec {
140   ObjectPart		object;
141   XmExtPart		ext;
142   XmDesktopPart		desktop;
143   XmWorldPart		world;
144 } XmWorldRec;
145 
146 externaldef(worldobjectclass) XmWorldClassRec xmWorldClassRec =
147 {
148   {
149     (WidgetClass) &xmDesktopClassRec, /* superclass		*/
150     "World",			/* class_name 		*/
151     sizeof(XmWorldRec),		/* size 		*/
152     NULL,			/* Class Initializer 	*/
153     NULL,			/* class_part_init 	*/
154     FALSE,			/* Class init'ed ? 	*/
155     NULL,			/* initialize         	*/
156     NULL,			/* initialize_notify    */
157     NULL,			/* realize            	*/
158     NULL,			/* actions            	*/
159     0,				/* num_actions        	*/
160     NULL,			/* resources          	*/
161     0,				/* resource_count     	*/
162     NULLQUARK, 			/* xrm_class          	*/
163     FALSE,			/* compress_motion    	*/
164     FALSE,			/* compress_exposure  	*/
165     FALSE,			/* compress_enterleave	*/
166     FALSE,			/* visible_interest   	*/
167     NULL,			/* destroy            	*/
168     NULL,			/* resize             	*/
169     NULL,			/* expose             	*/
170     NULL,			/* set_values         	*/
171     NULL,			/* set_values_hook      */
172     NULL,			/* set_values_almost    */
173     NULL,			/* get_values_hook      */
174     NULL,			/* accept_focus       	*/
175     XtVersion, 			/* intrinsics version 	*/
176     NULL,			/* callback offsets   	*/
177     NULL,			/* tm_table           	*/
178     NULL,			/* query_geometry       */
179     NULL,			/* world_accelerator    */
180     NULL,			/* extension            */
181   },
182   {				/* ext			*/
183     NULL,			/* synthetic resources	*/
184     0,				/* num syn resources	*/
185     NULL,			/* extension		*/
186   },
187   {				/* desktop		*/
188     (WidgetClass) &xmDisplayClassRec, /* child_class		*/
189     XtInheritInsertChild,	/* insert_child		*/
190     XtInheritDeleteChild,	/* delete_child		*/
191     NULL,			/* extension		*/
192   }
193 };
194 
195 externaldef(worldobjectclass) WidgetClass
196      xmWorldClass = (WidgetClass) &xmWorldClassRec;
197 
198 /************************************************************************
199  *                                                                      *
200  * _XmGetRealXlations - was global in ScrolledW.c, is now static.       *
201  *                                                                      *
202  ************************************************************************/
203 
204 char *
_XmGetRealXlations(Display * dpy,_XmBuildVirtualKeyStruct * keys,int num_keys)205 _XmGetRealXlations(
206         Display *dpy,
207         _XmBuildVirtualKeyStruct *keys,
208         int num_keys )
209 {
210   char *result, buf[1000];
211   char *tmp = buf;
212   char *keystring;
213   register int i;
214   int num_vkeys;
215   XmKeyBinding vkeys;
216   KeySym    keysym;
217   Modifiers mods;
218 
219   *tmp = '\0';
220   for (i = 0; i < num_keys; i++)
221     {
222       keysym = XStringToKeysym(keys[i].key);
223       if (keysym == NoSymbol)
224 	break;
225 
226       /* A virtual keysym may map to multiple real keysyms. */
227       num_vkeys = XmeVirtualToActualKeysyms(dpy, keysym, &vkeys);
228       while (--num_vkeys >= 0)
229 	{
230 	  keystring = XKeysymToString(vkeys[num_vkeys].keysym);
231 	  if (!keystring)
232 	    break;
233 	  mods = vkeys[num_vkeys].modifiers | keys[i].mod;
234 
235 	  if (mods & ControlMask)
236 	    strcat(tmp, "Ctrl ");
237 
238 	  if (mods & ShiftMask)
239 	    strcat(tmp, "Shift ");
240 
241 	  if (mods & Mod1Mask)
242 	    strcat(tmp, "Mod1 ");  /* "Alt" may not be right on some systems */
243 
244 	  strcat(tmp,"<Key>");
245 	  strcat(tmp, keystring);
246 	  strcat(tmp,": ");
247 	  strcat(tmp,keys[i].action);
248 
249 	  tmp += strlen(tmp);
250 	  assert((tmp - buf) < 1000);
251 	}
252 
253       XtFree((char*) vkeys);
254     }
255 
256   if (buf[0] != '\0')
257     result = XtNewString(buf);
258   else
259     result = NULL;
260   return(result);
261 
262 }
263 
264 
265 /************************************************************************
266  *
267  *  _XmSetEtchedSlider
268  *	Set the scrollbar variable which causes the slider pixmap
269  *	to be etched. Was in ScrollBar.c
270  ************************************************************************/
271 void
_XmSetEtchedSlider(XmScrollBarWidget sbw)272 _XmSetEtchedSlider(
273         XmScrollBarWidget sbw )
274 {
275    XtVaSetValues((Widget) sbw, XmNsliderVisual, XmETCHED_LINE, NULL);
276 }
277 
278 
279 
280 
281 /**********************************************************************
282  *
283  * _XmSortResourceList: superceded by XmReorderResourceList
284  *
285  **********************************************************************/
286 void
_XmSortResourceList(XrmResource * list[],Cardinal len)287 _XmSortResourceList(
288         XrmResource *list[],
289         Cardinal len )
290 {
291 	static Boolean first_time = TRUE;
292 	static XrmQuark unitQ;
293 	int n,i;
294 	XrmResource *p = NULL;
295 
296 	if (first_time)
297 	{
298 		unitQ = XrmPermStringToQuark(XmNunitType);
299 		first_time = FALSE;
300 	}
301 
302 	for (n=0; n < len; n++)
303 		if (list[n]->xrm_name == unitQ)
304 		{
305 			p = list[n];
306 			break;
307 		}
308 
309 	if (n == len)
310 		return; /* No unit type resource found in this list. */
311 	else
312 	{
313 		for (i=n; i > 0; i--)
314 			list[i] = list[i-1];
315 
316 		list[0] = p;
317 	}
318 }
319 
320 
321 /************************************************************************
322  ************************************************************************
323   Stuff that was in Visual.c, now obsolete by the XtReOrderResourceList
324   API.
325  ************************************************************************/
326 
327 
328 
329 /************************************************************************
330  *
331  *  _XmGetBGPixmapName
332  *	Return the background pixmap name set by the string to background
333  *	resource converter.  This is used by primitive and manager.
334  *
335  ************************************************************************/
336 char *
_XmGetBGPixmapName(void)337 _XmGetBGPixmapName( void )
338 {
339    return NULL;
340 }
341 
342 
343 
344 /************************************************************************
345  *
346  *  _XmClearBGPixmapName
347  *	Clear the background pixmap name set by the string to background
348  *	resource converter.  This is used by primitive and manager.
349  *
350  ************************************************************************/
351 void
_XmClearBGPixmapName(void)352 _XmClearBGPixmapName( void )
353 {
354   /*EMPTY*/
355 }
356 
357 
358 /**---------------------------------------------------------*/
359 /**---------------------------------------------------------*/
360 /* This code was in Visual.c, global while only localy used */
361 
362 #define MESSAGE0	_XmMsgVisual_0000
363 #define MESSAGE1	_XmMsgVisual_0001
364 #define MESSAGE2	_XmMsgVisual_0002
365 
366 
367 extern Pixel
_XmBlackPixel(Screen * screen,Colormap colormap,XColor blackcolor)368 _XmBlackPixel(
369 	      Screen *screen,
370 	      Colormap colormap,
371 	      XColor blackcolor )
372 {
373   Pixel p;
374 
375   blackcolor.red = 0;
376   blackcolor.green = 0;
377   blackcolor.blue = 0;
378 
379   if (colormap == DefaultColormapOfScreen(screen))
380     p = blackcolor.pixel = BlackPixelOfScreen(screen);
381   else if (XAllocColor(screen->display, colormap, &blackcolor))
382     p = blackcolor.pixel;
383   else
384     p = blackcolor.pixel = BlackPixelOfScreen(screen); /* fallback pixel */
385 
386   return (p);
387 }
388 
389 
390 extern Pixel
_XmWhitePixel(Screen * screen,Colormap colormap,XColor whitecolor)391 _XmWhitePixel(
392 	      Screen *screen,
393 	      Colormap colormap,
394 	      XColor whitecolor )
395 {
396   Pixel p;
397 
398   whitecolor.red = XmMAX_SHORT;
399   whitecolor.green = XmMAX_SHORT;
400   whitecolor.blue = XmMAX_SHORT;
401 
402   if (colormap == DefaultColormapOfScreen(screen))
403     p = whitecolor.pixel = WhitePixelOfScreen(screen);
404   else if (XAllocColor(screen->display, colormap, &whitecolor))
405     p = whitecolor.pixel;
406   else
407     p = whitecolor.pixel = WhitePixelOfScreen(screen); /* fallback pixel */
408   return (p);
409 }
410 
411 
412 String
_XmGetDefaultBackgroundColorSpec(Screen * screen)413 _XmGetDefaultBackgroundColorSpec( Screen *screen )
414 {
415   XrmName names[2];
416   XrmClass classes[2];
417   XrmRepresentation rep;
418   XrmValue db_value;
419   String default_background_color_spec = NULL ;
420 
421   names[0] = XrmPermStringToQuark(XmNbackground);
422   names[1] = NULLQUARK;
423 
424   classes[0] = XrmPermStringToQuark(XmCBackground);
425   classes[1] = NULLQUARK;
426 
427   if (XrmQGetResource(XtScreenDatabase(screen), names, classes,
428 		      &rep, &db_value))
429      {
430 	if (rep == XrmPermStringToQuark(XmRString))
431 	    default_background_color_spec = db_value.addr;
432      }
433   else default_background_color_spec = XmDEFAULT_BACKGROUND;
434 
435   return(default_background_color_spec);
436 }
437 
438 
439 /*ARGSUSED*/
440 void
_XmSetDefaultBackgroundColorSpec(Screen * screen,String new_color_spec)441 _XmSetDefaultBackgroundColorSpec(
442 	Screen *screen,	/* unused */
443         String new_color_spec )
444 {
445     static Boolean app_defined = FALSE;
446     String default_background_color_spec = NULL ;
447 
448     if (app_defined)
449 	{
450 	    XtFree(default_background_color_spec);
451 	}
452 
453     default_background_color_spec = (String)
454 	XtMalloc(strlen(new_color_spec) + 1);
455     /* this needs to be set per screen */
456     strcpy(default_background_color_spec, new_color_spec);
457 
458     app_defined = TRUE;
459 }
460 
461 /*
462  * GLOBAL VARIABLES
463  *
464  * These variables define the color cache.
465  */
466 
467 
468 /* Thresholds for brightness
469    above LITE threshold, LITE color model is used
470    below DARK threshold, DARK color model is be used
471    use STD color model in between */
472 
473 static int XmCOLOR_LITE_THRESHOLD;
474 static int XmCOLOR_DARK_THRESHOLD;
475 static int XmFOREGROUND_THRESHOLD;
476 static Boolean XmTHRESHOLDS_INITD = FALSE;
477 
478 
479 
480 void
_XmGetDefaultThresholdsForScreen(Screen * screen)481 _XmGetDefaultThresholdsForScreen( Screen *screen )
482 {
483   XrmName names[2];
484   XrmClass classes[2];
485   XrmRepresentation rep;
486   XrmValue db_value, to_value;
487   int int_value;
488   int default_light_threshold_spec;
489   int default_dark_threshold_spec;
490   int default_foreground_threshold_spec;
491   WidgetRec widget;
492 
493   XmTHRESHOLDS_INITD = True;
494 
495  /*
496   * We need a widget to pass into the XtConvertAndStore() function
497   * to convert the string to an int.  Since a widget can't be
498   * passed into this procedure because the public interfaces
499   * that call this routine don't have a widget, we need this hack
500   * to create a dummy widget.
501   */
502   bzero((void*) &widget, sizeof(widget) );
503   widget.core.self = &widget;
504   widget.core.widget_class = coreWidgetClass;
505   widget.core.screen = screen;
506   XtInitializeWidgetClass(coreWidgetClass);
507 
508 
509   names[0] = XrmPermStringToQuark(XmNlightThreshold);
510   names[1] = NULLQUARK;
511 
512   classes[0] = XrmPermStringToQuark(XmCLightThreshold);
513   classes[1] = NULLQUARK;
514 
515   if (XrmQGetResource(XtScreenDatabase(screen), names, classes,
516 		      &rep, &db_value))
517     {
518      /* convert the string to an int value */
519       to_value.size = sizeof(int);
520       to_value.addr = (XPointer) &int_value;
521       if (XtConvertAndStore(&widget, XmRString, &db_value, XmRInt, &to_value))
522       {
523 	default_light_threshold_spec = int_value;
524 	if ( (default_light_threshold_spec < 0) ||
525 	     (default_light_threshold_spec > 100) )
526 	  default_light_threshold_spec = XmDEFAULT_LIGHT_THRESHOLD;
527       }
528       else default_light_threshold_spec = XmDEFAULT_LIGHT_THRESHOLD;
529     }
530   else default_light_threshold_spec = XmDEFAULT_LIGHT_THRESHOLD;
531 
532   names[0] = XrmPermStringToQuark(XmNdarkThreshold);
533   names[1] = NULLQUARK;
534 
535   classes[0] = XrmPermStringToQuark(XmCDarkThreshold);
536   classes[1] = NULLQUARK;
537 
538   if (XrmQGetResource(XtScreenDatabase(screen), names, classes,
539 		      &rep, &db_value))
540     {
541      /* convert the string to an int value */
542       to_value.size = sizeof(int);
543       to_value.addr = (XPointer) &int_value;
544       if (XtConvertAndStore(&widget, XmRString, &db_value, XmRInt, &to_value))
545       {
546         XtConvertAndStore(&widget, XmRString, &db_value, XmRInt, &to_value);
547 	default_dark_threshold_spec = int_value;
548 	if ( (default_dark_threshold_spec < 0) ||
549 	     (default_dark_threshold_spec > 100) )
550 	  default_dark_threshold_spec = XmDEFAULT_DARK_THRESHOLD;
551        }
552        else default_dark_threshold_spec = XmDEFAULT_DARK_THRESHOLD;
553     }
554   else default_dark_threshold_spec = XmDEFAULT_DARK_THRESHOLD;
555 
556   names[0] = XrmPermStringToQuark(XmNforegroundThreshold);
557   names[1] = NULLQUARK;
558 
559   classes[0] = XrmPermStringToQuark(XmCForegroundThreshold);
560   classes[1] = NULLQUARK;
561 
562   if (XrmQGetResource(XtScreenDatabase(screen), names, classes,
563 		      &rep, &db_value))
564     {
565      /* convert the string to an int value */
566       to_value.size = sizeof(int);
567       to_value.addr = (XPointer) &int_value;
568       if (XtConvertAndStore(&widget, XmRString, &db_value, XmRInt, &to_value))
569       {
570 	default_foreground_threshold_spec = int_value;
571 	if ( (default_foreground_threshold_spec < 0) ||
572 	     (default_foreground_threshold_spec > 100) )
573 	  default_foreground_threshold_spec = XmDEFAULT_FOREGROUND_THRESHOLD;
574       }
575       else default_foreground_threshold_spec = XmDEFAULT_FOREGROUND_THRESHOLD;
576     }
577   else default_foreground_threshold_spec = XmDEFAULT_FOREGROUND_THRESHOLD;
578 
579   XmCOLOR_LITE_THRESHOLD = default_light_threshold_spec * XmCOLOR_PERCENTILE;
580   XmCOLOR_DARK_THRESHOLD = default_dark_threshold_spec * XmCOLOR_PERCENTILE;
581   XmFOREGROUND_THRESHOLD = default_foreground_threshold_spec * XmCOLOR_PERCENTILE;
582 }
583 
584 
585 
586 
587 /********--------------------------------------
588   IconPixmap VendorShell stuff previously in VendorSE.c.
589   Obsolete because XmRBitmap is now used to convert
590  ********-------------------------------------*/
591 
592 
593 /************************************************************************
594  *
595  *  _XmGetIconPixmapName
596  *      Return the icon pixmap name set by the string to icon resource
597  *      converter.  This is used by the vendor shell.
598  *
599  ************************************************************************/
600 char*
_XmGetIconPixmapName(void)601 _XmGetIconPixmapName( void )
602 {
603    return NULL;
604 }
605 
606 /************************************************************************
607  *
608  *  _XmClearIconPixmapName
609  *      Clear the icon pixmap name set by the string to icon resource
610  *      converter.  This is used by the vendor shell.
611  *
612  ************************************************************************/
613 void
_XmClearIconPixmapName(void)614 _XmClearIconPixmapName( void )
615 {
616   /*EMPTY*/
617 }
618 
619 
620 /************************************************************************
621  *									*
622  * _XmInitializeScrollBars - initialize the scrollbars for auto mode.	*
623  *			WAS in ScrolledW.c      			*
624  ************************************************************************/
625 #define ScrollBarVisible( wid)      (wid && XtIsManaged( wid))
626 void
_XmInitializeScrollBars(Widget w)627 _XmInitializeScrollBars(
628         Widget w )
629 {
630     XmScrolledWindowWidget	sw = (XmScrolledWindowWidget) w;
631     int i, inc;
632     Dimension bw;
633     Arg vSBArgs[6];
634     Arg hSBArgs[6];
635 
636     if (sw->swindow.VisualPolicy == XmVARIABLE)
637 	return;
638 
639     bw = 0;
640     if (sw->swindow.WorkWindow)
641         bw = sw->swindow.WorkWindow->core.border_width;
642 
643     sw->swindow.vmin = 0;
644     sw->swindow.vOrigin = 0;
645     sw->swindow.hmin = 0;
646     sw->swindow.hOrigin = 0;
647     if (ScrollBarVisible(sw->swindow.WorkWindow))
648     {
649         sw->swindow.vOrigin = abs(sw->swindow.WorkWindow->core.y);
650 	sw->swindow.vmax = sw->swindow.WorkWindow->core.height + (2 * bw);
651 	if (sw->swindow.vmax <1) sw->swindow.vmax = 1;
652 	sw->swindow.vExtent = sw->swindow.AreaHeight;
653         if (sw->swindow.vOrigin < sw->swindow.vmin)
654             sw->swindow.vOrigin = sw->swindow.vmin;
655 
656 	if ((sw->swindow.vExtent + sw->swindow.vOrigin) > sw->swindow.vmax)
657 	    sw->swindow.vExtent = sw->swindow.vmax - sw->swindow.vOrigin;
658 	if (sw->swindow.vExtent < 0)
659         {
660 	    sw->swindow.vExtent = sw->swindow.vmax;
661             sw->swindow.vOrigin = sw->swindow.vmin;
662         }
663 
664 	sw->swindow.hmax = sw->swindow.WorkWindow->core.width + (2 * bw);
665 	if (sw->swindow.hmax <1) sw->swindow.hmax = 1;
666         sw->swindow.hOrigin = abs(sw->swindow.WorkWindow->core.x);
667 	sw->swindow.hExtent = sw->swindow.AreaWidth;
668         if (sw->swindow.hOrigin < sw->swindow.hmin)
669             sw->swindow.hOrigin = sw->swindow.hmin;
670 
671 	if ((sw->swindow.hExtent + sw->swindow.hOrigin) > sw->swindow.hmax)
672 	    sw->swindow.hExtent = sw->swindow.hmax - sw->swindow.hOrigin;
673 	if (sw->swindow.hExtent < 0)
674         {
675 	    sw->swindow.hExtent = sw->swindow.hmax;
676             sw->swindow.hOrigin = sw->swindow.hmin;
677         }
678 
679     }
680     else
681     {
682 	sw->swindow.vExtent = (sw->swindow.ClipWindow->core.height > 0) ?
683 			       sw->swindow.ClipWindow->core.height : 1;
684 	sw->swindow.hExtent = (sw->swindow.ClipWindow->core.width > 0) ?
685 			       sw->swindow.ClipWindow->core.width : 1;
686 	sw->swindow.vmax = sw->swindow.vExtent;
687 	sw->swindow.hmax = sw->swindow.hExtent;
688     }
689     if(sw->swindow.vScrollBar)
690     {
691 	i = 0;
692         if (sw->swindow.WorkWindow)
693         {
694             if ((inc = ((sw->swindow.WorkWindow->core.height) / 10)) < 1)
695                 inc = 1;
696             XtSetArg (vSBArgs[i], XmNincrement, (XtArgVal) inc); i++;
697         }
698 	if ((inc = (sw->swindow.AreaHeight - (sw->swindow.AreaHeight / 10))) < 1)
699 	    inc = sw->swindow.AreaHeight;
700         XtSetArg (vSBArgs[i], XmNpageIncrement, (XtArgVal) inc); i++;
701 	XtSetArg (vSBArgs[i], XmNminimum, (XtArgVal) (sw->swindow.vmin)); i++;
702 	XtSetArg (vSBArgs[i], XmNmaximum, (XtArgVal) (sw->swindow.vmax)); i++;
703 	XtSetArg (vSBArgs[i], XmNvalue, (XtArgVal) sw->swindow.vOrigin); i++;
704 	XtSetArg (vSBArgs[i], XmNsliderSize, (XtArgVal) (sw->swindow.vExtent)); i++;
705 	assert(i <= XtNumber(vSBArgs));
706 	XtSetValues((Widget) sw->swindow.vScrollBar,vSBArgs,i);
707     }
708     if(sw->swindow.hScrollBar)
709     {
710 	i = 0;
711         if (sw->swindow.WorkWindow)
712         {
713             if ((inc = ((sw->swindow.WorkWindow->core.width) / 10)) < 1)
714                 inc = 1;
715             XtSetArg (hSBArgs[i], XmNincrement, (XtArgVal) inc); i++;
716         }
717 	if ((inc = (sw->swindow.AreaWidth - (sw->swindow.AreaWidth / 10))) < 1)
718 	    inc = sw->swindow.AreaWidth;
719 
720         XtSetArg (hSBArgs[i], XmNpageIncrement, (XtArgVal) inc); i++;
721 	XtSetArg (hSBArgs[i], XmNminimum, (XtArgVal) (sw->swindow.hmin)); i++;
722 	XtSetArg (hSBArgs[i], XmNmaximum, (XtArgVal) (sw->swindow.hmax)); i++;
723 	XtSetArg (hSBArgs[i], XmNvalue, (XtArgVal) sw->swindow.hOrigin); i++;
724 	XtSetArg (hSBArgs[i], XmNsliderSize, (XtArgVal) (sw->swindow.hExtent)); i++;
725 	assert(i <= XtNumber(hSBArgs));
726 	XtSetValues((Widget) sw->swindow.hScrollBar,hSBArgs,i);
727     }
728 
729 }
730 
731 void
InitializeScrollBars(Widget w)732 InitializeScrollBars(
733         Widget w )
734 {
735   _XmInitializeScrollBars( w) ;
736 }
737 
738 
739 void
_XmClearBCompatibility(Widget pb)740 _XmClearBCompatibility(
741         Widget pb )
742 {
743 
744 	((XmPushButtonWidget) pb)->pushbutton.compatible =  False;
745 }
746 
747 
748 void
_XmClearBGCompatibility(Widget pbg)749 _XmClearBGCompatibility(
750         Widget pbg )
751 {
752 	 PBG_Compatible (pbg) = False;
753 }
754 
755 
756 
757 
758 /****************************************************************/
759 void
_XmBulletinBoardSetDefaultShadow(Widget button)760 _XmBulletinBoardSetDefaultShadow(
761         Widget button )
762 {
763             Arg             argv[2] ;
764             Cardinal        argc ;
765             Dimension       dbShadowTh = 0;
766             Dimension       shadowTh ;
767 /****************/
768 
769     if(    XmIsPushButtonGadget( button)    )
770     {   _XmClearBGCompatibility( button) ;
771         }
772     else
773     {   if(    XmIsPushButton( button)    )
774         {   _XmClearBCompatibility( button) ;
775             }
776         }
777     argc = 0 ;
778     XtSetArg( argv[argc], XmNshadowThickness, &shadowTh) ; ++argc ;
779     XtSetArg( argv[argc], XmNdefaultButtonShadowThickness,
780                                                         &dbShadowTh) ; ++argc ;
781     XtGetValues( button, argv, argc) ;
782 
783     if(    !dbShadowTh    )
784     {   if(    shadowTh > 1    )
785         {   dbShadowTh = shadowTh >> 1 ;
786             }
787         else
788         {   dbShadowTh = shadowTh ;
789             }
790         argc = 0 ;
791         XtSetArg( argv[argc], XmNdefaultButtonShadowThickness,
792                                                          dbShadowTh) ; ++argc ;
793         XtSetValues( button, argv, argc) ;
794         }
795     return ;
796     }
797 
798 
799 static Widget
GetBBWithDB(Widget wid)800 GetBBWithDB(
801  	Widget wid)
802  {
803    Widget focus ;
804 
805    if(    (_XmGetFocusPolicy( wid) == XmEXPLICIT)
806       &&  (    (focus = XmGetFocusWidget( wid))
807  	  ||  (focus = _XmGetFirstFocus( wid)))    )
808      {
809        while(    focus
810  	    &&  !XtIsShell( focus)    )
811  	{
812  	  if(    XmIsBulletinBoard( focus)
813  	     &&  BB_DefaultButton( focus)    )
814  	    {
815  	      return focus ;
816  	    }
817  	  focus = XtParent( focus) ;
818  	}
819 
820      }
821    return NULL ;
822  }
823 
824 
825 void
_XmBBUpdateDynDefaultButton(Widget bb)826 _XmBBUpdateDynDefaultButton(
827  	Widget bb)
828  {
829    Widget bbwdb = GetBBWithDB( bb) ;
830 
831    if(    bbwdb == NULL    )
832      {
833        if(    ((XmBulletinBoardWidget) bb)
834  	                           ->bulletin_board.dynamic_default_button    )
835  	{
836  	  _XmBulletinBoardSetDynDefaultButton( bb, NULL) ;
837  	}
838      }
839    else
840      {
841        if(    bbwdb == bb    )
842  	{
843  	  _XmBulletinBoardSetDynDefaultButton( bb, BB_DefaultButton( bb)) ;
844  	}
845      }
846  }
847 
848 /********************************************************************/
849 
850 Boolean
_XmDifferentBackground(Widget w,Widget parent)851 _XmDifferentBackground(
852         Widget w,
853         Widget parent )
854 {
855     if (XmIsPrimitive (w) && XmIsManager (parent)) {
856 	if (w->core.background_pixel != parent->core.background_pixel ||
857 	    w->core.background_pixmap != parent->core.background_pixmap)
858 	    return (True);
859     }
860 
861     return (False);
862 }
863 
864 
865 /*******************************************************************
866   More Visual.c stuff not used */
867 
868 
869 
870 static void
SetMonochromeColors(XmColorData * colors)871 SetMonochromeColors(
872         XmColorData *colors )
873 {
874 	Screen *screen = colors->screen;
875 	Pixel background = colors->background.pixel;
876 
877 	if (background == BlackPixelOfScreen(screen))
878 	{
879 		colors->foreground.pixel = WhitePixelOfScreen (screen);
880 		colors->foreground.red = colors->foreground.green =
881 			colors->foreground.blue = XmMAX_SHORT;
882 
883 		colors->bottom_shadow.pixel = WhitePixelOfScreen(screen);
884 		colors->bottom_shadow.red = colors->bottom_shadow.green =
885 			colors->bottom_shadow.blue = XmMAX_SHORT;
886 
887 		colors->select.pixel = WhitePixelOfScreen(screen);
888 		colors->select.red = colors->select.green =
889 			colors->select.blue = XmMAX_SHORT;
890 
891 		colors->top_shadow.pixel = BlackPixelOfScreen(screen);
892 		colors->top_shadow.red = colors->top_shadow.green =
893 			colors->top_shadow.blue = 0;
894 	}
895 	else if (background == WhitePixelOfScreen(screen))
896 	{
897 		colors->foreground.pixel = BlackPixelOfScreen(screen);
898 		colors->foreground.red = colors->foreground.green =
899 			colors->foreground.blue = 0;
900 
901 		colors->top_shadow.pixel = WhitePixelOfScreen(screen);
902 		colors->top_shadow.red = colors->top_shadow.green =
903 			colors->top_shadow.blue = XmMAX_SHORT;
904 
905 		colors->bottom_shadow.pixel = BlackPixelOfScreen(screen);
906 		colors->bottom_shadow.red = colors->bottom_shadow.green =
907 			colors->bottom_shadow.blue = 0;
908 
909 		colors->select.pixel = BlackPixelOfScreen(screen);
910 		colors->select.red = colors->select.green =
911 			colors->select.blue = 0;
912 	}
913 
914 	colors->allocated |= (XmFOREGROUND | XmTOP_SHADOW
915 		| XmBOTTOM_SHADOW | XmSELECT);
916 }
917 
918 
919 /* This one still used by mwm: fix mwm */
920 
921 /*********************************************************************
922  *
923  *  _XmGetColors
924  *
925  *********************************************************************/
926 XmColorData *
_XmGetColors(Screen * screen,Colormap color_map,Pixel background)927 _XmGetColors(
928         Screen *screen,
929         Colormap color_map,
930         Pixel background )
931 {
932 	Display * display = DisplayOfScreen (screen);
933 	XmColorData *old_colors;
934 	XmColorData new_colors;
935 	XmColorProc ColorRGBCalcProc ;
936 
937 
938 	new_colors.screen = screen;
939 	new_colors.color_map = color_map;
940 	new_colors.background.pixel = background;
941 
942 	if (_XmSearchColorCache(
943 		(XmLOOK_AT_SCREEN | XmLOOK_AT_CMAP | XmLOOK_AT_BACKGROUND),
944 			&new_colors, &old_colors)) {
945                /*
946 		* initialize the thresholds if the current color scheme
947 		* already matched what is in the cache and the thresholds
948 		* haven't already been initialized.
949                 */
950                 if (!XmTHRESHOLDS_INITD)
951 	            _XmGetDefaultThresholdsForScreen(screen);
952 		return(old_colors);
953         }
954 
955 	XQueryColor (display, color_map, &(new_colors.background));
956 	new_colors.allocated = XmBACKGROUND;
957 
958 	/*
959 	 * Just in case somebody looks at these before they're ready,
960 	 * initialize them to a value that is always valid (for most
961 	 * implementations of X).
962 	 */
963 	new_colors.foreground.pixel = 0;
964 	new_colors.top_shadow.pixel = 0;
965 	new_colors.top_shadow.pixel = 0;
966 	new_colors.select.pixel = 0;
967 
968 	/*  Generate the foreground, top_shadow, and bottom_shadow based  */
969 	/*  on the background                                             */
970 
971 	if (DefaultDepthOfScreen(screen) == 1)
972 		SetMonochromeColors(&new_colors);
973 	else
974 	  {
975 	    _XmGetDefaultThresholdsForScreen(screen);
976 	    ColorRGBCalcProc = XmGetColorCalculation() ;
977 	    (*ColorRGBCalcProc)(&(new_colors.background),
978 				&(new_colors.foreground), &(new_colors.select),
979 				&(new_colors.top_shadow), &(new_colors.bottom_shadow));
980 	  }
981 	return (_XmAddToColorCache(&new_colors));
982 }
983 
984 
985 
986 XmColorData *
_XmGetDefaultColors(Screen * screen,Colormap color_map)987 _XmGetDefaultColors(
988         Screen *screen,
989         Colormap color_map )
990 {
991 	static XmColorData ** default_set = NULL;
992 	static int default_set_count = 0;
993 	static int default_set_size = 0;
994 	register int i;
995 	XColor color_def;
996 	static Pixel background;
997         XrmValue fromVal;
998         XrmValue toVal;
999         XrmValue args[2];
1000         Cardinal num_args;
1001 	String default_string = XtDefaultBackground;
1002 
1003 	/*  Look through  a set of screen / background pairs to see  */
1004 	/*  if the default is already in the table.                  */
1005 
1006 	for (i = 0; i < default_set_count; i++)
1007 	{
1008 	if ((default_set[i]->screen == screen) &&
1009 		(default_set[i]->color_map == color_map))
1010 		return (default_set[i]);
1011 	}
1012 
1013 	/*  See if more space is needed in the array  */
1014 
1015 	if (default_set == NULL)
1016 	{
1017 		default_set_size = 10;
1018 		default_set = (XmColorData **) XtRealloc((char *) default_set,
1019 			(sizeof(XmColorData *) * default_set_size));
1020 
1021 	}
1022 	else if (default_set_count == default_set_size)
1023 	{
1024 		default_set_size += 10;
1025 		default_set = (XmColorData **) XtRealloc((char *) default_set,
1026 			sizeof(XmColorData *) * default_set_size);
1027 	}
1028 
1029 	/* Find the background based on the depth of the screen */
1030 	if (DefaultDepthOfScreen(screen) == 1)
1031         {
1032 	  /*
1033 	   * Fix for 4603 - Convert the string XtDefaultBackground into a Pixel
1034 	   *                value using the XToolkit converter.  This converter
1035 	   *                will set this value to WhitePixelOfScreen if reverse
1036 	   *                video is not on, and to BlackPixelOfScreen if reverse
1037 	   *                video is on.
1038 	   */
1039 	  args[0].addr = (XPointer) &screen;
1040 	  args[0].size = sizeof(Screen*);
1041 	  args[1].addr = (XPointer) &color_map;
1042 	  args[1].size = sizeof(Colormap);
1043 	  num_args = 2;
1044 
1045 	  fromVal.addr = default_string;
1046 	  fromVal.size = strlen(default_string);
1047 
1048 	  toVal.addr = (XPointer) &background;
1049 	  toVal.size = sizeof(Pixel);
1050 
1051 	  if(!XtCallConverter(DisplayOfScreen(screen),XtCvtStringToPixel,
1052 			      args, num_args, &fromVal, &toVal, NULL))
1053 	    background = WhitePixelOfScreen(screen);
1054         }
1055 
1056 	else
1057 	{
1058 		/*  Parse out a color for the default background  */
1059 
1060 		if (XParseColor(DisplayOfScreen(screen), color_map,
1061 			_XmGetDefaultBackgroundColorSpec(screen), &color_def))
1062 		{
1063 			if (XAllocColor(DisplayOfScreen(screen), color_map,
1064 				&color_def))
1065 			{
1066 				background = color_def.pixel;
1067 			}
1068 			else
1069 			{
1070 				XtWarning(MESSAGE1);
1071 				background = WhitePixelOfScreen(screen);
1072 			}
1073 		}
1074 		else
1075 		{
1076 			XtWarning(MESSAGE2);
1077 			background = WhitePixelOfScreen(screen);
1078 		}
1079 	}
1080 
1081 	/*
1082 	 * Get the color data generated and save it in the next open
1083 	 * slot in the default set array.  default_set points to a subset
1084 	 * of the data pointed to by color_set (defined in _XmGetColors).
1085 	 */
1086 
1087 	default_set[default_set_count] =
1088 		_XmGetColors(screen, color_map, background);
1089 	default_set_count++;
1090 
1091 	return (default_set[default_set_count - 1]);
1092 }
1093 
1094 
1095 
1096 static int
_XmBrightness(XColor * color)1097 _XmBrightness(
1098         XColor *color )
1099 {
1100 	int brightness;
1101 	int intensity;
1102 	int light;
1103 	int luminosity, maxprimary, minprimary;
1104 	int red = color->red;
1105 	int green = color->green;
1106 	int blue = color->blue;
1107 
1108 	intensity = (red + green + blue) / 3;
1109 
1110 	/*
1111 	 * The casting nonsense below is to try to control the point at
1112 	 * the truncation occurs.
1113 	 */
1114 
1115 	luminosity = (int) ((XmRED_LUMINOSITY * (float) red)
1116 		+ (XmGREEN_LUMINOSITY * (float) green)
1117 		+ (XmBLUE_LUMINOSITY * (float) blue));
1118 
1119 	maxprimary = ( (red > green) ?
1120 					( (red > blue) ? red : blue ) :
1121 					( (green > blue) ? green : blue ) );
1122 
1123 	minprimary = ( (red < green) ?
1124 					( (red < blue) ? red : blue ) :
1125 					( (green < blue) ? green : blue ) );
1126 
1127 	light = (minprimary + maxprimary) / 2;
1128 
1129 	brightness = ( (intensity * XmINTENSITY_FACTOR) +
1130 				   (light * XmLIGHT_FACTOR) +
1131 				   (luminosity * XmLUMINOSITY_FACTOR) ) / 100;
1132 	return(brightness);
1133 }
1134 
1135 /* This one still used by mwm: fix mwm */
1136 Pixel
_XmAccessColorData(XmColorData * cd,unsigned int which)1137 _XmAccessColorData(
1138         XmColorData *cd,
1139 #if NeedWidePrototypes
1140         unsigned int which )
1141 #else
1142         unsigned char which )
1143 #endif /* NeedWidePrototypes */
1144 {
1145     Pixel p;
1146 
1147     switch(which) {
1148     case XmBACKGROUND:
1149 	if (!(cd->allocated & which) &&
1150 	    (XAllocColor(cd->screen->display,
1151 			 cd->color_map, &(cd->background)) == 0)) {
1152 	    if (_XmBrightness(&(cd->background))
1153 		< XmFOREGROUND_THRESHOLD )
1154 		cd->background.pixel = _XmBlackPixel(cd->screen,
1155 						     cd->color_map,
1156 						     cd->background);
1157 	    else
1158 		cd->background.pixel = _XmWhitePixel(cd->screen,
1159 						     cd->color_map,
1160 						     cd->background);
1161 	    XQueryColor(cd->screen->display, cd->color_map,
1162 			&(cd->background));
1163 	}
1164 	p = cd->background.pixel;
1165 	cd->allocated |= which;
1166 	break;
1167     case XmFOREGROUND:
1168 	if (!(cd->allocated & which) &&
1169 	    (XAllocColor(cd->screen->display,
1170 			 cd->color_map, &(cd->foreground)) == 0 ))
1171 	    {
1172 		if (_XmBrightness(&(cd->background))
1173 		    < XmFOREGROUND_THRESHOLD )
1174 		    cd->foreground.pixel = _XmWhitePixel(cd->screen,
1175 							 cd->color_map,
1176 							 cd->foreground);
1177 		else
1178 		    cd->foreground.pixel = _XmBlackPixel(cd->screen,
1179 							 cd->color_map,
1180 							 cd->foreground);
1181 		XQueryColor(cd->screen->display, cd->color_map,
1182 			    &(cd->foreground));
1183 	    }
1184 	p =  cd->foreground.pixel;
1185 	cd->allocated |= which;
1186 	break;
1187     case XmTOP_SHADOW:
1188 	if (!(cd->allocated & which) &&
1189 	    (XAllocColor(cd->screen->display,
1190 			 cd->color_map, &(cd->top_shadow)) == 0))
1191 	    {
1192 		if (_XmBrightness(&(cd->background))
1193 		    > XmCOLOR_LITE_THRESHOLD)
1194 		    cd->top_shadow.pixel =
1195 			_XmBlackPixel(cd->screen, cd->color_map,
1196 				      cd->top_shadow);
1197 		else
1198 		    cd->top_shadow.pixel =
1199 			_XmWhitePixel(cd->screen, cd->color_map,
1200 				      cd->top_shadow);
1201 		XQueryColor(cd->screen->display, cd->color_map,
1202 			    &(cd->top_shadow));
1203 
1204 	    }
1205 	p = cd->top_shadow.pixel;
1206 	cd->allocated |= which;
1207 	break;
1208     case XmBOTTOM_SHADOW:
1209 	if (!(cd->allocated & which) &&
1210 	    (XAllocColor(cd->screen->display,
1211 			 cd->color_map, &(cd->bottom_shadow)) == 0))
1212 	    {
1213 		if (_XmBrightness(&(cd->background))
1214 		    < XmCOLOR_DARK_THRESHOLD)
1215 		    cd->bottom_shadow.pixel =
1216 			_XmWhitePixel(cd->screen, cd->color_map,
1217 				      cd->bottom_shadow);
1218 		else
1219 		    cd->bottom_shadow.pixel =
1220 			_XmBlackPixel(cd->screen, cd->color_map,
1221 				      cd->bottom_shadow);
1222 		XQueryColor(cd->screen->display, cd->color_map,
1223 			    &(cd->bottom_shadow));
1224 	    }
1225 	p = cd->bottom_shadow.pixel;
1226 	cd->allocated |= which;
1227 	break;
1228     case XmSELECT:
1229 	if (!(cd->allocated & which) &&
1230 	    (XAllocColor(cd->screen->display,
1231 			 cd->color_map, &(cd->select)) == 0))
1232 	    {
1233 		if (_XmBrightness(&(cd->background))
1234 		    < XmFOREGROUND_THRESHOLD)
1235 		    cd->select.pixel = _XmWhitePixel(cd->screen,
1236 						     cd->color_map,
1237 						     cd->select);
1238 		else
1239 		    cd->select.pixel = _XmBlackPixel(cd->screen,
1240 						     cd->color_map,
1241 						     cd->select);
1242 		XQueryColor(cd->screen->display, cd->color_map,
1243 			    &(cd->select));
1244 	    }
1245 	p = cd->select.pixel;
1246 	cd->allocated |= which;
1247 	break;
1248     default:
1249 	XtWarning(MESSAGE0);
1250 	p = _XmBlackPixel(cd->screen, cd->color_map, cd->background);
1251 	break;
1252     }
1253 
1254     return(p);
1255 }
1256 
1257 
1258 /* OBSOLETE: Replaced by _XmMapKeyEvents. */
1259 Boolean
_XmMapKeyEvent(register String str,int * eventType,unsigned int * keysym,unsigned int * modifiers)1260 _XmMapKeyEvent(
1261         register String str,
1262         int *eventType,
1263         unsigned int *keysym,
1264         unsigned int *modifiers )
1265 {
1266   int		count;
1267   int          *all_types;
1268   KeySym       *all_keys;
1269   unsigned int *all_mods;
1270 
1271   /* Initialize the return parameters. */
1272   *eventType = 0;
1273   *keysym = 0;
1274   *modifiers = 0;
1275 
1276   /* Convert the string to a list of keysyms. */
1277   count = _XmMapKeyEvents(str, &all_types, &all_keys, &all_mods);
1278 
1279   /* The old implementation ignored trailing garbage. */
1280   if (count > 0)
1281     {
1282       *eventType = *all_types;
1283       *keysym = *all_keys;
1284       *modifiers = *all_mods;
1285     }
1286 
1287   XtFree((char*) all_types);
1288   XtFree((char*) all_keys);
1289   XtFree((char*) all_mods);
1290 
1291   return (count > 0);
1292 }
1293 
1294 
XmRegisterConverters()1295 void XmRegisterConverters() { _XmRegisterConverters() ; }
1296 
1297 
1298 /************************************************************************
1299  *
1300  *  _XmGetImageAndHotSpotFromFile
1301  *	Given a filename, extract and create an image from the file data.
1302  *
1303  ************************************************************************/
1304 XImage *
_XmGetImageAndHotSpotFromFile(char * filename,int * hot_x,int * hot_y)1305 _XmGetImageAndHotSpotFromFile(
1306         char *filename,
1307 	int *hot_x,
1308 	int *hot_y)
1309 {
1310     return _XmReadImageAndHotSpotFromFile(_XmGetDefaultDisplay(),
1311 					filename, hot_x, hot_y) ;
1312 
1313 }
1314 
1315 
1316 /************************************************************************
1317  *
1318  *  _XmGetImageFromFile
1319  *	Given a filename, extract and create an image from the file data.
1320  *
1321  ************************************************************************/
1322 
1323 XImage *
_XmGetImageFromFile(char * filename)1324 _XmGetImageFromFile(
1325         char *filename )
1326 {
1327    int hot_x, hot_y;
1328    return _XmReadImageAndHotSpotFromFile(_XmGetDefaultDisplay(),
1329 					filename, &hot_x, &hot_y) ;
1330 }
1331 
1332 Boolean
_XmFocusIsInShell(Widget wid)1333 _XmFocusIsInShell(
1334         Widget wid)
1335 {
1336   /* CR 7568: Actually return the value. */
1337   return XmeFocusIsInShell(wid);
1338 }
1339 
1340 
1341 void
_XmSleep(unsigned int secs)1342 _XmSleep(
1343         unsigned int secs)
1344 {
1345   sleep( secs) ;
1346 }
1347 
1348 int
_XmOSPutenv(char * string)1349 _XmOSPutenv(
1350     char *string)
1351 {
1352 #ifndef NO_PUTENV
1353   return (putenv(string));
1354 
1355 #else
1356   char *value;
1357 
1358   if ((value = strchr(string, '=')) != NULL)
1359     {
1360       char *name  = XtNewString(string);
1361       int result;
1362 
1363       name[value-string] = '\0';
1364 
1365       result = setenv(name, value+1, 1);
1366       XtFree(name);
1367       return result;
1368     }
1369   else
1370     return -1;
1371 #endif
1372 }
1373 
1374 /* after rework of inheritance of class extension method */
1375 externaldef(xmprimbaseclassextrec) XmBaseClassExtRec
1376      _XmPrimbaseClassExtRec = { 0 };
1377 externaldef(xmprimclassextrec) XmPrimitiveClassExtRec
1378      _XmPrimClassExtRec = { 0 };
1379 externaldef(xmdrawnbprimclassextrec) XmPrimitiveClassExtRec
1380      _XmDrawnBPrimClassExtRec = { 0 };
1381 externaldef(xmtogglebprimclassextrec) XmPrimitiveClassExtRec
1382      _XmToggleBPrimClassExtRec = { 0 };
1383 externaldef(xmpushbprimclassextrec) XmPrimitiveClassExtRec
1384      _XmPushBPrimClassExtRec = { 0 };
1385 externaldef(xmcascadebprimclassextrec) XmPrimitiveClassExtRec
1386      _XmCascadeBPrimClassExtRec = { 0 };
1387 externaldef(xmtearoffbprimclassextrec) XmPrimitiveClassExtRec
1388      _XmTearOffBPrimClassExtRec = { 0 };
1389 
1390 
1391 
1392 
1393 /* From old Visual.c */
1394 
1395 void
_XmPrimitiveTopShadowPixmapDefault(Widget widget,int offset,XrmValue * value)1396 _XmPrimitiveTopShadowPixmapDefault(
1397         Widget widget,
1398         int offset,
1399         XrmValue *value )
1400 {
1401     _XmTopShadowPixmapDefault(widget, offset, value );
1402 }
1403 
1404 void
_XmManagerTopShadowPixmapDefault(Widget widget,int offset,XrmValue * value)1405 _XmManagerTopShadowPixmapDefault(
1406         Widget widget,
1407         int offset,
1408         XrmValue *value )
1409 {
1410     _XmTopShadowPixmapDefault(widget, offset, value );
1411 }
1412 
1413 void
_XmPrimitiveHighlightPixmapDefault(Widget widget,int offset,XrmValue * value)1414 _XmPrimitiveHighlightPixmapDefault(
1415         Widget widget,
1416         int offset,
1417         XrmValue *value )
1418 {
1419     _XmHighlightPixmapDefault(widget, offset, value );
1420 }
1421 
1422 void
_XmManagerHighlightPixmapDefault(Widget widget,int offset,XrmValue * value)1423 _XmManagerHighlightPixmapDefault(
1424         Widget widget,
1425         int offset,
1426         XrmValue *value )
1427 {
1428     _XmHighlightPixmapDefault(widget, offset, value );
1429 }
1430 
1431 
1432 
1433 /************************************************************************
1434  *
1435  *  _XmFilterResources
1436  *
1437  ************************************************************************/
1438 Cardinal
_XmFilterResources(XtResource * resources,Cardinal numResources,WidgetClass filterClass,XtResource ** filteredResourcesRtn)1439 _XmFilterResources(
1440         XtResource *resources,
1441         Cardinal numResources,
1442         WidgetClass filterClass,
1443         XtResource **filteredResourcesRtn )
1444 {
1445     XtResource		*filteredResources;
1446     Cardinal		copyIndexes[256];
1447     Cardinal		filterOffset;
1448     Cardinal		i, j;
1449 
1450     filterOffset = filterClass->core_class.widget_size;
1451 
1452     for (i = 0, j = 0; i < numResources; i++)
1453       {
1454 	  if (resources[i].resource_offset >= filterOffset)
1455 	    {
1456 		copyIndexes[j++] = i;
1457 	    }
1458       }
1459 
1460     filteredResources = (XtResource *) XtMalloc(j * sizeof(XtResource));
1461 
1462     for (i = 0; i < j; i++)
1463       {
1464 	  filteredResources[i] = resources[copyIndexes[i]];
1465       }
1466     *filteredResourcesRtn = filteredResources;
1467     return j;
1468 }
1469 
1470 
1471 
1472 /************************************************************************
1473  *
1474  *  _XmRootGeometryManager
1475  *
1476  ************************************************************************/
1477 /*ARGSUSED*/
1478 XtGeometryResult
_XmRootGeometryManager(Widget w,XtWidgetGeometry * request,XtWidgetGeometry * reply)1479 _XmRootGeometryManager(
1480 	 Widget w,
1481 	 XtWidgetGeometry *request,
1482 	 XtWidgetGeometry *reply )
1483 {
1484     XmWidgetExtData	extData = _XmGetWidgetExtData(w, XmSHELL_EXTENSION);
1485     XmShellExtObject	se = (XmShellExtObject)extData->widget;
1486     XtGeometryHandler	wmGeoHandler;
1487     ShellWidgetClass	swc = (ShellWidgetClass)wmShellWidgetClass;
1488     ShellClassExtensionRec **scExtPtr;
1489     XtGeometryResult	returnVal = XtGeometryNo;
1490     WMShellWidget	wmShell = (WMShellWidget)w;
1491 
1492     if(extData == NULL)
1493     {
1494 #ifdef DEBUG
1495         XmeWarning(NULL, "_XmGetWidgetExtData() returned NULL pointer.");
1496 #endif
1497         return XtGeometryNo;
1498     }
1499 
1500     if (se)
1501       {
1502 	   se->shell.lastConfigureRequest = NextRequest(XtDisplay(w));
1503       }
1504 #ifdef DEBUG
1505     else
1506       XtError("no extension object");
1507 #endif /* DEBUG */
1508 
1509     scExtPtr = (ShellClassExtensionRec **)
1510       _XmGetClassExtensionPtr( (XmGenericClassExt *) &(swc->shell_class.extension),
1511 			       NULLQUARK);
1512     if (request->request_mode & XtCWQueryOnly)
1513       {
1514 	   if (!(wmShell->shell.allow_shell_resize) &&
1515 	       (request->request_mode &
1516 		(CWWidth | CWHeight | CWBorderWidth)))
1517 	     return XtGeometryNo;
1518 	   /*
1519 	    * we should switch on useAsyncGeometry but we won't |||
1520 	    */
1521 	   else
1522 	     return XtGeometryYes;
1523       }
1524 
1525     if (se->shell.useAsyncGeometry)
1526       {
1527 	   /* make wait_for_wm = FALSE to force desired behaviour */
1528 	   wmShell->wm.wait_for_wm = FALSE;
1529 	   /* FIX for 1684: remove the timeout = 0 line, not
1530 	      needed and introduced a bug if not saved/restore together
1531 	      with useAsync change - wait_for_wm will be later reset
1532 	      by Shell in Xt */
1533       }
1534     if ((wmGeoHandler = (*scExtPtr)->root_geometry_manager) != NULL)
1535       {
1536 	   returnVal =  (*wmGeoHandler)(w, request, reply);
1537 	   if (se->shell.useAsyncGeometry) {
1538 	       /* X configure was sent to the server, while this is happening,
1539 		  let's everybody think it's a success (which is true
1540 		  most of the time): set the shell size to what it wants
1541 		  to be and return Yes */
1542 	       if (request->request_mode & CWWidth)
1543 		   w->core.width = request->width;
1544 	       if (request->request_mode & CWHeight)
1545 		   w->core.height = request->height ;
1546 	       if (request->request_mode & CWBorderWidth)
1547 		   w->core.border_width = request->border_width ;
1548 	       if (request->request_mode & CWX)
1549 		   w->core.x = request->x;
1550 	       if (request->request_mode & CWY)
1551 		   w->core.y = request->y;
1552 
1553 	       returnVal = XtGeometryYes;
1554 	   }
1555       }
1556     return returnVal;
1557 }
1558 
1559 
1560 /*ARGSUSED*/
1561 void
_XmVendorExtRealize(Widget w,XtPointer closure,XtPointer call_data)1562 _XmVendorExtRealize(
1563 	 Widget w,
1564 	 XtPointer closure,	/* unused */
1565 	 XtPointer call_data )	/* unused */
1566 {
1567     XtWarning("Don't use _XmVendorExtRealize! It does nothing.");
1568 }
1569 
1570 
1571 
1572 /**********************
1573   Stuff from Desktop.c
1574 **********************/
1575 
1576 static XContext	actualClassContext = (XContext) NULL;
1577 
1578 
1579 /*ARGSUSED*/
1580 static void
DisplayDestroyCallback(Widget w,XtPointer client_data,XtPointer call_data)1581 DisplayDestroyCallback
1582 	( Widget w,
1583         XtPointer client_data,
1584         XtPointer call_data )	/* unused */
1585 {
1586     XDeleteContext(XtDisplay(w), (XID) client_data, actualClassContext);
1587 }
1588 
1589 
1590 /************************************************************************
1591  *
1592  *  _XmGetActualClass
1593  *
1594  ************************************************************************/
1595 /* ARGSUSED */
1596 WidgetClass
_XmGetActualClass(Display * display,WidgetClass w_class)1597 _XmGetActualClass(
1598 	Display     *display,
1599         WidgetClass w_class )
1600 {
1601 	  WidgetClass		actualClass;
1602 
1603 	  if (actualClassContext == (XContext) NULL)
1604 	    actualClassContext = XUniqueContext();
1605 
1606 	  /*
1607 	   * see if a non-default class has been specified for the
1608 	   * class
1609 	   */
1610 	  if (XFindContext(display,
1611 			   (Window) w_class,
1612 			   actualClassContext,
1613 			   (char **) &actualClass))
1614 	    {
1615 		return w_class;
1616 	    }
1617 	  else
1618 	    return actualClass;
1619 }
1620 
1621 /************************************************************************
1622  *
1623  *  _XmSetActualClass
1624  *
1625  ************************************************************************/
1626 /* ARGSUSED */
1627 void
_XmSetActualClass(Display * display,WidgetClass w_class,WidgetClass actualClass)1628 _XmSetActualClass(
1629 	Display     *display,
1630         WidgetClass w_class,
1631         WidgetClass actualClass )
1632 {
1633     XmDisplay   dd = (XmDisplay) XmGetXmDisplay(display);
1634     WidgetClass previous;
1635     WidgetClass oldActualClass;
1636 
1637     if (actualClassContext == (XContext) NULL)
1638       actualClassContext = XUniqueContext();
1639 
1640     /*
1641      * see if a non-default class has been specified for the
1642      * class
1643      */
1644     previous = _XmGetActualClass(display, w_class);
1645     XtRemoveCallback((Widget)dd, XtNdestroyCallback,
1646 			DisplayDestroyCallback, (XtPointer) previous);
1647 
1648 
1649     /*
1650      * Save class data.
1651      * Delete old context if one exists.
1652      */
1653     if (XFindContext (display, (Window) w_class, actualClassContext,
1654 			(char **)&oldActualClass)) {
1655 	XSaveContext(display, (Window) w_class, actualClassContext,
1656 			(char *) actualClass);
1657     }
1658     else if (oldActualClass != actualClass) {
1659 	XDeleteContext (display, (Window) w_class, actualClassContext);
1660 	XSaveContext(display, (Window) w_class, actualClassContext,
1661 			(char *) actualClass);
1662 
1663     }
1664 
1665     XtAddCallback((Widget)dd, XtNdestroyCallback,
1666 			DisplayDestroyCallback, (XtPointer) w_class);
1667 }
1668 
1669 
1670 
1671 /************************************************************************
1672  *
1673  *  _XmGetWorldObject
1674  *
1675  ************************************************************************/
1676 /* ARGSUSED */
1677 XmDesktopObject
_XmGetWorldObject(Widget shell,ArgList args,Cardinal * num_args)1678 _XmGetWorldObject(
1679         Widget shell,
1680         ArgList args,
1681         Cardinal *num_args )
1682 {
1683     XmDesktopObject	worldObject;
1684     static XContext	worldObjectContext = (XContext) NULL;
1685     XmWidgetExtData     ext;
1686     Display		*display;
1687 
1688     /*
1689     ** Note: in an ideal World we would be sure to delete this context when
1690     ** the display is closed, so that we don't get bad data if a second
1691     ** display with the same id is opened.
1692     */
1693     if (worldObjectContext == (XContext) NULL)
1694       worldObjectContext = XUniqueContext();
1695 
1696     display = XtDisplayOfObject(shell);
1697 
1698     if (XFindContext(display,
1699 		     (Window) NULL,
1700 		     worldObjectContext,
1701 		     (char **) &worldObject))
1702       {
1703 	  WidgetClass		worldClass;
1704 	  Widget		appShell = shell;
1705 
1706 	  worldClass = _XmGetActualClass(display, xmDesktopClass);
1707 
1708 	  while (XtParent(appShell))
1709 	    appShell = XtParent(appShell);
1710 
1711 	  worldObject = (XmDesktopObject)
1712 	    XtCreateWidget("world",
1713 			   worldClass,
1714 			   appShell,
1715 			   args,
1716 			   num_args ? *num_args: 0);
1717 
1718           ext = _XmGetWidgetExtData(worldObject->ext.logicalParent,
1719                                     worldObject->ext.extensionType);
1720 
1721           if(ext != NULL)
1722           {
1723             _XmExtObjFree((XtPointer) ext->reqWidget);
1724             ext->reqWidget = NULL;
1725           }
1726 #ifdef DEBUG
1727           else
1728           {
1729             XmeWarning(NULL, "_XmGetWidgetExtData() returned NULL pointer.");
1730           }
1731 #endif
1732 
1733 	  XSaveContext(display,
1734 		       (Window) NULL,
1735 		       worldObjectContext,
1736 		       (char *) worldObject);
1737       }
1738     return
1739       worldObject;
1740 }
1741 
1742 /************************************************************************
1743  *
1744  *  _XmVirtKeysHandler
1745  *
1746  ************************************************************************/
1747 
1748 /*ARGSUSED*/
1749 void
_XmVirtKeysHandler(Widget widget,XtPointer client_data,XEvent * event,Boolean * dontSwallow)1750 _XmVirtKeysHandler(Widget    widget,
1751 		   XtPointer client_data,
1752 		   XEvent   *event,
1753 		   Boolean  *dontSwallow )
1754 {
1755   if (widget->core.being_destroyed)
1756     {
1757       *dontSwallow = False;
1758       return;
1759     }
1760 }
1761 
1762 
1763 
1764 /****************************************************************
1765  *
1766  *  TextOut.c functions
1767  *
1768  ****************************************************************/
1769 
1770 /* ARGSUSED */
1771 void
_XmTextDrawDestination(XmTextWidget tw)1772 _XmTextDrawDestination(XmTextWidget tw)
1773 {
1774   /* DEPRECATED */
1775 }
1776 
1777 /* ARGSUSED */
1778 void
_XmTextClearDestination(XmTextWidget tw,int ignore_sens)1779 _XmTextClearDestination(XmTextWidget tw,
1780 #if NeedWidePrototypes
1781         int ignore_sens)
1782 #else
1783         Boolean ignore_sens)
1784 #endif /* NeedWidePrototypes */
1785 {
1786   /* DEPRECATED */
1787 }
1788 
1789 /* ARGSUSED */
1790 void
_XmTextDestinationVisible(Widget w,int turn_on)1791 _XmTextDestinationVisible(Widget w,
1792 #if NeedWidePrototypes
1793         int turn_on)
1794 #else
1795         Boolean turn_on)
1796 #endif /* NeedWidePrototypes */
1797 {
1798   /* DEPRECATED */
1799 }
1800 
1801 
1802 /****************************************************************
1803  *
1804  *  TextStrSo.c functions
1805  *
1806  ****************************************************************/
1807 
1808 Boolean
_XmStringSourceFindString(Widget w,XmTextPosition start,char * string,XmTextPosition * position)1809 _XmStringSourceFindString(Widget w,
1810 			  XmTextPosition start,
1811 			  char* string,
1812 			  XmTextPosition *position)
1813 {
1814   return(XmTextFindString(w, start, string, XmTEXT_FORWARD, position));
1815 }
1816 
1817 /****************************************************************
1818  *
1819  *  TextIn.c functions
1820  *
1821  ****************************************************************/
1822 
1823 XmTextPosition
_XmTextGetAnchor(XmTextWidget tw)1824 _XmTextGetAnchor(XmTextWidget tw)
1825 {
1826   InputData data = tw->text.input->data;
1827 
1828   return(data->anchor);
1829 }
1830 
1831 /****************************************************************
1832  *
1833  *  Traversal.c functions
1834  *
1835  ****************************************************************/
1836 
1837 /*ARGSUSED*/
1838 Boolean
_XmGrabTheFocus(Widget w,XEvent * event)1839 _XmGrabTheFocus(
1840         Widget w,
1841         XEvent *event )		/* unused */
1842 {
1843   /* Function used by TextEdit widgets to grab the focus.
1844    */
1845   return _XmMgrTraversal( w, XmTRAVERSE_CURRENT) ;
1846 }
1847 
1848 
1849 /*ARGSUSED*/
1850 void
_XmProcessTraversal(Widget w,XmTraversalDirection dir,int check)1851 _XmProcessTraversal(
1852         Widget w,
1853         XmTraversalDirection dir,
1854 #if NeedWidePrototypes
1855         int check )		/* unused */
1856 #else
1857         Boolean check )		/* unused */
1858 #endif /* NeedWidePrototypes */
1859 {
1860   _XmMgrTraversal( w, dir ) ;
1861 }
1862 
1863 
1864 Widget
_XmFindNextTabGroup(Widget wid)1865 _XmFindNextTabGroup(
1866         Widget wid )
1867 {
1868   return _XmNavigate( wid, XmTRAVERSE_NEXT_TAB_GROUP) ;
1869 }
1870 
1871 
1872 Widget
_XmFindPrevTabGroup(Widget wid)1873 _XmFindPrevTabGroup(
1874         Widget wid )
1875 {
1876   return _XmNavigate( wid, XmTRAVERSE_PREV_TAB_GROUP) ;
1877 }
1878 
1879 
1880 Boolean
_XmCreateVisibilityRect(Widget w,XRectangle * rectPtr)1881 _XmCreateVisibilityRect(Widget w,
1882 			XRectangle *rectPtr)
1883 {
1884   return _XmComputeVisibilityRect(w, rectPtr, FALSE, TRUE);
1885 }
1886 
1887 /****************************************************************
1888  *
1889  *  MenuShell.c functions
1890  *
1891  ****************************************************************/
1892 void
_XmSetLastManagedMenuTime(Widget wid,Time newTime)1893 _XmSetLastManagedMenuTime (
1894 	Widget wid,
1895 	Time newTime )
1896 {
1897    _XmGetMenuState((Widget)wid)->MS_LastManagedMenuTime = newTime;
1898 }
1899 
1900 
1901 /****************************************************************
1902  *
1903  *  XmString.c functions
1904  *
1905  ****************************************************************/
1906 
1907 /*
1908  * count the number of lines in an _XmString.
1909  */
1910 int
_XmStringLineCount(_XmString string)1911 _XmStringLineCount(
1912         _XmString string )
1913 {
1914   return(XmStringLineCount(string));
1915 }
1916 
1917 /* Used to create internal XmString, now just copies. */
1918 _XmString
_XmStringCreate(XmString cs)1919 _XmStringCreate(
1920         XmString cs )
1921 {
1922   return((_XmString)XmStringCopy(cs));
1923 }
1924 
1925 /* Used to create external XmString from internal, now just copies. */
1926 /*ARGSUSED*/
1927 XmString
_XmStringCreateExternal(XmRenderTable rendertable,_XmString cs)1928 _XmStringCreateExternal(
1929         XmRenderTable rendertable, /* unused */
1930         _XmString cs )
1931 {
1932   return(XmStringCopy((XmString)cs));
1933 }
1934 
1935 Boolean
_XmStringEmpty(_XmString string)1936 _XmStringEmpty(
1937         _XmString string )
1938 {
1939   return(XmStringEmpty(string));
1940 }
1941 
1942 void
_XmStringFree(_XmString string)1943 _XmStringFree(
1944         _XmString string )
1945 {
1946   XmStringFree(string);
1947 }
1948 
1949 /*
1950  * find total height of XmString
1951  */
1952 Dimension
_XmStringHeight(XmRenderTable rendertable,_XmString string)1953 _XmStringHeight(
1954         XmRenderTable rendertable,
1955         _XmString string )
1956 {
1957   if (!string || !rendertable) return (0);
1958 
1959   return(XmStringHeight(rendertable, string));
1960 }
1961 
1962 /*
1963  * find the rectangle which will enclose the text
1964  */
1965 void
_XmStringExtent(XmRenderTable rendertable,_XmString string,Dimension * width,Dimension * height)1966 _XmStringExtent(
1967         XmRenderTable rendertable,
1968         _XmString string,
1969         Dimension *width,
1970         Dimension *height )
1971 {
1972   if (!string || !rendertable)
1973     {
1974       *width = 0;
1975       *height = 0;
1976       return;
1977     }
1978 
1979   XmStringExtent(rendertable, string, width, height);
1980 }
1981 
1982 
1983 /*
1984  * find width of widest line in XmString
1985  */
1986 Dimension
_XmStringWidth(XmRenderTable rendertable,_XmString string)1987 _XmStringWidth(
1988         XmRenderTable rendertable,
1989         _XmString string )
1990 {
1991   if (!string || !rendertable) return (0);
1992 
1993   return(XmStringWidth(rendertable, string));
1994 }
1995 
1996 void
_XmStringDraw(Display * d,Window w,XmRenderTable rendertable,_XmString string,GC gc,int x,int y,int width,unsigned int align,unsigned int lay_dir,XRectangle * clip)1997 _XmStringDraw(
1998         Display *d,
1999         Window w,
2000         XmRenderTable rendertable,
2001         _XmString string,
2002         GC gc,
2003 #if NeedWidePrototypes
2004         int x,
2005         int y,
2006         int width,
2007         unsigned int align,
2008         unsigned int lay_dir,
2009 #else
2010         Position x,
2011         Position y,
2012         Dimension width,
2013         unsigned char align,
2014         unsigned char lay_dir,
2015 #endif /* NeedWidePrototypes */
2016         XRectangle *clip )
2017 {
2018     XmStringDraw(d, w, rendertable, string, gc, x, y, width,
2019 		 align, lay_dir, clip);
2020 }
2021 
2022 void
_XmStringDrawImage(Display * d,Window w,XmRenderTable rendertable,_XmString string,GC gc,int x,int y,int width,unsigned int align,unsigned int lay_dir,XRectangle * clip)2023 _XmStringDrawImage(
2024         Display *d,
2025         Window w,
2026         XmRenderTable rendertable,
2027         _XmString string,
2028         GC gc,
2029 #if NeedWidePrototypes
2030         int x,
2031         int y,
2032         int width,
2033         unsigned int align,
2034         unsigned int lay_dir,
2035 #else
2036         Position x,
2037         Position y,
2038         Dimension width,
2039         unsigned char align,
2040         unsigned char lay_dir,
2041 #endif /* NeedWidePrototypes */
2042         XRectangle *clip )
2043 {
2044     XmStringDrawImage(d, w, rendertable, string, gc, x, y, width,
2045 		      align, lay_dir, clip);
2046 }
2047 
2048 void
_XmStringDrawUnderline(Display * d,Window w,XmRenderTable f,_XmString s,GC gc,int x,int y,int width,unsigned int align,unsigned int lay_dir,XRectangle * clip,_XmString u)2049 _XmStringDrawUnderline(
2050         Display *d,
2051         Window w,
2052         XmRenderTable f,
2053         _XmString s,
2054         GC gc,
2055 #if NeedWidePrototypes
2056         int x,
2057         int y,
2058         int width,
2059         unsigned int align,
2060         unsigned int lay_dir,
2061 #else
2062         Position x,
2063         Position y,
2064         Dimension width,
2065         unsigned char align,
2066         unsigned char lay_dir,
2067 #endif /* NeedWidePrototypes */
2068         XRectangle *clip,
2069         _XmString u )
2070 {
2071     XmStringDrawUnderline(d, w, f, s, gc, x, y, width,
2072 			  align, lay_dir, clip, u);
2073 }
2074 
2075 void
_XmStringDrawMnemonic(Display * d,Window w,XmRenderTable rendertable,_XmString string,GC gc,int x,int y,int width,unsigned int align,unsigned int lay_dir,XRectangle * clip,String mnemonic,XmStringTag tag)2076 _XmStringDrawMnemonic(
2077         Display *d,
2078         Window w,
2079         XmRenderTable rendertable,
2080         _XmString string,
2081         GC gc,
2082 #if NeedWidePrototypes
2083         int x,
2084         int y,
2085         int width,
2086         unsigned int align,
2087         unsigned int lay_dir,
2088 #else
2089         Position x,
2090         Position y,
2091         Dimension width,
2092         unsigned char align,
2093         unsigned char lay_dir,
2094 #endif /* NeedWidePrototypes */
2095         XRectangle *clip,
2096         String mnemonic,
2097         XmStringTag tag )
2098 {
2099     XmString underline;
2100 
2101     underline = XmStringCreate(mnemonic, tag);
2102 
2103     XmStringDrawUnderline(d, w, rendertable, string, gc, x, y, width,
2104 			  align, lay_dir, clip, underline);
2105     XmStringFree(underline);
2106 }
2107 
2108 /*
2109  * internal structure access routines
2110  */
2111 Boolean
_XmStringInitContext(_XmStringContext * context,_XmString string)2112 _XmStringInitContext(
2113         _XmStringContext *context,
2114         _XmString string )
2115 {
2116   return(XmStringInitContext(context, string));
2117 }
2118 
2119 void
_XmStringFreeContext(_XmStringContext context)2120 _XmStringFreeContext(
2121         _XmStringContext context )
2122 {
2123   XmStringFreeContext(context);
2124 }
2125 
2126 _XmString
_XmStringCopy(_XmString string)2127 _XmStringCopy( _XmString string )
2128 {
2129   if (string == (_XmString) NULL) return ((_XmString) NULL);
2130   else return((_XmString)XmStringCopy(string));
2131 }
2132 
2133 /*
2134  * check these two internals
2135  */
2136 Boolean
_XmStringByteCompare(_XmString a,_XmString b)2137 _XmStringByteCompare(
2138         _XmString a,
2139         _XmString b )
2140 {
2141   if (!a && !b) return(TRUE);
2142   if (!a || !b) return(FALSE);
2143 
2144   return(XmStringByteCompare(a, b));
2145 }
2146 
2147 Dimension
_XmStringBaseline(XmRenderTable rendertable,_XmString string)2148 _XmStringBaseline(
2149         XmRenderTable rendertable,
2150         _XmString string )
2151 {
2152   if (!string || !rendertable) return (0);
2153 
2154   return(XmStringBaseline(rendertable, string));
2155 }
2156 
2157 Boolean
_XmStringHasSubstring(_XmString string,_XmString substring)2158 _XmStringHasSubstring(
2159         _XmString string,
2160         _XmString substring )
2161 {
2162   if ((string == NULL) || (substring == NULL) || (XmStringEmpty(substring)))
2163     return (FALSE);
2164 
2165   return(XmStringHasSubstring(string, substring));
2166 }
2167 
2168 
2169 
2170 
2171 /* Replaced by XmTextGetInsertionPosition */
2172 
2173 XmTextPosition
XmTextGetCursorPosition(Widget widget)2174 XmTextGetCursorPosition(Widget widget)
2175 {
2176   if (XmIsTextField(widget))
2177     return(XmTextFieldGetCursorPosition(widget));
2178   else {
2179     return(XmTextGetInsertionPosition(widget));
2180   }
2181 }
2182 
2183 
2184 /* Replaced by XmTextSetInsertionPosition */
2185 
2186 void
XmTextSetCursorPosition(Widget widget,XmTextPosition position)2187 XmTextSetCursorPosition(Widget widget,
2188 			XmTextPosition position)
2189 {
2190   if (XmIsTextField(widget))
2191     XmTextFieldSetCursorPosition(widget, position);
2192   else {
2193     XmTextSetInsertionPosition(widget, position);
2194   }
2195 }
2196 
2197 /* Replaced by XmTextFieldSetInsertionPosition */
2198 
2199 void
XmTextFieldSetCursorPosition(Widget w,XmTextPosition position)2200 XmTextFieldSetCursorPosition(Widget w,
2201 			     XmTextPosition position)
2202 {
2203   XmTextFieldSetInsertionPosition(w, position);
2204 }
2205 
2206 /* Replaced by XmTextFieldGetInsertionPosition */
2207 
2208 XmTextPosition
XmTextFieldGetCursorPosition(Widget w)2209 XmTextFieldGetCursorPosition(Widget w)
2210 {
2211   return XmTextFieldGetInsertionPosition(w);
2212 }
2213 
2214 
2215 /****************************************************************
2216  *
2217  *  TravAct.c functions
2218  *
2219  ****************************************************************/
2220 
2221 
2222 /*
2223  * Get the state of the 'ResettingFocus' flag, based upon the
2224  * display to which the widget is tied.
2225  */
2226 Boolean
_XmGetFocusResetFlag(Widget w)2227 _XmGetFocusResetFlag(
2228         Widget w )
2229 {
2230    return( (Boolean) _XmGetFocusFlag(w, XmFOCUS_RESET) );
2231 }
2232 
2233 
2234 /*
2235  * Set the state of the 'ResettingFocus' flag.
2236  */
2237 void
_XmSetFocusResetFlag(Widget w,int value)2238 _XmSetFocusResetFlag(
2239         Widget w,
2240 #if NeedWidePrototypes
2241         int value )
2242 #else
2243         Boolean value )
2244 #endif /* NeedWidePrototypes */
2245 {
2246    _XmSetFocusFlag(w, XmFOCUS_RESET, value);
2247 }
2248 
2249 /********************************************************************/
2250 
2251 /*ARGSUSED*/
2252 void
_XmStringUpdate(XmFontList fontlist,_XmString string)2253 _XmStringUpdate(XmFontList fontlist, /* unused */
2254 		_XmString string ) /* unused */
2255 {
2256   /*EMPTY*/
2257 }
2258 
2259 
2260 
2261 /* From BaseClass.c */
2262 
2263 /*ARGSUSED*/
2264 void
_XmFreeWidgetExtData(Widget widget)2265 _XmFreeWidgetExtData(
2266         Widget widget )		/* unused */
2267 {
2268   /*EMPTY*/
2269 }
2270 
2271 
2272 /*ARGSUSED*/
2273 void
_XmBaseClassPartInitialize(WidgetClass wc)2274 _XmBaseClassPartInitialize(
2275         WidgetClass wc )	/* unused */
2276 {
2277   /*EMPTY*/
2278 }
2279 
2280 
2281 Boolean
_XmIsSlowSubclass(WidgetClass wc,unsigned int bit)2282 _XmIsSlowSubclass(
2283         WidgetClass wc,
2284         unsigned int bit )
2285 {
2286   XmBaseClassExt *wcePtr = _XmGetBaseClassExtPtr(wc, XmQmotif);
2287 
2288   if (!wcePtr || !(*wcePtr))
2289     return False;
2290 
2291   if ((_XmGetFlagsBit((*wcePtr)->flags, bit)) != 0)
2292     return True;
2293   else
2294     return False;
2295 }
2296 
2297 
2298 Boolean
_XmIsStandardMotifWidgetClass(WidgetClass wc)2299 _XmIsStandardMotifWidgetClass(
2300         WidgetClass wc)
2301 {
2302   /* This routine depends on ALL standard Motif classes use fast subclassing. */
2303   XmBaseClassExt * fastPtr;
2304   XmBaseClassExt * superFastPtr;
2305   WidgetClass super_wc = wc->core_class.superclass;
2306 
2307   if ((fastPtr = _XmGetBaseClassExtPtr( wc, XmQmotif)) && *fastPtr)
2308     {
2309       if (!(superFastPtr = _XmGetBaseClassExtPtr( super_wc, XmQmotif)))
2310         {
2311           /* This catches all Motif classes which are direct subclasses
2312            * of an Xt Intrinsics widget class.
2313            */
2314           return TRUE;
2315         }
2316       if (*superFastPtr)
2317         {
2318           unsigned char * flags = (*fastPtr)->flags;
2319           unsigned char * superFlags = (*superFastPtr)->flags;
2320           unsigned numBytes = (XmLAST_FAST_SUBCLASS_BIT >> 3) + 1;
2321           unsigned Index;
2322 
2323           Index = numBytes;
2324           while (Index--)
2325             {
2326               if (flags[Index] != superFlags[Index])
2327                 {
2328                   /* Since all Motif classes use fast subclassing, the fast
2329                    * subclassing bits of any standard Motif class will be
2330                    * different than those of its superclass (the superclass
2331                    * will have one less bit set).  Any non-standard Motif
2332                    * subclass will have the same fast subclass bits as its
2333                    * superclass.
2334                    */
2335                   return TRUE;
2336                 }
2337             }
2338         }
2339     }
2340   return FALSE;
2341 }
2342 
2343 
2344 
2345 /** Obsolete from ImageCache.c */
2346 
2347 Pixmap
_XmGetPixmap(Screen * screen,char * image_name,int depth,Pixel foreground,Pixel background)2348 _XmGetPixmap(
2349     Screen *screen,
2350     char *image_name,
2351     int depth,
2352     Pixel foreground,
2353     Pixel background)
2354 {
2355     return(XmGetPixmapByDepth(screen, image_name,
2356 			      foreground, background, depth));
2357 }
2358 
2359 
2360 Boolean
_XmInstallPixmap(Pixmap pixmap,Screen * screen,char * image_name,Pixel foreground,Pixel background)2361 _XmInstallPixmap(
2362         Pixmap pixmap,
2363         Screen *screen,
2364         char *image_name,
2365         Pixel foreground,
2366         Pixel background )
2367 {
2368   return _XmCachePixmap(pixmap, screen, image_name,
2369 			foreground, background, 0, 0, 0);
2370 }
2371 
2372 
2373 
2374 
2375