2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = "$TOG: WmIconBox.c /main/7 1999/05/20 16:35:12 mgreess $"
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.
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>
56 #include <X11/keysymdef.h>
57 #include <X11/keysym.h>
61 #include <Xm/DialogS.h>
65 #include <Xm/DrawnB.h>
66 #include <Xm/ScrolledW.h>
67 #include <Xm/BulletinB.h>
68 #include <Xm/ToggleB.h>
70 #define MWM_NEED_IIMAGE
71 #define MWM_NEED_GREYED75
72 #define MWM_NEED_SLANT2
73 #include "WmIBitmap.h"
75 #include "WmResNames.h"
80 * include extern functions
83 #include "WmIconBox.h"
87 #include "WmFunction.h"
92 #include "WmPanelP.h" /* for typedef in WmManage.h */
96 #include "WmResParse.h"
97 #include "WmResource.h"
98 #include "WmWinInfo.h"
100 #include "WmWrkspace.h"
104 #define MAX(a,b) ((a)>(b)?(a):(b))
117 int frameShadowThickness;
119 Cardinal insertPosition = 0;
120 #define DEFAULT_ICON_BOX_TITLE "Icons"
121 Const char *szhorizontal = "horizontal";
122 Const char *szvertical = "vertical";
125 /*************************************<->*************************************
132 * This function controls creation of icon boxes
135 *************************************<->***********************************/
136 void InitIconBox (WmScreenData *pSD)
143 * Start the process of making the icon boxes
150 * Manage a separate icon box in every workspace
153 for (iws = 0; iws < pSD->numWorkspaces; iws++)
155 AddIconBoxForWorkspace (&pSD->pWS[iws]);
159 ManageWindow (pSD, None, MANAGEW_ICON_BOX);
162 if (pSD->fadeNormalIcon)
164 MakeFadeIconGC (pSD);
168 } /* END OF FUNCTION InitIconBox */
172 /*************************************<->*************************************
174 * AddIconBoxForWorkspace (pWS)
179 * This function adds an iconbox to a workspace
182 *************************************<->***********************************/
183 void AddIconBoxForWorkspace (WmWorkspaceData *pWS)
186 extern WmWorkspaceData *pIconBoxInitialWS;
188 pIconBoxInitialWS = pWS;
189 ManageWindow (pWS->pSD, None, MANAGEW_ICON_BOX);
191 } /* END OF FUNCTION AddIconBoxForWorkspace */
195 /*************************************<->*************************************
197 * MakeIconBox (pWS, pCD);
207 * pWS = pointer to workspace data
208 * pCD = a pointer to ClientData
214 * Return = (Boolean) True iff successful.
219 * If fails, frees the ClientData structure pointed to by pCD.
221 *************************************<->***********************************/
223 Boolean MakeIconBox (WmWorkspaceData *pWS, ClientData *pCD)
229 * Make an icon box and return the pCD
234 if (!(pIBD = (IconBoxData *)XtMalloc (sizeof (IconBoxData))))
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
243 Warning (((char *)GETMESSAGE(36, 1, "Insufficient memory to create icon box data")));
244 XtFree ((char *)pCD);
248 InitializeIconBoxData (pWS, pIBD);
249 InitializeClientData (pCD, pIBD);
251 if (!(pIBD->IPD.placeList =
252 (IconInfo *)XtMalloc (pIBD->IPD.totalPlaces * sizeof (IconInfo))))
254 Warning (((char *)GETMESSAGE(36, 2, "Insufficient memory to create icon box data")));
255 XtFree ((char *)pIBD);
256 XtFree ((char *)pCD);
259 memset (pIBD->IPD.placeList, 0,
260 pIBD->IPD.totalPlaces * sizeof (IconInfo));
263 * Make the top level shell for this icon box
265 MakeShell (pWS, pIBD);
268 * Make the scrolled window for this icon box
271 MakeScrolledWindow (pWS, pIBD);
274 * Make the row column manager for this icon box
276 MakeBulletinBoard (pWS, pIBD);
279 * Realize the widget tree and set client data fields
282 RealizeIconBox (pWS, pIBD, pCD);
285 * Link the new icon box to list of icon boxes
287 AddNewBox (pWS, pIBD);
292 } /* END OF FUNCTION MakeIconBox */
296 /*************************************<->*************************************
298 * DestroyIconBox (pWS)
303 * Destroys an icon box
308 * pWS = pointer to workspace data
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.
323 *************************************<->***********************************/
325 void DestroyIconBox (WmWorkspaceData *pWS)
329 pIBD = pWS->pIconBox;
331 XtDestroyWidget (pIBD->shellWidget);
333 UnManageWindow (pIBD->pCD_iconBox);
335 XtFree ((char *) pIBD);
337 } /* END OF FUNCTION DestroyIconBox */
341 /*************************************<->*************************************
343 * MakeShell (pWS, pIBD)
353 * pWS = pointer to workspace data
355 * pIBD = pointer to IconBoxData
370 *************************************<->***********************************/
372 void MakeShell (WmWorkspaceData *pWS, IconBoxData *pIBD)
378 char *pchIBTitle = NULL;
382 * Create top level application shell for icon box
387 XtSetArg (setArgs[i], XmNallowShellResize, (XtArgVal)True); i++;
389 XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal)0); i++;
391 XtSetArg (setArgs[i], XmNkeyboardFocusPolicy, (XtArgVal)XmEXPLICIT); i++;
394 if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
396 XtSetArg (setArgs[i], XmNbackground,
397 (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
398 XtSetArg (setArgs[i], XmNforeground,
399 (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
402 if (pWS->pSD->iconBoxTitle)
404 pchIBTitle = WmXmStringToString (pWS->pSD->iconBoxTitle);
406 XtSetArg (setArgs[i], XmNtitle, (XtArgVal)pchIBTitle); i++;
407 XtSetArg (setArgs[i], XmNiconName, (XtArgVal)pchIBTitle); i++;
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++;
418 pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNclient,
419 topLevelShellWidgetClass,
420 pWS->workspaceTopLevelW,
421 (ArgList)setArgs, i);
423 if (pchIBTitle != NULL) XtFree (pchIBTitle);
425 pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNiconBox,
426 topLevelShellWidgetClass,
427 pWS->workspaceTopLevelW,
428 (ArgList)setArgs, i);
431 } /* END OF FUNCTION MakeShell */
435 /*************************************<->*************************************
437 * MakeScrolledWindow (pWS, pIBD)
447 * pWS = pointer to workspace data
448 * pIBD = pointer to IconBoxData
455 * Return = pIBD with the pIBD->scrolledWidget set
462 *************************************<->***********************************/
464 void MakeScrolledWindow (WmWorkspaceData *pWS, IconBoxData *pIBD)
471 * Create frame widget to give the scrolled window
478 if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
480 XtSetArg (setArgs[i], XmNbackground,
481 (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
482 XtSetArg (setArgs[i], XmNforeground,
483 (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
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",
496 (ArgList)setArgs, i);
499 XtAddCallback (pIBD->frameWidget, XmNhelpCallback,
500 WmDtWmTopicHelpCB, WM_DT_ICONBOX_TOPIC);
504 * Create scrolled window to hold row column manager
509 XtSetArg (setArgs[i], XmNscrollingPolicy , (XtArgVal) XmAUTOMATIC ); i++;
511 XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0 ); i++;
512 XtSetArg (setArgs[i], XmNspacing , (XtArgVal) IB_MARGIN_WIDTH ); i++;
515 if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
517 XtSetArg (setArgs[i], XmNbackground,
518 (XtArgVal) pWS->pSD->clientAppearance.background ); i++;
519 XtSetArg (setArgs[i], XmNforeground,
520 (XtArgVal) pWS->pSD->clientAppearance.foreground ); i++;
524 * do we want to get these from a resource or set it here
525 * to control the appearance of the iconBox
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++;
533 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,(XtArgVal) XmSTATIC ); i++;
534 XtSetArg (setArgs[i], XmNvisualPolicy, (XtArgVal) XmVARIABLE ); i++;
536 pIBD->scrolledWidget = XtCreateManagedWidget ("IBsWindow",
537 xmScrolledWindowWidgetClass,
539 (ArgList)setArgs, i);
541 #ifndef MOTIF_ONE_DOT_ONE
542 XtAddCallback(pIBD->scrolledWidget, XmNtraverseObscuredCallback,
543 (XtCallbackProc) IconScrollVisibleCallback, (caddr_t)NULL);
546 XtAddEventHandler(pIBD->scrolledWidget,
549 (XtEventHandler)UpdateIncrements,
554 } /* END OF FUNCTION MakeScrolledWindow */
558 /*************************************<->*************************************
560 * MakeBulletinBoard (pWS, pIBD)
570 * pWS = pointer to workspace data
571 * pIBD = pointer to IconBoxData
579 * Return = pIBD with the pIBD->bBoardWidget
586 *************************************<->***********************************/
588 void MakeBulletinBoard (WmWorkspaceData *pWS, IconBoxData *pIBD)
595 * Create bulletin board to hold icons
599 #ifdef DEBUG_ICON_BOX
600 XtSetArg (setArgs[i], XmNborderWidth , 1); i++;
602 XtSetArg (setArgs[i], XmNborderWidth , 0); i++;
603 #endif /* DEBUG_ICON_BOX */
605 XtSetArg (setArgs[i], XmNshadowThickness,(XtArgVal) 0); i++;
607 if (!(Monochrome (XtScreen (pWS->pSD->screenTopLevelW))))
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++;
618 XtSetArg (setArgs[i], XmNspacing , 0); i++;
619 XtSetArg (setArgs[i], XmNmarginHeight , 0); i++;
620 XtSetArg (setArgs[i], XmNmarginWidth , 0); i++;
622 XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal) XmDIALOG_WORK_AREA); i++;
624 XtSetArg (setArgs[i], XmNresizePolicy, (XtArgVal) XmRESIZE_NONE); i++;
625 XtSetArg (setArgs[i], XmNdefaultPosition , (XtArgVal) False); i++;
627 XtSetArg (setArgs[i], XtNinsertPosition , InsertPosition); i++;
629 pIBD->bBoardWidget = XtCreateManagedWidget ("IBbBoard",
630 xmBulletinBoardWidgetClass,
631 pIBD->scrolledWidget,
632 (ArgList)setArgs, i);
634 } /* END OF FUNCTION MakeBulletinBoard */
638 /*************************************<->*************************************
640 * RealizeIconBox (pWS, pIBD, pCD)
650 * pWS = pointer to workspace data
652 * pIBD = pointer to IconBoxData
654 * pCD = pointer to ClientData
661 * Return = pIBD with the pIBD->shellWin set
662 * Return = pIBD with the pIBD->scrolledWin set
663 * Return = pIBD with the pIBD->bBoardWin set
666 * Return = pCD with appropriate fields set
673 *************************************<->***********************************/
675 void RealizeIconBox (WmWorkspaceData *pWS, IconBoxData *pIBD, ClientData *pCD)
686 XtRealizeWidget (pIBD->shellWidget);
688 pCD->client = XtWindow (pIBD->shellWidget);
691 * This will set the scrolling granularity for the icon box
694 SetGeometry (pWS, pCD, pIBD);
697 * Point to the iconBox
700 pIBD->pCD_iconBox = pCD;
701 pCD->thisIconBox = pIBD;
703 * get the background color of the bulletin board for
708 XtSetArg (setArgs[i], XmNbackground, (XtArgVal) select_color ); i++;
709 XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
713 XtSetArg (getArgs[i], XmNbackgroundPixmap, (XtArgVal) &bgPixmap ); i++;
714 XtGetValues (pIBD->bBoardWidget, getArgs, i);
717 XtSetArg (getArgs[i], XmNclipWindow, (XtArgVal) &clipWidget ); i++;
718 XtGetValues (pIBD->scrolledWidget, getArgs, i);
721 * Set the background of the clip window for the scrolled
722 * window so the default widget background doesn't flash
726 XtSetArg(setArgs[i], XmNbackground, (XtArgVal) select_color); i++;
727 XtSetValues (clipWidget, (ArgList) setArgs, i);
731 * Save the clipWidget id to use in constraining icon moves in box
734 pIBD->clipWidget = clipWidget;
736 MakeShrinkWrapIconsGC (pWS->pSD, bgPixmap);
739 if (pWS->pSD->iconDecoration & ICON_IMAGE_PART)
742 * Make a pixmap to use when iconWindows are unmapped
744 defaultImage = XCreateBitmapFromData (DISPLAY, pWS->pSD->rootWindow,
745 (char*)iImage_bits, iImage_width,
748 pWS->pSD->defaultPixmap = MakeIconPixmap (pCD,
755 } /* END OF FUNCTION RealizeIconBox */
759 /*************************************<->*************************************
761 * AddNewBox (pWS, pIBD)
771 * pWS = pointer to workspace data
773 * pIBD = pointer to IconBoxData
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.
785 *************************************<->***********************************/
787 void AddNewBox (WmWorkspaceData *pWS, IconBoxData *pIBD)
794 pibd = pWS->pIconBox;
796 while (pibd->pNextIconBox)
798 pibd = pibd->pNextIconBox;
801 pibd->pNextIconBox = pIBD;
805 pWS->pIconBox = pIBD;
809 } /* END OF FUNCTION AddNewBox */
813 /*************************************<->*************************************
815 * InitializeIconBoxData (pWS, pIBD)
825 * pWS = pointer to Workspace Data
827 * pIBD = pointer to IconBoxData
836 * Initializes all pIBD fields to NULL
838 *************************************<->***********************************/
840 void InitializeIconBoxData (WmWorkspaceData *pWS, IconBoxData *pIBD)
849 frameShadowThickness = FRAME_INTERNAL_SHADOW_WIDTH;
851 pIBD->numberOfIcons = 0;
852 pIBD->currentRow = 0;
853 pIBD->currentCol = 0;
856 pIBD->IPD.placeList = NULL;
858 pIBD->scrolledWidget = NULL;
859 pIBD->bBoardWidget = NULL;
860 pIBD->clipWidget = NULL;
862 pIBD->wsID = pWS->id;
865 ToLower (pWS->pSD->iconBoxSBDisplayPolicy);
867 if (!((!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , "all")) ||
868 (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)) ||
869 (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))))
871 strcpy(pWS->pSD->iconBoxSBDisplayPolicy, "all");
877 * this will be set by the iconPlacement resource if
878 * iconBoxGeometry width and height are not specified
882 if (pWS->iconBoxGeometry == NULL) /* not set by user */
884 if (pWS->pSD->iconBoxGeometry == NULL) /* not set by user */
888 * Use the iconPlacement resource
891 if (pWS->pSD->iconPlacement &
892 (ICON_PLACE_TOP_PRIMARY | ICON_PLACE_BOTTOM_PRIMARY))
894 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
895 pIBD->IPD.placementCols = 1;
896 pIBD->IPD.placementRows = 6;
900 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
901 pIBD->IPD.placementCols = 6;
902 pIBD->IPD.placementRows = 1;
909 mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
912 mask = XParseGeometry(pWS->pSD->iconBoxGeometry, &X, &Y,
916 if ((mask & WidthValue) && (width > 0))
918 pIBD->IPD.placementCols = (int)width;
922 pIBD->IPD.placementCols = 6;
925 if ((mask & HeightValue) && (height > 0))
927 pIBD->IPD.placementRows = (int)height;
931 pIBD->IPD.placementRows = 1;
938 if (pIBD->IPD.placementRows <= pIBD->IPD.placementCols)
940 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
944 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
950 * Override orientation if iconBoxSBDisplayPolicy is set to
951 * horizontal or vertical
954 if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)))
956 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
958 else if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal)))
960 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
967 * set initial size of placement space to size of screen
970 sW = DisplayWidth (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconWidth;
971 sH = DisplayHeight (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconHeight;
973 pIBD->IPD.totalPlaces = sW * sH;
975 pIBD->IPD.onRootWindow = False;
978 * The icon box does not live in an icon box in this version
981 pIBD->pNextIconBox =NULL;
984 } /* END OF FUNCTION InitializeIconBoxData */
988 /*************************************<->*************************************
990 * SetIconBoxInfo (pWS, pCD)
1004 *************************************<->***********************************/
1006 void SetIconBoxInfo (WmWorkspaceData *pWS, ClientData *pCD)
1008 pCD->clientClass = WmCIconBox;
1009 pCD->clientName = pWS->pSD->iconBoxName;
1010 ProcessClientResources (pCD);
1012 } /* END OF FUNCTION SetIconBoxInfo */
1016 /*************************************<->*************************************
1018 * InitializeClientData (pCD)
1037 * Initializes geometry, etc. fields
1039 *************************************<->***********************************/
1041 void InitializeClientData (ClientData *pCD, IconBoxData *pIBD)
1043 pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 :
1044 FRAME_INTERNAL_SHADOW_WIDTH;
1049 pCD->clientFlags |= ICON_BOX ;
1051 pCD->widthInc = pIBD->IPD.iPlaceW = ICON_WIDTH(pCD)
1053 + (2 * IB_MARGIN_WIDTH);
1055 pCD->heightInc = pIBD->IPD.iPlaceH = ICON_HEIGHT(pCD)
1057 + (2 * IB_MARGIN_HEIGHT);
1059 pCD->clientWidth = pIBD->IPD.placementCols * pCD->widthInc;
1060 pCD->clientHeight = pIBD->IPD.placementRows * pCD->heightInc;
1062 if (!(pCD->pSD->iconBoxTitle))
1064 #ifndef NO_MESSAGE_CATALOG
1065 pCD->pSD->iconBoxTitle =
1066 XmStringCreateLocalized(wmNLS.default_icon_box_title);
1068 pCD->pSD->iconBoxTitle =
1069 XmStringCreateLocalized(DEFAULT_ICON_BOX_TITLE);
1073 pCD->clientTitle = pCD->pSD->iconBoxTitle;
1074 pCD->iconTitle = pCD->pSD->iconBoxTitle;
1076 } /* END OF FUNCTION InitializeClientData */
1080 /*************************************<->*************************************
1082 * MakeShrinkWrapIconsGC (pSD, bgPixmap)
1087 * Make an graphic context to shrink the icons in the icon box
1088 * box that are not in the MINIMIZED_STATE.
1093 * pSD - pointer to screen data
1097 * Modifies global data
1103 *************************************<->***********************************/
1105 void MakeShrinkWrapIconsGC (WmScreenData *pSD, Pixmap bgPixmap)
1111 if (!pSD->shrinkWrapGC)
1113 pSD->shrinkWrapGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1114 (XGCValues *) NULL);
1118 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1119 copyMask, pSD->shrinkWrapGC);
1121 if (bgPixmap != XmUNSPECIFIED_PIXMAP)
1123 XSetTile (DISPLAY, pSD->shrinkWrapGC, bgPixmap);
1124 XSetFillStyle (DISPLAY, pSD->shrinkWrapGC, FillTiled);
1125 XSetBackground (DISPLAY, pSD->shrinkWrapGC, select_color);
1129 XSetForeground (DISPLAY, pSD->shrinkWrapGC, select_color);
1133 } /* END OF FUNCTION MakeShrinkWrapIconsGC */
1137 /*************************************<->*************************************
1139 * MakeFadeIconGC (pSD)
1144 * Make an graphic context for "greying" the icons in the icon
1145 * box that are not in the MINIMIZED_STATE.
1150 * pSD = pointer to screen data
1154 * Modifies global data
1160 *************************************<->***********************************/
1162 void MakeFadeIconGC (WmScreenData *pSD)
1166 static Pixmap tmpFontClipMask;
1169 pSD->fadeIconGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1170 (XGCValues *) NULL);
1171 pSD->fadeIconTextGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1172 (XGCValues *) NULL);
1176 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1177 copyMask, pSD->fadeIconGC);
1179 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1180 copyMask, pSD->fadeIconTextGC);
1182 tmpFontClipMask = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1183 (char*)greyed75_bits, greyed75_width, greyed75_height);
1185 greyedPixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1186 (char*)slant2_bits, slant2_width, slant2_height);
1188 XSetStipple (DISPLAY, pSD->fadeIconTextGC, tmpFontClipMask);
1189 XSetFillStyle (DISPLAY, pSD->fadeIconTextGC, FillStippled);
1191 XSetStipple (DISPLAY, pSD->fadeIconGC, greyedPixmap);
1192 XSetFillStyle (DISPLAY, pSD->fadeIconGC, FillStippled);
1193 XSetForeground (DISPLAY, pSD->fadeIconGC, select_color);
1195 } /* END OF FUNCTION MakeFadeIconGC */
1199 /*************************************<->*************************************
1201 * SetGeometry (pWS, pCD, pIBD)
1211 * pIBD = pointer to IconBoxData
1212 * pCD = pointer to ClientData
1226 *************************************<->***********************************/
1228 void SetGeometry (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1238 unsigned int height;
1239 unsigned int boxdim, tmpMin;
1241 unsigned long decoration;
1244 * Set horizontal and vertical scrolling granularity
1247 SetGranularity (pWS, pCD, pIBD );
1250 * Set the initial width and height of the icon box bulletin board
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);
1259 * Adjust icon box window height for height of
1260 * horizontal scroll bar etc.
1263 pCD->clientHeight = pCD->clientHeight + pCD->baseHeight;
1264 pCD->oldMaxHeight = pCD->maxHeight = pCD->clientHeight;
1267 * Adjust iconbox window width for width of
1268 * vertical scroll bar etc.
1271 pCD->clientWidth = pCD->clientWidth + pCD->baseWidth;
1272 pCD->oldMaxWidth = pCD->maxWidth = pCD->clientWidth;
1276 * Check that minWidth is large enough to disallow overlap
1277 * of title bar gadgets
1280 /* compute for minimum frame size */
1281 if ((decoration = pCD->decor) & MWM_DECOR_TITLE)
1283 boxdim = InitTitleBarHeight(pCD); /* macro not valid yet */
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);
1295 * minWidth >= tmpMin
1296 * minWidth >= max (baseWidth, widthInc) > 0
1297 * & an integral number of widthInc from baseWidth.
1300 if (pCD->minWidth < tmpMin)
1302 if ((diff = ((tmpMin - pCD->baseWidth)%pCD->widthInc)) != 0)
1304 pCD->minWidth = tmpMin + pCD->widthInc - diff;
1308 pCD->minWidth = tmpMin;
1312 if (pCD->minWidth < pCD->baseWidth)
1314 pCD->minWidth = pCD->baseWidth;
1317 if (pCD->minWidth == 0)
1319 pCD->minWidth = pCD->widthInc;
1321 else if ((diff = ((pCD->minWidth - pCD->baseWidth)%pCD->widthInc)) != 0)
1323 pCD->minWidth += pCD->widthInc - diff;
1328 if (pCD->clientWidth < pCD->minWidth)
1330 pCD->clientWidth = pCD->minWidth;
1333 pIBD->IPD.placementCols = (int)((pCD->clientWidth - pCD->baseWidth)
1340 * maxWidth >= minWidth
1341 * & an integral number of widthInc from baseWidth.
1344 if (pCD->maxWidth < pCD->minWidth)
1346 pCD->maxWidth = pCD->minWidth;
1349 pCD->maxWidthLimit = pCD->maxWidth;
1351 pCD->maxWidth -= ((pCD->maxWidth - pCD->baseWidth)% pCD->widthInc);
1352 pCD->oldMaxWidth = pCD->maxWidth;
1354 pCD->maxHeightLimit = pCD->maxHeight;
1358 * Set the initial width and height of the icon box bulletin board
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);
1370 * Set the initial width and height of the icon box scrolled Window
1374 XtSetArg (setArgs[i], XmNwidth, (XtArgVal)
1375 (pCD->clientWidth - (2 * frameShadowThickness))); i++;
1376 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
1377 (pCD->clientHeight - (2 * frameShadowThickness))); i++;
1379 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1384 * Call SetFrameInfo with fake X and Y so we can get clientOffset
1387 pCD->xBorderWidth = 0;
1392 * Set initial placement of icon box
1396 mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
1399 mask = XParseGeometry(pCD->pSD->iconBoxGeometry,
1400 &X, &Y, &width, &height);
1405 if (mask & XNegative)
1408 + DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1410 - pCD->clientOffset.x;
1414 pCD->clientX = X + pCD->clientOffset.x;
1419 pCD->clientX = pCD->clientOffset.x;
1424 if (mask & YNegative)
1427 + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1429 - pCD->clientOffset.x ;
1433 pCD->clientY = Y + pCD->clientOffset.y;
1438 pCD->clientY = pCD->clientOffset.x
1439 + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1440 - pCD->clientHeight;
1444 PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY, pCD->clientWidth,
1446 pCD->clientX -= (wmGD.positionIsFrame
1447 ? pCD->clientOffset.x
1450 pCD->clientY -= (wmGD.positionIsFrame
1451 ? pCD->clientOffset.y
1457 XtSetArg (setArgs[i], XmNx, (XtArgVal) pCD->clientX); i++;
1458 XtSetArg (setArgs[i], XmNy, (XtArgVal) pCD->clientY); i++;
1460 XtSetValues (pIBD->shellWidget, (ArgList) setArgs, i);
1462 pCD->maxX = pCD->clientX;
1463 pCD->maxY = pCD->clientY;
1466 } /* END OF FUNCTION SetGeometry */
1470 /*************************************<->*************************************
1472 * SetGranularity (pWS, pCD, pIBD )
1482 * pIBD = pointer to IconBoxData
1483 * pCD = pointer to ClientData
1497 *************************************<->***********************************/
1499 void SetGranularity (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1503 Dimension hScrollBarHeight = 0;
1504 Dimension hBarHeight = 0;
1505 Dimension vScrollBarWidth = 0;
1506 Dimension vBarWidth = 0;
1509 short shadowThickness;
1513 short hShighlightThickness;
1514 short vShighlightThickness;
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);
1536 if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1540 * Set horizontal scrolling granularity
1543 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hBarHeight ); i++;
1544 XtSetArg (getArgs[i], XmNhighlightThickness,
1545 (XtArgVal) &hShighlightThickness); i++;
1546 XtGetValues (pIBD->hScrollBar, getArgs, i);
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++;
1557 XtSetValues (pIBD->hScrollBar, (ArgList) setArgs, i);
1560 * Get hScrollBarHeight and troughColor
1564 XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1565 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hScrollBarHeight ); i++;
1566 XtGetValues (pIBD->hScrollBar, getArgs, i);
1571 if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1575 * Set vertical scrolling granularity
1578 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vBarWidth ); i++;
1579 XtSetArg (getArgs[i], XmNhighlightThickness,
1580 (XtArgVal) &vShighlightThickness); i++;
1581 XtGetValues (pIBD->vScrollBar, getArgs, i);
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++;
1592 XtSetValues (pIBD->vScrollBar, (ArgList) setArgs, i);
1595 * Get vScrollBarWidth
1599 XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1600 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vScrollBarWidth ); i++;
1601 XtGetValues (pIBD->vScrollBar, getArgs, i);
1606 if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1608 XtUnmanageChild(pIBD->hScrollBar);
1609 hScrollBarHeight = 0;
1612 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
1613 (XtArgVal) XmAS_NEEDED ); i++;
1614 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1617 else if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1619 XtUnmanageChild(pIBD->vScrollBar);
1620 vScrollBarWidth = 0;
1623 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
1624 (XtArgVal) XmAS_NEEDED ); i++;
1625 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1631 pCD->baseWidth = IB_SPACING
1632 + 2 * IB_HIGHLIGHT_BORDER
1633 #ifdef DEBUG_ICON_BOX
1636 #endif /* DEBUG_ICON_BOX */
1637 + (int) vScrollBarWidth
1638 + 2 * frameShadowThickness
1639 + (int) 2 * marginWidth
1641 ? 2 * (int) shadowThickness
1646 pCD->baseHeight = IB_SPACING
1647 + 2 * IB_HIGHLIGHT_BORDER
1648 #ifdef DEBUG_ICON_BOX
1650 #endif /* DEBUG_ICON_BOX */
1652 + (int) hScrollBarHeight
1653 + 2 * frameShadowThickness
1654 + (int) 2 * marginHeight
1656 ? 2 * (int) shadowThickness
1659 pCD->minWidth = pCD->baseWidth + pCD->widthInc;
1660 pCD->minHeight = pCD->baseHeight + pCD->heightInc;
1662 pCD->oldMaxWidth = pCD->maxWidth = pCD->minWidth;
1664 pCD->oldMaxHeight = pCD->maxHeight = pCD->minHeight;
1666 } /* END OF FUNCTION SetGranularity */
1670 /*************************************<->*************************************
1672 * GetIconBoxMenuItems ()
1679 *************************************<->***********************************/
1681 MenuItem *GetIconBoxMenuItems (pSD)
1687 return(ParseMwmMenuStr (pSD,
1688 (unsigned char *)((char *)GETMESSAGE(36, 3, "\"Pack Icons\" _P Alt Shift<Key>F7 f.pack_icons\n"))));
1690 } /* END OF FUNCTION GetIconBoxMenuItems */
1694 /*************************************<->*************************************
1714 * Maps all iconboxes on the list starting at pWS->pIconBox
1716 *************************************<->***********************************/
1718 void MapIconBoxes (WmWorkspaceData *pWS)
1725 pibd = pWS->pIconBox;
1729 XtPopup(pibd->shellWidget, XtGrabNone);
1731 F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1732 XMapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
1734 pibd = pibd->pNextIconBox;
1739 } /* END OF FUNCTION MapIconBoxes */
1743 /*************************************<->*************************************
1745 * UnmapIconBoxes (pWS)
1750 * Unmaps all the iconboxes in the specified workspace
1755 * pWS = pointer to workspace data
1763 * Unmaps all iconboxes on the list starting at pWS->pIconBox
1764 * Does not do anything with icon windows.
1766 *************************************<->***********************************/
1768 void UnmapIconBoxes (WmWorkspaceData *pWS)
1775 pibd = pWS->pIconBox;
1779 XUnmapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
1780 pibd = pibd->pNextIconBox;
1784 } /* END OF FUNCTION UnmapIconBoxes */
1787 #if defined(PANELIST)
1789 /******************************<->*************************************
1795 * Returns True if an icon box tied to a front panel button is
1800 * pWS = pointer to workspace data
1801 * pCW = pointer to control window data (for front panel button )
1805 * Return = True if icon box is up, False if it's invisible
1810 ******************************<->***********************************/
1815 IconBoxShowing (WmWorkspaceData *pWS)
1816 #else /* PANELIST */
1818 IconBoxShowing (WmWorkspaceData *pWS, ControlWindowStruct *pCW)
1819 #endif /* PANELIST */
1821 Boolean rval = False;
1824 if (pWS->pIconBox &&
1825 ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
1829 #else /* PANELIST */
1830 if (pWS->pIconBox &&
1831 ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox) &&
1832 (pCW->pWsStatus[wsIndex].wsClientStatus == CLIENT_WINDOW_OPEN))
1836 #endif /* PANELIST */
1840 } /* END OF FUNCTION IconBoxShowing */
1844 /******************************<->*************************************
1846 * IconBoxPopUp (pWS, pCW, up)
1850 * Sets the state of the icon box attached to a front panel control.
1854 * pWS = pointer to workspace data
1855 * pCW = pointer to control window data (for front panel button )
1856 * up = flag, if True, pop the icon box up; if False, hide it.
1865 ******************************<->***********************************/
1869 IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
1870 #else /* PANELIST */
1872 IconBoxPopUp (WmWorkspaceData *pWS,
1873 ControlWindowStruct *pCW, Boolean up)
1874 #endif /* PANELIST */
1881 pibd = pWS->pIconBox;
1887 if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
1889 F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1893 AddClientToWorkspaces (pibd->pCD_iconBox,
1898 else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
1900 RemoveClientFromWorkspaces (pibd->pCD_iconBox,
1904 pibd = pibd->pNextIconBox;
1909 } /* END OF FUNCTION IconBoxPopUp */
1910 #endif /* PANELIST */
1915 /******************************<->*************************************
1921 * pCD - pointer to data for client to insert
1927 *************************************<->***********************************/
1929 Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
1932 Boolean rval = False;
1935 int iconWidth, iconHeight;
1936 IconBoxData *tmpPointerToIconBox;
1938 IconInfo *pIconInfo;
1939 static XmString dummyString = NULL;
1942 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
1944 pWsc = GetWsClientData (pWS, pCD);
1948 * If we go to multiple icon boxes, find the box this client
1949 * wants to live in. For now, we only have one, so point to
1953 tmpPointerToIconBox = pIBD;
1959 pWsc->pIconBox = tmpPointerToIconBox;
1961 P_ICON_BOX(pCD) = tmpPointerToIconBox;
1964 iconWidth = ICON_WIDTH(pCD)
1965 + (2 * IB_MARGIN_WIDTH);
1967 iconHeight = ICON_HEIGHT(pCD)
1968 + (2 * IB_MARGIN_HEIGHT);
1971 pIconInfo = InsertIconInfo (pWsc->pIconBox, pCD, (Widget) NULL);
1973 pIconInfo = InsertIconInfo (P_ICON_BOX(pCD), pCD, (Widget) NULL);
1979 pWsc->pIconBox->numberOfIcons++;
1981 P_ICON_BOX(pCD)->numberOfIcons++;
1985 XtSetArg (setArgs[i], XmNbackground,
1986 (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
1987 XtSetArg (setArgs[i], XmNforeground,
1988 (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
1991 XtSetArg (setArgs[i], XmNx , (XtArgVal) pWsc->iconX); i++;
1992 XtSetArg (setArgs[i], XmNy , (XtArgVal) pWsc->iconY); i++;
1994 XtSetArg (setArgs[i], XmNx , (XtArgVal) ICON_X(pCD)); i++;
1995 XtSetArg (setArgs[i], XmNy , (XtArgVal) ICON_Y(pCD)); i++;
1998 XtSetArg (setArgs[i], XmNwidth , (XtArgVal) iconWidth); i++;
1999 XtSetArg (setArgs[i], XmNheight , (XtArgVal) iconHeight); i++;
2001 XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0); i++;
2003 XtSetArg (setArgs[i], XmNhighlightThickness ,
2004 IB_HIGHLIGHT_BORDER); i++;
2006 XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
2007 XtSetArg (setArgs[i], XmNmarginWidth , (XtArgVal) 0); i++;
2009 * Use type XmString so we don't get a message from XmLabel
2011 XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
2013 XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
2015 XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
2017 XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
2019 XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
2021 iconWidget = XtCreateManagedWidget("iconInIconBox",
2022 xmDrawnButtonWidgetClass,
2024 pWsc->pIconBox->bBoardWidget,
2026 P_ICON_BOX(pCD)->bBoardWidget,
2028 (ArgList)setArgs, i);
2030 if (dummyString == NULL)
2033 XmStringCreateLocalized("");
2037 XtSetArg (setArgs[i], XmNlabelString,
2038 (XtArgVal) dummyString); i++;
2040 XtSetValues (iconWidget, setArgs, i);
2042 pIconInfo->theWidget = iconWidget;
2045 pWsc->iconFrameWin = XtWindow (iconWidget);
2047 ICON_FRAME_WIN(pCD) = XtWindow (iconWidget);
2050 XtAddCallback (iconWidget, XmNactivateCallback,
2051 (XtCallbackProc)IconActivateCallback,
2054 XtAddEventHandler(iconWidget,
2055 SELECT_BUTTON_MOTION_MASK,
2057 (XtEventHandler)HandleIconBoxButtonMotion,
2060 XtAddEventHandler(iconWidget,
2061 DMANIP_BUTTON_MOTION_MASK,
2063 (XtEventHandler)HandleIconBoxButtonMotion,
2066 XtAddEventHandler(iconWidget,
2069 (XtEventHandler)HandleIconBoxIconKeyPress,
2074 if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
2076 XtAddEventHandler(iconWidget,
2079 (XtEventHandler)ChangeActiveIconboxIconText,
2082 if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
2084 XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
2089 ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox,
2090 pWsc->pIconBox->bBoardWidget);
2092 ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
2095 ResetIconBoxMaxSize(P_ICON_BOX(pCD)->pCD_iconBox,
2096 P_ICON_BOX(pCD)->bBoardWidget);
2098 ResetArrowButtonIncrements (P_ICON_BOX(pCD)->pCD_iconBox);
2106 } /* END FUNCTION InsertIconIntoBox() */
2110 /*************************************<->*************************************
2112 * InsertIconInfo (pIBD, pCD, theWidget)
2117 * Finds next available spot and inserts the icon
2122 * pIBD - pointer to icon box data
2123 * pCD - pointer to client data for this client
2124 * theWidget - widget containing the icon (may be null)
2132 *************************************<->***********************************/
2134 IconInfo *InsertIconInfo (pIBD, pCD, theWidget)
2146 Dimension clipWidth, clipHeight;
2151 place = GetNextIconPlace (&pIBD->IPD);
2152 if (place == NO_ICON_PLACE)
2154 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2156 amt = pIBD->IPD.placementCols; /* add a new row */
2160 amt = pIBD->IPD.placementRows; /* add a new column */
2163 if (!ExtendIconList (pIBD, amt))
2165 Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
2169 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2171 pIBD->IPD.placementRows++;
2175 pIBD->IPD.placementCols++;
2177 place = GetNextIconPlace (&pIBD->IPD);
2180 insertPosition = place;
2183 * Update icon info values
2186 pII = &pIBD->IPD.placeList[place];
2187 pII->theWidget = theWidget;
2192 pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
2193 pWsc->iconPlace = place;
2195 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2196 &pWsc->iconX, &pWsc->iconY);
2199 /* update next free position */
2201 pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
2202 pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
2205 ICON_PLACE(pCD) = place;
2207 CvtIconPlaceToPosition (&pIBD->IPD, ICON_PLACE(pCD),
2208 &ICON_X(pCD), &ICON_Y(pCD));
2211 /* update next free position */
2213 pIBD->currentCol = ICON_X(pCD) / pIBD->pCD_iconBox->widthInc;
2214 pIBD->currentRow = ICON_Y(pCD) / pIBD->pCD_iconBox->heightInc;
2219 * Increase bboard size if necessary
2222 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
2223 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2224 XtGetValues (pIBD->clipWidget, getArgs, i);
2227 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2229 if (pIBD->currentCol > pIBD->lastCol)
2231 pIBD->lastCol = pIBD->currentCol;
2234 if (pIBD->currentRow > pIBD->lastRow)
2236 pIBD->lastRow = pIBD->currentRow;
2238 if (clipHeight <= (Dimension) (pWsc->iconY +
2239 pIBD->pCD_iconBox->heightInc))
2242 * Increase bulletin board height as needed.
2244 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
2245 pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
2248 if (clipHeight <= (pII->pCD->iconY + pIBD->pCD_iconBox->heightInc))
2251 * Increase bulletin board height as needed.
2253 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
2254 pII->pCD->iconY + pIBD->pCD_iconBox->heightInc); i++;
2261 if (pIBD->currentCol > pIBD->lastCol)
2263 pIBD->lastCol = pIBD->currentCol;
2265 if (clipWidth <= (Dimension)
2266 (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
2269 * Increase bulletin board width as needed
2271 XtSetArg (setArgs[i], XmNwidth,
2272 (XtArgVal) pWsc->iconX +
2273 pIBD->pCD_iconBox->widthInc); i++;
2276 if (clipWidth <= (pII->pCD->iconX + pIBD->pCD_iconBox->widthInc))
2279 * Increase bulletin board width as needed
2281 XtSetArg (setArgs[i], XmNwidth,
2282 (XtArgVal) pII->pCD->iconX +
2283 pIBD->pCD_iconBox->widthInc); i++;
2288 if (pIBD->currentRow > pIBD->lastRow)
2290 pIBD->lastRow = pIBD->currentRow;
2296 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2303 } /* END OF FUNCTION InsertIconInfo */
2307 /*************************************<->*************************************
2316 *************************************<->***********************************/
2318 void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
2321 ClientData *pCD_tmp;
2323 Dimension clipWidth, clipHeight;
2324 Dimension oldWidth, oldHeight;
2325 int newWidth, newHeight;
2326 int i, newCols, newRows;
2328 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
2331 pWsc = GetWsClientData (pWS, pCD);
2335 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2336 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2337 XtGetValues (pIBD->bBoardWidget, args, i);
2340 XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
2341 XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2342 XtGetValues (pIBD->clipWidget, args, i);
2344 clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
2345 clipWidth /= (Dimension) pIBD->pCD_iconBox->widthInc;
2348 * find context of the activeIconTextWin to get pCD and then
2349 * if it is the same as this client, hide it.
2352 if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
2353 wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
2357 /* hide activeIconTextWin */
2358 HideActiveIconText ((WmScreenData *)NULL);
2363 DeleteIconInfo (pWsc->pIconBox, pCD);
2365 pWsc->pIconBox->numberOfIcons--;
2367 theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
2369 pWsc->pIconBox = NULL;
2370 pWsc->iconPlace = NO_ICON_PLACE;
2372 DeleteIconInfo (P_ICON_BOX(pCD), pCD);
2374 pCD->pIconBox->numberOfIcons--;
2376 theChild = XtWindowToWidget (DISPLAY, ICON_FRAME_WIN(pCD));
2378 XtUnmanageChild (theChild);
2380 XtDestroyWidget (theChild);
2382 /* update last row and col */
2384 SetNewBounds (pIBD);
2386 /* resize Bulletin board (so scroll bars show correctly */
2389 if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
2391 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
2392 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2393 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2397 newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;
2398 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2399 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2402 if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
2404 /* set height of bboard */
2405 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2406 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2407 newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2411 newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
2412 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2413 newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2416 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2418 XtSetValues (pIBD->bBoardWidget, args, i);
2419 RealignIconList (pIBD, newCols, newRows);
2420 pIBD->IPD.placementCols = newCols;
2421 pIBD->IPD.placementRows = newRows;
2425 /* reset max size for icon box */
2426 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2428 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
2430 } /* END FUNCTION DeleteIconFromBox */
2434 /*************************************<->*************************************
2436 * DeleteIconInfo (pIBD, pCD)
2441 * Deletes an icon info record from the icon box list based on the
2442 * client data pointer.
2447 * pIBD - pointer to icon box data
2448 * pCD - pointer to client data
2456 * o The deleted item is freed
2457 * o Is pCD the correct key???? !!!
2459 *************************************<->***********************************/
2460 void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
2465 /* find first matching entry in list */
2467 pII = &pIBD->IPD.placeList[0];
2468 count = pIBD->IPD.totalPlaces;
2470 for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
2476 /* found it, zero the entry out */
2477 pII->theWidget = NULL;
2482 } /* END FUNCTION DeleteIconInfo */
2486 /*************************************<->*************************************
2488 * ResetIconBoxMaxSize(pCD, bBoardWidget)
2495 *************************************<->***********************************/
2497 void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
2502 Dimension newHeight;
2505 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
2506 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
2507 XtGetValues (bBoardWidget, getArgs, i);
2509 pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
2511 pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
2513 pCD->maxX = pCD->clientX;
2514 pCD->maxY = pCD->clientY;
2515 PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY,
2516 pCD->maxWidth, pCD->maxHeight);
2518 } /* END OF FUNCTION ResetIconBoxMaxSize */
2522 /*************************************<->*************************************
2524 * CheckIconBoxSize(pIBD)
2531 *************************************<->***********************************/
2533 Boolean CheckIconBoxSize (IconBoxData *pIBD)
2539 Dimension oldHeight;
2541 Dimension newHeight;
2543 Boolean rval = True;
2546 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2547 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2548 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2550 newWidth = oldWidth;
2551 newHeight = oldHeight;
2552 oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
2553 oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
2556 * Increase bboard size if necessary
2560 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2562 if (oldRow < pIBD->lastRow + 1)
2565 * increase bulletin board height as needed
2567 newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
2568 + pIBD->pCD_iconBox->heightInc;
2570 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
2575 if (oldCol < pIBD->lastCol + 1)
2578 * increase bulletin board width as needed
2580 newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
2581 + pIBD->pCD_iconBox->widthInc;
2583 XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
2589 if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
2592 * The user has resized the iconbox larger than
2593 * memory will allow. Don't honor the resize request
2598 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2601 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2606 } /* END OF FUNCTION CheckIconBoxSize */
2610 /*************************************<->*************************************
2612 * CheckIconBoxResize(pCD, changedValues)
2619 *************************************<->***********************************/
2621 void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
2624 Boolean packVert = False;
2625 Boolean packHorz = False;
2629 IconPlacementData *pIPD;
2630 int i, newCols, newRows;
2634 Dimension oldHeight;
2636 pIPD = &pCD->thisIconBox->IPD;
2637 pIBD = pCD->thisIconBox;
2639 pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
2643 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2644 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2645 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2647 newCols = pIPD->placementCols;
2648 newRows = pIPD->placementRows;
2649 newWidth = newWidth - pCD->baseWidth;
2650 newHeight = newHeight - pCD->baseHeight;
2654 if (changedValues & CWWidth)
2657 * There was a change in Width, see if we need to change the
2660 if (newWidth > (int) oldWidth)
2662 newCols = newWidth / pCD->widthInc;
2663 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2666 if (newWidth < (int) oldWidth)
2668 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
2669 (newWidth / pCD->widthInc < pIBD->lastCol + 1))
2671 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2672 newCols = newWidth / pCD->widthInc;
2675 else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
2677 newWidth = (pIBD->lastCol +1) * pCD->widthInc;
2678 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2682 newCols = newWidth / pCD->widthInc;
2683 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2689 newWidth = oldWidth;
2692 if (changedValues & CWHeight)
2695 * There was a change in Height, see if we need to change the
2698 if (newHeight > (int) oldHeight)
2700 newRows = newHeight / pCD->heightInc;
2701 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2704 if (newHeight < (int) oldHeight)
2706 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
2707 (newHeight / pCD->heightInc < pIBD->lastRow + 1))
2709 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2710 newRows = newHeight / pCD->heightInc;
2713 else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
2715 newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
2716 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2720 newRows = newHeight / pCD->heightInc;
2721 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2727 newHeight = oldHeight;
2730 if ( i >0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2732 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2735 RealignIconList (pIBD, newCols, newRows);
2737 pIPD->placementCols = newCols;
2738 pIPD->placementRows = newRows;
2740 ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
2743 * Pack the icon box if there are icons that can no longer
2744 * be scrolled to due to iconBoxSBDisplayPolicy.
2748 PackIconBox (pIBD, packVert, False , newWidth, 0);
2752 PackIconBox (pIBD, False, packHorz , 0, newHeight);
2756 } /* END OF FUNCTION CheckIconBoxResize */
2760 /*************************************<->*************************************
2762 * ExpandVirtualSpace (pIBD, newWidth, newHeight)
2767 * Add virtural space (really the icon list )
2772 * pIBD - ptr to icon box data
2777 * Return - True if successful, False otherwise
2782 *************************************<->***********************************/
2784 Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
2786 Boolean rval = True;
2790 newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
2791 (newHeight / pIBD->pCD_iconBox->heightInc);
2793 if (newSize > pIBD->IPD.totalPlaces )
2795 increment = newSize - pIBD->IPD.totalPlaces;
2796 rval = ExtendIconList (pIBD, increment);
2801 } /* END OF FUNCTION ExpandVirtualSpace */
2805 /*************************************<->*************************************
2807 * ExtendIconList (pIBD, incr);
2812 * Add space to the icon list
2817 * pIBD - ptr to icon box data
2818 * incr - number of cells to add
2823 * Return - True if successful, False otherwise
2828 *************************************<->***********************************/
2830 Boolean ExtendIconList (IconBoxData *pIBD, int incr)
2836 newSize = pIBD->IPD.totalPlaces + incr;
2838 if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
2841 memcpy (pTmp, pIBD->IPD.placeList,
2842 pIBD->IPD.totalPlaces*sizeof(IconInfo));
2843 memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
2845 /* out with the old, in with the new */
2846 XtFree ((char *)pIBD->IPD.placeList);
2847 pIBD->IPD.placeList = pTmp;
2848 pIBD->IPD.totalPlaces = newSize;
2857 } /* END OF FUNCTION ExtendIconList */
2861 /*************************************<->*************************************
2863 * PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
2868 * Packs the icons in the icon box
2873 * pIBD - pointer to icon box data
2883 *************************************<->***********************************/
2884 void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
2886 IconInfo *pII_2, *pII_1;
2890 ClientData *pCD_tmp, *pMyCD;
2891 int hasActiveText = 1;
2893 Dimension majorDimension, minorDimension;
2894 Dimension oldWidth, oldHeight;
2895 int newWidth, newHeight;
2897 Boolean rippling = False;
2900 WmWorkspaceData *pWS;
2904 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2905 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2906 XtGetValues (pIBD->bBoardWidget, args, i);
2909 * packing to visual space, first update IconBoxData
2914 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2916 XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
2917 XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
2918 XtGetValues (pIBD->clipWidget, args, i);
2921 majorDimension = passedInWidth;
2924 minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2925 majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2926 if (majorDimension != pIBD->IPD.placementCols)
2928 pIBD->IPD.placementCols = majorDimension;
2933 XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
2934 XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
2935 XtGetValues (pIBD->clipWidget, args, i);
2938 majorDimension = passedInHeight;
2941 minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2942 majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2943 if (majorDimension != pIBD->IPD.placementRows)
2945 pIBD->IPD.placementRows = majorDimension;
2950 * find context of the activeIconTextWin to get pCD and then
2951 * if it is the same as this client, hide it.
2954 pMyCD = pIBD->pCD_iconBox;
2955 if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
2957 if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
2958 wmGD.windowContextType, (caddr_t *)&pCD_tmp))
2964 pII_2 = pII_1 = pIBD->IPD.placeList;
2966 count = pIBD->IPD.totalPlaces;
2970 if (!rippling && (pII_2->pCD != NULL))
2973 * We need to start rippling the icons into new positions if
2974 * their (x,y) position changed
2977 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2978 pWsc = GetWsClientData (pWS, pII_2->pCD);
2979 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2982 rippling = ((newX != pWsc->iconX) ||
2983 (newY != pWsc->iconY));
2985 CvtIconPlaceToPosition (&pIBD->IPD, pII_2->pCD->iconPlace,
2988 rippling = ((newX != pII_2->pCD->iconX) ||
2989 (newY != pII_2->pCD->iconY));
2993 if ((pII_2->pCD == NULL) || rippling)
2995 /* find next one to move */
2996 while ((ix1 < count) && (pII_1->pCD == NULL))
3002 if ((ix1 < count) && (pII_1->pCD != NULL))
3006 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3009 CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
3012 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
3013 pWsc = GetWsClientData (pWS, pII_2->pCD);
3017 pII_2->pCD->iconX = newX;
3018 pII_2->pCD->iconY = newY;
3021 if (hasActiveText && (pII_2->pCD == pCD_tmp))
3023 /* hide activeIconTextWin first */
3024 HideActiveIconText ((WmScreenData *)NULL);
3025 XtMoveWidget (pII_2->theWidget, newX, newY);
3026 ShowActiveIconText (pII_2->pCD);
3030 XtMoveWidget (pII_2->theWidget, newX, newY);
3045 /* update last row and col */
3047 SetNewBounds (pIBD);
3049 /* resize Bulletin board (so scroll bars show correctly */
3051 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
3053 if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
3055 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
3056 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3060 newWidth = oldWidth;
3063 if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
3065 /* set height of bboard */
3066 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3067 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3071 newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
3072 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3077 if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
3079 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3080 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3084 newHeight = oldHeight;
3087 if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
3089 /* set width of bboard */
3090 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
3091 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3095 newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;
3096 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3100 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
3102 XtSetValues (pIBD->bBoardWidget, args, i);
3106 /* reset max size for icon box */
3108 ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
3110 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
3112 } /* END FUNCTION PackIconBox */
3115 /*************************************<->*************************************
3117 * RealignIconList (pIBD, newRows, newCols)
3122 * Realigns the icon list according to the new virtual space dimensions
3127 * pIBD - ptr to icon box data
3128 * newRows - new number of rows
3129 * newCols - new number of columns
3137 * o The placement data structure contains the old values.
3139 *************************************<->***********************************/
3141 void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
3143 int c1, c2, ix1, ix2;
3144 int oldRows, oldCols;
3145 IconPlacementData ipdNew;
3149 * create new icon placement data for ease of calling conversion
3152 ipdNew.onRootWindow = pIBD->IPD.onRootWindow;
3153 ipdNew.iconPlacement = pIBD->IPD.iconPlacement;
3154 ipdNew.placementRows = newRows;
3155 ipdNew.placementCols = newCols;
3156 ipdNew.iPlaceW = pIBD->IPD.iPlaceW;
3157 ipdNew.iPlaceH = pIBD->IPD.iPlaceH;
3158 ipdNew.placeList = pIBD->IPD.placeList;
3159 ipdNew.totalPlaces = pIBD->IPD.totalPlaces;
3161 oldRows = pIBD->IPD.placementRows;
3162 oldCols = pIBD->IPD.placementCols;
3165 * Use the new organization and placement discipline to
3166 * determine how to move the icon info data around.
3168 if (((oldRows < newRows) &&
3169 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3170 ((oldCols < newCols) &&
3171 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3176 for (ix1 = pIBD->IPD.totalPlaces - 1,
3177 pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
3179 if (pII->pCD != NULL)
3181 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3182 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3185 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3191 if (((oldRows > newRows) &&
3192 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3193 ((oldCols > newCols) &&
3194 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3199 for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1];
3200 ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
3202 if (pII->pCD != NULL)
3204 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3205 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3208 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3215 * update info in placement structure to reflect new reality
3217 pIBD->IPD.placementRows = newRows;
3218 pIBD->IPD.placementCols = newCols;
3220 } /* END OF FUNCTION RealignIconList */
3225 /*************************************<->*************************************
3227 * SetNewBounds (pIBD)
3244 *************************************<->***********************************/
3246 void SetNewBounds (IconBoxData *pIBD)
3253 WidgetList children;
3255 cw = (CompositeWidget) pIBD->bBoardWidget;
3256 children = cw->composite.children;
3258 for (i = 0; i < cw->composite.num_children; i++)
3260 if (children[i]->core.x > X)
3262 X = children[i]->core.x;
3264 if (children[i]->core.y > Y)
3266 Y = children[i]->core.y;
3270 pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
3271 pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
3273 } /* END OF FUNCTION SetNewBounds */
3277 /*************************************<->*************************************
3279 * InsertPosition (w)
3284 * This procedure is passed to the bulletin board at create time
3285 * to be used when a child is inserted into the bulletin board
3288 *************************************<->***********************************/
3289 Cardinal InsertPosition (Widget w)
3291 return (insertPosition);
3293 } /* END OF FUNCTION InsertPosition */
3297 /*************************************<->*************************************
3299 * ShowClientIconState ();
3306 *************************************<->***********************************/
3308 void ShowClientIconState (ClientData *pCD, int newState)
3312 * Changing the appearance of an icon window in the box to
3313 * reflect the client's state
3316 if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
3317 XMapRaised (DISPLAY, pCD->iconWindow);
3319 if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE ))
3320 && (pCD->iconWindow))
3322 XUnmapWindow (DISPLAY, pCD->iconWindow);
3325 } /* END FUNCTION ShowClientIconState */
3329 #ifndef MOTIF_ONE_DOT_ONE
3330 /*************************************<->*************************************
3332 * IconScrollVisibleCallback
3337 * for each icon in the icon box
3339 *************************************<->***********************************/
3341 void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3343 XmTraverseObscuredCallbackStruct *vis_data;
3345 vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
3347 XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
3348 vis_data->traversal_destination,
3351 IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
3353 } /* END OF FUNCTION IconScrollVisibleCallback */
3358 /*************************************<->*************************************
3360 * IconActivateCallback
3365 * for each icon in the icon box
3367 *************************************<->***********************************/
3369 void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3374 theIcon = XtWindow(w);
3377 * find context to get pCD and then carry out
3381 if (!(XFindContext (DISPLAY, theIcon,
3382 wmGD.windowContextType, (caddr_t *)&pCD)))
3384 F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3385 /* F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3388 } /* END OF FUNCTION IconActivateCallback */
3392 /*************************************<->*************************************
3401 *************************************<->***********************************/
3403 void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
3405 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
3407 } /* END OF FUNCTION UpdateIncrements */
3410 /*************************************<->*************************************
3412 * ResetArrowButtonIncrements(pCD)
3414 *************************************<->***********************************/
3416 void ResetArrowButtonIncrements (ClientData *pCD)
3422 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
3423 XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i);
3426 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
3427 XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);
3429 } /* END OF FUNCTION ResetArrowButtonIncrements */
3433 /*************************************<->*************************************
3435 * ChangeActiveIconboxIconText
3442 *************************************<->***********************************/
3444 void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
3451 * find context to get pCD and then hide or show active icon text.
3452 * Show/hide the active icon text only if the icon box is not
3456 theIcon = XtWindow(icon);
3458 if (!(XFindContext (DISPLAY, theIcon,
3459 wmGD.windowContextType, (caddr_t *)&pCD)) &&
3461 P_ICON_BOX(pCD)->pCD_iconBox &&
3462 P_ICON_BOX(pCD)->pCD_iconBox->clientState != MINIMIZED_STATE)
3464 if (event->type == FocusIn)
3466 if (event->send_event)
3468 ShowActiveIconText (pCD);
3473 if (event->send_event)
3475 HideActiveIconText (pCD->pSD);
3480 } /* END OF FUNCTION ChangeActiveIconboxIconText */
3484 /*************************************<->*************************************
3486 * HandleIconBoxIconKeyPress
3491 * This event handler catches keyevents for icons in the icon box and
3492 * passes them on to the standard key handling routine for mwm.
3494 *************************************<->***********************************/
3496 void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
3504 * find context to get pCD and then post menu show active icon text.
3507 theIcon = XtWindow(icon);
3508 if (!(XFindContext (DISPLAY, theIcon,
3509 wmGD.windowContextType, (caddr_t *)&pCD)))
3512 SetClientWsIndex (pCD);
3514 keyEvent->window = ICON_FRAME_WIN(pCD);
3516 if (pCD->clientState == MINIMIZED_STATE)
3518 context = F_SUBCONTEXT_IB_IICON;
3519 pCD->grabContext = F_SUBCONTEXT_IB_IICON;
3523 context = F_SUBCONTEXT_IB_WICON;
3524 pCD->grabContext = F_SUBCONTEXT_IB_WICON;
3527 if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs,
3528 True, context, False, pCD)))
3530 keyEvent->window = 0;
3536 } /* END OF FUNCTION HandleIconBoxIconKeyPress */
3539 /*************************************<->*************************************
3541 * HandleIconBoxButtonMotion
3546 * Event handler for button motion events on icon frame window in
3552 * icon - widget for icon frame
3553 * client_data - extra client data
3554 * pev - ptr to event
3563 * o This is added to make sure that ButtonXMotion gets added to the
3564 * event mask for icons in the icon box.
3566 *************************************<->***********************************/
3568 void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
3571 } /* END OF FUNCTION HandleIconBoxButtonMotion */
3575 /*************************************<->*************************************
3577 * GetIconBoxIconRootXY (pCD, pX, pY)
3586 * pCD - pointer to client data
3587 * pX - pointer to X return value
3588 * pY - pointer to Y return value
3596 * o returns root-window coords
3598 *************************************<->***********************************/
3599 void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
3604 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3608 if (pCD->pSD->useIconBox && pWsc->pIconBox)
3610 if (pCD->pSD->useIconBox && P_ICON_BOX(pCD))
3614 XTranslateCoordinates(DISPLAY,
3615 XtWindow(pWsc->pIconBox->bBoardWidget),
3616 ROOT_FOR_CLIENT(pCD),
3617 pWsc->iconX + IB_MARGIN_WIDTH,
3618 pWsc->iconY + IB_MARGIN_HEIGHT,
3621 XTranslateCoordinates(DISPLAY,
3622 XtWindow(P_ICON_BOX(pCD)->bBoardWidget),
3623 ROOT_FOR_CLIENT(pCD),
3624 ICON_X(pCD) + IB_MARGIN_WIDTH,
3625 ICON_Y(pCD) + IB_MARGIN_HEIGHT,
3634 } /* END FUNCTION GetIconBoxIconRootXY */
3637 /*************************************<->*************************************
3647 * pCD - pointer to client data
3656 *************************************<->***********************************/
3657 Boolean IconVisible (ClientData *pCD)
3661 * May use icon->core.visible field if that gets fixed and
3662 * we want to accept the Intrinsics idea of what is visible.
3665 Boolean rval = True;
3667 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3675 Dimension tmpWidth = 0;
3676 Dimension tmpHeight = 0;
3684 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &tmpWidth ); i++;
3685 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &tmpHeight ); i++;
3686 XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
3687 XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
3689 XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
3690 XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
3694 XtGetValues (P_ICON_BOX(pCD)->clipWidget, getArgs, i);
3695 XtTranslateCoords(P_ICON_BOX(pCD)->scrolledWidget,
3700 GetIconBoxIconRootXY(pCD, &iconX, &iconY);
3704 * demand at least 2 pixels of the
3705 * real icon (not drawnButton) be showing
3708 if (iconX + 2 > ((int)clipX + (int)tmpWidth))
3712 if (iconY + 2 > ((int)clipY + (int)tmpHeight))
3717 if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
3721 if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
3728 } /* END OF FUNCTION IconVisible */
3730 /*************************************<->*************************************
3732 * WmXmStringToString (xmString
3748 * Return the ascii part of the first segment of an XmString
3749 * If xmString is NULL, then do nothing
3751 *************************************<->***********************************/
3753 String WmXmStringToString (XmString xmString)
3755 XmStringContext xmStrContext;
3756 char *asciiString = NULL;
3757 XmStringCharSet ibTitleCharset;
3758 XmStringDirection ibTitleDirection;
3763 XmStringInitContext (&xmStrContext, xmString);
3765 XmStringGetNextSegment (xmStrContext, &asciiString,
3766 &ibTitleCharset, &ibTitleDirection,
3769 if (ibTitleCharset != NULL)
3771 XtFree ((char *)ibTitleCharset);
3774 XmStringFreeContext (xmStrContext);
3777 return(asciiString);
3779 } /* END OF FUNCTION WmXmStringToString */