Help.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/10/30 13:09:47 rswiston $ */
  24. /****************************************************************************
  25. ****************************************************************************
  26. **
  27. ** File: HelpCB.h
  28. **
  29. ** Project: DT 3.0
  30. **
  31. ** Description: Routines that create/cache the dialogs for Help
  32. **
  33. **
  34. ** (c) Copyright Hewlett-Packard Company, 1990, 1991, 1992. All rights are
  35. ** reserved. Copying or other reproduction of this program
  36. ** except for archival purposes is prohibited without prior
  37. ** written consent of Hewlett-Packard Company.
  38. **
  39. **
  40. **
  41. ****************************************************************************/
  42. #include <stdio.h>
  43. #include <Xm/DialogS.h>
  44. #include <Xm/Form.h>
  45. #include <Xm/MwmUtil.h>
  46. #include <Dt/DtP.h>
  47. #include <Dt/Help.h>
  48. #include <Dt/HelpDialog.h>
  49. #include <Dt/Wsm.h>
  50. #include "Main.h"
  51. #include "Help.h"
  52. static Widget
  53. GetHelpDialog(void)
  54. {
  55. static HelpStruct *pHelpCache;
  56. HelpStruct *pHelp;
  57. Arg args[5];
  58. int n;
  59. if(pHelpCache == (HelpStruct *)NULL)
  60. {
  61. pHelp = pHelpCache = (HelpStruct *)XtMalloc(sizeof(HelpStruct));
  62. pHelp->pNext = (HelpStruct *)NULL;
  63. pHelp->pPrev = (HelpStruct *)NULL;
  64. pHelp->inUse = True;
  65. n = 0;
  66. XtSetArg(args[n], XmNtitle,
  67. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  68. pHelp->dialog = DtCreateHelpDialog(style.shell, "helpDlg",
  69. args, n);
  70. DtWsmRemoveWorkspaceFunctions(style.display,
  71. XtWindow(XtParent(pHelp->dialog)));
  72. XtAddCallback(pHelp->dialog, DtNhyperLinkCallback,
  73. (XtCallbackProc)HelpHyperlinkCB, NULL);
  74. XtAddCallback(pHelp->dialog, DtNcloseCallback,
  75. (XtCallbackProc)HelpCloseCB, pHelpCache);
  76. return pHelp->dialog;
  77. }
  78. else
  79. {
  80. for(pHelp = pHelpCache;
  81. pHelp != (HelpStruct *)NULL;
  82. pHelp = pHelp->pNext)
  83. {
  84. if(pHelp->inUse == False)
  85. {
  86. pHelp->inUse = True;
  87. return pHelp->dialog;
  88. }
  89. }
  90. pHelp = (HelpStruct *) XtMalloc(sizeof(HelpStruct));
  91. pHelpCache->pPrev = pHelp;
  92. pHelp->pNext = pHelpCache;
  93. pHelpCache = pHelp;
  94. pHelp->pPrev = (HelpStruct *)NULL;
  95. pHelp->inUse = True;
  96. n=0;
  97. XtSetArg(args[n], XmNtitle,
  98. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  99. pHelp->dialog = DtCreateHelpDialog(style.shell, "helpDlg",
  100. args, n);
  101. DtWsmRemoveWorkspaceFunctions(style.display,
  102. XtWindow(XtParent(pHelp->dialog)));
  103. XtAddCallback(pHelp->dialog, DtNhyperLinkCallback,
  104. (XtCallbackProc)HelpHyperlinkCB, NULL);
  105. XtAddCallback(pHelp->dialog, DtNcloseCallback,
  106. (XtCallbackProc)HelpCloseCB, pHelpCache);
  107. return pHelp->dialog;
  108. }
  109. }
  110. void
  111. DisplayHelp(
  112. char *helpVolume,
  113. char *locationId)
  114. {
  115. Widget helpDialog;
  116. Arg args[10];
  117. int n;
  118. helpDialog = GetHelpDialog();
  119. n = 0;
  120. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  121. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  122. XtSetArg(args[n], DtNlocationId, locationId); n++;
  123. XtSetValues(helpDialog, args, n);
  124. XtManageChild(helpDialog);
  125. XtMapWidget(XtParent(helpDialog));
  126. }
  127. void
  128. Help(
  129. char *helpVolume,
  130. char *locationId)
  131. {
  132. static Widget helpDialog = NULL;
  133. Arg args[10];
  134. int n;
  135. if(helpDialog == NULL)
  136. {
  137. n = 0;
  138. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  139. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  140. XtSetArg(args[n], DtNlocationId, locationId); n++;
  141. XtSetArg (args[n], XmNtitle,
  142. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  143. helpDialog = DtCreateHelpDialog(style.shell, "helpDlg", args, n);
  144. DtWsmRemoveWorkspaceFunctions(style.display,
  145. XtWindow(XtParent(helpDialog)));
  146. XtAddCallback(helpDialog, DtNhyperLinkCallback,
  147. (XtCallbackProc)HelpHyperlinkCB, NULL);
  148. XtAddCallback(helpDialog, DtNcloseCallback,
  149. (XtCallbackProc)HelpCloseCB, NULL);
  150. XtManageChild(helpDialog);
  151. }
  152. else
  153. {
  154. n = 0;
  155. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  156. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  157. XtSetArg(args[n], DtNlocationId, locationId); n++;
  158. XtSetValues(helpDialog, args, n);
  159. }
  160. XtMapWidget(XtParent(helpDialog));
  161. }