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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: WmHelp.c /main/8 1997/06/18 17:30:51 samborn $ */
26 * (c) Copyright 1987, 1988, 1989, 1990, 1992, 1993 HEWLETT-PACKARD COMPANY
27 * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
32 static char rcsid[] = ""
47 #include "WmFunction.h"
50 #include "WmResParse.h"
54 #include "WmResNames.h"
55 #include "WmWrkspace.h"
56 #include "DataBaseLoad.h"
60 #include <Xm/MessageB.h>
61 #include <X11/keysymdef.h>
62 #include <X11/keysym.h>
63 #include <X11/Shell.h>
64 #include <Xm/MwmUtil.h>
66 #include <Dt/HelpDialog.h>
67 #include <Dt/HelpQuickD.h>
69 #include <Dt/DtNlUtils.h>
71 #include <X11/cursorfont.h>
74 /****************************************************************
76 * Cache List Info Structure Definition.
78 ****************************************************************/
79 typedef struct _CacheListStruct {
87 struct _CacheListStruct *pNext;
88 struct _CacheListStruct *pPrevious;
91 typedef struct _DisplayTopicInfo {
98 * Function Declarations:
101 /******** Static Function Declarations ********/
102 static int LocateTheControl(
106 static WmScreenData *WmScreenDataFromWidget (
109 static int WmDtReturnSelectedWidget (
113 static void WmDtDisplayTopic (
124 DisplayTopicInfo *displayTopicInfo);
125 static void WmDtCloseHelpCB (
127 XtPointer clientData,
129 static void WmDtWmCloseHelpCB (
131 XtPointer clientData,
133 static void WmDtVersionCloseCB (
135 XtPointer clientData,
137 static void WmDtVersionPopupCB (
139 XtPointer clientData,
142 static void WmDtProcessLinkCB (
144 XtPointer clientData,
146 static Boolean WmDtGetFromCache(
147 CacheListStruct **pCurrentNode,
149 static void ShowHelpDialog(
150 ClientData *pClient);
152 static void HideHelpDialog(
154 Boolean userDismissed );
155 static void wmDtHelpSetPosition(
156 PtrWsDtHelpData pHelp,
159 static void wmDtHelpMapEventHandler (
164 static void wmDtErrorDialog(
168 static void wmDtErrorDialogOkCB(
170 XtPointer client_data,
171 XtPointer call_data );
172 static void wmDtErrorDialogPopupCB(
174 XtPointer client_data,
175 XtPointer call_data );
176 static void wmDtErrorDialogHide(
179 /******** End Static Function Declarations ********/
187 static DisplayTopicInfo displayTopicInfo;
188 static Widget versionWidget = (Widget)NULL;
190 #define PT_IN_CHILD(X, Y, CHILD) \
191 (((X) >= (CHILD)->core.x) && \
192 ((X) <= ((CHILD)->core.x + (Position) (CHILD)->core.width)) && \
193 ((Y) >= (CHILD)->core.y) && \
194 ((Y) <= ((CHILD)->core.y + (Position) (CHILD)->core.height)))
196 #define MAX_WIDGET_PATH 100
199 /**********************************************************************
200 * Function: LocateTheControl()
204 **********************************************************************/
213 CompositeWidget comp_widget;
217 Window target_win = None;
226 Widget widget = NULL;
228 Boolean foundOne = False;
230 WmFpEmbeddedClientData *pECD;
231 WmScreenData *pSD = NULL;
235 /* Make the target cursor */
236 cursor = XCreateFontCursor (wmGD.display, XC_question_arrow);
238 /* Grab the pointer using target cursor, letting it roam all over */
239 status = XGrabPointer (wmGD.display, RootWindow(wmGD.display, screen),
241 ButtonPressMask|ButtonReleaseMask, GrabModeAsync,
242 GrabModeAsync, None, cursor, CurrentTime);
243 if (status != GrabSuccess)
245 Warning (((char *)GETMESSAGE(29, 1,
246 "Help on Item failed. Another program may have grabbed the mouse.")));
247 return(DtHELP_SELECT_ERROR);
251 /* Grab the Keyboard so we can catch the ESC button press */
252 status = XGrabKeyboard(wmGD.display, RootWindow(wmGD.display, screen),
254 GrabModeAsync, GrabModeAsync, CurrentTime);
255 if (status != GrabSuccess)
257 XUngrabPointer (wmGD.display, CurrentTime);
258 Warning (((char *)GETMESSAGE(29, 2,
259 "Help on Item failed. Another program may have grabbed the mouse.")));
260 return(DtHELP_SELECT_ERROR);
263 /* Let the user select a window... */
264 while ((target_win == None) || (buttons != 0))
266 XtAppNextEvent(wmGD.mwmAppContext, &event);
271 if (target_win == None)
273 target_win = event.xbutton.subwindow; /* window selected */
274 if (target_win == None)
275 target_win = RootWindow (wmGD.display, screen);
280 /* there may have been some down before we started */
285 /* Look for ESC key press and stop if we get one */
286 if (event.xkey.state & ShiftMask)
291 keySym = XLookupKeysym((XKeyEvent *)&event, offset);
292 if (keySym == XK_Escape)
294 XUngrabKeyboard (wmGD.display, CurrentTime);
295 XUngrabPointer (wmGD.display, CurrentTime);
296 return(DtHELP_SELECT_ABORT);
300 XtDispatchEvent(&event);
303 XUngrabKeyboard (wmGD.display, CurrentTime); /* Done with keyboard */
304 XUngrabPointer (wmGD.display, CurrentTime); /* Done with pointer */
307 printf("RootWindow (wmGD.display, screen) = %ld\n", RootWindow (wmGD.display, screen));
308 printf("event.xbutton.root = %ld\n", event.xbutton.root);
309 printf("event.xbutton.window = %ld\n", event.xbutton.window);
310 printf("event.xbutton.subwindow = %ld\n", event.xbutton.subwindow);
311 printf("event.xbutton.x = %d\n", event.xbutton.x);
312 printf("event.xbutton.y = %d\n", event.xbutton.y);
313 printf("event.xbutton.x_root = %d\n", event.xbutton.x_root);
314 printf("event.xbutton.y_root = %d\n", event.xbutton.y_root);
315 #endif /* DEBUGGER */
317 if (target_win == RootWindow (wmGD.display, screen))
318 return (DtHELP_SELECT_INVALID);
320 for (scr = 0; scr < wmGD.numScreens; scr++)
322 if (wmGD.Screens[scr].managed &&
323 wmGD.Screens[scr].screen == screen)
325 pSD = (&(wmGD.Screens[scr]));
334 /* check for subwindows */
335 parent = RootWindow (wmGD.display, screen);
336 x = event.xbutton.x_root;
337 y = event.xbutton.y_root;
341 XTranslateCoordinates(wmGD.display, parent, target_win, x, y,
342 &new_x, &new_y, &sub);
351 pECD = (WmFpEmbeddedClientData *) pSD->pECD;
352 for (clientNum = 0; clientNum < pSD->numEmbeddedClients;
356 (target_win == pECD->pCD->client))
358 widget = pECD->wControl;
373 widget = XtWindowToWidget (wmGD.display, target_win);
378 widget = XtWindowToWidget (wmGD.display1, target_win);
382 return (DtHELP_SELECT_INVALID);
386 if (!XtIsComposite (widget))
389 return (DtHELP_SELECT_VALID);
391 comp_widget = (CompositeWidget)widget;
393 /* look for gadgets at this point */
394 for (i = 0; i < comp_widget->composite.num_children; i++)
396 child = comp_widget->composite.children[i];
398 if (PT_IN_CHILD (x, y, child) && XtIsManaged(child))
401 return (DtHELP_SELECT_VALID);
408 return (DtHELP_SELECT_VALID);
411 return (DtHELP_SELECT_INVALID);
413 } /* END OF FUNCTION LocateTheControl */
416 /**********************************************************************
418 * Cache Creek related help functions
420 **********************************************************************/
422 /*************************************<->*************************************
431 *************************************<->***********************************/
433 void WmDtStringHelpCB (Widget theWidget,
434 XtPointer client_data,
438 char * theHelpString = (char *)client_data;
439 Widget theRealWidget = theWidget;
440 if( XmIsGadget(theWidget))
442 theRealWidget = XtParent(theWidget);
444 pSD = WmScreenDataFromWidget(theWidget);
446 /* WmDtDisplayTopic(theRealWidget, NULL, theHelpString, */
447 WmDtDisplayTopic(pSD->screenTopLevelW1, NULL, theHelpString,
448 DtHELP_TYPE_DYNAMIC_STRING, (Widget) NULL, True,
449 NULL, 0, NULL, False, NULL);
453 } /* END OF FUNCTION WmDtStringHelpCB */
456 /*************************************<->*************************************
465 *************************************<->***********************************/
467 void WmDtWmStringHelpCB (Widget theWidget,
468 XtPointer client_data,
472 char * theHelpString = (char *)client_data;
473 pSD = WmScreenDataFromWidget(theWidget);
476 if (XtDisplay(theWidget) == DISPLAY)
478 WmDtDisplayTopic(pSD->screenTopLevelW1,
480 DtHELP_TYPE_STRING, theWidget, True,
481 NULL, 0, NULL, False, NULL);
485 WmDtDisplayTopic(theWidget, NULL, theHelpString,
486 DtHELP_TYPE_STRING, theWidget, True,
487 NULL, 0, NULL, False, NULL);
491 WmDtDisplayTopic(pSD->screenTopLevelW1,
493 DtHELP_TYPE_DYNAMIC_STRING, theWidget, True,
494 NULL, 0, NULL, False, NULL);
497 } /* END OF FUNCTION WmDtWmStringHelpCB */
501 /*************************************<->*************************************
503 * WmDtDisplayTopicHelp
507 * External entry procedure used to display help topics.
509 *************************************<->***********************************/
511 void WmDtDisplayTopicHelp (Widget widget,
515 WmScreenData *pSD = WmScreenDataFromWidget(widget);
517 WmDtDisplayTopic(pSD->screenTopLevelW1,
518 helpVolume, locationID,
519 DtHELP_TYPE_TOPIC, (Widget) NULL, True,
520 NULL, 0, NULL, False, NULL);
523 /*************************************<->*************************************
525 * WmDtDisplayStringHelp
529 * External entry procedure used to display help topics.
531 *************************************<->***********************************/
533 void WmDtDisplayStringHelp (Widget widget,
536 WmScreenData *pSD = WmScreenDataFromWidget(widget);
538 WmDtDisplayTopic(pSD->screenTopLevelW1,
540 DtHELP_TYPE_DYNAMIC_STRING, widget, True,
541 NULL, 0, NULL, False, NULL);
544 /*************************************<->*************************************
551 * for each icon in the icon box
553 *************************************<->***********************************/
555 void WmDtWmTopicHelpCB (Widget theWidget,
556 XtPointer client_data,
561 char *helpVolume = WM_DT_HELP_VOLUME;
562 char *locationID = (char *)client_data;
563 pSD = WmScreenDataFromWidget(theWidget);
565 shellWidget = theWidget;
566 while (!(XtIsSubclass(XtParent(shellWidget), shellWidgetClass)))
568 shellWidget = XtParent(shellWidget);
571 WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
573 DtHELP_TYPE_TOPIC, shellWidget, True,
574 NULL, 0, NULL, False, NULL);
576 } /* END OF FUNCTION WmDtWmTopicHelpCB */
578 /****************************************************************************
579 * Function: WmScreenDataFromWidget(
588 ***************************************************************************/
589 static WmScreenData *
590 WmScreenDataFromWidget (Widget theWidget)
593 WmScreenData *pSD = NULL;
596 CacheListStruct *pTemp;
600 for (scr = 0; scr < wmGD.numScreens; scr++)
602 if (wmGD.Screens[scr].managed &&
603 wmGD.Screens[scr].screen ==
604 XScreenNumberOfScreen(XtScreen(theWidget)))
606 pSD = (&(wmGD.Screens[scr]));
621 } /* END OF FUNCTION WmScreenDataFromWidget */
623 /****************************************************************************
624 * Function: WmDtCloseHelpCB(
626 * caddr_t clientData,
631 * Return Value: Void.
633 * Purpose: Process close requests on all Help Dialog widgets
634 * created and managed by this application.
636 ***************************************************************************/
637 static void WmDtCloseHelpCB (
639 XtPointer clientData,
642 WmScreenData *pSD = NULL;
644 Widget helpDialog = (Widget) clientData;
646 CacheListStruct *pTemp;
648 pSD = WmScreenDataFromWidget(w);
649 pTemp = pSD->cachedHelp;
651 /* Search our Cache List for the closed help dialog */
652 while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
654 pTemp = pTemp->pNext;
660 /* printf("Didn't find our help dialog widget in the cache list??? /n");*/
663 XtPopdown (XtParent(helpDialog));
665 pTemp->inUseFlag = FALSE;
666 pSD->cachedHelp->hLink = False;
668 /* Re-Assign our pTemp to point to our head so we can see
669 * if we have any in-use help dialog in our list.
671 pTemp = pSD->cachedHelp;
673 } /* END OF FUNCTION WmDtCloseHelpCB */
676 /****************************************************************************
677 * Function: WmDtWmCloseHelpCB(
679 * caddr_t clientData,
684 * Return Value: Void.
686 * Purpose: Process close requests on all Help Dialog widgets
687 * created and managed by this application.
689 ***************************************************************************/
690 static void WmDtWmCloseHelpCB (
692 XtPointer clientData,
696 Widget helpDialog = (Widget) clientData;
697 pSD = WmScreenDataFromWidget(w);
698 HideHelpDialog (pSD, True);
700 } /* END OF FUNCTION WmDtWmCloseHelpCB */
704 /****************************************************************************
705 * Function: WmDtWmPopupHelpCB(
707 * caddr_t clientData,
712 * Return Value: Void.
717 ***************************************************************************/
718 static void WmDtWmPopupHelpCB (
720 XtPointer clientData,
723 PtrWsDtHelpData pHelp;
726 pSD = WmScreenDataFromWidget(w);
728 pHelp = &pSD->dtHelp;
730 if (pSD->dtHelp.restored)
732 /* set position of dialog to restored position */
733 wmDtHelpSetPosition (pHelp, pSD, True);
734 pSD->dtHelp.restored = False;
738 /* set position of dialog relative to client window */
739 wmDtHelpSetPosition (pHelp, pSD, False);
742 } /* END OF FUNCTION WmDtWmPopupHelpCB */
745 /****************************************************************************
746 * Function: WmDtVersionPopupCB(
748 * caddr_t clientData,
753 * Return Value: Void.
758 ***************************************************************************/
759 static void WmDtVersionPopupCB (
761 XtPointer clientData,
766 Dimension width, height;
774 XtSetArg (setArgs[n], XmNx, 0); n++;
775 XtSetArg (setArgs[n], XmNy, 0); n++;
779 * Center the Version Dialog on the screen
783 XtSetArg(getArgs[n], XmNheight, &height); n++;
784 XtSetArg(getArgs[n], XmNwidth, &width); n++;
785 XtGetValues (w, (ArgList) getArgs, n);
788 (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) width))/2;
790 (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) height))/2;
792 XtSetArg(setArgs[n], XmNx, (XtArgVal) x); n++;
793 XtSetArg(setArgs[n], XmNy, (XtArgVal) y); n++;
794 XtSetValues (w, setArgs, n);
797 } /* END OF FUNCTION WmDtVersionPopupCB */
801 /****************************************************************************
802 * Function: WmDtPopupHelpCB(
804 * caddr_t clientData,
809 * Return Value: Void.
814 ***************************************************************************/
815 static void WmDtPopupHelpCB (
817 XtPointer clientData,
821 Atom * workspace_atoms = NULL;
822 int num_workspaces=0;
824 CacheListStruct *pTemp = (CacheListStruct *)clientData;
829 XtSetArg (args[n], XmNgeometry, NULL); n++;
830 XtSetArg (args[n], XmNwaitForWm, False); n++;
834 if (pTemp->workspaces)
836 char **atom_names = NULL;
839 ptr = DtStrchr (pTemp->workspaces, '*');
840 if (ptr != NULL) *ptr = '\0';
843 (char **) XtRealloc ((char *)atom_names,
844 sizeof(char*) * (num_workspaces + 1));
845 atom_names[num_workspaces] = XtNewString(pTemp->workspaces);
851 pTemp->workspaces = ptr + 1;
853 } while (ptr != NULL);
855 workspace_atoms = (Atom *) XtMalloc(sizeof(Atom) * num_workspaces);
856 XInternAtoms(wmGD.display, atom_names, num_workspaces,
857 True, workspace_atoms);
859 DtWsmSetWorkspacesOccupied (XtDisplay(helpShellW),
860 XtWindow (helpShellW),
864 while (num_workspaces-- > 0)
865 XtFree(atom_names[num_workspaces]);
866 XtFree ((char *) atom_names);
867 XtFree ((char *) workspace_atoms);
870 XtSetArg (args[n], XmNx, pTemp->xPos); n++;
871 XtSetArg (args[n], XmNy, pTemp->yPos); n++;
872 pTemp->restored = False;
873 XtRemoveCallback(helpShellW, XmNpopupCallback,
874 WmDtPopupHelpCB, clientData);
875 XtAddCallback(helpShellW, XmNpopupCallback, WmDtPopupHelpCB, NULL);
879 XtSetArg (args[n], XmNx, 0); n++;
880 XtSetArg (args[n], XmNy, 0); n++;
883 XtSetValues (helpShellW, args, n);
886 } /* END OF FUNCTION WmDtPopupHelpCB */
890 /****************************************************************************
891 * Function: WmDtVersionCloseCB(
893 * caddr_t clientData,
898 * Return Value: Void.
900 * Purpose: Process close requests on all Help Dialog widgets
901 * created and managed by this application.
903 ***************************************************************************/
904 static void WmDtVersionCloseCB (
906 XtPointer clientData,
911 } /* END OF FUNCTION WmDtWmVersionCloseHelpCB */
916 /****************************************************************************
917 * Function: void WmDtProcessLinkCB(
919 * caddr_t clientData,
924 * Return Value: Void.
926 * Purpose: Process JUMP-NEW and APP-LINK hypertext requests in a
927 * given Help Dialog Window.
929 * This is the callback used for the DtNhyperLinkCallback
930 * on each of the help dialog widges created.
932 ****************************************************************************/
933 static void WmDtProcessLinkCB (
935 XtPointer clientData,
939 DtHelpDialogCallbackStruct * hyperData =
940 (DtHelpDialogCallbackStruct *) callData;
942 switch (hyperData->hyperType)
944 case DtHELP_LINK_JUMP_NEW:
945 WmDtDisplayTopic (XtParent(w), hyperData->helpVolume,
946 hyperData->locationId,
947 /* DtHELP_LINK_JUMP_NEW */ DtHELP_TYPE_TOPIC,
949 NULL, 0, NULL, True, NULL);
952 default: /* This catches the application definded link types */
953 if (hyperData->hyperType >= 100)
955 /* The application would put any code here to handle their
956 * Applicaiton-defined-links.
962 /* printf("We some how got a bogus hyptertext link type/n");*/
964 } /* End Switch Statement */
966 } /* END OF FUNCTION WmDtProcessLinkCB */
969 /****************************************************************************
970 * Function: void WmDtHelpOnVersion(
975 * Return Value: Void.
977 * Purpose: Displays a new Cache Creek help topic in a new/cached
978 * help dialog widget.
980 ****************************************************************************/
981 void WmDtHelpOnVersion (
990 Widget printButton = NULL;
991 Widget helpButton = NULL;
992 Widget backButton = NULL;
993 Widget closeButton = NULL;
994 #ifdef NO_MESSAGE_CATALOG
995 XmString label = NULL;
998 if((versionWidget != NULL) &&
999 (XtIsManaged(versionWidget)))
1005 if (!(versionWidget))
1007 #ifndef NO_MESSAGE_CATALOG
1008 XtSetArg (setArgs[n], XmNtitle, wmNLS.defaultVersionTitle); n++;
1010 XtSetArg (setArgs[n], XmNtitle, "About Workspace Manager"); n++;
1014 XtSetArg (setArgs[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
1015 XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT"); n++;
1016 XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME); n++;
1018 versionWidget = DtCreateHelpQuickDialog (parent, "VersionDialog",
1021 XtAddCallback(versionWidget, DtNcloseCallback,
1023 (XtPointer) versionWidget);
1025 XtAddCallback(XtParent(versionWidget), XmNpopupCallback,
1026 WmDtVersionPopupCB, NULL);
1028 closeButton = DtHelpQuickDialogGetChild( versionWidget,
1029 DtHELP_QUICK_CLOSE_BUTTON );
1032 #ifndef NO_MESSAGE_CATALOG
1033 XtSetArg (setArgs2[n2], DtNcloseLabelString, wmGD.okLabel); n2++;
1035 XtSetArg (setArgs2[n2], DtNcloseLabelString,
1036 label=XmStringCreateLocalized ("OK")); n2++;
1039 XtSetValues(closeButton, setArgs2, n2);
1040 #ifdef NO_MESSAGE_CATALOG
1041 if(label)XmStringFree(label);
1044 printButton = DtHelpQuickDialogGetChild( versionWidget,
1045 DtHELP_QUICK_PRINT_BUTTON );
1046 helpButton = DtHelpQuickDialogGetChild( versionWidget,
1047 DtHELP_QUICK_HELP_BUTTON );
1048 backButton = DtHelpQuickDialogGetChild( versionWidget,
1049 DtHELP_QUICK_BACK_BUTTON );
1051 XtUnmanageChild(printButton);
1052 XtUnmanageChild(helpButton);
1053 XtUnmanageChild(backButton);
1057 XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT"); n++;
1058 XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME); n++;
1059 XtSetValues(versionWidget, setArgs, n);
1061 XtManageChild(versionWidget);
1065 } /* END OF FUNCTION WmDtHelpOnVersion */
1069 /******************************<->*************************************
1071 * Boolean WmDtHelp (String args)
1083 * Return - True if the find a help callback; false otherwise.
1088 ******************************<->***********************************/
1091 WmDtHelp (String args)
1095 WmPanelistObject pPanelist;
1096 char *theHelpVolume = WM_DT_HELP_VOLUME;
1097 char *theHelpTopic = WM_DT_HELP_TOPIC;
1098 unsigned char volume[MAXWMPATH + 1];
1099 unsigned char topic[MAXWMPATH + 1];
1103 /* get right screen data */
1104 /* pSD = WmScreenDataFromWidget(w);*/
1105 pSD = wmGD.pActiveSD;
1108 pPanelist = (WmPanelistObject) pSD->wPanelist;
1110 if ((theWidget = O_Panel(pPanelist)))
1115 * parse args for volume and topic
1117 WmDtGetHelpArgs(args, volume, topic, &argCount);
1120 WmDtDisplayTopic(pSD->screenTopLevelW1,
1123 DtHELP_TYPE_TOPIC, theWidget, True,
1124 NULL, 0, NULL, False, NULL);
1128 WmDtDisplayTopic(pSD->screenTopLevelW1,
1131 DtHELP_TYPE_TOPIC, theWidget, False,
1132 NULL, 0, NULL, False, NULL);
1138 WmDtDisplayTopic(pSD->screenTopLevelW1,
1141 DtHELP_TYPE_TOPIC, theWidget, True,
1142 NULL, 0, NULL, False, NULL);
1150 } /* END OF FUNCTION WmDtHelp */
1153 /******************************<->*************************************
1155 * Boolean WmDtHelpMode (void)
1159 * Invoke item help mode
1167 * Return - True if the find a help callback; false otherwise.
1172 ******************************<->***********************************/
1177 Widget selectedWidget = NULL;
1179 String sTmp, sMessage, sTitle;
1181 iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, None,
1186 case DtHELP_SELECT_VALID:
1187 if (selectedWidget != (Widget) NULL)
1191 if ((XtHasCallbacks(selectedWidget,
1192 XmNhelpCallback) == XtCallbackHasSome))
1194 XtCallCallbacks(selectedWidget, XmNhelpCallback,
1200 selectedWidget = XtParent(selectedWidget);
1203 while (selectedWidget != NULL);
1207 case DtHELP_SELECT_INVALID:
1208 /* invalid selection error (window not of this process) */
1209 #ifndef NO_MESSAGE_CATALOG
1210 sTmp = (char *)GETMESSAGE(29, 3,
1211 "You must select a Workspace Manager\n\
1212 dialog, an item in the Front Panel,\n\
1213 or an item in a subpanel.");
1214 sMessage = XtNewString (sTmp);
1215 sTmp = (char *)GETMESSAGE(29, 4,
1216 "Workspace Manager - Help On Item Error");
1217 sTitle = XtNewString (sTmp);
1219 sMessage = "You must select a Workspace Manager\n\
1220 dialog, an item in the Front Panel,\n\
1221 or an item in a subpanel.";
1222 sTitle = "Workspace Manager - Help On Item Error";
1224 wmDtErrorDialog (ACTIVE_PSD, sMessage, sTitle);
1225 #ifndef NO_MESSAGE_CATALOG
1226 if (sMessage) XtFree (sMessage);
1227 if (sTitle) XtFree (sTitle);
1231 case DtHELP_SELECT_ERROR:
1232 /* error (like grab failed) */
1235 case DtHELP_SELECT_ABORT:
1236 /* user aborted this selection */
1241 } /* END OF FUNCTION WmDtHelpMode */
1245 /*****************************************************************************
1246 * Function: WmDtReturnSelectedWidget (Widget, Cursor, Widget *)
1248 * Parameters: Widget Specifies a valid widget within the app's
1250 * Cursor Cursor to grab pointer with (use NULL!!)
1251 * Widget * ptr to loc to receive returned widget
1253 * Return Value: DtHELP_SELECT_ERROR - error in getting the widget
1254 * DtHELP_SELECT_ABORT - user aborted
1255 * DtHELP_SELECT_INVALID - user selected invalid window
1256 * DtHELP_SELECT_VALID - valid widget returned
1258 * Purpose: Allows developers to get the widget ID for any widget in their UI
1259 * that the user has selected vai the pointer. This function will
1260 * cause the cursor to change and allow a user to select an item in
1263 *****************************************************************************/
1265 WmDtReturnSelectedWidget(
1275 /* Setup some needed variables */
1276 dpy = XtDisplay(theWidget);
1277 screen = ACTIVE_SCREEN;
1279 /* refresh the display */
1280 XmUpdateDisplay(theWidget);
1282 /* Change the curser to let the user select the desired widget */
1283 iStatus = LocateTheControl(dpy, screen, pWidget);
1287 } /* END OF FUNCTION WmDtReturnSelectedWidget */
1290 /****************************************************************************
1291 * Function: void WmDtDisplayTopic(
1299 * ClientData *pCData,
1300 * Boolean hyperlink,
1301 * DisplayTopicInfo *displayTopicInfo)
1305 * Return Value: Void.
1307 * Purpose: Displays a new Cache Creek help topic in a new/cached
1308 * help dialog widget.
1310 ****************************************************************************/
1323 DisplayTopicInfo *displayTopicInfo)
1335 WmPanelistObject pPanelist;
1336 char * defaultTitle="Help";
1337 ClientData *pCD = NULL;
1338 WmScreenData *pSD = NULL;
1339 CacheListStruct *pCurrentNode = NULL;
1340 Boolean cachedNode = FALSE;
1343 pSD = WmScreenDataFromWidget (parent);
1346 pPanelist = (WmPanelistObject) pSD->wPanelist;
1350 /*argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount + 1)) ;*/
1351 argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount)) ;
1352 memcpy( argsNew, argList, (sizeof( Arg) * argCount)) ;
1355 shellWidget = parent;
1356 while (!(XtIsSubclass(shellWidget, shellWidgetClass)))
1358 shellWidget = XtParent(shellWidget);
1364 case DtHELP_TYPE_TOPIC:
1365 if (helpVolume != NULL)
1367 XtSetArg (setArgs[n],DtNhelpVolume,helpVolume); n++;
1369 XtSetArg (setArgs[n], DtNlocationId,locationId); n++;
1370 helpTitle=locationId;
1373 case DtHELP_TYPE_DYNAMIC_STRING:
1374 XtSetArg (setArgs[n], DtNstringData, locationId); n++;
1375 /* helpTitle=locationId;*/
1376 helpTitle=defaultTitle;
1379 case DtHELP_TYPE_MAN_PAGE:
1382 case DtHELP_TYPE_FILE:
1387 /* error condition, don't try to display help */
1393 XtSetArg (setArgs[n], DtNhelpType, helpType); n++;
1397 if (pSD->dtHelp.shell)
1399 helpWidget = pSD->dtHelp.dialog;
1400 XtSetValues(helpWidget, setArgs, n);
1404 #ifndef NO_MESSAGE_CATALOG
1405 XtSetArg (setArgs[n], XmNtitle,
1406 wmNLS.defaultDtwmHelpTitle); n++;
1408 XtSetArg (setArgs[n], XmNtitle,
1409 "Workspace Manager - Help"); n++;
1412 pSD->dtHelp.dialog =
1413 DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
1414 helpWidget = pSD->dtHelp.dialog;
1415 pSD->dtHelp.shell = XtParent(helpWidget);
1416 pSD->dtHelp.bMapped = False;
1419 XtSetArg (setArgs[n], XmNname, "wmHelp"); n++;
1422 XtSetValues(pSD->dtHelp.shell,
1426 XtAddCallback(helpWidget,
1427 DtNhyperLinkCallback,
1428 WmDtProcessLinkCB, NULL);
1430 XtAddCallback(helpWidget, DtNcloseCallback,
1432 (XtPointer) helpWidget);
1434 XtAddCallback(pSD->dtHelp.shell, XmNpopupCallback,
1435 WmDtWmPopupHelpCB, NULL);
1437 XtAddEventHandler(pSD->dtHelp.shell,
1438 StructureNotifyMask,
1440 wmDtHelpMapEventHandler,
1446 ShowHelpDialog(pCData);
1452 XFindContext (DISPLAY, XtWindow(XtParent(wmClient)),
1453 wmGD.windowContextType, (caddr_t *)&pCD);
1457 XFindContext (DISPLAY, XtWindow(O_Shell(pPanelist)),
1458 wmGD.windowContextType, (caddr_t *)&pCD);
1460 ShowHelpDialog(pCD);
1465 /* Get a used or new node form our cache if we have one */
1466 cachedNode = WmDtGetFromCache(&pCurrentNode, pSD);
1468 /* If we got a free one from the Cache, use it */
1469 /* Set Values on current free one, then map it */
1472 XtSetValues(pCurrentNode->helpDialog, setArgs, n);
1476 #ifndef NO_MESSAGE_CATALOG
1477 XtSetArg (setArgs[n], XmNtitle,
1478 wmNLS.defaultHelpTitle); n++;
1480 XtSetArg (setArgs[n], XmNtitle,
1481 "Workspace Manager - Help"); n++;
1484 XtSetArg (setArgs[n], XmNgeometry, NULL); n++;
1485 XtSetArg (setArgs[n], XmNx, 0); n++;
1486 XtSetArg (setArgs[n], XmNy, 0); n++;
1488 pCurrentNode->helpDialog =
1489 DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
1491 XtSetArg (setArgs[n], XmNname, "cachedHelp"); n++;
1494 XtSetValues(shellWidget, argList, argCount);
1497 XtAddCallback(pCurrentNode->helpDialog,
1498 DtNhyperLinkCallback,
1499 WmDtProcessLinkCB, NULL);
1501 XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
1503 (XtPointer) pCurrentNode->helpDialog);
1507 pCurrentNode->hLink = True;
1511 if (displayTopicInfo)
1513 pCurrentNode->workspaces =
1514 displayTopicInfo->workspaces;
1515 pCurrentNode->xPos = displayTopicInfo->xPos;
1516 pCurrentNode->yPos = displayTopicInfo->yPos;
1517 pCurrentNode->restored = True;
1518 XtAddCallback(XtParent(pCurrentNode->helpDialog),
1521 (XtPointer)pCurrentNode);
1525 XtAddCallback(XtParent(pCurrentNode->helpDialog),
1527 WmDtPopupHelpCB, NULL);
1532 helpWidget = pCurrentNode->helpDialog;
1533 XtManageChild(helpWidget);
1534 XtPopup(XtParent(helpWidget), XtGrabNone);
1537 } /* if n is still 0, we did not find a useful help type */
1539 } /* END OF FUNCTION WmDtDisplayTopic */
1542 /****************************************************************************
1543 * Function: static Boolean WmDtGetFromCache(
1544 * CacheListStruct **pCurrentNode)
1549 * Return Value: Void.
1551 * Purpose: Gets a free help node form our cache list. If none are
1552 * free, it will return fallse and the calling routine will
1553 * create a new help dialog widget.
1555 ****************************************************************************/
1556 static Boolean WmDtGetFromCache(
1557 CacheListStruct **pCurrentNode,
1560 CacheListStruct *pTemp;
1562 if (pSD->cachedHelp == NULL)
1564 /* We have a new list so lets create one and pass it back */
1566 (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
1568 /* Assign the default values to our node */
1569 pSD->cachedHelp->helpDialog = NULL;
1570 pSD->cachedHelp->inUseFlag = TRUE;
1571 pSD->cachedHelp->restored = False;
1572 pSD->cachedHelp->hLink = False;
1573 pSD->cachedHelp->pNext = NULL;
1574 pSD->cachedHelp->pPrevious = NULL;
1576 /* Return our head pointer because it's our first and only node */
1577 *pCurrentNode = pSD->cachedHelp;
1582 /* We have some nodes so search for a free one first */
1583 pTemp = pSD->cachedHelp;
1585 while (pTemp != NULL)
1587 if (pTemp->inUseFlag == FALSE)
1589 pTemp->inUseFlag = TRUE;
1590 pTemp->hLink = False;
1591 pTemp->restored = False;
1592 *pCurrentNode = pTemp;
1596 pTemp = pTemp->pNext;
1601 * If we did not find a free node then we must add a new one to the
1602 * top of the list, and return it.
1605 pTemp = (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
1607 /* Assign the default values to our node */
1608 pTemp->helpDialog = NULL;
1609 pTemp->inUseFlag = TRUE;
1610 pTemp->restored = False;
1611 pTemp->hLink = False;
1612 pTemp->pNext = pSD->cachedHelp;
1613 pTemp->pPrevious = NULL;
1615 pSD->cachedHelp->pPrevious = pTemp;
1617 /* Re-Assign our head pointer to point to the new head of the list */
1618 pSD->cachedHelp = pTemp;
1620 /* Return our head pointer because it's our new node */
1621 *pCurrentNode = pSD->cachedHelp;
1625 } /* END OF FUNCTION WmDtGetFromCache */
1627 /* End of Dt utils */
1630 /*************************************<->*************************************
1633 * RestoreHelpDialogs (pSD)
1638 * Saves the state of the help system
1652 ******************************<->***********************************/
1660 XrmName xrm_name[5];
1661 XrmRepresentation rep_type;
1664 Position xLoc, yLoc;
1665 short columns, rows;
1671 char dialogName[18];
1673 ClientData *pCD = NULL;
1674 char *tTitle = NULL;
1675 char *wsName = NULL;
1676 char *wmClientName = NULL;
1677 char *helpVolume = NULL;
1678 char *locationId = NULL;
1679 char *stringData = NULL;
1680 char *workspaces = NULL;
1685 WmPanelistObject pPanelist = (WmPanelistObject) pSD->wPanelist;
1692 if (pSD->helpResources)
1694 if ((db = XrmGetStringDatabase (pSD->helpResources)) == NULL)
1698 xrm_name [0] = XrmStringToQuark ("wsHelp");
1699 xrm_name [1] = XrmStringToQuark ("onScreen");
1700 xrm_name [2] = NULLQUARK;
1703 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
1705 /* Are we supposed to be mapped? */
1706 if (strcmp(value.addr, "True") == 0)
1709 /* get x position */
1710 xrm_name [1] = XrmStringToQuark ("x");
1711 if (XrmQGetResource (db, xrm_name, xrm_name,
1714 pSD->dtHelp.xPos = (Position)atoi((char *)value.addr);
1715 pSD->dtHelp.restored = True;
1718 /* get y position */
1719 xrm_name [1] = XrmStringToQuark ("y");
1720 if (XrmQGetResource (db, xrm_name, xrm_name,
1723 pSD->dtHelp.yPos = (Position)atoi((char *)value.addr);
1724 pSD->dtHelp.restored = True;
1728 xrm_name [1] = XrmStringToQuark ("columns");
1729 if (XrmQGetResource (db, xrm_name, xrm_name,
1732 XtSetArg (setArgs[ac], XmNcolumns,
1733 (short)atoi((char *)value.addr)); ac++;
1734 columns = (short)atoi((char *)value.addr);
1738 xrm_name [1] = XrmStringToQuark ("rows");
1739 if (XrmQGetResource (db, xrm_name, xrm_name,
1742 XtSetArg (setArgs[ac], XmNrows,
1743 (short)atoi((char *)value.addr)); ac++;
1744 rows = (short)atoi((char *)value.addr);
1746 sprintf (geometry, "=+%d+%d", xLoc, yLoc);
1748 XtSetArg (setArgs[ac], XmNgeometry,
1749 XtNewString(geometry)); ac++;
1751 /* get visiblePathCount */
1752 xrm_name [1] = XrmStringToQuark ("vPCount");
1753 if (XrmQGetResource (db, xrm_name, xrm_name,
1756 XtSetArg (setArgs[ac], DtNvisiblePathCount,
1757 (int)atoi((char *)value.addr)); ac++;
1760 /* get topicTitle */
1761 xrm_name [1] = XrmStringToQuark ("tTitle");
1762 if (XrmQGetResource (db, xrm_name, xrm_name,
1765 tTitle = XtNewString ((char *)value.addr);
1766 XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
1770 xrm_name [1] = XrmStringToQuark ("helpType");
1771 if (XrmQGetResource (db, xrm_name, xrm_name,
1774 XtSetArg (setArgs[ac], DtNhelpType,
1775 (int)atoi((char *)value.addr)); ac++;
1776 helpType = (int)atoi((char *)value.addr);
1782 case DtHELP_TYPE_TOPIC:
1783 /* get helpVolume */
1784 xrm_name [1] = XrmStringToQuark ("helpVolume");
1785 if (XrmQGetResource (db, xrm_name, xrm_name,
1788 helpVolume = XtNewString ((char *)value.addr);
1789 /* XtSetArg (setArgs[ac], DtNhelpVolume,
1790 helpVolume); ac++;*/
1792 /* get locationId */
1793 xrm_name [1] = XrmStringToQuark ("locationId");
1794 if (XrmQGetResource (db, xrm_name, xrm_name,
1797 locationId = XtNewString ((char *)value.addr);
1798 /* XtSetArg (setArgs[ac], DtNlocationId,
1799 locationId); ac++;*/
1804 case DtHELP_TYPE_DYNAMIC_STRING:
1806 /* get stringData */
1807 xrm_name [1] = XrmStringToQuark ("stringData");
1808 if (XrmQGetResource (db, xrm_name, xrm_name,
1811 stringData = XtNewString ((char *)value.addr);
1812 /* XtSetArg (setArgs[ac], DtNstringData,
1813 stringData); ac++;*/
1814 locationId = stringData;
1819 case DtHELP_TYPE_MAN_PAGE:
1823 case DtHELP_TYPE_FILE:
1828 /* error condition, don't try to display help */
1832 /* get name of wm client for which wmHelp is transient */
1834 xrm_name [1] = XrmStringToQuark ("windowGroup");
1835 if (XrmQGetResource (db, xrm_name, xrm_name,
1838 wmClientName = ((char *)value.addr);
1839 if ((!strcmp(wmClientName, pSD->iconBoxName)) &&
1842 xrm_name [1] = XrmStringToQuark ("wsName");
1843 if (XrmQGetResource (db, xrm_name, xrm_name,
1846 wsName = (char *)value.addr;
1847 for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
1850 if (!strcmp(pSD->pWS[wsCnt].name, wsName))
1852 pCD=pSD->pWS[wsCnt].pIconBox->pCD_iconBox;
1860 else if(!strcmp(wmClientName, O_PanelName(pPanelist)))
1862 pCD=O_ClientData(pPanelist);
1868 * Map the help dialog
1871 WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
1873 helpType, NULL, True,
1874 setArgs, ac, pCD, False, NULL);
1876 }/* if (XrmQGetResource for wsHelp) */
1878 xrm_name [0] = XrmStringToQuark ("cachedHelp");
1879 xrm_name [1] = XrmStringToQuark ("cachedCount");
1880 xrm_name [2] = NULLQUARK;
1883 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
1885 /* restore cachedCount number of help dialogs */
1886 cachedCount = (int)atoi((char *)value.addr);
1887 for (cCount=1; cCount < (cachedCount + 1); cCount++)
1889 sprintf (dialogName, "oWsHelp%d", cCount);
1890 xrm_name [0] = XrmStringToQuark (dialogName);
1891 xrm_name [1] = NULLQUARK;
1892 xrm_name [2] = NULLQUARK;
1894 displayTopicInfo.xPos = 0;
1895 displayTopicInfo.xPos = 0;
1896 displayTopicInfo.workspaces = NULL;
1899 /* get x position */
1900 xrm_name [1] = XrmStringToQuark ("x");
1901 if (XrmQGetResource (db, xrm_name, xrm_name,
1904 /* XtSetArg (setArgs[ac], XmNx,
1905 atoi((char *)value.addr)); ac++;*/
1906 xLoc = (Position)atoi((char *)value.addr);
1907 displayTopicInfo.xPos = xLoc;
1910 /* get y position */
1911 xrm_name [1] = XrmStringToQuark ("y");
1912 if (XrmQGetResource (db, xrm_name, xrm_name,
1915 /* XtSetArg (setArgs[ac], XmNy,
1916 atoi((char *)value.addr)); ac++;*/
1917 yLoc = (Position)atoi((char *)value.addr);
1918 displayTopicInfo.yPos = yLoc;
1922 xrm_name [1] = XrmStringToQuark ("columns");
1923 if (XrmQGetResource (db, xrm_name, xrm_name,
1926 XtSetArg (setArgs[ac], XmNcolumns,
1927 (short)atoi((char *)value.addr)); ac++;
1928 columns = (short)atoi((char *)value.addr);
1932 xrm_name [1] = XrmStringToQuark ("rows");
1933 if (XrmQGetResource (db, xrm_name, xrm_name,
1936 XtSetArg (setArgs[ac], XmNrows,
1937 (short)atoi((char *)value.addr)); ac++;
1938 rows = (short)atoi((char *)value.addr);
1940 sprintf (geometry, "=+%d+%d", xLoc, yLoc);
1942 XtSetArg (setArgs[ac], XmNgeometry,
1943 XtNewString(geometry)); ac++;
1945 /* get visiblePathCount */
1946 xrm_name [1] = XrmStringToQuark ("vPCount");
1947 if (XrmQGetResource (db, xrm_name, xrm_name,
1950 XtSetArg (setArgs[ac], DtNvisiblePathCount,
1951 (int)atoi((char *)value.addr)); ac++;
1954 /* get topicTitle */
1955 xrm_name [1] = XrmStringToQuark ("tTitle");
1956 if (XrmQGetResource (db, xrm_name, xrm_name,
1959 tTitle = XtNewString ((char *)value.addr);
1960 XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
1963 /* get workspaces list */
1964 xrm_name [1] = XrmStringToQuark ("workspaces");
1965 if (XrmQGetResource (db, xrm_name, xrm_name,
1968 workspaces = XtNewString ((char *)value.addr);
1969 displayTopicInfo.workspaces = workspaces;
1974 xrm_name [1] = XrmStringToQuark ("helpType");
1975 if (XrmQGetResource (db, xrm_name, xrm_name,
1978 XtSetArg (setArgs[ac], DtNhelpType,
1979 (int)atoi((char *)value.addr)); ac++;
1980 helpType = (int)atoi((char *)value.addr);
1986 case DtHELP_TYPE_TOPIC:
1987 /* get helpVolume */
1988 xrm_name [1] = XrmStringToQuark ("helpVolume");
1989 if (XrmQGetResource (db, xrm_name, xrm_name,
1992 helpVolume = XtNewString ((char *)value.addr);
1994 /* get locationId */
1995 xrm_name [1] = XrmStringToQuark ("locationId");
1996 if (XrmQGetResource (db, xrm_name, xrm_name,
1999 locationId = XtNewString ((char *)value.addr);
2004 case DtHELP_TYPE_DYNAMIC_STRING:
2006 /* get stringData */
2007 xrm_name [1] = XrmStringToQuark ("stringData");
2008 if (XrmQGetResource (db, xrm_name, xrm_name,
2011 stringData = XtNewString ((char *)value.addr);
2012 /* XtSetArg (setArgs[ac], DtNstringData,
2013 stringData); ac++;*/
2014 locationId = stringData;
2019 case DtHELP_TYPE_MAN_PAGE:
2023 case DtHELP_TYPE_FILE:
2028 /* error condition, don't try to display help */
2033 WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
2035 helpType, NULL, False,
2036 setArgs, ac, NULL, False,
2039 } /* for all cached help dialogs */
2042 } /* if (XrmQGetResource ) cachedHelp/cachedCount */
2044 XrmDestroyDatabase(db);
2049 } /* END OF FUNCTION RestoreHelpDialogs */
2051 /*************************************<->*************************************
2054 * SaveHelpResources (pSD)
2059 * Saves the state of the help system
2073 ******************************<->***********************************/
2080 PtrWsDtHelpData pHelp;
2081 CacheListStruct *pTemp;
2085 Window wmGroupWindow;
2087 ClientData *pCDforHelp;
2091 WmWorkspaceData *pWS;
2093 Position xLoc, yLoc;
2094 short columns, rows;
2095 unsigned char helpType;
2102 char workspaces[MAXWMPATH+1];
2104 char buffer[MAXWMPATH+1];
2109 char screenName[10];
2110 char dialogName[128];
2111 char resString[MAXWMPATH+1];
2116 pHelp = &pSD->dtHelp;
2118 /* allocate initial data space */
2119 if ((data = (char *) XtMalloc (MAXWMPATH+1)) == NULL)
2122 GETMESSAGE(76,12,"Insufficient memory to save resources")));
2123 Do_Quit_Mwm (False);
2128 /* Get our current resource class */
2132 res_class = WM_RESOURCE_CLASS;
2136 res_class = DT_WM_RESOURCE_CLASS;
2139 sprintf (screenName, "%d", pSD->screen);
2141 sprintf (buffer, "%s*%s*%s: \\n ", res_class, screenName,
2143 AddStringToResourceData (buffer, &data, &cum_len);
2145 if (pHelp->onScreen)
2147 sprintf (dialogName, "wsHelp");
2148 sprintf (buffer, "%s*onScreen: True\\n ", dialogName);
2149 AddStringToResourceData (buffer, &data, &cum_len);
2152 XtSetArg(getArgs[ac], XmNx, &xLoc); ac++;
2153 XtSetArg(getArgs[ac], XmNy, &yLoc); ac++;
2154 XtGetValues(pSD->dtHelp.shell, getArgs, ac);
2155 if (!XFindContext (DISPLAY, XtWindow(pSD->dtHelp.shell),
2156 wmGD.windowContextType, (caddr_t *)&pCDforHelp))
2158 if (wmGD.positionIsFrame)
2160 xLoc = xLoc - pCDforHelp->clientOffset.x;
2161 yLoc = yLoc - pCDforHelp->clientOffset.y;
2166 XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
2167 XtSetArg(getArgs[ac], XmNrows, &rows); ac++;
2168 XtSetArg(getArgs[ac], DtNhelpType, &helpType); ac++;
2169 XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount); ac++;
2170 XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle); ac++;
2171 XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2173 sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
2174 AddStringToResourceData (buffer, &data, &cum_len);
2175 sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
2176 AddStringToResourceData (buffer, &data, &cum_len);
2177 sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
2178 AddStringToResourceData (buffer, &data, &cum_len);
2179 sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
2180 AddStringToResourceData (buffer, &data, &cum_len);
2181 sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
2182 AddStringToResourceData (buffer, &data, &cum_len);
2183 sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
2184 AddStringToResourceData (buffer, &data, &cum_len);
2185 sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
2186 AddStringToResourceData (buffer, &data, &cum_len);
2191 case DtHELP_TYPE_TOPIC:
2192 XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++;
2193 XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
2194 XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2195 sprintf (buffer, "%s*helpVolume: %s\\n ", dialogName, helpVolume);
2196 AddStringToResourceData (buffer, &data, &cum_len);
2197 sprintf (buffer, "%s*locationId: %s\\n ", dialogName, locationId);
2198 AddStringToResourceData (buffer, &data, &cum_len);
2202 case DtHELP_TYPE_DYNAMIC_STRING:
2203 XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
2204 XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2205 sprintf (buffer, "%s*stringData: %s\\n ", dialogName, stringData);
2206 AddStringToResourceData (buffer, &data, &cum_len);
2210 case DtHELP_TYPE_MAN_PAGE:
2214 case DtHELP_TYPE_FILE:
2219 /* error condition, don't try to display help */
2224 XtSetArg(getArgs[ac], XmNwindowGroup, &wmGroupWindow); ac++;
2225 XtGetValues(pSD->dtHelp.shell, getArgs, ac);
2227 if (!XFindContext (DISPLAY, wmGroupWindow,
2228 wmGD.windowContextType, (caddr_t *)&pCD))
2230 sprintf (buffer, "%s*windowGroup: %s\\n ", dialogName,
2232 AddStringToResourceData (buffer, &data, &cum_len);
2234 if ((!strcmp(pCD->clientName, pSD->iconBoxName)) &&
2237 wsName = XGetAtomName(DISPLAY,
2238 pCD->pWsList[pCD->currentWsc].wsID);
2239 sprintf (buffer, "%s*wsName: %s\\n ", dialogName,
2241 AddStringToResourceData (buffer, &data, &cum_len);
2248 if (pSD->cachedHelp != NULL)
2251 * We have some nodes so search for
2252 * managed dialogs and save their state
2255 pTemp = pSD->cachedHelp;
2257 while (pTemp != NULL)
2259 if (pTemp->inUseFlag == FALSE)
2261 pTemp = pTemp->pNext;
2266 sprintf (dialogName, "oWsHelp%d",cachedCount);
2269 XtSetArg(getArgs[ac], XmNx, &xLoc); ac++;
2270 XtSetArg(getArgs[ac], XmNy, &yLoc); ac++;
2271 XtGetValues(XtParent(pTemp->helpDialog), getArgs, ac);
2272 if (!XFindContext (DISPLAY,
2273 XtWindow(XtParent(pTemp->helpDialog)),
2274 wmGD.windowContextType,
2275 (caddr_t *)&pCDforHelp))
2277 if (wmGD.positionIsFrame)
2279 xLoc = xLoc - pCDforHelp->clientOffset.x;
2280 yLoc = yLoc - pCDforHelp->clientOffset.y;
2290 XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
2291 XtSetArg(getArgs[ac], XmNrows, &rows); ac++;
2292 XtSetArg(getArgs[ac], DtNhelpType, &helpType); ac++;
2293 XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount); ac++;
2294 XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle); ac++;
2295 XtGetValues(pTemp->helpDialog, getArgs, ac);
2297 sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
2298 AddStringToResourceData (buffer, &data, &cum_len);
2299 sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
2300 AddStringToResourceData (buffer, &data, &cum_len);
2301 sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
2302 AddStringToResourceData (buffer, &data, &cum_len);
2303 sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
2304 AddStringToResourceData (buffer, &data, &cum_len);
2305 sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
2306 AddStringToResourceData (buffer, &data, &cum_len);
2307 sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
2308 AddStringToResourceData (buffer, &data, &cum_len);
2309 sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
2310 AddStringToResourceData (buffer, &data, &cum_len);
2315 case DtHELP_TYPE_TOPIC:
2316 XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++;
2317 XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
2318 XtGetValues(pTemp->helpDialog, getArgs, ac);
2319 sprintf (buffer, "%s*helpVolume: %s\\n ",
2320 dialogName, helpVolume);
2321 AddStringToResourceData (buffer, &data, &cum_len);
2322 sprintf (buffer, "%s*locationId: %s\\n ",
2323 dialogName, locationId);
2324 AddStringToResourceData (buffer, &data, &cum_len);
2328 case DtHELP_TYPE_DYNAMIC_STRING:
2329 XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
2330 XtGetValues(pTemp->helpDialog, getArgs, ac);
2331 sprintf (buffer, "%s*stringData: %s\\n ",
2332 dialogName, stringData);
2333 AddStringToResourceData (buffer, &data, &cum_len);
2337 case DtHELP_TYPE_MAN_PAGE:
2341 case DtHELP_TYPE_FILE:
2346 /* error condition, don't try to display help */
2353 sprintf(workspaces, "%s", "");
2354 for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
2357 wsID = XInternAtom (DISPLAY, pSD->pWS[wsCnt].name,
2359 pWS = GetWorkspaceData (pSD, wsID);
2361 if (ClientInWorkspace (pWS, pCDforHelp))
2365 strcpy(workspaces, pSD->pWS[wsCnt].name);
2370 strcat(workspaces, "*");
2371 strcat(workspaces, pSD->pWS[wsCnt].name);
2376 sprintf (buffer, "%s*workspaces: %s\\n ", dialogName,
2378 AddStringToResourceData (buffer, &data, &cum_len);
2380 pTemp = pTemp->pNext;
2385 sprintf (buffer, "cachedHelp*cachedCount: %d\\n ", cachedCount);
2386 AddStringToResourceData (buffer, &data, &cum_len);
2393 * Save help resources as a string
2395 sprintf (buffer, " \n");
2396 AddStringToResourceData (buffer, &data, &cum_len);
2398 _DtAddToResource (DISPLAY, data);
2402 } /* END OF FUNCTION SaveHelpResources */
2406 /* Code stolen from WmPresence.c */
2408 /*************************************<->*************************************
2411 * ShowHelpDialog (pClient)
2416 * Pops up (shows) the help dialog
2430 ******************************<->***********************************/
2434 ClientData *pClient)
2436 PtrWsDtHelpData pHelp;
2448 pHelp = &pSD->dtHelp;
2450 pOldCD = pHelp->pCDforClient;
2451 pHelp->pCDforClient = pClient;
2452 /* pHelp->contextForClient = wsContext;*/
2454 if (pSD->dtHelp.onScreen)
2456 ClientData *pCD = NULL;
2458 XFindContext (DISPLAY, XtWindow (pSD->dtHelp.shell),
2459 wmGD.windowContextType, (XtPointer) &pCD);
2461 if ((!pSD->dtHelp.bMapped) ||
2463 (!ClientInWorkspace (ACTIVE_WS, pCD) ||
2464 (pCD->clientState == MINIMIZED_STATE) ||
2465 (pOldCD && pOldCD != pHelp->pCDforClient))))
2467 HideHelpDialog (pSD, True);
2475 XtManageChild(pSD->dtHelp.dialog);
2476 XtPopup (pSD->dtHelp.shell, XtGrabNone);
2478 pSD->dtHelp.onScreen = True;
2480 } /* END OF FUNCTION ShowHelpDialog */
2483 /*************************************<->*************************************
2486 * HideHelpDialog (pSD, userDismissed)
2491 * Pops down (hides) the workspace presence dialog
2495 * pSD = pointer to screen data
2496 * userDismissed = did the user dismiss or did workspace switching
2497 * unpost the workspace presence box ?
2507 ******************************<->***********************************/
2512 Boolean userDismissed )
2515 if (pSD->dtHelp.onScreen)
2517 /* Pop down the shell */
2518 XtPopdown (pSD->dtHelp.shell);
2521 * Do a withdraw to make sure window gets unmanaged
2522 * (popdown does nothing if its unmapped)
2524 XWithdrawWindow (DISPLAY, XtWindow (pSD->dtHelp.shell),
2526 /* must sync to insure event order */
2527 XSync (DISPLAY, False);
2530 pSD->dtHelp.onScreen = False;
2531 pSD->dtHelp.userDismissed = userDismissed;
2534 } /* END OF FUNCTION HideHelpDialog */
2537 /*************************************<->*************************************
2539 * wmDtHelpSetPosition (pHelp, pSD, restorePos)
2544 * Sets the position of the workspace presence dialog
2548 * pPres = pointer to workspace presence data
2553 ******************************<->***********************************/
2555 wmDtHelpSetPosition(
2556 PtrWsDtHelpData pHelp,
2564 Window wGroup = None;
2566 ClientData *pCDforHelp;
2571 * Get size of this dialog
2574 XtSetArg (args[n], XmNheight, &height); n++;
2575 XtGetValues (pHelp->shell, args, n);
2577 if (wmGD.positionIsFrame)
2579 if (pSD->decoupleTitleAppearance)
2581 font = pSD->clientTitleAppearance.font;
2585 font = pSD->clientAppearance.font;
2588 /* height += TEXT_HEIGHT(font) + (2 * pSD->frameBorderWidth);*/
2589 height += TEXT_HEIGHT(font) + (2 * pSD->resizeBorderWidth);
2594 * set position of dialog relative to client window
2595 * (use system menu position)
2596 * set this dialog to be transient for the client
2597 * for which it is posted.
2599 if (pHelp->pCDforClient)
2601 GetSystemMenuPosition (pHelp->pCDforClient,
2605 if(y < pHelp->pCDforClient->frameInfo.y)
2607 if (!XFindContext (DISPLAY, XtWindow(pHelp->shell),
2608 wmGD.windowContextType,
2609 (caddr_t *)&pCDforHelp))
2611 if (wmGD.positionIsFrame)
2613 /* x = x - pCDforHelp->clientOffset.x;*/
2614 y = y - pCDforHelp->clientOffset.x;
2619 y = y - (2 * pSD->frameBorderWidth);
2627 * Don't have a client so map at 0,0
2640 XtSetArg (args[n], XmNgeometry, NULL); n++;
2641 XtSetArg (args[n], XmNx, x); n++;
2642 XtSetArg (args[n], XmNy, y); n++;
2643 XtSetArg (args[n], XmNtransientFor, NULL); n++;
2645 if (pHelp->pCDforClient)
2651 XtSetArg (al[ac], XmNwindowGroup, &wGroup); ac++;
2652 XtGetValues (pHelp->shell, al, ac);
2655 if (pHelp->contextForClient != F_CONTEXT_ICON)
2657 XtSetArg (args[n], XmNwindowGroup,
2658 pHelp->pCDforClient->client);
2661 else if (pSD->useIconBox && P_ICON_BOX(pHelp->pCDforClient))
2663 XtSetArg (args[n], XmNwindowGroup,
2664 P_ICON_BOX(pHelp->pCDforClient)->pCD_iconBox->client);
2669 XtSetArg (args[n], XmNwindowGroup, 0); n++;
2672 if (wGroup != pHelp->pCDforClient->client)
2675 * Changing who this is transient for, need to
2676 * make sure the window is unmapped so that the
2677 * window manager moves it to the right place.
2679 HideHelpDialog (pSD, True);
2682 XtSetArg (args[n], XmNwindowGroup, pHelp->pCDforClient->client); n++;
2689 HideHelpDialog (pSD, True);
2691 XtSetArg (args[n], XmNwindowGroup, 0); n++;
2694 XtSetArg (args[n], XmNwaitForWm, False); n++;
2696 XtSetValues (pHelp->shell, args, n);
2699 } /* END OF FUNCTION wmDtHelpSetPosition */
2701 /* End of Code stolen from WmPresence.c */
2703 /*************************************<->*************************************
2705 * wmDtHelpMapEventHandler (wHelp, pSD, pEvent)
2710 * An XtEventHandler called on structure notify events on the screen's
2711 * help window. (Only handles map and unmap events)
2715 * wHelp = help widget
2716 * pSD = ptr to screen data
2717 * pEvent = event triggering this call
2722 ******************************<->***********************************/
2724 wmDtHelpMapEventHandler(
2728 Boolean *pBoolean) /* unused */
2730 WmScreenData *pSD = (WmScreenData *) ptr;
2732 switch (pEvent->type)
2735 pSD->dtHelp.bMapped = True;
2739 pSD->dtHelp.bMapped = False;
2743 /* END OF FUNCTION wmDtHelpMapHandler */
2747 /*************************************<->*************************************
2749 * wmDtErrorDialog (pSD, message, title)
2754 * Called to show an error message
2758 * pSD = ptr to screen data
2759 * message = error message to display
2760 * title = title for the error dialog
2765 ******************************<->***********************************/
2775 XmString xmsMessage;
2780 Window wRoot, wChild;
2781 int rootX, rootY, winX, winY;
2783 Dimension dWidth, dHeight;
2786 WmPanelistObject pPanelist;
2787 #endif /* PANELIST */
2790 XmStringCreateLocalized (sMessage);
2792 XmStringCreateLocalized (sTitle);
2794 if (pSD->dtHelp.errorDialog == NULL)
2796 #ifdef NO_MESSAGE_CATALOG
2797 XmString tmpXmString = (XmString)NULL;
2801 XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++;
2802 XtSetArg (al[ac], XmNdialogTitle, xmsTitle); ac++;
2803 #ifndef NO_MESSAGE_CATALOG
2804 XtSetArg (al[ac], XmNokLabelString, wmGD.okLabel); ac++;
2806 tmpXmString = XmStringCreateLocalized ("OK");
2807 XtSetArg (al[ac], XmNokLabelString, tmpXmString); ac++;
2811 if ((wmGD.dtSD == pSD) && pSD->wPanelist)
2813 pPanelist = (WmPanelistObject) pSD->wPanelist;
2814 wParent = O_Shell (pPanelist);
2818 wParent = pSD->screenTopLevelW1;
2821 wParent = pSD->screenTopLevelW1;
2823 pSD->dtHelp.errorDialog =
2824 XmCreateErrorDialog (wParent, "Error Dialog", al, ac);
2826 #ifdef NO_MESSAGE_CATALOG
2828 XmStringFree(tmpXmString);
2831 wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog,
2832 XmDIALOG_HELP_BUTTON);
2833 XtUnmanageChild (wTemp);
2835 wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog,
2836 XmDIALOG_CANCEL_BUTTON);
2837 XtUnmanageChild (wTemp);
2839 XtAddCallback (pSD->dtHelp.errorDialog, XmNokCallback,
2840 wmDtErrorDialogOkCB, (XtPointer)pSD);
2842 wShell = pSD->dtHelp.errorDialog;
2843 while (!(XtIsSubclass(wShell, shellWidgetClass)))
2845 wShell = XtParent(wShell);
2847 XtAddCallback(wShell, XmNpopupCallback, wmDtErrorDialogPopupCB,
2850 XtRealizeWidget (pSD->dtHelp.errorDialog);
2852 /* remove some WM functions */
2854 XtSetArg (al[ac], XmNmwmFunctions, (MWM_FUNC_ALL|
2855 MWM_FUNC_RESIZE|MWM_FUNC_MINIMIZE|MWM_FUNC_MAXIMIZE));
2857 XtSetValues (wShell, al, ac);
2859 DtWsmRemoveWorkspaceFunctions (DISPLAY, XtWindow(wShell));
2863 /* make sure it's unmanaged */
2864 wmDtErrorDialogHide (pSD);
2866 /* set new message and title */
2868 XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++;
2869 XtSetArg (al[ac], XmNdialogTitle, xmsTitle); ac++;
2870 XtSetValues (pSD->dtHelp.errorDialog, al, ac);
2873 if (pSD->dtHelp.errorDialog)
2875 XtManageChild (pSD->dtHelp.errorDialog);
2876 XtPopup (XtParent(pSD->dtHelp.errorDialog), XtGrabNone);
2879 XmStringFree (xmsMessage);
2880 XmStringFree (xmsTitle);
2882 /* END OF FUNCTION wmDtErrorDialog */
2885 /*************************************<->*************************************
2888 * wmDtErrorDialogHide (pSD)
2897 * pSD = ptr to screen data
2908 *************************************<->***********************************/
2911 wmDtErrorDialogHide( WmScreenData *pSD )
2915 XtPopdown (XtParent(pSD->dtHelp.errorDialog));
2916 XtUnmanageChild (pSD->dtHelp.errorDialog);
2918 * Do a withdraw to make sure window gets unmanaged
2919 * (popdown does nothing if its unmapped)
2921 wShell = pSD->dtHelp.errorDialog;
2922 while (!(XtIsSubclass(wShell, shellWidgetClass)))
2924 wShell = XtParent(wShell);
2927 XWithdrawWindow (DISPLAY, XtWindow (wShell), pSD->screen);
2929 /* must sync to insure event order */
2930 XSync (DISPLAY, False);
2932 } /* END OF FUNCTION wmDtErrorDialogHide */
2935 /*************************************<->*************************************
2938 * wmDtErrorDialogOkCB (w, client_data, call_data)
2960 *************************************<->***********************************/
2963 wmDtErrorDialogOkCB(
2965 XtPointer client_data,
2966 XtPointer call_data )
2968 WmScreenData *pSD = (WmScreenData *) client_data;
2970 wmDtErrorDialogHide (pSD);
2972 } /* END OF FUNCTION wmDtErrorDialogOkCB */
2975 /*************************************<->*************************************
2978 * wmDtErrorDialogPopupCB (w, client_data, call_data)
3000 *************************************<->***********************************/
3003 wmDtErrorDialogPopupCB(
3005 XtPointer client_data,
3006 XtPointer call_data )
3008 WmScreenData *pSD = (WmScreenData *) client_data;
3009 Window wRoot, wChild;
3010 int rootX, rootY, winX, winY;
3012 Dimension dWidth, dHeight;
3017 /* set new position near cursor position */
3018 XQueryPointer (DISPLAY, XtWindow(pSD->screenTopLevelW1),
3019 &wRoot, &wChild, &rootX, &rootY, &winX, &winY, &mask);
3022 XtSetArg (al[ac], XmNwidth, &dWidth); ac++;
3023 XtSetArg (al[ac], XmNheight, &dHeight); ac++;
3024 XtGetValues (w, al, ac);
3026 x = (Position) rootX - (dWidth / 2);
3027 y = (Position) rootY - (dHeight / 2);
3029 if ((x + ((Position) dWidth / 2)) > DisplayWidth (DISPLAY, pSD->screen))
3030 x = DisplayWidth (DISPLAY,pSD->screen) - (dWidth/2) - 1;
3034 if ((y + ((Position) dHeight / 2)) > DisplayHeight (DISPLAY, pSD->screen))
3035 y = DisplayHeight (DISPLAY,pSD->screen) - (dHeight/2) - 1;
3040 XtSetArg (al[ac], XmNx, x); ac++;
3041 XtSetArg (al[ac], XmNy, y); ac++;
3042 XtSetArg (al[ac], XmNwindowGroup,
3043 XtUnspecifiedWindowGroup); ac++;
3044 XtSetArg (al[ac], XmNwaitForWm, False); ac++;
3045 XtSetValues (w, al, ac);
3048 } /* END OF FUNCTION wmDtErrorDialogPopupCB */
3050 /**************************** eof ***************************/