Fix some minor issues and re-enable building of DE, ES, FR, and IT locale data (help...
[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, NULL, 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 ((unsigned char *) 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     int wsIndex =  GetCurrentWorkspaceIndex (pWS->pSD); 
1823     
1824 #ifdef PANELIST
1825     if (pWS->pIconBox &&
1826         ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
1827     {
1828         rval = True;
1829     }
1830 #else /* PANELIST */
1831     if (pWS->pIconBox &&
1832         ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox) &&
1833         (pCW->pWsStatus[wsIndex].wsClientStatus == CLIENT_WINDOW_OPEN))
1834     {
1835         rval = True;
1836     }
1837 #endif /* PANELIST */
1838
1839     return (rval);
1840     
1841 } /* END OF FUNCTION IconBoxShowing */
1842
1843
1844 \f
1845 /******************************<->*************************************
1846  *
1847  *  IconBoxPopUp (pWS, pCW, up)
1848  *
1849  *  Description:
1850  *  -----------
1851  *  Sets the state of the icon box attached to a front panel control.
1852  *
1853  *  Inputs:
1854  *  ------
1855  *  pWS = pointer to workspace data
1856  *  pCW = pointer to control window data (for front panel button )
1857  *  up = flag, if True, pop the icon box up; if False, hide it.
1858  * 
1859  *  Outputs:
1860  *  -------
1861  *  None
1862  *
1863  *  Comments:
1864  *  --------
1865  * 
1866  ******************************<->***********************************/
1867     
1868 #ifdef PANELIST
1869 void
1870 IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
1871 #else /* PANELIST */
1872 void
1873 IconBoxPopUp (WmWorkspaceData *pWS, 
1874     ControlWindowStruct *pCW, Boolean up)
1875 #endif /* PANELIST */
1876 {
1877     
1878     IconBoxData *pibd;
1879     int wsIndex =  GetCurrentWorkspaceIndex (pWS->pSD); 
1880     
1881     if (pWS->pIconBox)
1882     {
1883         pibd = pWS->pIconBox;
1884         
1885         while (pibd)
1886         {
1887             if (up)
1888             {
1889                 if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
1890                 {
1891                     F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1892                 }
1893                 else
1894                 { 
1895                     AddClientToWorkspaces (pibd->pCD_iconBox, 
1896                                            &pWS->id, 1);
1897                     return;
1898                 }
1899             }
1900             else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
1901             {
1902                 RemoveClientFromWorkspaces (pibd->pCD_iconBox,
1903                                             &pWS->id, 1);
1904                 return;
1905             }               
1906             pibd = pibd->pNextIconBox;
1907         }
1908         
1909     }
1910     
1911 } /* END OF FUNCTION IconBoxPopUp */
1912 #endif /* PANELIST */
1913
1914
1915
1916 \f
1917 /******************************<->*************************************
1918  *
1919  *  InsertIconIntoBox
1920  *
1921  *  Inputs
1922  *  ------
1923  *  pCD         - pointer to data for client to insert
1924  *
1925  *  Description:
1926  *  -----------
1927  *  XXDescription ...
1928  * 
1929  *************************************<->***********************************/
1930
1931 Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
1932 {
1933
1934     Boolean rval = False;
1935     Arg setArgs[20]; 
1936     int i;
1937     int iconWidth, iconHeight;
1938     IconBoxData  *tmpPointerToIconBox;
1939     Widget iconWidget;
1940     IconInfo *pIconInfo;
1941     static XmString dummyString = NULL;
1942 #ifdef WSM
1943     WsClientData *pWsc;
1944     WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
1945
1946     pWsc = GetWsClientData (pWS, pCD);
1947 #endif /* WSM */
1948
1949     /*
1950      * If we go to multiple icon boxes, find the box this client
1951      * wants to live in.  For now, we only have one, so point to
1952      * the first one.
1953      */
1954
1955     tmpPointerToIconBox = pIBD;
1956     
1957     if (pCD->client)
1958     {
1959
1960 #ifdef WSM
1961         pWsc->pIconBox = tmpPointerToIconBox;
1962 #else /* WSM */
1963         P_ICON_BOX(pCD) = tmpPointerToIconBox;
1964 #endif /* WSM */
1965
1966         iconWidth = ICON_WIDTH(pCD)
1967                 + (2 * IB_MARGIN_WIDTH); 
1968
1969         iconHeight = ICON_HEIGHT(pCD) 
1970                 + (2 * IB_MARGIN_HEIGHT);
1971
1972 #ifdef WSM
1973         pIconInfo = InsertIconInfo  (pWsc->pIconBox, pCD, (Widget) NULL);
1974 #else /* WSM */
1975         pIconInfo = InsertIconInfo  (P_ICON_BOX(pCD), pCD, (Widget) NULL);
1976 #endif /* WSM */
1977
1978         if (pIconInfo)
1979         {
1980 #ifdef WSM
1981             pWsc->pIconBox->numberOfIcons++;
1982 #else /* WSM */
1983             P_ICON_BOX(pCD)->numberOfIcons++;
1984 #endif /* WSM */
1985
1986             i = 0;
1987             XtSetArg (setArgs[i], XmNbackground,  
1988                             (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
1989             XtSetArg (setArgs[i], XmNforeground,  
1990                             (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
1991
1992 #ifdef WSM
1993             XtSetArg (setArgs[i], XmNx ,  (XtArgVal) pWsc->iconX); i++;
1994             XtSetArg (setArgs[i], XmNy ,  (XtArgVal) pWsc->iconY); i++;
1995 #else /* WSM */
1996             XtSetArg (setArgs[i], XmNx ,  (XtArgVal) ICON_X(pCD)); i++;
1997             XtSetArg (setArgs[i], XmNy ,  (XtArgVal) ICON_Y(pCD)); i++;
1998 #endif /* WSM */
1999
2000             XtSetArg (setArgs[i], XmNwidth ,  (XtArgVal) iconWidth); i++;
2001             XtSetArg (setArgs[i], XmNheight ,  (XtArgVal) iconHeight); i++;
2002
2003             XtSetArg (setArgs[i], XmNborderWidth ,  (XtArgVal) 0); i++;
2004
2005             XtSetArg (setArgs[i], XmNhighlightThickness ,  
2006                             IB_HIGHLIGHT_BORDER); i++;
2007
2008             XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
2009             XtSetArg (setArgs[i], XmNmarginWidth ,      (XtArgVal) 0); i++;
2010             /* 
2011              * Use type XmString so we don't get a message from XmLabel
2012              */
2013             XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
2014
2015             XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
2016
2017             XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
2018
2019             XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
2020
2021             XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
2022
2023             iconWidget =  XtCreateManagedWidget("iconInIconBox",
2024                                            xmDrawnButtonWidgetClass,
2025 #ifdef WSM
2026                                            pWsc->pIconBox->bBoardWidget,
2027 #else /* WSM */
2028                                            P_ICON_BOX(pCD)->bBoardWidget,
2029 #endif /* WSM */
2030                                            (ArgList)setArgs, i);
2031
2032             if (dummyString == NULL)
2033             {
2034                 dummyString = 
2035                     XmStringCreateLocalized("");
2036             }
2037
2038             i = 0;
2039             XtSetArg (setArgs[i], XmNlabelString, 
2040                                         (XtArgVal) dummyString); i++;
2041
2042             XtSetValues (iconWidget, setArgs, i);
2043
2044             pIconInfo->theWidget = iconWidget;
2045
2046 #ifdef WSM
2047             pWsc->iconFrameWin = XtWindow (iconWidget); 
2048 #else /* WSM */
2049             ICON_FRAME_WIN(pCD) = XtWindow (iconWidget); 
2050 #endif /* WSM */
2051
2052             XtAddCallback (iconWidget, XmNactivateCallback, 
2053                            (XtCallbackProc)IconActivateCallback, 
2054                            (XtPointer)NULL);
2055
2056             XtAddEventHandler(iconWidget, 
2057                               SELECT_BUTTON_MOTION_MASK, 
2058                               False, 
2059                               (XtEventHandler)HandleIconBoxButtonMotion, 
2060                               (XtPointer)NULL);
2061
2062             XtAddEventHandler(iconWidget, 
2063                               DMANIP_BUTTON_MOTION_MASK, 
2064                               False, 
2065                               (XtEventHandler)HandleIconBoxButtonMotion, 
2066                               (XtPointer)NULL);
2067
2068             XtAddEventHandler(iconWidget,
2069                               KeyPressMask,
2070                               False,
2071                               (XtEventHandler)HandleIconBoxIconKeyPress,
2072                               (XtPointer)NULL);
2073
2074             
2075             
2076             if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
2077             {
2078                 XtAddEventHandler(iconWidget, 
2079                                   FocusChangeMask, 
2080                                   False, 
2081                                   (XtEventHandler)ChangeActiveIconboxIconText, 
2082                                   (XtPointer)NULL);
2083
2084                 if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
2085                 {
2086                     XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
2087                 }
2088             }
2089
2090 #ifdef WSM
2091             ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox, 
2092                                 pWsc->pIconBox->bBoardWidget);
2093
2094             ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
2095
2096 #else /* WSM */
2097             ResetIconBoxMaxSize(P_ICON_BOX(pCD)->pCD_iconBox, 
2098                                 P_ICON_BOX(pCD)->bBoardWidget);
2099
2100             ResetArrowButtonIncrements (P_ICON_BOX(pCD)->pCD_iconBox);
2101
2102 #endif /* WSM */
2103             rval = True;
2104         }
2105     } 
2106     return(rval);
2107
2108 } /* END FUNCTION InsertIconIntoBox() */   
2109    
2110
2111 \f
2112 /*************************************<->*************************************
2113  *
2114  *  InsertIconInfo  (pIBD, pCD, theWidget)
2115  *
2116  *
2117  *  Description:
2118  *  -----------
2119  *  Finds next available spot and inserts the icon 
2120  *
2121  *
2122  *  Inputs:
2123  *  ------
2124  *  pIBD        - pointer to icon box data
2125  *  pCD         - pointer to client data for this client
2126  *  theWidget   - widget containing the icon (may be null)
2127  * 
2128  *  Outputs:
2129  *  -------
2130  *
2131  *  Comments:
2132  *  --------
2133  * 
2134  *************************************<->***********************************/
2135
2136 IconInfo *InsertIconInfo (pIBD, pCD, theWidget)
2137
2138     IconBoxData *pIBD;
2139     ClientData *pCD;
2140     Widget theWidget;
2141
2142 {
2143     IconInfo *pII;
2144     int place;
2145     int amt, i;
2146     Arg setArgs[3];
2147     Arg getArgs[4];
2148     Dimension clipWidth, clipHeight;
2149 #ifdef WSM
2150     WsClientData *pWsc;
2151 #endif /* WSM */
2152
2153     place = GetNextIconPlace (&pIBD->IPD);
2154     if (place == NO_ICON_PLACE)
2155     {
2156         if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2157         {
2158             amt = pIBD->IPD.placementCols;              /* add a new row */
2159         }
2160         else
2161         {
2162             amt = pIBD->IPD.placementRows;              /* add a new column */
2163         }
2164
2165         if (!ExtendIconList (pIBD, amt))
2166         {
2167             Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
2168             return (NULL);
2169         }
2170
2171         if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2172         {
2173             pIBD->IPD.placementRows++;
2174         }
2175         else
2176         {
2177             pIBD->IPD.placementCols++;
2178         }
2179         place = GetNextIconPlace (&pIBD->IPD);
2180     }
2181
2182     insertPosition = place;
2183
2184     /*
2185      * Update icon info values
2186      */
2187
2188     pII = &pIBD->IPD.placeList[place];
2189     pII->theWidget = theWidget;
2190
2191     pII->pCD = pCD;
2192
2193 #ifdef WSM
2194     pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
2195     pWsc->iconPlace = place;
2196
2197     CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2198             &pWsc->iconX, &pWsc->iconY);
2199
2200
2201     /* update next free position */
2202
2203     pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
2204     pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
2205
2206 #else /* WSM */
2207     ICON_PLACE(pCD) = place;
2208
2209     CvtIconPlaceToPosition (&pIBD->IPD, ICON_PLACE(pCD),
2210             &ICON_X(pCD), &ICON_Y(pCD));
2211
2212
2213     /* update next free position */
2214
2215     pIBD->currentCol = ICON_X(pCD) / pIBD->pCD_iconBox->widthInc;
2216     pIBD->currentRow = ICON_Y(pCD) / pIBD->pCD_iconBox->heightInc;
2217
2218 #endif /* WSM */
2219
2220     /* 
2221      * Increase bboard size if necessary
2222      */
2223     i = 0;
2224     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
2225     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2226     XtGetValues (pIBD->clipWidget, getArgs, i);
2227
2228     i = 0;
2229     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2230     {
2231         if (pIBD->currentCol > pIBD->lastCol)
2232         {
2233             pIBD->lastCol = pIBD->currentCol;
2234         }
2235
2236         if (pIBD->currentRow > pIBD->lastRow)
2237         {
2238             pIBD->lastRow = pIBD->currentRow;
2239 #ifdef WSM
2240             if (clipHeight <= (Dimension) (pWsc->iconY + 
2241                                            pIBD->pCD_iconBox->heightInc))
2242             {
2243                 /*
2244                  * Increase bulletin board height as needed.
2245                  */
2246                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) 
2247                           pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
2248             }
2249 #else /* WSM */
2250             if (clipHeight <= (pII->pCD->iconY + pIBD->pCD_iconBox->heightInc))
2251             {
2252                 /*
2253                  * Increase bulletin board height as needed.
2254                  */
2255                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) 
2256                           pII->pCD->iconY + pIBD->pCD_iconBox->heightInc); i++;
2257             }
2258 #endif /* WSM */
2259         }
2260     }
2261     else
2262     {
2263         if (pIBD->currentCol > pIBD->lastCol)
2264         {
2265             pIBD->lastCol = pIBD->currentCol;
2266 #ifdef WSM
2267             if (clipWidth <= (Dimension) 
2268                               (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
2269             {
2270                 /*
2271                  * Increase bulletin board width as needed
2272                  */
2273                 XtSetArg (setArgs[i], XmNwidth, 
2274                 (XtArgVal) pWsc->iconX +
2275                            pIBD->pCD_iconBox->widthInc); i++;
2276             }
2277 #else /* WSM */
2278             if (clipWidth <= (pII->pCD->iconX + pIBD->pCD_iconBox->widthInc))
2279             {
2280                 /*
2281                  * Increase bulletin board width as needed
2282                  */
2283                 XtSetArg (setArgs[i], XmNwidth, 
2284                 (XtArgVal) pII->pCD->iconX +
2285                            pIBD->pCD_iconBox->widthInc); i++;
2286             }
2287 #endif /* WSM */
2288         }
2289
2290         if (pIBD->currentRow > pIBD->lastRow)
2291         {
2292             pIBD->lastRow = pIBD->currentRow;
2293         }
2294     }
2295
2296     if (i > 0)
2297     {
2298         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2299     }
2300
2301     return(pII);
2302     
2303
2304
2305 } /* END OF FUNCTION InsertIconInfo */
2306
2307
2308 \f
2309 /*************************************<->*************************************
2310  *
2311  *  DeleteIconFromBox
2312  *
2313  *
2314  *  Description:
2315  *  -----------
2316  *  XXDescription ...
2317  * 
2318  *************************************<->***********************************/
2319
2320 void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
2321 {
2322     Widget       theChild;
2323     ClientData  *pCD_tmp;
2324     Arg          args[4];
2325     Dimension    clipWidth, clipHeight;
2326     Dimension    oldWidth, oldHeight;
2327     int          newWidth, newHeight;
2328     int          i, newCols, newRows;
2329 #ifdef WSM
2330     WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
2331     WsClientData *pWsc;
2332
2333     pWsc = GetWsClientData (pWS, pCD);
2334 #endif /* WSM */
2335
2336     i = 0;
2337     XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2338     XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2339     XtGetValues (pIBD->bBoardWidget, args, i);
2340
2341     i = 0;
2342     XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
2343     XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2344     XtGetValues (pIBD->clipWidget, args, i);
2345
2346     clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
2347     clipWidth  /= (Dimension) pIBD->pCD_iconBox->widthInc;
2348
2349     /* 
2350      * find context of the activeIconTextWin to get pCD and then 
2351      * if it is the same as this client, hide it.
2352      */
2353
2354     if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
2355                         wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
2356     {
2357         if (pCD == pCD_tmp)
2358         {
2359             /* hide activeIconTextWin */
2360             HideActiveIconText ((WmScreenData *)NULL);
2361         }
2362     }
2363
2364 #ifdef WSM
2365     DeleteIconInfo (pWsc->pIconBox, pCD);
2366
2367     pWsc->pIconBox->numberOfIcons--;
2368
2369     theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
2370
2371     pWsc->pIconBox = NULL;
2372     pWsc->iconPlace = NO_ICON_PLACE;
2373 #else /* WSM */
2374     DeleteIconInfo (P_ICON_BOX(pCD), pCD);
2375
2376     pCD->pIconBox->numberOfIcons--;
2377
2378     theChild = XtWindowToWidget (DISPLAY, ICON_FRAME_WIN(pCD));
2379 #endif /* WSM */
2380     XtUnmanageChild (theChild);
2381
2382     XtDestroyWidget (theChild);
2383
2384     /* update last row and col */
2385
2386     SetNewBounds (pIBD);
2387
2388     /* resize Bulletin board  (so scroll bars show correctly */
2389     i = 0;
2390
2391     if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
2392     {
2393         newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
2394         XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2395         newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2396     }
2397     else
2398     {
2399         newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;    
2400         XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2401         newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2402     }
2403
2404     if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
2405     {
2406         /* set height of bboard */
2407         newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2408         XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2409         newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2410     }
2411     else
2412     {
2413         newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
2414         XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2415         newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2416     }
2417
2418     if (i > 0  &&  ExpandVirtualSpace(pIBD, newWidth, newHeight))
2419     {
2420         XtSetValues (pIBD->bBoardWidget, args, i);
2421         RealignIconList (pIBD, newCols, newRows);
2422         pIBD->IPD.placementCols = newCols;
2423         pIBD->IPD.placementRows = newRows;
2424     }
2425
2426
2427     /* reset max size for icon box */
2428     ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2429     
2430     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
2431
2432 } /* END FUNCTION DeleteIconFromBox */
2433
2434
2435 \f
2436 /*************************************<->*************************************
2437  *
2438  *  DeleteIconInfo (pIBD, pCD)
2439  *
2440  *
2441  *  Description:
2442  *  -----------
2443  *  Deletes an icon info record from the icon box list based on the 
2444  *  client data pointer.
2445  *
2446  *
2447  *  Inputs:
2448  *  ------
2449  *  pIBD        - pointer to icon box data
2450  *  pCD         - pointer to client data
2451  * 
2452  *  Outputs:
2453  *  -------
2454  *
2455  *
2456  *  Comments:
2457  *  --------
2458  *  o The deleted item is freed
2459  *  o Is pCD the correct key???? !!!
2460  * 
2461  *************************************<->***********************************/
2462 void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
2463 {
2464     int ix, count;
2465     IconInfo *pII;
2466
2467     /* find first matching entry in list */
2468
2469     pII = &pIBD->IPD.placeList[0]; 
2470     count = pIBD->IPD.totalPlaces;
2471
2472     for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
2473     {
2474     }
2475
2476     if (ix < count)
2477     {
2478         /* found it, zero the entry out */
2479         pII->theWidget = NULL;
2480         pII->pCD = NULL;
2481     }
2482
2483
2484 } /* END FUNCTION DeleteIconInfo */
2485
2486
2487 \f
2488 /*************************************<->*************************************
2489  *
2490  *  ResetIconBoxMaxSize(pCD, bBoardWidget)
2491  *
2492  *
2493  *  Description:
2494  *  -----------
2495  *  XXDescription ...
2496  * 
2497  *************************************<->***********************************/
2498
2499 void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
2500 {
2501     int i;
2502     Arg getArgs[3]; 
2503     Dimension newWidth;
2504     Dimension newHeight;
2505
2506     i=0;
2507     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
2508     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
2509     XtGetValues (bBoardWidget, getArgs, i);
2510
2511     pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
2512
2513     pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
2514
2515     pCD->maxX = pCD->clientX;
2516     pCD->maxY = pCD->clientY;
2517     PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY, 
2518                         pCD->maxWidth, pCD->maxHeight);
2519
2520 } /* END OF FUNCTION    ResetIconBoxMaxSize */
2521
2522
2523 \f
2524 /*************************************<->*************************************
2525  *
2526  * CheckIconBoxSize(pIBD)
2527  *
2528  *
2529  *  Description:
2530  *  -----------
2531  *  XXDescription ...
2532  * 
2533  *************************************<->***********************************/
2534
2535 Boolean CheckIconBoxSize (IconBoxData *pIBD)
2536 {
2537     int i;
2538     Arg getArgs[3]; 
2539     Arg setArgs[3]; 
2540     Dimension oldWidth;
2541     Dimension oldHeight;
2542     Dimension newWidth;
2543     Dimension newHeight;
2544     int oldCol, oldRow;
2545     Boolean rval = True;
2546
2547     i=0;
2548     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2549     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2550     XtGetValues (pIBD->bBoardWidget, getArgs, i);
2551
2552     newWidth = oldWidth;
2553     newHeight = oldHeight;
2554     oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
2555     oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
2556
2557     /* 
2558      * Increase bboard size if necessary
2559      */
2560
2561     i = 0;
2562     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2563     {
2564         if (oldRow < pIBD->lastRow + 1)
2565         {
2566             /*
2567              * increase bulletin board height as needed
2568              */
2569             newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
2570                          + pIBD->pCD_iconBox->heightInc;
2571
2572             XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
2573         }
2574     }
2575     else
2576     {
2577         if (oldCol  < pIBD->lastCol + 1)
2578         {
2579             /*
2580              * increase bulletin board width as needed
2581              */
2582             newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
2583                             + pIBD->pCD_iconBox->widthInc;
2584
2585             XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
2586         }
2587     }
2588
2589     if (i > 0)
2590     {
2591         if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
2592         {
2593             /*
2594              * The user has resized the iconbox larger than
2595              * memory will allow.  Don't honor the resize request
2596              */
2597             rval = False;
2598             return(rval);
2599         }
2600         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2601     }
2602
2603     ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2604     
2605
2606     return(rval);
2607
2608 } /* END OF FUNCTION CheckIconBoxSize */
2609
2610
2611 \f
2612 /*************************************<->*************************************
2613  *
2614  * CheckIconBoxResize(pCD, changedValues)
2615  *
2616  *
2617  *  Description:
2618  *  -----------
2619  *  XXDescription ...
2620  * 
2621  *************************************<->***********************************/
2622
2623 void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
2624 {
2625
2626     Boolean  packVert = False;
2627     Boolean  packHorz = False;
2628     WmScreenData *pSD;
2629
2630     IconBoxData *pIBD;
2631     IconPlacementData *pIPD;
2632     int i, newCols, newRows;
2633     Arg getArgs[3]; 
2634     Arg setArgs[3]; 
2635     Dimension oldWidth;
2636     Dimension oldHeight;
2637
2638     pIPD = &pCD->thisIconBox->IPD;
2639     pIBD = pCD->thisIconBox;
2640
2641     pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
2642
2643     
2644     i=0;
2645     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2646     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2647     XtGetValues (pIBD->bBoardWidget, getArgs, i);
2648     
2649     newCols = pIPD->placementCols;
2650     newRows = pIPD->placementRows;
2651     newWidth = newWidth - pCD->baseWidth;               
2652     newHeight = newHeight - pCD->baseHeight;
2653     
2654     i = 0;
2655     
2656     if (changedValues & CWWidth) 
2657     {
2658         /*
2659          * There was a change in Width, see if we need to change the
2660          * bulletin board
2661          */
2662         if (newWidth > (int) oldWidth)
2663         {
2664             newCols = newWidth / pCD->widthInc;
2665             XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2666         }
2667         
2668         if (newWidth < (int) oldWidth)
2669         {
2670             if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
2671                 (newWidth / pCD->widthInc < pIBD->lastCol + 1))
2672             {
2673                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2674                 newCols = newWidth / pCD->widthInc;
2675                 packVert = True;
2676             }
2677             else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
2678             {
2679                 newWidth = (pIBD->lastCol +1) * pCD->widthInc;
2680                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2681             }
2682             else
2683             {
2684                 newCols = newWidth / pCD->widthInc;
2685                 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2686             }
2687         }
2688     }
2689     else
2690     {
2691         newWidth = oldWidth;
2692     }
2693         
2694     if (changedValues & CWHeight) 
2695     {
2696         /*
2697          * There was a change in Height, see if we need to change the
2698          * bulletin board
2699          */
2700         if (newHeight > (int) oldHeight)
2701         {
2702             newRows = newHeight / pCD->heightInc;
2703             XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2704         }
2705
2706         if (newHeight < (int) oldHeight)
2707         {
2708             if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
2709                 (newHeight / pCD->heightInc < pIBD->lastRow + 1))
2710             {
2711                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2712                 newRows = newHeight / pCD->heightInc;
2713                 packHorz = True;                
2714             }
2715             else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
2716             {
2717                 newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
2718                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2719             }
2720             else
2721             {
2722                 newRows = newHeight / pCD->heightInc;
2723                 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2724             }
2725         }
2726     }
2727     else
2728     {
2729         newHeight = oldHeight;
2730     }
2731     
2732     if ( i >0   &&   ExpandVirtualSpace(pIBD, newWidth, newHeight))
2733     {
2734         XtSetValues (pIBD->bBoardWidget, setArgs, i);
2735     }
2736
2737     RealignIconList (pIBD, newCols, newRows);
2738
2739     pIPD->placementCols = newCols;
2740     pIPD->placementRows = newRows;
2741     
2742     ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
2743     
2744     /*
2745      * Pack the icon box if there are icons that can no longer
2746      * be scrolled to due to iconBoxSBDisplayPolicy.
2747      */
2748     if (packVert)
2749     {
2750         PackIconBox (pIBD, packVert, False , newWidth, 0);
2751     }
2752     else if (packHorz)
2753     {
2754         PackIconBox (pIBD, False, packHorz , 0, newHeight);
2755     }
2756
2757
2758 } /* END OF FUNCTION CheckIconBoxResize */
2759
2760
2761 \f
2762 /*************************************<->*************************************
2763  *
2764  *  ExpandVirtualSpace (pIBD, newWidth, newHeight)
2765  *
2766  *
2767  *  Description:
2768  *  -----------
2769  *  Add virtural space (really the icon list )
2770  *
2771  *
2772  *  Inputs:
2773  *  ------
2774  *  pIBD        - ptr to icon box data
2775  *
2776  * 
2777  *  Outputs:
2778  *  -------
2779  *  Return      - True if successful, False otherwise
2780  *
2781  *  Comments:
2782  *  --------
2783  * 
2784  *************************************<->***********************************/
2785
2786 Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
2787 {
2788     Boolean rval = True;
2789     int newSize;
2790     int increment;
2791
2792     newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
2793                 (newHeight / pIBD->pCD_iconBox->heightInc);
2794
2795     if (newSize > pIBD->IPD.totalPlaces )
2796     {
2797         increment = newSize - pIBD->IPD.totalPlaces;
2798         rval = ExtendIconList (pIBD, increment);
2799     }
2800
2801     return (rval);
2802
2803 } /* END OF FUNCTION ExpandVirtualSpace */
2804
2805
2806 \f
2807 /*************************************<->*************************************
2808  *
2809  *  ExtendIconList (pIBD, incr);
2810  *
2811  *
2812  *  Description:
2813  *  -----------
2814  *  Add space to the icon list
2815  *
2816  *
2817  *  Inputs:
2818  *  ------
2819  *  pIBD        - ptr to icon box data
2820  *  incr        - number of cells to add
2821  *
2822  * 
2823  *  Outputs:
2824  *  -------
2825  *  Return      - True if successful, False otherwise
2826  *
2827  *  Comments:
2828  *  --------
2829  * 
2830  *************************************<->***********************************/
2831
2832 Boolean ExtendIconList (IconBoxData *pIBD, int incr)
2833 {
2834     Boolean rval;
2835     int newSize;
2836     IconInfo *pTmp;
2837
2838     newSize = pIBD->IPD.totalPlaces + incr;
2839
2840     if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
2841     {
2842         /* copy data */
2843         memcpy (pTmp, pIBD->IPD.placeList, 
2844             pIBD->IPD.totalPlaces*sizeof(IconInfo));
2845         memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
2846
2847         /* out with the old, in with the new */
2848         XtFree ((char *)pIBD->IPD.placeList);
2849         pIBD->IPD.placeList = pTmp;
2850         pIBD->IPD.totalPlaces = newSize;
2851         rval = True;
2852     }
2853     else
2854     {
2855         rval = False;
2856     }
2857
2858     return (rval);
2859 } /* END OF FUNCTION ExtendIconList */
2860
2861
2862 \f
2863 /*************************************<->*************************************
2864  *
2865  *  PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
2866  *
2867  *
2868  *  Description:
2869  *  -----------
2870  *  Packs the icons in the icon box
2871  *
2872  *
2873  *  Inputs:
2874  *  ------
2875  *  pIBD        - pointer to icon box data
2876  *
2877  * 
2878  *  Outputs:
2879  *  -------
2880  *
2881  *
2882  *  Comments:
2883  *  --------
2884  * 
2885  *************************************<->***********************************/
2886 void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
2887 {
2888     IconInfo *pII_2, *pII_1;
2889     int ix1, ix2;
2890     int count;
2891     int newX, newY;
2892     ClientData *pCD_tmp, *pMyCD;
2893     int hasActiveText = 1;
2894     Arg args[4];
2895     Dimension majorDimension, minorDimension;
2896     Dimension oldWidth, oldHeight;
2897     int newWidth, newHeight;
2898     int i;
2899     Boolean rippling = False;
2900 #ifdef WSM
2901     WsClientData *pWsc;
2902     WmWorkspaceData *pWS;
2903 #endif /* WSM */
2904
2905     i = 0;
2906     XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2907     XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2908     XtGetValues (pIBD->bBoardWidget, args, i);
2909
2910     /*
2911      * packing to visual space, first update IconBoxData
2912      */
2913
2914     i = 0;
2915
2916     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2917     {
2918         XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
2919         XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
2920         XtGetValues (pIBD->clipWidget, args, i);
2921         if (packVert)
2922         {
2923             majorDimension = passedInWidth;
2924         }
2925         
2926         minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2927         majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2928         if (majorDimension != pIBD->IPD.placementCols)
2929         {
2930             pIBD->IPD.placementCols = majorDimension;
2931         }
2932     }
2933     else
2934     {
2935         XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
2936         XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
2937         XtGetValues (pIBD->clipWidget, args, i);
2938         if (packHorz)
2939         {
2940             majorDimension = passedInHeight;
2941         }
2942
2943         minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2944         majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2945         if (majorDimension != pIBD->IPD.placementRows)
2946         {
2947             pIBD->IPD.placementRows = majorDimension;
2948         }
2949     }
2950
2951     /* 
2952      * find context of the activeIconTextWin to get pCD and then 
2953      * if it is the same as this client, hide it.
2954      */
2955
2956     pMyCD = pIBD->pCD_iconBox;
2957     if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
2958     {
2959         if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
2960                         wmGD.windowContextType, (caddr_t *)&pCD_tmp))
2961         {
2962             hasActiveText = 0;
2963         }
2964     }
2965
2966     pII_2 = pII_1 = pIBD->IPD.placeList;
2967     ix1 = ix2 = 0;
2968     count = pIBD->IPD.totalPlaces;
2969
2970     while (ix1 < count)
2971     {
2972         if (!rippling && (pII_2->pCD != NULL))
2973         {
2974             /* 
2975              * We need to start rippling the icons into new positions if
2976              * their (x,y) position changed 
2977              */
2978 #ifdef WSM
2979             pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2980             pWsc = GetWsClientData (pWS, pII_2->pCD);
2981             CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2982                 &newX, &newY);
2983
2984             rippling = ((newX != pWsc->iconX) ||
2985                         (newY != pWsc->iconY));
2986 #else /* WSM */
2987             CvtIconPlaceToPosition (&pIBD->IPD, pII_2->pCD->iconPlace,
2988                 &newX, &newY);
2989
2990             rippling = ((newX != pII_2->pCD->iconX) ||
2991                         (newY != pII_2->pCD->iconY));
2992 #endif /* WSM */
2993         }
2994
2995         if ((pII_2->pCD == NULL) || rippling)
2996         {
2997             /* find next one to move */
2998             while ((ix1 < count) && (pII_1->pCD == NULL))
2999             {
3000                 ix1++;
3001                 pII_1++;
3002             }
3003
3004             if ((ix1 < count) && (pII_1->pCD != NULL))
3005             {
3006                 if (ix1 != ix2)
3007                 {
3008                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3009                 }
3010
3011                 CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
3012
3013 #ifdef WSM
3014                 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
3015                 pWsc = GetWsClientData (pWS, pII_2->pCD);
3016                 pWsc->iconX = newX;
3017                 pWsc->iconY = newY;
3018 #else /* WSM */
3019                 pII_2->pCD->iconX = newX;
3020                 pII_2->pCD->iconY = newY;
3021 #endif /* WSM */
3022
3023                 if (hasActiveText && (pII_2->pCD == pCD_tmp))
3024                 {
3025                     /* hide activeIconTextWin first */
3026                     HideActiveIconText ((WmScreenData *)NULL);
3027                     XtMoveWidget (pII_2->theWidget, newX, newY);
3028                     ShowActiveIconText (pII_2->pCD);
3029                 }
3030                 else
3031                 {
3032                     XtMoveWidget (pII_2->theWidget, newX, newY);
3033                 }
3034             }
3035         }
3036
3037         if (ix1 < count)
3038         {
3039             ix2++;
3040             pII_2++;
3041         }
3042
3043         ix1++;
3044         pII_1++;
3045     }
3046
3047     /* update last row and col */
3048
3049     SetNewBounds (pIBD);
3050
3051     /* resize Bulletin board  (so scroll bars show correctly */
3052     i = 0;
3053     if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
3054     {
3055         if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
3056         {
3057             newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
3058             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3059         }
3060         else
3061         {
3062             newWidth = oldWidth;
3063         }
3064
3065         if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
3066         {
3067             /* set height of bboard */
3068             newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3069             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3070         }
3071         else
3072         {
3073             newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
3074             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3075         }
3076     }
3077     else
3078     {
3079         if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
3080         {
3081             newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3082             XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3083         }
3084         else
3085         {
3086             newHeight = oldHeight;
3087         }
3088
3089         if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
3090         {
3091             /* set width of bboard */
3092             newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;    
3093             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3094         }
3095         else
3096         {
3097             newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;    
3098             XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3099         }
3100     }
3101
3102     if (i > 0  &&  ExpandVirtualSpace(pIBD, newWidth, newHeight))
3103     {
3104         XtSetValues (pIBD->bBoardWidget, args, i);
3105     }
3106
3107
3108     /* reset max size for icon box */
3109
3110     ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
3111     
3112     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
3113
3114 } /* END FUNCTION PackIconBox */
3115
3116 \f
3117 /*************************************<->*************************************
3118  *
3119  *  RealignIconList (pIBD, newRows, newCols)
3120  *
3121  *
3122  *  Description:
3123  *  -----------
3124  *  Realigns the icon list according to the new virtual space dimensions 
3125  *
3126  *
3127  *  Inputs:
3128  *  ------
3129  *  pIBD        - ptr to icon box data
3130  *  newRows     - new number of rows
3131  *  newCols     - new number of columns
3132  *
3133  * 
3134  *  Outputs:
3135  *  -------
3136  *
3137  *  Comments:
3138  *  --------
3139  *  o The placement data structure contains the old values.
3140  * 
3141  *************************************<->***********************************/
3142
3143 void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
3144 {
3145     int c1, c2, ix1, ix2;
3146     int oldRows, oldCols;
3147     IconPlacementData  ipdNew;
3148     IconInfo *pII;
3149
3150     /* 
3151      * create new icon placement data for ease of calling conversion 
3152      * routines.
3153      */
3154     ipdNew.onRootWindow = pIBD->IPD.onRootWindow;
3155     ipdNew.iconPlacement = pIBD->IPD.iconPlacement;
3156     ipdNew.placementRows = newRows;
3157     ipdNew.placementCols = newCols;
3158     ipdNew.iPlaceW = pIBD->IPD.iPlaceW;
3159     ipdNew.iPlaceH = pIBD->IPD.iPlaceH;
3160     ipdNew.placeList = pIBD->IPD.placeList;
3161     ipdNew.totalPlaces = pIBD->IPD.totalPlaces;
3162
3163     oldRows = pIBD->IPD.placementRows;
3164     oldCols = pIBD->IPD.placementCols;
3165
3166     /*
3167      * Use the new organization and placement discipline to
3168      * determine how to move the icon info data around.
3169      */
3170     if (((oldRows < newRows) && 
3171          (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3172         ((oldCols < newCols) && 
3173          (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3174     { 
3175     /* 
3176      * work backwards 
3177      */
3178         for (ix1 = pIBD->IPD.totalPlaces - 1, 
3179                  pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
3180         {
3181             if (pII->pCD != NULL)
3182             {
3183                 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3184                 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3185                 if (ix1 != ix2)
3186                 { 
3187                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3188                 } 
3189             }
3190         }
3191     }
3192     else 
3193     if (((oldRows > newRows) && 
3194          (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3195         ((oldCols > newCols) && 
3196          (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3197     {
3198         /* 
3199          * work forwards 
3200          */
3201         for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1]; 
3202                 ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
3203         {
3204             if (pII->pCD != NULL)
3205             {
3206                 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3207                 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3208                 if (ix1 != ix2)
3209                 {
3210                     MoveIconInfo (&pIBD->IPD, ix1, ix2);
3211                 }
3212             }
3213         }
3214     }
3215
3216     /* 
3217      * update info in placement structure to reflect new reality
3218      */
3219     pIBD->IPD.placementRows = newRows;
3220     pIBD->IPD.placementCols = newCols;
3221
3222 } /* END OF FUNCTION RealignIconList */
3223
3224
3225
3226 \f
3227 /*************************************<->*************************************
3228  *
3229  *  SetNewBounds (pIBD)
3230  *
3231  *
3232  *  Description:
3233  *  -----------
3234  *
3235  *
3236  *  Inputs:
3237  *  ------
3238  *
3239  * 
3240  *  Outputs:
3241  *  -------
3242  *
3243  *  Comments:
3244  *  --------
3245  * 
3246  *************************************<->***********************************/
3247
3248 void SetNewBounds (IconBoxData *pIBD)
3249 {
3250
3251     int i;
3252     int X = 0;
3253     int Y = 0; 
3254     CompositeWidget cw;
3255     WidgetList      children;
3256
3257     cw = (CompositeWidget) pIBD->bBoardWidget;
3258     children = cw->composite.children;
3259
3260     for (i = 0; i < cw->composite.num_children; i++)
3261     {
3262         if (children[i]->core.x > X)
3263         {
3264             X = children[i]->core.x;
3265         }
3266         if (children[i]->core.y > Y)
3267         {
3268             Y = children[i]->core.y;
3269         }
3270     }
3271
3272     pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
3273     pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
3274
3275 } /* END OF FUNCTION SetNewBounds */
3276
3277
3278 \f
3279 /*************************************<->*************************************
3280  *
3281  *  InsertPosition (w)
3282  *
3283  *
3284  *  Description:
3285  *  -----------
3286  *  This procedure is passed to the bulletin board at create time
3287  *  to be used when a child is inserted into the bulletin board
3288  *  
3289  *
3290  *************************************<->***********************************/
3291 Cardinal InsertPosition (Widget w)
3292 {
3293     return (insertPosition);
3294
3295 } /* END OF FUNCTION InsertPosition */
3296
3297
3298 \f
3299 /*************************************<->*************************************
3300  *
3301  *  ShowClientIconState ();
3302  *
3303  *
3304  *  Description:
3305  *  -----------
3306  *  XXDescription ...
3307  *
3308  *************************************<->***********************************/
3309
3310 void ShowClientIconState (ClientData *pCD, int newState)
3311 {
3312
3313     /*
3314      * Changing the appearance of an icon window in the box to 
3315      * reflect the client's state
3316      */
3317
3318     if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
3319         XMapRaised (DISPLAY, pCD->iconWindow);
3320
3321     if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE )) 
3322                                                 && (pCD->iconWindow))
3323     {
3324         XUnmapWindow (DISPLAY, pCD->iconWindow);
3325     }
3326
3327 } /* END FUNCTION ShowClientIconState */
3328
3329
3330 \f
3331 #ifndef MOTIF_ONE_DOT_ONE
3332 /*************************************<->*************************************
3333  *
3334  *  IconScrollVisibleCallback
3335  *
3336  *
3337  *  Description:
3338  *  -----------
3339  *  for each icon in the icon box
3340  * 
3341  *************************************<->***********************************/
3342
3343 void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3344 {
3345     XmTraverseObscuredCallbackStruct *vis_data;
3346
3347     vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
3348
3349     XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
3350                     vis_data->traversal_destination,
3351                     0,0);
3352 /*
3353                     IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
3354 */
3355 } /* END OF FUNCTION IconScrollVisibleCallback */
3356
3357 #endif
3358
3359 \f
3360 /*************************************<->*************************************
3361  *
3362  *  IconActivateCallback
3363  *
3364  *
3365  *  Description:
3366  *  -----------
3367  *  for each icon in the icon box
3368  * 
3369  *************************************<->***********************************/
3370
3371 void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3372 {
3373     ClientData          *pCD;
3374     Window              theIcon;
3375
3376     theIcon = XtWindow(w);
3377
3378     /* 
3379      * find context to get pCD and then carry out
3380      * default action.
3381      */
3382
3383     if (!(XFindContext (DISPLAY, theIcon,
3384                         wmGD.windowContextType, (caddr_t *)&pCD)))
3385     {
3386         F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3387 /*      F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3388 */    }
3389
3390 } /* END OF FUNCTION IconActivateCallback */
3391
3392
3393 \f
3394 /*************************************<->*************************************
3395  *
3396  *  UpdateIncrements
3397  *
3398  *
3399  *  Description:
3400  *  -----------
3401  *  XXDescription ...
3402  * 
3403  *************************************<->***********************************/
3404
3405 void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
3406 {
3407     ResetArrowButtonIncrements (pIBD->pCD_iconBox);    
3408   
3409 } /* END OF FUNCTION UpdateIncrements */
3410
3411 \f
3412 /*************************************<->*************************************
3413  *
3414  *  ResetArrowButtonIncrements(pCD)
3415  *
3416  *************************************<->***********************************/
3417
3418 void ResetArrowButtonIncrements (ClientData *pCD)
3419 {
3420     int i;
3421     Arg setArgs[2]; 
3422         
3423     i=0;
3424     XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;    
3425     XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i); 
3426
3427     i=0;
3428     XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;    
3429     XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);     
3430     
3431 } /* END OF FUNCTION ResetArrowButtonIncrements */    
3432
3433
3434 \f
3435 /*************************************<->*************************************
3436  *
3437  *  ChangeActiveIconboxIconText
3438  *
3439  *
3440  *  Description:
3441  *  -----------
3442  *  XXDescription ...
3443  * 
3444  *************************************<->***********************************/
3445
3446 void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
3447 {
3448
3449     ClientData          *pCD;
3450     Window              theIcon;
3451
3452     /* 
3453      * find context to get pCD and then hide or show active icon text. 
3454      * Show/hide the active icon text only if the icon box is not 
3455      * iconified.
3456      */
3457
3458     theIcon = XtWindow(icon);
3459
3460     if (!(XFindContext (DISPLAY, theIcon,
3461                         wmGD.windowContextType, (caddr_t *)&pCD)) &&
3462         P_ICON_BOX(pCD) &&
3463         P_ICON_BOX(pCD)->pCD_iconBox &&
3464         P_ICON_BOX(pCD)->pCD_iconBox->clientState !=  MINIMIZED_STATE)
3465     {
3466         if (event->type == FocusIn) 
3467         {
3468             if (event->send_event)
3469             {
3470                ShowActiveIconText (pCD);
3471             }
3472         }
3473         else
3474         {
3475             if (event->send_event)
3476             {
3477                 HideActiveIconText (pCD->pSD);
3478             }
3479         }
3480     }
3481
3482 } /* END OF FUNCTION ChangeActiveIconboxIconText */
3483
3484
3485 \f
3486 /*************************************<->*************************************
3487  *
3488  *  HandleIconBoxIconKeyPress
3489  *
3490  *
3491  *  Description:
3492  *  -----------
3493  *  This event handler catches keyevents for icons in the icon box and
3494  *  passes them on to the standard key handling routine for mwm.
3495  *
3496  *************************************<->***********************************/
3497
3498 void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
3499 {
3500     
3501     Context context; 
3502     ClientData          *pCD; 
3503     Window              theIcon;
3504
3505     /*
3506      * find context to get pCD and then post menu show active icon text.
3507      */
3508     
3509     theIcon = XtWindow(icon);
3510     if (!(XFindContext (DISPLAY, theIcon,
3511                         wmGD.windowContextType, (caddr_t *)&pCD)))
3512     {
3513 #ifdef WSM
3514         SetClientWsIndex (pCD);
3515 #endif /* WSM */
3516         keyEvent->window = ICON_FRAME_WIN(pCD);
3517
3518         if (pCD->clientState == MINIMIZED_STATE)
3519         {
3520             context = F_SUBCONTEXT_IB_IICON;
3521             pCD->grabContext = F_SUBCONTEXT_IB_IICON;
3522         }
3523         else
3524         {
3525             context = F_SUBCONTEXT_IB_WICON;
3526             pCD->grabContext = F_SUBCONTEXT_IB_WICON;
3527         }
3528         
3529         if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs, 
3530                         True, context, False, pCD)))
3531         {
3532             keyEvent->window = 0;
3533             keyEvent->type = 0;
3534         }
3535
3536     }
3537         
3538 } /* END OF FUNCTION HandleIconBoxIconKeyPress */
3539
3540 \f
3541 /*************************************<->*************************************
3542  *
3543  *  HandleIconBoxButtonMotion
3544  *
3545  *
3546  *  Description:
3547  *  -----------
3548  *  Event handler for button motion events on icon frame window in 
3549  *  in icon box.
3550  *
3551  *
3552  *  Inputs:
3553  *  ------
3554  *  icon                - widget for icon frame 
3555  *  client_data         - extra client data
3556  *  pev                 - ptr to event
3557  *
3558  * 
3559  *  Outputs:
3560  *  -------
3561  *
3562  *
3563  *  Comments:
3564  *  --------
3565  *  o This is added to make sure that ButtonXMotion gets added to the 
3566  *    event mask for icons in the icon box.
3567  * 
3568  *************************************<->***********************************/
3569
3570 void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
3571 {
3572
3573 } /* END OF FUNCTION HandleIconBoxButtonMotion */
3574
3575
3576 \f
3577 /*************************************<->*************************************
3578  *
3579  *  GetIconBoxIconRootXY (pCD, pX, pY)
3580  *
3581  *
3582  *  Description:
3583  *  -----------
3584  *
3585  *
3586  *  Inputs:
3587  *  ------
3588  *  pCD         - pointer to client data
3589  *  pX          - pointer to X return value
3590  *  pY          - pointer to Y return value
3591  *
3592  *  Outputs:
3593  *  -------
3594  *
3595  *
3596  *  Comments:
3597  *  --------
3598  *  o returns root-window coords
3599  *
3600  *************************************<->***********************************/
3601 void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
3602 {
3603
3604     Window child;
3605 #ifdef WSM
3606     WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3607 #endif /* WSM */
3608
3609 #ifdef WSM
3610     if (pCD->pSD->useIconBox && pWsc->pIconBox)
3611 #else /* WSM */
3612     if (pCD->pSD->useIconBox && P_ICON_BOX(pCD))
3613 #endif /* WSM */
3614     {
3615 #ifdef WSM
3616         XTranslateCoordinates(DISPLAY,
3617                               XtWindow(pWsc->pIconBox->bBoardWidget),
3618                               ROOT_FOR_CLIENT(pCD),
3619                               pWsc->iconX + IB_MARGIN_WIDTH,
3620                               pWsc->iconY + IB_MARGIN_HEIGHT,
3621                               pX, pY, &child);
3622 #else /* WSM */
3623         XTranslateCoordinates(DISPLAY,
3624                               XtWindow(P_ICON_BOX(pCD)->bBoardWidget),
3625                               ROOT_FOR_CLIENT(pCD),
3626                               ICON_X(pCD) + IB_MARGIN_WIDTH,
3627                               ICON_Y(pCD) + IB_MARGIN_HEIGHT,
3628                               pX, pY, &child);
3629 #endif /* WSM */
3630
3631     }
3632     else
3633     {
3634         *pX = *pY = 0;
3635     }
3636 } /* END FUNCTION GetIconBoxIconRootXY */
3637
3638 \f
3639 /*************************************<->*************************************
3640  *
3641  *  IconVisible (pCD)
3642  *
3643  *
3644  *  Description:
3645  *  -----------
3646  *
3647  *  Inputs:
3648  *  ------
3649  *  pCD         - pointer to client data
3650  *
3651  *  Outputs:
3652  *  -------
3653  *
3654  *
3655  *  Comments:
3656  *  --------
3657  *
3658  *************************************<->***********************************/
3659 Boolean IconVisible (ClientData *pCD)
3660 {
3661
3662     /*
3663      * May use icon->core.visible field if that gets fixed and
3664      * we want to accept the Intrinsics idea of what is visible.
3665      */
3666
3667     Boolean rval = True;
3668 #ifdef WSM
3669     WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3670 #endif /* WSM */
3671
3672
3673     
3674     int i;
3675     Arg getArgs[5];
3676
3677     Dimension tmpWidth = 0;
3678     Dimension tmpHeight = 0;
3679     Position clipX = 0;
3680     Position clipY = 0;
3681     Position tmpX = 0;
3682     Position tmpY = 0;
3683     int iconX, iconY;
3684
3685     i=0;
3686     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &tmpWidth ); i++;
3687     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &tmpHeight ); i++;
3688     XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
3689     XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
3690 #ifdef WSM
3691     XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
3692     XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
3693                         tmpX, tmpY,
3694                         &clipX, &clipY);
3695 #else /* WSM */
3696     XtGetValues (P_ICON_BOX(pCD)->clipWidget, getArgs, i);
3697     XtTranslateCoords(P_ICON_BOX(pCD)->scrolledWidget,
3698                         tmpX, tmpY,
3699                         &clipX, &clipY);
3700 #endif /* WSM */
3701
3702     GetIconBoxIconRootXY(pCD, &iconX, &iconY);
3703
3704
3705     /* 
3706      * demand at least 2 pixels of the 
3707      * real icon (not drawnButton) be showing 
3708      */
3709        
3710     if (iconX + 2 > ((int)clipX + (int)tmpWidth))
3711     {
3712         return(False);
3713     }
3714     if (iconY + 2 > ((int)clipY + (int)tmpHeight))
3715     {
3716         return(False);
3717     }
3718
3719     if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
3720     {
3721         return(False);
3722     }
3723     if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
3724     {
3725         return(False);
3726     }
3727
3728     return(rval);
3729
3730 } /* END OF FUNCTION IconVisible */
3731 \f
3732 /*************************************<->*************************************
3733  *
3734  *  WmXmStringToString (xmString
3735  *
3736  *
3737  *  Description:
3738  *  -----------
3739  *
3740  *
3741  *  Inputs:
3742  *  ------
3743  *
3744  *  Outputs:
3745  *  -------
3746  *
3747  *
3748  *  Comments:
3749  *  --------
3750  *  Return the ascii part of the first segment of an XmString 
3751  *  If xmString is NULL, then do nothing 
3752  *
3753  *************************************<->***********************************/
3754
3755 String WmXmStringToString (XmString xmString)
3756
3757     XmStringContext       xmStrContext;
3758     char                 *asciiString = NULL; 
3759     XmStringCharSet      ibTitleCharset; 
3760     XmStringDirection    ibTitleDirection; 
3761     Boolean              separator; 
3762     
3763     if (xmString)
3764     {
3765         XmStringInitContext (&xmStrContext, xmString);
3766     
3767         XmStringGetNextSegment (xmStrContext, &asciiString, 
3768                                 &ibTitleCharset, &ibTitleDirection, 
3769                                 &separator);
3770
3771         if (ibTitleCharset != NULL) 
3772         {
3773             XtFree ((char *)ibTitleCharset);
3774         }
3775
3776         XmStringFreeContext (xmStrContext);
3777     }
3778     
3779     return(asciiString);
3780     
3781 } /* END OF FUNCTION WmXmStringToString */