dtfile: Add missing prototypes
[oweals/cde.git] / cde / programs / dtwm / WmIconBox.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* 
24  * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC. 
25  * ALL RIGHTS RESERVED 
26 */ 
27 /* 
28  * Motif Release 1.2.4
29 */ 
30 #ifdef REV_INFO
31 #ifndef lint
32 static char rcsid[] = "$TOG: WmIconBox.c /main/7 1999/05/20 16:35:12 mgreess $"
33 #endif
34 #endif
35 /*
36  * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 Hewlett-Packard Company
37  * (c) Copyright 1993, 1994 International Business Machines Corp.
38  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39  * (c) Copyright 1993, 1994 Novell, Inc.
40  */
41
42 /*
43  * Included Files:
44  */
45
46 #include "WmGlobal.h"
47 #ifdef WSM
48 #include "WmHelp.h"
49 #endif /* WSM */
50 #include <X11/StringDefs.h>
51 #include <X11/Intrinsic.h>
52 #include <X11/Shell.h>
53 #include <X11/Xutil.h>
54 #include <X11/Vendor.h>
55
56 #include <X11/keysymdef.h>
57 #include <X11/keysym.h>
58
59
60 #include <Xm/Xm.h>
61 #include <Xm/DialogS.h>
62 #include <Xm/Frame.h>
63 #include <Xm/Label.h>
64 #include <Xm/PushB.h>
65 #include <Xm/DrawnB.h>
66 #include <Xm/ScrolledW.h>
67 #include <Xm/BulletinB.h>
68 #include <Xm/ToggleB.h>
69
70 #define MWM_NEED_IIMAGE
71 #define MWM_NEED_GREYED75
72 #define MWM_NEED_SLANT2
73 #include "WmIBitmap.h"
74
75 #include "WmResNames.h"
76
77 #include <stdio.h>
78
79 /*
80  * include extern functions
81  */
82
83 #include "WmIconBox.h"
84 #include "WmCDInfo.h"
85 #include "WmError.h"
86 #include "WmEvent.h"
87 #include "WmFunction.h"
88 #include "WmIDecor.h"
89 #include "WmIPlace.h"
90 #include "WmImage.h"
91 #ifdef PANELIST
92 #include "WmPanelP.h"  /* for typedef in WmManage.h */
93 #endif /* PANELIST */
94 #include "WmManage.h"
95 #include "WmMenu.h"
96 #include "WmResParse.h"
97 #include "WmResource.h"
98 #include "WmWinInfo.h"
99 #ifdef WSM
100 #include "WmWrkspace.h"
101 #endif /* WSM */
102
103 #ifndef MAX
104 #define MAX(a,b) ((a)>(b)?(a):(b))
105 #endif
106
107
108
109 /*
110  * Global Variables:
111  */
112
113
114 Pixel select_color;
115 Pixmap greyedPixmap;
116
117 int frameShadowThickness;
118 int firstTime = 1;
119 Cardinal insertPosition = 0;
120 #define    DEFAULT_ICON_BOX_TITLE "Icons"
121 Const char *szhorizontal = "horizontal";
122 Const char *szvertical = "vertical";
123
124 \f
125 /*************************************<->*************************************
126  *
127  *  InitIconBox (pSD)
128  *
129  *
130  *  Description:
131  *  -----------
132  *  This function controls creation of icon boxes
133  *
134  *
135  *************************************<->***********************************/
136 void InitIconBox (WmScreenData *pSD)
137
138 {
139 #ifdef WSM
140     int iws;
141 #endif /* WSM */
142     /*
143      * Start the process of making the icon boxes
144      */
145
146
147
148 #ifdef WSM
149     /*
150      * Manage a separate icon box in every workspace
151      * on this screen.
152      */
153     for (iws = 0; iws < pSD->numWorkspaces; iws++)
154     {
155         AddIconBoxForWorkspace (&pSD->pWS[iws]);
156     }
157
158 #else /* WSM */
159     ManageWindow (pSD, None, MANAGEW_ICON_BOX);
160 #endif /* WSM */
161
162     if (pSD->fadeNormalIcon)
163     {
164         MakeFadeIconGC (pSD);
165     }
166
167
168 } /* END OF FUNCTION InitIconBox */
169
170 #ifdef WSM
171 \f
172 /*************************************<->*************************************
173  *
174  *  AddIconBoxForWorkspace (pWS)
175  *
176  *
177  *  Description:
178  *  -----------
179  *  This function adds an iconbox to a workspace
180  *
181  *
182  *************************************<->***********************************/
183 void AddIconBoxForWorkspace (WmWorkspaceData *pWS)
184
185 {
186     extern WmWorkspaceData *pIconBoxInitialWS;
187
188     pIconBoxInitialWS = pWS;
189     ManageWindow (pWS->pSD, None, MANAGEW_ICON_BOX);
190
191 } /* END OF FUNCTION AddIconBoxForWorkspace */
192 #endif /* WSM */
193
194 \f
195 /*************************************<->*************************************
196  *
197  *  MakeIconBox (pWS, pCD);
198  *
199  *
200  *  Description:
201  *  -----------
202  *  
203  *
204  *
205  *  Inputs:
206  *  ------
207  *  pWS     = pointer to workspace data
208  *  pCD     =  a pointer to ClientData
209  *
210  * 
211  *  Outputs:
212  *  -------
213  *  
214  *  Return =  (Boolean) True iff successful.
215  *
216  *
217  *  Comments:
218  *  --------
219  *  If fails, frees the ClientData structure pointed to by pCD.
220  * 
221  *************************************<->***********************************/
222
223 Boolean MakeIconBox (WmWorkspaceData *pWS, ClientData *pCD)
224 {
225     IconBoxData *pIBD;
226
227
228     /* 
229      * Make an icon box and return the pCD
230      */
231
232     if (pCD)
233     {
234         if (!(pIBD = (IconBoxData *)XtMalloc (sizeof (IconBoxData))))
235         {
236             /*
237              * We need a pointer to icon box data to add to the
238              * list of icon boxes linked to pWS->pIconBox. If
239              * we can't allocate space we need to free the space
240              * allocated for the ClientData structure 
241              */
242
243             Warning (((char *)GETMESSAGE(36, 1, "Insufficient memory to create icon box data")));
244             XtFree ((char *)pCD);  
245             return (FALSE);  
246         }
247
248         InitializeIconBoxData (pWS, pIBD);
249         InitializeClientData (pCD, pIBD);
250
251         if (!(pIBD->IPD.placeList = 
252             (IconInfo *)XtMalloc (pIBD->IPD.totalPlaces * sizeof (IconInfo))))
253         {
254             Warning (((char *)GETMESSAGE(36, 2, "Insufficient memory to create icon box data")));
255             XtFree ((char *)pIBD);
256             XtFree ((char *)pCD);  
257             return (FALSE);  
258         }
259         memset (pIBD->IPD.placeList, 0, 
260             pIBD->IPD.totalPlaces * sizeof (IconInfo));
261
262         /*
263          * Make  the top level shell for this icon box
264          */
265         MakeShell (pWS, pIBD);
266
267         /*
268          * Make  the scrolled window for this icon box
269          */
270
271         MakeScrolledWindow (pWS, pIBD);
272
273         /*
274          * Make  the row column manager for this icon box
275          */
276         MakeBulletinBoard (pWS, pIBD);
277
278         /*
279          * Realize the widget tree and set client data fields
280          */
281
282         RealizeIconBox (pWS, pIBD, pCD);
283
284         /*
285          * Link the new icon box to list of icon boxes
286          */
287         AddNewBox (pWS, pIBD);
288     }
289     
290     return (TRUE);  
291
292 } /* END OF FUNCTION MakeIconBox */
293
294 #ifdef WSM
295 \f
296 /*************************************<->*************************************
297  *
298  *  DestroyIconBox (pWS)
299  *
300  *
301  *  Description:
302  *  -----------
303  *  Destroys an icon box 
304  *
305  *
306  *  Inputs:
307  *  ------
308  *  pWS     = pointer to workspace data
309  *
310  * 
311  *  Outputs:
312  *  -------
313  *  
314  *  Return =  none
315  *
316  *
317  *  Comments:
318  *  --------
319  *  Used when deleting a workspace
320  *  Should be called AFTER all clients have been removed from the 
321  *  workspace -- there should be no icons in the icon box.
322  * 
323  *************************************<->***********************************/
324
325 void DestroyIconBox (WmWorkspaceData *pWS)
326 {
327     IconBoxData *pIBD;
328
329     pIBD = pWS->pIconBox;
330
331     XtDestroyWidget (pIBD->shellWidget);
332
333     UnManageWindow (pIBD->pCD_iconBox);
334
335     XtFree ((char *) pIBD);
336    
337 } /* END OF FUNCTION DestroyIconBox */
338 #endif /* WSM */
339
340 \f
341 /*************************************<->*************************************
342  *
343  *  MakeShell (pWS, pIBD)
344  *
345  *
346  *  Description:
347  *  -----------
348  *  
349  *
350  *
351  *  Inputs:
352  *  ------
353  *  pWS = pointer to workspace data
354  *
355  *  pIBD  = pointer to IconBoxData
356  *
357  *  XXinput = ...
358  *
359  * 
360  *  Outputs:
361  *  -------
362  *  
363  *  pIBD->shellWidget 
364  *
365  *
366  *  Comments:
367  *  --------
368  *  XXComments ...
369  * 
370  *************************************<->***********************************/
371
372 void MakeShell (WmWorkspaceData *pWS, IconBoxData *pIBD)
373 {
374
375     Arg setArgs[20];
376     int i;
377 #ifdef WSM
378     char *pchIBTitle = NULL;
379 #endif /* WSM */
380
381     /*
382      * Create top level application shell for icon box
383      */
384
385     i=0;
386
387     XtSetArg (setArgs[i], XmNallowShellResize, (XtArgVal)True); i++; 
388     
389     XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal)0); i++; 
390
391     XtSetArg (setArgs[i], XmNkeyboardFocusPolicy, (XtArgVal)XmEXPLICIT); i++;
392
393 #ifndef WSM
394     if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
395     {
396         XtSetArg (setArgs[i], XmNbackground,  
397                   (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
398         XtSetArg (setArgs[i], XmNforeground,  
399                   (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
400     }
401 #else  /* WSM  */
402     if (pWS->pSD->iconBoxTitle)
403     {
404         pchIBTitle = WmXmStringToString (pWS->pSD->iconBoxTitle);
405
406         XtSetArg (setArgs[i], XmNtitle, (XtArgVal)pchIBTitle); i++;
407         XtSetArg (setArgs[i], XmNiconName, (XtArgVal)pchIBTitle); i++;
408     }
409 #endif /* WSM */
410     XtSetArg (setArgs[i], XmNmappedWhenManaged, (XtArgVal)False); i++;
411     XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal)XmDIALOG_MODELESS); i++;
412     XtSetArg (setArgs[i], XmNdepth, 
413         (XtArgVal) DefaultDepth (DISPLAY, pWS->pSD->screen)); i++;
414     XtSetArg (setArgs[i], XmNscreen, 
415         (XtArgVal) ScreenOfDisplay (DISPLAY, pWS->pSD->screen)); i++;
416
417 #ifdef WSM
418     pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNclient, 
419                                         topLevelShellWidgetClass,
420                                         pWS->workspaceTopLevelW,
421                                         (ArgList)setArgs, i);
422
423     if (pchIBTitle != NULL) XtFree (pchIBTitle);
424 #else /* WSM */
425     pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNiconBox, 
426                                         topLevelShellWidgetClass,
427                                         pWS->workspaceTopLevelW,
428                                         (ArgList)setArgs, i);
429 #endif /* WSM */
430
431 } /* END OF FUNCTION MakeShell */
432
433
434 \f
435 /*************************************<->*************************************
436  *
437  *  MakeScrolledWindow (pWS, pIBD)
438  *
439  *
440  *  Description:
441  *  -----------
442  *  
443  *
444  *
445  *  Inputs:
446  *  ------
447  *  pWS = pointer to workspace data
448  *  pIBD  = pointer to IconBoxData
449  *  XXinput = ...
450  *
451  * 
452  *  Outputs:
453  *  -------
454  *  
455  *  Return =  pIBD with the  pIBD->scrolledWidget set
456  *
457  *
458  *  Comments:
459  *  --------
460  *  XXComments ...
461  * 
462  *************************************<->***********************************/
463
464 void MakeScrolledWindow (WmWorkspaceData *pWS, IconBoxData *pIBD)
465 {
466
467     Arg setArgs[20]; 
468     int i;
469
470     /*
471      * Create frame widget to give the scrolled window 
472      * an external bevel
473      */
474
475     i=0;
476 #ifndef WSM
477 /*
478     if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
479     {
480         XtSetArg (setArgs[i], XmNbackground,  
481                   (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
482         XtSetArg (setArgs[i], XmNforeground,  
483                   (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
484     }
485 */
486 #endif /* WSM */
487     XtSetArg (setArgs[i], XmNborderWidth,  (XtArgVal) 0 ); i++;
488     XtSetArg (setArgs[i], XmNmarginWidth,  (XtArgVal) 0 ); i++;
489     XtSetArg (setArgs[i], XmNmarginHeight, (XtArgVal) 0 ); i++;
490     XtSetArg (setArgs[i], XmNshadowType, (XtArgVal) XmSHADOW_OUT); i++;
491     XtSetArg (setArgs[i], XmNshadowThickness,
492                         (XtArgVal) frameShadowThickness); i++;
493     pIBD->frameWidget = XtCreateManagedWidget ("IBframe", 
494                                         xmFrameWidgetClass, 
495                                         pIBD->shellWidget,
496                                         (ArgList)setArgs, i);
497
498 #ifdef WSM
499     XtAddCallback (pIBD->frameWidget, XmNhelpCallback,
500                    WmDtWmTopicHelpCB, WM_DT_ICONBOX_TOPIC);
501
502 #endif /* WSM */
503     /*
504      * Create scrolled window to hold row column manager 
505      */
506
507     i=0;
508
509     XtSetArg (setArgs[i], XmNscrollingPolicy , (XtArgVal) XmAUTOMATIC ); i++;
510
511     XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0 ); i++;
512     XtSetArg (setArgs[i], XmNspacing , (XtArgVal) IB_MARGIN_WIDTH ); i++;
513 #ifndef WSM
514
515     if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
516     {
517         XtSetArg (setArgs[i], XmNbackground,  
518                   (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
519         XtSetArg (setArgs[i], XmNforeground,  
520                   (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
521     }
522 #endif /* WSM */
523     /*
524      * do we want to get these from a resource or set it here
525      * to control the appearance of the iconBox
526      */
527
528     XtSetArg (setArgs[i], XmNscrolledWindowMarginWidth, (XtArgVal) 3); i++;
529     XtSetArg (setArgs[i], XmNscrolledWindowMarginHeight, (XtArgVal) 3); i++;
530     XtSetArg (setArgs[i], XmNshadowThickness,
531                         (XtArgVal) FRAME_EXTERNAL_SHADOW_WIDTH); i++;
532
533     XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,(XtArgVal) XmSTATIC ); i++;
534     XtSetArg (setArgs[i], XmNvisualPolicy, (XtArgVal) XmVARIABLE ); i++;
535
536     pIBD->scrolledWidget = XtCreateManagedWidget ("IBsWindow", 
537                                         xmScrolledWindowWidgetClass, 
538                                         pIBD->frameWidget,
539                                         (ArgList)setArgs, i);
540
541 #ifndef MOTIF_ONE_DOT_ONE
542     XtAddCallback(pIBD->scrolledWidget, XmNtraverseObscuredCallback,
543                   (XtCallbackProc) IconScrollVisibleCallback, (caddr_t)NULL);
544 #endif
545
546     XtAddEventHandler(pIBD->scrolledWidget, 
547                         StructureNotifyMask, 
548                         False, 
549                         (XtEventHandler)UpdateIncrements, 
550                         (XtPointer) pIBD);
551
552
553
554 } /* END OF FUNCTION MakeScrolledWindow */
555
556
557 \f
558 /*************************************<->*************************************
559  *
560  *  MakeBulletinBoard (pWS, pIBD)
561  *
562  *
563  *  Description:
564  *  -----------
565  *  
566  *
567  *
568  *  Inputs:
569  *  ------
570  *  pWS = pointer to workspace data
571  *  pIBD  = pointer to IconBoxData
572  *
573  *  XXinput = ...
574  *
575  * 
576  *  Outputs:
577  *  -------
578  *  
579  *  Return =  pIBD with the  pIBD->bBoardWidget
580  *
581  *
582  *  Comments:
583  *  --------
584  *  XXComments ...
585  * 
586  *************************************<->***********************************/
587
588 void MakeBulletinBoard (WmWorkspaceData *pWS, IconBoxData *pIBD)
589 {
590
591     int i;
592     Arg setArgs[20];
593
594     /*
595      * Create bulletin board to hold icons
596      */
597
598     i=0;
599 #ifdef DEBUG_ICON_BOX
600     XtSetArg (setArgs[i], XmNborderWidth , 1); i++; 
601 #else
602     XtSetArg (setArgs[i], XmNborderWidth , 0); i++; 
603 #endif /* DEBUG_ICON_BOX */
604     
605     XtSetArg (setArgs[i], XmNshadowThickness,(XtArgVal) 0); i++;
606 #ifndef WSM
607     if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
608     {
609         XtSetArg (setArgs[i], XmNforeground,  
610                   (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
611         XtSetArg (setArgs[i], XmNbottomShadowColor,  
612                 (XtArgVal) pWS->pSD->clientAppearance.bottomShadowColor ); i++;
613         XtSetArg (setArgs[i], XmNtopShadowColor,  
614                   (XtArgVal) pWS->pSD->clientAppearance.topShadowColor ); i++;
615     }
616 #endif /* WSM */
617
618     XtSetArg (setArgs[i], XmNspacing , 0); i++; 
619     XtSetArg (setArgs[i], XmNmarginHeight , 0); i++;
620     XtSetArg (setArgs[i], XmNmarginWidth ,  0); i++;
621
622     XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal) XmDIALOG_WORK_AREA); i++;
623
624     XtSetArg (setArgs[i], XmNresizePolicy, (XtArgVal) XmRESIZE_NONE); i++;
625     XtSetArg (setArgs[i], XmNdefaultPosition , (XtArgVal) False); i++;
626
627     XtSetArg (setArgs[i], XtNinsertPosition , InsertPosition); i++;
628
629     pIBD->bBoardWidget = XtCreateManagedWidget ("IBbBoard", 
630                                         xmBulletinBoardWidgetClass,
631                                         pIBD->scrolledWidget,
632                                         (ArgList)setArgs, i);
633
634 } /* END OF FUNCTION MakeBulletinBoard */
635
636
637 \f
638 /*************************************<->*************************************
639  *
640  *  RealizeIconBox (pWS, pIBD, pCD)
641  *
642  *
643  *  Description:
644  *  -----------
645  *  
646  *
647  *
648  *  Inputs:
649  *  ------
650  *  pWS = pointer to workspace data 
651  *
652  *  pIBD  = pointer to IconBoxData
653  *
654  *  pCD   = pointer to ClientData
655  *
656  * 
657  *  Outputs:
658  *  -------
659  *  
660
661  *  Return =  pIBD with the  pIBD->shellWin set
662  *  Return =  pIBD with the  pIBD->scrolledWin set
663  *  Return =  pIBD with the  pIBD->bBoardWin set
664
665  *
666  *  Return =  pCD  with appropriate fields set
667  *
668  *
669  *  Comments:
670  *  --------
671  *  XXComments ...
672  * 
673  *************************************<->***********************************/
674
675 void RealizeIconBox (WmWorkspaceData *pWS, IconBoxData *pIBD, ClientData *pCD)
676 {
677
678     int i;
679     Arg getArgs[10]; 
680     Arg setArgs[2]; 
681     Widget clipWidget;
682     Pixmap  bgPixmap;
683     Pixmap defaultImage;
684     
685
686     XtRealizeWidget (pIBD->shellWidget);
687
688     pCD->client = XtWindow (pIBD->shellWidget);
689
690     /*
691      * This will set the scrolling granularity for the icon box
692      */
693
694     SetGeometry (pWS, pCD, pIBD);
695
696     /*
697      * Point to the iconBox 
698      */
699
700     pIBD->pCD_iconBox = pCD;
701     pCD->thisIconBox = pIBD;    
702     /*
703      * get the background color of the bulletin board for
704      * greyed icon work
705      */
706
707     i=0;
708     XtSetArg (setArgs[i], XmNbackground, (XtArgVal) select_color ); i++;
709     XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i); 
710
711
712     i=0;
713     XtSetArg (getArgs[i], XmNbackgroundPixmap, (XtArgVal) &bgPixmap ); i++;
714     XtGetValues (pIBD->bBoardWidget, getArgs, i);
715
716     i=0;
717     XtSetArg (getArgs[i], XmNclipWindow, (XtArgVal) &clipWidget ); i++;
718     XtGetValues (pIBD->scrolledWidget, getArgs, i);
719
720     /*
721      * Set the background of the clip window for the scrolled 
722      * window so the default widget background doesn't flash
723      */
724
725     i = 0;
726     XtSetArg(setArgs[i], XmNbackground, (XtArgVal) select_color); i++;
727     XtSetValues (clipWidget, (ArgList) setArgs, i); 
728
729
730     /*
731      * Save the clipWidget id to use in constraining icon moves in box
732      */
733
734     pIBD->clipWidget = clipWidget; 
735
736     MakeShrinkWrapIconsGC (pWS->pSD, bgPixmap);
737
738     
739     if (pWS->pSD->iconDecoration & ICON_IMAGE_PART)
740     {
741         /*
742          * Make a pixmap to use when iconWindows are unmapped
743          */
744         defaultImage = XCreateBitmapFromData (DISPLAY, pWS->pSD->rootWindow,
745                                               (char*)iImage_bits, iImage_width, 
746                                               iImage_height);
747         
748         pWS->pSD->defaultPixmap = MakeIconPixmap (pCD,
749                                                   defaultImage,
750                                                   None, iImage_width,
751                                                   iImage_height, 1);
752     }
753     
754     
755 } /* END OF FUNCTION RealizeIconBox */
756
757
758 \f
759 /*************************************<->*************************************
760  *
761  *  AddNewBox (pWS, pIBD)
762  *
763  *
764  *  Description:
765  *  -----------
766  *  
767  *
768  *
769  *  Inputs:
770  *  ------
771  *  pWS = pointer to workspace data
772  *
773  *  pIBD  = pointer to IconBoxData
774  *
775  * 
776  *  Outputs:
777  *  -------
778  *  
779  *
780  *  Comments:
781  *  --------
782  *  Finds the last iconbox on the list starting at pWS->pIconBox and
783  *  adds the new icon box to the end of the list.
784  * 
785  *************************************<->***********************************/
786
787 void AddNewBox (WmWorkspaceData *pWS, IconBoxData *pIBD)
788 {
789  
790     IconBoxData *pibd;
791
792     if (pWS->pIconBox)
793     {
794         pibd = pWS->pIconBox;
795
796         while (pibd->pNextIconBox)
797         {
798             pibd = pibd->pNextIconBox;
799         }
800
801         pibd->pNextIconBox = pIBD;
802     }
803     else
804     {
805         pWS->pIconBox = pIBD;
806     }
807
808   
809 } /* END OF FUNCTION AddNewBox */
810
811
812 \f
813 /*************************************<->*************************************
814  *
815  *  InitializeIconBoxData (pWS, pIBD)
816  *
817  *
818  *  Description:
819  *  -----------
820  *  
821  *
822  *
823  *  Inputs:
824  *  ------
825  *  pWS = pointer to Workspace Data
826  *
827  *  pIBD  = pointer to IconBoxData
828  *
829  * 
830  *  Outputs:
831  *  -------
832  *  
833  *
834  *  Comments:
835  *  --------
836  *  Initializes all pIBD fields to NULL
837  * 
838  *************************************<->***********************************/
839
840 void InitializeIconBoxData (WmWorkspaceData *pWS, IconBoxData *pIBD)
841 {
842     int mask;
843     int X;
844     int Y;
845     unsigned int width;
846     unsigned int height;
847     int sW, sH;
848
849     frameShadowThickness = FRAME_INTERNAL_SHADOW_WIDTH;
850
851     pIBD->numberOfIcons = 0;
852     pIBD->currentRow = 0;
853     pIBD->currentCol = 0;
854     pIBD->lastRow = 0;
855     pIBD->lastCol = 0;
856     pIBD->IPD.placeList = NULL;
857
858     pIBD->scrolledWidget = NULL;
859     pIBD->bBoardWidget = NULL;
860     pIBD->clipWidget = NULL; 
861 #ifdef WSM
862     pIBD->wsID = pWS->id;
863 #endif /* WSM */
864
865     ToLower (pWS->pSD->iconBoxSBDisplayPolicy);
866     
867     if (!((!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , "all"))      ||
868           (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)) ||
869           (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))))
870     {
871         strcpy(pWS->pSD->iconBoxSBDisplayPolicy, "all");
872     }
873
874         
875
876     /*
877      * this will be set by the iconPlacement resource if
878      * iconBoxGeometry width and height are not specified
879      */
880
881 #ifdef WSM
882     if (pWS->iconBoxGeometry == NULL) /* not set by user */
883 #else /* WSM */
884     if (pWS->pSD->iconBoxGeometry == NULL) /* not set by user */
885 #endif /* WSM */
886     {
887         /*
888          * Use the iconPlacement resource 
889          */
890         
891         if (pWS->pSD->iconPlacement & 
892             (ICON_PLACE_TOP_PRIMARY | ICON_PLACE_BOTTOM_PRIMARY))
893         {
894             pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
895             pIBD->IPD.placementCols = 1;  
896             pIBD->IPD.placementRows = 6;
897         }
898         else
899         {
900             pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
901             pIBD->IPD.placementCols = 6;  
902             pIBD->IPD.placementRows = 1;
903         }
904
905     }
906     else
907     {
908 #ifdef WSM
909         mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y, 
910                               &width, &height);
911 #else /* WSM */
912         mask = XParseGeometry(pWS->pSD->iconBoxGeometry, &X, &Y, 
913                               &width, &height);
914 #endif /* WSM */
915
916         if ((mask & WidthValue) && (width > 0))
917         {
918             pIBD->IPD.placementCols = (int)width; 
919         }
920         else
921         {
922             pIBD->IPD.placementCols = 6;   
923         }
924
925         if ((mask & HeightValue) && (height > 0))
926         {
927             pIBD->IPD.placementRows = (int)height; 
928         }
929         else
930         {
931             pIBD->IPD.placementRows = 1; 
932         }
933
934         /*
935          * Set orientation 
936          */
937
938         if (pIBD->IPD.placementRows <= pIBD->IPD.placementCols) 
939         {
940             pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
941         }
942         else
943         {
944             pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
945         }
946     }
947
948
949     /*
950      * Override orientation if iconBoxSBDisplayPolicy is set to
951      * horizontal or vertical
952      */
953
954     if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)))  
955     {
956         pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;          
957     }
958     else if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal)))
959     {
960         pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
961     }
962         
963
964     
965
966     /* 
967      * set initial size of placement space to size of screen 
968      */
969
970     sW = DisplayWidth (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconWidth;
971     sH = DisplayHeight (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconHeight;
972
973     pIBD->IPD.totalPlaces = sW * sH;
974
975     pIBD->IPD.onRootWindow = False;
976
977     /*
978      * The icon box does not live in an icon box in this version
979      */
980
981     pIBD->pNextIconBox =NULL;
982     
983
984 } /* END OF FUNCTION InitializeIconBoxData */   
985
986
987 \f
988 /*************************************<->*************************************
989  *
990  *  SetIconBoxInfo (pWS, pCD)
991  *
992  *
993  *  Description:
994  *  -----------
995  *
996  *  Inputs:
997  *  ------
998  *  pCD
999  *
1000  * 
1001  *  Comments:
1002  *  --------
1003  * 
1004  *************************************<->***********************************/
1005
1006 void SetIconBoxInfo (WmWorkspaceData *pWS, ClientData *pCD)
1007 {
1008     pCD->clientClass = WmCIconBox;
1009     pCD->clientName = pWS->pSD->iconBoxName;
1010     ProcessClientResources (pCD); 
1011
1012 } /* END OF FUNCTION SetIconBoxInfo */
1013
1014
1015 \f
1016 /*************************************<->*************************************
1017  *
1018  *  InitializeClientData (pCD)
1019  *
1020  *
1021  *  Description:
1022  *  -----------
1023  *  
1024  *
1025  *
1026  *  Inputs:
1027  *  ------
1028  *  pCD
1029  *
1030  * 
1031  *  Outputs:
1032  *  -------
1033  *  
1034  *
1035  *  Comments:
1036  *  --------
1037  *  Initializes geometry, etc. fields 
1038  * 
1039  *************************************<->***********************************/
1040
1041 void InitializeClientData (ClientData *pCD, IconBoxData *pIBD)
1042 {
1043     pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 : 
1044                                             FRAME_INTERNAL_SHADOW_WIDTH;
1045
1046     pCD->clientX = 0;
1047     pCD->clientY = 0;
1048
1049     pCD->clientFlags |= ICON_BOX ;
1050
1051     pCD->widthInc = pIBD->IPD.iPlaceW = ICON_WIDTH(pCD)   
1052         + IB_SPACING 
1053         + (2 * IB_MARGIN_WIDTH); 
1054
1055     pCD->heightInc = pIBD->IPD.iPlaceH = ICON_HEIGHT(pCD) 
1056         + IB_SPACING  
1057         + (2 * IB_MARGIN_HEIGHT);
1058
1059     pCD->clientWidth = pIBD->IPD.placementCols * pCD->widthInc;
1060     pCD->clientHeight = pIBD->IPD.placementRows * pCD->heightInc;
1061     
1062     if (!(pCD->pSD->iconBoxTitle))
1063     {
1064 #ifndef NO_MESSAGE_CATALOG
1065         pCD->pSD->iconBoxTitle = 
1066             XmStringCreateLocalized(wmNLS.default_icon_box_title);
1067 #else
1068         pCD->pSD->iconBoxTitle = 
1069             XmStringCreateLocalized(DEFAULT_ICON_BOX_TITLE);
1070 #endif
1071     }
1072
1073     pCD->clientTitle = pCD->pSD->iconBoxTitle;
1074     pCD->iconTitle   = pCD->pSD->iconBoxTitle;
1075     
1076 } /* END OF FUNCTION InitializeClientData */   
1077
1078
1079 \f
1080 /*************************************<->*************************************
1081  *
1082  *  MakeShrinkWrapIconsGC (pSD, bgPixmap)
1083  *
1084  *
1085  *  Description:
1086  *  -----------
1087  *  Make an  graphic context to shrink the icons in the icon box
1088  *      box that are not in the MINIMIZED_STATE.
1089  *
1090  *
1091  *  Inputs:
1092  *  ------
1093  *  pSD         - pointer to screen data
1094  * 
1095  *  Outputs:
1096  *  -------
1097  *  Modifies global data
1098  *
1099  *  Comments:
1100  *  --------
1101  *  
1102  * 
1103  *************************************<->***********************************/
1104
1105 void MakeShrinkWrapIconsGC (WmScreenData *pSD, Pixmap bgPixmap)
1106 {
1107
1108     XtGCMask  copyMask;
1109    
1110
1111     if (!pSD->shrinkWrapGC)
1112     {
1113         pSD->shrinkWrapGC = XCreateGC (DISPLAY, pSD->rootWindow, 0, 
1114                 (XGCValues *) NULL);
1115
1116         copyMask = ~0L;
1117
1118         XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1119                 copyMask, pSD->shrinkWrapGC);
1120
1121         if (bgPixmap != XmUNSPECIFIED_PIXMAP)
1122         {
1123             XSetTile (DISPLAY, pSD->shrinkWrapGC,  bgPixmap); 
1124             XSetFillStyle (DISPLAY, pSD->shrinkWrapGC, FillTiled);
1125             XSetBackground (DISPLAY, pSD->shrinkWrapGC, select_color);
1126         }
1127         else
1128         {
1129             XSetForeground (DISPLAY, pSD->shrinkWrapGC, select_color);
1130         }
1131     }
1132
1133 } /* END OF FUNCTION MakeShrinkWrapIconsGC */
1134
1135
1136 \f
1137 /*************************************<->*************************************
1138  *
1139  *  MakeFadeIconGC (pSD)
1140  *
1141  *
1142  *  Description:
1143  *  -----------
1144  *  Make an  graphic context for "greying" the icons in the icon
1145  *      box that are not in the MINIMIZED_STATE.
1146  *
1147  *
1148  *  Inputs:
1149  *  ------
1150  *  pSD = pointer to screen data
1151  * 
1152  *  Outputs:
1153  *  -------
1154  *  Modifies global data
1155  *
1156  *  Comments:
1157  *  --------
1158  *  
1159  * 
1160  *************************************<->***********************************/
1161
1162 void MakeFadeIconGC (WmScreenData *pSD)
1163 {
1164
1165     XtGCMask  copyMask;
1166     static    Pixmap tmpFontClipMask;
1167    
1168
1169     pSD->fadeIconGC = XCreateGC (DISPLAY, pSD->rootWindow, 0, 
1170                                 (XGCValues *) NULL);
1171     pSD->fadeIconTextGC = XCreateGC (DISPLAY, pSD->rootWindow, 0, 
1172                                 (XGCValues *) NULL);
1173
1174     copyMask = ~0L;
1175
1176     XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1177                 copyMask, pSD->fadeIconGC);
1178
1179     XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1180                 copyMask, pSD->fadeIconTextGC);
1181
1182     tmpFontClipMask = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1183                         (char*)greyed75_bits, greyed75_width, greyed75_height);
1184
1185     greyedPixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1186                         (char*)slant2_bits, slant2_width, slant2_height);
1187
1188     XSetStipple (DISPLAY, pSD->fadeIconTextGC,  tmpFontClipMask); 
1189     XSetFillStyle (DISPLAY, pSD->fadeIconTextGC, FillStippled);
1190
1191     XSetStipple (DISPLAY, pSD->fadeIconGC,  greyedPixmap); 
1192     XSetFillStyle (DISPLAY, pSD->fadeIconGC, FillStippled);
1193     XSetForeground (DISPLAY, pSD->fadeIconGC, select_color);
1194
1195 } /* END OF FUNCTION MakeFadeIconGC */
1196
1197
1198 \f
1199 /*************************************<->*************************************
1200  *
1201  *  SetGeometry (pWS, pCD, pIBD)
1202  *
1203  *
1204  *  Description:
1205  *  -----------
1206  *  
1207  *
1208  *
1209  *  Inputs:
1210  *  ------
1211  *  pIBD  = pointer to IconBoxData
1212  *  pCD   = pointer to ClientData
1213  *  XXinput = ...
1214  *
1215  * 
1216  *  Outputs:
1217  *  -------
1218  *  
1219  *  
1220  *
1221  *
1222  *  Comments:
1223  *  --------
1224  *  XXComments ...
1225  * 
1226  *************************************<->***********************************/
1227
1228 void SetGeometry (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1229 {
1230
1231     int i;
1232     Arg setArgs[10];
1233
1234     int mask;
1235     int X;
1236     int Y;
1237     unsigned int width;
1238     unsigned int height;
1239     unsigned int boxdim, tmpMin;
1240     int diff;
1241     unsigned long       decoration;
1242
1243     /*
1244      * Set horizontal and vertical scrolling granularity
1245      */
1246
1247     SetGranularity (pWS, pCD, pIBD );
1248
1249     /*
1250      * Set the initial width and height of the icon box bulletin board
1251      */
1252
1253     i=0; 
1254     XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth); i++;
1255     XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight); i++;
1256     XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i); 
1257
1258     /*
1259      * Adjust icon box window height for height of 
1260      * horizontal scroll bar etc.
1261      */
1262
1263     pCD->clientHeight = pCD->clientHeight + pCD->baseHeight;
1264     pCD->oldMaxHeight = pCD->maxHeight = pCD->clientHeight;
1265
1266     /*
1267      * Adjust iconbox window width for width of 
1268      * vertical scroll bar etc.
1269      */
1270
1271     pCD->clientWidth = pCD->clientWidth + pCD->baseWidth;
1272     pCD->oldMaxWidth = pCD->maxWidth = pCD->clientWidth;
1273
1274
1275     /* 
1276      * Check that minWidth is large enough to disallow overlap
1277      * of title bar gadgets
1278      */
1279
1280     /* compute for minimum frame size */
1281     if ((decoration = pCD->decor) & MWM_DECOR_TITLE)
1282     {
1283         boxdim = InitTitleBarHeight(pCD);   /* macro not valid yet */
1284         tmpMin = boxdim +
1285                  ((decoration & MWM_DECOR_MENU) ? boxdim : 0) +
1286                  ((decoration & MWM_DECOR_MINIMIZE) ? boxdim : 0) +
1287                  ((decoration & MWM_DECOR_MAXIMIZE) ? boxdim : 0) -
1288                  2*(pCD->matteWidth);
1289     }
1290     else {
1291         tmpMin = 0;
1292     }
1293
1294     /* Make: 
1295      *   minWidth >= tmpMin
1296      *   minWidth >= max (baseWidth, widthInc) > 0
1297      *     & an integral number of widthInc from baseWidth.
1298      */
1299
1300     if (pCD->minWidth < tmpMin)
1301     {
1302         if ((diff = ((tmpMin - pCD->baseWidth)%pCD->widthInc)) != 0)
1303         {
1304             pCD->minWidth = tmpMin + pCD->widthInc - diff;
1305         }
1306         else
1307         {
1308             pCD->minWidth = tmpMin;
1309         }
1310     }
1311
1312     if (pCD->minWidth < pCD->baseWidth)
1313     {
1314         pCD->minWidth = pCD->baseWidth;
1315     }
1316
1317     if (pCD->minWidth == 0)
1318     {
1319         pCD->minWidth = pCD->widthInc;
1320     }
1321     else if ((diff = ((pCD->minWidth - pCD->baseWidth)%pCD->widthInc)) != 0)
1322     {
1323         pCD->minWidth += pCD->widthInc - diff;
1324     }
1325
1326
1327
1328     if (pCD->clientWidth < pCD->minWidth)
1329     {
1330         pCD->clientWidth = pCD->minWidth;
1331     }
1332
1333     pIBD->IPD.placementCols = (int)((pCD->clientWidth - pCD->baseWidth)
1334                                     / pCD->widthInc);
1335
1336
1337     /*
1338      * Make:
1339      *
1340      *   maxWidth >= minWidth
1341      *     & an integral number of widthInc from baseWidth.
1342      */
1343
1344     if (pCD->maxWidth < pCD->minWidth)
1345     {
1346         pCD->maxWidth = pCD->minWidth;
1347     }
1348
1349     pCD->maxWidthLimit = pCD->maxWidth;
1350
1351     pCD->maxWidth -= ((pCD->maxWidth - pCD->baseWidth)% pCD->widthInc);
1352     pCD->oldMaxWidth = pCD->maxWidth;
1353
1354     pCD->maxHeightLimit = pCD->maxHeight;
1355
1356
1357     /*
1358      * Set the initial width and height of the icon box bulletin board
1359      */
1360
1361     i=0; 
1362     XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth 
1363               - pCD->baseWidth ); i++;
1364     XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight 
1365               - pCD->baseHeight ); i++;
1366     XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i); 
1367
1368
1369     /*
1370      * Set the initial width and height of the icon box scrolled Window
1371      */
1372
1373     i=0; 
1374     XtSetArg (setArgs[i], XmNwidth, (XtArgVal) 
1375                 (pCD->clientWidth - (2 * frameShadowThickness))); i++;
1376     XtSetArg (setArgs[i], XmNheight, (XtArgVal) 
1377                 (pCD->clientHeight - (2 * frameShadowThickness))); i++;
1378
1379     XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i); 
1380
1381
1382              
1383     /*
1384      * Call SetFrameInfo with fake X and Y so we can get clientOffset
1385      */
1386
1387     pCD->xBorderWidth = 0;
1388     SetFrameInfo (pCD);
1389
1390
1391     /*
1392      * Set initial placement of icon box
1393      */
1394
1395 #ifdef WSM
1396     mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y, 
1397                               &width, &height);
1398 #else /* WSM */
1399     mask = XParseGeometry(pCD->pSD->iconBoxGeometry, 
1400                           &X, &Y, &width, &height);
1401 #endif /* WSM */    
1402     
1403     if (mask & XValue)
1404     {
1405         if (mask & XNegative)
1406         {
1407             pCD->clientX = X 
1408                            + DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pCD)) 
1409                            - pCD->clientWidth
1410                            - pCD->clientOffset.x;
1411         }
1412         else 
1413         {
1414             pCD->clientX = X + pCD->clientOffset.x;
1415         }
1416     }
1417     else
1418     {
1419         pCD->clientX = pCD->clientOffset.x;
1420     }
1421
1422     if (mask & YValue)
1423     {
1424         if (mask & YNegative)
1425         {
1426             pCD->clientY = Y 
1427                            + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD)) 
1428                            - pCD->clientHeight
1429                            - pCD->clientOffset.x ;
1430         }
1431         else
1432         {
1433             pCD->clientY = Y + pCD->clientOffset.y;
1434         }
1435     }
1436     else
1437     {
1438         pCD->clientY =  pCD->clientOffset.x
1439                         + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD)) 
1440                         - pCD->clientHeight;
1441     }
1442
1443
1444     PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY, pCD->clientWidth,
1445         pCD->clientHeight);
1446     pCD->clientX -= (wmGD.positionIsFrame
1447                         ? pCD->clientOffset.x
1448                         : 0);
1449                         
1450     pCD->clientY -=  (wmGD.positionIsFrame
1451                         ? pCD->clientOffset.y
1452                         : 0);
1453
1454
1455     i=0; 
1456
1457     XtSetArg (setArgs[i], XmNx, (XtArgVal) pCD->clientX); i++;
1458     XtSetArg (setArgs[i], XmNy, (XtArgVal) pCD->clientY); i++;
1459
1460     XtSetValues (pIBD->shellWidget, (ArgList) setArgs, i); 
1461
1462     pCD->maxX = pCD->clientX;
1463     pCD->maxY = pCD->clientY;
1464
1465
1466 } /* END OF FUNCTION SetGeometry */
1467
1468
1469 \f
1470 /*************************************<->*************************************
1471  *
1472  *  SetGranularity (pWS, pCD, pIBD )
1473  *
1474  *
1475  *  Description:
1476  *  -----------
1477  *  
1478  *
1479  *
1480  *  Inputs:
1481  *  ------
1482  *  pIBD  = pointer to IconBoxData
1483  *  pCD   = pointer to ClientData
1484  *  XXinput = ...
1485  *
1486  * 
1487  *  Outputs:
1488  *  -------
1489  *  
1490  *  
1491  *
1492  *
1493  *  Comments:
1494  *  --------
1495  *  XXComments ...
1496  * 
1497  *************************************<->***********************************/
1498
1499 void SetGranularity (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1500 {
1501
1502     int i;
1503     Dimension hScrollBarHeight = 0;
1504     Dimension hBarHeight = 0;
1505     Dimension vScrollBarWidth = 0;
1506     Dimension vBarWidth = 0;
1507
1508     Dimension spacing;
1509     short shadowThickness;
1510     short marginWidth;
1511     short marginHeight;
1512
1513     short hShighlightThickness;
1514     short vShighlightThickness;
1515
1516     Arg setArgs[10];
1517     Arg getArgs[10]; 
1518
1519     i=0;
1520
1521
1522
1523     XtSetArg(getArgs[i], XmNspacing, (XtArgVal) &spacing ); i++;
1524     XtSetArg(getArgs[i], XmNshadowThickness, (XtArgVal) &shadowThickness); i++;
1525     XtSetArg(getArgs[i], XmNscrolledWindowMarginWidth, 
1526                                         (XtArgVal) &marginWidth); i++;
1527     XtSetArg(getArgs[i], XmNscrolledWindowMarginHeight, 
1528                                         (XtArgVal) &marginHeight); i++;
1529     XtSetArg (getArgs[i], XmNverticalScrollBar, 
1530                                         (XtArgVal) &pIBD->vScrollBar); i++;
1531     XtSetArg(getArgs[i], XmNhorizontalScrollBar, 
1532                                         (XtArgVal) &pIBD->hScrollBar); i++;
1533     XtGetValues (pIBD->scrolledWidget, getArgs, i);
1534
1535     
1536     if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1537     {
1538         
1539         /*
1540          * Set horizontal scrolling granularity
1541          */
1542         i=0;
1543         XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hBarHeight ); i++;
1544         XtSetArg (getArgs[i], XmNhighlightThickness,
1545                  (XtArgVal) &hShighlightThickness); i++;
1546         XtGetValues (pIBD->hScrollBar, getArgs, i);
1547
1548
1549         i=0; 
1550         XtSetArg(setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
1551         XtSetArg (setArgs[i], XmNhighlightThickness ,
1552                   IB_HIGHLIGHT_BORDER); i++;
1553         XtSetArg(setArgs[i], XmNheight,
1554                  (XtArgVal) (hBarHeight - (2 * hShighlightThickness)) +
1555                  (2 * IB_HIGHLIGHT_BORDER)); i++;
1556
1557         XtSetValues (pIBD->hScrollBar, (ArgList) setArgs, i); 
1558         
1559         /*
1560          * Get hScrollBarHeight and troughColor
1561          */
1562         
1563         i=0;
1564         XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1565         XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hScrollBarHeight ); i++;
1566         XtGetValues (pIBD->hScrollBar, getArgs, i);
1567
1568     }
1569     
1570     
1571     if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1572     {
1573         
1574         /*
1575          * Set vertical scrolling granularity
1576          */
1577         i=0;
1578         XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vBarWidth ); i++;
1579         XtSetArg (getArgs[i], XmNhighlightThickness,
1580                  (XtArgVal) &vShighlightThickness); i++;
1581         XtGetValues (pIBD->vScrollBar, getArgs, i);
1582
1583
1584         i=0; 
1585         XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
1586         XtSetArg (setArgs[i], XmNhighlightThickness ,
1587                         IB_HIGHLIGHT_BORDER); i++;
1588         XtSetArg(setArgs[i], XmNwidth,
1589                  (XtArgVal) (vBarWidth - (2 * vShighlightThickness)) +
1590                  (2 * IB_HIGHLIGHT_BORDER)); i++;
1591
1592         XtSetValues (pIBD->vScrollBar, (ArgList) setArgs, i); 
1593         
1594         /*
1595          * Get vScrollBarWidth
1596          */
1597         
1598         i=0;
1599         XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1600         XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vScrollBarWidth ); i++;
1601         XtGetValues (pIBD->vScrollBar, getArgs, i);
1602     }
1603     
1604     
1605     
1606     if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1607     {
1608         XtUnmanageChild(pIBD->hScrollBar);
1609         hScrollBarHeight = 0;
1610         
1611         i=0;
1612         XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy, 
1613                   (XtArgVal) XmAS_NEEDED ); i++;
1614         XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1615         
1616     }
1617     else if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1618     {
1619         XtUnmanageChild(pIBD->vScrollBar);
1620         vScrollBarWidth = 0;
1621         
1622         i=0;
1623         XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy, 
1624                   (XtArgVal) XmAS_NEEDED ); i++;
1625         XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1626     }
1627     
1628     
1629     
1630     
1631     pCD->baseWidth =  IB_SPACING 
1632                        + 2 * IB_HIGHLIGHT_BORDER
1633 #ifdef DEBUG_ICON_BOX
1634                        + 2
1635                        + spacing
1636 #endif /* DEBUG_ICON_BOX */
1637                        + (int) vScrollBarWidth 
1638                        + 2 * frameShadowThickness
1639                        + (int) 2 * marginWidth
1640                        + (marginWidth > 0 
1641                                ? 2 * (int) shadowThickness 
1642                                : shadowThickness);
1643
1644                         
1645
1646     pCD->baseHeight =  IB_SPACING
1647                         + 2 * IB_HIGHLIGHT_BORDER
1648 #ifdef DEBUG_ICON_BOX
1649                         + 2
1650 #endif /* DEBUG_ICON_BOX */
1651                         + spacing
1652                         + (int) hScrollBarHeight 
1653                         + 2 * frameShadowThickness
1654                         + (int) 2 * marginHeight
1655                         + (marginHeight > 0 
1656                                 ? 2 * (int) shadowThickness 
1657                                 : shadowThickness);
1658
1659     pCD->minWidth = pCD->baseWidth + pCD->widthInc;
1660     pCD->minHeight = pCD->baseHeight + pCD->heightInc;
1661
1662     pCD->oldMaxWidth = pCD->maxWidth = pCD->minWidth;
1663
1664     pCD->oldMaxHeight = pCD->maxHeight = pCD->minHeight;
1665
1666 } /* END OF FUNCTION SetGranularity */
1667
1668
1669 \f
1670 /*************************************<->*************************************
1671  *
1672  * GetIconBoxMenuItems ()
1673  *
1674  *
1675  *  Description:
1676  *  -----------
1677  *  XXDescription ...
1678  * 
1679  *************************************<->***********************************/
1680
1681 MenuItem *GetIconBoxMenuItems (pSD)
1682
1683     WmScreenData *pSD;
1684
1685 {
1686
1687     return(ParseMwmMenuStr (pSD, 
1688         (unsigned char *)((char *)GETMESSAGE(36, 3, "\"Pack Icons\" _P  Alt Shift<Key>F7 f.pack_icons\n"))));
1689
1690 } /* END OF FUNCTION GetIconBoxMenuItems */
1691
1692
1693 \f
1694 /*************************************<->*************************************
1695  *
1696  *  MapIconBoxes ()
1697  *
1698  *
1699  *  Description:
1700  *  -----------
1701  *  
1702  *
1703  *
1704  *  Inputs:
1705  *  ------
1706  *
1707  * 
1708  *  Outputs:
1709  *  -------
1710  *  
1711  *
1712  *  Comments:
1713  *  --------
1714  *  Maps all iconboxes on the list starting at pWS->pIconBox 
1715  * 
1716  *************************************<->***********************************/
1717
1718 void MapIconBoxes (WmWorkspaceData *pWS)
1719 {
1720  
1721     IconBoxData *pibd;
1722
1723     if (pWS->pIconBox)
1724     {
1725         pibd = pWS->pIconBox;
1726
1727         while (pibd)
1728         {
1729             XtPopup(pibd->shellWidget, XtGrabNone);
1730 #ifndef WSM
1731             F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1732             XMapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
1733 #endif /* WSM */
1734             pibd = pibd->pNextIconBox;
1735         }
1736     }
1737
1738   
1739 } /* END OF FUNCTION MapIconBoxes */
1740
1741 #ifdef WSM
1742 \f
1743 /*************************************<->*************************************
1744  *
1745  *  UnmapIconBoxes (pWS)
1746  *
1747  *
1748  *  Description:
1749  *  -----------
1750  *  Unmaps all the iconboxes in the  specified workspace
1751  *
1752  *
1753  *  Inputs:
1754  *  ------
1755  *  pWS = pointer to workspace data
1756  * 
1757  *  Outputs:
1758  *  -------
1759  *  
1760  *
1761  *  Comments:
1762  *  --------
1763  *  Unmaps all iconboxes on the list starting at pWS->pIconBox 
1764  *  Does not do anything with icon windows.
1765  * 
1766  *************************************<->***********************************/
1767
1768 void UnmapIconBoxes (WmWorkspaceData *pWS)
1769 {
1770  
1771     IconBoxData *pibd;
1772
1773     if (pWS->pIconBox)
1774     {
1775         pibd = pWS->pIconBox;
1776
1777         while (pibd)
1778         {
1779             XUnmapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
1780             pibd = pibd->pNextIconBox;
1781         }
1782     }
1783
1784 } /* END OF FUNCTION UnmapIconBoxes */
1785 #endif /* WSM */
1786
1787 #if defined(PANELIST)
1788 \f
1789 /******************************<->*************************************
1790  *
1791  *  IconBoxShowing ()
1792  *
1793  *  Description:
1794  *  -----------
1795  *  Returns True if an icon box tied to a front panel button is
1796  *  showing.
1797  *
1798  *  Inputs:
1799  *  ------
1800  *  pWS = pointer to workspace data
1801  *  pCW = pointer to control window data (for front panel button )
1802  * 
1803  *  Outputs:
1804  *  -------
1805  *  Return = True if icon box is up, False if it's invisible
1806  *
1807  *  Comments:
1808  *  --------
1809  * 
1810  ******************************<->***********************************/
1811
1812     
1813 #ifdef PANELIST
1814 Boolean
1815 IconBoxShowing (WmWorkspaceData *pWS)
1816 #else /* PANELIST */
1817 Boolean
1818 IconBoxShowing (WmWorkspaceData *pWS, ControlWindowStruct *pCW)
1819 #endif /* PANELIST */
1820 {
1821     Boolean rval = False;
1822     
1823 #ifdef PANELIST
1824     if (pWS->pIconBox &&
1825         ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
1826     {
1827         rval = True;
1828     }
1829 #else /* PANELIST */
1830     if (pWS->pIconBox &&
1831         ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox) &&
1832         (pCW->pWsStatus[wsIndex].wsClientStatus == CLIENT_WINDOW_OPEN))
1833     {
1834         rval = True;
1835     }
1836 #endif /* PANELIST */
1837
1838     return (rval);
1839     
1840 } /* END OF FUNCTION IconBoxShowing */
1841
1842
1843 \f
1844 /******************************<->*************************************
1845  *
1846  *  IconBoxPopUp (pWS, pCW, up)
1847  *
1848  *  Description:
1849  *  -----------
1850  *  Sets the state of the icon box attached to a front panel control.
1851  *
1852  *  Inputs:
1853  *  ------
1854  *  pWS = pointer to workspace data
1855  *  pCW = pointer to control window data (for front panel button )
1856  *  up = flag, if True, pop the icon box up; if False, hide it.
1857  * 
1858  *  Outputs:
1859  *  -------
1860  *  None
1861  *
1862  *  Comments:
1863  *  --------
1864  * 
1865  ******************************<->***********************************/
1866     
1867 #ifdef PANELIST
1868 void
1869 IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
1870 #else /* PANELIST */
1871 void
1872 IconBoxPopUp (WmWorkspaceData *pWS, 
1873     ControlWindowStruct *pCW, Boolean up)
1874 #endif /* PANELIST */
1875 {
1876     
1877     IconBoxData *pibd;
1878     
1879     if (pWS->pIconBox)
1880     {
1881         pibd = pWS->pIconBox;
1882         
1883         while (pibd)
1884         {
1885             if (up)
1886             {
1887                 if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
1888                 {
1889                     F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1890                 }
1891                 else
1892                 { 
1893                     AddClientToWorkspaces (pibd->pCD_iconBox, 
1894                                            &pWS->id, 1);
1895                     return;
1896                 }
1897             }
1898             else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
1899             {
1900                 RemoveClientFromWorkspaces (pibd->pCD_iconBox,
1901                                             &pWS->id, 1);
1902                 return;
1903             }               
1904             pibd = pibd->pNextIconBox;
1905         }
1906         
1907     }
1908     
1909 } /* END OF FUNCTION IconBoxPopUp */
1910 #endif /* PANELIST */
1911
1912
1913
1914 \f
1915 /******************************<->*************************************
1916  *
1917  *  InsertIconIntoBox
1918  *
1919  *  Inputs
1920  *  ------
1921  *  pCD         - pointer to data for client to insert
1922  *
1923  *  Description:
1924  *  -----------
1925  *  XXDescription ...
1926  * 
1927  *************************************<->***********************************/
1928
1929 Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
1930 {
1931
1932     Boolean rval = False;
1933     Arg setArgs[20]; 
1934     int i;
1935     int iconWidth, iconHeight;
1936     IconBoxData  *tmpPointerToIconBox;
1937     Widget iconWidget;
1938     IconInfo *pIconInfo;
1939     static XmString dummyString = NULL;
1940 #ifdef WSM
1941     WsClientData *pWsc;
1942     WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
1943
1944     pWsc = GetWsClientData (pWS, pCD);
1945 #endif /* WSM */
1946
1947     /*
1948      * If we go to multiple icon boxes, find the box this client
1949      * wants to live in.  For now, we only have one, so point to
1950      * the first one.
1951      */
1952
1953     tmpPointerToIconBox = pIBD;
1954     
1955     if (pCD->client)
1956     {
1957
1958 #ifdef WSM
1959         pWsc->pIconBox = tmpPointerToIconBox;
1960 #else /* WSM */
1961         P_ICON_BOX(pCD) = tmpPointerToIconBox;
1962 #endif /* WSM */
1963
1964         iconWidth = ICON_WIDTH(pCD)
1965                 + (2 * IB_MARGIN_WIDTH); 
1966
1967         iconHeight = ICON_HEIGHT(pCD) 
1968                 + (2 * IB_MARGIN_HEIGHT);
1969
1970 #ifdef WSM
1971         pIconInfo = InsertIconInfo  (pWsc->pIconBox, pCD, (Widget) NULL);
1972 #else /* WSM */
1973         pIconInfo = InsertIconInfo  (P_ICON_BOX(pCD), pCD, (Widget) NULL);
1974 #endif /* WSM */
1975
1976         if (pIconInfo)
1977         {
1978 #ifdef WSM
1979             pWsc->pIconBox->numberOfIcons++;
1980 #else /* WSM */
1981             P_ICON_BOX(pCD)->numberOfIcons++;
1982 #endif /* WSM */
1983
1984             i = 0;
1985             XtSetArg (setArgs[i], XmNbackground,  
1986                             (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
1987             XtSetArg (setArgs[i], XmNforeground,  
1988                             (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
1989
1990 #ifdef WSM
1991             XtSetArg (setArgs[i], XmNx ,  (XtArgVal) pWsc->iconX); i++;
1992             XtSetArg (setArgs[i], XmNy ,  (XtArgVal) pWsc->iconY); i++;
1993 #else /* WSM */
1994             XtSetArg (setArgs[i], XmNx ,  (XtArgVal) ICON_X(pCD)); i++;
1995             XtSetArg (setArgs[i], XmNy ,  (XtArgVal) ICON_Y(pCD)); i++;
1996 #endif /* WSM */
1997
1998             XtSetArg (setArgs[i], XmNwidth ,  (XtArgVal) iconWidth); i++;
1999             XtSetArg (setArgs[i], XmNheight ,  (XtArgVal) iconHeight); i++;
2000
2001             XtSetArg (setArgs[i], XmNborderWidth ,  (XtArgVal) 0); i++;
2002
2003             XtSetArg (setArgs[i], XmNhighlightThickness ,  
2004                             IB_HIGHLIGHT_BORDER); i++;
2005
2006             XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
2007             XtSetArg (setArgs[i], XmNmarginWidth ,      (XtArgVal) 0); i++;
2008             /* 
2009              * Use type XmString so we don't get a message from XmLabel
2010              */
2011             XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
2012
2013             XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
2014
2015             XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
2016
2017             XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
2018
2019             XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
2020
2021             iconWidget =  XtCreateManagedWidget("iconInIconBox",
2022                                            xmDrawnButtonWidgetClass,
2023 #ifdef WSM
2024                                            pWsc->pIconBox->bBoardWidget,
2025 #else /* WSM */
2026                                            P_ICON_BOX(pCD)->bBoardWidget,
2027 #endif /* WSM */
2028                                            (ArgList)setArgs, i);
2029
2030             if (dummyString == NULL)
2031             {
2032                 dummyString = 
2033                     XmStringCreateLocalized("");
2034             }
2035
2036             i = 0;
2037             XtSetArg (setArgs[i], XmNlabelString, 
2038                                         (XtArgVal) dummyString); i++;
2039
2040             XtSetValues (iconWidget, setArgs, i);
2041
2042             pIconInfo->theWidget = iconWidget;
2043
2044 #ifdef WSM
2045             pWsc->iconFrameWin = XtWindow (iconWidget); 
2046 #else /* WSM */
2047             ICON_FRAME_WIN(pCD) = XtWindow (iconWidget); 
2048 #endif /* WSM */
2049
2050             XtAddCallback (iconWidget, XmNactivateCallback, 
2051                            (XtCallbackProc)IconActivateCallback, 
2052                            (XtPointer)NULL);
2053
2054             XtAddEventHandler(iconWidget, 
2055                               SELECT_BUTTON_MOTION_MASK, 
2056                               False, 
2057                               (XtEventHandler)HandleIconBoxButtonMotion, 
2058                               (XtPointer)NULL);
2059
2060             XtAddEventHandler(iconWidget, 
2061                               DMANIP_BUTTON_MOTION_MASK, 
2062                               False, 
2063                               (XtEventHandler)HandleIconBoxButtonMotion, 
2064                               (XtPointer)NULL);
2065
2066             XtAddEventHandler(iconWidget,
2067                               KeyPressMask,
2068                               False,
2069                               (XtEventHandler)HandleIconBoxIconKeyPress,
2070                               (XtPointer)NULL);
2071
2072             
2073             
2074             if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
2075             {
2076                 XtAddEventHandler(iconWidget, 
2077                                   FocusChangeMask, 
2078                                   False, 
2079                                   (XtEventHandler)ChangeActiveIconboxIconText, 
2080                                   (XtPointer)NULL);
2081
2082                 if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
2083                 {
2084                     XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
2085                 }
2086             }
2087
2088 #ifdef WSM
2089             ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox, 
2090                                 pWsc->pIconBox->bBoardWidget);
2091
2092             ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
2093
2094 #else /* WSM */
2095             ResetIconBoxMaxSize(P_ICON_BOX(pCD)->pCD_iconBox, 
2096                                 P_ICON_BOX(pCD)->bBoardWidget);
2097
2098             ResetArrowButtonIncrements (P_ICON_BOX(pCD)->pCD_iconBox);
2099
2100 #endif /* WSM */
2101             rval = True;
2102         }
2103     } 
2104     return(rval);
2105
2106 } /* END FUNCTION InsertIconIntoBox() */   
2107    
2108
2109 \f
2110 /*************************************<->*************************************
2111  *
2112  *  InsertIconInfo  (pIBD, pCD, theWidget)
2113  *
2114  *
2115  *  Description:
2116  *  -----------
2117  *  Finds next available spot and inserts the icon 
2118  *
2119  *
2120  *  Inputs:
2121  *  ------
2122  *  pIBD        - pointer to icon box data
2123  *  pCD         - pointer to client data for this client
2124  *  theWidget   - widget containing the icon (may be null)
2125  * 
2126  *  Outputs:
2127  *  -------
2128  *
2129  *  Comments:
2130  *  --------
2131  * 
2132  *************************************<->***********************************/
2133
2134 IconInfo *InsertIconInfo (pIBD, pCD, theWidget)
2135
2136     IconBoxData *pIBD;
2137     ClientData *pCD;
2138     Widget theWidget;
2139
2140 {
2141     IconInfo *pII;
2142     int place;
2143     int amt, i;
2144     Arg setArgs[3];
2145     Arg getArgs[4];
2146     Dimension clipWidth, clipHeight;
2147 #ifdef WSM
2148     WsClientData *pWsc;
2149 #endif /* WSM */
2150
2151     place = GetNextIconPlace (&pIBD->IPD);
2152     if (place == NO_ICON_PLACE)
2153     {
2154         if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2155         {
2156             amt = pIBD->IPD.placementCols;              /* add a new row */
2157         }
2158         else
2159         {
2160             amt = pIBD->IPD.placementRows;              /* add a new column */
2161         }
2162
2163         if (!ExtendIconList (pIBD, amt))
2164         {
2165             Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
2166             return (NULL);
2167         }
2168
2169         if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2170         {
2171             pIBD->IPD.placementRows++;
2172         }
2173         else
2174         {
2175             pIBD->IPD.placementCols++;
2176         }
2177         place = GetNextIconPlace (&pIBD->IPD);
2178     }
2179
2180     insertPosition = place;
2181
2182     /*
2183      * Update icon info values
2184      */
2185
2186     pII = &pIBD->IPD.placeList[place];
2187     pII->theWidget = theWidget;
2188
2189     pII->pCD = pCD;
2190
2191 #ifdef WSM
2192     pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
2193     pWsc->iconPlace = place;
2194
2195     CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2196             &pWsc->iconX, &pWsc->iconY);
2197
2198
2199     /* update next free position */
2200
2201     pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
2202     pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
2203
2204 #else /* WSM */
2205     ICON_PLACE(pCD) = place;
2206
2207     CvtIconPlaceToPosition (&pIBD->IPD, ICON_PLACE(pCD),
2208             &ICON_X(pCD), &ICON_Y(pCD));
2209
2210
2211     /* update next free position */
2212
2213     pIBD->currentCol = ICON_X(pCD) / pIBD->pCD_iconBox->widthInc;
2214     pIBD->currentRow = ICON_Y(pCD) / pIBD->pCD_iconBox->heightInc;
2215
2216 #endif /* WSM */
2217
2218     /* 
2219      * Increase bboard size if necessary
2220      */
2221     i = 0;
2222     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
2223     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2224     XtGetValues (pIBD->clipWidget, getArgs, i);
2225
2226     i = 0;
2227     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2228     {
2229         if (pIBD->currentCol > pIBD->lastCol)
2230         {
2231             pIBD->lastCol = pIBD->currentCol;
2232         }
2233
2234         if (pIBD->currentRow > pIBD->lastRow)
2235         {
2236             pIBD->lastRow = pIBD->currentRow;
2237 #ifdef WSM
2238             if (clipHeight <= (Dimension) (pWsc->iconY + 
2239                                            pIBD->pCD_iconBox->heightInc))
2240             {
2241                 /*
2242                  * Increase bulletin board height as needed.
2243                  */
2244                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) 
2245                           pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
2246             }
2247 #else /* WSM */
2248             if (clipHeight <= (pII->pCD->iconY + pIBD->pCD_iconBox->heightInc))
2249             {
2250                 /*
2251                  * Increase bulletin board height as needed.
2252                  */
2253                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) 
2254                           pII->pCD->iconY + pIBD->pCD_iconBox->heightInc); i++;
2255             }
2256 #endif /* WSM */
2257         }
2258     }
2259     else
2260     {
2261         if (pIBD->currentCol > pIBD->lastCol)
2262         {
2263             pIBD->lastCol = pIBD->currentCol;
2264 #ifdef WSM
2265             if (clipWidth <= (Dimension) 
2266                               (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
2267             {
2268                 /*
2269                  * Increase bulletin board width as needed
2270                  */
2271                 XtSetArg (setArgs[i], XmNwidth, 
2272                 (XtArgVal) pWsc->iconX +
2273                            pIBD->pCD_iconBox->widthInc); i++;
2274             }
2275 #else /* WSM */
2276             if (clipWidth <= (pII->pCD->iconX + pIBD->pCD_iconBox->widthInc))
2277             {
2278                 /*
2279                  * Increase bulletin board width as needed
2280                  */
2281                 XtSetArg (setArgs[i], XmNwidth, 
2282                 (XtArgVal) pII->pCD->iconX +
2283                            pIBD->pCD_iconBox->widthInc); i++;
2284             }
2285 #endif /* WSM */
2286         }
2287
2288         if (pIBD->currentRow > pIBD->lastRow)
2289         {
2290             pIBD->lastRow = pIBD->currentRow;
2291         }
2292     }
2293
2294     if (i > 0)
2295     {
2296         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2297     }
2298
2299     return(pII);
2300     
2301
2302
2303 } /* END OF FUNCTION InsertIconInfo */
2304
2305
2306 \f
2307 /*************************************<->*************************************
2308  *
2309  *  DeleteIconFromBox
2310  *
2311  *
2312  *  Description:
2313  *  -----------
2314  *  XXDescription ...
2315  * 
2316  *************************************<->***********************************/
2317
2318 void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
2319 {
2320     Widget       theChild;
2321     ClientData  *pCD_tmp;
2322     Arg          args[4];
2323     Dimension    clipWidth, clipHeight;
2324     Dimension    oldWidth, oldHeight;
2325     int          newWidth, newHeight;
2326     int          i, newCols, newRows;
2327 #ifdef WSM
2328     WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
2329     WsClientData *pWsc;
2330
2331     pWsc = GetWsClientData (pWS, pCD);
2332 #endif /* WSM */
2333
2334     i = 0;
2335     XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2336     XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2337     XtGetValues (pIBD->bBoardWidget, args, i);
2338
2339     i = 0;
2340     XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
2341     XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2342     XtGetValues (pIBD->clipWidget, args, i);
2343
2344     clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
2345     clipWidth  /= (Dimension) pIBD->pCD_iconBox->widthInc;
2346
2347     /* 
2348      * find context of the activeIconTextWin to get pCD and then 
2349      * if it is the same as this client, hide it.
2350      */
2351
2352     if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
2353                         wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
2354     {
2355         if (pCD == pCD_tmp)
2356         {
2357             /* hide activeIconTextWin */
2358             HideActiveIconText ((WmScreenData *)NULL);
2359         }
2360     }
2361
2362 #ifdef WSM
2363     DeleteIconInfo (pWsc->pIconBox, pCD);
2364
2365     pWsc->pIconBox->numberOfIcons--;
2366
2367     theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
2368
2369     pWsc->pIconBox = NULL;
2370     pWsc->iconPlace = NO_ICON_PLACE;
2371 #else /* WSM */
2372     DeleteIconInfo (P_ICON_BOX(pCD), pCD);
2373
2374     pCD->pIconBox->numberOfIcons--;
2375
2376     theChild = XtWindowToWidget (DISPLAY, ICON_FRAME_WIN(pCD));
2377 #endif /* WSM */
2378     XtUnmanageChild (theChild);
2379
2380     XtDestroyWidget (theChild);
2381
2382     /* update last row and col */
2383
2384     SetNewBounds (pIBD);
2385
2386     /* resize Bulletin board  (so scroll bars show correctly */
2387     i = 0;
2388
2389     if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
2390     {
2391         newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
2392         XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2393         newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2394     }
2395     else
2396     {
2397         newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;    
2398         XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2399         newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2400     }
2401
2402     if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
2403     {
2404         /* set height of bboard */
2405         newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2406         XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2407         newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2408     }
2409     else
2410     {
2411         newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
2412         XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2413         newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2414     }
2415
2416     if (i > 0  &&  ExpandVirtualSpace(pIBD, newWidth, newHeight))
2417     {
2418         XtSetValues (pIBD->bBoardWidget, args, i);
2419         RealignIconList (pIBD, newCols, newRows);
2420         pIBD->IPD.placementCols = newCols;
2421         pIBD->IPD.placementRows = newRows;
2422     }
2423
2424
2425     /* reset max size for icon box */
2426     ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2427     
2428     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
2429
2430 } /* END FUNCTION DeleteIconFromBox */
2431
2432
2433 \f
2434 /*************************************<->*************************************
2435  *
2436  *  DeleteIconInfo (pIBD, pCD)
2437  *
2438  *
2439  *  Description:
2440  *  -----------
2441  *  Deletes an icon info record from the icon box list based on the 
2442  *  client data pointer.
2443  *
2444  *
2445  *  Inputs:
2446  *  ------
2447  *  pIBD        - pointer to icon box data
2448  *  pCD         - pointer to client data
2449  * 
2450  *  Outputs:
2451  *  -------
2452  *
2453  *
2454  *  Comments:
2455  *  --------
2456  *  o The deleted item is freed
2457  *  o Is pCD the correct key???? !!!
2458  * 
2459  *************************************<->***********************************/
2460 void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
2461 {
2462     int ix, count;
2463     IconInfo *pII;
2464
2465     /* find first matching entry in list */
2466
2467     pII = &pIBD->IPD.placeList[0]; 
2468     count = pIBD->IPD.totalPlaces;
2469
2470     for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
2471     {
2472     }
2473
2474     if (ix < count)
2475     {
2476         /* found it, zero the entry out */
2477         pII->theWidget = NULL;
2478         pII->pCD = NULL;
2479     }
2480
2481
2482 } /* END FUNCTION DeleteIconInfo */
2483
2484
2485 \f
2486 /*************************************<->*************************************
2487  *
2488  *  ResetIconBoxMaxSize(pCD, bBoardWidget)
2489  *
2490  *
2491  *  Description:
2492  *  -----------
2493  *  XXDescription ...
2494  * 
2495  *************************************<->***********************************/
2496
2497 void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
2498 {
2499     int i;
2500     Arg getArgs[3]; 
2501     Dimension newWidth;
2502     Dimension newHeight;
2503
2504     i=0;
2505     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
2506     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
2507     XtGetValues (bBoardWidget, getArgs, i);
2508
2509     pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
2510
2511     pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
2512
2513     pCD->maxX = pCD->clientX;
2514     pCD->maxY = pCD->clientY;
2515     PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY, 
2516                         pCD->maxWidth, pCD->maxHeight);
2517
2518 } /* END OF FUNCTION    ResetIconBoxMaxSize */
2519
2520
2521 \f
2522 /*************************************<->*************************************
2523  *
2524  * CheckIconBoxSize(pIBD)
2525  *
2526  *
2527  *  Description:
2528  *  -----------
2529  *  XXDescription ...
2530  * 
2531  *************************************<->***********************************/
2532
2533 Boolean CheckIconBoxSize (IconBoxData *pIBD)
2534 {
2535     int i;
2536     Arg getArgs[3]; 
2537     Arg setArgs[3]; 
2538     Dimension oldWidth;
2539     Dimension oldHeight;
2540     Dimension newWidth;
2541     Dimension newHeight;
2542     int oldCol, oldRow;
2543     Boolean rval = True;
2544
2545     i=0;
2546     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2547     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2548     XtGetValues (pIBD->bBoardWidget, getArgs, i);
2549
2550     newWidth = oldWidth;
2551     newHeight = oldHeight;
2552     oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
2553     oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
2554
2555     /* 
2556      * Increase bboard size if necessary
2557      */
2558
2559     i = 0;
2560     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2561     {
2562         if (oldRow < pIBD->lastRow + 1)
2563         {
2564             /*
2565              * increase bulletin board height as needed
2566              */
2567             newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
2568                          + pIBD->pCD_iconBox->heightInc;
2569
2570             XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
2571         }
2572     }
2573     else
2574     {
2575         if (oldCol  < pIBD->lastCol + 1)
2576         {
2577             /*
2578              * increase bulletin board width as needed
2579              */
2580             newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
2581                             + pIBD->pCD_iconBox->widthInc;
2582
2583             XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
2584         }
2585     }
2586
2587     if (i > 0)
2588     {
2589         if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
2590         {
2591             /*
2592              * The user has resized the iconbox larger than
2593              * memory will allow.  Don't honor the resize request
2594              */
2595             rval = False;
2596             return(rval);
2597         }
2598         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2599     }
2600
2601     ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2602     
2603
2604     return(rval);
2605
2606 } /* END OF FUNCTION CheckIconBoxSize */
2607
2608
2609 \f
2610 /*************************************<->*************************************
2611  *
2612  * CheckIconBoxResize(pCD, changedValues)
2613  *
2614  *
2615  *  Description:
2616  *  -----------
2617  *  XXDescription ...
2618  * 
2619  *************************************<->***********************************/
2620
2621 void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
2622 {
2623
2624     Boolean  packVert = False;
2625     Boolean  packHorz = False;
2626     WmScreenData *pSD;
2627
2628     IconBoxData *pIBD;
2629     IconPlacementData *pIPD;
2630     int i, newCols, newRows;
2631     Arg getArgs[3]; 
2632     Arg setArgs[3]; 
2633     Dimension oldWidth;
2634     Dimension oldHeight;
2635
2636     pIPD = &pCD->thisIconBox->IPD;
2637     pIBD = pCD->thisIconBox;
2638
2639     pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
2640
2641     
2642     i=0;
2643     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2644     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2645     XtGetValues (pIBD->bBoardWidget, getArgs, i);
2646     
2647     newCols = pIPD->placementCols;
2648     newRows = pIPD->placementRows;
2649     newWidth = newWidth - pCD->baseWidth;               
2650     newHeight = newHeight - pCD->baseHeight;
2651     
2652     i = 0;
2653     
2654     if (changedValues & CWWidth) 
2655     {
2656         /*
2657          * There was a change in Width, see if we need to change the
2658          * bulletin board
2659          */
2660         if (newWidth > (int) oldWidth)
2661         {
2662             newCols = newWidth / pCD->widthInc;
2663             XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2664         }
2665         
2666         if (newWidth < (int) oldWidth)
2667         {
2668             if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
2669                 (newWidth / pCD->widthInc < pIBD->lastCol + 1))
2670             {
2671                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2672                 newCols = newWidth / pCD->widthInc;
2673                 packVert = True;
2674             }
2675             else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
2676             {
2677                 newWidth = (pIBD->lastCol +1) * pCD->widthInc;
2678                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2679             }
2680             else
2681             {
2682                 newCols = newWidth / pCD->widthInc;
2683                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2684             }
2685         }
2686     }
2687     else
2688     {
2689         newWidth = oldWidth;
2690     }
2691         
2692     if (changedValues & CWHeight) 
2693     {
2694         /*
2695          * There was a change in Height, see if we need to change the
2696          * bulletin board
2697          */
2698         if (newHeight > (int) oldHeight)
2699         {
2700             newRows = newHeight / pCD->heightInc;
2701             XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2702         }
2703
2704         if (newHeight < (int) oldHeight)
2705         {
2706             if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
2707                 (newHeight / pCD->heightInc < pIBD->lastRow + 1))
2708             {
2709                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2710                 newRows = newHeight / pCD->heightInc;
2711                 packHorz = True;                
2712             }
2713             else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
2714             {
2715                 newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
2716                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2717             }
2718             else
2719             {
2720                 newRows = newHeight / pCD->heightInc;
2721                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2722             }
2723         }
2724     }
2725     else
2726     {
2727         newHeight = oldHeight;
2728     }
2729     
2730     if ( i >0   &&   ExpandVirtualSpace(pIBD, newWidth, newHeight))
2731     {
2732         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2733     }
2734
2735     RealignIconList (pIBD, newCols, newRows);
2736
2737     pIPD->placementCols = newCols;
2738     pIPD->placementRows = newRows;
2739     
2740     ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
2741     
2742     /*
2743      * Pack the icon box if there are icons that can no longer
2744      * be scrolled to due to iconBoxSBDisplayPolicy.
2745      */
2746     if (packVert)
2747     {
2748         PackIconBox (pIBD, packVert, False , newWidth, 0);
2749     }
2750     else if (packHorz)
2751     {
2752         PackIconBox (pIBD, False, packHorz , 0, newHeight);
2753     }
2754
2755
2756 } /* END OF FUNCTION CheckIconBoxResize */
2757
2758
2759 \f
2760 /*************************************<->*************************************
2761  *
2762  *  ExpandVirtualSpace (pIBD, newWidth, newHeight)
2763  *
2764  *
2765  *  Description:
2766  *  -----------
2767  *  Add virtural space (really the icon list )
2768  *
2769  *
2770  *  Inputs:
2771  *  ------
2772  *  pIBD        - ptr to icon box data
2773  *
2774  * 
2775  *  Outputs:
2776  *  -------
2777  *  Return      - True if successful, False otherwise
2778  *
2779  *  Comments:
2780  *  --------
2781  * 
2782  *************************************<->***********************************/
2783
2784 Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
2785 {
2786     Boolean rval = True;
2787     int newSize;
2788     int increment;
2789
2790     newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
2791                 (newHeight / pIBD->pCD_iconBox->heightInc);
2792
2793     if (newSize > pIBD->IPD.totalPlaces )
2794     {
2795         increment = newSize - pIBD->IPD.totalPlaces;
2796         rval = ExtendIconList (pIBD, increment);
2797     }
2798
2799     return (rval);
2800
2801 } /* END OF FUNCTION ExpandVirtualSpace */
2802
2803
2804 \f
2805 /*************************************<->*************************************
2806  *
2807  *  ExtendIconList (pIBD, incr);
2808  *
2809  *
2810  *  Description:
2811  *  -----------
2812  *  Add space to the icon list
2813  *
2814  *
2815  *  Inputs:
2816  *  ------
2817  *  pIBD        - ptr to icon box data
2818  *  incr        - number of cells to add
2819  *
2820  * 
2821  *  Outputs:
2822  *  -------
2823  *  Return      - True if successful, False otherwise
2824  *
2825  *  Comments:
2826  *  --------
2827  * 
2828  *************************************<->***********************************/
2829
2830 Boolean ExtendIconList (IconBoxData *pIBD, int incr)
2831 {
2832     Boolean rval;
2833     int newSize;
2834     IconInfo *pTmp;
2835
2836     newSize = pIBD->IPD.totalPlaces + incr;
2837
2838     if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
2839     {
2840         /* copy data */
2841         memcpy (pTmp, pIBD->IPD.placeList, 
2842             pIBD->IPD.totalPlaces*sizeof(IconInfo));
2843         memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
2844
2845         /* out with the old, in with the new */
2846         XtFree ((char *)pIBD->IPD.placeList);
2847         pIBD->IPD.placeList = pTmp;
2848         pIBD->IPD.totalPlaces = newSize;
2849         rval = True;
2850     }
2851     else
2852     {
2853         rval = False;
2854     }
2855
2856     return (rval);
2857 } /* END OF FUNCTION ExtendIconList */
2858
2859
2860 \f
2861 /*************************************<->*************************************
2862  *
2863  *  PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
2864  *
2865  *
2866  *  Description:
2867  *  -----------
2868  *  Packs the icons in the icon box
2869  *
2870  *
2871  *  Inputs:
2872  *  ------
2873  *  pIBD        - pointer to icon box data
2874  *
2875  * 
2876  *  Outputs:
2877  *  -------
2878  *
2879  *
2880  *  Comments:
2881  *  --------
2882  * 
2883  *************************************<->***********************************/
2884 void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
2885 {
2886     IconInfo *pII_2, *pII_1;
2887     int ix1, ix2;
2888     int count;
2889     int newX, newY;
2890     ClientData *pCD_tmp, *pMyCD;
2891     int hasActiveText = 1;
2892     Arg args[4];
2893     Dimension majorDimension, minorDimension;
2894     Dimension oldWidth, oldHeight;
2895     int newWidth, newHeight;
2896     int i;
2897     Boolean rippling = False;
2898 #ifdef WSM
2899     WsClientData *pWsc;
2900     WmWorkspaceData *pWS;
2901 #endif /* WSM */
2902
2903     i = 0;
2904     XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2905     XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2906     XtGetValues (pIBD->bBoardWidget, args, i);
2907
2908     /*
2909      * packing to visual space, first update IconBoxData
2910      */
2911
2912     i = 0;
2913
2914     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2915     {
2916         XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
2917         XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
2918         XtGetValues (pIBD->clipWidget, args, i);
2919         if (packVert)
2920         {
2921             majorDimension = passedInWidth;
2922         }
2923         
2924         minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2925         majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2926         if (majorDimension != pIBD->IPD.placementCols)
2927         {
2928             pIBD->IPD.placementCols = majorDimension;
2929         }
2930     }
2931     else
2932     {
2933         XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
2934         XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
2935         XtGetValues (pIBD->clipWidget, args, i);
2936         if (packHorz)
2937         {
2938             majorDimension = passedInHeight;
2939         }
2940
2941         minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2942         majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2943         if (majorDimension != pIBD->IPD.placementRows)
2944         {
2945             pIBD->IPD.placementRows = majorDimension;
2946         }
2947     }
2948
2949     /* 
2950      * find context of the activeIconTextWin to get pCD and then 
2951      * if it is the same as this client, hide it.
2952      */
2953
2954     pMyCD = pIBD->pCD_iconBox;
2955     if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
2956     {
2957         if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
2958                         wmGD.windowContextType, (caddr_t *)&pCD_tmp))
2959         {
2960             hasActiveText = 0;
2961         }
2962     }
2963
2964     pII_2 = pII_1 = pIBD->IPD.placeList;
2965     ix1 = ix2 = 0;
2966     count = pIBD->IPD.totalPlaces;
2967
2968     while (ix1 < count)
2969     {
2970         if (!rippling && (pII_2->pCD != NULL))
2971         {
2972             /* 
2973              * We need to start rippling the icons into new positions if
2974              * their (x,y) position changed 
2975              */
2976 #ifdef WSM
2977             pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2978             pWsc = GetWsClientData (pWS, pII_2->pCD);
2979             CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2980                 &newX, &newY);
2981
2982             rippling = ((newX != pWsc->iconX) ||
2983                         (newY != pWsc->iconY));
2984 #else /* WSM */
2985             CvtIconPlaceToPosition (&pIBD->IPD, pII_2->pCD->iconPlace,
2986                 &newX, &newY);
2987
2988             rippling = ((newX != pII_2->pCD->iconX) ||
2989                         (newY != pII_2->pCD->iconY));
2990 #endif /* WSM */
2991         }
2992
2993         if ((pII_2->pCD == NULL) || rippling)
2994         {
2995             /* find next one to move */
2996             while ((ix1 < count) && (pII_1->pCD == NULL))
2997             {
2998                 ix1++;
2999                 pII_1++;
3000             }
3001
3002             if ((ix1 < count) && (pII_1->pCD != NULL))
3003             {
3004                 if (ix1 != ix2)
3005                 {
3006                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3007                 }
3008
3009                 CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
3010
3011 #ifdef WSM
3012                 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
3013                 pWsc = GetWsClientData (pWS, pII_2->pCD);
3014                 pWsc->iconX = newX;
3015                 pWsc->iconY = newY;
3016 #else /* WSM */
3017                 pII_2->pCD->iconX = newX;
3018                 pII_2->pCD->iconY = newY;
3019 #endif /* WSM */
3020
3021                 if (hasActiveText && (pII_2->pCD == pCD_tmp))
3022                 {
3023                     /* hide activeIconTextWin first */
3024                     HideActiveIconText ((WmScreenData *)NULL);
3025                     XtMoveWidget (pII_2->theWidget, newX, newY);
3026                     ShowActiveIconText (pII_2->pCD);
3027                 }
3028                 else
3029                 {
3030                     XtMoveWidget (pII_2->theWidget, newX, newY);
3031                 }
3032             }
3033         }
3034
3035         if (ix1 < count)
3036         {
3037             ix2++;
3038             pII_2++;
3039         }
3040
3041         ix1++;
3042         pII_1++;
3043     }
3044
3045     /* update last row and col */
3046
3047     SetNewBounds (pIBD);
3048
3049     /* resize Bulletin board  (so scroll bars show correctly */
3050     i = 0;
3051     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
3052     {
3053         if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
3054         {
3055             newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
3056             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3057         }
3058         else
3059         {
3060             newWidth = oldWidth;
3061         }
3062
3063         if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
3064         {
3065             /* set height of bboard */
3066             newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3067             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3068         }
3069         else
3070         {
3071             newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
3072             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3073         }
3074     }
3075     else
3076     {
3077         if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
3078         {
3079             newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3080             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3081         }
3082         else
3083         {
3084             newHeight = oldHeight;
3085         }
3086
3087         if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
3088         {
3089             /* set width of bboard */
3090             newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
3091             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3092         }
3093         else
3094         {
3095             newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;    
3096             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3097         }
3098     }
3099
3100     if (i > 0  &&  ExpandVirtualSpace(pIBD, newWidth, newHeight))
3101     {
3102         XtSetValues (pIBD->bBoardWidget, args, i);
3103     }
3104
3105
3106     /* reset max size for icon box */
3107
3108     ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
3109     
3110     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
3111
3112 } /* END FUNCTION PackIconBox */
3113
3114 \f
3115 /*************************************<->*************************************
3116  *
3117  *  RealignIconList (pIBD, newRows, newCols)
3118  *
3119  *
3120  *  Description:
3121  *  -----------
3122  *  Realigns the icon list according to the new virtual space dimensions 
3123  *
3124  *
3125  *  Inputs:
3126  *  ------
3127  *  pIBD        - ptr to icon box data
3128  *  newRows     - new number of rows
3129  *  newCols     - new number of columns
3130  *
3131  * 
3132  *  Outputs:
3133  *  -------
3134  *
3135  *  Comments:
3136  *  --------
3137  *  o The placement data structure contains the old values.
3138  * 
3139  *************************************<->***********************************/
3140
3141 void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
3142 {
3143     int c1, c2, ix1, ix2;
3144     int oldRows, oldCols;
3145     IconPlacementData  ipdNew;
3146     IconInfo *pII;
3147
3148     /* 
3149      * create new icon placement data for ease of calling conversion 
3150      * routines.
3151      */
3152     ipdNew.onRootWindow = pIBD->IPD.onRootWindow;
3153     ipdNew.iconPlacement = pIBD->IPD.iconPlacement;
3154     ipdNew.placementRows = newRows;
3155     ipdNew.placementCols = newCols;
3156     ipdNew.iPlaceW = pIBD->IPD.iPlaceW;
3157     ipdNew.iPlaceH = pIBD->IPD.iPlaceH;
3158     ipdNew.placeList = pIBD->IPD.placeList;
3159     ipdNew.totalPlaces = pIBD->IPD.totalPlaces;
3160
3161     oldRows = pIBD->IPD.placementRows;
3162     oldCols = pIBD->IPD.placementCols;
3163
3164     /*
3165      * Use the new organization and placement discipline to
3166      * determine how to move the icon info data around.
3167      */
3168     if (((oldRows < newRows) && 
3169          (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3170         ((oldCols < newCols) && 
3171          (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3172     { 
3173     /* 
3174      * work backwards 
3175      */
3176         for (ix1 = pIBD->IPD.totalPlaces - 1, 
3177                  pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
3178         {
3179             if (pII->pCD != NULL)
3180             {
3181                 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3182                 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3183                 if (ix1 != ix2)
3184                 { 
3185                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3186                 } 
3187             }
3188         }
3189     }
3190     else 
3191     if (((oldRows > newRows) && 
3192          (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3193         ((oldCols > newCols) && 
3194          (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3195     {
3196         /* 
3197          * work forwards 
3198          */
3199         for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1]; 
3200                 ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
3201         {
3202             if (pII->pCD != NULL)
3203             {
3204                 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3205                 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3206                 if (ix1 != ix2)
3207                 {
3208                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3209                 }
3210             }
3211         }
3212     }
3213
3214     /* 
3215      * update info in placement structure to reflect new reality
3216      */
3217     pIBD->IPD.placementRows = newRows;
3218     pIBD->IPD.placementCols = newCols;
3219
3220 } /* END OF FUNCTION RealignIconList */
3221
3222
3223
3224 \f
3225 /*************************************<->*************************************
3226  *
3227  *  SetNewBounds (pIBD)
3228  *
3229  *
3230  *  Description:
3231  *  -----------
3232  *
3233  *
3234  *  Inputs:
3235  *  ------
3236  *
3237  * 
3238  *  Outputs:
3239  *  -------
3240  *
3241  *  Comments:
3242  *  --------
3243  * 
3244  *************************************<->***********************************/
3245
3246 void SetNewBounds (IconBoxData *pIBD)
3247 {
3248
3249     int i;
3250     int X = 0;
3251     int Y = 0; 
3252     CompositeWidget cw;
3253     WidgetList      children;
3254
3255     cw = (CompositeWidget) pIBD->bBoardWidget;
3256     children = cw->composite.children;
3257
3258     for (i = 0; i < cw->composite.num_children; i++)
3259     {
3260         if (children[i]->core.x > X)
3261         {
3262             X = children[i]->core.x;
3263         }
3264         if (children[i]->core.y > Y)
3265         {
3266             Y = children[i]->core.y;
3267         }
3268     }
3269
3270     pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
3271     pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
3272
3273 } /* END OF FUNCTION SetNewBounds */
3274
3275
3276 \f
3277 /*************************************<->*************************************
3278  *
3279  *  InsertPosition (w)
3280  *
3281  *
3282  *  Description:
3283  *  -----------
3284  *  This procedure is passed to the bulletin board at create time
3285  *  to be used when a child is inserted into the bulletin board
3286  *  
3287  *
3288  *************************************<->***********************************/
3289 Cardinal InsertPosition (Widget w)
3290 {
3291     return (insertPosition);
3292
3293 } /* END OF FUNCTION InsertPosition */
3294
3295
3296 \f
3297 /*************************************<->*************************************
3298  *
3299  *  ShowClientIconState ();
3300  *
3301  *
3302  *  Description:
3303  *  -----------
3304  *  XXDescription ...
3305  *
3306  *************************************<->***********************************/
3307
3308 void ShowClientIconState (ClientData *pCD, int newState)
3309 {
3310
3311     /*
3312      * Changing the appearance of an icon window in the box to 
3313      * reflect the client's state
3314      */
3315
3316     if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
3317         XMapRaised (DISPLAY, pCD->iconWindow);
3318
3319     if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE )) 
3320                                                 && (pCD->iconWindow))
3321     {
3322         XUnmapWindow (DISPLAY, pCD->iconWindow);
3323     }
3324
3325 } /* END FUNCTION ShowClientIconState */
3326
3327
3328 \f
3329 #ifndef MOTIF_ONE_DOT_ONE
3330 /*************************************<->*************************************
3331  *
3332  *  IconScrollVisibleCallback
3333  *
3334  *
3335  *  Description:
3336  *  -----------
3337  *  for each icon in the icon box
3338  * 
3339  *************************************<->***********************************/
3340
3341 void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3342 {
3343     XmTraverseObscuredCallbackStruct *vis_data;
3344
3345     vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
3346
3347     XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
3348                     vis_data->traversal_destination,
3349                     0,0);
3350 /*
3351                     IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
3352 */
3353 } /* END OF FUNCTION IconScrollVisibleCallback */
3354
3355 #endif
3356
3357 \f
3358 /*************************************<->*************************************
3359  *
3360  *  IconActivateCallback
3361  *
3362  *
3363  *  Description:
3364  *  -----------
3365  *  for each icon in the icon box
3366  * 
3367  *************************************<->***********************************/
3368
3369 void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3370 {
3371     ClientData          *pCD;
3372     Window              theIcon;
3373
3374     theIcon = XtWindow(w);
3375
3376     /* 
3377      * find context to get pCD and then carry out
3378      * default action.
3379      */
3380
3381     if (!(XFindContext (DISPLAY, theIcon,
3382                         wmGD.windowContextType, (caddr_t *)&pCD)))
3383     {
3384         F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3385 /*      F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3386 */    }
3387
3388 } /* END OF FUNCTION IconActivateCallback */
3389
3390
3391 \f
3392 /*************************************<->*************************************
3393  *
3394  *  UpdateIncrements
3395  *
3396  *
3397  *  Description:
3398  *  -----------
3399  *  XXDescription ...
3400  * 
3401  *************************************<->***********************************/
3402
3403 void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
3404 {
3405     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
3406   
3407 } /* END OF FUNCTION UpdateIncrements */
3408
3409 \f
3410 /*************************************<->*************************************
3411  *
3412  *  ResetArrowButtonIncrements(pCD)
3413  *
3414  *************************************<->***********************************/
3415
3416 void ResetArrowButtonIncrements (ClientData *pCD)
3417 {
3418     int i;
3419     Arg setArgs[2]; 
3420         
3421     i=0;
3422     XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;    
3423     XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i); 
3424
3425     i=0;
3426     XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;    
3427     XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);     
3428     
3429 } /* END OF FUNCTION ResetArrowButtonIncrements */    
3430
3431
3432 \f
3433 /*************************************<->*************************************
3434  *
3435  *  ChangeActiveIconboxIconText
3436  *
3437  *
3438  *  Description:
3439  *  -----------
3440  *  XXDescription ...
3441  * 
3442  *************************************<->***********************************/
3443
3444 void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
3445 {
3446
3447     ClientData          *pCD;
3448     Window              theIcon;
3449
3450     /* 
3451      * find context to get pCD and then hide or show active icon text. 
3452      * Show/hide the active icon text only if the icon box is not 
3453      * iconified.
3454      */
3455
3456     theIcon = XtWindow(icon);
3457
3458     if (!(XFindContext (DISPLAY, theIcon,
3459                         wmGD.windowContextType, (caddr_t *)&pCD)) &&
3460         P_ICON_BOX(pCD) &&
3461         P_ICON_BOX(pCD)->pCD_iconBox &&
3462         P_ICON_BOX(pCD)->pCD_iconBox->clientState !=  MINIMIZED_STATE)
3463     {
3464         if (event->type == FocusIn) 
3465         {
3466             if (event->send_event)
3467             {
3468                ShowActiveIconText (pCD);
3469             }
3470         }
3471         else
3472         {
3473             if (event->send_event)
3474             {
3475                 HideActiveIconText (pCD->pSD);
3476             }
3477         }
3478     }
3479
3480 } /* END OF FUNCTION ChangeActiveIconboxIconText */
3481
3482
3483 \f
3484 /*************************************<->*************************************
3485  *
3486  *  HandleIconBoxIconKeyPress
3487  *
3488  *
3489  *  Description:
3490  *  -----------
3491  *  This event handler catches keyevents for icons in the icon box and
3492  *  passes them on to the standard key handling routine for mwm.
3493  *
3494  *************************************<->***********************************/
3495
3496 void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
3497 {
3498     
3499     Context context; 
3500     ClientData          *pCD; 
3501     Window              theIcon;
3502
3503     /*
3504      * find context to get pCD and then post menu show active icon text.
3505      */
3506     
3507     theIcon = XtWindow(icon);
3508     if (!(XFindContext (DISPLAY, theIcon,
3509                         wmGD.windowContextType, (caddr_t *)&pCD)))
3510     {
3511 #ifdef WSM
3512         SetClientWsIndex (pCD);
3513 #endif /* WSM */
3514         keyEvent->window = ICON_FRAME_WIN(pCD);
3515
3516         if (pCD->clientState == MINIMIZED_STATE)
3517         {
3518             context = F_SUBCONTEXT_IB_IICON;
3519             pCD->grabContext = F_SUBCONTEXT_IB_IICON;
3520         }
3521         else
3522         {
3523             context = F_SUBCONTEXT_IB_WICON;
3524             pCD->grabContext = F_SUBCONTEXT_IB_WICON;
3525         }
3526         
3527         if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs, 
3528                         True, context, False, pCD)))
3529         {
3530             keyEvent->window = 0;
3531             keyEvent->type = 0;
3532         }
3533
3534     }
3535         
3536 } /* END OF FUNCTION HandleIconBoxIconKeyPress */
3537
3538 \f
3539 /*************************************<->*************************************
3540  *
3541  *  HandleIconBoxButtonMotion
3542  *
3543  *
3544  *  Description:
3545  *  -----------
3546  *  Event handler for button motion events on icon frame window in 
3547  *  in icon box.
3548  *
3549  *
3550  *  Inputs:
3551  *  ------
3552  *  icon                - widget for icon frame 
3553  *  client_data         - extra client data
3554  *  pev                 - ptr to event
3555  *
3556  * 
3557  *  Outputs:
3558  *  -------
3559  *
3560  *
3561  *  Comments:
3562  *  --------
3563  *  o This is added to make sure that ButtonXMotion gets added to the 
3564  *    event mask for icons in the icon box.
3565  * 
3566  *************************************<->***********************************/
3567
3568 void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
3569 {
3570
3571 } /* END OF FUNCTION HandleIconBoxButtonMotion */
3572
3573
3574 \f
3575 /*************************************<->*************************************
3576  *
3577  *  GetIconBoxIconRootXY (pCD, pX, pY)
3578  *
3579  *
3580  *  Description:
3581  *  -----------
3582  *
3583  *
3584  *  Inputs:
3585  *  ------
3586  *  pCD         - pointer to client data
3587  *  pX          - pointer to X return value
3588  *  pY          - pointer to Y return value
3589  *
3590  *  Outputs:
3591  *  -------
3592  *
3593  *
3594  *  Comments:
3595  *  --------
3596  *  o returns root-window coords
3597  *
3598  *************************************<->***********************************/
3599 void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
3600 {
3601
3602     Window child;
3603 #ifdef WSM
3604     WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3605 #endif /* WSM */
3606
3607 #ifdef WSM
3608     if (pCD->pSD->useIconBox && pWsc->pIconBox)
3609 #else /* WSM */
3610     if (pCD->pSD->useIconBox && P_ICON_BOX(pCD))
3611 #endif /* WSM */
3612     {
3613 #ifdef WSM
3614         XTranslateCoordinates(DISPLAY,
3615                               XtWindow(pWsc->pIconBox->bBoardWidget),
3616                               ROOT_FOR_CLIENT(pCD),
3617                               pWsc->iconX + IB_MARGIN_WIDTH,
3618                               pWsc->iconY + IB_MARGIN_HEIGHT,
3619                               pX, pY, &child);
3620 #else /* WSM */
3621         XTranslateCoordinates(DISPLAY,
3622                               XtWindow(P_ICON_BOX(pCD)->bBoardWidget),
3623                               ROOT_FOR_CLIENT(pCD),
3624                               ICON_X(pCD) + IB_MARGIN_WIDTH,
3625                               ICON_Y(pCD) + IB_MARGIN_HEIGHT,
3626                               pX, pY, &child);
3627 #endif /* WSM */
3628
3629     }
3630     else
3631     {
3632         *pX = *pY = 0;
3633     }
3634 } /* END FUNCTION GetIconBoxIconRootXY */
3635
3636 \f
3637 /*************************************<->*************************************
3638  *
3639  *  IconVisible (pCD)
3640  *
3641  *
3642  *  Description:
3643  *  -----------
3644  *
3645  *  Inputs:
3646  *  ------
3647  *  pCD         - pointer to client data
3648  *
3649  *  Outputs:
3650  *  -------
3651  *
3652  *
3653  *  Comments:
3654  *  --------
3655  *
3656  *************************************<->***********************************/
3657 Boolean IconVisible (ClientData *pCD)
3658 {
3659
3660     /*
3661      * May use icon->core.visible field if that gets fixed and
3662      * we want to accept the Intrinsics idea of what is visible.
3663      */
3664
3665     Boolean rval = True;
3666 #ifdef WSM
3667     WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3668 #endif /* WSM */
3669
3670
3671     
3672     int i;
3673     Arg getArgs[5];
3674
3675     Dimension tmpWidth = 0;
3676     Dimension tmpHeight = 0;
3677     Position clipX = 0;
3678     Position clipY = 0;
3679     Position tmpX = 0;
3680     Position tmpY = 0;
3681     int iconX, iconY;
3682
3683     i=0;
3684     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &tmpWidth ); i++;
3685     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &tmpHeight ); i++;
3686     XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
3687     XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
3688 #ifdef WSM
3689     XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
3690     XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
3691                         tmpX, tmpY,
3692                         &clipX, &clipY);
3693 #else /* WSM */
3694     XtGetValues (P_ICON_BOX(pCD)->clipWidget, getArgs, i);
3695     XtTranslateCoords(P_ICON_BOX(pCD)->scrolledWidget,
3696                         tmpX, tmpY,
3697                         &clipX, &clipY);
3698 #endif /* WSM */
3699
3700     GetIconBoxIconRootXY(pCD, &iconX, &iconY);
3701
3702
3703     /* 
3704      * demand at least 2 pixels of the 
3705      * real icon (not drawnButton) be showing 
3706      */
3707        
3708     if (iconX + 2 > ((int)clipX + (int)tmpWidth))
3709     {
3710         return(False);
3711     }
3712     if (iconY + 2 > ((int)clipY + (int)tmpHeight))
3713     {
3714         return(False);
3715     }
3716
3717     if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
3718     {
3719         return(False);
3720     }
3721     if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
3722     {
3723         return(False);
3724     }
3725
3726     return(rval);
3727
3728 } /* END OF FUNCTION IconVisible */
3729 \f
3730 /*************************************<->*************************************
3731  *
3732  *  WmXmStringToString (xmString
3733  *
3734  *
3735  *  Description:
3736  *  -----------
3737  *
3738  *
3739  *  Inputs:
3740  *  ------
3741  *
3742  *  Outputs:
3743  *  -------
3744  *
3745  *
3746  *  Comments:
3747  *  --------
3748  *  Return the ascii part of the first segment of an XmString 
3749  *  If xmString is NULL, then do nothing 
3750  *
3751  *************************************<->***********************************/
3752
3753 String WmXmStringToString (XmString xmString)
3754
3755     XmStringContext       xmStrContext;
3756     char                 *asciiString = NULL; 
3757     XmStringCharSet      ibTitleCharset; 
3758     XmStringDirection    ibTitleDirection; 
3759     Boolean              separator; 
3760     
3761     if (xmString)
3762     {
3763         XmStringInitContext (&xmStrContext, xmString);
3764     
3765         XmStringGetNextSegment (xmStrContext, &asciiString, 
3766                                 &ibTitleCharset, &ibTitleDirection, 
3767                                 &separator);
3768
3769         if (ibTitleCharset != NULL) 
3770         {
3771             XtFree ((char *)ibTitleCharset);
3772         }
3773
3774         XmStringFreeContext (xmStrContext);
3775     }
3776     
3777     return(asciiString);
3778     
3779 } /* END OF FUNCTION WmXmStringToString */