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, NULL, 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 ((unsigned char *) 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;
1822 int wsIndex = GetCurrentWorkspaceIndex (pWS->pSD);
1825 if (pWS->pIconBox &&
1826 ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
1830 #else /* PANELIST */
1831 if (pWS->pIconBox &&
1832 ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox) &&
1833 (pCW->pWsStatus[wsIndex].wsClientStatus == CLIENT_WINDOW_OPEN))
1837 #endif /* PANELIST */
1841 } /* END OF FUNCTION IconBoxShowing */
1845 /******************************<->*************************************
1847 * IconBoxPopUp (pWS, pCW, up)
1851 * Sets the state of the icon box attached to a front panel control.
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.
1866 ******************************<->***********************************/
1870 IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
1871 #else /* PANELIST */
1873 IconBoxPopUp (WmWorkspaceData *pWS,
1874 ControlWindowStruct *pCW, Boolean up)
1875 #endif /* PANELIST */
1879 int wsIndex = GetCurrentWorkspaceIndex (pWS->pSD);
1883 pibd = pWS->pIconBox;
1889 if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
1891 F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1895 AddClientToWorkspaces (pibd->pCD_iconBox,
1900 else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
1902 RemoveClientFromWorkspaces (pibd->pCD_iconBox,
1906 pibd = pibd->pNextIconBox;
1911 } /* END OF FUNCTION IconBoxPopUp */
1912 #endif /* PANELIST */
1917 /******************************<->*************************************
1923 * pCD - pointer to data for client to insert
1929 *************************************<->***********************************/
1931 Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
1934 Boolean rval = False;
1937 int iconWidth, iconHeight;
1938 IconBoxData *tmpPointerToIconBox;
1940 IconInfo *pIconInfo;
1941 static XmString dummyString = NULL;
1944 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
1946 pWsc = GetWsClientData (pWS, pCD);
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
1955 tmpPointerToIconBox = pIBD;
1961 pWsc->pIconBox = tmpPointerToIconBox;
1963 P_ICON_BOX(pCD) = tmpPointerToIconBox;
1966 iconWidth = ICON_WIDTH(pCD)
1967 + (2 * IB_MARGIN_WIDTH);
1969 iconHeight = ICON_HEIGHT(pCD)
1970 + (2 * IB_MARGIN_HEIGHT);
1973 pIconInfo = InsertIconInfo (pWsc->pIconBox, pCD, (Widget) NULL);
1975 pIconInfo = InsertIconInfo (P_ICON_BOX(pCD), pCD, (Widget) NULL);
1981 pWsc->pIconBox->numberOfIcons++;
1983 P_ICON_BOX(pCD)->numberOfIcons++;
1987 XtSetArg (setArgs[i], XmNbackground,
1988 (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
1989 XtSetArg (setArgs[i], XmNforeground,
1990 (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
1993 XtSetArg (setArgs[i], XmNx , (XtArgVal) pWsc->iconX); i++;
1994 XtSetArg (setArgs[i], XmNy , (XtArgVal) pWsc->iconY); i++;
1996 XtSetArg (setArgs[i], XmNx , (XtArgVal) ICON_X(pCD)); i++;
1997 XtSetArg (setArgs[i], XmNy , (XtArgVal) ICON_Y(pCD)); i++;
2000 XtSetArg (setArgs[i], XmNwidth , (XtArgVal) iconWidth); i++;
2001 XtSetArg (setArgs[i], XmNheight , (XtArgVal) iconHeight); i++;
2003 XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0); i++;
2005 XtSetArg (setArgs[i], XmNhighlightThickness ,
2006 IB_HIGHLIGHT_BORDER); i++;
2008 XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
2009 XtSetArg (setArgs[i], XmNmarginWidth , (XtArgVal) 0); i++;
2011 * Use type XmString so we don't get a message from XmLabel
2013 XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
2015 XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
2017 XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
2019 XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
2021 XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
2023 iconWidget = XtCreateManagedWidget("iconInIconBox",
2024 xmDrawnButtonWidgetClass,
2026 pWsc->pIconBox->bBoardWidget,
2028 P_ICON_BOX(pCD)->bBoardWidget,
2030 (ArgList)setArgs, i);
2032 if (dummyString == NULL)
2035 XmStringCreateLocalized("");
2039 XtSetArg (setArgs[i], XmNlabelString,
2040 (XtArgVal) dummyString); i++;
2042 XtSetValues (iconWidget, setArgs, i);
2044 pIconInfo->theWidget = iconWidget;
2047 pWsc->iconFrameWin = XtWindow (iconWidget);
2049 ICON_FRAME_WIN(pCD) = XtWindow (iconWidget);
2052 XtAddCallback (iconWidget, XmNactivateCallback,
2053 (XtCallbackProc)IconActivateCallback,
2056 XtAddEventHandler(iconWidget,
2057 SELECT_BUTTON_MOTION_MASK,
2059 (XtEventHandler)HandleIconBoxButtonMotion,
2062 XtAddEventHandler(iconWidget,
2063 DMANIP_BUTTON_MOTION_MASK,
2065 (XtEventHandler)HandleIconBoxButtonMotion,
2068 XtAddEventHandler(iconWidget,
2071 (XtEventHandler)HandleIconBoxIconKeyPress,
2076 if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
2078 XtAddEventHandler(iconWidget,
2081 (XtEventHandler)ChangeActiveIconboxIconText,
2084 if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
2086 XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
2091 ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox,
2092 pWsc->pIconBox->bBoardWidget);
2094 ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
2097 ResetIconBoxMaxSize(P_ICON_BOX(pCD)->pCD_iconBox,
2098 P_ICON_BOX(pCD)->bBoardWidget);
2100 ResetArrowButtonIncrements (P_ICON_BOX(pCD)->pCD_iconBox);
2108 } /* END FUNCTION InsertIconIntoBox() */
2112 /*************************************<->*************************************
2114 * InsertIconInfo (pIBD, pCD, theWidget)
2119 * Finds next available spot and inserts the icon
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)
2134 *************************************<->***********************************/
2136 IconInfo *InsertIconInfo (pIBD, pCD, theWidget)
2148 Dimension clipWidth, clipHeight;
2153 place = GetNextIconPlace (&pIBD->IPD);
2154 if (place == NO_ICON_PLACE)
2156 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2158 amt = pIBD->IPD.placementCols; /* add a new row */
2162 amt = pIBD->IPD.placementRows; /* add a new column */
2165 if (!ExtendIconList (pIBD, amt))
2167 Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
2171 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2173 pIBD->IPD.placementRows++;
2177 pIBD->IPD.placementCols++;
2179 place = GetNextIconPlace (&pIBD->IPD);
2182 insertPosition = place;
2185 * Update icon info values
2188 pII = &pIBD->IPD.placeList[place];
2189 pII->theWidget = theWidget;
2194 pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
2195 pWsc->iconPlace = place;
2197 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2198 &pWsc->iconX, &pWsc->iconY);
2201 /* update next free position */
2203 pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
2204 pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
2207 ICON_PLACE(pCD) = place;
2209 CvtIconPlaceToPosition (&pIBD->IPD, ICON_PLACE(pCD),
2210 &ICON_X(pCD), &ICON_Y(pCD));
2213 /* update next free position */
2215 pIBD->currentCol = ICON_X(pCD) / pIBD->pCD_iconBox->widthInc;
2216 pIBD->currentRow = ICON_Y(pCD) / pIBD->pCD_iconBox->heightInc;
2221 * Increase bboard size if necessary
2224 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
2225 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2226 XtGetValues (pIBD->clipWidget, getArgs, i);
2229 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2231 if (pIBD->currentCol > pIBD->lastCol)
2233 pIBD->lastCol = pIBD->currentCol;
2236 if (pIBD->currentRow > pIBD->lastRow)
2238 pIBD->lastRow = pIBD->currentRow;
2240 if (clipHeight <= (Dimension) (pWsc->iconY +
2241 pIBD->pCD_iconBox->heightInc))
2244 * Increase bulletin board height as needed.
2246 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
2247 pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
2250 if (clipHeight <= (pII->pCD->iconY + pIBD->pCD_iconBox->heightInc))
2253 * Increase bulletin board height as needed.
2255 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
2256 pII->pCD->iconY + pIBD->pCD_iconBox->heightInc); i++;
2263 if (pIBD->currentCol > pIBD->lastCol)
2265 pIBD->lastCol = pIBD->currentCol;
2267 if (clipWidth <= (Dimension)
2268 (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
2271 * Increase bulletin board width as needed
2273 XtSetArg (setArgs[i], XmNwidth,
2274 (XtArgVal) pWsc->iconX +
2275 pIBD->pCD_iconBox->widthInc); i++;
2278 if (clipWidth <= (pII->pCD->iconX + pIBD->pCD_iconBox->widthInc))
2281 * Increase bulletin board width as needed
2283 XtSetArg (setArgs[i], XmNwidth,
2284 (XtArgVal) pII->pCD->iconX +
2285 pIBD->pCD_iconBox->widthInc); i++;
2290 if (pIBD->currentRow > pIBD->lastRow)
2292 pIBD->lastRow = pIBD->currentRow;
2298 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2305 } /* END OF FUNCTION InsertIconInfo */
2309 /*************************************<->*************************************
2318 *************************************<->***********************************/
2320 void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
2323 ClientData *pCD_tmp;
2325 Dimension clipWidth, clipHeight;
2326 Dimension oldWidth, oldHeight;
2327 int newWidth, newHeight;
2328 int i, newCols, newRows;
2330 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
2333 pWsc = GetWsClientData (pWS, pCD);
2337 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2338 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2339 XtGetValues (pIBD->bBoardWidget, args, i);
2342 XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
2343 XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2344 XtGetValues (pIBD->clipWidget, args, i);
2346 clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
2347 clipWidth /= (Dimension) pIBD->pCD_iconBox->widthInc;
2350 * find context of the activeIconTextWin to get pCD and then
2351 * if it is the same as this client, hide it.
2354 if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
2355 wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
2359 /* hide activeIconTextWin */
2360 HideActiveIconText ((WmScreenData *)NULL);
2365 DeleteIconInfo (pWsc->pIconBox, pCD);
2367 pWsc->pIconBox->numberOfIcons--;
2369 theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
2371 pWsc->pIconBox = NULL;
2372 pWsc->iconPlace = NO_ICON_PLACE;
2374 DeleteIconInfo (P_ICON_BOX(pCD), pCD);
2376 pCD->pIconBox->numberOfIcons--;
2378 theChild = XtWindowToWidget (DISPLAY, ICON_FRAME_WIN(pCD));
2380 XtUnmanageChild (theChild);
2382 XtDestroyWidget (theChild);
2384 /* update last row and col */
2386 SetNewBounds (pIBD);
2388 /* resize Bulletin board (so scroll bars show correctly */
2391 if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
2393 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
2394 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2395 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2399 newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;
2400 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2401 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2404 if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
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;
2413 newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
2414 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2415 newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2418 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2420 XtSetValues (pIBD->bBoardWidget, args, i);
2421 RealignIconList (pIBD, newCols, newRows);
2422 pIBD->IPD.placementCols = newCols;
2423 pIBD->IPD.placementRows = newRows;
2427 /* reset max size for icon box */
2428 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2430 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
2432 } /* END FUNCTION DeleteIconFromBox */
2436 /*************************************<->*************************************
2438 * DeleteIconInfo (pIBD, pCD)
2443 * Deletes an icon info record from the icon box list based on the
2444 * client data pointer.
2449 * pIBD - pointer to icon box data
2450 * pCD - pointer to client data
2458 * o The deleted item is freed
2459 * o Is pCD the correct key???? !!!
2461 *************************************<->***********************************/
2462 void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
2467 /* find first matching entry in list */
2469 pII = &pIBD->IPD.placeList[0];
2470 count = pIBD->IPD.totalPlaces;
2472 for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
2478 /* found it, zero the entry out */
2479 pII->theWidget = NULL;
2484 } /* END FUNCTION DeleteIconInfo */
2488 /*************************************<->*************************************
2490 * ResetIconBoxMaxSize(pCD, bBoardWidget)
2497 *************************************<->***********************************/
2499 void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
2504 Dimension newHeight;
2507 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
2508 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
2509 XtGetValues (bBoardWidget, getArgs, i);
2511 pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
2513 pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
2515 pCD->maxX = pCD->clientX;
2516 pCD->maxY = pCD->clientY;
2517 PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY,
2518 pCD->maxWidth, pCD->maxHeight);
2520 } /* END OF FUNCTION ResetIconBoxMaxSize */
2524 /*************************************<->*************************************
2526 * CheckIconBoxSize(pIBD)
2533 *************************************<->***********************************/
2535 Boolean CheckIconBoxSize (IconBoxData *pIBD)
2541 Dimension oldHeight;
2543 Dimension newHeight;
2545 Boolean rval = True;
2548 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2549 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2550 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2552 newWidth = oldWidth;
2553 newHeight = oldHeight;
2554 oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
2555 oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
2558 * Increase bboard size if necessary
2562 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2564 if (oldRow < pIBD->lastRow + 1)
2567 * increase bulletin board height as needed
2569 newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
2570 + pIBD->pCD_iconBox->heightInc;
2572 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
2577 if (oldCol < pIBD->lastCol + 1)
2580 * increase bulletin board width as needed
2582 newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
2583 + pIBD->pCD_iconBox->widthInc;
2585 XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
2591 if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
2594 * The user has resized the iconbox larger than
2595 * memory will allow. Don't honor the resize request
2600 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2603 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2608 } /* END OF FUNCTION CheckIconBoxSize */
2612 /*************************************<->*************************************
2614 * CheckIconBoxResize(pCD, changedValues)
2621 *************************************<->***********************************/
2623 void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
2626 Boolean packVert = False;
2627 Boolean packHorz = False;
2631 IconPlacementData *pIPD;
2632 int i, newCols, newRows;
2636 Dimension oldHeight;
2638 pIPD = &pCD->thisIconBox->IPD;
2639 pIBD = pCD->thisIconBox;
2641 pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
2645 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2646 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2647 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2649 newCols = pIPD->placementCols;
2650 newRows = pIPD->placementRows;
2651 newWidth = newWidth - pCD->baseWidth;
2652 newHeight = newHeight - pCD->baseHeight;
2656 if (changedValues & CWWidth)
2659 * There was a change in Width, see if we need to change the
2662 if (newWidth > (int) oldWidth)
2664 newCols = newWidth / pCD->widthInc;
2665 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2668 if (newWidth < (int) oldWidth)
2670 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
2671 (newWidth / pCD->widthInc < pIBD->lastCol + 1))
2673 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2674 newCols = newWidth / pCD->widthInc;
2677 else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
2679 newWidth = (pIBD->lastCol +1) * pCD->widthInc;
2680 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2684 newCols = newWidth / pCD->widthInc;
2685 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2691 newWidth = oldWidth;
2694 if (changedValues & CWHeight)
2697 * There was a change in Height, see if we need to change the
2700 if (newHeight > (int) oldHeight)
2702 newRows = newHeight / pCD->heightInc;
2703 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2706 if (newHeight < (int) oldHeight)
2708 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
2709 (newHeight / pCD->heightInc < pIBD->lastRow + 1))
2711 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2712 newRows = newHeight / pCD->heightInc;
2715 else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
2717 newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
2718 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2722 newRows = newHeight / pCD->heightInc;
2723 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2729 newHeight = oldHeight;
2732 if ( i >0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2734 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2737 RealignIconList (pIBD, newCols, newRows);
2739 pIPD->placementCols = newCols;
2740 pIPD->placementRows = newRows;
2742 ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
2745 * Pack the icon box if there are icons that can no longer
2746 * be scrolled to due to iconBoxSBDisplayPolicy.
2750 PackIconBox (pIBD, packVert, False , newWidth, 0);
2754 PackIconBox (pIBD, False, packHorz , 0, newHeight);
2758 } /* END OF FUNCTION CheckIconBoxResize */
2762 /*************************************<->*************************************
2764 * ExpandVirtualSpace (pIBD, newWidth, newHeight)
2769 * Add virtural space (really the icon list )
2774 * pIBD - ptr to icon box data
2779 * Return - True if successful, False otherwise
2784 *************************************<->***********************************/
2786 Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
2788 Boolean rval = True;
2792 newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
2793 (newHeight / pIBD->pCD_iconBox->heightInc);
2795 if (newSize > pIBD->IPD.totalPlaces )
2797 increment = newSize - pIBD->IPD.totalPlaces;
2798 rval = ExtendIconList (pIBD, increment);
2803 } /* END OF FUNCTION ExpandVirtualSpace */
2807 /*************************************<->*************************************
2809 * ExtendIconList (pIBD, incr);
2814 * Add space to the icon list
2819 * pIBD - ptr to icon box data
2820 * incr - number of cells to add
2825 * Return - True if successful, False otherwise
2830 *************************************<->***********************************/
2832 Boolean ExtendIconList (IconBoxData *pIBD, int incr)
2838 newSize = pIBD->IPD.totalPlaces + incr;
2840 if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
2843 memcpy (pTmp, pIBD->IPD.placeList,
2844 pIBD->IPD.totalPlaces*sizeof(IconInfo));
2845 memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
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;
2859 } /* END OF FUNCTION ExtendIconList */
2863 /*************************************<->*************************************
2865 * PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
2870 * Packs the icons in the icon box
2875 * pIBD - pointer to icon box data
2885 *************************************<->***********************************/
2886 void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
2888 IconInfo *pII_2, *pII_1;
2892 ClientData *pCD_tmp, *pMyCD;
2893 int hasActiveText = 1;
2895 Dimension majorDimension, minorDimension;
2896 Dimension oldWidth, oldHeight;
2897 int newWidth, newHeight;
2899 Boolean rippling = False;
2902 WmWorkspaceData *pWS;
2906 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2907 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2908 XtGetValues (pIBD->bBoardWidget, args, i);
2911 * packing to visual space, first update IconBoxData
2916 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2918 XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
2919 XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
2920 XtGetValues (pIBD->clipWidget, args, i);
2923 majorDimension = passedInWidth;
2926 minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2927 majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2928 if (majorDimension != pIBD->IPD.placementCols)
2930 pIBD->IPD.placementCols = majorDimension;
2935 XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
2936 XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
2937 XtGetValues (pIBD->clipWidget, args, i);
2940 majorDimension = passedInHeight;
2943 minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2944 majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2945 if (majorDimension != pIBD->IPD.placementRows)
2947 pIBD->IPD.placementRows = majorDimension;
2952 * find context of the activeIconTextWin to get pCD and then
2953 * if it is the same as this client, hide it.
2956 pMyCD = pIBD->pCD_iconBox;
2957 if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
2959 if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
2960 wmGD.windowContextType, (caddr_t *)&pCD_tmp))
2966 pII_2 = pII_1 = pIBD->IPD.placeList;
2968 count = pIBD->IPD.totalPlaces;
2972 if (!rippling && (pII_2->pCD != NULL))
2975 * We need to start rippling the icons into new positions if
2976 * their (x,y) position changed
2979 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2980 pWsc = GetWsClientData (pWS, pII_2->pCD);
2981 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2984 rippling = ((newX != pWsc->iconX) ||
2985 (newY != pWsc->iconY));
2987 CvtIconPlaceToPosition (&pIBD->IPD, pII_2->pCD->iconPlace,
2990 rippling = ((newX != pII_2->pCD->iconX) ||
2991 (newY != pII_2->pCD->iconY));
2995 if ((pII_2->pCD == NULL) || rippling)
2997 /* find next one to move */
2998 while ((ix1 < count) && (pII_1->pCD == NULL))
3004 if ((ix1 < count) && (pII_1->pCD != NULL))
3008 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3011 CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
3014 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
3015 pWsc = GetWsClientData (pWS, pII_2->pCD);
3019 pII_2->pCD->iconX = newX;
3020 pII_2->pCD->iconY = newY;
3023 if (hasActiveText && (pII_2->pCD == pCD_tmp))
3025 /* hide activeIconTextWin first */
3026 HideActiveIconText ((WmScreenData *)NULL);
3027 XtMoveWidget (pII_2->theWidget, newX, newY);
3028 ShowActiveIconText (pII_2->pCD);
3032 XtMoveWidget (pII_2->theWidget, newX, newY);
3047 /* update last row and col */
3049 SetNewBounds (pIBD);
3051 /* resize Bulletin board (so scroll bars show correctly */
3053 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
3055 if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
3057 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
3058 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3062 newWidth = oldWidth;
3065 if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
3067 /* set height of bboard */
3068 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3069 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3073 newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
3074 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3079 if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
3081 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
3082 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
3086 newHeight = oldHeight;
3089 if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
3091 /* set width of bboard */
3092 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
3093 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3097 newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;
3098 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
3102 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
3104 XtSetValues (pIBD->bBoardWidget, args, i);
3108 /* reset max size for icon box */
3110 ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
3112 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
3114 } /* END FUNCTION PackIconBox */
3117 /*************************************<->*************************************
3119 * RealignIconList (pIBD, newRows, newCols)
3124 * Realigns the icon list according to the new virtual space dimensions
3129 * pIBD - ptr to icon box data
3130 * newRows - new number of rows
3131 * newCols - new number of columns
3139 * o The placement data structure contains the old values.
3141 *************************************<->***********************************/
3143 void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
3145 int c1, c2, ix1, ix2;
3146 int oldRows, oldCols;
3147 IconPlacementData ipdNew;
3151 * create new icon placement data for ease of calling conversion
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;
3163 oldRows = pIBD->IPD.placementRows;
3164 oldCols = pIBD->IPD.placementCols;
3167 * Use the new organization and placement discipline to
3168 * determine how to move the icon info data around.
3170 if (((oldRows < newRows) &&
3171 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3172 ((oldCols < newCols) &&
3173 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3178 for (ix1 = pIBD->IPD.totalPlaces - 1,
3179 pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
3181 if (pII->pCD != NULL)
3183 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3184 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3187 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3193 if (((oldRows > newRows) &&
3194 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
3195 ((oldCols > newCols) &&
3196 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
3201 for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1];
3202 ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
3204 if (pII->pCD != NULL)
3206 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
3207 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
3210 MoveIconInfo (&pIBD->IPD, ix1, ix2);
3217 * update info in placement structure to reflect new reality
3219 pIBD->IPD.placementRows = newRows;
3220 pIBD->IPD.placementCols = newCols;
3222 } /* END OF FUNCTION RealignIconList */
3227 /*************************************<->*************************************
3229 * SetNewBounds (pIBD)
3246 *************************************<->***********************************/
3248 void SetNewBounds (IconBoxData *pIBD)
3255 WidgetList children;
3257 cw = (CompositeWidget) pIBD->bBoardWidget;
3258 children = cw->composite.children;
3260 for (i = 0; i < cw->composite.num_children; i++)
3262 if (children[i]->core.x > X)
3264 X = children[i]->core.x;
3266 if (children[i]->core.y > Y)
3268 Y = children[i]->core.y;
3272 pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
3273 pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
3275 } /* END OF FUNCTION SetNewBounds */
3279 /*************************************<->*************************************
3281 * InsertPosition (w)
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
3290 *************************************<->***********************************/
3291 Cardinal InsertPosition (Widget w)
3293 return (insertPosition);
3295 } /* END OF FUNCTION InsertPosition */
3299 /*************************************<->*************************************
3301 * ShowClientIconState ();
3308 *************************************<->***********************************/
3310 void ShowClientIconState (ClientData *pCD, int newState)
3314 * Changing the appearance of an icon window in the box to
3315 * reflect the client's state
3318 if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
3319 XMapRaised (DISPLAY, pCD->iconWindow);
3321 if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE ))
3322 && (pCD->iconWindow))
3324 XUnmapWindow (DISPLAY, pCD->iconWindow);
3327 } /* END FUNCTION ShowClientIconState */
3331 #ifndef MOTIF_ONE_DOT_ONE
3332 /*************************************<->*************************************
3334 * IconScrollVisibleCallback
3339 * for each icon in the icon box
3341 *************************************<->***********************************/
3343 void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3345 XmTraverseObscuredCallbackStruct *vis_data;
3347 vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
3349 XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
3350 vis_data->traversal_destination,
3353 IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
3355 } /* END OF FUNCTION IconScrollVisibleCallback */
3360 /*************************************<->*************************************
3362 * IconActivateCallback
3367 * for each icon in the icon box
3369 *************************************<->***********************************/
3371 void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3376 theIcon = XtWindow(w);
3379 * find context to get pCD and then carry out
3383 if (!(XFindContext (DISPLAY, theIcon,
3384 wmGD.windowContextType, (caddr_t *)&pCD)))
3386 F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3387 /* F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3390 } /* END OF FUNCTION IconActivateCallback */
3394 /*************************************<->*************************************
3403 *************************************<->***********************************/
3405 void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
3407 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
3409 } /* END OF FUNCTION UpdateIncrements */
3412 /*************************************<->*************************************
3414 * ResetArrowButtonIncrements(pCD)
3416 *************************************<->***********************************/
3418 void ResetArrowButtonIncrements (ClientData *pCD)
3424 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
3425 XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i);
3428 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
3429 XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);
3431 } /* END OF FUNCTION ResetArrowButtonIncrements */
3435 /*************************************<->*************************************
3437 * ChangeActiveIconboxIconText
3444 *************************************<->***********************************/
3446 void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
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
3458 theIcon = XtWindow(icon);
3460 if (!(XFindContext (DISPLAY, theIcon,
3461 wmGD.windowContextType, (caddr_t *)&pCD)) &&
3463 P_ICON_BOX(pCD)->pCD_iconBox &&
3464 P_ICON_BOX(pCD)->pCD_iconBox->clientState != MINIMIZED_STATE)
3466 if (event->type == FocusIn)
3468 if (event->send_event)
3470 ShowActiveIconText (pCD);
3475 if (event->send_event)
3477 HideActiveIconText (pCD->pSD);
3482 } /* END OF FUNCTION ChangeActiveIconboxIconText */
3486 /*************************************<->*************************************
3488 * HandleIconBoxIconKeyPress
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.
3496 *************************************<->***********************************/
3498 void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
3506 * find context to get pCD and then post menu show active icon text.
3509 theIcon = XtWindow(icon);
3510 if (!(XFindContext (DISPLAY, theIcon,
3511 wmGD.windowContextType, (caddr_t *)&pCD)))
3514 SetClientWsIndex (pCD);
3516 keyEvent->window = ICON_FRAME_WIN(pCD);
3518 if (pCD->clientState == MINIMIZED_STATE)
3520 context = F_SUBCONTEXT_IB_IICON;
3521 pCD->grabContext = F_SUBCONTEXT_IB_IICON;
3525 context = F_SUBCONTEXT_IB_WICON;
3526 pCD->grabContext = F_SUBCONTEXT_IB_WICON;
3529 if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs,
3530 True, context, False, pCD)))
3532 keyEvent->window = 0;
3538 } /* END OF FUNCTION HandleIconBoxIconKeyPress */
3541 /*************************************<->*************************************
3543 * HandleIconBoxButtonMotion
3548 * Event handler for button motion events on icon frame window in
3554 * icon - widget for icon frame
3555 * client_data - extra client data
3556 * pev - ptr to event
3565 * o This is added to make sure that ButtonXMotion gets added to the
3566 * event mask for icons in the icon box.
3568 *************************************<->***********************************/
3570 void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
3573 } /* END OF FUNCTION HandleIconBoxButtonMotion */
3577 /*************************************<->*************************************
3579 * GetIconBoxIconRootXY (pCD, pX, pY)
3588 * pCD - pointer to client data
3589 * pX - pointer to X return value
3590 * pY - pointer to Y return value
3598 * o returns root-window coords
3600 *************************************<->***********************************/
3601 void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
3606 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3610 if (pCD->pSD->useIconBox && pWsc->pIconBox)
3612 if (pCD->pSD->useIconBox && P_ICON_BOX(pCD))
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,
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,
3636 } /* END FUNCTION GetIconBoxIconRootXY */
3639 /*************************************<->*************************************
3649 * pCD - pointer to client data
3658 *************************************<->***********************************/
3659 Boolean IconVisible (ClientData *pCD)
3663 * May use icon->core.visible field if that gets fixed and
3664 * we want to accept the Intrinsics idea of what is visible.
3667 Boolean rval = True;
3669 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3677 Dimension tmpWidth = 0;
3678 Dimension tmpHeight = 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++;
3691 XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
3692 XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
3696 XtGetValues (P_ICON_BOX(pCD)->clipWidget, getArgs, i);
3697 XtTranslateCoords(P_ICON_BOX(pCD)->scrolledWidget,
3702 GetIconBoxIconRootXY(pCD, &iconX, &iconY);
3706 * demand at least 2 pixels of the
3707 * real icon (not drawnButton) be showing
3710 if (iconX + 2 > ((int)clipX + (int)tmpWidth))
3714 if (iconY + 2 > ((int)clipY + (int)tmpHeight))
3719 if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
3723 if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
3730 } /* END OF FUNCTION IconVisible */
3732 /*************************************<->*************************************
3734 * WmXmStringToString (xmString
3750 * Return the ascii part of the first segment of an XmString
3751 * If xmString is NULL, then do nothing
3753 *************************************<->***********************************/
3755 String WmXmStringToString (XmString xmString)
3757 XmStringContext xmStrContext;
3758 char *asciiString = NULL;
3759 XmStringCharSet ibTitleCharset;
3760 XmStringDirection ibTitleDirection;
3765 XmStringInitContext (&xmStrContext, xmString);
3767 XmStringGetNextSegment (xmStrContext, &asciiString,
3768 &ibTitleCharset, &ibTitleDirection,
3771 if (ibTitleCharset != NULL)
3773 XtFree ((char *)ibTitleCharset);
3776 XmStringFreeContext (xmStrContext);
3779 return(asciiString);
3781 } /* END OF FUNCTION WmXmStringToString */