WmHelp.c 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * (c) Copyright 1987, 1988, 1989, 1990, 1992, 1993 HEWLETT-PACKARD COMPANY
  25. * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
  26. * ALL RIGHTS RESERVED
  27. */
  28. /*
  29. * Included Files:
  30. */
  31. #if defined(sun)
  32. #ifndef XK_MISCELLANY
  33. #define XK_MISCELLANY
  34. #endif
  35. #endif
  36. #include "WmGlobal.h"
  37. #include "WmError.h"
  38. #include "WmFunction.h"
  39. #include "WmHelp.h"
  40. #include "WmCDecor.h"
  41. #include "WmResParse.h"
  42. #include "WmPanelP.h"
  43. #include "WmResNames.h"
  44. #include "WmWrkspace.h"
  45. #include "DataBaseLoad.h"
  46. #include <stdio.h>
  47. #include <Xm/Xm.h>
  48. #include <Xm/XmP.h>
  49. #include <Xm/MessageB.h>
  50. #include <X11/keysymdef.h>
  51. #include <X11/keysym.h>
  52. #include <X11/Shell.h>
  53. #include <Xm/MwmUtil.h>
  54. #include <Dt/HelpDialog.h>
  55. #include <Dt/HelpQuickD.h>
  56. #include <Dt/DtNlUtils.h>
  57. #include <X11/cursorfont.h>
  58. /****************************************************************
  59. *
  60. * Cache List Info Structure Definition.
  61. *
  62. ****************************************************************/
  63. typedef struct _CacheListStruct {
  64. Widget helpDialog;
  65. Boolean inUseFlag;
  66. Boolean hLink;
  67. Boolean restored;
  68. char *workspaces;
  69. Position xPos;
  70. Position yPos;
  71. struct _CacheListStruct *pNext;
  72. struct _CacheListStruct *pPrevious;
  73. } CacheListStruct;
  74. typedef struct _DisplayTopicInfo {
  75. char *workspaces;
  76. Position xPos;
  77. Position yPos;
  78. } DisplayTopicInfo;
  79. /*
  80. * Function Declarations:
  81. */
  82. /******** Static Function Declarations ********/
  83. static int LocateTheControl(
  84. Display *dpy,
  85. int screen,
  86. Widget *pWidget);
  87. static WmScreenData *WmScreenDataFromWidget (
  88. Widget theWidget) ;
  89. static int WmDtReturnSelectedWidget (
  90. Widget theWidget,
  91. Cursor cursor,
  92. Widget *pWidget);
  93. static void WmDtDisplayTopic (
  94. Widget parent,
  95. char *accessPath,
  96. char *idString,
  97. int helpType,
  98. Widget wmClient,
  99. Boolean wmHelp,
  100. ArgList argList,
  101. int argCount,
  102. ClientData *pCData,
  103. Boolean hyperLink,
  104. DisplayTopicInfo *displayTopicInfo);
  105. static void WmDtCloseHelpCB (
  106. Widget w,
  107. XtPointer clientData,
  108. XtPointer callData);
  109. static void WmDtWmCloseHelpCB (
  110. Widget w,
  111. XtPointer clientData,
  112. XtPointer callData);
  113. static void WmDtVersionCloseCB (
  114. Widget w,
  115. XtPointer clientData,
  116. XtPointer callData);
  117. static void WmDtVersionPopupCB (
  118. Widget w,
  119. XtPointer clientData,
  120. XtPointer callData);
  121. static void WmDtProcessLinkCB (
  122. Widget w,
  123. XtPointer clientData,
  124. XtPointer callData);
  125. static Boolean WmDtGetFromCache(
  126. CacheListStruct **pCurrentNode,
  127. WmScreenData *pSD);
  128. static void ShowHelpDialog(
  129. ClientData *pClient);
  130. static void HideHelpDialog(
  131. WmScreenData *pSD,
  132. Boolean userDismissed );
  133. static void wmDtHelpSetPosition(
  134. PtrWsDtHelpData pHelp,
  135. WmScreenData *pSD,
  136. Boolean restorePos);
  137. static void wmDtHelpMapEventHandler (
  138. Widget,
  139. XtPointer,
  140. XEvent *,
  141. Boolean *);
  142. static void wmDtErrorDialog(
  143. WmScreenData *pSD,
  144. String sMessage,
  145. String sTitle);
  146. static void wmDtErrorDialogOkCB(
  147. Widget w,
  148. XtPointer client_data,
  149. XtPointer call_data );
  150. static void wmDtErrorDialogPopupCB(
  151. Widget w,
  152. XtPointer client_data,
  153. XtPointer call_data );
  154. static void wmDtErrorDialogHide(
  155. WmScreenData *pSD );
  156. /******** End Static Function Declarations ********/
  157. /*
  158. * Global Variables:
  159. */
  160. static DisplayTopicInfo displayTopicInfo;
  161. static Widget versionWidget = (Widget)NULL;
  162. #define PT_IN_CHILD(X, Y, CHILD) \
  163. (((X) >= (CHILD)->core.x) && \
  164. ((X) <= ((CHILD)->core.x + (Position) (CHILD)->core.width)) && \
  165. ((Y) >= (CHILD)->core.y) && \
  166. ((Y) <= ((CHILD)->core.y + (Position) (CHILD)->core.height)))
  167. #define MAX_WIDGET_PATH 100
  168. /**********************************************************************
  169. * Function: LocateTheControl()
  170. *
  171. *
  172. *
  173. **********************************************************************/
  174. static int
  175. LocateTheControl(
  176. Display *dpy,
  177. int screen,
  178. Widget *pWidget )
  179. {
  180. Widget child;
  181. CompositeWidget comp_widget;
  182. int status;
  183. Cursor cursor;
  184. XEvent event;
  185. Window target_win = None;
  186. int buttons = 0;
  187. int x,y;
  188. int i;
  189. Window parent;
  190. Window sub;
  191. int new_x, new_y;
  192. int offset;
  193. KeySym keySym;
  194. Widget widget = NULL;
  195. Boolean foundOne = False;
  196. int clientNum, scr;
  197. WmFpEmbeddedClientData *pECD;
  198. WmScreenData *pSD = NULL;
  199. /* Make the target cursor */
  200. cursor = XCreateFontCursor (wmGD.display, XC_question_arrow);
  201. /* Grab the pointer using target cursor, letting it roam all over */
  202. status = XGrabPointer (wmGD.display, RootWindow(wmGD.display, screen),
  203. False,
  204. ButtonPressMask|ButtonReleaseMask, GrabModeAsync,
  205. GrabModeAsync, None, cursor, CurrentTime);
  206. if (status != GrabSuccess)
  207. {
  208. Warning (((char *)GETMESSAGE(29, 1,
  209. "Help on Item failed. Another program may have grabbed the mouse.")));
  210. return(DtHELP_SELECT_ERROR);
  211. }
  212. /* Grab the Keyboard so we can catch the ESC button press */
  213. status = XGrabKeyboard(wmGD.display, RootWindow(wmGD.display, screen),
  214. False,
  215. GrabModeAsync, GrabModeAsync, CurrentTime);
  216. if (status != GrabSuccess)
  217. {
  218. XUngrabPointer (wmGD.display, CurrentTime);
  219. Warning (((char *)GETMESSAGE(29, 2,
  220. "Help on Item failed. Another program may have grabbed the mouse.")));
  221. return(DtHELP_SELECT_ERROR);
  222. }
  223. /* Let the user select a window... */
  224. while ((target_win == None) || (buttons != 0))
  225. {
  226. XtAppNextEvent(wmGD.mwmAppContext, &event);
  227. switch (event.type)
  228. {
  229. case ButtonPress:
  230. if (target_win == None)
  231. {
  232. target_win = event.xbutton.subwindow; /* window selected */
  233. if (target_win == None)
  234. target_win = RootWindow (wmGD.display, screen);
  235. }
  236. buttons++;
  237. break;
  238. case ButtonRelease:
  239. /* there may have been some down before we started */
  240. if (buttons > 0)
  241. buttons--;
  242. break;
  243. case KeyPress:
  244. /* Look for ESC key press and stop if we get one */
  245. if (event.xkey.state & ShiftMask)
  246. offset = 1;
  247. else
  248. offset = 0;
  249. keySym = XLookupKeysym((XKeyEvent *)&event, offset);
  250. if (keySym == XK_Escape)
  251. {
  252. XUngrabKeyboard (wmGD.display, CurrentTime);
  253. XUngrabPointer (wmGD.display, CurrentTime);
  254. return(DtHELP_SELECT_ABORT);
  255. }
  256. }
  257. XtDispatchEvent(&event);
  258. }
  259. XUngrabKeyboard (wmGD.display, CurrentTime); /* Done with keyboard */
  260. XUngrabPointer (wmGD.display, CurrentTime); /* Done with pointer */
  261. #ifdef DEBUGGER
  262. printf("RootWindow (wmGD.display, screen) = %ld\n", RootWindow (wmGD.display, screen));
  263. printf("event.xbutton.root = %ld\n", event.xbutton.root);
  264. printf("event.xbutton.window = %ld\n", event.xbutton.window);
  265. printf("event.xbutton.subwindow = %ld\n", event.xbutton.subwindow);
  266. printf("event.xbutton.x = %d\n", event.xbutton.x);
  267. printf("event.xbutton.y = %d\n", event.xbutton.y);
  268. printf("event.xbutton.x_root = %d\n", event.xbutton.x_root);
  269. printf("event.xbutton.y_root = %d\n", event.xbutton.y_root);
  270. #endif /* DEBUGGER */
  271. if (target_win == RootWindow (wmGD.display, screen))
  272. return (DtHELP_SELECT_INVALID);
  273. for (scr = 0; scr < wmGD.numScreens; scr++)
  274. {
  275. if (wmGD.Screens[scr].managed &&
  276. wmGD.Screens[scr].screen == screen)
  277. {
  278. pSD = (&(wmGD.Screens[scr]));
  279. break;
  280. }
  281. }
  282. if (!pSD)
  283. {
  284. pSD=wmGD.pActiveSD;
  285. }
  286. /* check for subwindows */
  287. parent = RootWindow (wmGD.display, screen);
  288. x = event.xbutton.x_root;
  289. y = event.xbutton.y_root;
  290. while (!foundOne)
  291. {
  292. XTranslateCoordinates(wmGD.display, parent, target_win, x, y,
  293. &new_x, &new_y, &sub);
  294. if (!sub)
  295. {
  296. x = new_x;
  297. y = new_y;
  298. break;
  299. }
  300. else
  301. {
  302. pECD = (WmFpEmbeddedClientData *) pSD->pECD;
  303. for (clientNum = 0; clientNum < pSD->numEmbeddedClients;
  304. clientNum++, pECD++)
  305. {
  306. if ((pECD->pCD) &&
  307. (target_win == pECD->pCD->client))
  308. {
  309. widget = pECD->wControl;
  310. foundOne = True;
  311. break;
  312. }
  313. }
  314. parent = target_win;
  315. target_win = sub;
  316. x = new_x;
  317. y = new_y;
  318. }
  319. }
  320. if (widget == NULL)
  321. {
  322. widget = XtWindowToWidget (wmGD.display, target_win);
  323. }
  324. if (widget == NULL)
  325. {
  326. widget = XtWindowToWidget (wmGD.display1, target_win);
  327. if (widget == NULL)
  328. {
  329. return (DtHELP_SELECT_INVALID);
  330. }
  331. }
  332. if (!XtIsComposite (widget))
  333. {
  334. *pWidget = widget;
  335. return (DtHELP_SELECT_VALID);
  336. }
  337. comp_widget = (CompositeWidget)widget;
  338. /* look for gadgets at this point */
  339. for (i = 0; i < comp_widget->composite.num_children; i++)
  340. {
  341. child = comp_widget->composite.children[i];
  342. if (PT_IN_CHILD (x, y, child) && XtIsManaged(child))
  343. {
  344. *pWidget = child;
  345. return (DtHELP_SELECT_VALID);
  346. }
  347. }
  348. if (widget != NULL)
  349. {
  350. *pWidget = widget;
  351. return (DtHELP_SELECT_VALID);
  352. }
  353. return (DtHELP_SELECT_INVALID);
  354. } /* END OF FUNCTION LocateTheControl */
  355. /**********************************************************************
  356. *
  357. * Cache Creek related help functions
  358. *
  359. **********************************************************************/
  360. /*************************************<->*************************************
  361. *
  362. * WmDtStringHelpCB
  363. *
  364. *
  365. * Description:
  366. * -----------
  367. *
  368. *
  369. *************************************<->***********************************/
  370. void WmDtStringHelpCB (Widget theWidget,
  371. XtPointer client_data,
  372. XtPointer call_data)
  373. {
  374. WmScreenData *pSD;
  375. char * theHelpString = (char *)client_data;
  376. Widget theRealWidget = theWidget;
  377. if( XmIsGadget(theWidget))
  378. {
  379. theRealWidget = XtParent(theWidget);
  380. }
  381. pSD = WmScreenDataFromWidget(theWidget);
  382. /* WmDtDisplayTopic(theRealWidget, NULL, theHelpString, */
  383. WmDtDisplayTopic(pSD->screenTopLevelW1, NULL, theHelpString,
  384. DtHELP_TYPE_DYNAMIC_STRING, (Widget) NULL, True,
  385. NULL, 0, NULL, False, NULL);
  386. } /* END OF FUNCTION WmDtStringHelpCB */
  387. /*************************************<->*************************************
  388. *
  389. * WmDtWmStringHelpCB
  390. *
  391. *
  392. * Description:
  393. * -----------
  394. *
  395. *
  396. *************************************<->***********************************/
  397. void WmDtWmStringHelpCB (Widget theWidget,
  398. XtPointer client_data,
  399. XtPointer call_data)
  400. {
  401. WmScreenData *pSD;
  402. char * theHelpString = (char *)client_data;
  403. pSD = WmScreenDataFromWidget(theWidget);
  404. WmDtDisplayTopic(pSD->screenTopLevelW1,
  405. NULL, theHelpString,
  406. DtHELP_TYPE_DYNAMIC_STRING, theWidget, True,
  407. NULL, 0, NULL, False, NULL);
  408. } /* END OF FUNCTION WmDtWmStringHelpCB */
  409. /*************************************<->*************************************
  410. *
  411. * WmDtDisplayTopicHelp
  412. *
  413. * Description:
  414. * -----------
  415. * External entry procedure used to display help topics.
  416. *
  417. *************************************<->***********************************/
  418. void WmDtDisplayTopicHelp (Widget widget,
  419. char * helpVolume,
  420. char * locationID)
  421. {
  422. WmScreenData *pSD = WmScreenDataFromWidget(widget);
  423. WmDtDisplayTopic(pSD->screenTopLevelW1,
  424. helpVolume, locationID,
  425. DtHELP_TYPE_TOPIC, (Widget) NULL, True,
  426. NULL, 0, NULL, False, NULL);
  427. }
  428. /*************************************<->*************************************
  429. *
  430. * WmDtDisplayStringHelp
  431. *
  432. * Description:
  433. * -----------
  434. * External entry procedure used to display help topics.
  435. *
  436. *************************************<->***********************************/
  437. void WmDtDisplayStringHelp (Widget widget,
  438. char * helpString)
  439. {
  440. WmScreenData *pSD = WmScreenDataFromWidget(widget);
  441. WmDtDisplayTopic(pSD->screenTopLevelW1,
  442. NULL, helpString,
  443. DtHELP_TYPE_DYNAMIC_STRING, widget, True,
  444. NULL, 0, NULL, False, NULL);
  445. }
  446. /*************************************<->*************************************
  447. *
  448. * WmDtWmTopicHelpCB
  449. *
  450. *
  451. * Description:
  452. * -----------
  453. * for each icon in the icon box
  454. *
  455. *************************************<->***********************************/
  456. void WmDtWmTopicHelpCB (Widget theWidget,
  457. XtPointer client_data,
  458. XtPointer call_data)
  459. {
  460. Widget shellWidget;
  461. WmScreenData *pSD;
  462. char *helpVolume = WM_DT_HELP_VOLUME;
  463. char *locationID = (char *)client_data;
  464. pSD = WmScreenDataFromWidget(theWidget);
  465. shellWidget = theWidget;
  466. while (!(XtIsSubclass(XtParent(shellWidget), shellWidgetClass)))
  467. {
  468. shellWidget = XtParent(shellWidget);
  469. }
  470. WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
  471. locationID,
  472. DtHELP_TYPE_TOPIC, shellWidget, True,
  473. NULL, 0, NULL, False, NULL);
  474. } /* END OF FUNCTION WmDtWmTopicHelpCB */
  475. /****************************************************************************
  476. * Function: WmScreenDataFromWidget(
  477. * Widget theWidget)
  478. *
  479. * Parameters:
  480. *
  481. * Return Value: pSD
  482. *
  483. * Purpose:
  484. *
  485. ***************************************************************************/
  486. static WmScreenData *
  487. WmScreenDataFromWidget (Widget theWidget)
  488. {
  489. WmScreenData *pSD = NULL;
  490. int scr;
  491. CacheListStruct *pTemp;
  492. if (theWidget)
  493. {
  494. for (scr = 0; scr < wmGD.numScreens; scr++)
  495. {
  496. if (wmGD.Screens[scr].managed &&
  497. wmGD.Screens[scr].screen ==
  498. XScreenNumberOfScreen(XtScreen(theWidget)))
  499. {
  500. pSD = (&(wmGD.Screens[scr]));
  501. break;
  502. }
  503. }
  504. if (!pSD)
  505. {
  506. pSD=wmGD.pActiveSD;
  507. }
  508. }
  509. else
  510. {
  511. pSD=wmGD.pActiveSD;
  512. }
  513. return(pSD);
  514. } /* END OF FUNCTION WmScreenDataFromWidget */
  515. /****************************************************************************
  516. * Function: WmDtCloseHelpCB(
  517. * Widget w,
  518. * caddr_t clientData,
  519. * caddr_t callData
  520. *
  521. * Parameters:
  522. *
  523. * Return Value: Void.
  524. *
  525. * Purpose: Process close requests on all Help Dialog widgets
  526. * created and managed by this application.
  527. *
  528. ***************************************************************************/
  529. static void WmDtCloseHelpCB (
  530. Widget w,
  531. XtPointer clientData,
  532. XtPointer callData)
  533. {
  534. WmScreenData *pSD = NULL;
  535. int scr;
  536. Widget helpDialog = (Widget) clientData;
  537. CacheListStruct *pTemp;
  538. pSD = WmScreenDataFromWidget(w);
  539. pTemp = pSD->cachedHelp;
  540. /* Search our Cache List for the closed help dialog */
  541. while (pTemp && (pTemp->helpDialog != helpDialog))
  542. {
  543. pTemp = pTemp->pNext;
  544. }
  545. if (pTemp == NULL)
  546. {
  547. /* ERROR */
  548. /* printf("Didn't find our help dialog widget in the cache list??? /n");*/
  549. }
  550. XtPopdown (XtParent(helpDialog));
  551. pTemp->inUseFlag = FALSE;
  552. pSD->cachedHelp->hLink = False;
  553. /* Re-Assign our pTemp to point to our head so we can see
  554. * if we have any in-use help dialog in our list.
  555. */
  556. pTemp = pSD->cachedHelp;
  557. } /* END OF FUNCTION WmDtCloseHelpCB */
  558. /****************************************************************************
  559. * Function: WmDtWmCloseHelpCB(
  560. * Widget w,
  561. * caddr_t clientData,
  562. * caddr_t callData
  563. *
  564. * Parameters:
  565. *
  566. * Return Value: Void.
  567. *
  568. * Purpose: Process close requests on all Help Dialog widgets
  569. * created and managed by this application.
  570. *
  571. ***************************************************************************/
  572. static void WmDtWmCloseHelpCB (
  573. Widget w,
  574. XtPointer clientData,
  575. XtPointer callData)
  576. {
  577. WmScreenData *pSD;
  578. Widget helpDialog = (Widget) clientData;
  579. pSD = WmScreenDataFromWidget(w);
  580. HideHelpDialog (pSD, True);
  581. } /* END OF FUNCTION WmDtWmCloseHelpCB */
  582. /****************************************************************************
  583. * Function: WmDtWmPopupHelpCB(
  584. * Widget w,
  585. * caddr_t clientData,
  586. * caddr_t callData
  587. *
  588. * Parameters:
  589. *
  590. * Return Value: Void.
  591. *
  592. * Purpose: Process
  593. *
  594. *
  595. ***************************************************************************/
  596. static void WmDtWmPopupHelpCB (
  597. Widget w,
  598. XtPointer clientData,
  599. XtPointer callData)
  600. {
  601. PtrWsDtHelpData pHelp;
  602. WmScreenData *pSD;
  603. pSD = WmScreenDataFromWidget(w);
  604. pHelp = &pSD->dtHelp;
  605. if (pSD->dtHelp.restored)
  606. {
  607. /* set position of dialog to restored position */
  608. wmDtHelpSetPosition (pHelp, pSD, True);
  609. pSD->dtHelp.restored = False;
  610. }
  611. else
  612. {
  613. /* set position of dialog relative to client window */
  614. wmDtHelpSetPosition (pHelp, pSD, False);
  615. }
  616. } /* END OF FUNCTION WmDtWmPopupHelpCB */
  617. /****************************************************************************
  618. * Function: WmDtVersionPopupCB(
  619. * Widget w,
  620. * caddr_t clientData,
  621. * caddr_t callData
  622. *
  623. * Parameters:
  624. *
  625. * Return Value: Void.
  626. *
  627. * Purpose: Process
  628. *
  629. *
  630. ***************************************************************************/
  631. static void WmDtVersionPopupCB (
  632. Widget w,
  633. XtPointer clientData,
  634. XtPointer callData)
  635. {
  636. Arg setArgs[10];
  637. Arg getArgs[10];
  638. Dimension width, height;
  639. int x, y;
  640. int n;
  641. if (w)
  642. {
  643. /*
  644. * Center the Version Dialog on the screen
  645. */
  646. n = 0;
  647. XtSetArg(getArgs[n], XmNheight, &height); n++;
  648. XtSetArg(getArgs[n], XmNwidth, &width); n++;
  649. XtGetValues (w, (ArgList) getArgs, n);
  650. x = (DisplayWidth
  651. (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) width))/2;
  652. y = (DisplayHeight
  653. (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) height))/2;
  654. n = 0;
  655. XtSetArg(setArgs[n], XmNx, (XtArgVal) x); n++;
  656. XtSetArg(setArgs[n], XmNy, (XtArgVal) y); n++;
  657. XtSetValues (w, setArgs, n);
  658. }
  659. } /* END OF FUNCTION WmDtVersionPopupCB */
  660. /****************************************************************************
  661. * Function: WmDtPopupHelpCB(
  662. * Widget helpShellW,
  663. * caddr_t clientData,
  664. * caddr_t callData
  665. *
  666. * Parameters:
  667. *
  668. * Return Value: Void.
  669. *
  670. * Purpose: Process
  671. *
  672. *
  673. ***************************************************************************/
  674. static void WmDtPopupHelpCB (
  675. Widget helpShellW,
  676. XtPointer clientData,
  677. XtPointer callData)
  678. {
  679. char * ptr;
  680. Atom * workspace_atoms = NULL;
  681. int num_workspaces=0;
  682. CacheListStruct *pTemp = (CacheListStruct *)clientData;
  683. Arg args[10];
  684. int n;
  685. n = 0;
  686. XtSetArg (args[n], XmNgeometry, NULL); n++;
  687. XtSetArg (args[n], XmNwaitForWm, False); n++;
  688. if (pTemp)
  689. {
  690. if (pTemp->workspaces)
  691. {
  692. char **atom_names = NULL;
  693. do
  694. {
  695. ptr = DtStrchr (pTemp->workspaces, '*');
  696. if (ptr != NULL) *ptr = '\0';
  697. atom_names =
  698. (char **) XtRealloc ((char *)atom_names,
  699. sizeof(char*) * (num_workspaces + 1));
  700. atom_names[num_workspaces] = XtNewString(pTemp->workspaces);
  701. num_workspaces++;
  702. if (ptr != NULL)
  703. {
  704. *ptr = '*';
  705. pTemp->workspaces = ptr + 1;
  706. }
  707. } while (ptr != NULL);
  708. workspace_atoms = (Atom *) XtMalloc(sizeof(Atom) * num_workspaces);
  709. XInternAtoms(wmGD.display, atom_names, num_workspaces,
  710. True, workspace_atoms);
  711. DtWsmSetWorkspacesOccupied (XtDisplay(helpShellW),
  712. XtWindow (helpShellW),
  713. workspace_atoms,
  714. num_workspaces);
  715. while (num_workspaces-- > 0)
  716. XtFree(atom_names[num_workspaces]);
  717. XtFree ((char *) atom_names);
  718. XtFree ((char *) workspace_atoms);
  719. }
  720. XtSetArg (args[n], XmNx, pTemp->xPos); n++;
  721. XtSetArg (args[n], XmNy, pTemp->yPos); n++;
  722. pTemp->restored = False;
  723. XtRemoveCallback(helpShellW, XmNpopupCallback,
  724. WmDtPopupHelpCB, clientData);
  725. XtAddCallback(helpShellW, XmNpopupCallback, WmDtPopupHelpCB, NULL);
  726. }
  727. else
  728. {
  729. XtSetArg (args[n], XmNx, 0); n++;
  730. XtSetArg (args[n], XmNy, 0); n++;
  731. }
  732. XtSetValues (helpShellW, args, n);
  733. } /* END OF FUNCTION WmDtPopupHelpCB */
  734. /****************************************************************************
  735. * Function: WmDtVersionCloseCB(
  736. * Widget w,
  737. * caddr_t clientData,
  738. * caddr_t callData
  739. *
  740. * Parameters:
  741. *
  742. * Return Value: Void.
  743. *
  744. * Purpose: Process close requests on all Help Dialog widgets
  745. * created and managed by this application.
  746. *
  747. ***************************************************************************/
  748. static void WmDtVersionCloseCB (
  749. Widget w,
  750. XtPointer clientData,
  751. XtPointer callData)
  752. {
  753. XtUnmanageChild (w);
  754. } /* END OF FUNCTION WmDtWmVersionCloseHelpCB */
  755. /****************************************************************************
  756. * Function: void WmDtProcessLinkCB(
  757. * Widget w,
  758. * caddr_t clientData,
  759. * caddr_t callData
  760. *
  761. * Parameters:
  762. *
  763. * Return Value: Void.
  764. *
  765. * Purpose: Process JUMP-NEW and APP-LINK hypertext requests in a
  766. * given Help Dialog Window.
  767. *
  768. * This is the callback used for the DtNhyperLinkCallback
  769. * on each of the help dialog widges created.
  770. *
  771. ****************************************************************************/
  772. static void WmDtProcessLinkCB (
  773. Widget w,
  774. XtPointer clientData,
  775. XtPointer callData)
  776. {
  777. DtHelpDialogCallbackStruct * hyperData =
  778. (DtHelpDialogCallbackStruct *) callData;
  779. switch (hyperData->hyperType)
  780. {
  781. case DtHELP_LINK_JUMP_NEW:
  782. WmDtDisplayTopic (XtParent(w), hyperData->helpVolume,
  783. hyperData->locationId,
  784. /* DtHELP_LINK_JUMP_NEW */ DtHELP_TYPE_TOPIC,
  785. (Widget)NULL, False,
  786. NULL, 0, NULL, True, NULL);
  787. break;
  788. default: /* This catches the application definded link types */
  789. if (hyperData->hyperType >= 100)
  790. {
  791. /* The application would put any code here to handle their
  792. * Applicaiton-defined-links.
  793. */
  794. }
  795. else
  796. {
  797. /* ERROR */
  798. /* printf("We some how got a bogus hyptertext link type/n");*/
  799. }
  800. } /* End Switch Statement */
  801. } /* END OF FUNCTION WmDtProcessLinkCB */
  802. /****************************************************************************
  803. * Function: void WmDtHelpOnVersion(
  804. * Widget parent)
  805. *
  806. * Parameters:
  807. *
  808. * Return Value: Void.
  809. *
  810. * Purpose: Displays a new Cache Creek help topic in a new/cached
  811. * help dialog widget.
  812. *
  813. ****************************************************************************/
  814. void WmDtHelpOnVersion (
  815. Widget parent)
  816. {
  817. Arg setArgs[10];
  818. Arg setArgs2[5];
  819. int n, n2;
  820. Widget printButton = NULL;
  821. Widget helpButton = NULL;
  822. Widget backButton = NULL;
  823. Widget closeButton = NULL;
  824. #ifdef NO_MESSAGE_CATALOG
  825. XmString label = NULL;
  826. #endif
  827. if((versionWidget != NULL) &&
  828. (XtIsManaged(versionWidget)))
  829. {
  830. return ;
  831. }
  832. n = 0;
  833. if (!(versionWidget))
  834. {
  835. #ifndef NO_MESSAGE_CATALOG
  836. XtSetArg (setArgs[n], XmNtitle, wmNLS.defaultVersionTitle); n++;
  837. #else
  838. XtSetArg (setArgs[n], XmNtitle, "About Workspace Manager"); n++;
  839. #endif
  840. XtSetArg (setArgs[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  841. XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT"); n++;
  842. XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME); n++;
  843. versionWidget = DtCreateHelpQuickDialog (parent, "VersionDialog",
  844. setArgs, n);
  845. XtAddCallback(versionWidget, DtNcloseCallback,
  846. WmDtVersionCloseCB,
  847. (XtPointer) versionWidget);
  848. XtAddCallback(XtParent(versionWidget), XmNpopupCallback,
  849. WmDtVersionPopupCB, NULL);
  850. closeButton = DtHelpQuickDialogGetChild( versionWidget,
  851. DtHELP_QUICK_CLOSE_BUTTON );
  852. n2=0;
  853. #ifndef NO_MESSAGE_CATALOG
  854. XtSetArg (setArgs2[n2], DtNcloseLabelString, wmGD.okLabel); n2++;
  855. #else
  856. XtSetArg (setArgs2[n2], DtNcloseLabelString,
  857. label=XmStringCreateLocalized ("OK")); n2++;
  858. #endif
  859. XtSetValues(closeButton, setArgs2, n2);
  860. #ifdef NO_MESSAGE_CATALOG
  861. if(label)XmStringFree(label);
  862. #endif
  863. printButton = DtHelpQuickDialogGetChild( versionWidget,
  864. DtHELP_QUICK_PRINT_BUTTON );
  865. helpButton = DtHelpQuickDialogGetChild( versionWidget,
  866. DtHELP_QUICK_HELP_BUTTON );
  867. backButton = DtHelpQuickDialogGetChild( versionWidget,
  868. DtHELP_QUICK_BACK_BUTTON );
  869. XtUnmanageChild(printButton);
  870. XtUnmanageChild(helpButton);
  871. XtUnmanageChild(backButton);
  872. }
  873. else
  874. {
  875. XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT"); n++;
  876. XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME); n++;
  877. XtSetValues(versionWidget, setArgs, n);
  878. }
  879. XtManageChild(versionWidget);
  880. } /* END OF FUNCTION WmDtHelpOnVersion */
  881. /******************************<->*************************************
  882. *
  883. * Boolean WmDtHelp (String args)
  884. *
  885. * Description:
  886. * -----------
  887. * Invoke item help
  888. *
  889. * Inputs:
  890. * ------
  891. * args -
  892. *
  893. * Outputs:
  894. * -------
  895. * Return - True if the find a help callback; false otherwise.
  896. *
  897. * Comments:
  898. * --------
  899. *
  900. ******************************<->***********************************/
  901. Boolean
  902. WmDtHelp (String args)
  903. {
  904. WmScreenData *pSD;
  905. Widget theWidget;
  906. WmPanelistObject pPanelist;
  907. char *theHelpVolume = WM_DT_HELP_VOLUME;
  908. char *theHelpTopic = WM_DT_HELP_TOPIC;
  909. unsigned char volume[MAXWMPATH + 1];
  910. unsigned char topic[MAXWMPATH + 1];
  911. int argCount = 0;
  912. /* get right screen data */
  913. /* pSD = WmScreenDataFromWidget(w);*/
  914. pSD = wmGD.pActiveSD;
  915. pPanelist = (WmPanelistObject) pSD->wPanelist;
  916. if ((theWidget = O_Panel(pPanelist)))
  917. {
  918. if (args )
  919. {
  920. /*
  921. * parse args for volume and topic
  922. */
  923. WmDtGetHelpArgs(args, volume, topic, &argCount);
  924. if (argCount == 1)
  925. {
  926. WmDtDisplayTopic(pSD->screenTopLevelW1,
  927. theHelpVolume,
  928. (char *)topic,
  929. DtHELP_TYPE_TOPIC, theWidget, True,
  930. NULL, 0, NULL, False, NULL);
  931. }
  932. else
  933. {
  934. WmDtDisplayTopic(pSD->screenTopLevelW1,
  935. (char *)volume,
  936. (char *)topic,
  937. DtHELP_TYPE_TOPIC, theWidget, False,
  938. NULL, 0, NULL, False, NULL);
  939. }
  940. }
  941. else
  942. {
  943. WmDtDisplayTopic(pSD->screenTopLevelW1,
  944. theHelpVolume,
  945. theHelpTopic,
  946. DtHELP_TYPE_TOPIC, theWidget, True,
  947. NULL, 0, NULL, False, NULL);
  948. }
  949. return(True);
  950. }
  951. else
  952. {
  953. return (False);
  954. }
  955. } /* END OF FUNCTION WmDtHelp */
  956. /******************************<->*************************************
  957. *
  958. * Boolean WmDtHelpMode (void)
  959. *
  960. * Description:
  961. * -----------
  962. * Invoke item help mode
  963. *
  964. * Inputs:
  965. * ------
  966. * args -
  967. *
  968. * Outputs:
  969. * -------
  970. * Return - True if the find a help callback; false otherwise.
  971. *
  972. * Comments:
  973. * --------
  974. *
  975. ******************************<->***********************************/
  976. Boolean
  977. WmDtHelpMode (void)
  978. {
  979. Widget selectedWidget = NULL;
  980. int iStatus;
  981. String sTmp, sMessage, sTitle;
  982. iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, None,
  983. &selectedWidget);
  984. switch (iStatus)
  985. {
  986. case DtHELP_SELECT_VALID:
  987. if (selectedWidget != (Widget) NULL)
  988. {
  989. do
  990. {
  991. if ((XtHasCallbacks(selectedWidget,
  992. XmNhelpCallback) == XtCallbackHasSome))
  993. {
  994. XtCallCallbacks(selectedWidget, XmNhelpCallback,
  995. (XtPointer)NULL);
  996. return(True);
  997. }
  998. else
  999. {
  1000. selectedWidget = XtParent(selectedWidget);
  1001. }
  1002. }
  1003. while (selectedWidget != NULL);
  1004. }
  1005. break;
  1006. case DtHELP_SELECT_INVALID:
  1007. /* invalid selection error (window not of this process) */
  1008. #ifndef NO_MESSAGE_CATALOG
  1009. sTmp = (char *)GETMESSAGE(29, 3,
  1010. "You must select a Workspace Manager\n\
  1011. dialog, an item in the Front Panel,\n\
  1012. or an item in a subpanel.");
  1013. sMessage = XtNewString (sTmp);
  1014. sTmp = (char *)GETMESSAGE(29, 4,
  1015. "Workspace Manager - Help On Item Error");
  1016. sTitle = XtNewString (sTmp);
  1017. #else
  1018. sMessage = "You must select a Workspace Manager\n\
  1019. dialog, an item in the Front Panel,\n\
  1020. or an item in a subpanel.";
  1021. sTitle = "Workspace Manager - Help On Item Error";
  1022. #endif
  1023. wmDtErrorDialog (ACTIVE_PSD, sMessage, sTitle);
  1024. #ifndef NO_MESSAGE_CATALOG
  1025. if (sMessage) XtFree (sMessage);
  1026. if (sTitle) XtFree (sTitle);
  1027. #endif
  1028. break;
  1029. case DtHELP_SELECT_ERROR:
  1030. /* error (like grab failed) */
  1031. break;
  1032. case DtHELP_SELECT_ABORT:
  1033. /* user aborted this selection */
  1034. break;
  1035. } /* end switch */
  1036. return (False);
  1037. } /* END OF FUNCTION WmDtHelpMode */
  1038. /*****************************************************************************
  1039. * Function: WmDtReturnSelectedWidget (Widget, Cursor, Widget *)
  1040. *
  1041. * Parameters: Widget Specifies a valid widget within the app's
  1042. * widget hierarchy.
  1043. * Cursor Cursor to grab pointer with (use NULL!!)
  1044. * Widget * ptr to loc to receive returned widget
  1045. *
  1046. * Return Value: DtHELP_SELECT_ERROR - error in getting the widget
  1047. * DtHELP_SELECT_ABORT - user aborted
  1048. * DtHELP_SELECT_INVALID - user selected invalid window
  1049. * DtHELP_SELECT_VALID - valid widget returned
  1050. *
  1051. * Purpose: Allows developers to get the widget ID for any widget in their UI
  1052. * that the user has selected vai the pointer. This function will
  1053. * cause the cursor to change and allow a user to select an item in
  1054. * the UI.
  1055. *
  1056. *****************************************************************************/
  1057. static int
  1058. WmDtReturnSelectedWidget(
  1059. Widget theWidget,
  1060. Cursor cursor,
  1061. Widget *pWidget )
  1062. {
  1063. Display *dpy;
  1064. int screen;
  1065. int iStatus;
  1066. /* Setup some needed variables */
  1067. dpy = XtDisplay(theWidget);
  1068. screen = ACTIVE_SCREEN;
  1069. /* refresh the display */
  1070. XmUpdateDisplay(theWidget);
  1071. /* Change the curser to let the user select the desired widget */
  1072. iStatus = LocateTheControl(dpy, screen, pWidget);
  1073. return (iStatus);
  1074. } /* END OF FUNCTION WmDtReturnSelectedWidget */
  1075. /****************************************************************************
  1076. * Function: void WmDtDisplayTopic(
  1077. * Widget parent,
  1078. * char *helpVolume,
  1079. * char *locationId,
  1080. * Widget wmClient,
  1081. * Boolean wmHelp,
  1082. * ArgList argList,
  1083. * int argCount,
  1084. * ClientData *pCData,
  1085. * Boolean hyperlink,
  1086. * DisplayTopicInfo *displayTopicInfo)
  1087. *
  1088. * Parameters:
  1089. *
  1090. * Return Value: Void.
  1091. *
  1092. * Purpose: Displays a new Cache Creek help topic in a new/cached
  1093. * help dialog widget.
  1094. *
  1095. ****************************************************************************/
  1096. static void
  1097. WmDtDisplayTopic (
  1098. Widget parent,
  1099. char *helpVolume,
  1100. char *locationId,
  1101. int helpType,
  1102. Widget wmClient,
  1103. Boolean wmHelp ,
  1104. ArgList argList,
  1105. int argCount,
  1106. ClientData *pCData,
  1107. Boolean hyperLink,
  1108. DisplayTopicInfo *displayTopicInfo)
  1109. {
  1110. Arg setArgs[10];
  1111. Arg smallArgs[2];
  1112. ArgList argsNew;
  1113. int n;
  1114. int ac;
  1115. Widget helpWidget;
  1116. Widget shellWidget;
  1117. char * helpTitle;
  1118. WmPanelistObject pPanelist;
  1119. char * defaultTitle="Help";
  1120. ClientData *pCD = NULL;
  1121. WmScreenData *pSD = NULL;
  1122. CacheListStruct *pCurrentNode = NULL;
  1123. Boolean cachedNode = FALSE;
  1124. pSD = WmScreenDataFromWidget (parent);
  1125. pPanelist = (WmPanelistObject) pSD->wPanelist;
  1126. if (argCount)
  1127. {
  1128. /*argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount + 1)) ;*/
  1129. argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount)) ;
  1130. memcpy( argsNew, argList, (sizeof( Arg) * argCount)) ;
  1131. }
  1132. shellWidget = parent;
  1133. while (!(XtIsSubclass(shellWidget, shellWidgetClass)))
  1134. {
  1135. shellWidget = XtParent(shellWidget);
  1136. }
  1137. n = 0;
  1138. switch (helpType)
  1139. {
  1140. case DtHELP_TYPE_TOPIC:
  1141. if (helpVolume != NULL)
  1142. {
  1143. XtSetArg (setArgs[n],DtNhelpVolume,helpVolume); n++;
  1144. }
  1145. XtSetArg (setArgs[n], DtNlocationId,locationId); n++;
  1146. helpTitle=locationId;
  1147. break;
  1148. case DtHELP_TYPE_DYNAMIC_STRING:
  1149. XtSetArg (setArgs[n], DtNstringData, locationId); n++;
  1150. /* helpTitle=locationId;*/
  1151. helpTitle=defaultTitle;
  1152. break;
  1153. case DtHELP_TYPE_MAN_PAGE:
  1154. break;
  1155. case DtHELP_TYPE_FILE:
  1156. break;
  1157. default:
  1158. /* error condition, don't try to display help */
  1159. break;
  1160. }
  1161. if (n)
  1162. {
  1163. XtSetArg (setArgs[n], DtNhelpType, helpType); n++;
  1164. if (wmHelp)
  1165. {
  1166. if (pSD->dtHelp.shell)
  1167. {
  1168. helpWidget = pSD->dtHelp.dialog;
  1169. XtSetValues(helpWidget, setArgs, n);
  1170. }
  1171. else
  1172. {
  1173. #ifndef NO_MESSAGE_CATALOG
  1174. XtSetArg (setArgs[n], XmNtitle,
  1175. wmNLS.defaultDtwmHelpTitle); n++;
  1176. #else
  1177. XtSetArg (setArgs[n], XmNtitle,
  1178. "Workspace Manager - Help"); n++;
  1179. #endif
  1180. pSD->dtHelp.dialog =
  1181. DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
  1182. helpWidget = pSD->dtHelp.dialog;
  1183. pSD->dtHelp.shell = XtParent(helpWidget);
  1184. pSD->dtHelp.bMapped = False;
  1185. n = 0;
  1186. XtSetArg (setArgs[n], XmNname, "wmHelp"); n++;
  1187. if (argCount)
  1188. {
  1189. XtSetValues(pSD->dtHelp.shell,
  1190. argList, argCount);
  1191. }
  1192. XtAddCallback(helpWidget,
  1193. DtNhyperLinkCallback,
  1194. WmDtProcessLinkCB, NULL);
  1195. XtAddCallback(helpWidget, DtNcloseCallback,
  1196. WmDtWmCloseHelpCB,
  1197. (XtPointer) helpWidget);
  1198. XtAddCallback(pSD->dtHelp.shell, XmNpopupCallback,
  1199. WmDtWmPopupHelpCB, NULL);
  1200. XtAddEventHandler(pSD->dtHelp.shell,
  1201. StructureNotifyMask,
  1202. False,
  1203. wmDtHelpMapEventHandler,
  1204. (XtPointer) pSD);
  1205. }
  1206. if(pCData)
  1207. {
  1208. ShowHelpDialog(pCData);
  1209. }
  1210. else
  1211. {
  1212. if (wmClient)
  1213. {
  1214. XFindContext (DISPLAY, XtWindow(XtParent(wmClient)),
  1215. wmGD.windowContextType, (caddr_t *)&pCD);
  1216. }
  1217. else
  1218. {
  1219. XFindContext (DISPLAY, XtWindow(O_Shell(pPanelist)),
  1220. wmGD.windowContextType, (caddr_t *)&pCD);
  1221. }
  1222. ShowHelpDialog(pCD);
  1223. }
  1224. } /* if (wmHelp) */
  1225. else
  1226. {
  1227. /* Get a used or new node form our cache if we have one */
  1228. cachedNode = WmDtGetFromCache(&pCurrentNode, pSD);
  1229. /* If we got a free one from the Cache, use it */
  1230. /* Set Values on current free one, then map it */
  1231. if (cachedNode)
  1232. {
  1233. XtSetValues(pCurrentNode->helpDialog, setArgs, n);
  1234. }
  1235. else
  1236. {
  1237. #ifndef NO_MESSAGE_CATALOG
  1238. XtSetArg (setArgs[n], XmNtitle,
  1239. wmNLS.defaultHelpTitle); n++;
  1240. #else
  1241. XtSetArg (setArgs[n], XmNtitle,
  1242. "Workspace Manager - Help"); n++;
  1243. #endif
  1244. XtSetArg (setArgs[n], XmNgeometry, NULL); n++;
  1245. XtSetArg (setArgs[n], XmNx, 0); n++;
  1246. XtSetArg (setArgs[n], XmNy, 0); n++;
  1247. pCurrentNode->helpDialog =
  1248. DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
  1249. n = 0;
  1250. XtSetArg (setArgs[n], XmNname, "cachedHelp"); n++;
  1251. if (argCount)
  1252. {
  1253. XtSetValues(shellWidget, argList, argCount);
  1254. }
  1255. XtAddCallback(pCurrentNode->helpDialog,
  1256. DtNhyperLinkCallback,
  1257. WmDtProcessLinkCB, NULL);
  1258. XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
  1259. WmDtCloseHelpCB,
  1260. (XtPointer) pCurrentNode->helpDialog);
  1261. if (hyperLink)
  1262. {
  1263. pCurrentNode->hLink = True;
  1264. }
  1265. else
  1266. {
  1267. if (displayTopicInfo)
  1268. {
  1269. pCurrentNode->workspaces =
  1270. displayTopicInfo->workspaces;
  1271. pCurrentNode->xPos = displayTopicInfo->xPos;
  1272. pCurrentNode->yPos = displayTopicInfo->yPos;
  1273. pCurrentNode->restored = True;
  1274. XtAddCallback(XtParent(pCurrentNode->helpDialog),
  1275. XmNpopupCallback,
  1276. WmDtPopupHelpCB,
  1277. (XtPointer)pCurrentNode);
  1278. }
  1279. else
  1280. {
  1281. XtAddCallback(XtParent(pCurrentNode->helpDialog),
  1282. XmNpopupCallback,
  1283. WmDtPopupHelpCB, NULL);
  1284. }
  1285. }
  1286. }
  1287. helpWidget = pCurrentNode->helpDialog;
  1288. XtManageChild(helpWidget);
  1289. XtPopup(XtParent(helpWidget), XtGrabNone);
  1290. }
  1291. } /* if n is still 0, we did not find a useful help type */
  1292. } /* END OF FUNCTION WmDtDisplayTopic */
  1293. /****************************************************************************
  1294. * Function: static Boolean WmDtGetFromCache(
  1295. * CacheListStruct **pCurrentNode)
  1296. *
  1297. *
  1298. * Parameters:
  1299. *
  1300. * Return Value: Void.
  1301. *
  1302. * Purpose: Gets a free help node form our cache list. If none are
  1303. * free, it will return fallse and the calling routine will
  1304. * create a new help dialog widget.
  1305. *
  1306. ****************************************************************************/
  1307. static Boolean WmDtGetFromCache(
  1308. CacheListStruct **pCurrentNode,
  1309. WmScreenData *pSD)
  1310. {
  1311. CacheListStruct *pTemp;
  1312. if (pSD->cachedHelp == NULL)
  1313. {
  1314. /* We have a new list so lets create one and pass it back */
  1315. pSD->cachedHelp =
  1316. (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  1317. /* Assign the default values to our node */
  1318. pSD->cachedHelp->helpDialog = NULL;
  1319. pSD->cachedHelp->inUseFlag = TRUE;
  1320. pSD->cachedHelp->restored = False;
  1321. pSD->cachedHelp->hLink = False;
  1322. pSD->cachedHelp->pNext = NULL;
  1323. pSD->cachedHelp->pPrevious = NULL;
  1324. /* Return our head pointer because it's our first and only node */
  1325. *pCurrentNode = pSD->cachedHelp;
  1326. return (FALSE);
  1327. }
  1328. else
  1329. {
  1330. /* We have some nodes so search for a free one first */
  1331. pTemp = pSD->cachedHelp;
  1332. while (pTemp != NULL)
  1333. {
  1334. if (pTemp->inUseFlag == FALSE)
  1335. {
  1336. pTemp->inUseFlag = TRUE;
  1337. pTemp->hLink = False;
  1338. pTemp->restored = False;
  1339. *pCurrentNode = pTemp;
  1340. return (TRUE);
  1341. }
  1342. else
  1343. pTemp = pTemp->pNext;
  1344. }
  1345. /*
  1346. * If we did not find a free node then we must add a new one to the
  1347. * top of the list, and return it.
  1348. */
  1349. pTemp = (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  1350. /* Assign the default values to our node */
  1351. pTemp->helpDialog = NULL;
  1352. pTemp->inUseFlag = TRUE;
  1353. pTemp->restored = False;
  1354. pTemp->hLink = False;
  1355. pTemp->pNext = pSD->cachedHelp;
  1356. pTemp->pPrevious = NULL;
  1357. pSD->cachedHelp->pPrevious = pTemp;
  1358. /* Re-Assign our head pointer to point to the new head of the list */
  1359. pSD->cachedHelp = pTemp;
  1360. /* Return our head pointer because it's our new node */
  1361. *pCurrentNode = pSD->cachedHelp;
  1362. return (FALSE);
  1363. }
  1364. } /* END OF FUNCTION WmDtGetFromCache */
  1365. /* End of Dt utils */
  1366. /*************************************<->*************************************
  1367. *
  1368. * void
  1369. * RestoreHelpDialogs (pSD)
  1370. *
  1371. *
  1372. * Description:
  1373. * -----------
  1374. * Saves the state of the help system
  1375. *
  1376. * Inputs:
  1377. * ------
  1378. *
  1379. *
  1380. * Outputs:
  1381. * -------
  1382. * Return = none
  1383. *
  1384. *
  1385. * Comments:
  1386. * --------
  1387. *
  1388. ******************************<->***********************************/
  1389. Boolean
  1390. RestoreHelpDialogs(
  1391. WmScreenData *pSD)
  1392. {
  1393. XrmDatabase db;
  1394. XrmName xrm_name[5];
  1395. XrmRepresentation rep_type;
  1396. XrmValue value;
  1397. Position xLoc, yLoc;
  1398. short columns, rows;
  1399. int helpType;
  1400. char geometry[40];
  1401. int wsCnt;
  1402. int cCount;
  1403. int cachedCount=0;
  1404. char dialogName[18];
  1405. ClientData *pCD = NULL;
  1406. char *tTitle = NULL;
  1407. char *wsName = NULL;
  1408. char *wmClientName = NULL;
  1409. char *helpVolume = NULL;
  1410. char *locationId = NULL;
  1411. char *stringData = NULL;
  1412. char *workspaces = NULL;
  1413. Arg setArgs[20];
  1414. int ac;
  1415. WmPanelistObject pPanelist = (WmPanelistObject) pSD->wPanelist;
  1416. xLoc = 0;
  1417. yLoc = 0;
  1418. columns = 40;
  1419. rows = 15;
  1420. if (pSD->helpResources)
  1421. {
  1422. if ((db = XrmGetStringDatabase (pSD->helpResources)) == NULL)
  1423. {
  1424. return(False);
  1425. }
  1426. xrm_name [0] = XrmStringToQuark ("wsHelp");
  1427. xrm_name [1] = XrmStringToQuark ("onScreen");
  1428. xrm_name [2] = NULLQUARK;
  1429. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
  1430. {
  1431. /* Are we supposed to be mapped? */
  1432. if (strcmp(value.addr, "True") == 0)
  1433. {
  1434. ac = 0;
  1435. /* get x position */
  1436. xrm_name [1] = XrmStringToQuark ("x");
  1437. if (XrmQGetResource (db, xrm_name, xrm_name,
  1438. &rep_type, &value))
  1439. {
  1440. pSD->dtHelp.xPos = (Position)atoi((char *)value.addr);
  1441. pSD->dtHelp.restored = True;
  1442. }
  1443. /* get y position */
  1444. xrm_name [1] = XrmStringToQuark ("y");
  1445. if (XrmQGetResource (db, xrm_name, xrm_name,
  1446. &rep_type, &value))
  1447. {
  1448. pSD->dtHelp.yPos = (Position)atoi((char *)value.addr);
  1449. pSD->dtHelp.restored = True;
  1450. }
  1451. /* get columns */
  1452. xrm_name [1] = XrmStringToQuark ("columns");
  1453. if (XrmQGetResource (db, xrm_name, xrm_name,
  1454. &rep_type, &value))
  1455. {
  1456. XtSetArg (setArgs[ac], XmNcolumns,
  1457. (short)atoi((char *)value.addr)); ac++;
  1458. columns = (short)atoi((char *)value.addr);
  1459. }
  1460. /* get rows */
  1461. xrm_name [1] = XrmStringToQuark ("rows");
  1462. if (XrmQGetResource (db, xrm_name, xrm_name,
  1463. &rep_type, &value))
  1464. {
  1465. XtSetArg (setArgs[ac], XmNrows,
  1466. (short)atoi((char *)value.addr)); ac++;
  1467. rows = (short)atoi((char *)value.addr);
  1468. }
  1469. sprintf (geometry, "=+%d+%d", xLoc, yLoc);
  1470. XtSetArg (setArgs[ac], XmNgeometry,
  1471. XtNewString(geometry)); ac++;
  1472. /* get visiblePathCount */
  1473. xrm_name [1] = XrmStringToQuark ("vPCount");
  1474. if (XrmQGetResource (db, xrm_name, xrm_name,
  1475. &rep_type, &value))
  1476. {
  1477. XtSetArg (setArgs[ac], DtNvisiblePathCount,
  1478. (int)atoi((char *)value.addr)); ac++;
  1479. }
  1480. /* get topicTitle */
  1481. xrm_name [1] = XrmStringToQuark ("tTitle");
  1482. if (XrmQGetResource (db, xrm_name, xrm_name,
  1483. &rep_type, &value))
  1484. {
  1485. tTitle = XtNewString ((char *)value.addr);
  1486. XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
  1487. }
  1488. /* get help type */
  1489. xrm_name [1] = XrmStringToQuark ("helpType");
  1490. if (XrmQGetResource (db, xrm_name, xrm_name,
  1491. &rep_type, &value))
  1492. {
  1493. XtSetArg (setArgs[ac], DtNhelpType,
  1494. (int)atoi((char *)value.addr)); ac++;
  1495. helpType = (int)atoi((char *)value.addr);
  1496. }
  1497. switch (helpType)
  1498. {
  1499. case DtHELP_TYPE_TOPIC:
  1500. /* get helpVolume */
  1501. xrm_name [1] = XrmStringToQuark ("helpVolume");
  1502. if (XrmQGetResource (db, xrm_name, xrm_name,
  1503. &rep_type, &value))
  1504. {
  1505. helpVolume = XtNewString ((char *)value.addr);
  1506. /* XtSetArg (setArgs[ac], DtNhelpVolume,
  1507. helpVolume); ac++;*/
  1508. }
  1509. /* get locationId */
  1510. xrm_name [1] = XrmStringToQuark ("locationId");
  1511. if (XrmQGetResource (db, xrm_name, xrm_name,
  1512. &rep_type, &value))
  1513. {
  1514. locationId = XtNewString ((char *)value.addr);
  1515. /* XtSetArg (setArgs[ac], DtNlocationId,
  1516. locationId); ac++;*/
  1517. }
  1518. break;
  1519. case DtHELP_TYPE_DYNAMIC_STRING:
  1520. /* get stringData */
  1521. xrm_name [1] = XrmStringToQuark ("stringData");
  1522. if (XrmQGetResource (db, xrm_name, xrm_name,
  1523. &rep_type, &value))
  1524. {
  1525. stringData = XtNewString ((char *)value.addr);
  1526. /* XtSetArg (setArgs[ac], DtNstringData,
  1527. stringData); ac++;*/
  1528. locationId = stringData;
  1529. }
  1530. break;
  1531. case DtHELP_TYPE_MAN_PAGE:
  1532. break;
  1533. case DtHELP_TYPE_FILE:
  1534. break;
  1535. default:
  1536. /* error condition, don't try to display help */
  1537. break;
  1538. }
  1539. /* get name of wm client for which wmHelp is transient */
  1540. xrm_name [1] = XrmStringToQuark ("windowGroup");
  1541. if (XrmQGetResource (db, xrm_name, xrm_name,
  1542. &rep_type, &value))
  1543. {
  1544. wmClientName = ((char *)value.addr);
  1545. if ((!strcmp(wmClientName, pSD->iconBoxName)) &&
  1546. (pSD->useIconBox))
  1547. {
  1548. xrm_name [1] = XrmStringToQuark ("wsName");
  1549. if (XrmQGetResource (db, xrm_name, xrm_name,
  1550. &rep_type, &value))
  1551. {
  1552. wsName = (char *)value.addr;
  1553. for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
  1554. wsCnt++)
  1555. {
  1556. if (!strcmp(pSD->pWS[wsCnt].name, wsName))
  1557. {
  1558. pCD=pSD->pWS[wsCnt].pIconBox->pCD_iconBox;
  1559. break;
  1560. }
  1561. }
  1562. }
  1563. }
  1564. /*
  1565. else if(!strcmp(wmClientName, O_PanelName(pPanelist)))
  1566. {
  1567. pCD=O_ClientData(pPanelist);
  1568. }
  1569. */
  1570. }
  1571. /*
  1572. * Map the help dialog
  1573. */
  1574. WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
  1575. locationId,
  1576. helpType, NULL, True,
  1577. setArgs, ac, pCD, False, NULL);
  1578. }
  1579. }/* if (XrmQGetResource for wsHelp) */
  1580. xrm_name [0] = XrmStringToQuark ("cachedHelp");
  1581. xrm_name [1] = XrmStringToQuark ("cachedCount");
  1582. xrm_name [2] = NULLQUARK;
  1583. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
  1584. {
  1585. /* restore cachedCount number of help dialogs */
  1586. cachedCount = (int)atoi((char *)value.addr);
  1587. for (cCount=1; cCount < (cachedCount + 1); cCount++)
  1588. {
  1589. sprintf (dialogName, "oWsHelp%d", cCount);
  1590. xrm_name [0] = XrmStringToQuark (dialogName);
  1591. xrm_name [1] = NULLQUARK;
  1592. xrm_name [2] = NULLQUARK;
  1593. displayTopicInfo.xPos = 0;
  1594. displayTopicInfo.xPos = 0;
  1595. displayTopicInfo.workspaces = NULL;
  1596. ac = 0;
  1597. /* get x position */
  1598. xrm_name [1] = XrmStringToQuark ("x");
  1599. if (XrmQGetResource (db, xrm_name, xrm_name,
  1600. &rep_type, &value))
  1601. {
  1602. /* XtSetArg (setArgs[ac], XmNx,
  1603. atoi((char *)value.addr)); ac++;*/
  1604. xLoc = (Position)atoi((char *)value.addr);
  1605. displayTopicInfo.xPos = xLoc;
  1606. }
  1607. /* get y position */
  1608. xrm_name [1] = XrmStringToQuark ("y");
  1609. if (XrmQGetResource (db, xrm_name, xrm_name,
  1610. &rep_type, &value))
  1611. {
  1612. /* XtSetArg (setArgs[ac], XmNy,
  1613. atoi((char *)value.addr)); ac++;*/
  1614. yLoc = (Position)atoi((char *)value.addr);
  1615. displayTopicInfo.yPos = yLoc;
  1616. }
  1617. /* get columns */
  1618. xrm_name [1] = XrmStringToQuark ("columns");
  1619. if (XrmQGetResource (db, xrm_name, xrm_name,
  1620. &rep_type, &value))
  1621. {
  1622. XtSetArg (setArgs[ac], XmNcolumns,
  1623. (short)atoi((char *)value.addr)); ac++;
  1624. columns = (short)atoi((char *)value.addr);
  1625. }
  1626. /* get rows */
  1627. xrm_name [1] = XrmStringToQuark ("rows");
  1628. if (XrmQGetResource (db, xrm_name, xrm_name,
  1629. &rep_type, &value))
  1630. {
  1631. XtSetArg (setArgs[ac], XmNrows,
  1632. (short)atoi((char *)value.addr)); ac++;
  1633. rows = (short)atoi((char *)value.addr);
  1634. }
  1635. sprintf (geometry, "=+%d+%d", xLoc, yLoc);
  1636. XtSetArg (setArgs[ac], XmNgeometry,
  1637. XtNewString(geometry)); ac++;
  1638. /* get visiblePathCount */
  1639. xrm_name [1] = XrmStringToQuark ("vPCount");
  1640. if (XrmQGetResource (db, xrm_name, xrm_name,
  1641. &rep_type, &value))
  1642. {
  1643. XtSetArg (setArgs[ac], DtNvisiblePathCount,
  1644. (int)atoi((char *)value.addr)); ac++;
  1645. }
  1646. /* get topicTitle */
  1647. xrm_name [1] = XrmStringToQuark ("tTitle");
  1648. if (XrmQGetResource (db, xrm_name, xrm_name,
  1649. &rep_type, &value))
  1650. {
  1651. tTitle = XtNewString ((char *)value.addr);
  1652. XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
  1653. }
  1654. /* get workspaces list */
  1655. xrm_name [1] = XrmStringToQuark ("workspaces");
  1656. if (XrmQGetResource (db, xrm_name, xrm_name,
  1657. &rep_type, &value))
  1658. {
  1659. workspaces = XtNewString ((char *)value.addr);
  1660. displayTopicInfo.workspaces = workspaces;
  1661. }
  1662. /* get help type */
  1663. xrm_name [1] = XrmStringToQuark ("helpType");
  1664. if (XrmQGetResource (db, xrm_name, xrm_name,
  1665. &rep_type, &value))
  1666. {
  1667. XtSetArg (setArgs[ac], DtNhelpType,
  1668. (int)atoi((char *)value.addr)); ac++;
  1669. helpType = (int)atoi((char *)value.addr);
  1670. }
  1671. switch (helpType)
  1672. {
  1673. case DtHELP_TYPE_TOPIC:
  1674. /* get helpVolume */
  1675. xrm_name [1] = XrmStringToQuark ("helpVolume");
  1676. if (XrmQGetResource (db, xrm_name, xrm_name,
  1677. &rep_type, &value))
  1678. {
  1679. helpVolume = XtNewString ((char *)value.addr);
  1680. }
  1681. /* get locationId */
  1682. xrm_name [1] = XrmStringToQuark ("locationId");
  1683. if (XrmQGetResource (db, xrm_name, xrm_name,
  1684. &rep_type, &value))
  1685. {
  1686. locationId = XtNewString ((char *)value.addr);
  1687. }
  1688. break;
  1689. case DtHELP_TYPE_DYNAMIC_STRING:
  1690. /* get stringData */
  1691. xrm_name [1] = XrmStringToQuark ("stringData");
  1692. if (XrmQGetResource (db, xrm_name, xrm_name,
  1693. &rep_type, &value))
  1694. {
  1695. stringData = XtNewString ((char *)value.addr);
  1696. /* XtSetArg (setArgs[ac], DtNstringData,
  1697. stringData); ac++;*/
  1698. locationId = stringData;
  1699. }
  1700. break;
  1701. case DtHELP_TYPE_MAN_PAGE:
  1702. break;
  1703. case DtHELP_TYPE_FILE:
  1704. break;
  1705. default:
  1706. /* error condition, don't try to display help */
  1707. break;
  1708. } /* switch */
  1709. WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume,
  1710. locationId,
  1711. helpType, NULL, False,
  1712. setArgs, ac, NULL, False,
  1713. &displayTopicInfo);
  1714. } /* for all cached help dialogs */
  1715. } /* if (XrmQGetResource ) cachedHelp/cachedCount */
  1716. XrmDestroyDatabase(db);
  1717. }
  1718. return True;
  1719. } /* END OF FUNCTION RestoreHelpDialogs */
  1720. /*************************************<->*************************************
  1721. *
  1722. * void
  1723. * SaveHelpResources (pSD)
  1724. *
  1725. *
  1726. * Description:
  1727. * -----------
  1728. * Saves the state of the help system
  1729. *
  1730. * Inputs:
  1731. * ------
  1732. *
  1733. *
  1734. * Outputs:
  1735. * -------
  1736. * Return = none
  1737. *
  1738. *
  1739. * Comments:
  1740. * --------
  1741. *
  1742. ******************************<->***********************************/
  1743. void
  1744. SaveHelpResources(
  1745. WmScreenData *pSD)
  1746. {
  1747. PtrWsDtHelpData pHelp;
  1748. CacheListStruct *pTemp;
  1749. Arg getArgs[20];
  1750. int ac;
  1751. Window wmGroupWindow;
  1752. ClientData *pCD;
  1753. ClientData *pCDforHelp;
  1754. int wsCnt;
  1755. int thisCnt;
  1756. WorkspaceID wsID;
  1757. WmWorkspaceData *pWS;
  1758. Position xLoc, yLoc;
  1759. short columns, rows;
  1760. unsigned char helpType;
  1761. int vPCount;
  1762. char *helpVolume;
  1763. char *locationId;
  1764. char *stringData;
  1765. char *topicTitle;
  1766. char *wsName;
  1767. char workspaces[MAXWMPATH+1];
  1768. char buffer[MAXWMPATH+1];
  1769. char *res_class;
  1770. char *data;
  1771. int cum_len;
  1772. char screenName[10];
  1773. char dialogName[128];
  1774. char resString[MAXWMPATH+1];
  1775. int cachedCount=0;
  1776. pHelp = &pSD->dtHelp;
  1777. /* allocate initial data space */
  1778. if ((data = (char *) XtMalloc (MAXWMPATH+1)) == NULL)
  1779. {
  1780. Warning (((char *)
  1781. GETMESSAGE(76,12,"Insufficient memory to save resources")));
  1782. Do_Quit_Mwm (False);
  1783. }
  1784. cum_len = 1;
  1785. *data = '\0';
  1786. /* Get our current resource class */
  1787. if (MwmBehavior)
  1788. {
  1789. res_class = WM_RESOURCE_CLASS;
  1790. }
  1791. else
  1792. {
  1793. res_class = DT_WM_RESOURCE_CLASS;
  1794. }
  1795. sprintf (screenName, "%d", pSD->screen);
  1796. sprintf (buffer, "%s*%s*%s: \\n ", res_class, screenName,
  1797. WmNhelpResources);
  1798. AddStringToResourceData (buffer, &data, &cum_len);
  1799. if (pHelp->onScreen)
  1800. {
  1801. sprintf (dialogName, "wsHelp");
  1802. sprintf (buffer, "%s*onScreen: True\\n ", dialogName);
  1803. AddStringToResourceData (buffer, &data, &cum_len);
  1804. ac = 0;
  1805. XtSetArg(getArgs[ac], XmNx, &xLoc); ac++;
  1806. XtSetArg(getArgs[ac], XmNy, &yLoc); ac++;
  1807. XtGetValues(pSD->dtHelp.shell, getArgs, ac);
  1808. if (!XFindContext (DISPLAY, XtWindow(pSD->dtHelp.shell),
  1809. wmGD.windowContextType, (caddr_t *)&pCDforHelp))
  1810. {
  1811. if (wmGD.positionIsFrame)
  1812. {
  1813. xLoc = xLoc - pCDforHelp->clientOffset.x;
  1814. yLoc = yLoc - pCDforHelp->clientOffset.y;
  1815. }
  1816. }
  1817. ac = 0;
  1818. XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
  1819. XtSetArg(getArgs[ac], XmNrows, &rows); ac++;
  1820. XtSetArg(getArgs[ac], DtNhelpType, &helpType); ac++;
  1821. XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount); ac++;
  1822. XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle); ac++;
  1823. XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
  1824. sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
  1825. AddStringToResourceData (buffer, &data, &cum_len);
  1826. sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
  1827. AddStringToResourceData (buffer, &data, &cum_len);
  1828. sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
  1829. AddStringToResourceData (buffer, &data, &cum_len);
  1830. sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
  1831. AddStringToResourceData (buffer, &data, &cum_len);
  1832. sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
  1833. AddStringToResourceData (buffer, &data, &cum_len);
  1834. sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
  1835. AddStringToResourceData (buffer, &data, &cum_len);
  1836. sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
  1837. AddStringToResourceData (buffer, &data, &cum_len);
  1838. ac = 0;
  1839. switch (helpType)
  1840. {
  1841. case DtHELP_TYPE_TOPIC:
  1842. XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++;
  1843. XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
  1844. XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
  1845. sprintf (buffer, "%s*helpVolume: %s\\n ", dialogName, helpVolume);
  1846. AddStringToResourceData (buffer, &data, &cum_len);
  1847. sprintf (buffer, "%s*locationId: %s\\n ", dialogName, locationId);
  1848. AddStringToResourceData (buffer, &data, &cum_len);
  1849. break;
  1850. case DtHELP_TYPE_DYNAMIC_STRING:
  1851. XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
  1852. XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
  1853. sprintf (buffer, "%s*stringData: %s\\n ", dialogName, stringData);
  1854. AddStringToResourceData (buffer, &data, &cum_len);
  1855. break;
  1856. case DtHELP_TYPE_MAN_PAGE:
  1857. break;
  1858. case DtHELP_TYPE_FILE:
  1859. break;
  1860. default:
  1861. /* error condition, don't try to display help */
  1862. break;
  1863. }
  1864. ac = 0;
  1865. XtSetArg(getArgs[ac], XmNwindowGroup, &wmGroupWindow); ac++;
  1866. XtGetValues(pSD->dtHelp.shell, getArgs, ac);
  1867. if (!XFindContext (DISPLAY, wmGroupWindow,
  1868. wmGD.windowContextType, (caddr_t *)&pCD))
  1869. {
  1870. sprintf (buffer, "%s*windowGroup: %s\\n ", dialogName,
  1871. pCD->clientName);
  1872. AddStringToResourceData (buffer, &data, &cum_len);
  1873. if ((!strcmp(pCD->clientName, pSD->iconBoxName)) &&
  1874. (pSD->useIconBox))
  1875. {
  1876. wsName = XGetAtomName(DISPLAY,
  1877. pCD->pWsList[pCD->currentWsc].wsID);
  1878. sprintf (buffer, "%s*wsName: %s\\n ", dialogName,
  1879. wsName);
  1880. AddStringToResourceData (buffer, &data, &cum_len);
  1881. XFree(wsName);
  1882. }
  1883. }
  1884. }
  1885. if (pSD->cachedHelp != NULL)
  1886. {
  1887. /*
  1888. * We have some nodes so search for
  1889. * managed dialogs and save their state
  1890. */
  1891. pTemp = pSD->cachedHelp;
  1892. while (pTemp != NULL)
  1893. {
  1894. if (pTemp->inUseFlag == FALSE)
  1895. {
  1896. pTemp = pTemp->pNext;
  1897. }
  1898. else
  1899. {
  1900. cachedCount++;
  1901. sprintf (dialogName, "oWsHelp%d",cachedCount);
  1902. ac = 0;
  1903. XtSetArg(getArgs[ac], XmNx, &xLoc); ac++;
  1904. XtSetArg(getArgs[ac], XmNy, &yLoc); ac++;
  1905. XtGetValues(XtParent(pTemp->helpDialog), getArgs, ac);
  1906. if (!XFindContext (DISPLAY,
  1907. XtWindow(XtParent(pTemp->helpDialog)),
  1908. wmGD.windowContextType,
  1909. (caddr_t *)&pCDforHelp))
  1910. {
  1911. if (wmGD.positionIsFrame)
  1912. {
  1913. xLoc = xLoc - pCDforHelp->clientOffset.x;
  1914. yLoc = yLoc - pCDforHelp->clientOffset.y;
  1915. }
  1916. }
  1917. else
  1918. {
  1919. pCDforHelp = NULL;
  1920. }
  1921. ac = 0;
  1922. XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
  1923. XtSetArg(getArgs[ac], XmNrows, &rows); ac++;
  1924. XtSetArg(getArgs[ac], DtNhelpType, &helpType); ac++;
  1925. XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount); ac++;
  1926. XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle); ac++;
  1927. XtGetValues(pTemp->helpDialog, getArgs, ac);
  1928. sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
  1929. AddStringToResourceData (buffer, &data, &cum_len);
  1930. sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
  1931. AddStringToResourceData (buffer, &data, &cum_len);
  1932. sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
  1933. AddStringToResourceData (buffer, &data, &cum_len);
  1934. sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
  1935. AddStringToResourceData (buffer, &data, &cum_len);
  1936. sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
  1937. AddStringToResourceData (buffer, &data, &cum_len);
  1938. sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
  1939. AddStringToResourceData (buffer, &data, &cum_len);
  1940. sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
  1941. AddStringToResourceData (buffer, &data, &cum_len);
  1942. ac = 0;
  1943. switch (helpType)
  1944. {
  1945. case DtHELP_TYPE_TOPIC:
  1946. XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++;
  1947. XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
  1948. XtGetValues(pTemp->helpDialog, getArgs, ac);
  1949. sprintf (buffer, "%s*helpVolume: %s\\n ",
  1950. dialogName, helpVolume);
  1951. AddStringToResourceData (buffer, &data, &cum_len);
  1952. sprintf (buffer, "%s*locationId: %s\\n ",
  1953. dialogName, locationId);
  1954. AddStringToResourceData (buffer, &data, &cum_len);
  1955. break;
  1956. case DtHELP_TYPE_DYNAMIC_STRING:
  1957. XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
  1958. XtGetValues(pTemp->helpDialog, getArgs, ac);
  1959. sprintf (buffer, "%s*stringData: %s\\n ",
  1960. dialogName, stringData);
  1961. AddStringToResourceData (buffer, &data, &cum_len);
  1962. break;
  1963. case DtHELP_TYPE_MAN_PAGE:
  1964. break;
  1965. case DtHELP_TYPE_FILE:
  1966. break;
  1967. default:
  1968. /* error condition, don't try to display help */
  1969. break;
  1970. }
  1971. if (pCDforHelp)
  1972. {
  1973. thisCnt = 0;
  1974. sprintf(workspaces, "%s", "");
  1975. for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
  1976. wsCnt++)
  1977. {
  1978. wsID = XInternAtom (DISPLAY, pSD->pWS[wsCnt].name,
  1979. False);
  1980. pWS = GetWorkspaceData (pSD, wsID);
  1981. if (ClientInWorkspace (pWS, pCDforHelp))
  1982. {
  1983. if (thisCnt == 0)
  1984. {
  1985. strcpy(workspaces, pSD->pWS[wsCnt].name);
  1986. }
  1987. else
  1988. {
  1989. strcat(workspaces, "*");
  1990. strcat(workspaces, pSD->pWS[wsCnt].name);
  1991. }
  1992. thisCnt++;
  1993. }
  1994. }
  1995. sprintf (buffer, "%s*workspaces: %s\\n ", dialogName,
  1996. workspaces);
  1997. AddStringToResourceData (buffer, &data, &cum_len);
  1998. }
  1999. pTemp = pTemp->pNext;
  2000. }
  2001. } /* While */
  2002. if (cachedCount)
  2003. {
  2004. sprintf (buffer, "cachedHelp*cachedCount: %d\\n ", cachedCount);
  2005. AddStringToResourceData (buffer, &data, &cum_len);
  2006. }
  2007. }
  2008. if (data)
  2009. {
  2010. /*
  2011. * Save help resources as a string
  2012. */
  2013. sprintf (buffer, " \n");
  2014. AddStringToResourceData (buffer, &data, &cum_len);
  2015. _DtAddToResource (DISPLAY, data);
  2016. XtFree(data);
  2017. }
  2018. } /* END OF FUNCTION SaveHelpResources */
  2019. /* Code stolen from WmPresence.c */
  2020. /*************************************<->*************************************
  2021. *
  2022. * void
  2023. * ShowHelpDialog (pClient)
  2024. *
  2025. *
  2026. * Description:
  2027. * -----------
  2028. * Pops up (shows) the help dialog
  2029. *
  2030. * Inputs:
  2031. * ------
  2032. *
  2033. *
  2034. * Outputs:
  2035. * -------
  2036. * Return = none
  2037. *
  2038. *
  2039. * Comments:
  2040. * --------
  2041. *
  2042. ******************************<->***********************************/
  2043. static void
  2044. ShowHelpDialog(
  2045. ClientData *pClient)
  2046. {
  2047. PtrWsDtHelpData pHelp;
  2048. WmScreenData *pSD;
  2049. ClientData *pOldCD;
  2050. if (!(pClient))
  2051. {
  2052. pSD=wmGD.pActiveSD;
  2053. }
  2054. else
  2055. {
  2056. pSD = pClient->pSD;
  2057. }
  2058. pHelp = &pSD->dtHelp;
  2059. pOldCD = pHelp->pCDforClient;
  2060. pHelp->pCDforClient = pClient;
  2061. /* pHelp->contextForClient = wsContext;*/
  2062. if (pSD->dtHelp.onScreen)
  2063. {
  2064. ClientData *pCD = NULL;
  2065. XFindContext (DISPLAY, XtWindow (pSD->dtHelp.shell),
  2066. wmGD.windowContextType, (XtPointer) &pCD);
  2067. if ((!pSD->dtHelp.bMapped) ||
  2068. (pCD &&
  2069. (!ClientInWorkspace (ACTIVE_WS, pCD) ||
  2070. (pCD->clientState == MINIMIZED_STATE) ||
  2071. (pOldCD && pOldCD != pHelp->pCDforClient))))
  2072. {
  2073. HideHelpDialog (pSD, True);
  2074. }
  2075. }
  2076. /*
  2077. * pop it up
  2078. */
  2079. XtManageChild(pSD->dtHelp.dialog);
  2080. XtPopup (pSD->dtHelp.shell, XtGrabNone);
  2081. pSD->dtHelp.onScreen = True;
  2082. } /* END OF FUNCTION ShowHelpDialog */
  2083. /*************************************<->*************************************
  2084. *
  2085. * void
  2086. * HideHelpDialog (pSD, userDismissed)
  2087. *
  2088. *
  2089. * Description:
  2090. * -----------
  2091. * Pops down (hides) the workspace presence dialog
  2092. *
  2093. * Inputs:
  2094. * ------
  2095. * pSD = pointer to screen data
  2096. * userDismissed = did the user dismiss or did workspace switching
  2097. * unpost the workspace presence box ?
  2098. *
  2099. * Outputs:
  2100. * -------
  2101. * Return = none
  2102. *
  2103. *
  2104. * Comments:
  2105. * --------
  2106. *
  2107. ******************************<->***********************************/
  2108. static void
  2109. HideHelpDialog(
  2110. WmScreenData *pSD,
  2111. Boolean userDismissed )
  2112. {
  2113. if (pSD->dtHelp.onScreen)
  2114. {
  2115. /* Pop down the shell */
  2116. XtPopdown (pSD->dtHelp.shell);
  2117. /*
  2118. * Do a withdraw to make sure window gets unmanaged
  2119. * (popdown does nothing if its unmapped)
  2120. */
  2121. XWithdrawWindow (DISPLAY, XtWindow (pSD->dtHelp.shell),
  2122. pSD->screen);
  2123. /* must sync to insure event order */
  2124. XSync (DISPLAY, False);
  2125. pSD->dtHelp.onScreen = False;
  2126. pSD->dtHelp.userDismissed = userDismissed;
  2127. }
  2128. } /* END OF FUNCTION HideHelpDialog */
  2129. /*************************************<->*************************************
  2130. *
  2131. * wmDtHelpSetPosition (pHelp, pSD, restorePos)
  2132. *
  2133. *
  2134. * Description:
  2135. * -----------
  2136. * Sets the position of the workspace presence dialog
  2137. *
  2138. * Inputs:
  2139. * ------
  2140. * pPres = pointer to workspace presence data
  2141. *
  2142. * Outputs:
  2143. * --------
  2144. *
  2145. ******************************<->***********************************/
  2146. static void
  2147. wmDtHelpSetPosition(
  2148. PtrWsDtHelpData pHelp,
  2149. WmScreenData *pSD,
  2150. Boolean restorePos)
  2151. {
  2152. Arg args[10];
  2153. int n;
  2154. XFontStruct *font;
  2155. Dimension height;
  2156. Window wGroup = None;
  2157. int x, y;
  2158. ClientData *pCDforHelp;
  2159. if (!restorePos)
  2160. {
  2161. /*
  2162. * Get size of this dialog
  2163. */
  2164. n = 0;
  2165. XtSetArg (args[n], XmNheight, &height); n++;
  2166. XtGetValues (pHelp->shell, args, n);
  2167. if (wmGD.positionIsFrame)
  2168. {
  2169. if (pSD->decoupleTitleAppearance)
  2170. {
  2171. font = pSD->clientTitleAppearance.font;
  2172. }
  2173. else
  2174. {
  2175. font = pSD->clientAppearance.font;
  2176. }
  2177. /* height += TEXT_HEIGHT(font) + (2 * pSD->frameBorderWidth);*/
  2178. height += TEXT_HEIGHT(font) + (2 * pSD->resizeBorderWidth);
  2179. }
  2180. /*
  2181. * set position of dialog relative to client window
  2182. * (use system menu position)
  2183. * set this dialog to be transient for the client
  2184. * for which it is posted.
  2185. */
  2186. if (pHelp->pCDforClient)
  2187. {
  2188. GetSystemMenuPosition (pHelp->pCDforClient,
  2189. &x, &y, height,
  2190. (Context)0);
  2191. }
  2192. else
  2193. {
  2194. /*
  2195. * Don't have a client so map at 0,0
  2196. */
  2197. x = 0;
  2198. y = 0;
  2199. }
  2200. }
  2201. else
  2202. {
  2203. x = pHelp->xPos;
  2204. y = pHelp->yPos;
  2205. }
  2206. n = 0;
  2207. XtSetArg (args[n], XmNgeometry, NULL); n++;
  2208. XtSetArg (args[n], XmNx, x); n++;
  2209. XtSetArg (args[n], XmNy, y); n++;
  2210. XtSetArg (args[n], XmNtransientFor, NULL); n++;
  2211. if (pHelp->pCDforClient)
  2212. {
  2213. int ac;
  2214. Arg al[5];
  2215. ac = 0;
  2216. XtSetArg (al[ac], XmNwindowGroup, &wGroup); ac++;
  2217. XtGetValues (pHelp->shell, al, ac);
  2218. if (wGroup != pHelp->pCDforClient->client)
  2219. {
  2220. /*
  2221. * Changing who this is transient for, need to
  2222. * make sure the window is unmapped so that the
  2223. * window manager moves it to the right place.
  2224. */
  2225. HideHelpDialog (pSD, True);
  2226. }
  2227. XtSetArg (args[n], XmNwindowGroup, pHelp->pCDforClient->client); n++;
  2228. }
  2229. else
  2230. {
  2231. if (wGroup != None)
  2232. {
  2233. HideHelpDialog (pSD, True);
  2234. }
  2235. XtSetArg (args[n], XmNwindowGroup, 0); n++;
  2236. }
  2237. XtSetArg (args[n], XmNwaitForWm, False); n++;
  2238. XtSetValues (pHelp->shell, args, n);
  2239. } /* END OF FUNCTION wmDtHelpSetPosition */
  2240. /* End of Code stolen from WmPresence.c */
  2241. /*************************************<->*************************************
  2242. *
  2243. * wmDtHelpMapEventHandler (wHelp, pSD, pEvent)
  2244. *
  2245. *
  2246. * Description:
  2247. * -----------
  2248. * An XtEventHandler called on structure notify events on the screen's
  2249. * help window. (Only handles map and unmap events)
  2250. *
  2251. * Inputs:
  2252. * ------
  2253. * wHelp = help widget
  2254. * pSD = ptr to screen data
  2255. * pEvent = event triggering this call
  2256. *
  2257. * Outputs:
  2258. * --------
  2259. *
  2260. ******************************<->***********************************/
  2261. static void
  2262. wmDtHelpMapEventHandler(
  2263. Widget wHelp,
  2264. XtPointer ptr,
  2265. XEvent *pEvent,
  2266. Boolean *pBoolean) /* unused */
  2267. {
  2268. WmScreenData *pSD = (WmScreenData *) ptr;
  2269. switch (pEvent->type)
  2270. {
  2271. case MapNotify:
  2272. pSD->dtHelp.bMapped = True;
  2273. break;
  2274. case UnmapNotify:
  2275. pSD->dtHelp.bMapped = False;
  2276. break;
  2277. }
  2278. }
  2279. /* END OF FUNCTION wmDtHelpMapHandler */
  2280. /*************************************<->*************************************
  2281. *
  2282. * wmDtErrorDialog (pSD, message, title)
  2283. *
  2284. *
  2285. * Description:
  2286. * -----------
  2287. * Called to show an error message
  2288. *
  2289. * Inputs:
  2290. * ------
  2291. * pSD = ptr to screen data
  2292. * message = error message to display
  2293. * title = title for the error dialog
  2294. *
  2295. * Outputs:
  2296. * --------
  2297. *
  2298. ******************************<->***********************************/
  2299. static void
  2300. wmDtErrorDialog(
  2301. WmScreenData *pSD,
  2302. String sMessage,
  2303. String sTitle
  2304. )
  2305. {
  2306. int ac;
  2307. Arg al[20];
  2308. XmString xmsMessage;
  2309. XmString xmsTitle;
  2310. Widget wTemp;
  2311. Widget wParent;
  2312. Widget wShell;
  2313. Window wRoot, wChild;
  2314. int rootX, rootY, winX, winY;
  2315. unsigned int mask;
  2316. Dimension dWidth, dHeight;
  2317. Position x, y;
  2318. WmPanelistObject pPanelist;
  2319. xmsMessage =
  2320. XmStringCreateLocalized (sMessage);
  2321. xmsTitle =
  2322. XmStringCreateLocalized (sTitle);
  2323. if (pSD->dtHelp.errorDialog == NULL)
  2324. {
  2325. #ifdef NO_MESSAGE_CATALOG
  2326. XmString tmpXmString = (XmString)NULL;
  2327. #endif
  2328. ac = 0;
  2329. XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++;
  2330. XtSetArg (al[ac], XmNdialogTitle, xmsTitle); ac++;
  2331. #ifndef NO_MESSAGE_CATALOG
  2332. XtSetArg (al[ac], XmNokLabelString, wmGD.okLabel); ac++;
  2333. #else
  2334. tmpXmString = XmStringCreateLocalized ("OK");
  2335. XtSetArg (al[ac], XmNokLabelString, tmpXmString); ac++;
  2336. #endif
  2337. #if 0
  2338. if ((wmGD.dtSD == pSD) && pSD->wPanelist)
  2339. {
  2340. pPanelist = (WmPanelistObject) pSD->wPanelist;
  2341. wParent = O_Shell (pPanelist);
  2342. }
  2343. else
  2344. {
  2345. wParent = pSD->screenTopLevelW1;
  2346. }
  2347. #else
  2348. wParent = pSD->screenTopLevelW1;
  2349. #endif
  2350. pSD->dtHelp.errorDialog =
  2351. XmCreateErrorDialog (wParent, "Error Dialog", al, ac);
  2352. #ifdef NO_MESSAGE_CATALOG
  2353. if (tmpXmString)
  2354. XmStringFree(tmpXmString);
  2355. #endif
  2356. wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog,
  2357. XmDIALOG_HELP_BUTTON);
  2358. XtUnmanageChild (wTemp);
  2359. wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog,
  2360. XmDIALOG_CANCEL_BUTTON);
  2361. XtUnmanageChild (wTemp);
  2362. XtAddCallback (pSD->dtHelp.errorDialog, XmNokCallback,
  2363. wmDtErrorDialogOkCB, (XtPointer)pSD);
  2364. wShell = pSD->dtHelp.errorDialog;
  2365. while (!(XtIsSubclass(wShell, shellWidgetClass)))
  2366. {
  2367. wShell = XtParent(wShell);
  2368. }
  2369. XtAddCallback(wShell, XmNpopupCallback, wmDtErrorDialogPopupCB,
  2370. (XtPointer)pSD);
  2371. XtRealizeWidget (pSD->dtHelp.errorDialog);
  2372. /* remove some WM functions */
  2373. ac = 0;
  2374. XtSetArg (al[ac], XmNmwmFunctions, (MWM_FUNC_ALL|
  2375. MWM_FUNC_RESIZE|MWM_FUNC_MINIMIZE|MWM_FUNC_MAXIMIZE));
  2376. ac++;
  2377. XtSetValues (wShell, al, ac);
  2378. DtWsmRemoveWorkspaceFunctions (DISPLAY, XtWindow(wShell));
  2379. }
  2380. else
  2381. {
  2382. /* make sure it's unmanaged */
  2383. wmDtErrorDialogHide (pSD);
  2384. /* set new message and title */
  2385. ac = 0;
  2386. XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++;
  2387. XtSetArg (al[ac], XmNdialogTitle, xmsTitle); ac++;
  2388. XtSetValues (pSD->dtHelp.errorDialog, al, ac);
  2389. }
  2390. if (pSD->dtHelp.errorDialog)
  2391. {
  2392. XtManageChild (pSD->dtHelp.errorDialog);
  2393. XtPopup (XtParent(pSD->dtHelp.errorDialog), XtGrabNone);
  2394. }
  2395. XmStringFree (xmsMessage);
  2396. XmStringFree (xmsTitle);
  2397. }
  2398. /* END OF FUNCTION wmDtErrorDialog */
  2399. /*************************************<->*************************************
  2400. *
  2401. * void
  2402. * wmDtErrorDialogHide (pSD)
  2403. *
  2404. *
  2405. * Description:
  2406. * -----------
  2407. *
  2408. *
  2409. * Inputs:
  2410. * ------
  2411. * pSD = ptr to screen data
  2412. *
  2413. *
  2414. * Outputs:
  2415. * -------
  2416. * Return = ...
  2417. *
  2418. *
  2419. * Comments:
  2420. * --------
  2421. *
  2422. *************************************<->***********************************/
  2423. static void
  2424. wmDtErrorDialogHide( WmScreenData *pSD )
  2425. {
  2426. Widget wShell;
  2427. XtPopdown (XtParent(pSD->dtHelp.errorDialog));
  2428. XtUnmanageChild (pSD->dtHelp.errorDialog);
  2429. /*
  2430. * Do a withdraw to make sure window gets unmanaged
  2431. * (popdown does nothing if its unmapped)
  2432. */
  2433. wShell = pSD->dtHelp.errorDialog;
  2434. while (!(XtIsSubclass(wShell, shellWidgetClass)))
  2435. {
  2436. wShell = XtParent(wShell);
  2437. }
  2438. if (wShell)
  2439. XWithdrawWindow (DISPLAY, XtWindow (wShell), pSD->screen);
  2440. /* must sync to insure event order */
  2441. XSync (DISPLAY, False);
  2442. } /* END OF FUNCTION wmDtErrorDialogHide */
  2443. /*************************************<->*************************************
  2444. *
  2445. * void
  2446. * wmDtErrorDialogOkCB (w, client_data, call_data)
  2447. *
  2448. *
  2449. * Description:
  2450. * -----------
  2451. *
  2452. *
  2453. * Inputs:
  2454. * ------
  2455. * w = ...
  2456. * client_data = ...
  2457. * call_data = ...
  2458. *
  2459. *
  2460. * Outputs:
  2461. * -------
  2462. * Return = ...
  2463. *
  2464. *
  2465. * Comments:
  2466. * --------
  2467. *
  2468. *************************************<->***********************************/
  2469. static void
  2470. wmDtErrorDialogOkCB(
  2471. Widget w,
  2472. XtPointer client_data,
  2473. XtPointer call_data )
  2474. {
  2475. WmScreenData *pSD = (WmScreenData *) client_data;
  2476. wmDtErrorDialogHide (pSD);
  2477. } /* END OF FUNCTION wmDtErrorDialogOkCB */
  2478. /*************************************<->*************************************
  2479. *
  2480. * void
  2481. * wmDtErrorDialogPopupCB (w, client_data, call_data)
  2482. *
  2483. *
  2484. * Description:
  2485. * -----------
  2486. *
  2487. *
  2488. * Inputs:
  2489. * ------
  2490. * w = ...
  2491. * client_data = ...
  2492. * call_data = ...
  2493. *
  2494. *
  2495. * Outputs:
  2496. * -------
  2497. * Return = ...
  2498. *
  2499. *
  2500. * Comments:
  2501. * --------
  2502. *
  2503. *************************************<->***********************************/
  2504. static void
  2505. wmDtErrorDialogPopupCB(
  2506. Widget w,
  2507. XtPointer client_data,
  2508. XtPointer call_data )
  2509. {
  2510. WmScreenData *pSD = (WmScreenData *) client_data;
  2511. Window wRoot, wChild;
  2512. int rootX, rootY, winX, winY;
  2513. unsigned int mask;
  2514. Dimension dWidth, dHeight;
  2515. Position x, y;
  2516. Arg al[10];
  2517. int ac;
  2518. /* set new position near cursor position */
  2519. XQueryPointer (DISPLAY, XtWindow(pSD->screenTopLevelW1),
  2520. &wRoot, &wChild, &rootX, &rootY, &winX, &winY, &mask);
  2521. ac = 0;
  2522. XtSetArg (al[ac], XmNwidth, &dWidth); ac++;
  2523. XtSetArg (al[ac], XmNheight, &dHeight); ac++;
  2524. XtGetValues (w, al, ac);
  2525. x = (Position) rootX - (dWidth / 2);
  2526. y = (Position) rootY - (dHeight / 2);
  2527. if ((x + ((Position) dWidth / 2)) > DisplayWidth (DISPLAY, pSD->screen))
  2528. x = DisplayWidth (DISPLAY,pSD->screen) - (dWidth/2) - 1;
  2529. if (x < 0)
  2530. x = 0;
  2531. if ((y + ((Position) dHeight / 2)) > DisplayHeight (DISPLAY, pSD->screen))
  2532. y = DisplayHeight (DISPLAY,pSD->screen) - (dHeight/2) - 1;
  2533. if (y < 0)
  2534. y = 0;
  2535. ac = 0;
  2536. XtSetArg (al[ac], XmNx, x); ac++;
  2537. XtSetArg (al[ac], XmNy, y); ac++;
  2538. XtSetArg (al[ac], XmNwindowGroup,
  2539. XtUnspecifiedWindowGroup); ac++;
  2540. XtSetArg (al[ac], XmNwaitForWm, False); ac++;
  2541. XtSetValues (w, al, ac);
  2542. } /* END OF FUNCTION wmDtErrorDialogPopupCB */
  2543. /**************************** eof ***************************/