Help.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 "Main.h"
  50. #include "Help.h"
  51. static Widget
  52. GetHelpDialog(void)
  53. {
  54. static HelpStruct *pHelpCache;
  55. HelpStruct *pHelp;
  56. Arg args[5];
  57. int n;
  58. if(pHelpCache == (HelpStruct *)NULL)
  59. {
  60. pHelp = pHelpCache = (HelpStruct *)XtMalloc(sizeof(HelpStruct));
  61. pHelp->pNext = (HelpStruct *)NULL;
  62. pHelp->pPrev = (HelpStruct *)NULL;
  63. pHelp->inUse = True;
  64. n = 0;
  65. XtSetArg(args[n], XmNtitle,
  66. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  67. pHelp->dialog = DtCreateHelpDialog(style.shell, "helpDlg",
  68. args, n);
  69. DtWsmRemoveWorkspaceFunctions(style.display,
  70. XtWindow(XtParent(pHelp->dialog)));
  71. XtAddCallback(pHelp->dialog, DtNhyperLinkCallback,
  72. (XtCallbackProc)HelpHyperlinkCB, NULL);
  73. XtAddCallback(pHelp->dialog, DtNcloseCallback,
  74. (XtCallbackProc)HelpCloseCB, pHelpCache);
  75. return pHelp->dialog;
  76. }
  77. else
  78. {
  79. for(pHelp = pHelpCache;
  80. pHelp != (HelpStruct *)NULL;
  81. pHelp = pHelp->pNext)
  82. {
  83. if(pHelp->inUse == False)
  84. {
  85. pHelp->inUse = True;
  86. return pHelp->dialog;
  87. }
  88. }
  89. pHelp = (HelpStruct *) XtMalloc(sizeof(HelpStruct));
  90. pHelpCache->pPrev = pHelp;
  91. pHelp->pNext = pHelpCache;
  92. pHelpCache = pHelp;
  93. pHelp->pPrev = (HelpStruct *)NULL;
  94. pHelp->inUse = True;
  95. n=0;
  96. XtSetArg(args[n], XmNtitle,
  97. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  98. pHelp->dialog = DtCreateHelpDialog(style.shell, "helpDlg",
  99. args, n);
  100. DtWsmRemoveWorkspaceFunctions(style.display,
  101. XtWindow(XtParent(pHelp->dialog)));
  102. XtAddCallback(pHelp->dialog, DtNhyperLinkCallback,
  103. (XtCallbackProc)HelpHyperlinkCB, NULL);
  104. XtAddCallback(pHelp->dialog, DtNcloseCallback,
  105. (XtCallbackProc)HelpCloseCB, pHelpCache);
  106. return pHelp->dialog;
  107. }
  108. }
  109. void
  110. DisplayHelp(
  111. char *helpVolume,
  112. char *locationId)
  113. {
  114. Widget helpDialog;
  115. Arg args[10];
  116. int n;
  117. helpDialog = GetHelpDialog();
  118. n = 0;
  119. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  120. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  121. XtSetArg(args[n], DtNlocationId, locationId); n++;
  122. XtSetValues(helpDialog, args, n);
  123. XtManageChild(helpDialog);
  124. XtMapWidget(XtParent(helpDialog));
  125. }
  126. void
  127. Help(
  128. char *helpVolume,
  129. char *locationId)
  130. {
  131. static Widget helpDialog = NULL;
  132. Arg args[10];
  133. int n;
  134. if(helpDialog == NULL)
  135. {
  136. n = 0;
  137. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  138. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  139. XtSetArg(args[n], DtNlocationId, locationId); n++;
  140. XtSetArg (args[n], XmNtitle,
  141. ((char *)GETMESSAGE(2, 7, "Style Manager - Help"))); n++;
  142. helpDialog = DtCreateHelpDialog(style.shell, "helpDlg", args, n);
  143. DtWsmRemoveWorkspaceFunctions(style.display,
  144. XtWindow(XtParent(helpDialog)));
  145. XtAddCallback(helpDialog, DtNhyperLinkCallback,
  146. (XtCallbackProc)HelpHyperlinkCB, NULL);
  147. XtAddCallback(helpDialog, DtNcloseCallback,
  148. (XtCallbackProc)HelpCloseCB, NULL);
  149. XtManageChild(helpDialog);
  150. }
  151. else
  152. {
  153. n = 0;
  154. XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
  155. XtSetArg(args[n], DtNhelpVolume, helpVolume); n++;
  156. XtSetArg(args[n], DtNlocationId, locationId); n++;
  157. XtSetValues(helpDialog, args, n);
  158. }
  159. XtMapWidget(XtParent(helpDialog));
  160. }