1 /* $XConsortium: Obso1_2.c /main/7 1996/06/14 23:10:17 pascale $ */
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 #ifdef HAVE_CONFIG_H
30 #include <config.h>
31 #endif
32 
33 
34 #include <ctype.h>
35 #ifndef X_NOT_STDC_ENV
36 #include <stdlib.h>
37 #endif
38 #include <Xm/XmP.h>
39 #include <Xm/BaseClassP.h>
40 #include <Xm/DesktopP.h>
41 #include <Xm/DisplayP.h>
42 #include <Xm/DrawingAP.h>
43 #include <Xm/FileSBP.h>
44 #include <Xm/GadgetP.h>
45 #include <Xm/List.h>
46 #include <Xm/ManagerP.h>
47 #include <Xm/MenuShellP.h>
48 #include <Xm/PrimitiveP.h>
49 #include <Xm/PushBGP.h>
50 #include <Xm/PushBP.h>
51 #include <Xm/RowColumnP.h>
52 #include <Xm/ScaleP.h>
53 #include <Xm/ScreenP.h>
54 #include <Xm/ScrolledWP.h>
55 #include <Xm/Text.h>
56 #include <Xm/TextF.h>
57 #include <Xm/TransltnsP.h>
58 #include <Xm/VendorSEP.h>
59 #include "BulletinBI.h"
60 #include "MessagesI.h"
61 #include "SelectioBI.h"
62 #include "SyntheticI.h"
63 #include "TraversalI.h"
64 #include "XmStringI.h"		/* for _XmStringGetTextConcat() */
65 
66 
67 typedef struct {
68     int		segment_size;
69     char*	start;
70     char*	current;
71     int		bytes_remaining;
72 } XmHeapRec, *XmHeap;
73 
74 
75 /********    Static Function Declarations    ********/
76 
77 
78 /********    End Static Function Declarations    ********/
79 
80 
81 externaldef(desktopobjectclass) WidgetClass
82       xmDesktopObjectClass = (WidgetClass) &xmDesktopClassRec;
83 
84 externaldef(displayobjectclass) WidgetClass
85       xmDisplayObjectClass = (WidgetClass) (&xmDisplayClassRec);
86 
87 externaldef(screenobjectclass) WidgetClass
88       xmScreenObjectClass = (WidgetClass) (&xmScreenClassRec);
89 
90 externaldef(worldobjectclass) WidgetClass
91       xmWorldObjectClass = (WidgetClass) NULL;
92 /* WorldP.h was defuncted for 2.0 , no more ref to (&xmWorldClassRec) */
93 
94 
95 int
XmTextFieldGetBaseLine(Widget w)96 XmTextFieldGetBaseLine(
97         Widget w )
98 {
99   return XmTextFieldGetBaseline( w) ;
100 }
101 
102 int
XmTextGetBaseLine(Widget w)103 XmTextGetBaseLine(
104         Widget w )
105 {
106   return XmTextGetBaseline( w) ;
107 }
108 
109 /*ARGSUSED*/
110 Boolean
_XmTestTraversability(Widget widget,XRectangle * visRect)111 _XmTestTraversability(
112         Widget widget,
113         XRectangle *visRect )	/* unused */
114 {
115   return XmIsTraversable( widget) ;
116 }
117 
118 /*ARGSUSED*/
119 void
_XmClearTabGroup(Widget w)120 _XmClearTabGroup(
121         Widget w )		/* unused */
122 {
123   return ;
124 }
125 
126 Widget
_XmFindTabGroup(Widget widget)127 _XmFindTabGroup(
128         Widget widget )
129 {
130   return XmGetTabGroup( widget) ;
131 }
132 
133 /*ARGSUSED*/
134 void
_XmClearKbdFocus(Widget tabGroup)135 _XmClearKbdFocus(
136         Widget tabGroup )	/* unused */
137 {
138   return ;
139 }
140 
141 Widget
_XmGetTabGroup(Widget w)142 _XmGetTabGroup(
143         Widget w )
144 {
145   return XmGetTabGroup( w) ;
146 }
147 
148 /*ARGSUSED*/
149 Boolean
_XmWidgetIsTraversable(Widget widget,int navType,XRectangle * visRect)150 _XmWidgetIsTraversable(
151         Widget widget,
152 #if NeedWidePrototypes
153         int navType,		/* unused */
154 #else
155         XmNavigationType navType, /* unused */
156 #endif /* NeedWidePrototypes */
157         XRectangle *visRect )	/* unused */
158 {
159   return XmIsTraversable( widget) ;
160 }
161 
162 Boolean
_XmGetManagedInfo(Widget w)163 _XmGetManagedInfo(
164         Widget w )
165 {
166   /* Depending upon the widget coming in, extract its mapped_when_managed flag
167    * and its managed flag.
168    */
169     if (XmIsPrimitive (w))
170       return (w->core.managed && w->core.mapped_when_managed);
171     else if (XmIsGadget (w))
172       return (w->core.managed);
173     else
174       {
175 	  /* Treat menupanes specially */
176 	  if (XmIsRowColumn(w) && XmIsMenuShell(XtParent(w)))
177 	    {
178 		return (True);
179 	    }
180 	  else
181 	    return (w->core.managed && w->core.mapped_when_managed);
182       }
183 }
184 
185 Boolean
_XmChangeNavigationType(Widget current,int newNavType)186 _XmChangeNavigationType(
187         Widget current,
188 #if NeedWidePrototypes
189         int newNavType )
190 #else
191         XmNavigationType newNavType )
192 #endif /* NeedWidePrototypes */
193 {
194   /* This is a convenience routine for widgets wanting to change
195    * their navigation type without using XtSetValues().
196    */
197   XmFocusData focusData ;
198   Widget new_wid = current->core.self ;
199   XmNavigationType curNavType = _XmGetNavigationType( current) ;
200   XmTravGraph tgraph ;
201 
202   if(    (curNavType != newNavType)
203      &&  (focusData = _XmGetFocusData( new_wid))
204      &&  (tgraph = &(focusData->trav_graph))->num_entries    )
205     {
206       _XmTravGraphUpdate( tgraph, new_wid) ;
207 
208       if(    (focusData->focus_policy == XmEXPLICIT)
209 	 &&  (focusData->focus_item == new_wid)
210 	 &&  !XmIsTraversable( new_wid)    )
211 	{
212 	  Widget new_focus = _XmTraverseAway( tgraph, new_wid,
213 				    (focusData->active_tab_group != new_wid)) ;
214 	  if(    !new_focus    )
215 	    {
216 	      new_focus = new_wid ;
217 	    }
218 	  _XmMgrTraversal( new_focus, XmTRAVERSE_CURRENT) ;
219 	}
220     }
221   return TRUE ;
222 }
223 
224 
225 /********************************************************************/
226 /* Following is the old code needed for subclasses already using it */
227 /* They can either define the macro and change nothing (but suffer
228    the addition of code and the drawing performance) or adapt to the
229    new interface (better) */
230 
231 /************************************************************************
232  *
233  *  Primitive:_XmDrawShadow, become XmDrawShadow
234  *
235  *      Draw an n segment wide bordering shadow on the drawable
236  *      d, using the provided GC's and rectangle.
237  *
238  ************************************************************************/
239 
_XmDrawShadow(Display * display,Drawable d,GC top_GC,GC bottom_GC,int size,int x,int y,int width,int height)240 void _XmDrawShadow (Display *display, Drawable d,
241                     GC top_GC, GC bottom_GC, int size, int x, int y,
242                     int width, int height)
243 {
244    static XRectangle * rects = NULL;
245    static int rect_count = 0;
246    register int i;
247    register int size2;
248    register int size3;
249 
250    if (size <= 0) return;
251    if (size > width / 2) size = width / 2;
252    if (size > height / 2) size = height / 2;
253    if (size <= 0) return;
254 
255    if (rect_count == 0)
256    {
257       rects = (XRectangle *) XtMalloc (sizeof (XRectangle) * size * 4);
258       rect_count = size;
259    }
260 
261    if (rect_count < size)
262    {
263       rects = (XRectangle *) XtRealloc((char *)rects, sizeof (XRectangle) * size * 4);
264       rect_count = size;
265    }
266 
267    size2 = size + size;
268    size3 = size2 + size;
269 
270    for (i = 0; i < size; i++)
271    {
272       /*  Top segments  */
273 
274       rects[i].x = x;
275       rects[i].y = y + i;
276       rects[i].width = width - i;
277       rects[i].height = 1;
278 
279 
280       /*  Left segments  */
281 
282       rects[i + size].x = x + i;
283       rects[i + size].y = y;
284       rects[i + size].width = 1;
285       rects[i + size].height = height - i;
286 
287 
288       /*  Bottom segments  */
289 
290       rects[i + size2].x = x + i + 1;
291       rects[i + size2].y = y + height - i - 1;
292       rects[i + size2].width = width - i - 1;
293       rects[i + size2].height = 1;
294 
295 
296       /*  Right segments  */
297 
298       rects[i + size3].x = x + width - i - 1;
299       rects[i + size3].y = y + i + 1;
300       rects[i + size3].width = 1;
301       rects[i + size3].height = height - i - 1;
302    }
303 
304    XFillRectangles (display, d, top_GC, &rects[0], size2);
305    XFillRectangles (display, d, bottom_GC, &rects[size2], size2);
306 }
307 
308 /************************************************************************
309  *
310  *  Primitive:_XmEraseShadow become XmClearShadow
311  *
312  *      Erase an n segment wide bordering shadow on the drawable
313  *      d, using the provided  rectangle.
314  *
315  ************************************************************************/
316 
_XmEraseShadow(Display * display,Drawable d,int size,int x,int y,int width,int height)317 void _XmEraseShadow (Display *display, Drawable d, int size,
318                      int x, int y, int width, int height)
319 {
320    if (width > 0 && size > 0)
321    {
322       XClearArea (display, d, x, y, width, size, FALSE);
323       XClearArea (display, d, x, y + height - size, width, size, FALSE);
324    }
325 
326    if (size > 0 && height - (2 * size) > 0)
327    {
328       XClearArea (display, d, x, y + size, size, height - (2 * size), FALSE);
329       XClearArea (display, d, x + width - size, y + size, size,
330                   height - (2 * size), FALSE);
331    }
332 }
333 
334 
335 
336 /************************************************************************
337  *    ArrowBI:_XmGetArrowDrawRects, become XmDrawArrow
338  *
339  *      Calculate the drawing rectangles.
340  *
341  ************************************************************************/
342 
_XmGetArrowDrawRects(int highlight_thickness,int shadow_thickness,unsigned int direction,int core_width,int core_height,short * top_count,short * cent_count,short * bot_count,XRectangle ** top,XRectangle ** cent,XRectangle ** bot)343 void _XmGetArrowDrawRects (int highlight_thickness, int shadow_thickness, unsigned int direction, int core_width, int core_height, short *top_count, short *cent_count, short *bot_count, XRectangle **top, XRectangle **cent, XRectangle **bot)
344 {
345    /*  Arrow rectangle generation function  */
346 
347    int size, width, start;
348    register int y;
349    XRectangle *tmp;
350    register int temp;
351    short t = 0;
352    short b = 0;
353    short c = 0;
354    int xOffset = 0;
355    int yOffset = 0;
356 
357 
358    /*  Free the old lists  */
359 
360    if (*top != NULL)
361    {
362       XtFree ((char *) *top);   *top  = NULL;
363       XtFree ((char *) *cent);  *cent = NULL;
364       XtFree ((char *) *bot);   *bot  = NULL;
365       *top_count = 0;
366       *cent_count = 0;
367       *bot_count = 0;
368    }
369 
370 
371    /*  Get the size and allocate the rectangle lists  */
372 
373    if (core_width > core_height)
374    {
375       size = core_height - 2 -
376              2 * (highlight_thickness + shadow_thickness);
377       xOffset = (core_width - core_height) / 2;
378    }
379    else
380    {
381       size = core_width - 2 -
382              2 * (highlight_thickness + shadow_thickness);
383       yOffset = (core_height - core_width) / 2;
384    }
385 
386    if (size < 1) return;
387 
388 
389    if (direction == XmARROW_RIGHT ||
390        direction == XmARROW_LEFT)
391    {
392       temp = xOffset;
393       xOffset = yOffset;
394       yOffset = temp;
395    }
396 
397    *top  = (XRectangle *) XtMalloc (sizeof (XRectangle) * (size / 2 + 6));
398    *cent = (XRectangle *) XtMalloc (sizeof (XRectangle) * (size  / 2 + 6));
399    *bot  = (XRectangle *) XtMalloc (sizeof (XRectangle) * (size / 2 + 6));
400 
401    /*  Set up a loop to generate the segments.  */
402 
403    width = size;
404    y = size + highlight_thickness + shadow_thickness - 1 + yOffset;
405 
406    start = highlight_thickness + shadow_thickness + 1 + xOffset;
407 
408    while (width > 0)
409    {
410 
411       if (width == 1)
412       {
413          (*top)[t].x = start; (*top)[t].y = y + 1;
414          (*top)[t].width = 1; (*top)[t].height = 1;
415          t++;
416       }
417       else if (width == 2)
418       {
419          if (size == 2 ||
420              (direction == XmARROW_UP ||
421               direction == XmARROW_LEFT))
422          {
423             (*top)[t].x = start; (*top)[t].y = y;
424             (*top)[t].width = 2; (*top)[t].height = 1;
425             t++;
426             (*top)[t].x = start; (*top)[t].y = y + 1;
427             (*top)[t].width = 1; (*top)[t].height = 1;
428             t++;
429             (*bot)[b].x = start + 1; (*bot)[b].y = y + 1;
430             (*bot)[b].width = 1; (*bot)[b].height = 1;
431             b++;
432          }
433          else if (direction == XmARROW_UP ||
434                   direction == XmARROW_LEFT)
435          {
436             (*top)[t].x = start; (*top)[t].y = y;
437             (*top)[t].width = 2; (*top)[t].height = 1;
438             t++;
439             (*bot)[b].x = start; (*bot)[b].y = y + 1;
440             (*bot)[b].width = 2; (*bot)[b].height = 1;
441             b++;
442          }
443       }
444       else
445       {
446          if (start == highlight_thickness +
447                       shadow_thickness + 1 + xOffset)
448          {
449             if (direction == XmARROW_UP ||
450                 direction == XmARROW_LEFT)
451             {
452                (*top)[t].x = start; (*top)[t].y = y;
453                (*top)[t].width = 2; (*top)[t].height = 1;
454                t++;
455                (*top)[t].x = start; (*top)[t].y = y + 1;
456                (*top)[t].width = 1; (*top)[t].height = 1;
457                t++;
458                (*bot)[b].x = start + 1; (*bot)[b].y = y + 1;
459                (*bot)[b].width = 1; (*bot)[b].height = 1;
460                b++;
461                (*bot)[b].x = start + 2; (*bot)[b].y = y;
462                (*bot)[b].width = width - 2; (*bot)[b].height = 2;
463                b++;
464             }
465             else
466             {
467                (*top)[t].x = start; (*top)[t].y = y;
468                (*top)[t].width = 2; (*top)[t].height = 1;
469                t++;
470                (*bot)[b].x = start; (*bot)[b].y = y + 1;
471                (*bot)[b].width = 2; (*bot)[b].height = 1;
472                b++;
473                (*bot)[b].x = start + 2; (*bot)[b].y = y;
474                (*bot)[b].width = width - 2; (*bot)[b].height = 2;
475                b++;
476             }
477          }
478          else
479          {
480             (*top)[t].x = start; (*top)[t].y = y;
481             (*top)[t].width = 2; (*top)[t].height = 2;
482             t++;
483             (*bot)[b].x = start + width - 2; (*bot)[b].y = y;
484             (*bot)[b].width = 2; (*bot)[b].height = 2;
485             if (width == 3)
486             {
487                (*bot)[b].width = 1;
488                (*bot)[b].x += 1;
489             }
490             b++;
491             if (width > 4)
492             {
493                (*cent)[c].x = start + 2; (*cent)[c].y = y;
494                (*cent)[c].width = width - 4; (*cent)[c].height = 2;
495                c++;
496             }
497          }
498       }
499       start++;
500       width -= 2;
501       y -= 2;
502    }
503 
504    if (direction == XmARROW_UP ||
505        direction == XmARROW_LEFT)
506    {
507       *top_count = t;
508       *cent_count = c;
509       *bot_count = b;
510    }
511    else
512    {
513       tmp = *top;
514       *top = *bot;
515       *bot = tmp;
516       *top_count = b;
517       *cent_count = c;
518       *bot_count = t;
519    }
520 
521 
522    /*  Transform the "up" pointing arrow to the correct direction  */
523 
524    switch (direction)
525    {
526       case XmARROW_LEFT:
527       {
528           register int i;
529 
530           i = -1;
531           do
532           {
533              i++;
534              if (i < *top_count)
535              {
536                 temp = (*top)[i].y; (*top)[i].y =
537                     (*top)[i].x; (*top)[i].x = temp;
538                 temp = (*top)[i].width;
539                 (*top)[i].width = (*top)[i].height; (*top)[i].height = temp;
540              }
541              if (i < *bot_count)
542              {
543                 temp = (*bot)[i].y; (*bot)[i].y =
544                     (*bot)[i].x; (*bot)[i].x = temp;
545                 temp = (*bot)[i].width;
546                 (*bot)[i].width = (*bot)[i].height; (*bot)[i].height = temp;
547              }
548              if (i < *cent_count)
549              {
550                 temp = (*cent)[i].y; (*cent)[i].y =
551                     (*cent)[i].x; (*cent)[i].x = temp;
552                 temp = (*cent)[i].width;
553                 (*cent)[i].width = (*cent)[i].height; (*cent)[i].height = temp;
554              }
555           }
556           while (i < *top_count || i < *bot_count || i < *cent_count);
557       }
558       break;
559 
560       case XmARROW_RIGHT:
561       {
562           register int h_right = core_height - 2;
563           register int w_right = core_width - 2;
564           register int i;
565 
566           i = -1;
567           do
568           {
569              i++;
570              if (i < *top_count)
571              {
572                 temp = (*top)[i].y; (*top)[i].y = (*top)[i].x;
573                 (*top)[i].x = temp;
574                 temp = (*top)[i].width; (*top)[i].width = (*top)[i].height;
575                 (*top)[i].height = temp;
576                 (*top)[i].x = w_right - (*top)[i].x - (*top)[i].width + 2;
577                 (*top)[i].y = h_right - (*top)[i].y - (*top)[i].height + 2;
578              }
579              if (i < *bot_count)
580              {
581                 temp = (*bot)[i].y; (*bot)[i].y = (*bot)[i].x;
582                 (*bot)[i].x = temp;
583                 temp = (*bot)[i].width; (*bot)[i].width = (*bot)[i].height;
584                 (*bot)[i].height = temp;
585                 (*bot)[i].x = w_right - (*bot)[i].x - (*bot)[i].width + 2;
586                 (*bot)[i].y = h_right - (*bot)[i].y - (*bot)[i].height + 2;
587              }
588              if (i < *cent_count)
589              {
590                 temp = (*cent)[i].y; (*cent)[i].y = (*cent)[i].x;
591                 (*cent)[i].x = temp;
592                 temp = (*cent)[i].width; (*cent)[i].width = (*cent)[i].height;
593                 (*cent)[i].height = temp;
594                 (*cent)[i].x = w_right - (*cent)[i].x - (*cent)[i].width + 2;
595                 (*cent)[i].y = h_right - (*cent)[i].y - (*cent)[i].height + 2;
596              }
597           }
598           while (i < *top_count || i < *bot_count || i < *cent_count);
599       }
600       break;
601 
602       case XmARROW_UP:
603       {
604       }
605       break;
606 
607       case XmARROW_DOWN:
608       {
609           register int w_down = core_width - 2;
610           register int h_down = core_height - 2;
611           register int i;
612 
613           i = -1;
614           do
615           {
616              i++;
617              if (i < *top_count)
618              {
619                 (*top)[i].x = w_down - (*top)[i].x - (*top)[i].width + 2;
620                 (*top)[i].y = h_down - (*top)[i].y - (*top)[i].height + 2;
621              }
622              if (i < *bot_count)
623              {
624                 (*bot)[i].x = w_down - (*bot)[i].x - (*bot)[i].width + 2;
625                 (*bot)[i].y = h_down - (*bot)[i].y - (*bot)[i].height + 2;
626              }
627              if (i < *cent_count)
628              {
629                 (*cent)[i].x = w_down - (*cent)[i].x - (*cent)[i].width + 2;
630                 (*cent)[i].y = h_down - (*cent)[i].y - (*cent)[i].height + 2;
631              }
632           }
633 
634           while (i < *top_count || i < *bot_count || i < *cent_count);
635       }
636       break;
637    }
638 }
639 
640 /************************************************************************
641  *
642  *    ArrowBI:_XmOffsetArrow, become XmDrawArrow
643  *
644  *      Offset the arrow drawing rectangles, if needed, by the difference
645  *      of the current x, y and the saved x, y);
646  *
647  ************************************************************************/
648 
_XmOffsetArrow(int diff_x,int diff_y,XRectangle * top,XRectangle * cent,XRectangle * bot,int top_count,int cent_count,int bot_count)649 void _XmOffsetArrow (int diff_x, int diff_y, XRectangle *top, XRectangle *cent, XRectangle *bot, int top_count, int cent_count, int bot_count)
650 {
651    register int i;
652 
653    if (diff_x != 0 || diff_y != 0)
654    {
655       for (i = 0; i < top_count; i++)
656       {
657          (top + i)->x += diff_x;
658          (top + i)->y += diff_y;
659       }
660 
661       for (i = 0; i < cent_count; i++)
662       {
663          (cent + i)->x += diff_x;
664          (cent + i)->y += diff_y;
665       }
666 
667       for (i = 0; i < bot_count; i++)
668       {
669          (bot + i)->x += diff_x;
670          (bot + i)->y += diff_y;
671       }
672    }
673 }
674 
675 /*************************************<->*************************************
676  *
677  *  ToggleBI:_DrawSquareButton, become code
678  *
679  *
680  *************************************<->***********************************/
681 
_XmDrawSquareButton(Widget w,int x,int y,int size,GC topGC,GC bottomGC,GC centerGC,int fill)682 void _XmDrawSquareButton (Widget w, int x, int y, int size, GC topGC, GC bottomGC, GC centerGC,
683 #if NeedWidePrototypes
684 int fill)
685 #else
686 Boolean fill)
687 #endif /* NeedWidePrototypes */
688 {
689    _XmDrawShadow (XtDisplay (w), XtWindow (w),
690                   topGC, bottomGC,
691                   2, x, y, size, size);
692 
693    if (fill)
694        if (size > 6)
695            XFillRectangle (XtDisplay ((Widget) w),
696                            XtWindow ((Widget) w),
697                            centerGC,
698                            ((fill) ? x+2 : x+3),
699                            ((fill) ? y+2 : y+3),
700                            ((fill) ? size-4 : size-6),
701                            ((fill) ? size-4 : size-6));
702 }
703 
704 /************************************************************************
705  *
706  *  ToggleBI:DrawDiamondButton, become XmDrawDiamond
707  *
708  *      The diamond drawing routine.  Used in place of  widgets or gadgets
709  *      draw routine when toggleButton's indicatorType is one_of_many.
710  *
711  ************************************************************************/
712 
713 
_XmDrawDiamondButton(Widget tw,int x,int y,int size,GC topGC,GC bottomGC,GC centerGC,int fill)714 void _XmDrawDiamondButton (Widget tw, int x, int y, int size, GC topGC, GC bottomGC, GC centerGC,
715 #if NeedWidePrototypes
716 int fill )
717 #else
718 Boolean fill)
719 #endif /* NeedWidePrototypes */
720 {
721    XSegment seg[12];
722    XPoint   pt[5];
723    int midX, midY;
724 
725    if (size % 2 == 0)
726       size--;
727 
728    midX = x + (size + 1) / 2;
729    midY = y + (size + 1) / 2;
730 
731    /* COUNTER REVERSE DRAWING EFFECT ON TINY ToggleButtonS */
732    if (size <= 3)
733     {
734        /*  The top shadow segments  */
735 
736        seg[0].x1 = x + size - 1;        /*  1  */
737        seg[0].y1 = midY - 1;
738        seg[0].x2 = midX - 1;            /*  2  */
739        seg[0].y2 = y + size - 1;
740 
741        seg[1].x1 = x + size - 2;        /*  3  */
742        seg[1].y1 = midY - 1;
743        seg[1].x2 = midX - 1;            /*  4  */
744        seg[1].y2 = y + size - 2;
745 
746        seg[2].x1 = x + size - 3;        /*  3  */
747        seg[2].y1 = midY - 1;
748        seg[2].x2 = midX - 1;            /*  4  */
749        seg[2].y2 = y + size - 3;
750 
751        /*--*/
752 
753        seg[3].x1 = midX - 1;            /*  5  */
754        seg[3].y1 = y + size - 1;
755        seg[3].x2 = x;                   /*  6  */
756        seg[3].y2 = midY - 1;
757 
758        seg[4].x1 = midX - 1;            /*  7  */
759        seg[4].y1 = y + size - 2;
760        seg[4].x2 = x + 1;               /*  8  */
761        seg[4].y2 = midY - 1;
762 
763        seg[5].x1 = midX - 1;            /*  7  */
764        seg[5].y1 = y + size - 3;
765        seg[5].x2 = x + 2;               /*  8  */
766        seg[5].y2 = midY - 1;
767 
768        /*  The bottom shadow segments  */
769 
770        seg[6].x1 = x + size - 1;        /*  9  */
771        seg[6].y1 = midY - 1;
772        seg[6].x2 = midX - 1;            /*  10  */
773        seg[6].y2 = y;
774 
775        seg[7].x1 = x + size - 2;        /*  11  */
776        seg[7].y1 = midY - 1;
777        seg[7].x2 = midX - 1;            /*  12  */
778        seg[7].y2 = y + 1;
779 
780        seg[8].x1 = x + size - 3;        /*  11  */
781        seg[8].y1 = midY - 1;
782        seg[8].x2 = midX - 1;            /*  12  */
783        seg[8].y2 = y + 2;
784 
785        /*--*/
786 
787        seg[9].x1 = midX - 1;            /*  13  */
788        seg[9].y1 = y;
789        seg[9].x2 = x;                   /*  14  */
790        seg[9].y2 = midY - 1;
791 
792        seg[10].x1 = midX - 1;           /*  15  */
793        seg[10].y1 = y + 1;
794        seg[10].x2 = x + 1;              /*  16  */
795        seg[10].y2 = midY - 1;
796 
797        seg[11].x1 = midX - 1;           /*  15  */
798        seg[11].y1 = y + 2;
799        seg[11].x2 = x + 2;              /*  16  */
800        seg[11].y2 = midY - 1;
801 
802     }
803   else    /* NORMAL SIZED ToggleButtonS */
804     {
805        /*  The top shadow segments  */
806 
807        seg[0].x1 = x;                   /*  1  */
808        seg[0].y1 = midY - 1;
809        seg[0].x2 = midX - 1;            /*  2  */
810        seg[0].y2 = y;
811 
812        seg[1].x1 = x + 1;               /*  3  */
813        seg[1].y1 = midY - 1;
814        seg[1].x2 = midX - 1;            /*  4  */
815        seg[1].y2 = y + 1;
816 
817        seg[2].x1 = x + 2;               /*  3  */
818        seg[2].y1 = midY - 1;
819        seg[2].x2 = midX - 1;            /*  4  */
820        seg[2].y2 = y + 2;
821 
822        /*--*/
823 
824        seg[3].x1 = midX - 1;            /*  5  */
825        seg[3].y1 = y;
826        seg[3].x2 = x + size - 1;        /*  6  */
827        seg[3].y2 = midY - 1;
828 
829        seg[4].x1 = midX - 1;            /*  7  */
830        seg[4].y1 = y + 1;
831        seg[4].x2 = x + size - 2;        /*  8  */
832        seg[4].y2 = midY - 1;
833 
834        seg[5].x1 = midX - 1;            /*  7  */
835        seg[5].y1 = y + 2;
836        seg[5].x2 = x + size - 3;        /*  8  */
837        seg[5].y2 = midY - 1;
838 
839 
840        /*  The bottom shadow segments  */
841 
842        seg[6].x1 = x;                   /*  9  */
843        seg[6].y1 = midY - 1;
844        seg[6].x2 = midX - 1;            /*  10  */
845        seg[6].y2 = y + size - 1;
846 
847        seg[7].x1 = x + 1;               /*  11  */
848        seg[7].y1 = midY - 1;
849        seg[7].x2 = midX - 1;            /*  12  */
850        seg[7].y2 = y + size - 2;
851 
852        seg[8].x1 = x + 2;               /*  11  */
853        seg[8].y1 = midY - 1;
854        seg[8].x2 = midX - 1;            /*  12  */
855        seg[8].y2 = y + size - 3;
856 
857        /*--*/
858 
859        seg[9].x1 = midX - 1;            /*  13  */
860        seg[9].y1 = y + size - 1;
861        seg[9].x2 = x + size - 1;        /*  14  */
862        seg[9].y2 = midY - 1;
863 
864        seg[10].x1 = midX - 1;           /*  15  */
865        seg[10].y1 = y + size - 2;
866        seg[10].x2 = x + size - 2;       /*  16  */
867        seg[10].y2 = midY - 1;
868 
869        seg[11].x1 = midX - 1;           /*  15  */
870        seg[11].y1 = y + size - 3;
871        seg[11].x2 = x + size - 3;       /*  16  */
872        seg[11].y2 = midY - 1;
873     }
874 
875    XDrawSegments (XtDisplay ((Widget) tw), XtWindow ((Widget) tw),
876                   topGC, &seg[3], 3);
877 
878    XDrawSegments (XtDisplay ((Widget) tw), XtWindow ((Widget) tw),
879                   bottomGC, &seg[6], 6);
880 
881    XDrawSegments (XtDisplay ((Widget) tw), XtWindow ((Widget) tw),
882                   topGC, &seg[0], 3);
883 
884 
885 /* For Fill */
886    if (fill)
887    {
888       pt[0].x = x + 3;
889       pt[0].y = midY - 1;
890       pt[1].x = midX - 1 ;
891       pt[1].y = y + 2;
892       pt[2].x = x + size - 3;
893       pt[2].y = midY - 1;
894       pt[3].x = midX - 1 ;
895       pt[3].y = y + size - 3;
896    }
897    else
898    {
899       pt[0].x = x + 4;
900       pt[0].y = midY - 1;
901       pt[1].x = midX - 1;
902       pt[1].y = y + 3;
903       pt[2].x = x + size - 4;
904       pt[2].y = midY - 1;
905       pt[3].x = midX - 1;
906       pt[3].y = y + size - 4;
907    }
908 
909 
910    /* NOTE: code which handled the next two ifs by setting pt[1-3]
911       to match pt[0] values was replaced with return statements because
912       passing 4 identical coordinates to XFillPolygon caused the PMAX
913       to give a bus error.  Dana@HP reports that the call is legitimate
914       and that the error is in the PMAX server.  The return statements
915       will stay until the situation with the PMAX is resolved. (mitch) */
916 
917    /* COUNTER REVERSE DRAWING EFFECT ON TINY ToggleButtonS */
918    if (pt[0].x > pt[1].x)
919      {
920        return;
921      }
922 
923    if (pt[0].y < pt[1].y)
924      {
925        return;
926      }
927 
928    XFillPolygon (XtDisplay ((Widget) tw), XtWindow ((Widget) tw),
929                  centerGC, pt, 4, Convex, CoordModeOrigin);
930 }
931 
932 /************************************************************************
933  *
934  *  Manager:XmDrawEtchedShadow, become XmDrawShadow
935  *
936  *      Draw an n segment wide etched shadow on the drawable
937  *      d, using the provided GC's and rectangle.
938  *
939  ************************************************************************/
940 
941 static XRectangle *rects = NULL;
942 static int rect_count = 0;
943 
944 static void
get_rects(int max_i,register int offset,register int x,register int y,register int width,register int height,register int pos_top,register int pos_left,register int pos_bottom,register int pos_right)945 get_rects(
946 int max_i,
947 register int offset,
948 register int x,
949 register int y,
950 register int width,
951 register int height,
952 register int pos_top,
953 register int pos_left,
954 register int pos_bottom,
955 register int pos_right)
956 {
957    register int i;
958    register int offsetX2;
959 
960    for (i = 0; i < max_i; i++, offset++)
961    {
962       offsetX2 = offset + offset;
963 
964       /*  Top segments  */
965 
966       rects[pos_top + i].x = x + offset;
967       rects[pos_top + i].y = y + offset;
968       rects[pos_top + i].width = width - offsetX2 -1;
969       rects[pos_top + i].height = 1;
970 
971 
972       /*  Left segments  */
973 
974       rects[pos_left + i].x = x + offset;
975       rects[pos_left + i].y = y + offset;
976       rects[pos_left + i].width = 1;
977       rects[pos_left + i].height = height - offsetX2 - 1;
978 
979 
980       /*  Bottom segments  */
981 
982       rects[pos_bottom + i].x = x + offset;
983       rects[pos_bottom + i].y = y + height - offset - 1;
984       rects[pos_bottom + i].width = width - offsetX2;
985       rects[pos_bottom + i].height = 1;
986 
987 
988       /*  Right segments  */
989 
990       rects[pos_right + i].x = x + width - offset - 1;
991       rects[pos_right + i].y = y + offset;
992       rects[pos_right + i].width = 1;
993       rects[pos_right + i].height = height - offsetX2;
994    }
995 }
996 
997 static void
XmDrawEtchedShadow(Display * display,Drawable d,GC top_GC,GC bottom_GC,register int size,register int x,register int y,register int width,register int height)998 XmDrawEtchedShadow (
999 Display * display,
1000 Drawable d,
1001 GC top_GC,
1002 GC bottom_GC,
1003 register int size,
1004 register int x,
1005 register int y,
1006 register int width,
1007 register int height)
1008 {
1009    int half_size;
1010    int size2;
1011    int size3;
1012    int pos_top, pos_left, pos_bottom, pos_right;
1013 
1014    if (size <= 0) return;
1015    if (size == 1)
1016         {
1017       _XmDrawShadow (display, d,
1018          top_GC,  bottom_GC, size, x, y, width, height);
1019           return;
1020         }
1021 
1022    if (size > width / 2) size = width / 2;
1023    if (size > height / 2) size = height / 2;
1024    if (size <= 0) return;
1025 
1026    size = (size % 2) ? (size-1) : (size);
1027 
1028    half_size = size / 2;
1029    size2 = size + size;
1030    size3 = size2 + size;
1031 
1032    if (rect_count == 0)
1033    {
1034       rects = (XRectangle *) XtMalloc (sizeof (XRectangle) * size * 4);
1035       rect_count = size;
1036    }
1037 
1038    if (rect_count < size)
1039    {
1040       rects = (XRectangle *) XtRealloc((char *)rects, sizeof (XRectangle) * size * 4);
1041       rect_count = size;
1042    }
1043 
1044    pos_top = 0;
1045    pos_left = half_size;
1046    pos_bottom = size2;
1047    pos_right = size2 + half_size;
1048 
1049    get_rects(half_size, 0, x, y, width, height,
1050              pos_top, pos_left, pos_bottom, pos_right);
1051 
1052    pos_top = size3;
1053    pos_left = size3 + half_size;
1054    pos_bottom = size;
1055    pos_right = size + half_size;
1056 
1057    get_rects(half_size, half_size, x, y, width, height,
1058                 pos_top, pos_left, pos_bottom, pos_right);
1059 
1060    XFillRectangles (display, d, bottom_GC, &rects[size2], size2);
1061    XFillRectangles (display, d, top_GC, &rects[0], size2);
1062 }
1063 
1064 
1065 /*****************************************************************
1066  * Manager:_XmDrawShadowType, become XmDrawShadow
1067  *****************************************************************/
1068 
_XmDrawShadowType(Widget w,unsigned int shadow_type,int core_width,int core_height,int shadow_thickness,int highlight_thickness,GC top_shadow_GC,GC bottom_shadow_GC)1069 void _XmDrawShadowType (Widget w, unsigned int shadow_type,
1070 #if NeedWidePrototypes
1071 			int core_width, int core_height,
1072                         int shadow_thickness, int highlight_thickness,
1073 #else
1074                         Dimension core_width, Dimension core_height,
1075                         Dimension shadow_thickness, Dimension highlight_thickness,
1076 #endif
1077                         GC top_shadow_GC, GC bottom_shadow_GC)
1078 {
1079    if (!XtIsRealized(w))
1080      return;
1081    switch (shadow_type)
1082    {
1083       case XmSHADOW_IN:
1084       case XmSHADOW_OUT:
1085          if (shadow_thickness > 0)
1086             _XmDrawShadow (XtDisplay (w), XtWindow (w),
1087              (shadow_type == XmSHADOW_IN) ? bottom_shadow_GC : top_shadow_GC,
1088              (shadow_type == XmSHADOW_IN) ? top_shadow_GC : bottom_shadow_GC,
1089               shadow_thickness,
1090               highlight_thickness,
1091               highlight_thickness,
1092               core_width - 2 * highlight_thickness,
1093               core_height - 2 * highlight_thickness);
1094       break;
1095 
1096       case XmSHADOW_ETCHED_IN:
1097       case XmSHADOW_ETCHED_OUT:
1098            XmDrawEtchedShadow (XtDisplay(w), XtWindow(w),
1099                  (shadow_type == XmSHADOW_ETCHED_IN) ?
1100                          bottom_shadow_GC : top_shadow_GC,
1101                  (shadow_type == XmSHADOW_ETCHED_IN) ?
1102                              top_shadow_GC : bottom_shadow_GC,
1103                  shadow_thickness,
1104                  highlight_thickness,
1105                      highlight_thickness,
1106                  core_width - 2 * highlight_thickness,
1107                  core_height - 2 * highlight_thickness);
1108 
1109             break;
1110 
1111    }
1112 }
1113 
1114 /************************************************************************
1115  * Primitive:_XmDrawBorder, become XmDrawHighlight
1116  ************************************************************************/
1117 
_XmDrawBorder(Widget w,GC gc,int x,int y,int width,int height,int highlight_width)1118 void _XmDrawBorder ( Widget w, GC gc,
1119 #if NeedWidePrototypes
1120                                       int x, int y,
1121         int width, int height, int highlight_width)
1122 #else
1123                                       Position x, Position y,
1124         Dimension width, Dimension height, Dimension highlight_width)
1125 #endif /* NeedWidePrototypes */
1126 
1127 {
1128    XRectangle rect[4];
1129 
1130    rect[0].x = x;
1131    rect[0].y = y;
1132    rect[0].width = width;
1133    rect[0].height = highlight_width;
1134 
1135    rect[1].x = x;
1136    rect[1].y = y;
1137    rect[1].width = highlight_width;
1138    rect[1].height = height;
1139 
1140    rect[2].x = x + width - highlight_width;
1141    rect[2].y = y;
1142    rect[2].width = highlight_width;
1143    rect[2].height = height;
1144 
1145    rect[3].x = x;
1146    rect[3].y = y + height - highlight_width;
1147    rect[3].width = width;
1148    rect[3].height = highlight_width;
1149 
1150    XFillRectangles (XtDisplay (w), XtWindow (w), gc, &rect[0], 4);
1151 }
1152 
1153 /***************************************************************
1154   All these functions were private but global in 1.1, so instead of
1155    just moving them static, we also provide the compatibility stuff.
1156    They are just wrapping around the new static names
1157 ****************************************************************/
1158 void
_XmFileSelectionBoxCreateFilterLabel(XmFileSelectionBoxWidget fsb)1159 _XmFileSelectionBoxCreateFilterLabel(
1160         XmFileSelectionBoxWidget fsb )
1161 {
1162   FS_FilterLabel( fsb) = _XmBB_CreateLabelG( (Widget) fsb,
1163 					      FS_FilterLabelString( fsb),
1164 					      "FilterLabel",
1165 					      XmFilterStringLoc) ;
1166 }
1167 
1168 void
_XmFileSelectionBoxCreateDirListLabel(XmFileSelectionBoxWidget fsb)1169 _XmFileSelectionBoxCreateDirListLabel(
1170         XmFileSelectionBoxWidget fsb )
1171 {
1172     FS_DirListLabel( fsb) = _XmBB_CreateLabelG( (Widget) fsb,
1173 					       FS_DirListLabelString( fsb),
1174 					       "Dir",
1175 					       XmDirListStringLoc) ;
1176 }
1177 /*****************************************************************/
1178 void
_XmFileSelectionBoxCreateDirList(XmFileSelectionBoxWidget fsb)1179 _XmFileSelectionBoxCreateDirList(
1180         XmFileSelectionBoxWidget fsb )
1181 {
1182 	Arg		al[20];
1183 	register int	ac = 0;
1184             XtCallbackProc callbackProc ;
1185 /****************/
1186 
1187     FS_DirListSelectedItemPosition( fsb) = 0 ;
1188 
1189     XtSetArg( al[ac], XmNvisibleItemCount,
1190                                         SB_ListVisibleItemCount( fsb)) ; ac++ ;
1191     XtSetArg( al[ac], XmNstringDirection, SB_StringDirection( fsb));  ac++;
1192     XtSetArg( al[ac], XmNselectionPolicy, XmBROWSE_SELECT);  ac++;
1193     XtSetArg( al[ac], XmNlistSizePolicy, XmCONSTANT);  ac++;
1194     XtSetArg( al[ac], XmNscrollBarDisplayPolicy, XmSTATIC);  ac++;
1195     XtSetArg( al[ac], XmNnavigationType, XmSTICKY_TAB_GROUP) ; ++ac ;
1196 
1197     FS_DirList( fsb) = XmCreateScrolledList( (Widget) fsb, "DirList", al, ac);
1198 
1199     callbackProc = ((XmSelectionBoxWidgetClass) fsb->core.widget_class)
1200                                           ->selection_box_class.list_callback ;
1201     if(    callbackProc    )
1202     {
1203         XtAddCallback( FS_DirList( fsb), XmNsingleSelectionCallback,
1204                                                callbackProc, (XtPointer) fsb) ;
1205         XtAddCallback( FS_DirList( fsb), XmNbrowseSelectionCallback,
1206                                                callbackProc, (XtPointer) fsb) ;
1207         XtAddCallback( FS_DirList( fsb), XmNdefaultActionCallback,
1208                                                callbackProc, (XtPointer) fsb) ;
1209         }
1210     XtManageChild( FS_DirList( fsb)) ;
1211 
1212     return ;
1213 }
1214 
1215 /*****************************************************************/
1216 void
_XmFileSelectionBoxCreateFilterText(XmFileSelectionBoxWidget fs)1217 _XmFileSelectionBoxCreateFilterText(
1218         XmFileSelectionBoxWidget fs )
1219 {
1220             Arg             arglist[10] ;
1221             int             argCount ;
1222             char *          stext_value ;
1223             XtAccelerators  temp_accelerators ;
1224 /****************/
1225 
1226     /* Get text portion from Compound String, and set
1227     *   fs_stext_charset and fs_stext_direction bits...
1228     */
1229     /* Should do this stuff entirely with XmStrings when the text
1230     *   widget supports it.
1231     */
1232     if(    !(stext_value = _XmStringGetTextConcat( FS_Pattern( fs)))    )
1233     {   stext_value = (char *) XtMalloc( 1) ;
1234         stext_value[0] = '\0' ;
1235         }
1236     argCount = 0 ;
1237     XtSetArg( arglist[argCount], XmNcolumns,
1238                                             SB_TextColumns( fs)) ; argCount++ ;
1239     XtSetArg( arglist[argCount], XmNresizeWidth, FALSE) ; argCount++ ;
1240     XtSetArg( arglist[argCount], XmNvalue, stext_value) ; argCount++ ;
1241     XtSetArg( arglist[argCount], XmNnavigationType,
1242                                              XmSTICKY_TAB_GROUP) ; argCount++ ;
1243     FS_FilterText( fs) = XmCreateTextField( (Widget) fs, "FilterText",
1244                                                            arglist, argCount) ;
1245 
1246     /*	Install text accelerators.
1247     */
1248     temp_accelerators = fs->core.accelerators ;
1249     fs->core.accelerators = SB_TextAccelerators( fs) ;
1250     XtInstallAccelerators( FS_FilterText( fs), (Widget) fs) ;
1251     fs->core.accelerators = temp_accelerators ;
1252 
1253     XtFree( stext_value) ;
1254     return ;
1255 }
1256 
1257 /****************************************************************/
1258 /*ARGSUSED*/
1259 void
_XmFileSelectionBoxGetDirectory(Widget fs,int resource,XtArgVal * value)1260 _XmFileSelectionBoxGetDirectory(
1261             Widget fs,
1262             int resource,	/* unused */
1263             XtArgVal *value)
1264 {
1265     XmString        data ;
1266 
1267     data = XmStringCopy(FS_Directory(fs));
1268     *value = (XtArgVal) data ;
1269 }
1270 /****************************************************************/
1271 /*ARGSUSED*/
1272 void
_XmFileSelectionBoxGetNoMatchString(Widget fs,int resource,XtArgVal * value)1273 _XmFileSelectionBoxGetNoMatchString(
1274             Widget fs,
1275             int resource,	/* unused */
1276             XtArgVal *value)
1277 {
1278     XmString        data ;
1279 
1280     data = XmStringCopy(FS_NoMatchString(fs));
1281     *value = (XtArgVal) data ;
1282 }
1283 /****************************************************************/
1284 /*ARGSUSED*/
1285 void
_XmFileSelectionBoxGetPattern(Widget fs,int resource,XtArgVal * value)1286 _XmFileSelectionBoxGetPattern(
1287             Widget fs,
1288             int resource,	/* unused */
1289             XtArgVal *value)
1290 {
1291     XmString        data ;
1292 
1293     data = XmStringCopy(FS_Pattern(fs));
1294     *value = (XtArgVal) data ;
1295 }
1296 /*****************************************************************/
1297 /*ARGSUSED*/
1298 void
_XmFileSelectionBoxGetFilterLabelString(Widget fs,int resource_offset,XtArgVal * value)1299 _XmFileSelectionBoxGetFilterLabelString(
1300         Widget fs,
1301         int resource_offset,	/* unused */
1302         XtArgVal *value )
1303 {
1304             XmString        data ;
1305             Arg             al[1] ;
1306 
1307     XtSetArg( al[0], XmNlabelString, &data) ;
1308     XtGetValues( FS_FilterLabel( fs), al, 1) ;
1309     *value = (XtArgVal) data ;
1310 }
1311 /*****************************************************************/
1312 /*ARGSUSED*/
1313 void
_XmFileSelectionBoxGetDirListLabelString(Widget fs,int resource_offset,XtArgVal * value)1314 _XmFileSelectionBoxGetDirListLabelString(
1315         Widget fs,
1316         int resource_offset,	/* unused */
1317         XtArgVal *value )
1318 {
1319             XmString        data ;
1320             Arg             al[1] ;
1321 
1322     XtSetArg( al[0], XmNlabelString, &data) ;
1323     XtGetValues( FS_DirListLabel( fs), al, 1) ;
1324     *value = (XtArgVal) data ;
1325 }
1326 /*****************************************************************/
1327 /*ARGSUSED*/
1328 void
_XmFileSelectionBoxGetDirListItems(Widget fs,int resource_offset,XtArgVal * value)1329 _XmFileSelectionBoxGetDirListItems(
1330         Widget fs,
1331         int resource_offset,	/* unused */
1332         XtArgVal *value )
1333 {
1334             XmString        data ;
1335             Arg             al[1] ;
1336 
1337     XtSetArg( al[0], XmNitems, &data) ;
1338     XtGetValues( FS_DirList( fs), al, 1) ;
1339     *value = (XtArgVal) data ;
1340 }
1341 /*****************************************************************/
1342 /*ARGSUSED*/
1343 void
_XmFileSelectionBoxGetDirListItemCount(Widget fs,int resource_offset,XtArgVal * value)1344 _XmFileSelectionBoxGetDirListItemCount(
1345         Widget fs,
1346         int resource_offset,	/* unused */
1347         XtArgVal *value )
1348 {
1349             XmString        data ;
1350             Arg             al[1] ;
1351 
1352     XtSetArg( al[0], XmNitemCount, &data) ;
1353     XtGetValues( FS_DirList( fs), al, 1) ;
1354     *value = (XtArgVal) data ;
1355 }
1356 /*****************************************************************/
1357 /*ARGSUSED*/
1358 void
_XmFileSelectionBoxGetListItems(Widget fs,int resource_offset,XtArgVal * value)1359 _XmFileSelectionBoxGetListItems(
1360         Widget fs,
1361         int resource_offset,	/* unused */
1362         XtArgVal *value )
1363 {
1364             XmString        data ;
1365             Arg             al[1] ;
1366 
1367     if(    FS_StateFlags( fs) & XmFS_NO_MATCH    )
1368     {
1369         *value = (XtArgVal) NULL ;
1370         }
1371     else
1372     {   XtSetArg( al[0], XmNitems, &data) ;
1373         XtGetValues( SB_List( fs), al, 1) ;
1374         *value = (XtArgVal) data ;
1375         }
1376 }
1377 /*****************************************************************/
1378 /*ARGSUSED*/
1379 void
_XmFileSelectionBoxGetListItemCount(Widget fs,int resource_offset,XtArgVal * value)1380 _XmFileSelectionBoxGetListItemCount(
1381         Widget fs,
1382         int resource_offset,	/* unused */
1383         XtArgVal *value )
1384 {
1385             XmString        data ;
1386             Arg             al[1] ;
1387 /****************/
1388 
1389     if(    FS_StateFlags( fs) & XmFS_NO_MATCH    )
1390     {
1391         *value = (XtArgVal) 0 ;
1392         }
1393     else
1394     {   XtSetArg( al[0], XmNitemCount, &data) ;
1395         XtGetValues( SB_List( fs), al, 1) ;
1396         *value = (XtArgVal) data ;
1397         }
1398 }
1399 /*****************************************************************/
1400 /*ARGSUSED*/
1401 void
_XmFileSelectionBoxGetDirMask(Widget fs,int resource_offset,XtArgVal * value)1402 _XmFileSelectionBoxGetDirMask(
1403         Widget fs,
1404         int resource_offset,	/* unused */
1405         XtArgVal *value )
1406 {
1407             String          filterText ;
1408             XmString        data ;
1409 
1410     filterText = XmTextFieldGetString( FS_FilterText(fs)) ;
1411     data = XmStringGenerate(filterText, XmFONTLIST_DEFAULT_TAG,
1412 			    XmCHARSET_TEXT, NULL) ;
1413     *value = (XtArgVal) data ;
1414     XtFree( filterText) ;
1415 
1416     return ;
1417 }
1418 
1419 /****************************************************************/
1420 static Widget
GetActiveText(XmFileSelectionBoxWidget fsb,XEvent * event)1421 GetActiveText(
1422         XmFileSelectionBoxWidget fsb,
1423         XEvent *event )
1424 {
1425             Widget          activeChild = NULL ;
1426 /****************/
1427 
1428     if(    _XmGetFocusPolicy( (Widget) fsb) == XmEXPLICIT    )
1429     {
1430         if(    (fsb->manager.active_child == SB_Text( fsb))
1431             || (fsb->manager.active_child == FS_FilterText( fsb))    )
1432         {
1433             activeChild = fsb->manager.active_child ;
1434             }
1435         }
1436     else
1437     {
1438         if(    SB_Text( fsb)
1439             && (XtWindow( SB_Text( fsb))
1440                                    == ((XKeyPressedEvent *) event)->window)   )
1441         {   activeChild = SB_Text( fsb) ;
1442             }
1443         else
1444         {   if(    FS_FilterText( fsb)
1445                 && (XtWindow( FS_FilterText( fsb))
1446                                   ==  ((XKeyPressedEvent *) event)->window)   )
1447             {   activeChild = FS_FilterText( fsb) ;
1448                 }
1449             }
1450         }
1451     return( activeChild) ;
1452     }
1453 /****************************************************************/
1454 /*ARGSUSED*/
1455 void
_XmFileSelectionBoxUpOrDown(Widget wid,XEvent * event,String * argv,Cardinal * argc)1456 _XmFileSelectionBoxUpOrDown(
1457         Widget wid,
1458         XEvent *event,
1459         String *argv,
1460         Cardinal *argc )	/* unused */
1461 {
1462             XmFileSelectionBoxWidget fsb = (XmFileSelectionBoxWidget) wid ;
1463             int	            visible ;
1464             int	            top ;
1465             int	            key_pressed ;
1466             Widget	    list ;
1467             int	*           position ;
1468             int	            count ;
1469             Widget          activeChild ;
1470             Arg             av[5] ;
1471             Cardinal        ac ;
1472 /****************/
1473 
1474     if(    !(activeChild = GetActiveText( fsb, event))    )
1475     {   return ;
1476         }
1477     if(    activeChild == SB_Text( fsb)    )
1478     {
1479         if(    FS_StateFlags( fsb) & XmFS_NO_MATCH    )
1480         {   return ;
1481             }
1482         list = SB_List( fsb) ;
1483         position = &SB_ListSelectedItemPosition( fsb) ;
1484         }
1485     else /* activeChild == FS_FilterText( fsb) */
1486     {   list = fsb->file_selection_box.dir_list ;
1487         position = &FS_DirListSelectedItemPosition( fsb) ;
1488         }
1489     if(    !list    )
1490     {   return ;
1491         }
1492     ac = 0 ;
1493     XtSetArg( av[ac], XmNitemCount, &count) ; ++ac ;
1494     XtSetArg( av[ac], XmNtopItemPosition, &top) ; ++ac ;
1495     XtSetArg( av[ac], XmNvisibleItemCount, &visible) ; ++ac ;
1496     XtGetValues( (Widget) list, av, ac) ;
1497 
1498     if(    !count    )
1499     {   return ;
1500         }
1501     key_pressed = atoi( *argv) ;
1502 
1503     if(    *position == 0    )
1504     {   /*  No selection, so select first item.
1505         */
1506         XmListSelectPos( list, ++*position, True) ;
1507         }
1508     else
1509     {   if(    !key_pressed && (*position > 1)    )
1510         {   /*  up  */
1511             XmListDeselectPos( list, *position) ;
1512             XmListSelectPos( list, --*position, True) ;
1513             }
1514         else
1515         {   if(    (key_pressed == 1) && (*position < count)    )
1516             {   /*  down  */
1517                 XmListDeselectPos( list, *position) ;
1518                 XmListSelectPos( list, ++*position, True) ;
1519                 }
1520             else
1521             {   if(    key_pressed == 2    )
1522                 {   /*  home  */
1523                     XmListDeselectPos( list, *position) ;
1524                     *position = 1 ;
1525                     XmListSelectPos( list, *position, True) ;
1526                     }
1527                 else
1528                 {   if(    key_pressed == 3    )
1529                     {   /*  end  */
1530                         XmListDeselectPos( list, *position) ;
1531                         *position = count ;
1532                         XmListSelectPos( list, *position, True) ;
1533                         }
1534                     }
1535                 }
1536             }
1537         }
1538     if(    top > *position    )
1539     {   XmListSetPos( list, *position) ;
1540         }
1541     else
1542     {   if(    (top + visible) <= *position    )
1543         {   XmListSetBottomPos( list, *position) ;
1544             }
1545         }
1546     return ;
1547 }
1548 /****************************************************************/
1549 void
_XmFileSelectionBoxRestore(Widget wid,XEvent * event,String * argv,Cardinal * argc)1550 _XmFileSelectionBoxRestore(
1551         Widget wid,
1552         XEvent *event,
1553         String *argv,
1554         Cardinal *argc )
1555 {
1556             XmFileSelectionBoxWidget fsb = (XmFileSelectionBoxWidget) wid ;
1557             String          itemString ;
1558             String          dir ;
1559             String          mask ;
1560             int             dirLen ;
1561             int             maskLen ;
1562             Widget          activeChild ;
1563 /****************/
1564 
1565     if(    !(activeChild = GetActiveText( fsb, event))    )
1566     {   return ;
1567         }
1568     if(    activeChild == SB_Text( fsb)    )
1569     {   _XmSelectionBoxRestore( (Widget) fsb, event, argv, argc) ;
1570         }
1571     else /* activeChild == FS_FilterText( fsb) */
1572     {   /* Should do this stuff entirely with XmStrings when the text
1573         *   widget supports it.
1574         */
1575         if(    (dir = _XmStringGetTextConcat( FS_Directory( fsb))) != NULL    )
1576         {
1577             dirLen = strlen( dir) ;
1578 
1579             if(   (mask = _XmStringGetTextConcat( FS_Pattern( fsb))) != NULL   )
1580             {
1581                 maskLen = strlen( mask) ;
1582                 itemString = XtMalloc( dirLen + maskLen + 1) ;
1583                 strcpy( itemString, dir) ;
1584                 strcpy( &itemString[dirLen], mask) ;
1585                 XmTextFieldSetString( FS_FilterText( fsb), itemString) ;
1586                 XmTextFieldSetCursorPosition( FS_FilterText( fsb),
1587 			    XmTextFieldGetLastPosition( FS_FilterText( fsb))) ;
1588                 XtFree( itemString) ;
1589                 XtFree( mask) ;
1590                 }
1591             XtFree( dir) ;
1592             }
1593         }
1594     return ;
1595 }
1596 /*****************************************************************/
1597 XmGeoMatrix
_XmFileSBGeoMatrixCreate(Widget wid,Widget instigator,XtWidgetGeometry * desired)1598 _XmFileSBGeoMatrixCreate(
1599         Widget wid,
1600         Widget instigator,
1601         XtWidgetGeometry *desired )
1602 {
1603   return (*(xmFileSelectionBoxClassRec.bulletin_board_class
1604 	                      .geo_matrix_create))( wid, instigator, desired) ;
1605 }
1606 /****************************************************************/
1607 Boolean
_XmFileSelectionBoxNoGeoRequest(XmGeoMatrix geoSpec)1608 _XmFileSelectionBoxNoGeoRequest(
1609         XmGeoMatrix geoSpec )
1610 {
1611 
1612     if(    BB_InSetValues( geoSpec->composite)
1613         && (XtClass( geoSpec->composite) == xmFileSelectionBoxWidgetClass)    )
1614     {
1615         return( TRUE) ;
1616         }
1617     return( FALSE) ;
1618 }
1619 /****************************************************************/
1620 void
_XmFileSelectionBoxFocusMoved(Widget wid,XtPointer client_data,XtPointer data)1621 _XmFileSelectionBoxFocusMoved(
1622         Widget wid,
1623         XtPointer client_data,
1624         XtPointer data )
1625 {
1626   (*(xmFileSelectionBoxClassRec.bulletin_board_class.focus_moved_proc))(
1627 						      wid, client_data, data );
1628 }
1629 
1630 XmHeap
_XmHeapCreate(int segment_size)1631 _XmHeapCreate(
1632         int segment_size )
1633 {
1634     XmHeap	heap;
1635 
1636     heap = XtNew(XmHeapRec);
1637     heap->start = NULL;
1638     heap->segment_size = segment_size;
1639     heap->bytes_remaining = 0;
1640     return heap;
1641 }
1642 
1643 char *
_XmHeapAlloc(XmHeap heap,Cardinal bytes)1644 _XmHeapAlloc(
1645         XmHeap heap,
1646         Cardinal bytes )
1647 {
1648     register char* heap_loc;
1649     if (heap == NULL) return XtMalloc(bytes);
1650     if (heap->bytes_remaining < bytes) {
1651 	if ((bytes + sizeof(char*)) >= (heap->segment_size>>1)) {
1652 	    /* preserve current segment; insert this one in front */
1653 	    heap_loc = XtMalloc(bytes + sizeof(char*));
1654 	    if (heap->start) {
1655 		*(char**)heap_loc = *(char**)heap->start;
1656 		*(char**)heap->start = heap_loc;
1657 	    }
1658 	    else {
1659 		*(char**)heap_loc = NULL;
1660 		heap->start = heap_loc;
1661 	    }
1662 	    return heap_loc;
1663 	}
1664 	/* else discard remainder of this segment */
1665 	heap_loc = XtMalloc((unsigned)heap->segment_size);
1666 	*(char**)heap_loc = heap->start;
1667 	heap->start = heap_loc;
1668 	heap->current = heap_loc + sizeof(char*);
1669 	heap->bytes_remaining = heap->segment_size - sizeof(char*);
1670     }
1671 #ifdef WORD64
1672     /* round to nearest 8-byte boundary */
1673     bytes = (bytes + 7) & (~7);
1674 #else
1675     /* round to nearest 4-byte boundary */
1676     bytes = (bytes + 3) & (~3);
1677 #endif /* WORD64 */
1678     heap_loc = heap->current;
1679     heap->current += bytes;
1680     heap->bytes_remaining -= bytes; /* can be negative, if rounded */
1681     return heap_loc;
1682 }
1683 
1684 void
_XmHeapFree(XmHeap heap)1685 _XmHeapFree(
1686         XmHeap heap )
1687 {
1688     char* segment = heap->start;
1689     while (segment != NULL) {
1690 	char* next_segment = *(char**)segment;
1691 	XtFree(segment);
1692 	segment = next_segment;
1693     }
1694     heap->start = NULL;
1695     heap->bytes_remaining = 0;
1696 }
1697 
1698 typedef struct {
1699     Boolean	*traversal_on;
1700     Boolean	*have_traversal;
1701     Boolean	*sensitive;
1702     Boolean	*ancestor_sensitive;
1703     Boolean	*mapped_when_managed;
1704     Boolean	*highlighted;
1705     Boolean	*managed;
1706     unsigned char *navigation_type;
1707 }*WidgetNavigPtrs;
1708 
1709 void
_XmGetWidgetNavigPtrs(Widget widget,WidgetNavigPtrs np)1710 _XmGetWidgetNavigPtrs(
1711         Widget widget,
1712         WidgetNavigPtrs np )
1713 {
1714     np->sensitive 		= &(widget->core.sensitive);
1715     np->ancestor_sensitive	= &(widget->core.ancestor_sensitive);
1716     np->managed			= &(widget->core.managed);
1717 
1718     if (XmIsManager(widget))
1719       {
1720 	  XmManagerWidget w = (XmManagerWidget) widget;
1721 
1722 	  np->traversal_on 		= &(w->manager.traversal_on);
1723 	  np->mapped_when_managed 	= &(w->core.mapped_when_managed);
1724 	  np->navigation_type	 	= &(w->manager.navigation_type);
1725 	  np->highlighted		= NULL;
1726 	  np->have_traversal		= NULL;
1727       }
1728     else if (XmIsPrimitive(widget))
1729       {
1730 	  XmPrimitiveWidget w = (XmPrimitiveWidget) widget;
1731 
1732 	  np->traversal_on 		= &(w->primitive.traversal_on);
1733 	  np->mapped_when_managed 	= &(w->core.mapped_when_managed);
1734 	  np->navigation_type	 	= &(w->primitive.navigation_type);
1735 	  np->highlighted		= &(w->primitive.highlighted);
1736 	  np->have_traversal		= &(w->primitive.have_traversal);
1737       }
1738     else if (XmIsGadget(widget))
1739       {
1740 	  XmGadget w = (XmGadget) widget;
1741 
1742 	  np->traversal_on 		= &(w->gadget.traversal_on);
1743 	  np->mapped_when_managed 	= NULL;
1744 	  np->navigation_type	 	= &(w->gadget.navigation_type);
1745 	  np->highlighted		= &(w->gadget.highlighted);
1746 	  np->have_traversal		= &(w->gadget.have_traversal);
1747       }
1748     else /* it must be an object or foriegn widget */
1749       {
1750 	  np->traversal_on 		= NULL;
1751 	  np->mapped_when_managed 	= NULL;
1752 	  np->navigation_type	 	= NULL;
1753 	  np->highlighted		= NULL;
1754 	  np->have_traversal		= NULL;
1755       }
1756 }
1757 
1758 void
GetWidgetNavigPtrs(Widget widget,WidgetNavigPtrs np)1759 GetWidgetNavigPtrs(
1760         Widget widget,
1761         WidgetNavigPtrs np )
1762 {
1763   _XmGetWidgetNavigPtrs( widget, np) ;
1764 }
1765 
1766 Boolean
_XmFindTraversablePrim(CompositeWidget tabGroup)1767 _XmFindTraversablePrim(
1768         CompositeWidget tabGroup )
1769 {
1770   Widget first = _XmNavigate( (Widget) tabGroup, XmTRAVERSE_CURRENT) ;
1771 
1772   return first ? (XmCONTROL_NAVIGABLE == _XmGetNavigability( first)) : FALSE ;
1773 }
1774 
1775 typedef enum {
1776     HereOnly,
1777     AboveOnly,
1778     BelowOnly,
1779     AboveAndBelow
1780 } XmNavigTestType;
1781 
1782 /*ARGSUSED*/
1783 Boolean
_XmPathIsTraversable(Widget widget,int navType,XmNavigTestType testType,XRectangle * visRect)1784 _XmPathIsTraversable(
1785         Widget widget,
1786 #if NeedWidePrototypes
1787         int navType,
1788 #else
1789         XmNavigationType navType,
1790 #endif /* NeedWidePrototypes */
1791         XmNavigTestType testType, /* unused */
1792         XRectangle *visRect )	/* unused */
1793 {
1794   return _XmFindTraversablePrim( (CompositeWidget) widget) ;
1795 }
1796 
1797 /*ARGSUSED*/
1798 void
SetMwmStuff(XmVendorShellExtObject ove,XmVendorShellExtObject nve)1799 SetMwmStuff(
1800         XmVendorShellExtObject ove, /* unused */
1801         XmVendorShellExtObject nve ) /* unused */
1802 {
1803   /* Sorry Charlie, this doesn't work any more.
1804    */
1805   return ;
1806 }
1807 
1808 /*ARGSUSED*/
1809 void
_XmBB_GetDialogTitle(Widget bb,int resource,XtArgVal * value)1810 _XmBB_GetDialogTitle(
1811         Widget bb,
1812         int resource,		/* unused */
1813         XtArgVal *value)
1814 {
1815   XmString data = XmStringCopy((XmString) ((XmBulletinBoardWidget) bb)
1816                                                 ->bulletin_board.dialog_title);
1817   *value = (XtArgVal) data ;
1818 }
1819 
1820 static Boolean
_isISO(String charset)1821 _isISO(
1822         String charset )
1823 {
1824   register int	i;
1825 
1826   if (strlen(charset) == 5)
1827     {
1828       for (i = 0; i < 5; i++)
1829 	{
1830 	  if (!isdigit((unsigned char)charset[i])) return (False);
1831 	}
1832       return (True);
1833     }
1834   else return (False);
1835 }
1836 
1837 char *
_XmCharsetCanonicalize(String charset)1838 _XmCharsetCanonicalize(
1839         String charset )
1840 {
1841   String	new_s;
1842   int		len;
1843 
1844   /* ASCII -> ISO8859-1 */
1845   if (!strcmp(charset, "ASCII"))
1846     {
1847       len = strlen(XmSTRING_ISO8859_1);
1848 
1849       new_s = XtMalloc(len + 1);
1850       strncpy(new_s, XmSTRING_ISO8859_1, len);
1851       new_s[len] = '\0';
1852     }
1853   else if (_isISO(charset))
1854     {
1855       /* "ISO####-#" */
1856       new_s = XtMalloc(3 + 4 + 1 + 1 + 1);
1857       sprintf(new_s, "ISO%s", charset);
1858       new_s[7] = '-';
1859       new_s[8] = charset[4];
1860       new_s[9] = '\0';
1861     }
1862   else
1863     /* Anything else is copied but not modified. */
1864     {
1865       len = strlen(charset);
1866 
1867       new_s = XtMalloc(len + 1);
1868       strncpy(new_s, charset, len);
1869       new_s[len] = '\0';
1870     }
1871   return (new_s);
1872 }
1873 
1874 /*ARGSUSED*/
1875 Widget
_XmGetDisplayObject(Widget shell,ArgList args,Cardinal * num_args)1876 _XmGetDisplayObject(Widget shell,
1877 		    ArgList args, /* unused */
1878 		    Cardinal *num_args)	/* unused */
1879 {
1880   return XmGetXmDisplay( XtDisplay( shell)) ;
1881 }
1882 
1883 /*ARGSUSED*/
1884 Widget
_XmGetScreenObject(Widget shell,ArgList args,Cardinal * num_args)1885 _XmGetScreenObject(Widget shell,
1886 		   ArgList args, /* unused */
1887 		   Cardinal *num_args) /* unused */
1888 {
1889   return XmGetXmScreen( XtScreen( shell)) ;
1890 }
1891 
1892 /*ARGSUSED*/
1893 XmWrapperData
_XmGetWrapperData(WidgetClass w_class)1894 _XmGetWrapperData (WidgetClass w_class)	/* unused */
1895 {
1896   /* If somebody actually used this, they are probably in for a surprise.
1897    */
1898   return (XmWrapperData) XtCalloc( 1, sizeof( XmWrapperDataRec)) ;
1899 }
1900 
1901 void
_XmLowerCase(register char * source,register char * dest)1902 _XmLowerCase(
1903          register char *source,
1904          register char *dest )
1905 {
1906     register char ch;
1907     int i;
1908 
1909     for (i = 0; (ch = *source) != 0 && i < 999; source++, dest++, i++) {
1910     	if ('A' <= ch && ch <= 'Z')
1911 	    *dest = ch - 'A' + 'a';
1912 	else
1913 	    *dest = ch;
1914     }
1915     *dest = 0;
1916 }
1917 
dump_external()1918 void dump_external(){}
dump_fontlist_cache()1919 void dump_fontlist_cache(){}
dump_fontlist()1920 void dump_fontlist(){}
dump_internal()1921 void dump_internal(){}
1922 
1923 void
_XmButtonPopdownChildren(XmRowColumnWidget rowcol)1924 _XmButtonPopdownChildren (XmRowColumnWidget rowcol)
1925 {
1926   if (RC_PopupPosted(rowcol))
1927     {
1928       (*(((XmMenuShellClassRec *)xmMenuShellWidgetClass)->
1929                      menu_shell_class.popdownEveryone))(RC_PopupPosted(rowcol),
1930 							NULL,NULL,NULL);
1931     }
1932 }
1933 
1934 void
_XmInitializeMenuCursor(void)1935 _XmInitializeMenuCursor (void)
1936 {
1937   /* It's unlucky to hit this one...
1938    */
1939 }
1940 
1941 /*ARGSUSED*/
1942 void
_XmCreateMenuCursor(Widget m)1943 _XmCreateMenuCursor (Widget m)	/* unused */
1944 {
1945   /* ... or this one.
1946    */
1947 }
1948 XContext _XmMenuCursorContext = 0; /* This won't help much either. */
1949 
1950 
1951 static Boolean simplistic_transient_flag ;
1952 
1953 /*ARGSUSED*/
1954 Boolean
_XmGetTransientFlag(Widget w)1955 _XmGetTransientFlag (Widget w)	/* unused */
1956 {
1957   return simplistic_transient_flag ;
1958 }
1959 
1960 /*ARGSUSED*/
1961 void
_XmSetTransientFlag(Widget w,Boolean value)1962 _XmSetTransientFlag (Widget w,	/* unused */
1963 		     Boolean value)
1964 {
1965   /* In a very simple case, this might work.  To implement more of this
1966    *  for BC would probably not help an application which was invasive
1967    *  enough to use this flag in the first place.
1968    */
1969   simplistic_transient_flag = value ;
1970 }
1971 
1972 /*ARGSUSED*/
1973 Boolean
_XmQueryPixmapCache(Screen * screen,char * image_name,Pixel foreground,Pixel background)1974 _XmQueryPixmapCache (Screen *screen, /* unused */
1975 		     char *image_name, /* unused */
1976 		     Pixel foreground, /* unused */
1977 		     Pixel background) /* unused */
1978 {
1979   /* Simple case: return FALSE (creating new pixmap will find it in cache).
1980    */
1981   return FALSE ;
1982 }
1983 
1984 /*ARGSUSED*/
1985 void
_XmRC_GetLabelString(XmRowColumnWidget rc,XrmQuark resource,XtArgVal * value)1986 _XmRC_GetLabelString(
1987             XmRowColumnWidget rc,
1988             XrmQuark        resource, /* unused */
1989             XtArgVal *      value)
1990 {
1991   *value = (XtArgVal) XmStringCopy(RC_OptionLabel(rc));
1992 }
1993 
1994 /*ARGSUSED*/
1995 void
_XmRC_GetMenuAccelerator(XmRowColumnWidget rc,XrmQuark resource,XtArgVal * value)1996 _XmRC_GetMenuAccelerator(
1997             XmRowColumnWidget rc,
1998             XrmQuark        resource, /* unused */
1999             XtArgVal *      value)
2000 {
2001   String        data ;
2002 
2003   if (rc->row_column.menu_accelerator != NULL) {
2004      data = (String)XtMalloc(strlen(RC_MenuAccelerator(rc)) + 1);
2005      strcpy(data, RC_MenuAccelerator(rc));
2006      *value = (XtArgVal) data ;
2007    }
2008   else *value = (XtArgVal) NULL;
2009 }
2010 
2011 /*ARGSUSED*/
2012 void
_XmRC_GetMnemonicCharSet(XmRowColumnWidget rc,XrmQuark resource,XtArgVal * value)2013 _XmRC_GetMnemonicCharSet(
2014             XmRowColumnWidget rc,
2015             XrmQuark        resource, /* unused */
2016             XtArgVal *      value)
2017 {
2018   Widget	label = XmOptionLabelGadget((Widget)rc);
2019 
2020   if (label)
2021     {
2022       int n = 0;
2023       Arg           al[1] ;
2024       String        data ;
2025 
2026       XtSetArg(al[n], XmNmnemonicCharSet, &data); n++;
2027       XtGetValues(label, al, n);
2028       *value = (XtArgVal) data ;
2029     }
2030   else
2031     {
2032       *value = (XtArgVal) NULL;
2033     }
2034 }
2035 
2036 /*ARGSUSED*/
2037 void
_XmScaleGetTitleString(Widget wid,int resource,XtArgVal * value)2038 _XmScaleGetTitleString(
2039         Widget wid,
2040         int resource,		/* unused */
2041         XtArgVal *value)
2042 {
2043   XmScaleWidget scale = (XmScaleWidget) wid ;
2044 
2045   if (scale->scale.title == NULL) {
2046     *value = (XtArgVal) NULL ;
2047   } else {
2048     Arg           al[1] ;
2049 
2050     XtSetArg (al[0], XmNlabelString, value);
2051     XtGetValues (scale->composite.children[0], al, 1);
2052   }
2053 }
2054 
2055 /*ARGSUSED*/
2056 void
_XmTextFieldDestinationVisible(Widget w,int turn_on)2057 _XmTextFieldDestinationVisible(
2058         Widget w,		/* unused */
2059 #if NeedWidePrototypes
2060         int turn_on )		/* unused */
2061 #else
2062         Boolean turn_on )	/* unused */
2063 #endif /* NeedWidePrototypes */
2064 {
2065   return ;
2066 }
2067 
2068 int
_XmTextGetBaseLine(Widget widget)2069 _XmTextGetBaseLine(
2070         Widget widget )
2071 {
2072   return XmTextGetBaseline( widget) ;
2073 }
2074 
2075 /*ARGSUSED*/
2076 void
_XmTextOutLoadGCsAndRecolorCursors(XmTextWidget old_tw,XmTextWidget new_tw)2077 _XmTextOutLoadGCsAndRecolorCursors(XmTextWidget old_tw, /* unused */
2078 				   XmTextWidget new_tw)	/* unused */
2079 {
2080   return ;
2081 }
2082 
2083 _XmConst char *_XmTextEventBindings1 = _XmTextIn_XmTextEventBindings1 ;
2084 _XmConst char *_XmTextEventBindings2 = _XmTextIn_XmTextEventBindings2 ;
2085 _XmConst char *_XmTextEventBindings3 = _XmTextIn_XmTextEventBindings3 ;
2086 
2087 
2088 /************************************************************************
2089  *
2090  *	The following are the gadget traversal action routines
2091  *      DD; was in Manager.c but not used anywhere.
2092  ************************************************************************/
2093 /*ARGSUSED*/
2094 void
_XmDoGadgetTraversal(XmManagerWidget mw,XEvent * event,int direction)2095 _XmDoGadgetTraversal(
2096         XmManagerWidget mw,
2097         XEvent *event,		/* unused */
2098         int direction )
2099 {
2100   Widget ref_wid = mw->manager.active_child ;
2101 
2102   if(    ref_wid == NULL    )
2103     {
2104       ref_wid = (Widget) mw ;
2105     }
2106   _XmMgrTraversal( ref_wid, (XmTraversalDirection) direction) ;
2107 }
2108 
2109 
2110 
2111 /**********************************************************************
2112  *
2113  *  _XmBuildManagerResources
2114  *	Build up the manager's synthetic and constraint synthetic
2115  *	resource processing list by combining the super classes with
2116  *	this class.
2117  *  DD: This one should is now static in Manager.c
2118  *
2119  **********************************************************************/
2120 void
_XmBuildManagerResources(WidgetClass c)2121 _XmBuildManagerResources(
2122         WidgetClass c )
2123 {
2124         XmManagerWidgetClass wc = (XmManagerWidgetClass) c ;
2125 	XmManagerWidgetClass sc;
2126 
2127 	sc = (XmManagerWidgetClass) wc->core_class.superclass;
2128 
2129 	_XmInitializeSyntheticResources(wc->manager_class.syn_resources,
2130 		wc->manager_class.num_syn_resources);
2131 
2132 	_XmInitializeSyntheticResources(
2133 		wc->manager_class.syn_constraint_resources,
2134 		wc->manager_class.num_syn_constraint_resources);
2135 
2136 	if (sc == (XmManagerWidgetClass) constraintWidgetClass) return;
2137 
2138 	_XmBuildResources (&(wc->manager_class.syn_resources),
2139 		&(wc->manager_class.num_syn_resources),
2140 		sc->manager_class.syn_resources,
2141 		sc->manager_class.num_syn_resources);
2142 
2143 	_XmBuildResources (&(wc->manager_class.syn_constraint_resources),
2144 		&(wc->manager_class.num_syn_constraint_resources),
2145 		sc->manager_class.syn_constraint_resources,
2146 		sc->manager_class.num_syn_constraint_resources);
2147 }
2148 
2149 
2150 /** Gadget synthetic hook from Manager.c. Are not static in Gadget.c **/
2151 
2152 /*ARGSUSED*/
2153 void
_XmGetHighlightColor(Widget w,int offset,XtArgVal * value)2154 _XmGetHighlightColor(
2155         Widget w,
2156 	int offset,  /* unused */
2157 	XtArgVal *value )
2158 {
2159 	XmManagerWidget mw = (XmManagerWidget) XtParent(w);
2160 
2161 	*value = (XtArgVal) mw->manager.highlight_color;
2162 }
2163 
2164 /*ARGSUSED*/
2165 void
_XmGetTopShadowColor(Widget w,int offset,XtArgVal * value)2166 _XmGetTopShadowColor(
2167         Widget w,
2168 	int offset,  /* unused */
2169 	XtArgVal *value )
2170 {
2171 	XmManagerWidget mw = (XmManagerWidget) XtParent(w);
2172 
2173 	*value = (XtArgVal) mw->manager.top_shadow_color;
2174 }
2175 
2176 /*ARGSUSED*/
2177 void
_XmGetBottomShadowColor(Widget w,int offset,XtArgVal * value)2178 _XmGetBottomShadowColor(
2179         Widget w,
2180 	int offset,  /* unused */
2181 	XtArgVal *value )
2182 {
2183 	XmManagerWidget mw = (XmManagerWidget) XtParent(w);
2184 
2185 	*value = (XtArgVal) mw->manager.bottom_shadow_color;
2186 }
2187 
2188 
2189 
2190 /************************************************************************
2191  *
2192  *  The border highlighting and unhighlighting routines.
2193  *
2194  *  These routines were originally in Primitive.c but not used anywhere.
2195  *
2196  ************************************************************************/
2197 
2198 void
_XmHighlightBorder(Widget w)2199 _XmHighlightBorder(
2200         Widget w )
2201 {
2202     if(    XmIsPrimitive( w)    ) {
2203         (*(xmPrimitiveClassRec.primitive_class.border_highlight))( w) ;
2204     }  else  {
2205 	if(    XmIsGadget( w)    ) {
2206 	    (*(xmGadgetClassRec.gadget_class.border_highlight))( w) ;
2207 	}
2208     }
2209     return ;
2210 }
2211 
2212 void
_XmUnhighlightBorder(Widget w)2213 _XmUnhighlightBorder(
2214         Widget w )
2215 {
2216     if(    XmIsPrimitive( w)    )
2217     {
2218         (*(xmPrimitiveClassRec.primitive_class.border_unhighlight))( w) ;
2219         }
2220     else
2221     {   if(    XmIsGadget( w)    )
2222         {
2223             (*(xmGadgetClassRec.gadget_class.border_unhighlight))( w) ;
2224             }
2225         }
2226     return ;
2227     }
2228 
2229 /************************************************************************
2230  *
2231  *  This routine was global in Primitive.c. It is now static.
2232  *
2233  ************************************************************************/
2234 
2235 void
_XmBuildPrimitiveResources(WidgetClass c)2236 _XmBuildPrimitiveResources(
2237         WidgetClass c )
2238 {
2239         XmPrimitiveWidgetClass wc = (XmPrimitiveWidgetClass) c ;
2240 	XmPrimitiveWidgetClass sc;
2241 
2242 	sc = (XmPrimitiveWidgetClass) wc->core_class.superclass;
2243 
2244 	_XmInitializeSyntheticResources(wc->primitive_class.syn_resources,
2245 		wc->primitive_class.num_syn_resources);
2246 
2247 	if (sc == (XmPrimitiveWidgetClass) widgetClass) return;
2248 
2249 	_XmBuildResources (&(wc->primitive_class.syn_resources),
2250 		&(wc->primitive_class.num_syn_resources),
2251 		sc->primitive_class.syn_resources,
2252 		sc->primitive_class.num_syn_resources);
2253 }
2254 
2255 
2256