help.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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. /* $XConsortium: help.c /main/4 1995/11/02 14:05:18 rswiston $ */
  24. /*********************************************************************
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  28. * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  29. * Novell, Inc.
  30. **********************************************************************/
  31. /******************************************************************************
  32. ** Program: dticon
  33. **
  34. ** Description: X11-based multi-color icon editor
  35. **
  36. ** File: help.c, which contains the following subroutines or
  37. ** functions:
  38. ** AssignHelpCallbacks()
  39. ** HelpTriggerCB()
  40. ** HelpHyperlinkCB()
  41. ** HelpCloseCB()
  42. ** GetHelpDialog()
  43. ** HelpSetVolAndLocation()
  44. ** DisplayHelp()
  45. ** DisplayNewHelp()
  46. ** DisplayHelpDialog()
  47. ** CreateHelpDialog()
  48. **
  49. ******************************************************************************
  50. **
  51. ** Copyright 1991 by Hewlett-Packard Company, 1990, 1991, 1992.
  52. ** All rights are reserved. Copying or reproduction of this program,
  53. ** except for archival purposes, is prohibited without prior written
  54. ** consent of Hewlett-Packard Company.
  55. **
  56. ** Hewlett-Packard makes no representations about the suitibility of this
  57. ** software for any purpose. It is provided "as is" without express or
  58. ** implied warranty.
  59. **
  60. ******************************************************************************/
  61. #include <stdio.h>
  62. #include <stdint.h>
  63. #include <Xm/DialogS.h>
  64. #include <Xm/Form.h>
  65. #include <Xm/MwmUtil.h>
  66. #include <Dt/HelpDialog.h>
  67. #include "help.h"
  68. #include "main.h"
  69. #include "utils.h"
  70. extern Widget circleButton, editMenu_addHS_pb, editMenu_clear_pb;
  71. extern Widget editMenu_copy_pb, editMenu_cut_pb, editMenu_deleteHS_pb;
  72. extern Widget editMenu_flip_pb, editMenu_paste_pb, editMenu_resize_pb;
  73. extern Widget editMenu_rotate_pb, editMenu_scale_pb, editMenu_top_pb;
  74. extern Widget editMenu_undo_pb, ellipseButton, eraseButton, floodButton;
  75. extern Widget fileMenu_new_pb, fileMenu_open_pb, fileMenu_quit_pb;
  76. extern Widget fileMenu_saveAs_pb, fileMenu_save_pb, fileMenu_top_pb;
  77. extern Widget lineButton, menu1, optionsMenu_format, optionsMenu_grid;
  78. extern Widget optionsMenu_magnify, optionsMenu_top_pb, pointButton;
  79. extern Widget polygonButton, polylineButton, queryDialog, rectangleButton;
  80. extern Widget selectButton, fillToggle;
  81. extern Widget editMenu_grabImage_pb;
  82. extern Widget helpMenu_top_pb, helpMenu_intro_pb, helpMenu_tasks_pb,
  83. helpMenu_ref_pb, helpMenu_item_pb, helpMenu_using_pb,
  84. helpMenu_version_pb;
  85. extern Widget rotateMenu, flipMenu, formatMenu, magnificationMenu;
  86. extern Widget staticColorsBox, symbolicColorsBox, staticGreysBox;
  87. extern Widget viewport;
  88. void HelpTriggerCB(Widget w, caddr_t client_data, caddr_t call_data);
  89. void HelpOnItemCB(Widget w, caddr_t client_data, caddr_t call_data);
  90. void HelpSetVolAndLocation(int topic);
  91. void DisplayNewHelp(char *helpVolume, char *locationId);
  92. void DisplayHelp(char *helpVolume, char *locationId);
  93. void DisplayHelpDialog(Widget dialog, char *helpVolume, char *locationId);
  94. Widget CreateHelpDialog(HelpStruct *pHelp);
  95. void
  96. AssignHelpCallbacks( void )
  97. {
  98. #ifdef DEBUG
  99. if (debug)
  100. stat_out("Entering AssignHelpCallbacks\n");
  101. #endif
  102. /*** Set Help callbacks for the graphic tools ***/
  103. XtAddCallback(pointButton, XmNhelpCallback,
  104. (XtCallbackProc) HelpTriggerCB,
  105. (XtPointer)HELP_POINT_BUTTON);
  106. XtAddCallback(floodButton, XmNhelpCallback,
  107. (XtCallbackProc) HelpTriggerCB,
  108. (XtPointer)HELP_FLOOD_BUTTON);
  109. XtAddCallback(lineButton, XmNhelpCallback,
  110. (XtCallbackProc) HelpTriggerCB,
  111. (XtPointer)HELP_LINE_BUTTON);
  112. XtAddCallback(polylineButton, XmNhelpCallback,
  113. (XtCallbackProc) HelpTriggerCB,
  114. (XtPointer)HELP_POLYLINE_BUTTON);
  115. XtAddCallback(rectangleButton, XmNhelpCallback,
  116. (XtCallbackProc) HelpTriggerCB,
  117. (XtPointer)HELP_RECTANGLE_BUTTON);
  118. XtAddCallback(polygonButton, XmNhelpCallback,
  119. (XtCallbackProc) HelpTriggerCB,
  120. (XtPointer)HELP_POLYGON_BUTTON);
  121. XtAddCallback(circleButton, XmNhelpCallback,
  122. (XtCallbackProc) HelpTriggerCB,
  123. (XtPointer)HELP_CIRCLE_BUTTON);
  124. XtAddCallback(ellipseButton, XmNhelpCallback,
  125. (XtCallbackProc) HelpTriggerCB,
  126. (XtPointer)HELP_ELLIPSE_BUTTON);
  127. XtAddCallback(eraseButton, XmNhelpCallback,
  128. (XtCallbackProc) HelpTriggerCB,
  129. (XtPointer)HELP_ERASER_BUTTON);
  130. XtAddCallback(selectButton, XmNhelpCallback,
  131. (XtCallbackProc) HelpTriggerCB,
  132. (XtPointer)HELP_SELECT_BUTTON);
  133. XtAddCallback(fillToggle, XmNhelpCallback,
  134. (XtCallbackProc) HelpTriggerCB,
  135. (XtPointer)HELP_FILL_BUTTON);
  136. /*** Set Help callbacks for the pen groups ***/
  137. XtAddCallback(staticColorsBox, XmNhelpCallback,
  138. (XtCallbackProc) HelpTriggerCB,
  139. (XtPointer)HELP_STATIC_COLOR_BUTTON);
  140. XtAddCallback(staticGreysBox, XmNhelpCallback,
  141. (XtCallbackProc) HelpTriggerCB,
  142. (XtPointer)HELP_STATIC_GREY_BUTTON);
  143. XtAddCallback(symbolicColorsBox, XmNhelpCallback,
  144. (XtCallbackProc) HelpTriggerCB,
  145. (XtPointer)HELP_DYNAMIC_COLOR_BUTTON);
  146. /*** Set Help callbacks for the File menu ***/
  147. XtAddCallback(fileMenu_top_pb, XmNhelpCallback,
  148. (XtCallbackProc) HelpTriggerCB,
  149. (XtPointer)HELP_FILE_BUTTON);
  150. XtAddCallback(fileMenu_new_pb, XmNhelpCallback,
  151. (XtCallbackProc) HelpTriggerCB,
  152. (XtPointer)HELP_NEW_BUTTON);
  153. XtAddCallback(fileMenu_open_pb, XmNhelpCallback,
  154. (XtCallbackProc) HelpTriggerCB,
  155. (XtPointer)HELP_OPEN_BUTTON);
  156. XtAddCallback(fileMenu_save_pb, XmNhelpCallback,
  157. (XtCallbackProc) HelpTriggerCB,
  158. (XtPointer)HELP_SAVE_BUTTON);
  159. XtAddCallback(fileMenu_saveAs_pb, XmNhelpCallback,
  160. (XtCallbackProc) HelpTriggerCB,
  161. (XtPointer)HELP_SAVE_AS_BUTTON);
  162. XtAddCallback(fileMenu_quit_pb, XmNhelpCallback,
  163. (XtCallbackProc) HelpTriggerCB,
  164. (XtPointer)HELP_QUIT_BUTTON);
  165. /*** Set Help callbacks for the Edit menu ***/
  166. XtAddCallback(editMenu_top_pb, XmNhelpCallback,
  167. (XtCallbackProc) HelpTriggerCB,
  168. (XtPointer)HELP_EDIT_BUTTON);
  169. XtAddCallback(editMenu_undo_pb, XmNhelpCallback,
  170. (XtCallbackProc) HelpTriggerCB,
  171. (XtPointer)HELP_UNDO_BUTTON);
  172. XtAddCallback(editMenu_cut_pb, XmNhelpCallback,
  173. (XtCallbackProc) HelpTriggerCB,
  174. (XtPointer)HELP_CUT_BUTTON);
  175. XtAddCallback(editMenu_copy_pb, XmNhelpCallback,
  176. (XtCallbackProc) HelpTriggerCB,
  177. (XtPointer)HELP_COPY_BUTTON);
  178. XtAddCallback(editMenu_paste_pb, XmNhelpCallback,
  179. (XtCallbackProc) HelpTriggerCB,
  180. (XtPointer)HELP_PASTE_BUTTON);
  181. XtAddCallback(editMenu_rotate_pb, XmNhelpCallback,
  182. (XtCallbackProc) HelpTriggerCB,
  183. (XtPointer)HELP_ROTATE_BUTTON);
  184. XtAddCallback(rotateMenu, XmNhelpCallback,
  185. (XtCallbackProc) HelpTriggerCB,
  186. (XtPointer)HELP_ROTATE_BUTTON);
  187. XtAddCallback(editMenu_flip_pb, XmNhelpCallback,
  188. (XtCallbackProc) HelpTriggerCB,
  189. (XtPointer)HELP_FLIP_BUTTON);
  190. XtAddCallback(flipMenu, XmNhelpCallback,
  191. (XtCallbackProc) HelpTriggerCB,
  192. (XtPointer)HELP_FLIP_BUTTON);
  193. XtAddCallback(editMenu_scale_pb, XmNhelpCallback,
  194. (XtCallbackProc) HelpTriggerCB,
  195. (XtPointer)HELP_SCALE_BUTTON);
  196. XtAddCallback(editMenu_resize_pb, XmNhelpCallback,
  197. (XtCallbackProc) HelpTriggerCB,
  198. (XtPointer)HELP_RESIZE_ICON_BUTTON);
  199. XtAddCallback(editMenu_addHS_pb, XmNhelpCallback,
  200. (XtCallbackProc) HelpTriggerCB,
  201. (XtPointer)HELP_ADD_HOTSPOT_BUTTON);
  202. XtAddCallback(editMenu_deleteHS_pb, XmNhelpCallback,
  203. (XtCallbackProc) HelpTriggerCB,
  204. (XtPointer)HELP_DELETE_HOTSPOT_BUTTON);
  205. XtAddCallback(editMenu_grabImage_pb, XmNhelpCallback,
  206. (XtCallbackProc) HelpTriggerCB,
  207. (XtPointer)HELP_GRAB_BUTTON);
  208. XtAddCallback(editMenu_clear_pb, XmNhelpCallback,
  209. (XtCallbackProc) HelpTriggerCB,
  210. (XtPointer)HELP_CLEAR_ICON_BUTTON);
  211. /*** Set Help callbacks for the Options menu ***/
  212. XtAddCallback(optionsMenu_top_pb, XmNhelpCallback,
  213. (XtCallbackProc) HelpTriggerCB,
  214. (XtPointer)HELP_OPTIONS_BUTTON);
  215. XtAddCallback(optionsMenu_grid, XmNhelpCallback,
  216. (XtCallbackProc) HelpTriggerCB,
  217. (XtPointer)HELP_VISIBLE_GRID_BUTTON);
  218. XtAddCallback(optionsMenu_format, XmNhelpCallback,
  219. (XtCallbackProc) HelpTriggerCB,
  220. (XtPointer)HELP_OUTPUT_FORMAT_BUTTON);
  221. XtAddCallback(formatMenu, XmNhelpCallback,
  222. (XtCallbackProc) HelpTriggerCB,
  223. (XtPointer)HELP_OUTPUT_FORMAT_BUTTON);
  224. XtAddCallback(optionsMenu_magnify, XmNhelpCallback,
  225. (XtCallbackProc) HelpTriggerCB,
  226. (XtPointer)HELP_MAGNIFICATION_BUTTON);
  227. XtAddCallback(magnificationMenu, XmNhelpCallback,
  228. (XtCallbackProc) HelpTriggerCB,
  229. (XtPointer)HELP_MAGNIFICATION_BUTTON);
  230. /*** Set Help callbacks for the Help menu (menu items activated) ***/
  231. XtAddCallback(helpMenu_intro_pb,
  232. XmNactivateCallback,
  233. (XtCallbackProc) HelpTriggerCB,
  234. (XtPointer)HELP_INTRODUCTION);
  235. XtAddCallback(helpMenu_tasks_pb,
  236. XmNactivateCallback,
  237. (XtCallbackProc) HelpTriggerCB,
  238. (XtPointer)HELP_TASKS);
  239. XtAddCallback(helpMenu_ref_pb,
  240. XmNactivateCallback,
  241. (XtCallbackProc) HelpTriggerCB,
  242. (XtPointer)HELP_REFERENCE);
  243. XtAddCallback(helpMenu_item_pb,
  244. XmNactivateCallback,
  245. (XtCallbackProc) HelpOnItemCB,
  246. (XtPointer)HELP_ON_ITEM);
  247. XtAddCallback(helpMenu_using_pb,
  248. XmNactivateCallback,
  249. (XtCallbackProc) HelpTriggerCB,
  250. (XtPointer)HELP_USING_HELP);
  251. XtAddCallback(helpMenu_version_pb,
  252. XmNactivateCallback,
  253. (XtCallbackProc) HelpTriggerCB,
  254. (XtPointer)HELP_VERSION);
  255. /*** Set Help callbacks for the Help menu (help on menu items themselves) ***/
  256. XtAddCallback(helpMenu_top_pb,
  257. XmNhelpCallback,
  258. (XtCallbackProc) HelpTriggerCB,
  259. (XtPointer)HELP_HELP_BUTTON);
  260. XtAddCallback(helpMenu_intro_pb,
  261. XmNhelpCallback,
  262. (XtCallbackProc) HelpTriggerCB,
  263. (XtPointer)HELP_HELP_INTRODUCTION);
  264. XtAddCallback(helpMenu_tasks_pb,
  265. XmNhelpCallback,
  266. (XtCallbackProc) HelpTriggerCB,
  267. (XtPointer)HELP_HELP_TASKS);
  268. XtAddCallback(helpMenu_ref_pb,
  269. XmNhelpCallback,
  270. (XtCallbackProc) HelpTriggerCB,
  271. (XtPointer)HELP_HELP_REFERENCE);
  272. XtAddCallback(helpMenu_item_pb,
  273. XmNhelpCallback,
  274. (XtCallbackProc) HelpTriggerCB,
  275. (XtPointer)HELP_HELP_ON_ITEM);
  276. XtAddCallback(helpMenu_using_pb,
  277. XmNhelpCallback,
  278. (XtCallbackProc) HelpTriggerCB,
  279. (XtPointer)HELP_HELP_USING_HELP);
  280. XtAddCallback(helpMenu_version_pb,
  281. XmNhelpCallback,
  282. (XtCallbackProc) HelpTriggerCB,
  283. (XtPointer)HELP_HELP_VERSION);
  284. /*** Set Help callbacks for other GUI components ***/
  285. XtAddCallback(menu1, XmNhelpCallback,
  286. (XtCallbackProc) HelpTriggerCB,
  287. (XtPointer)HELP_MENUBAR);
  288. XtAddCallback(queryDialog, XmNhelpCallback,
  289. (XtCallbackProc) HelpTriggerCB,
  290. (XtPointer)HELP_QUERY);
  291. XtAddCallback(stdErrDialog, XmNhelpCallback,
  292. (XtCallbackProc) HelpTriggerCB,
  293. (XtPointer)HELP_ERROR);
  294. XtAddCallback(newIconDialog, XmNhelpCallback,
  295. (XtCallbackProc) HelpTriggerCB,
  296. (XtPointer)HELP_NEW_ICON);
  297. XtAddCallback(fileIODialog, XmNhelpCallback,
  298. (XtCallbackProc) HelpTriggerCB,
  299. (XtPointer)HELP_FILEIO_ICON);
  300. XtAddCallback(viewport, XmNhelpCallback,
  301. (XtCallbackProc) HelpTriggerCB,
  302. (XtPointer)HELP_VIEWPORT);
  303. XtAddCallback(mainWindow, XmNhelpCallback,
  304. (XtCallbackProc) HelpTriggerCB,
  305. (XtPointer)HELP_MAIN_WINDOW);
  306. #ifdef DEBUG
  307. if (debug)
  308. stat_out("Leaving AssignHelpCallbacks\n");
  309. #endif
  310. }
  311. void
  312. HelpTriggerCB(
  313. Widget w,
  314. caddr_t client_data,
  315. caddr_t call_data )
  316. {
  317. #ifdef DEBUG
  318. if (debug)
  319. stat_out("Entering HelpTriggerCB: help-tag=%d\n", (int) client_data);
  320. #endif
  321. HelpSetVolAndLocation((int) (intptr_t) client_data);
  322. #ifdef DEBUG
  323. if (debug)
  324. stat_out("Leaving HelpTriggerCB\n");
  325. #endif
  326. }
  327. void
  328. HelpOnItemCB(
  329. Widget w,
  330. caddr_t client_data,
  331. caddr_t call_data )
  332. {
  333. Widget selWidget;
  334. int status;
  335. #ifdef DEBUG
  336. if (debug)
  337. stat_out("Entering HelpOnItemCB: help-tag=%d\n", (int) client_data);
  338. #endif
  339. while (!XtIsSubclass(w, applicationShellWidgetClass))
  340. w = XtParent(w);
  341. status = DtHelpReturnSelectedWidgetId(w, 0, &selWidget);
  342. /* NULL value for cursor, uses default cursor value. */
  343. switch ((int)status)
  344. {
  345. case DtHELP_SELECT_ERROR:
  346. /* Display error dialog here, function call failed */
  347. break;
  348. case DtHELP_SELECT_VALID:
  349. while (selWidget != (Widget)NULL)
  350. {
  351. if ( (XtHasCallbacks(selWidget, XmNhelpCallback)
  352. == XtCallbackHasSome) )
  353. {
  354. XtCallCallbacks(selWidget, XmNhelpCallback, NULL);
  355. break;
  356. }
  357. else
  358. selWidget = XtParent(selWidget);
  359. }
  360. break;
  361. case DtHELP_SELECT_ABORT:
  362. /* Display error dialog here,
  363. * "Selection Aborted by user."
  364. */
  365. break;
  366. case DtHELP_SELECT_INVALID:
  367. DoErrorDialog( GETSTR(14,4,"You must select an item\nwithin the Icon Editor.") );
  368. break;
  369. }
  370. #ifdef DEBUG
  371. if (debug)
  372. stat_out("Leaving HelpOnItemCB\n");
  373. #endif
  374. }
  375. void
  376. HelpHyperlinkCB(
  377. Widget w,
  378. caddr_t client_data_unused,
  379. caddr_t call_data )
  380. {
  381. DtHelpDialogCallbackStruct *pHyper =
  382. (DtHelpDialogCallbackStruct *) call_data;
  383. switch(pHyper->hyperType) {
  384. case DtHELP_LINK_JUMP_NEW :
  385. DisplayNewHelp(pHyper->helpVolume, pHyper->locationId);
  386. break;
  387. default : ; /* application defined link code goes here */
  388. } /* switch */
  389. }
  390. void
  391. HelpCloseCB(
  392. Widget w,
  393. caddr_t client_data,
  394. caddr_t call_data_unused )
  395. {
  396. HelpStruct *pHelp = (HelpStruct *)client_data;
  397. #ifdef DEBUG
  398. if (debug)
  399. stat_out("Entering HelpCloseCB\n");
  400. #endif
  401. if(pHelp != (HelpStruct *)NULL)
  402. {
  403. /* this is a "cached" help dialog */
  404. pHelp->inUse = False;
  405. }
  406. XtUnmanageChild(w);
  407. #ifdef DEBUG
  408. if (debug)
  409. stat_out("Leaving HelpCloseCB\n");
  410. #endif
  411. }
  412. static Widget
  413. GetHelpDialog( void )
  414. {
  415. HelpStruct *pHelp;
  416. Arg args[5];
  417. int i, done;
  418. #ifdef DEBUG
  419. if (debug)
  420. stat_out("Entering GetHelpDialog\n");
  421. #endif
  422. if(help_head == (HelpStruct *)NULL) {
  423. pHelp = (HelpStruct *)XtMalloc(sizeof(HelpStruct));
  424. pHelp->pNext = (HelpStruct *)NULL;
  425. pHelp->pPrev = (HelpStruct *)NULL;
  426. pHelp->inUse = True;
  427. pHelp->dialog = CreateHelpDialog(pHelp);
  428. help_head = pHelp;
  429. #ifdef DEBUG
  430. if (debug)
  431. stat_out("Leaving GetHelpDialog: Created the 1st help dialog\n");
  432. #endif
  433. return pHelp->dialog;
  434. }
  435. else {
  436. pHelp = help_head;
  437. done = False;
  438. while (!done) {
  439. if(pHelp->inUse == False) {
  440. pHelp->inUse = True;
  441. #ifdef DEBUG
  442. if (debug)
  443. stat_out("Leaving GetHelpDialog: activated an existing help dialog\n");
  444. #endif
  445. return pHelp->dialog;
  446. } /* if */
  447. if(pHelp->pNext != (HelpStruct *)NULL)
  448. pHelp = pHelp->pNext;
  449. else
  450. done = True;
  451. } /* while */
  452. pHelp->pNext = (HelpStruct *) XtMalloc(sizeof(HelpStruct));
  453. pHelp->pNext->pPrev = pHelp;
  454. pHelp = pHelp->pNext;
  455. pHelp->pNext = (HelpStruct *)NULL;
  456. pHelp->inUse = True;
  457. pHelp->dialog = CreateHelpDialog(pHelp);
  458. #ifdef DEBUG
  459. if (debug)
  460. stat_out("Leaving GetHelpDialog: Created a new help dialog\n");
  461. #endif
  462. return pHelp->dialog;
  463. }
  464. }
  465. void
  466. HelpSetVolAndLocation(
  467. int topic)
  468. {
  469. char *helpVolume, *locationId;
  470. #ifdef DEBUG
  471. if (debug)
  472. stat_out("Entering HelpSetVolAndLocation: topic = %d\n", topic);
  473. #endif
  474. helpVolume = HELP_VOLUME;
  475. switch (topic) {
  476. /*** choices for the 'Help' pulldown menu ***/
  477. case HELP_INTRODUCTION:
  478. locationId = HELP_INTRODUCTION_STR;
  479. break;
  480. case HELP_TASKS:
  481. locationId = HELP_TASKS_STR;
  482. break;
  483. case HELP_REFERENCE:
  484. locationId = HELP_REFERENCE_STR;
  485. break;
  486. case HELP_ON_ITEM:
  487. locationId = HELP_ON_ITEM_STR;
  488. break;
  489. case HELP_USING_HELP:
  490. helpVolume = HELP_HELP_VOLUME;
  491. locationId = HELP_USING_HELP_STR;
  492. break;
  493. case HELP_VERSION:
  494. locationId = HELP_VERSION_STR;
  495. break;
  496. /*** choices for the top-level menus on the main menubar ***/
  497. case HELP_FILE_BUTTON:
  498. locationId = HELP_FILE_BUTTON_STR;
  499. break;
  500. case HELP_EDIT_BUTTON:
  501. locationId = HELP_EDIT_BUTTON_STR;
  502. break;
  503. case HELP_OPTIONS_BUTTON:
  504. locationId = HELP_OPTIONS_BUTTON_STR;
  505. break;
  506. case HELP_HELP_BUTTON:
  507. locationId = HELP_HELP_BUTTON_STR;
  508. break;
  509. /*** choices for the 'File' pulldown menu ***/
  510. case HELP_NEW_BUTTON:
  511. locationId = HELP_NEW_BUTTON_STR;
  512. break;
  513. case HELP_OPEN_BUTTON:
  514. locationId = HELP_OPEN_BUTTON_STR;
  515. break;
  516. case HELP_SAVE_BUTTON:
  517. locationId = HELP_SAVE_BUTTON_STR;
  518. break;
  519. case HELP_SAVE_AS_BUTTON:
  520. locationId = HELP_SAVE_AS_BUTTON_STR;
  521. break;
  522. case HELP_QUIT_BUTTON:
  523. locationId = HELP_QUIT_BUTTON_STR;
  524. break;
  525. /*** choices for the 'Edit' pulldown menu ***/
  526. case HELP_UNDO_BUTTON:
  527. locationId = HELP_UNDO_BUTTON_STR;
  528. break;
  529. case HELP_CUT_BUTTON:
  530. locationId = HELP_CUT_BUTTON_STR;
  531. break;
  532. case HELP_COPY_BUTTON:
  533. locationId = HELP_COPY_BUTTON_STR;
  534. break;
  535. case HELP_PASTE_BUTTON:
  536. locationId = HELP_PASTE_BUTTON_STR;
  537. break;
  538. case HELP_ROTATE_BUTTON:
  539. locationId = HELP_ROTATE_BUTTON_STR;
  540. break;
  541. case HELP_FLIP_BUTTON:
  542. locationId = HELP_FLIP_BUTTON_STR;
  543. break;
  544. case HELP_SCALE_BUTTON:
  545. locationId = HELP_SCALE_BUTTON_STR;
  546. break;
  547. case HELP_RESIZE_ICON_BUTTON:
  548. locationId = HELP_RESIZE_ICON_BUTTON_STR;
  549. break;
  550. case HELP_ADD_HOTSPOT_BUTTON:
  551. locationId = HELP_ADD_HOTSPOT_BUTTON_STR;
  552. break;
  553. case HELP_DELETE_HOTSPOT_BUTTON:
  554. locationId = HELP_DELETE_HOTSPOT_BUTTON_STR;
  555. break;
  556. case HELP_GRAB_BUTTON:
  557. locationId = HELP_GRAB_BUTTON_STR;
  558. break;
  559. case HELP_CLEAR_ICON_BUTTON:
  560. locationId = HELP_CLEAR_ICON_BUTTON_STR;
  561. break;
  562. /*** choices for the 'Options' pulldown menu ***/
  563. case HELP_VISIBLE_GRID_BUTTON:
  564. locationId = HELP_VISIBLE_GRID_BUTTON_STR;
  565. break;
  566. case HELP_OUTPUT_FORMAT_BUTTON:
  567. locationId = HELP_OUTPUT_FORMAT_BUTTON_STR;
  568. break;
  569. case HELP_MAGNIFICATION_BUTTON:
  570. locationId = HELP_MAGNIFICATION_BUTTON_STR;
  571. break;
  572. /*** choices for the 'Help' pulldown menu ***/
  573. case HELP_HELP_INTRODUCTION:
  574. locationId = HELP_HELP_INTRODUCTION_STR;
  575. break;
  576. case HELP_HELP_TASKS:
  577. locationId = HELP_HELP_TASKS_STR;
  578. break;
  579. case HELP_HELP_REFERENCE:
  580. locationId = HELP_HELP_REFERENCE_STR;
  581. break;
  582. case HELP_HELP_ON_ITEM:
  583. locationId = HELP_HELP_ON_ITEM_STR;
  584. break;
  585. case HELP_HELP_USING_HELP:
  586. locationId = HELP_HELP_USING_HELP_STR;
  587. break;
  588. case HELP_HELP_VERSION:
  589. locationId = HELP_HELP_VERSION_STR;
  590. break;
  591. /*** choices for each of the Graphics Tool pushbuttons ***/
  592. case HELP_POINT_BUTTON:
  593. locationId = HELP_POINT_BUTTON_STR;
  594. break;
  595. case HELP_FLOOD_BUTTON:
  596. locationId = HELP_FLOOD_BUTTON_STR;
  597. break;
  598. case HELP_LINE_BUTTON:
  599. locationId = HELP_LINE_BUTTON_STR;
  600. break;
  601. case HELP_POLYLINE_BUTTON:
  602. locationId = HELP_POLYLINE_BUTTON_STR;
  603. break;
  604. case HELP_RECTANGLE_BUTTON:
  605. locationId = HELP_RECTANGLE_BUTTON_STR;
  606. break;
  607. case HELP_POLYGON_BUTTON:
  608. locationId = HELP_POLYGON_BUTTON_STR;
  609. break;
  610. case HELP_CIRCLE_BUTTON:
  611. locationId = HELP_CIRCLE_BUTTON_STR;
  612. break;
  613. case HELP_ELLIPSE_BUTTON:
  614. locationId = HELP_ELLIPSE_BUTTON_STR;
  615. break;
  616. case HELP_ERASER_BUTTON:
  617. locationId = HELP_ERASER_BUTTON_STR;
  618. break;
  619. case HELP_SELECT_BUTTON:
  620. locationId = HELP_SELECT_BUTTON_STR;
  621. break;
  622. case HELP_FILL_BUTTON:
  623. locationId = HELP_FILL_BUTTON_STR;
  624. break;
  625. /*** choices for each of the Pen Color Group pushbuttons ***/
  626. case HELP_STATIC_COLOR_BUTTON:
  627. locationId = HELP_STATIC_COLOR_BUTTON_STR;
  628. break;
  629. case HELP_STATIC_GREY_BUTTON:
  630. locationId = HELP_STATIC_GREY_BUTTON_STR;
  631. break;
  632. case HELP_DYNAMIC_COLOR_BUTTON:
  633. locationId = HELP_DYNAMIC_COLOR_BUTTON_STR;
  634. break;
  635. /*** choice for other GUI components ***/
  636. case HELP_MENUBAR:
  637. locationId = HELP_MENUBAR_STR;
  638. break;
  639. case HELP_QUERY:
  640. locationId = HELP_QUERY_STR;
  641. break;
  642. case HELP_ERROR:
  643. locationId = HELP_ERROR_STR;
  644. break;
  645. case HELP_NEW_ICON:
  646. locationId = HELP_NEW_ICON_STR;
  647. break;
  648. case HELP_FILEIO_ICON:
  649. locationId = HELP_FILEIO_ICON_STR;
  650. break;
  651. case HELP_VIEWPORT:
  652. locationId = HELP_VIEWPORT_STR;
  653. break;
  654. case HELP_MAIN_WINDOW:
  655. locationId = HELP_MAIN_WINDOW_STR;
  656. break;
  657. default:
  658. locationId = HELP_MAIN_WINDOW_STR;
  659. break;
  660. }
  661. DisplayHelp(helpVolume, locationId);
  662. #ifdef DEBUG
  663. if (debug)
  664. stat_out("Leaving HelpSetVolAndLocation\n");
  665. #endif
  666. }
  667. void
  668. DisplayHelp(
  669. char *helpVolume,
  670. char *locationId)
  671. {
  672. static Widget mainHelpDialog = NULL;
  673. #ifdef DEBUG
  674. if (debug)
  675. stat_out("Entering DisplayHelp\n");
  676. #endif
  677. if (mainHelpDialog == NULL)
  678. mainHelpDialog = CreateHelpDialog(NULL);
  679. DisplayHelpDialog (mainHelpDialog, helpVolume, locationId);
  680. #ifdef DEBUG
  681. if (debug)
  682. stat_out("Leaving DisplayHelp\n");
  683. #endif
  684. }
  685. void
  686. DisplayNewHelp(
  687. char *helpVolume,
  688. char *locationId)
  689. {
  690. Widget helpDialog;
  691. #ifdef DEBUG
  692. if (debug)
  693. stat_out("Entering DisplayNewHelp\n");
  694. #endif
  695. helpDialog = GetHelpDialog();
  696. DisplayHelpDialog (helpDialog, helpVolume, locationId);
  697. #ifdef DEBUG
  698. if (debug)
  699. stat_out("Leaving DisplayNewHelp\n");
  700. #endif
  701. }
  702. void
  703. DisplayHelpDialog (
  704. Widget helpDialog,
  705. char *helpVolume,
  706. char *locationId)
  707. {
  708. Arg args[10];
  709. int n;
  710. #ifdef DEBUG
  711. if (debug)
  712. stat_out("Entering DisplayHelpDialog\n");
  713. #endif
  714. n = 0;
  715. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  716. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  717. XtSetArg(args[n], DtNlocationId, locationId); n++;
  718. XtSetValues(helpDialog, args, n);
  719. XtManageChild(helpDialog);
  720. #ifdef DEBUG
  721. if (debug)
  722. stat_out("Leaving DisplayHelpDialog\n");
  723. #endif
  724. }
  725. Widget
  726. CreateHelpDialog (HelpStruct *pHelp)
  727. {
  728. Widget helpDialog;
  729. Arg args[10];
  730. int i;
  731. #ifdef DEBUG
  732. if (debug)
  733. stat_out("Entering CreateHelpDialog, pHelp is %x\n", pHelp);
  734. #endif
  735. i = 0;
  736. XtSetArg(args[i], XmNtitle, GETSTR(14,2, "Icon Editor - Help")); i++;
  737. XtSetArg(args[i], XmNiconName,GETSTR(14,2, "Icon Editor - Help"));i++;
  738. helpDialog = DtCreateHelpDialog(dtIconShell, "helpDlg",
  739. args, i);
  740. XtAddCallback(helpDialog, DtNhyperLinkCallback,
  741. (XtCallbackProc)HelpHyperlinkCB, NULL);
  742. XtAddCallback(helpDialog, DtNcloseCallback,
  743. (XtCallbackProc)HelpCloseCB, pHelp);
  744. #ifdef DEBUG
  745. if (debug)
  746. stat_out("Leaving CreateHelpDialog\n");
  747. #endif
  748. return helpDialog;
  749. }