HelpDialog.c 121 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660
  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: HelpDialog.c /main/16 1996/11/22 12:24:49 cde-hp $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: HelpDialog.c
  28. **
  29. ** Project: Cde Help 1.0 Project
  30. **
  31. ** Description:
  32. **
  33. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
  34. **
  35. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  36. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  37. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  38. ** (c) Copyright 1993, 1994 Novell, Inc.
  39. **
  40. ****************************************************************************
  41. ************************************<+>*************************************/
  42. #include <stdio.h>
  43. #include <signal.h>
  44. #include <unistd.h> /* R_OK */
  45. #include <X11/Intrinsic.h>
  46. #include <X11/Shell.h>
  47. #include <X11/Xatom.h>
  48. /* These includes work in R4 and R5 */
  49. #include <Xm/MwmUtil.h>
  50. #include <Xm/Protocols.h>
  51. #include <Xm/RepType.h>
  52. #include <Xm/XmP.h>
  53. #include <Xm/ScrolledW.h>
  54. #include <Xm/DialogS.h>
  55. #include <Xm/PanedW.h>
  56. #include <Xm/List.h>
  57. #include <Xm/RowColumnP.h>
  58. #include <Xm/LabelG.h>
  59. #include <Xm/Label.h>
  60. #include <Xm/PushB.h>
  61. #include <Xm/PushBG.h>
  62. #include <Xm/SeparatoG.h>
  63. #include <Xm/CascadeB.h>
  64. #include <Xm/CascadeBG.h>
  65. #include <Xm/XmPrivate.h>
  66. /* Copied from Xm/GeoUtilsI.h */
  67. extern XmGeoMatrix _XmGeoMatrixAlloc(
  68. unsigned int numRows,
  69. unsigned int numBoxes,
  70. unsigned int extSize) ;
  71. /* Canvas Engine */
  72. #include "CanvasP.h" /* for AccessI.h */
  73. /* Help Dialog Widget Includes */
  74. #include "Access.h"
  75. #include "bufioI.h"
  76. #include "AccessI.h"
  77. #include "ActionsI.h"
  78. #include "DisplayAreaI.h"
  79. #include "DisplayAreaP.h"
  80. #include <Dt/Help.h>
  81. #include "HelpI.h"
  82. #include "HelpP.h"
  83. #include "StringFuncsI.h"
  84. #include "HelposI.h"
  85. #include "HelpDialog.h"
  86. #include "HelpDialogI.h"
  87. #include "HelpDialogP.h"
  88. #include "HistoryI.h"
  89. #include "HelpUtilI.h"
  90. #include "PathAreaI.h"
  91. #include "HelpAccessI.h"
  92. #include "HourGlassI.h"
  93. #include "HyperTextI.h"
  94. #include "FileUtilsI.h"
  95. #include "Lock.h"
  96. /* search dialogs */
  97. #include "GlobSearchI.h"
  98. /* print dialogs */
  99. #include "PrintI.h"
  100. /* Error Messages Includes */
  101. #include "MessagesP.h"
  102. /* Quick Help Widget Inlcudes */
  103. #include "HelpQuickD.h"
  104. /* Display Area Includes */
  105. #include "XUICreateI.h"
  106. #include "CallbacksI.h"
  107. #include "DestroyI.h"
  108. #include "FormatI.h"
  109. #include "FormatManI.h"
  110. #include "SetListI.h"
  111. #include "ResizeI.h"
  112. /*********** Global Variables **********/
  113. /******** Messages *********/
  114. /* Help Dialog Error message Defines */
  115. #define HDMessage0 _DtHelpMsg_0000
  116. #define HDMessage1 _DtHelpMsg_0001
  117. #define HDMessage2 _DtHelpMsg_0002
  118. #define HDMessage3 _DtHelpMsg_0003
  119. #define HDMessage4 _DtHelpMsg_0004
  120. #define HDMessage5 _DtHelpMsg_0005
  121. #define HDMessage6 _DtHelpMsg_0006
  122. #define HDMessage7 _DtHelpMsg_0007
  123. #define HDMessage8 _DtHelpMsg_0008
  124. #define HDMessage9 _DtHelpMsg_0009
  125. /******** Static Function Declarations ********/
  126. static void NavigationTypeDefault(
  127. Widget widget,
  128. int offset,
  129. XrmValue *value) ;
  130. static void ClassPartInitialize(
  131. WidgetClass wc) ;
  132. static void ClassInitialize(
  133. void) ;
  134. static void Initialize(
  135. Widget rw,
  136. Widget nw,
  137. ArgList args,
  138. Cardinal *num_args);
  139. static void Destroy(
  140. Widget w );
  141. static Boolean SetValues(
  142. Widget cw,
  143. Widget rw,
  144. Widget nw,
  145. ArgList args,
  146. Cardinal *num_args);
  147. static void CloseHelpCB (
  148. Widget w,
  149. XtPointer clientData,
  150. XtPointer callData);
  151. static void BuildDisplayArea(
  152. Widget parent,
  153. DtHelpDialogWidget nw);
  154. static void ProcessJumpBack(
  155. DtHelpDialogWidget nw);
  156. static void VariableInitialize(
  157. DtHelpDialogWidget nw);
  158. static void CleanUpHelpDialog(
  159. Widget nw,
  160. int cleanUpKind);
  161. static void CatchClose(Widget widget);
  162. static void DisplayTopLevelCB(
  163. Widget w,
  164. XtPointer client_data,
  165. XtPointer call_data );
  166. static void CopyTextCB(
  167. Widget w,
  168. XtPointer clientData,
  169. XtPointer callData );
  170. static void DisplayPrintCB(
  171. Widget w,
  172. XtPointer client_data,
  173. XtPointer call_data );
  174. static void ProcessBMenuBackCB(
  175. Widget w,
  176. XtPointer clientData,
  177. XButtonEvent * event,
  178. Boolean *continueToDispatch);
  179. static void ProcessJumpReuse(
  180. Widget nw,
  181. DtHelpHyperTextStruct *hyperData);
  182. static Widget SetupHelpDialogMenus(
  183. Widget parent);
  184. static Widget CreatePopupMenu(
  185. Widget parent);
  186. static void ResizeHelpDialogCB (
  187. XtPointer clientData);
  188. static void InitialPopupCB(
  189. Widget w,
  190. XtPointer clientData,
  191. XtPointer callData);
  192. /******** End Static Function Declarations ********/
  193. /* Static variables */
  194. /* Supported resources for the HelpDialog Widget */
  195. static XtResource resources[] = {
  196. { DtNshowNewWindowButton,
  197. DtCShowNewWindowButton,
  198. XmRBoolean,
  199. sizeof(Boolean),
  200. XtOffset (DtHelpDialogWidget, help_dialog.menu.showDupBtn),
  201. XmRImmediate,
  202. (XtPointer) False
  203. },
  204. { DtNshowTopLevelButton,
  205. DtCShowTopLevelButton,
  206. XmRBoolean,
  207. sizeof(Boolean),
  208. XtOffset (DtHelpDialogWidget, help_dialog.browser.showTopLevelBtn),
  209. XmRImmediate,
  210. (XtPointer) False
  211. },
  212. {
  213. DtNscrollBarPolicy,
  214. DtCScrollBarPolicy, DtRDtScrollBarPolicy, sizeof (unsigned char),
  215. XtOffset (DtHelpDialogWidget, help_dialog.display.scrollBarPolicy),
  216. XmRImmediate, (XtPointer) DtHELP_AS_NEEDED_SCROLLBARS
  217. },
  218. {
  219. DtNexecutionPolicy,
  220. DtCExecutionPolicy, DtRDtExecutionPolicy, sizeof (unsigned char),
  221. XtOffset (DtHelpDialogWidget, help_dialog.display.executionPolicy),
  222. XmRImmediate, (XtPointer) DtHELP_EXECUTE_QUERY_UNALIASED
  223. },
  224. { DtNcolumns,
  225. DtCColumns, XmRShort, sizeof(short),
  226. XtOffset (DtHelpDialogWidget, help_dialog.display.textColumns),
  227. XmRImmediate, (XtPointer) 70
  228. },
  229. { DtNrows,
  230. DtCRows, XmRShort, sizeof(short),
  231. XtOffset (DtHelpDialogWidget, help_dialog.display.textRows),
  232. XmRImmediate, (XtPointer) 25
  233. },
  234. { DtNmarginWidth,
  235. DtCMarginWidth, XmRHorizontalDimension, sizeof (Dimension),
  236. XtOffset (DtHelpDialogWidget, help_dialog.ghelp.marginWidth),
  237. XmRImmediate, (XtPointer) 1
  238. },
  239. { DtNmarginHeight,
  240. DtCMarginHeight, XmRVerticalDimension, sizeof (Dimension),
  241. XtOffset (DtHelpDialogWidget, help_dialog.ghelp.marginHeight),
  242. XmRImmediate, (XtPointer) 4
  243. },
  244. { DtNvisiblePathCount,
  245. DtCVisiblePathCount, XmRInt, sizeof(int),
  246. XtOffset (DtHelpDialogWidget, help_dialog.browser.visiblePathCount),
  247. XmRImmediate, (XtPointer) 7
  248. },
  249. { DtNlocationId,
  250. DtCLocationId, XmRString, sizeof (char*),
  251. XtOffset (DtHelpDialogWidget, help_dialog.display.locationId),
  252. XmRImmediate, (XtPointer) _DtHelpDefaultLocationId
  253. },
  254. { DtNhelpPrint,
  255. DtCHelpPrint, XmRString, sizeof (char*),
  256. XtOffset (DtHelpDialogWidget, help_dialog.print.helpPrint),
  257. XmRImmediate, (XtPointer) _DtHelpDefaultHelpPrint
  258. },
  259. { DtNprinter,
  260. DtCPrinter, XmRString, sizeof (char*),
  261. XtOffset (DtHelpDialogWidget, help_dialog.print.printer),
  262. XmRImmediate, (XtPointer) NULL
  263. },
  264. { DtNpaperSize,
  265. DtCPaperSize, DtRDtPaperSize, sizeof (unsigned char),
  266. XtOffset (DtHelpDialogWidget, help_dialog.print.paperSize),
  267. XmRImmediate, (XtPointer) DtHELP_PAPERSIZE_LETTER
  268. },
  269. { DtNsrchHitPrefixFont,
  270. DtCSrchHitPrefixFont, XmRString, sizeof (char *),
  271. XtOffset (DtHelpDialogWidget, help_dialog.srch.hitPrefixFont),
  272. XmRImmediate, (XtPointer) _DtHelpDefaultSrchHitPrefixFont
  273. },
  274. { DtNhelpVolume,
  275. DtCHelpVolume, XmRString, sizeof (char*),
  276. XtOffset (DtHelpDialogWidget, help_dialog.display.helpVolume),
  277. XmRImmediate, (XtPointer) NULL
  278. },
  279. { DtNmanPage,
  280. DtCManPage, XmRString, sizeof (char*),
  281. XtOffset (DtHelpDialogWidget, help_dialog.display.manPage),
  282. XmRImmediate, (XtPointer) NULL
  283. },
  284. { DtNstringData,
  285. DtCStringData, XmRString, sizeof (char*),
  286. XtOffset (DtHelpDialogWidget, help_dialog.display.stringData),
  287. XmRImmediate, (XtPointer) NULL
  288. },
  289. { DtNhelpFile,
  290. DtCHelpFile, XmRString, sizeof (char*),
  291. XtOffset (DtHelpDialogWidget, help_dialog.display.helpFile),
  292. XmRImmediate, (XtPointer) NULL
  293. },
  294. { DtNtopicTitle,
  295. DtCTopicTitle, XmRString, sizeof (char*),
  296. XtOffset (DtHelpDialogWidget, help_dialog.display.topicTitleStr),
  297. XmRImmediate, (XtPointer) NULL
  298. },
  299. { DtNhelpOnHelpVolume,
  300. DtCHelpOnHelpVolume, XmRString, sizeof (char*),
  301. XtOffset (DtHelpDialogWidget, help_dialog.help.helpOnHelpVolume),
  302. XmRImmediate, (XtPointer) _DtHelpDefaultHelp4HelpVolume
  303. },
  304. { DtNhelpType,
  305. DtCHelpType, DtRDtHelpType, sizeof(unsigned char),
  306. XtOffset (DtHelpDialogWidget, help_dialog.display.helpType),
  307. XmRImmediate, (XtPointer) DtHELP_TYPE_TOPIC
  308. },
  309. { DtNhyperLinkCallback,
  310. DtCHyperLinkCallback, XmRCallback, sizeof (XtCallbackList),
  311. XtOffset (DtHelpDialogWidget, help_dialog.display.hyperLinkCallback),
  312. XmRImmediate, (XtPointer) NULL
  313. },
  314. { DtNcloseCallback,
  315. DtCCloseCallback, XmRCallback, sizeof (XtCallbackList),
  316. XtOffset (DtHelpDialogWidget, help_dialog.ghelp.closeCallback),
  317. XmRImmediate, (XtPointer) NULL
  318. },
  319. { XmNnavigationType, XmCNavigationType, XmRNavigationType,
  320. sizeof(unsigned char),
  321. XtOffsetOf (XmManagerRec, manager.navigation_type),
  322. XmRCallProc, (XtPointer) NavigationTypeDefault
  323. },
  324. };
  325. /*
  326. * attach the action list to the widget. Then it does not
  327. * matter which Xt[App]Initialize an application does.
  328. */
  329. static XtActionsRec DrawnBActions[] =
  330. {
  331. {"DeSelectAll" , _DtHelpDeSelectAll },
  332. {"SelectAll" , _DtHelpSelectAll },
  333. {"ActivateLink" , _DtHelpActivateLink },
  334. {"CopyToClipboard", _DtHelpCopyAction },
  335. {"PageUpOrDown" , _DtHelpPageUpOrDown },
  336. {"PageLeftOrRight", _DtHelpPageLeftOrRight},
  337. {"NextLink" , _DtHelpNextLink }
  338. };
  339. /****************************************************************
  340. *
  341. * Full class record constant
  342. *
  343. ****************************************************************/
  344. externaldef( dthelpdialogwidgetclassrec) DtHelpDialogWidgetClassRec dtHelpDialogWidgetClassRec =
  345. {
  346. { /* core_class fields */
  347. (WidgetClass) &xmBulletinBoardClassRec, /* superclass */
  348. "DtHelpDialog", /* class_name */
  349. sizeof(DtHelpDialogWidgetRec), /* widget_size */
  350. ClassInitialize, /* class_initialize */
  351. ClassPartInitialize, /* class_part_init */
  352. FALSE, /* class_inited */
  353. Initialize, /* initialize */
  354. NULL, /* initialize_hook */
  355. XtInheritRealize, /* realize */
  356. DrawnBActions, /* actions */
  357. XtNumber(DrawnBActions), /* num_actions */
  358. resources, /* resources */
  359. XtNumber(resources), /* num_resources */
  360. NULLQUARK, /* xrm_class */
  361. TRUE, /* compress_motion */
  362. XtExposeCompressMaximal, /* compress_exposure */
  363. FALSE, /* compress_enterlv */
  364. FALSE, /* visible_interest */
  365. Destroy, /* destroy */
  366. XtInheritResize, /* resize */
  367. XtInheritExpose, /* expose */
  368. SetValues, /* set_values */
  369. NULL, /* set_values_hook */
  370. XtInheritSetValuesAlmost, /* set_values_almost */
  371. NULL, /* get_values_hook */
  372. XtInheritAcceptFocus, /* enter_focus */
  373. XtVersion, /* version */
  374. NULL, /* callback_private */
  375. XtInheritTranslations, /* tm_table */
  376. XtInheritQueryGeometry, /* query_geometry */
  377. NULL, /* display_accelerator*/
  378. NULL, /* extension */
  379. },
  380. { /* composite_class fields */
  381. XtInheritGeometryManager, /* geometry_manager */
  382. XtInheritChangeManaged, /* change_managed */
  383. XtInheritInsertChild, /* insert_child */
  384. XtInheritDeleteChild, /* delete_child */
  385. NULL, /* extension */
  386. },
  387. { /* constraint_class fields */
  388. NULL, /* resource list */
  389. 0, /* num resources */
  390. 0, /* constraint size */
  391. NULL, /* init proc */
  392. NULL, /* destroy proc */
  393. NULL, /* set values proc */
  394. NULL, /* extension */
  395. },
  396. { /* manager_class fields */
  397. XmInheritTranslations, /* translations */
  398. NULL, /* syn_resources */
  399. 0, /* num_syn_resources */
  400. NULL, /* syn_cont_resources */
  401. 0, /* num_syn_cont_resources */
  402. XmInheritParentProcess, /* parent_process */
  403. NULL, /* extension */
  404. },
  405. { /* bulletinBoard class */
  406. TRUE, /*always_install_accelerators*/
  407. _DtHelpDialogWidgetGeoMatrixCreate, /* geo__matrix_create */
  408. XmInheritFocusMovedProc, /* focus_moved_proc */
  409. NULL /* extension */
  410. },
  411. { /* messageBox class - none */
  412. 0 /* mumble */
  413. }
  414. };
  415. externaldef( dthelpdialogwidgetclass) WidgetClass dtHelpDialogWidgetClass
  416. = (WidgetClass) &dtHelpDialogWidgetClassRec;
  417. static char *HelpTypeNames[] =
  418. { "help_type_topic",
  419. "help_type_string",
  420. "help_type_man_page",
  421. "help_type_file",
  422. "help_type_dynamic_string"
  423. };
  424. static char *ScrollBarValueNames[] =
  425. { "help_no_scrollbars",
  426. "help_static_scrollbars",
  427. "help_as_needed_scrollbars"
  428. };
  429. static char *ExecutionValueNames[] =
  430. { "help_execute_none",
  431. "help_execute_query_all",
  432. "help_execute_query_unaliased",
  433. "help_execute_all"
  434. };
  435. /* the _DtHelpPaperSizeNames[] are in Print.c */
  436. #define NUM_NAMES( list ) (sizeof( list) / sizeof( char *))
  437. /*********************************************************************
  438. *
  439. * NavigationTypeDefault
  440. *
  441. *
  442. *********************************************************************/
  443. static void
  444. NavigationTypeDefault(
  445. Widget widget,
  446. int offset, /* unused */
  447. XrmValue *value )
  448. {
  449. static XmNavigationType navigation_type;
  450. Widget parent = XtParent(widget) ;
  451. value->addr = (XPointer) &navigation_type;
  452. if (XtIsShell(parent)) {
  453. navigation_type = XmSTICKY_TAB_GROUP;
  454. } else {
  455. navigation_type = XmTAB_GROUP;
  456. }
  457. }
  458. /*****************************************************************************
  459. * Function: static void ClassInitialize (
  460. * void)
  461. *
  462. * Parameters: Void.
  463. *
  464. *
  465. * Return Value: Void.
  466. *
  467. * Purpose: Register our representation types here
  468. *
  469. *****************************************************************************/
  470. static void ClassInitialize(void)
  471. {
  472. XmRepTypeId checkId;
  473. /* First check to see if these have already been registered */
  474. checkId = XmRepTypeGetId(DtRDtScrollBarPolicy);
  475. if (checkId == XmREP_TYPE_INVALID)
  476. {
  477. /* Register the help representation types here */
  478. XmRepTypeRegister(DtRDtHelpType, HelpTypeNames, NULL,
  479. NUM_NAMES(HelpTypeNames)) ;
  480. XmRepTypeRegister(DtRDtScrollBarPolicy, ScrollBarValueNames, NULL,
  481. NUM_NAMES(ScrollBarValueNames)) ;
  482. XmRepTypeRegister(DtRDtExecutionPolicy, ExecutionValueNames, NULL,
  483. NUM_NAMES(ExecutionValueNames)) ;
  484. XmRepTypeRegister(DtRDtPaperSize, _DtHelpPaperSizeNames, NULL,
  485. _DtHelpPaperSizeNamesCnt) ;
  486. }
  487. return ;
  488. }
  489. /*****************************************************************************
  490. * Function: static void ClassPartInitialize (
  491. * WidgetClass widgetClass)
  492. *
  493. * Parameters: WidgetClass
  494. *
  495. *
  496. * Return Value: Void.
  497. *
  498. * Purpose:
  499. *
  500. *****************************************************************************/
  501. static void ClassPartInitialize(
  502. WidgetClass widgetClass)
  503. {
  504. return ;
  505. }
  506. /*****************************************************************************
  507. * Function: static void VariableInitialize()
  508. *
  509. *
  510. * Return Value: Void.
  511. *
  512. * Purpose: This routine initializes all global variables to valid
  513. * starting values.
  514. *
  515. *****************************************************************************/
  516. static void VariableInitialize(
  517. DtHelpDialogWidget nw)
  518. {
  519. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  520. /* Set our current topic variables to initial values */
  521. _DtHelpCommonHelpInit(&hw->help_dialog.help);
  522. /* Make local copies of all resource strings assigned by the user */
  523. if (hw->help_dialog.display.locationId != NULL)
  524. hw->help_dialog.display.locationId = XtNewString(hw->help_dialog.display.locationId);
  525. if (hw->help_dialog.display.helpVolume != NULL)
  526. hw->help_dialog.display.helpVolume = XtNewString(hw->help_dialog.display.helpVolume);
  527. if (hw->help_dialog.display.manPage != NULL)
  528. hw->help_dialog.display.manPage = XtNewString(hw->help_dialog.display.manPage);
  529. if (hw->help_dialog.display.stringData != NULL)
  530. hw->help_dialog.display.stringData = XtNewString(hw->help_dialog.display.stringData);
  531. if (hw->help_dialog.display.helpFile != NULL)
  532. hw->help_dialog.display.helpFile = XtNewString(hw->help_dialog.display.helpFile);
  533. /*
  534. * Initialize the topic title variables.
  535. */
  536. hw->help_dialog.display.count = 1;
  537. hw->help_dialog.display.topicTitleLbl = NULL;
  538. if (hw->help_dialog.display.topicTitleStr != NULL)
  539. hw->help_dialog.display.topicTitleStr =
  540. XtNewString(hw->help_dialog.display.topicTitleStr);
  541. else
  542. hw->help_dialog.display.topicTitleStr =
  543. XtNewString((char *)_DTGETMESSAGE(2, 70,
  544. "Nonexistent Topic Title."));
  545. /*
  546. * create the XmString version
  547. */
  548. if (hw->help_dialog.display.topicTitleStr != NULL)
  549. hw->help_dialog.display.topicTitleLbl = XmStringCreateLocalized(
  550. hw->help_dialog.display.topicTitleStr);
  551. if (hw->help_dialog.print.printer != NULL)
  552. hw->help_dialog.print.printer = XtNewString(hw->help_dialog.print.printer);
  553. if (hw->help_dialog.print.helpPrint != _DtHelpDefaultHelpPrint)
  554. hw->help_dialog.print.helpPrint = XtNewString(hw->help_dialog.print.helpPrint);
  555. hw->bulletin_board.auto_unmanage = FALSE;
  556. hw->bulletin_board.resize_policy = XmRESIZE_NONE;
  557. /* Setup some of our generic widget variables */
  558. hw->help_dialog.print.printVolume = NULL;
  559. /* Set our volume handle to an NULL initial value */
  560. hw->help_dialog.display.volumeHandle = NULL;
  561. hw->help_dialog.ghelp.volumeFlag = FALSE;
  562. _DtHelpGlobSrchInitVars(&hw->help_dialog.srch);
  563. /* Set our print display stuff to initial values */
  564. hw->help_dialog.print.printForm = NULL;
  565. /* Set our map flag: true after we hit our popup callback,
  566. * false otherwise
  567. */
  568. hw->help_dialog.display.firstTimePopupFlag = FALSE;
  569. /* Set our history display stuff to initial vlaues */
  570. hw->help_dialog.history.historyWidget = NULL;
  571. hw->help_dialog.history.volumeList = NULL;
  572. hw->help_dialog.history.topicList = NULL;
  573. hw->help_dialog.history.pHistoryListHead = NULL;
  574. /* Set our path display stuff to initial values */
  575. hw->help_dialog.history.pPathListHead = NULL;
  576. hw->help_dialog.history.pPathListTale = NULL;
  577. hw->help_dialog.history.totalPathNodes = 0;
  578. /* Set our jump list display stuff to initial values */
  579. hw->help_dialog.backtr.pJumpListHead = NULL;
  580. hw->help_dialog.backtr.pJumpListTale = NULL;
  581. hw->help_dialog.backtr.totalJumpNodes = 0;
  582. hw->help_dialog.backtr.scrollPosition = -1;
  583. /* Set our help dialog widgets to NULL starting values */
  584. hw->help_dialog.menu.menuBar = NULL;
  585. hw->help_dialog.browser.panedWindow = NULL;
  586. hw->help_dialog.browser.pathArea = NULL;
  587. hw->help_dialog.menu.topBtn = NULL;
  588. hw->help_dialog.menu.popupTopBtn = NULL;
  589. hw->help_dialog.menu.keyBtn = NULL;
  590. hw->help_dialog.menu.backBtn = NULL;
  591. hw->help_dialog.menu.popupBackBtn = NULL;
  592. hw->help_dialog.menu.historyBtn = NULL;
  593. hw->help_dialog.menu.printBtn = NULL;
  594. hw->help_dialog.menu.closeBtn = NULL;
  595. hw->help_dialog.menu.helpBtn = NULL;
  596. hw->help_dialog.ghelp.definitionBox = NULL;
  597. hw->help_dialog.menu.newWindowBtn = NULL;
  598. hw->help_dialog.browser.btnBoxBackBtn = NULL;
  599. hw->help_dialog.browser.btnBoxHistoryBtn = NULL;
  600. hw->help_dialog.browser.btnBoxIndexBtn = NULL;
  601. /* Set our parentId to a null starting value */
  602. hw->help_dialog.ghelp.parentId = NULL;
  603. }
  604. /*****************************************************************************
  605. * Function: static void Initialize (
  606. * WidgetClass widgetClass)
  607. *
  608. * Parameters: WidgetClass
  609. *
  610. *
  611. * Return Value: Void.
  612. *
  613. * Purpose: This is the Help Dialog widget initialize routine. This
  614. * routine is responsible for the following:
  615. * 1) Validate all resources the user passed in.
  616. * 2) Over ride any invalid resources.
  617. * 3) Build the internal UI component for the Help Dialog.
  618. * 4) Add any internal callbacks for the UI components.
  619. *
  620. *****************************************************************************/
  621. static void Initialize(
  622. Widget rw,
  623. Widget nw,
  624. ArgList args_init,
  625. Cardinal *num_args)
  626. {
  627. Arg args[10]; /* arg list */
  628. int n; /* arg count */
  629. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  630. /* Local variables */
  631. DtHelpListStruct *pHelpInfo;
  632. /* Initialize all global variables */
  633. VariableInitialize(hw);
  634. /* Validate the incoming arguments to make sure they are ok */
  635. /* Build the Menus bar */
  636. hw->help_dialog.menu.menuBar = SetupHelpDialogMenus((Widget)hw);
  637. /* Build the Paned Window to hold the path area and display area */
  638. n = 0;
  639. XtSetArg (args[n], XmNspacing, 10); ++n;
  640. hw->help_dialog.browser.panedWindow =
  641. XmCreatePanedWindow ((Widget)hw, "panedWindow", args, n);
  642. XtManageChild (hw->help_dialog.browser.panedWindow);
  643. /* Call the setup routine to build the actual path area */
  644. _DtHelpBuildPathArea(hw->help_dialog.browser.panedWindow, hw);
  645. /* Force our keyboard traversal to start within the path area */
  646. /*
  647. * NOTE 04/25/96 : pathArea is NOT set by _DtHelpBuildPathArea().
  648. * The test for NULL is a work-around for defect CDExc20246; but
  649. * the proper widget should be given to XmProcessTraversal() someday.
  650. */
  651. if (hw->help_dialog.browser.pathArea != (Widget)NULL)
  652. XmProcessTraversal(hw->help_dialog.browser.pathArea, XmTRAVERSE_HOME);
  653. /* We build our display area last because we need the other UI
  654. * components created first.
  655. */
  656. /* Call the setup routine to build the display area */
  657. BuildDisplayArea(hw->help_dialog.browser.panedWindow, hw);
  658. /* Add the proper help callback to the top level shell of our dialog */
  659. /* Add all our help callbacks for each of the created widgets */
  660. pHelpInfo = _DtHelpListAdd(DtHELP_dialogShell_STR,
  661. (Widget) hw, &hw->help_dialog.help,
  662. &hw->help_dialog.help.pHelpListHead);
  663. XtAddCallback((Widget) hw, XmNhelpCallback,
  664. _DtHelpCB, (XtPointer) pHelpInfo);
  665. /* Just for fun, lets make sure our sizes are correct */
  666. XtAddCallback (XtParent(hw), XmNpopupCallback, (XtCallbackProc)
  667. InitialPopupCB, (XtPointer) hw);
  668. return;
  669. }
  670. /****************************************************************************
  671. * Function: static XtCallbackProc InitialPopupCB
  672. *
  673. *
  674. *
  675. * Parameters:
  676. *
  677. * Return Value: Void.
  678. *
  679. * Purpose: We do some last minute sizing of our dialog on its first
  680. * mapping, then we remove the callback.
  681. *
  682. ****************************************************************************/
  683. static void InitialPopupCB(
  684. Widget w,
  685. XtPointer clientData,
  686. XtPointer callData)
  687. {
  688. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
  689. /* set our firstTimePopupFlag to TRUE because we map it right after
  690. this call */
  691. hw->help_dialog.display.firstTimePopupFlag = TRUE;
  692. _DtHelpResizeDisplayArea (XtParent(hw),
  693. hw->help_dialog.help.pDisplayArea,
  694. hw->help_dialog.display.textRows,
  695. hw->help_dialog.display.textColumns);
  696. XtRemoveCallback (XtParent(hw), XmNpopupCallback, (XtCallbackProc)
  697. InitialPopupCB, (XtPointer) hw);
  698. }
  699. /*****************************************************************************
  700. * Function: static Boolean SetValues(
  701. * Widget cw,
  702. * Widget rw,
  703. * Widget nw,
  704. * ArgList args,
  705. * Cardinal *num_args )
  706. *
  707. * Parameters: cw Specifies the current working widget.
  708. * rw Specifies the replacement working widget.
  709. * nw Specifies the new widget.
  710. * args Specifies the arguments to be applied to the
  711. * New widget.
  712. * numArgs Number of argument/value pars in args.
  713. *
  714. * Return Value:
  715. *
  716. * Purpose: Set the attributes of the Help Dialog widget.
  717. *
  718. *****************************************************************************/
  719. static Boolean SetValues(
  720. Widget cw,
  721. Widget rw,
  722. Widget nw,
  723. ArgList args,
  724. Cardinal *numArgs)
  725. {
  726. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  727. DtHelpDialogWidget current = (DtHelpDialogWidget) cw ;
  728. Boolean updateRequest=FALSE;
  729. Boolean newTitle=FALSE;
  730. /* Validate the incoming arguments to make sure they are ok */
  731. /* Setup some initial argument values we know we need on the B-board */
  732. hw->bulletin_board.auto_unmanage = FALSE;
  733. hw->bulletin_board.resize_policy = XmRESIZE_NONE;
  734. /* Check DtNcolumns & or DtNrows resource for change */
  735. if ((current->help_dialog.display.textRows != hw->help_dialog.display.textRows) ||
  736. (current->help_dialog.display.textColumns != hw->help_dialog.display.textColumns))
  737. {
  738. /* Perform a resize on our display area */
  739. _DtHelpResizeDisplayArea (XtParent(hw),
  740. hw->help_dialog.help.pDisplayArea,
  741. hw->help_dialog.display.textRows,
  742. hw->help_dialog.display.textColumns);
  743. }
  744. /* Check DtNhelpVolume resource for change */
  745. if (current->help_dialog.display.helpVolume != hw->help_dialog.display.helpVolume)
  746. {
  747. hw->help_dialog.display.helpVolume = XtNewString(hw->help_dialog.display.helpVolume);
  748. XtFree(current->help_dialog.display.helpVolume);
  749. /* Update our volumeFlag so we know to resolve our new help volume */
  750. hw->help_dialog.ghelp.volumeFlag=FALSE;
  751. updateRequest = TRUE;
  752. }
  753. /* Check DtNlocationId resource for change */
  754. if (current->help_dialog.display.locationId != hw->help_dialog.display.locationId)
  755. {
  756. hw->help_dialog.display.locationId = XtNewString(hw->help_dialog.display.locationId);
  757. XtFree(current->help_dialog.display.locationId);
  758. updateRequest = TRUE;
  759. }
  760. /* set the printing resources */
  761. _DtHelpPrintSetValues(&current->help_dialog.print,&hw->help_dialog.print,
  762. &hw->help_dialog.display,&hw->help_dialog.help);
  763. /* Check XmhelpOnHelpVolume resource for change */
  764. if (current->help_dialog.help.helpOnHelpVolume !=
  765. hw->help_dialog.help.helpOnHelpVolume)
  766. {
  767. hw->help_dialog.help.helpOnHelpVolume =
  768. XtNewString(hw->help_dialog.help.helpOnHelpVolume);
  769. if (current->help_dialog.help.helpOnHelpVolume != _DtHelpDefaultHelp4HelpVolume)
  770. XtFree(current->help_dialog.help.helpOnHelpVolume);
  771. }
  772. /* Check DtNmanPage resource for change */
  773. if (current->help_dialog.display.manPage != hw->help_dialog.display.manPage)
  774. {
  775. hw->help_dialog.display.manPage = XtNewString(hw->help_dialog.display.manPage);
  776. XtFree(current->help_dialog.display.manPage);
  777. updateRequest = TRUE;
  778. newTitle = TRUE;
  779. }
  780. /* Check DtNstringData resource for change */
  781. if (current->help_dialog.display.stringData != hw->help_dialog.display.stringData)
  782. {
  783. hw->help_dialog.display.stringData = XtNewString(hw->help_dialog.display.stringData);
  784. XtFree(current->help_dialog.display.stringData);
  785. updateRequest = TRUE;
  786. newTitle = TRUE;
  787. }
  788. /* Check DtNhelpFile resource for change */
  789. if (current->help_dialog.display.helpFile != hw->help_dialog.display.helpFile)
  790. {
  791. hw->help_dialog.display.helpFile = XtNewString(hw->help_dialog.display.helpFile);
  792. XtFree(current->help_dialog.display.helpFile);
  793. updateRequest = TRUE;
  794. newTitle = TRUE;
  795. }
  796. /* Check DtNtopicTitle resource for change */
  797. if (hw->help_dialog.display.topicTitleStr != NULL &&
  798. current->help_dialog.display.topicTitleStr !=
  799. hw->help_dialog.display.topicTitleStr)
  800. {
  801. /*
  802. * copy the string and make a XmString version.
  803. */
  804. hw->help_dialog.display.topicTitleStr =
  805. XtNewString(hw->help_dialog.display.topicTitleStr);
  806. XtFree(current->help_dialog.display.topicTitleStr);
  807. updateRequest = TRUE;
  808. newTitle = TRUE;
  809. }
  810. else if (newTitle == True)
  811. {
  812. /*
  813. * A new file, string or man page has been specified.
  814. * But XmNtopicTitle has not been set or set to null (otherwise
  815. * the if stmt would have been true). Therefore, create a new
  816. * title for this entry for history and topic labels.
  817. */
  818. int len;
  819. char *str;
  820. str = (char *)_DTGETMESSAGE(2, 70, "Nonexistent Topic Title.");
  821. len = strlen(str);
  822. hw->help_dialog.display.topicTitleStr = XtMalloc(sizeof(char)*(len+10));
  823. if (NULL != hw->help_dialog.display.topicTitleStr)
  824. {
  825. sprintf(hw->help_dialog.display.topicTitleStr, "%s%d", str,
  826. hw->help_dialog.display.count++);
  827. newTitle = TRUE;
  828. }
  829. }
  830. /*
  831. * Turn the string into an XmString and free the old
  832. */
  833. if (newTitle == TRUE)
  834. {
  835. hw->help_dialog.display.topicTitleLbl = XmStringCreateLocalized(
  836. hw->help_dialog.display.topicTitleStr);
  837. if (current->help_dialog.display.topicTitleLbl != NULL)
  838. XmStringFree(current->help_dialog.display.topicTitleLbl);
  839. }
  840. /* Check the help type for change */
  841. if (current->help_dialog.display.helpType != hw->help_dialog.display.helpType
  842. || updateRequest)
  843. {
  844. /* Setup and display our new topic */
  845. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
  846. }
  847. return(FALSE);
  848. }
  849. /*****************************************************************************
  850. * Function: static void Destroy(Widget w );
  851. *
  852. * Parameters: w Specifies the widget to be destroyed.
  853. *
  854. * Return Value:
  855. *
  856. * Purpose: Destroy any internally malloced memory.
  857. *
  858. *****************************************************************************/
  859. static void Destroy(
  860. Widget w)
  861. {
  862. DtHelpDialogWidget hw = (DtHelpDialogWidget) w;
  863. /* This routine will clean up all malloc'ed stuff in our instance
  864. * structure. It does not remove any callbacks or delete any of the
  865. * widgets created in this instance of the help dialog.
  866. */
  867. CleanUpHelpDialog((Widget) hw, DtCLEAN_FOR_DESTROY);
  868. /* Remove any of the callbacks added to the help dialog ??? */
  869. }
  870. /*****************************************************************************
  871. * Function: static void MenuBarFix(
  872. * XmGeoMatrix geoSpec,
  873. * int action,
  874. * XmGeoRowLayout layoutPtr,
  875. * XmKidGeometry rowPtr)
  876. *
  877. *
  878. *
  879. * Parameters:
  880. *
  881. * Return Value:
  882. *
  883. * Purpose: This routine is a fixup routine which can be used for rows
  884. * which consist of a single MenuBar RowColumn. The effect of
  885. * this routine is to have the RowColumn ignore the margin
  886. * width and height.
  887. *
  888. *****************************************************************************/
  889. static void MenuBarFix(
  890. XmGeoMatrix geoSpec,
  891. int action,
  892. XmGeoMajorLayout layoutPtr,
  893. XmKidGeometry rowPtr )
  894. {
  895. Dimension marginW ;
  896. Dimension marginH ;
  897. Dimension twoMarginW ;
  898. marginW = geoSpec->margin_w ;
  899. twoMarginW = (marginW << 1) ;
  900. marginH = geoSpec->margin_h ;
  901. switch( action )
  902. {
  903. case XmGEO_PRE_SET:
  904. { rowPtr->box.x -= marginW ;
  905. rowPtr->box.width += twoMarginW ;
  906. rowPtr->box.y -= marginH ;
  907. break ;
  908. }
  909. default:
  910. { if( rowPtr->box.width > twoMarginW )
  911. {
  912. /* Avoid subtracting a margin from box width which would
  913. * result in underflow.
  914. */
  915. rowPtr->box.x += marginW ;
  916. rowPtr->box.width -= twoMarginW ;
  917. }
  918. if( action == XmGET_PREFERRED_SIZE )
  919. {
  920. /* Set width to some small value so it does not
  921. * effect total width of matrix.
  922. */
  923. rowPtr->box.width = 1 ;
  924. }
  925. break ;
  926. }
  927. }
  928. return ;
  929. }
  930. /*****************************************************************************
  931. * Function: XmGeoMatrix _DtHelpDialogWidgeGeoMatrixCreate(
  932. * Widget wid,
  933. * Widget instigator,
  934. * XtWidgetGeometry *desired)
  935. *
  936. * Parameters:
  937. *
  938. * Return Value:
  939. *
  940. * Purpose: This routine is responsible for all the positioning of the
  941. * the internal Help Dialog widgets.
  942. *
  943. *****************************************************************************/
  944. XmGeoMatrix _DtHelpDialogWidgetGeoMatrixCreate(
  945. Widget wid,
  946. Widget instigator,
  947. XtWidgetGeometry *desired )
  948. {
  949. DtHelpDialogWidget hw = (DtHelpDialogWidget) wid ;
  950. XmGeoMatrix geoSpec ;
  951. XmGeoRowLayout layoutPtr ;
  952. XmKidGeometry boxPtr ;
  953. geoSpec = _XmGeoMatrixAlloc( TB_MAX_WIDGETS_VERT, TB_MAX_NUM_WIDGETS, 0) ;
  954. geoSpec->composite = (Widget) hw ;
  955. geoSpec->instigator = (Widget) instigator ;
  956. if( desired )
  957. { geoSpec->instig_request = *desired ;
  958. }
  959. geoSpec->margin_w = hw->help_dialog.ghelp.marginWidth
  960. + hw->manager.shadow_thickness ;
  961. geoSpec->margin_h = hw->help_dialog.ghelp.marginHeight
  962. + hw->manager.shadow_thickness ;
  963. geoSpec->no_geo_request = _DtHelpDialogWidgetNoGeoRequest ;
  964. layoutPtr = (XmGeoRowLayout) geoSpec->layouts ;
  965. boxPtr = geoSpec->boxes ;
  966. /* Menubar setup stuff */
  967. if( _XmGeoSetupKid( boxPtr, hw->help_dialog.menu.menuBar))
  968. {
  969. layoutPtr->fix_up = MenuBarFix;
  970. boxPtr += 2;
  971. ++layoutPtr;
  972. }
  973. /* Display area setup stuff */
  974. if( _XmGeoSetupKid(boxPtr, hw->help_dialog.browser.panedWindow))
  975. {
  976. layoutPtr->space_above = 0;
  977. layoutPtr->stretch_height = TRUE ;
  978. layoutPtr->min_height = 100 ;
  979. boxPtr += 2 ; /* For new row, add 2. */
  980. ++layoutPtr ; /* For new row. */
  981. }
  982. layoutPtr->space_above = hw->help_dialog.ghelp.marginWidth;
  983. layoutPtr->end = TRUE ; /* Mark the last row. */
  984. return( geoSpec) ;
  985. }
  986. /*****************************************************************************
  987. * Function: Boolean _DtHelpDialogWidgetNoGeoRequest(geoSpec)
  988. * XmGeoMatrix geoSpec)
  989. *
  990. *
  991. * Parameters:
  992. *
  993. * Return Value:
  994. *
  995. * Purpose:
  996. *
  997. ****************************************************************************/
  998. Boolean _DtHelpDialogWidgetNoGeoRequest(XmGeoMatrix geoSpec)
  999. {
  1000. if( BB_InSetValues( geoSpec->composite)
  1001. && (XtClass( geoSpec->composite) == dtHelpDialogWidgetClass) )
  1002. {
  1003. return( TRUE) ;
  1004. }
  1005. return( FALSE) ;
  1006. }
  1007. /*****************************************************************************
  1008. * Function: static void DisplayTopLevelCB(
  1009. * Widget w,
  1010. * XtPointer client_data,
  1011. * XtPointer call_data);
  1012. *
  1013. * Parameters:
  1014. *
  1015. * Return Value:
  1016. *
  1017. * Purpose: causes the top level topic to be displayed.
  1018. *
  1019. ****************************************************************************/
  1020. static void DisplayTopLevelCB(
  1021. Widget w,
  1022. XtPointer client_data,
  1023. XtPointer call_data )
  1024. {
  1025. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1026. /* Display the top level topic */
  1027. if (hw->help_dialog.help.topLevelId != NULL)
  1028. _DtHelpUpdateDisplayArea(hw->help_dialog.help.topLevelId, hw, TRUE,
  1029. DtHISTORY_AND_JUMP, DtHELP_TYPE_TOPIC);
  1030. else
  1031. _DtHelpUpdateDisplayArea(NULL, hw, TRUE, DtHISTORY_AND_JUMP,
  1032. DtHELP_TYPE_TOPIC);
  1033. }
  1034. /*****************************************************************************
  1035. * Function: extern void _DtHelpDisplayBackCB(
  1036. * Widget w,
  1037. * XtPointer client_data,
  1038. * XtPointer call_data);
  1039. *
  1040. * Parameters:
  1041. *
  1042. * Return Value:
  1043. *
  1044. * Purpose: This routine will cause the top element in the jump
  1045. * stack to be displayed.
  1046. *
  1047. ****************************************************************************/
  1048. void _DtHelpDisplayBackCB(
  1049. Widget w,
  1050. XtPointer client_data,
  1051. XtPointer call_data)
  1052. {
  1053. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1054. ProcessJumpBack(hw);
  1055. }
  1056. /*****************************************************************************
  1057. * Function: extern void _DtHelpDuplicateWindowCB(
  1058. * Widget w,
  1059. * XtPointer client_data,
  1060. * XtPointer call_data);
  1061. *
  1062. * Parameters:
  1063. *
  1064. * Return Value:
  1065. *
  1066. * Purpose: This routine creates a new help widget by forcing the
  1067. * equivelent of a Jump New hyper text call
  1068. *
  1069. ****************************************************************************/
  1070. void _DtHelpDuplicateWindowCB(
  1071. Widget w,
  1072. XtPointer clientData,
  1073. XtPointer callData)
  1074. {
  1075. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
  1076. DtHelpDialogCallbackStruct callDataStruct;
  1077. /* Setup the DtHelpHyperProcStruct to pass back
  1078. * to the client as callData
  1079. */
  1080. _DtHelpTurnOnHourGlass(XtParent(hw));
  1081. if (hw->help_dialog.display.hyperLinkCallback != NULL)
  1082. {
  1083. /* Use the old one */
  1084. callDataStruct.helpVolume = XtNewString
  1085. (hw->help_dialog.display.helpVolume);
  1086. callDataStruct.reason = DtCR_HELP_LINK_ACTIVATE;
  1087. callDataStruct.event = NULL; /* should be hyperData->event */
  1088. callDataStruct.locationId = XtNewString
  1089. (hw->help_dialog.display.locationId);
  1090. callDataStruct.specification = NULL;
  1091. callDataStruct.hyperType = DtHELP_LINK_TOPIC;
  1092. callDataStruct.windowHint = DtHELP_NEW_WINDOW;
  1093. XtCallCallbackList((Widget)hw,hw->help_dialog.display.hyperLinkCallback,
  1094. &callDataStruct);
  1095. }
  1096. else
  1097. { /* The application did not register a hypertext callback so
  1098. * we must generate the proper warning message and continue!
  1099. */
  1100. XmeWarning((Widget)hw, (char*) HDMessage6);
  1101. }
  1102. _DtHelpTurnOffHourGlass(XtParent(hw));
  1103. }
  1104. /*****************************************************************************
  1105. * Function: static void CopyTextCB(
  1106. * Widget w,
  1107. * XtPointer client_data,
  1108. * XtPointer call_data);
  1109. *
  1110. * Parameters:
  1111. *
  1112. * Return Value:
  1113. *
  1114. * Purpose: This routine will cause the display area to copy text to
  1115. * the clip-board.
  1116. *
  1117. ****************************************************************************/
  1118. static void CopyTextCB(
  1119. Widget w,
  1120. XtPointer clientData,
  1121. XtPointer callData)
  1122. {
  1123. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
  1124. _DtHelpInitiateClipboard(hw->help_dialog.help.pDisplayArea);
  1125. }
  1126. /*****************************************************************************
  1127. * Function: static void ProcessBMenuBackCB(
  1128. * Widget w,
  1129. * XtPointer client_data,
  1130. * XtPointer call_data);
  1131. *
  1132. * Parameters:
  1133. *
  1134. * Return Value:
  1135. *
  1136. * Purpose: This routine will cause the top element in the jump
  1137. * stack to be displayed, if their is a top element.
  1138. *
  1139. ****************************************************************************/
  1140. static void ProcessBMenuBackCB(
  1141. Widget w,
  1142. XtPointer clientData,
  1143. XButtonEvent * event,
  1144. Boolean *continueToDispatch)
  1145. {
  1146. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
  1147. XmMenuPosition(hw->help_dialog.menu.popupMenu, event);
  1148. XtManageChild(hw->help_dialog.menu.popupMenu);
  1149. }
  1150. /*****************************************************************************
  1151. * Function: extern void _DtHelpDisplayHistoryCB(
  1152. * Widget w,
  1153. * XtPointer client_data,
  1154. * XtPointer call_data);
  1155. *
  1156. * Parameters:
  1157. *
  1158. * Return Value:
  1159. *
  1160. * Purpose: This routine will cause the history dialog to be
  1161. * posted.
  1162. *
  1163. ****************************************************************************/
  1164. void _DtHelpDisplayHistoryCB(
  1165. Widget w,
  1166. XtPointer client_data,
  1167. XtPointer call_data )
  1168. {
  1169. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1170. XmUpdateDisplay((Widget) hw);
  1171. _DtHelpTurnOnHourGlass(XtParent(hw));
  1172. _DtHelpDisplayHistoryInfo((Widget)hw);
  1173. _DtHelpTurnOffHourGlass(XtParent(hw));
  1174. }
  1175. /*****************************************************************************
  1176. * Function: void _DtHelpDisplayBrowserHomeCB(
  1177. * Widget w,
  1178. * XtPointer client_data,
  1179. * XtPointer call_data);
  1180. *
  1181. * Parameters:
  1182. *
  1183. * Return Value:
  1184. *
  1185. * Purpose: This routine will cause the top level of the browser.hv
  1186. * help volume to be displayed.
  1187. *
  1188. ****************************************************************************/
  1189. void _DtHelpDisplayBrowserHomeCB(
  1190. Widget w,
  1191. XtPointer client_data,
  1192. XtPointer call_data )
  1193. {
  1194. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1195. XmUpdateDisplay((Widget) hw);
  1196. /* ??? Check to see if help volume is always fully expanded at this point
  1197. * ??? if so, we will never have a match.
  1198. */
  1199. if ( hw->help_dialog.display.helpVolume == NULL
  1200. || strstr (hw->help_dialog.display.helpVolume, DtBROWSER_NAME) == NULL)
  1201. {
  1202. XtFree(hw->help_dialog.display.helpVolume);
  1203. hw->help_dialog.display.helpVolume = XtNewString(DtBROWSER_NAME);
  1204. /* Set our help volume flag so we open the proper volume */
  1205. hw->help_dialog.ghelp.volumeFlag = FALSE;
  1206. }
  1207. XtFree(hw->help_dialog.display.locationId);
  1208. hw->help_dialog.display.locationId = XtNewString(DtBROWSER_HOME);
  1209. hw->help_dialog.display.helpType = DtHELP_TYPE_TOPIC;
  1210. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
  1211. }
  1212. /*****************************************************************************
  1213. * Function: void _DtHelpDisplayIndexCB(
  1214. * Widget w,
  1215. * XtPointer client_data,
  1216. * XtPointer call_data);
  1217. *
  1218. * Parameters:
  1219. *
  1220. * Return Value:
  1221. *
  1222. * Purpose: This routine will cause the index dialog to be
  1223. * posted.
  1224. *
  1225. ****************************************************************************/
  1226. void _DtHelpDisplayIndexCB(
  1227. Widget w,
  1228. XtPointer client_data,
  1229. XtPointer call_data )
  1230. {
  1231. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1232. XmUpdateDisplay((Widget) hw);
  1233. _DtHelpTurnOnHourGlass(XtParent(hw));
  1234. /* display the index search dialog */
  1235. _DtHelpGlobSrchDisplayDialog((Widget)hw,NULL,hw->help_dialog.display.helpVolume);
  1236. _DtHelpTurnOffHourGlass(XtParent(hw));
  1237. }
  1238. /*****************************************************************************
  1239. * Function: static void DisplayPrintCB(
  1240. * Widget w,
  1241. * XtPointer client_data,
  1242. * XtPointer call_data);
  1243. *
  1244. * Parameters:
  1245. *
  1246. * Return Value:
  1247. *
  1248. * Purpose: This routine will cause the history dialog to be
  1249. * posted.
  1250. *
  1251. ****************************************************************************/
  1252. static void DisplayPrintCB(
  1253. Widget w,
  1254. XtPointer client_data,
  1255. XtPointer call_data )
  1256. {
  1257. DtHelpDialogWidget hw = (DtHelpDialogWidget) client_data;
  1258. XmUpdateDisplay((Widget) hw);
  1259. _DtHelpTurnOnHourGlass(XtParent(hw));
  1260. /* display the print dialog */
  1261. _DtHelpDisplayPrintDialog((Widget) hw,&hw->help_dialog.print,
  1262. &hw->help_dialog.display,&hw->help_dialog.help);
  1263. _DtHelpTurnOffHourGlass(XtParent(hw));
  1264. }
  1265. /*****************************************************************************
  1266. * Function: Widget DtCreateHelpDialog(Widget parent,
  1267. * String name,
  1268. * ArgList arglist,
  1269. * Cardinal argcount);
  1270. *
  1271. * Parameters: parent Specifies the parent widget ID.
  1272. * name Specifies the name of the created dialog
  1273. * shell widget.
  1274. * arglis Specifies the argument list.
  1275. * argcount Specifies the number of attribute/value pairs
  1276. * in the argument list (arglist).
  1277. *
  1278. * Return Value: Returns a Help Dialog shell widget ID.
  1279. *
  1280. * Purpose: Create an instance of a Help Dialog.
  1281. *
  1282. *****************************************************************************/
  1283. Widget DtCreateHelpDialog(
  1284. Widget parent,
  1285. char *name,
  1286. ArgList al,
  1287. Cardinal ac)
  1288. {
  1289. Widget w;
  1290. _DtHelpWidgetToAppContext(parent);
  1291. _DtHelpAppLock(app);
  1292. w = XmeCreateClassDialog (dtHelpDialogWidgetClass, parent, name, al, ac);
  1293. /* Add the CatchClose here so we catch the window manager close requests */
  1294. CatchClose(w);
  1295. _DtHelpAppUnlock(app);
  1296. return w;
  1297. }
  1298. /*****************************************************************************
  1299. * Function: _DtHelpFilterExecCmdCB
  1300. *
  1301. * clientData: The general help dialog widget
  1302. * cmdStr: cmd string to filter
  1303. * ret_filteredCmdStr: string after filtering. NULL if exec denied
  1304. *
  1305. * Return Value: 0: ok, < 0: error
  1306. *
  1307. * Purpose: filter an execution command using executionPolicy rsrc
  1308. *
  1309. * Memory:
  1310. * The caller must free memory allocated for the ret_filteredCmdStr
  1311. *****************************************************************************/
  1312. int _DtHelpFilterExecCmdCB(
  1313. void * clientData,
  1314. const char * cmdStr,
  1315. char * * ret_filteredCmdStr)
  1316. {
  1317. DtHelpDialogWidget hw;
  1318. char *hv_path;
  1319. hw = (DtHelpDialogWidget) _DtHelpDisplayAreaData(clientData);
  1320. hv_path = _DtHelpFileLocate(DtHelpVOLUME_TYPE,
  1321. hw->help_dialog.display.helpVolume,
  1322. _DtHelpFileSuffixList, False, R_OK);
  1323. return _DtHelpFilterExecCmd((Widget) hw, cmdStr,
  1324. hw->help_dialog.display.executionPolicy,
  1325. True, &hw->help_dialog.help, ret_filteredCmdStr, hv_path);
  1326. }
  1327. /*****************************************************************************
  1328. * Function: void BuildDisplayArea(Widget parent,
  1329. * DtHelpDialogWidget nw);
  1330. *
  1331. *
  1332. * Parameters: parent Specifies the widget ID of the help dialog you
  1333. * want to set the topic in.
  1334. * nw Specifies the current help dialog widget.
  1335. *
  1336. * Return Value: Void.
  1337. *
  1338. * Purpose: Creates the Display area in the help dialog.
  1339. *
  1340. *****************************************************************************/
  1341. static void BuildDisplayArea(
  1342. Widget parent,
  1343. DtHelpDialogWidget nw)
  1344. {
  1345. Arg args[2];
  1346. int n;
  1347. XmFontList defaultList;
  1348. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  1349. /* Get our current fontlist value */
  1350. n = 0;
  1351. XtSetArg (args[n], XmNfontList, &(defaultList)); ++n;
  1352. XtGetValues (hw->help_dialog.menu.topBtn, args, n);
  1353. /* Build the Display Area */
  1354. hw->help_dialog.help.pDisplayArea = _DtHelpCreateDisplayArea(parent,
  1355. "DisplayArea",
  1356. ((short) hw->help_dialog.display.scrollBarPolicy),
  1357. ((short) hw->help_dialog.display.scrollBarPolicy),
  1358. False,
  1359. ((int) hw->help_dialog.display.textRows),
  1360. ((int) hw->help_dialog.display.textColumns),
  1361. _DtHelpDialogHypertextCB,
  1362. ResizeHelpDialogCB,
  1363. _DtHelpFilterExecCmdCB,
  1364. (XtPointer) hw,
  1365. defaultList);
  1366. /* Build the popup menu item for inside the display area */
  1367. hw->help_dialog.menu.popupMenu = CreatePopupMenu((Widget)hw);
  1368. /* Determin what type of info we are going to display */
  1369. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
  1370. }
  1371. /*****************************************************************************
  1372. * Function: void _DtHelpSetupDisplayType(DtHelpDialogWidget nw,
  1373. * int updateType);
  1374. *
  1375. *
  1376. * Parameters: nw Specifies the current help dialog widget.
  1377. *
  1378. * Return Value: Void.
  1379. *
  1380. * Purpose: Determins the type of topic the user want's to display
  1381. * in the current help dialog and sets it up for display.
  1382. *
  1383. *****************************************************************************/
  1384. void _DtHelpSetupDisplayType(
  1385. DtHelpDialogWidget nw,
  1386. Boolean vol_changed,
  1387. int updateType)
  1388. {
  1389. char *templocationId;
  1390. Boolean validAccessPath=FALSE;
  1391. XtPointer topicHandle;
  1392. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  1393. int status=VALID_STATUS;
  1394. char *tmpMessage;
  1395. char *tmpError;
  1396. char *locTitle;
  1397. char *volumeTitle;
  1398. DtTopicListStruct *tmpPtr;
  1399. Boolean adjustTopicTitle=TRUE;
  1400. /* This is a local flag that we use to determine
  1401. * if we need to re-adjust the topic volume title
  1402. * at the end of this
  1403. * Function: True == Modify title, False == leave alone.
  1404. */
  1405. Boolean didWeHaveAnError=FALSE;
  1406. XmString labelString;
  1407. Arg args[10];
  1408. int n=0;
  1409. /* Here we need to store away our current scroll position as the currentlly
  1410. * displayed item is about replaced w/a new item.
  1411. * We already have placed this item in the jump stack, and now are just adding
  1412. * the proper value for our scrollPosition.
  1413. */
  1414. if (hw->help_dialog.backtr.pJumpListHead != NULL)
  1415. {
  1416. tmpPtr = hw->help_dialog.backtr.pJumpListHead;
  1417. tmpPtr->scrollPosition =
  1418. _DtHelpGetScrollbarValue(hw->help_dialog.help.pDisplayArea);
  1419. }
  1420. /* Here we set our UP, and Home Topic buttons to FALSE, they should be
  1421. * true then the following code will set them correctly.
  1422. */
  1423. XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
  1424. XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
  1425. switch (hw->help_dialog.display.helpType)
  1426. {
  1427. case DtHELP_TYPE_TOPIC:
  1428. /* Expand the helpVolume resource if needed */
  1429. if ((hw->help_dialog.ghelp.volumeFlag) &&
  1430. (hw->help_dialog.display.volumeHandle != NULL))
  1431. validAccessPath = TRUE;
  1432. else
  1433. if (hw->help_dialog.display.helpVolume != NULL)
  1434. validAccessPath = _DtHelpExpandHelpVolume((Widget)hw,
  1435. &hw->help_dialog.display,
  1436. &hw->help_dialog.help,
  1437. &hw->help_dialog.print);
  1438. /* If the developer gave us a valid Access Path then we can continue
  1439. * else, we will do nothing
  1440. */
  1441. if (validAccessPath)
  1442. {
  1443. #if 0
  1444. /* Update our keyword search dialog if needed */
  1445. if ( FALSE == hw->help_dialog.ghelp.volumeFlag)
  1446. _DtHelpGlobSrchUpdateCurVol((Widget) hw);
  1447. /* We now set this to true after we update our volumeTitle
  1448. * value in _DtHelpUpdateDisplayArea.
  1449. */
  1450. /* hw->help_dialog.ghelp.volumeFlag = TRUE;*/
  1451. #endif
  1452. /* Setup all the proper lists and display area with the
  1453. * topic string
  1454. */
  1455. templocationId = XtNewString(hw->help_dialog.display.locationId);
  1456. /* Set the initial locationId into the display area */
  1457. _DtHelpUpdateDisplayArea(templocationId, hw, vol_changed, updateType,
  1458. DtHELP_TYPE_TOPIC);
  1459. XtFree(templocationId);
  1460. adjustTopicTitle = FALSE;
  1461. }
  1462. else
  1463. {
  1464. if (hw->help_dialog.display.helpVolume == NULL)
  1465. {
  1466. didWeHaveAnError=TRUE;
  1467. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 60,
  1468. "No help volume specified."));
  1469. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea,
  1470. (Widget)hw, tmpError, NULL);
  1471. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1472. (Widget) hw);
  1473. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1474. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1475. XtFree(tmpError);
  1476. }
  1477. else
  1478. {
  1479. /* We cannot find our HelpVolume so display the proper error
  1480. * message in the help dialog and continue.
  1481. */
  1482. didWeHaveAnError=TRUE;
  1483. tmpMessage = XtNewString((char *)_DTGETMESSAGE(2, 58,
  1484. "The requested online help is either not installed "
  1485. "or not in the proper help search path. For "
  1486. "information on installing online help, consult "
  1487. "the documentation for the product.\n"));
  1488. locTitle = XtNewString((char *)_DTGETMESSAGE(2, 62,
  1489. "Location ID:"));
  1490. volumeTitle = XtNewString((char *)_DTGETMESSAGE(2, 61,
  1491. "Help Volume:"));
  1492. tmpError = XtMalloc(strlen(tmpMessage) +
  1493. strlen(locTitle) +
  1494. strlen(volumeTitle) +
  1495. strlen(hw->help_dialog.display.locationId) +
  1496. strlen(hw->help_dialog.display.helpVolume) + 4);
  1497. (void) strcpy(tmpError, tmpMessage);
  1498. (void) strcat(tmpError, volumeTitle);
  1499. (void) strcat(tmpError, " ");
  1500. (void) strcat(tmpError, hw->help_dialog.display.helpVolume);
  1501. (void) strcat(tmpError,"\n");
  1502. (void) strcat(tmpError, locTitle);
  1503. (void) strcat(tmpError, " ");
  1504. (void) strcat(tmpError, hw->help_dialog.display.locationId);
  1505. /* Set current path area to null by giving it a null id */
  1506. _DtHelpUpdatePathArea(NULL, hw);
  1507. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea,
  1508. (Widget)hw, tmpError, NULL);
  1509. _DtHelpUpdateJumpList(tmpError,DtHELP_TYPE_DYNAMIC_STRING,
  1510. (Widget) hw);
  1511. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1512. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1513. XtFree(tmpError);
  1514. XtFree(tmpMessage);
  1515. XtFree(locTitle);
  1516. XtFree(volumeTitle);
  1517. }
  1518. }
  1519. break;
  1520. case DtHELP_TYPE_STRING:
  1521. _DtHelpUpdatePathArea(NULL, hw);
  1522. /* Set the string to the current help dialog */
  1523. status = _DtHelpFormatAsciiString(hw->help_dialog.help.pDisplayArea,
  1524. hw->help_dialog.display.stringData,
  1525. &topicHandle);
  1526. if (status >= VALID_STATUS)
  1527. {
  1528. /* Update the History and Jump Lists */
  1529. if (updateType == DtHISTORY_AND_JUMP)
  1530. _DtHelpUpdateJumpList(hw->help_dialog.display.stringData,
  1531. DtHELP_TYPE_STRING, (Widget) hw);
  1532. _DtHelpUpdateHistoryList(hw->help_dialog.display.stringData,
  1533. DtHELP_TYPE_STRING, TRUE, (Widget)hw);
  1534. _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
  1535. topicHandle, FALSE,
  1536. hw->help_dialog.backtr.scrollPosition);
  1537. }
  1538. else
  1539. {
  1540. didWeHaveAnError=TRUE;
  1541. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 50,
  1542. "String data could not be formatted."));
  1543. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
  1544. tmpError, (char*)HDMessage0);
  1545. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1546. (Widget) hw);
  1547. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1548. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1549. XtFree(tmpError);
  1550. }
  1551. break;
  1552. case DtHELP_TYPE_DYNAMIC_STRING:
  1553. _DtHelpUpdatePathArea(NULL, hw);
  1554. /* Set the string to the current help dialog */
  1555. status = _DtHelpFormatAsciiStringDynamic(
  1556. hw->help_dialog.help.pDisplayArea,
  1557. hw->help_dialog.display.stringData,
  1558. &topicHandle);
  1559. if (status >= VALID_STATUS)
  1560. {
  1561. /* Update the History and Jump Lists */
  1562. if (updateType == DtHISTORY_AND_JUMP)
  1563. _DtHelpUpdateJumpList(hw->help_dialog.display.stringData,
  1564. DtHELP_TYPE_DYNAMIC_STRING, (Widget) hw);
  1565. _DtHelpUpdateHistoryList(hw->help_dialog.display.stringData,
  1566. DtHELP_TYPE_DYNAMIC_STRING, TRUE, (Widget)hw);
  1567. _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
  1568. topicHandle, FALSE,
  1569. hw->help_dialog.backtr.scrollPosition);
  1570. }
  1571. else
  1572. {
  1573. didWeHaveAnError=TRUE;
  1574. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 51,
  1575. "Dynamic string data could not be formatted."));
  1576. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1577. (Widget) hw);
  1578. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1579. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1580. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea,(Widget)hw,
  1581. tmpError, (char*) HDMessage1);
  1582. XtFree(tmpError);
  1583. }
  1584. break;
  1585. case DtHELP_TYPE_MAN_PAGE:
  1586. _DtHelpUpdatePathArea(NULL, hw);
  1587. /* Set the string to the current help dialog */
  1588. status = _DtHelpFormatManPage(
  1589. hw->help_dialog.help.pDisplayArea,
  1590. hw->help_dialog.display.manPage, &topicHandle);
  1591. if (status >= VALID_STATUS)
  1592. {
  1593. /* Update the History and Jump Lists */
  1594. if (updateType == DtHISTORY_AND_JUMP)
  1595. _DtHelpUpdateJumpList(hw->help_dialog.display.manPage,
  1596. DtHELP_TYPE_MAN_PAGE, (Widget)hw);
  1597. _DtHelpUpdateHistoryList(hw->help_dialog.display.manPage,
  1598. DtHELP_TYPE_MAN_PAGE, TRUE, (Widget)hw);
  1599. _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
  1600. topicHandle, FALSE,
  1601. hw->help_dialog.backtr.scrollPosition);
  1602. }
  1603. else
  1604. {
  1605. didWeHaveAnError=TRUE;
  1606. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 52,
  1607. "Man Page could not be formatted. The requested Man Page is either not present, or corrupt."));
  1608. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1609. (Widget) hw);
  1610. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1611. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1612. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
  1613. tmpError, (char*) HDMessage2);
  1614. XtFree(tmpError);
  1615. }
  1616. break;
  1617. case DtHELP_TYPE_FILE:
  1618. _DtHelpUpdatePathArea(NULL, hw);
  1619. /* Set the string to the current help dialog */
  1620. status = _DtHelpFormatAsciiFile(hw->help_dialog.help.pDisplayArea,
  1621. hw->help_dialog.display.helpFile, &topicHandle);
  1622. if (status >= VALID_STATUS)
  1623. {
  1624. /* Update the History and Jump Lists */
  1625. if (updateType == DtHISTORY_AND_JUMP)
  1626. _DtHelpUpdateJumpList(hw->help_dialog.display.helpFile,
  1627. DtHELP_TYPE_FILE,(Widget)hw);
  1628. _DtHelpUpdateHistoryList(hw->help_dialog.display.helpFile,
  1629. DtHELP_TYPE_FILE, TRUE, (Widget)hw);
  1630. _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
  1631. topicHandle, FALSE,
  1632. hw->help_dialog.backtr.scrollPosition);
  1633. }
  1634. else
  1635. {
  1636. didWeHaveAnError=TRUE;
  1637. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 53,
  1638. "Text file data could not be formatted. The requested text file is either not present, or corrupt."));
  1639. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1640. (Widget) hw);
  1641. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1642. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1643. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
  1644. tmpError, (char*) HDMessage3);
  1645. XtFree(tmpError);
  1646. }
  1647. break;
  1648. default:
  1649. /* ERROR-MESSAGE */
  1650. /* This means the user used the wrong help type */
  1651. didWeHaveAnError=TRUE;
  1652. tmpError = XtNewString((char *)_DTGETMESSAGE(2, 80,
  1653. "The specified help type is invalid."));
  1654. _DtHelpUpdateJumpList(tmpError, DtHELP_TYPE_DYNAMIC_STRING,
  1655. (Widget) hw);
  1656. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1657. hw->help_dialog.display.stringData = XtNewString(tmpError);
  1658. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget)hw,
  1659. tmpError, (char*) HDMessage4);
  1660. XtFree(tmpError);
  1661. break;
  1662. } /* End Switch Statement */
  1663. if ((adjustTopicTitle == TRUE) && (didWeHaveAnError == FALSE))
  1664. {
  1665. /* We have a valid HelpType other than a volume and
  1666. * no error condition, so lets update the Topics title.
  1667. */
  1668. XtSetArg(args[0], XmNlabelString, hw->help_dialog.display.topicTitleLbl);
  1669. XtSetValues (hw->help_dialog.browser.volumeLabel, args, 1);
  1670. }
  1671. else if (didWeHaveAnError)
  1672. {
  1673. /* error messages displayed, clear out the topics title */
  1674. n=0;
  1675. labelString = XmStringCreateLocalized(" ");
  1676. XtSetArg (args[n], XmNlabelString, labelString); n++;
  1677. XtSetValues (hw->help_dialog.browser.volumeLabel, args, n);
  1678. XmStringFree(labelString);
  1679. if (hw->help_dialog.history.topicList != NULL)
  1680. XmListDeselectAllItems(hw->help_dialog.history.topicList);
  1681. if (hw->help_dialog.history.volumeList != NULL)
  1682. XmListDeselectAllItems(hw->help_dialog.history.volumeList);
  1683. /* Set current path area to null by giving it a null id */
  1684. _DtHelpUpdatePathArea(NULL, hw);
  1685. }
  1686. /* Update our keyword search dialog */
  1687. _DtHelpGlobSrchUpdateCurVol((Widget) hw);
  1688. /* Update the print dialog */
  1689. _DtHelpUpdatePrintDialog(&hw->help_dialog.print,
  1690. &hw->help_dialog.display,&hw->help_dialog.help,False);
  1691. /* covers error states and non-help topics; case of help topic but
  1692. in/not in the top-level volume is covered elsewhere */
  1693. if ( hw->help_dialog.browser.showTopLevelBtn == TRUE
  1694. && hw->help_dialog.display.helpType != DtHELP_TYPE_TOPIC)
  1695. XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
  1696. }
  1697. /*****************************************************************************
  1698. * Function: void _DtHelpUpdateDisplayArea(char *locationId,
  1699. * DtHelpDialogWidget nw,
  1700. * int listUpdateType,
  1701. * int topicUpdateType);
  1702. *
  1703. *
  1704. * Parameters: locationId Specifies the ID string for the new topic we
  1705. * are going to display in the HelpDialog widget.
  1706. *
  1707. * nw Specifies the current help dialog widget.
  1708. *
  1709. * Return Value: Void.
  1710. *
  1711. * Purpose: Updates the Display area with a new Cache Creek Topic.
  1712. *
  1713. *****************************************************************************/
  1714. void _DtHelpUpdateDisplayArea(
  1715. char *locationId,
  1716. DtHelpDialogWidget nw,
  1717. Boolean vol_changed,
  1718. int listUpdateType,
  1719. int topicUpdateType)
  1720. {
  1721. XtPointer topicHandle;
  1722. Boolean validlocationId=FALSE;
  1723. int status=NON_VALID_STATUS;
  1724. char *userErrorStr=NULL;
  1725. char *sysErrorStr=NULL;
  1726. char *tmpMsg=NULL;
  1727. XmString labelString;
  1728. Arg args[10];
  1729. int n=0;
  1730. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
  1731. _DtHelpTurnOnHourGlass(XtParent(hw));
  1732. validlocationId = False; /* default */
  1733. /* If we have a null idString, assign the top level topic to it */
  1734. if (locationId == NULL
  1735. && hw->help_dialog.help.topLevelId != NULL)
  1736. {
  1737. locationId = XtNewString(hw->help_dialog.help.topLevelId);
  1738. }
  1739. if (locationId != NULL)
  1740. {
  1741. XmUpdateDisplay((Widget)hw);
  1742. /* format the initial locationId info to display */
  1743. status = _DtHelpFormatTopic (
  1744. hw->help_dialog.help.pDisplayArea,
  1745. hw->help_dialog.display.volumeHandle,
  1746. locationId,
  1747. True,
  1748. &topicHandle);
  1749. /* unless locationId not found, the topic is valid */
  1750. if (status != -2)
  1751. validlocationId = True;
  1752. } /* if existing loc id, try to format it */
  1753. if (status == 0) /* success */
  1754. {
  1755. if (hw->help_dialog.ghelp.volumeFlag == FALSE)
  1756. {
  1757. XmFontList fontList;
  1758. Boolean mod = False;
  1759. XtSetArg(args[0], XmNfontList, &fontList);
  1760. XtGetValues(hw->help_dialog.browser.volumeLabel, args, 1);
  1761. /* We have a new volume, so update the volume title */
  1762. _DtHelpFormatVolumeTitle(hw->help_dialog.help.pDisplayArea,
  1763. hw->help_dialog.display.volumeHandle,
  1764. &labelString, &fontList, &mod);
  1765. if(labelString == NULL && NULL != hw->help_dialog.display.helpVolume)
  1766. labelString = XmStringCreateLocalized(
  1767. hw->help_dialog.display.helpVolume);
  1768. if (NULL != labelString)
  1769. {
  1770. n = 0;
  1771. XtSetArg (args[n], XmNlabelString, labelString); n++;
  1772. if (mod == True)
  1773. { XtSetArg (args[n], XmNfontList, fontList); n++; }
  1774. XtSetValues (hw->help_dialog.browser.volumeLabel, args, n);
  1775. XmStringFree(labelString);
  1776. }
  1777. if (True == mod)
  1778. XmFontListFree(fontList);
  1779. /* Update our volumeFlag because we know that its we have just,
  1780. * opened a new volume. It will get set to false when we need
  1781. * to process a different help volume, and remain true while
  1782. * processing the current help volume.
  1783. */
  1784. hw->help_dialog.ghelp.volumeFlag = TRUE;
  1785. } /* if volumeFlag == False */
  1786. /* Update our history and jump lists */
  1787. if (listUpdateType == DtHISTORY_AND_JUMP)
  1788. {
  1789. _DtHelpUpdateHistoryList(locationId, topicUpdateType,
  1790. vol_changed, (Widget)hw);
  1791. _DtHelpUpdateJumpList(locationId, topicUpdateType,(Widget) hw);
  1792. }
  1793. else if (listUpdateType == DtHISTORY_ONLY)
  1794. _DtHelpUpdateHistoryList(locationId, topicUpdateType,
  1795. vol_changed, (Widget)hw);
  1796. else if (listUpdateType == DtJUMP_ONLY)
  1797. _DtHelpUpdateJumpList(locationId, topicUpdateType,(Widget)hw);
  1798. /* Adjust our "Top Level" browser home buttons */
  1799. if (hw->help_dialog.browser.showTopLevelBtn == TRUE)
  1800. {
  1801. if (strstr (hw->help_dialog.display.helpVolume, DtBROWSER_NAME) != NULL)
  1802. {
  1803. /* FIX: get top topic of the current volume & compare with locationId */
  1804. if (strcmp (hw->help_dialog.display.locationId, DtBROWSER_HOME)== 0)
  1805. XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, FALSE);
  1806. else
  1807. XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
  1808. }
  1809. else
  1810. XtSetSensitive(hw->help_dialog.browser.btnBoxTopLevelBtn, TRUE);
  1811. } /* if showTopLevelBtn */
  1812. /* Check to see if we are going to display the top level is so */
  1813. if (_DtHelpCeIsTopTopic(hw->help_dialog.display.volumeHandle,
  1814. hw->help_dialog.display.locationId) == 0)
  1815. {
  1816. XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
  1817. XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
  1818. }
  1819. else
  1820. {
  1821. XtSetSensitive(hw->help_dialog.menu.topBtn, TRUE);
  1822. XtSetSensitive(hw->help_dialog.menu.popupTopBtn, TRUE);
  1823. }
  1824. /* Change the widget instance record locationId field to
  1825. * represent the new locationId being desplayed.
  1826. */
  1827. XtFree(hw->help_dialog.display.locationId);
  1828. hw->help_dialog.display.locationId = XtNewString(locationId);
  1829. /* Update the current path area for the given topic */
  1830. _DtHelpUpdatePathArea(hw->help_dialog.display.locationId, hw);
  1831. _DtHelpDisplayAreaSetList (hw->help_dialog.help.pDisplayArea,
  1832. topicHandle, FALSE, hw->help_dialog.backtr.scrollPosition);
  1833. } /* if status == 0 */
  1834. if (status < 0)
  1835. {
  1836. /* Invalid idString */
  1837. /* Clear the current volume title label */
  1838. /* ??? Is this the best way to null out a label gadget ??? */
  1839. labelString = XmStringCreateLocalized(" ");
  1840. XtSetArg (args[n], XmNlabelString, labelString);
  1841. XtSetValues (hw->help_dialog.browser.volumeLabel, args, 1);
  1842. XmStringFree(labelString);
  1843. /* Clear our history dialog selected items */
  1844. if (hw->help_dialog.history.topicList != NULL)
  1845. XmListDeselectAllItems(hw->help_dialog.history.topicList);
  1846. if (hw->help_dialog.history.volumeList != NULL)
  1847. XmListDeselectAllItems(hw->help_dialog.history.volumeList);
  1848. /* Set current path area to null by giving it a null idStirng */
  1849. _DtHelpUpdatePathArea(NULL, hw);
  1850. /* De-sensatize our buttons, they do not work
  1851. * with out valid topics.
  1852. */
  1853. XtSetSensitive(hw->help_dialog.menu.topBtn, FALSE);
  1854. XtSetSensitive(hw->help_dialog.menu.popupTopBtn, FALSE);
  1855. if (hw->help_dialog.history.pHistoryListHead == NULL)
  1856. {
  1857. XtSetSensitive(hw->help_dialog.menu.historyBtn, FALSE);
  1858. XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, FALSE);
  1859. }
  1860. else
  1861. {
  1862. /* in case they were desensitized for any reason */
  1863. XtSetSensitive(hw->help_dialog.menu.historyBtn, TRUE);
  1864. XtSetSensitive(hw->help_dialog.browser.btnBoxHistoryBtn, TRUE);
  1865. }
  1866. if (hw->help_dialog.backtr.pJumpListHead != NULL)
  1867. {
  1868. XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
  1869. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
  1870. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
  1871. }
  1872. /* Determin the proper error message to give */
  1873. if (!validlocationId)
  1874. {
  1875. if (locationId == NULL)
  1876. {
  1877. tmpMsg = (char *)_DTGETMESSAGE(2, 59,
  1878. "No location ID specified.");
  1879. userErrorStr = XtNewString(tmpMsg);
  1880. }
  1881. else
  1882. {
  1883. tmpMsg = (char *)_DTGETMESSAGE(2, 55,
  1884. "Nonexistent location ID:");
  1885. userErrorStr = XtMalloc(strlen(tmpMsg) +
  1886. strlen(hw->help_dialog.display.locationId)+ 2);
  1887. (void) strcpy(userErrorStr, tmpMsg);
  1888. (void) strcat(userErrorStr, " ");
  1889. (void) strcat(userErrorStr, hw->help_dialog.display.locationId);
  1890. sysErrorStr = XtNewString(HDMessage9);
  1891. }
  1892. }
  1893. else
  1894. {
  1895. tmpMsg = (char*)_DTGETMESSAGE(2, 54,
  1896. "Help topic could not be formatted.");
  1897. userErrorStr = XtNewString(tmpMsg);
  1898. sysErrorStr = XtNewString(HDMessage5);
  1899. }
  1900. _DtHelpUpdateJumpList(userErrorStr, DtHELP_TYPE_DYNAMIC_STRING,
  1901. (Widget) hw);
  1902. hw->help_dialog.display.helpType = DtHELP_TYPE_DYNAMIC_STRING;
  1903. hw->help_dialog.display.stringData = XtNewString(userErrorStr);
  1904. _DtHelpDisplayFormatError(hw->help_dialog.help.pDisplayArea, (Widget) hw,
  1905. userErrorStr, sysErrorStr);
  1906. XtFree(userErrorStr);
  1907. XtFree(sysErrorStr);
  1908. } /* if (status < 0) */
  1909. _DtHelpTurnOffHourGlass(XtParent(hw));
  1910. }
  1911. /*****************************************************************************
  1912. * Function: void _DtHelpUpdateJumpList(char *topicInfo,
  1913. * int topicType,
  1914. * DtHelpDialogWidget nw);
  1915. *
  1916. *
  1917. * Parameters: topicInfo Specifies the
  1918. * int Specifies the topicInfo type.
  1919. *
  1920. * nw Specifies the current help dialog widget.
  1921. *
  1922. * Return Value: Void.
  1923. *
  1924. * Purpose: Updates the Jump List with the new topic.
  1925. *
  1926. *****************************************************************************/
  1927. void _DtHelpUpdateJumpList(
  1928. char *topicInfo,
  1929. int topicType,
  1930. Widget nw)
  1931. {
  1932. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  1933. /* Add the new topic to the top of the jump list */
  1934. /* We add a -1 for the scrollbar position value, and will replace it with the
  1935. * actual value just prior to changing the window to the new topic.
  1936. */
  1937. _DtHelpTopicListAddToHead(topicInfo, hw->help_dialog.display.topicTitleLbl,
  1938. topicType, DtJUMP_LIST_MAX,
  1939. hw->help_dialog.display.helpVolume,
  1940. &hw->help_dialog.backtr.pJumpListHead,
  1941. &hw->help_dialog.backtr.pJumpListTale,
  1942. &hw->help_dialog.backtr.totalJumpNodes,
  1943. -1);
  1944. if (hw->help_dialog.backtr.totalJumpNodes <= 1)
  1945. {
  1946. XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
  1947. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
  1948. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
  1949. }
  1950. else
  1951. {
  1952. XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
  1953. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
  1954. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
  1955. }
  1956. }
  1957. /*****************************************************************************
  1958. * Function: void ProcessJumpBack(DtHelpDialogWidget nw);
  1959. *
  1960. *
  1961. * Parameters: helpDialogWidget Specifies the current help dialog widget.
  1962. *
  1963. * Return Value: Void.
  1964. *
  1965. * Purpose: Pops the top element in the jump list off the stack
  1966. * and jumps
  1967. *
  1968. * back to that topic.
  1969. *
  1970. *****************************************************************************/
  1971. static void ProcessJumpBack(
  1972. DtHelpDialogWidget nw)
  1973. {
  1974. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw ;
  1975. DtTopicListStruct *pTemp= NULL;
  1976. /* Pop the top element off our jump list and display the new top element */
  1977. _DtHelpTopicListDeleteHead(&hw->help_dialog.backtr.pJumpListHead,
  1978. &hw->help_dialog.backtr.pJumpListTale,
  1979. &hw->help_dialog.backtr.totalJumpNodes);
  1980. /* Assign pTemp to the current head pointer for or jump list */
  1981. pTemp = hw->help_dialog.backtr.pJumpListHead;
  1982. if (hw->help_dialog.backtr.totalJumpNodes <= 1)
  1983. {
  1984. XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
  1985. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
  1986. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
  1987. }
  1988. else
  1989. {
  1990. XtSetSensitive(hw->help_dialog.menu.backBtn, TRUE);
  1991. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, TRUE);
  1992. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, TRUE);
  1993. }
  1994. /* Assign the jump values to or instance structure variables */
  1995. if (NULL != pTemp->helpVolume &&
  1996. strcmp (hw->help_dialog.display.helpVolume, pTemp->helpVolume) != 0)
  1997. {
  1998. XtFree(hw->help_dialog.display.helpVolume);
  1999. hw->help_dialog.display.helpVolume = XtNewString(pTemp->helpVolume);
  2000. /* Set our help volume flag so we open the proper volume */
  2001. hw->help_dialog.ghelp.volumeFlag = FALSE;
  2002. }
  2003. /* grab the current backtracs's topic title value */
  2004. XmStringFree(hw->help_dialog.display.topicTitleLbl);
  2005. hw->help_dialog.display.topicTitleLbl = XmStringCopy(pTemp->topicTitleLbl);
  2006. /* Assign our scrollbar value to our instance structure so we jump to the
  2007. * proper location
  2008. */
  2009. hw->help_dialog.backtr.scrollPosition = pTemp->scrollPosition;
  2010. hw->help_dialog.display.helpType = pTemp->topicType;
  2011. switch (pTemp->topicType)
  2012. {
  2013. case DtHELP_TYPE_TOPIC:
  2014. /* Update our help dialog with top jump element */
  2015. XtFree(hw->help_dialog.display.locationId);
  2016. hw->help_dialog.display.locationId = XtNewString(pTemp->locationId);
  2017. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
  2018. break;
  2019. case DtHELP_TYPE_STRING:
  2020. case DtHELP_TYPE_DYNAMIC_STRING:
  2021. XtFree(hw->help_dialog.display.stringData);
  2022. hw->help_dialog.display.stringData = XtNewString(pTemp->locationId);
  2023. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
  2024. break;
  2025. case DtHELP_TYPE_MAN_PAGE:
  2026. XtFree(hw->help_dialog.display.manPage);
  2027. hw->help_dialog.display.manPage = XtNewString(pTemp->locationId);
  2028. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
  2029. break;
  2030. case DtHELP_TYPE_FILE:
  2031. XtFree(hw->help_dialog.display.helpFile);
  2032. hw->help_dialog.display.helpFile = XtNewString(pTemp->locationId);
  2033. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_ONLY);
  2034. break;
  2035. default:
  2036. /* ERROR-MESSAGE */
  2037. /* This means the user used the worng help type */
  2038. XmeWarning((Widget)hw, (char*) HDMessage4);
  2039. break;
  2040. } /* End Switch Statement */
  2041. /* reset our scrollPosition back to its default here so in any other case,
  2042. * we jump to the top of the topic
  2043. */
  2044. hw->help_dialog.backtr.scrollPosition = -1;
  2045. }
  2046. /*****************************************************************************
  2047. * Function: void _DtHelpDialogHypertextCB(
  2048. * XtPointer pDisplayAreaStruct,
  2049. * XtPointer clientData,
  2050. * DtHelpHyperTextStruct *hyperData.)
  2051. *
  2052. * Parameters: pDisplayAreaStruct Specifies the curretn display are info.
  2053. *
  2054. * clientData Specifies the client data passed into
  2055. * the hypertext callback.
  2056. *
  2057. * hyperData Specifies the current hypertext info
  2058. * structure.
  2059. *
  2060. * Return Value: Void.
  2061. *
  2062. * Purpose: Process all hypertext requests in a given Help Dialogs
  2063. * display area.
  2064. *
  2065. ****************************************************************************/
  2066. void _DtHelpDialogHypertextCB (
  2067. XtPointer pDisplayAreaStruct,
  2068. XtPointer clientData,
  2069. DtHelpHyperTextStruct *hyperData)
  2070. {
  2071. char *pTempAccessPath;
  2072. char *pTempLocationId;
  2073. DtHelpDialogCallbackStruct callData;
  2074. char *tmpErrorMsg;
  2075. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
  2076. /* We allow users to force a new window and override the jump-reuse
  2077. * hyper type and force a new window to be used
  2078. */
  2079. if ( ( ButtonRelease == hyperData->event->type
  2080. && hyperData->event->xbutton.state & (ControlMask|ShiftMask))
  2081. || ( KeyPress == hyperData->event->type
  2082. && hyperData->event->xkey.state & (ControlMask|ShiftMask)))
  2083. hyperData->window_hint = _DtCvWindowHint_NewWindow;
  2084. switch (hyperData->hyper_type)
  2085. {
  2086. case _DtCvLinkType_SameVolume:
  2087. case _DtCvLinkType_CrossLink:
  2088. switch (hyperData->window_hint)
  2089. {
  2090. case _DtCvWindowHint_CurrentWindow:
  2091. ProcessJumpReuse((Widget)hw, hyperData);
  2092. break;
  2093. case _DtCvWindowHint_NewWindow:
  2094. _DtHelpTurnOnHourGlass(XtParent(hw));
  2095. if (hw->help_dialog.display.hyperLinkCallback != NULL)
  2096. {
  2097. pTempAccessPath =
  2098. _DtHelpParseAccessFile(hyperData->specification);
  2099. if (pTempAccessPath != NULL) /* Use the New one */
  2100. callData.helpVolume = pTempAccessPath;
  2101. else /* Use the old one */
  2102. callData.helpVolume =
  2103. XtNewString(hw->help_dialog.display.helpVolume);
  2104. callData.reason = DtCR_HELP_LINK_ACTIVATE;
  2105. callData.event = hyperData->event;
  2106. callData.locationId = _DtHelpParseIdString
  2107. (hyperData->specification);
  2108. callData.specification = NULL;
  2109. callData.hyperType = DtHELP_LINK_TOPIC;
  2110. callData.windowHint = DtHELP_NEW_WINDOW;
  2111. /* Now, envoke the apps hyper callback */
  2112. XtCallCallbackList(
  2113. (Widget)hw,hw->help_dialog.display.hyperLinkCallback,&callData);
  2114. }
  2115. else
  2116. { /* The application did not register a hypertext callback so
  2117. * we must generate the proper warning message and
  2118. * continue!
  2119. */
  2120. XmeWarning((Widget)hw, (char*) HDMessage6);
  2121. /* Call jump-reuse procedure for default */
  2122. ProcessJumpReuse((Widget)hw, hyperData);
  2123. }
  2124. _DtHelpTurnOffHourGlass(XtParent(hw));
  2125. break;
  2126. case _DtCvWindowHint_PopupWindow:
  2127. _DtHelpTurnOnHourGlass(XtParent(hw));
  2128. pTempAccessPath =
  2129. _DtHelpParseAccessFile(hyperData->specification);
  2130. if (pTempAccessPath == NULL) /* Use the old one */
  2131. pTempAccessPath = XtNewString(hw->help_dialog.display.helpVolume);
  2132. pTempLocationId = _DtHelpParseIdString(hyperData->specification);
  2133. _DtHelpDisplayDefinitionBox((Widget)hw,
  2134. (Widget **)&(hw->help_dialog.ghelp.definitionBox),
  2135. pTempAccessPath, pTempLocationId);
  2136. XtFree(pTempLocationId);
  2137. XtFree(pTempAccessPath);
  2138. _DtHelpTurnOffHourGlass(XtParent(hw));
  2139. break;
  2140. default:
  2141. /* Non valid window hint generage the proper
  2142. * error message.
  2143. */
  2144. /* ERROR-MESSAGE */
  2145. break;
  2146. } /* End Window_hint Switch Statement */
  2147. break;
  2148. case _DtCvLinkType_Execute:
  2149. _DtHelpExecFilteredCmd((Widget) hw,
  2150. hyperData->specification, DtHELP_ExecutionPolicy_STR,
  2151. &hw->help_dialog.display, &hw->help_dialog.help);
  2152. break;
  2153. case _DtCvLinkType_ManPage:
  2154. case _DtCvLinkType_AppDefine:
  2155. case _DtCvLinkType_TextFile:
  2156. /* Process Application Man page link or App Defined link types */
  2157. _DtHelpTurnOnHourGlass(XtParent(hw));
  2158. /* If the application registered a hypertext callback use it! */
  2159. if (hw->help_dialog.display.hyperLinkCallback != NULL)
  2160. {
  2161. /* Setup the DtHyperProcStructer to pass back to the
  2162. * client as callData.
  2163. */
  2164. callData.reason = DtCR_HELP_LINK_ACTIVATE;
  2165. callData.event = hyperData->event;
  2166. callData.locationId = NULL;
  2167. callData.helpVolume = NULL;
  2168. if (_DtCvLinkType_AppDefine == hyperData->hyper_type)
  2169. {
  2170. callData.locationId =
  2171. _DtHelpParseIdString(hyperData->specification);
  2172. callData.helpVolume =
  2173. XtNewString(hw->help_dialog.display.helpVolume);
  2174. }
  2175. callData.specification = hyperData->specification;
  2176. callData.hyperType = hyperData->hyper_type;
  2177. callData.windowHint = hyperData->window_hint;
  2178. XtCallCallbackList ((Widget) hw,
  2179. hw->help_dialog.display.hyperLinkCallback, &callData);
  2180. }
  2181. else
  2182. {
  2183. /* The application did not register a hypertext
  2184. * callback so we must generate the proper error
  2185. * message and continue!
  2186. */
  2187. XmeWarning((Widget)hw, (char*) HDMessage8);
  2188. if (hyperData->hyper_type == DtHELP_LINK_APP_DEFINE)
  2189. {
  2190. tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 56,
  2191. "The selected Hypertext link is not supported within this application."));
  2192. _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
  2193. }
  2194. else
  2195. {
  2196. tmpErrorMsg = XtNewString((char *)_DTGETMESSAGE(2, 57,
  2197. "Links to Man Pages are not supported by this application."));
  2198. _DtHelpErrorDialog(XtParent(hw),tmpErrorMsg);
  2199. }
  2200. XtFree(tmpErrorMsg);
  2201. }
  2202. _DtHelpTurnOffHourGlass(XtParent(hw));
  2203. break;
  2204. default: /* This catches bogus link types */
  2205. /* Non valid link type so we are dropping it and are generating
  2206. * the proper error message.
  2207. */
  2208. /* ERROR-MESSAGE */
  2209. XmeWarning((Widget)hw, (char*) HDMessage7);
  2210. break;
  2211. } /* End Switch Statement */
  2212. } /* End _DtHelpDialogHypertextCB */
  2213. /*****************************************************************************
  2214. * Function: void ResizeHelpDialogCB()
  2215. *
  2216. *
  2217. * Return Value: Void.
  2218. *
  2219. * Purpose: Adjust the widget instance values for rows and columns.
  2220. *
  2221. ****************************************************************************/
  2222. static void ResizeHelpDialogCB (
  2223. XtPointer clientData)
  2224. {
  2225. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData ;
  2226. /* Re-Set our rows and colums values */
  2227. if ((hw->help_dialog.help.pDisplayArea != NULL) &&
  2228. hw->help_dialog.display.firstTimePopupFlag == TRUE)
  2229. _DtHelpDisplayAreaDimensionsReturn (hw->help_dialog.help.pDisplayArea,
  2230. &(hw->help_dialog.display.textRows),
  2231. &(hw->help_dialog.display.textColumns));
  2232. }
  2233. /*****************************************************************************
  2234. * Function: static void ProcessJumpReuse(nw, hyperData)
  2235. * Widget nw;
  2236. * DtHelpHyperTextStruct *hyperData;
  2237. *
  2238. * Parameters: nw Specifies the widget ID of the current help dialog
  2239. * widget.
  2240. *
  2241. * hyperData Specifies the hypertext data callback struct.
  2242. *
  2243. * Return Value: Void.
  2244. *
  2245. * Purpose: Process the jump-reuse hypertext link data.
  2246. *
  2247. *****************************************************************************/
  2248. static void ProcessJumpReuse(
  2249. Widget nw,
  2250. DtHelpHyperTextStruct *hyperData)
  2251. {
  2252. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
  2253. char *pTempAccessPath;
  2254. char *pTempLocationId;
  2255. /* Parse our specification into the proper fields in our instance
  2256. * record.
  2257. */
  2258. pTempAccessPath = _DtHelpParseAccessFile(hyperData->specification);
  2259. if (pTempAccessPath != NULL)
  2260. {
  2261. /* Free the old one and assign the new path */
  2262. XtFree(hw->help_dialog.display.helpVolume);
  2263. hw->help_dialog.display.helpVolume = pTempAccessPath;
  2264. hw->help_dialog.ghelp.volumeFlag = FALSE;
  2265. }
  2266. /* Free old copy first ??? */
  2267. pTempLocationId = _DtHelpParseIdString(hyperData->specification);
  2268. XtFree(hw->help_dialog.display.locationId);
  2269. hw->help_dialog.display.locationId = pTempLocationId;
  2270. hw->help_dialog.display.helpType = DtHELP_TYPE_TOPIC;
  2271. _DtHelpSetupDisplayType(hw, TRUE, DtHISTORY_AND_JUMP);
  2272. }
  2273. /*****************************************************************************
  2274. * Function: void _DtHelpTopicListFree (DtTopicListStruct *pHead);
  2275. *
  2276. *
  2277. * Parameters: pHead Specifies the head pointer to the topic list.
  2278. *
  2279. * Return Value: Void.
  2280. *
  2281. * Purpose: Frees all elements in a Topic List.
  2282. *
  2283. *****************************************************************************/
  2284. void _DtHelpTopicListFree(
  2285. DtTopicListStruct *pHead)
  2286. {
  2287. DtTopicListStruct *pTemp=NULL;
  2288. while (pHead != NULL)
  2289. {
  2290. /* Free up each element in the current node */
  2291. pTemp = pHead;
  2292. pHead = pHead->pNext;
  2293. pTemp->pNext = NULL;
  2294. pTemp->pPrevious = NULL;
  2295. /* Free the id String and AccessPath elements */
  2296. XtFree(pTemp->locationId);
  2297. XtFree(pTemp->helpVolume);
  2298. XmStringFree(pTemp->topicTitleLbl);
  2299. /* Now, free the whole node */
  2300. XtFree((char *)pTemp);
  2301. }
  2302. }
  2303. /*****************************************************************************
  2304. * Function: void CleanUpHelpDialog(DtHelpDialogWidget nw,
  2305. * int cleanUpKind);
  2306. *
  2307. *
  2308. * Parameters: nw Specifies the current help dialog widget.
  2309. * cleanUpKind Specifies the type of clean up we are doing,
  2310. * celan up and reuse or clean up and destroy.
  2311. *
  2312. * Return Value: Void.
  2313. *
  2314. * Purpose: This function will re-initializes a Help Dialog Widget to
  2315. * known good starting values or clean up in prepretion for
  2316. * an impending destroy.
  2317. *
  2318. *****************************************************************************/
  2319. static void CleanUpHelpDialog(
  2320. Widget nw,
  2321. int cleanUpKind)
  2322. {
  2323. Arg args[10];
  2324. DtHistoryListStruct *pTempVolume=NULL;
  2325. DtHistoryListStruct *pTempVolumeCurrent=NULL;
  2326. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
  2327. XtFree(hw->help_dialog.print.printVolume);
  2328. hw->help_dialog.print.printVolume = NULL;
  2329. /* must clean volume list and topic list from history */
  2330. pTempVolume = hw->help_dialog.history.pHistoryListHead;
  2331. while (pTempVolume != NULL)
  2332. {
  2333. _DtHelpTopicListFree(pTempVolume->pTopicHead);
  2334. pTempVolumeCurrent = pTempVolume;
  2335. pTempVolume = pTempVolume->pNext;
  2336. XmStringFree(pTempVolumeCurrent->itemTitle);
  2337. XtFree((char *)pTempVolumeCurrent);
  2338. }
  2339. hw->help_dialog.history.pHistoryListHead = NULL;
  2340. _DtHelpTopicListFree(hw->help_dialog.history.pPathListHead);
  2341. hw->help_dialog.history.pPathListHead = NULL;
  2342. hw->help_dialog.history.pPathListTale = NULL;
  2343. hw->help_dialog.history.totalPathNodes = 0;
  2344. /* Free our jump list display stuff */
  2345. _DtHelpTopicListFree(hw->help_dialog.backtr.pJumpListHead);
  2346. hw->help_dialog.backtr.pJumpListHead = NULL;
  2347. hw->help_dialog.backtr.pJumpListTale = NULL;
  2348. hw->help_dialog.backtr.totalJumpNodes = 0;
  2349. /* do nothing for index search dialog on a Clean for Reuse */
  2350. /* Close our current help volume */
  2351. if (hw->help_dialog.display.volumeHandle != NULL)
  2352. {
  2353. _DtHelpCloseVolume(hw->help_dialog.display.volumeHandle);
  2354. hw->help_dialog.display.volumeHandle = NULL;
  2355. }
  2356. /* Depending on weither we are just closing this help dialog or destroying
  2357. * it we will do the following!
  2358. */
  2359. if (cleanUpKind == DtCLEAN_FOR_DESTROY)
  2360. {
  2361. /* Free any remaining char * values we malloc'ed in our help dialog */
  2362. XtFree(hw->help_dialog.display.locationId);
  2363. XtFree(hw->help_dialog.display.helpVolume);
  2364. XtFree(hw->help_dialog.display.manPage);
  2365. XtFree(hw->help_dialog.display.stringData);
  2366. XtFree(hw->help_dialog.display.helpFile);
  2367. XtFree(hw->help_dialog.display.topicTitleStr);
  2368. if (hw->help_dialog.display.topicTitleLbl != NULL)
  2369. XmStringFree(hw->help_dialog.display.topicTitleLbl);
  2370. XtFree(hw->help_dialog.ghelp.parentId);
  2371. XtFree(hw->help_dialog.print.printer);
  2372. if (hw->help_dialog.print.helpPrint != _DtHelpDefaultHelpPrint)
  2373. XtFree(hw->help_dialog.print.helpPrint);
  2374. /* Clean and close and destroy (True) our index search dialog */
  2375. _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,True);
  2376. /* Set our current topic variables to initial values */
  2377. _DtHelpCommonHelpClean(&hw->help_dialog.help,True);
  2378. }
  2379. else
  2380. {
  2381. /* Reset our buttons to the proper state */
  2382. XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
  2383. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
  2384. XtSetSensitive(hw->help_dialog.browser.btnBoxBackBtn, FALSE);
  2385. /* Clean and close our index search dialog */
  2386. _DtHelpGlobSrchCleanAndClose(&hw->help_dialog.srch,False);
  2387. if (hw->help_dialog.history.historyWidget != NULL)
  2388. {
  2389. XtUnmanageChild(hw->help_dialog.history.historyWidget);
  2390. }
  2391. if (hw->help_dialog.print.printForm != NULL)
  2392. {
  2393. XtUnmanageChild(hw->help_dialog.print.printForm);
  2394. }
  2395. /* Free our history display stuff */
  2396. if (hw->help_dialog.history.volumeList != NULL)
  2397. {
  2398. XtSetArg(args[0], XmNitems, NULL);
  2399. XtSetArg(args[1], XmNitemCount, 0);
  2400. XtSetValues(hw->help_dialog.history.volumeList, args, 2);
  2401. }
  2402. if (hw->help_dialog.history.topicList != NULL)
  2403. {
  2404. XtSetArg(args[0], XmNitems, NULL);
  2405. XtSetArg(args[1], XmNitemCount, 0);
  2406. XtSetValues(hw->help_dialog.history.topicList, args, 2);
  2407. }
  2408. /* Set our toc areay area to a null starting vlaues */
  2409. _DtHelpDisplayAreaClean(hw->help_dialog.browser.pTocArea);
  2410. /* Set our current topic variables to initial values */
  2411. _DtHelpCommonHelpClean(&hw->help_dialog.help,False);
  2412. }
  2413. }
  2414. /****************************************************************************
  2415. * Function: CatchClose( Widget w);
  2416. *
  2417. * Parameters:
  2418. *
  2419. * Return Value: Void.
  2420. *
  2421. * Purpose: Catches the window manager close requests and assigns our
  2422. * CloseHelpCB to handel them.
  2423. *
  2424. ***************************************************************************/
  2425. static void CatchClose (
  2426. Widget widget)
  2427. {
  2428. Atom wm_delete_window;
  2429. Arg args[2];
  2430. /* Grab the window mgr close */
  2431. wm_delete_window = XmInternAtom(XtDisplay(XtParent(widget)),
  2432. "WM_DELETE_WINDOW", FALSE);
  2433. XtSetArg(args[0], XmNdeleteResponse, XmDO_NOTHING);
  2434. /* Current Help Dialog Window */
  2435. XmAddWMProtocolCallback(XtParent(widget),wm_delete_window,
  2436. (XtCallbackProc)CloseHelpCB, (XtPointer) widget);
  2437. XtSetValues(XtParent(widget), args, 1);
  2438. }
  2439. /************************************************************************
  2440. * Function: CloseHelpCB()
  2441. *
  2442. * Close the Help Dialog Window
  2443. *
  2444. ************************************************************************/
  2445. static void CloseHelpCB (
  2446. Widget w,
  2447. XtPointer clientData,
  2448. XtPointer callData)
  2449. {
  2450. DtHelpDialogWidget hw = (DtHelpDialogWidget) clientData;
  2451. DtHelpDialogCallbackStruct callDataInfo;
  2452. XmPushButtonCallbackStruct *callbackStruct =
  2453. (XmPushButtonCallbackStruct*) callData;
  2454. /*
  2455. * Check to see if a selection is in process.
  2456. * If so, cancel the selection and don't close the dialog
  2457. */
  2458. if (_DtHelpCancelSelection(hw->help_dialog.help.pDisplayArea) == True)
  2459. return;
  2460. /* No selection in progress. Close the dialog.
  2461. *
  2462. * ??? By definition, when a user closes a Help Dialog if it is
  2463. * used again by the application the state will be new. So we should
  2464. * flush out any info currently in the help, history, and search dialogs.
  2465. */
  2466. CleanUpHelpDialog((Widget)hw, DtCLEAN_FOR_REUSE);
  2467. /* Look to see if they registered their own close callback */
  2468. if (hw->help_dialog.ghelp.closeCallback != NULL)
  2469. {
  2470. callDataInfo.reason = DtCR_HELP_CLOSE;
  2471. callDataInfo.event = callbackStruct->event;
  2472. callDataInfo.locationId = NULL;
  2473. callDataInfo.helpVolume = NULL;
  2474. callDataInfo.specification = NULL;
  2475. callDataInfo.hyperType = 0;
  2476. /* All we do is envoke the applications close callback */
  2477. XtCallCallbackList((Widget)hw,hw->help_dialog.ghelp.closeCallback,
  2478. (XtPointer) &callDataInfo);
  2479. }
  2480. else
  2481. XtUnmanageChild((Widget)hw);
  2482. }
  2483. /*********************************************************************
  2484. * Function: SetupHelpDialogMenus
  2485. *
  2486. * This procedure build the menubar pulldows buttons for the Index
  2487. * Browser and the Topic Viewer.
  2488. *
  2489. * Called by: MakeIndexWindow, and MakeTopicWindow.
  2490. *********************************************************************/
  2491. static Widget SetupHelpDialogMenus(
  2492. Widget parent)
  2493. {
  2494. Widget menuBar;
  2495. Widget c[10];
  2496. Widget cascadeB5;
  2497. Widget menupane1, menupane2, menupane3, menupane4, menupane5;
  2498. Widget helpBtn1, helpBtn2, helpBtn3, helpBtn4, helpBtn5, helpBtn6;
  2499. Arg args[10];
  2500. int n;
  2501. XmString labelStr;
  2502. char *mnemonic;
  2503. DtHelpListStruct *pHelpInfo;
  2504. DtHelpDialogWidget hw = (DtHelpDialogWidget) parent;
  2505. /* Build the menubar */
  2506. n = 0;
  2507. menuBar = XmCreateMenuBar (parent, "menuBar", args, n);
  2508. XtManageChild (menuBar);
  2509. /*******************************************************
  2510. * Menupane: Close, and related buttons
  2511. *******************************************************/
  2512. n = 0;
  2513. XtSetArg(args[n], XmNmarginWidth, 0); ++n;
  2514. XtSetArg(args[n], XmNmarginHeight, 0); ++n;
  2515. menupane1 = XmCreatePulldownMenu(menuBar, "fileMenu", args, n);
  2516. /* Add callback for File Menu */
  2517. pHelpInfo = _DtHelpListAdd(DtHELP_FileMenu_STR,
  2518. (Widget) hw, &hw->help_dialog.help,
  2519. &hw->help_dialog.help.pHelpListHead);
  2520. XtAddCallback((Widget) menupane1, XmNhelpCallback,
  2521. _DtHelpCB, (XtPointer) pHelpInfo);
  2522. /* Print button */
  2523. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 1,"Print...")));
  2524. mnemonic = ((char *)_DTGETMESSAGE(2, 2,"P"));
  2525. n = 0;
  2526. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2527. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2528. c[0] = hw->help_dialog.menu.printBtn = XmCreatePushButtonGadget(menupane1,
  2529. "print", args, n);
  2530. XtAddCallback(hw->help_dialog.menu.printBtn,XmNactivateCallback,
  2531. DisplayPrintCB, (XtPointer) hw);
  2532. XmStringFree(labelStr);
  2533. if (hw->help_dialog.menu.showDupBtn == True)
  2534. {
  2535. /* Duplicate button */
  2536. labelStr = XmStringCreateLocalized(((char *)
  2537. _DTGETMESSAGE(2, 5,"New Window...")));
  2538. mnemonic = ((char *)_DTGETMESSAGE(2, 6,"W"));
  2539. n = 0;
  2540. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2541. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2542. c[1] = hw->help_dialog.menu.newWindowBtn =
  2543. XmCreatePushButtonGadget(menupane1,"newWindowBtn", args, n);
  2544. XtAddCallback(hw->help_dialog.menu.newWindowBtn,XmNactivateCallback,
  2545. _DtHelpDuplicateWindowCB, (XtPointer) hw);
  2546. XmStringFree(labelStr);
  2547. /* Exit button */
  2548. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
  2549. mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
  2550. n = 0;
  2551. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2552. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2553. c[2] = hw->help_dialog.menu.closeBtn =
  2554. XmCreatePushButtonGadget(menupane1,"close", args, n);
  2555. XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback,
  2556. CloseHelpCB, (XtPointer) hw);
  2557. XmStringFree(labelStr);
  2558. /* set the cancel button (for KCancel) */
  2559. hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
  2560. /* Manage the children for the File menu pane */
  2561. XtManageChildren(c, 3);
  2562. }
  2563. else
  2564. {
  2565. /* Exit button */
  2566. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 3,"Close")));
  2567. mnemonic = ((char *)_DTGETMESSAGE(2, 4,"C"));
  2568. n = 0;
  2569. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2570. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2571. c[1] = hw->help_dialog.menu.closeBtn =
  2572. XmCreatePushButtonGadget(menupane1,"close", args, n);
  2573. XtAddCallback(hw->help_dialog.menu.closeBtn,XmNactivateCallback,
  2574. CloseHelpCB, (XtPointer) hw);
  2575. XmStringFree(labelStr);
  2576. /* set the cancel button (for KCancel) */
  2577. hw->bulletin_board.cancel_button= hw->help_dialog.menu.closeBtn;
  2578. /* Manage the children for the File menu pane */
  2579. XtManageChildren(c, 2);
  2580. }
  2581. /*******************************************************
  2582. * Menupane: Edit, (Copy)
  2583. *******************************************************/
  2584. n = 0;
  2585. XtSetArg(args[n], XmNmarginWidth, 0); ++n;
  2586. XtSetArg(args[n], XmNmarginHeight, 0); ++n;
  2587. menupane2 = XmCreatePulldownMenu(menuBar, "editMenu", args, n);
  2588. /* Add callback for Edit Menu */
  2589. pHelpInfo = _DtHelpListAdd(DtHELP_EditMenu_STR,
  2590. (Widget) hw, &hw->help_dialog.help,
  2591. &hw->help_dialog.help.pHelpListHead);
  2592. XtAddCallback((Widget) menupane2, XmNhelpCallback,
  2593. _DtHelpCB, (XtPointer) pHelpInfo);
  2594. /* Edit button */
  2595. labelStr = XmStringCreateLocalized((
  2596. (char *)_DTGETMESSAGE(2,7,"Copy")));
  2597. mnemonic = ((char *)_DTGETMESSAGE(2, 8,"C"));
  2598. n = 0;
  2599. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2600. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2601. c[0] = hw->help_dialog.menu.copyBtn = XmCreatePushButtonGadget
  2602. (menupane2, "copy", args, n);
  2603. XtAddCallback(hw->help_dialog.menu.copyBtn,XmNactivateCallback,
  2604. CopyTextCB, (XtPointer) hw);
  2605. XmStringFree(labelStr);
  2606. XtManageChildren(c, 1);
  2607. /*******************************************************
  2608. * Menupane: Search, (Topic Index)
  2609. *******************************************************/
  2610. n = 0;
  2611. XtSetArg(args[n], XmNmarginWidth, 0); ++n;
  2612. XtSetArg(args[n], XmNmarginHeight, 0); ++n;
  2613. menupane3 = XmCreatePulldownMenu(menuBar, "searchMenu", args, n);
  2614. /* Add callback for Search Menu */
  2615. pHelpInfo = _DtHelpListAdd(DtHELP_SearchMenu_STR,
  2616. (Widget) hw, &hw->help_dialog.help,
  2617. &hw->help_dialog.help.pHelpListHead);
  2618. XtAddCallback((Widget) menupane3, XmNhelpCallback,
  2619. _DtHelpCB, (XtPointer) pHelpInfo);
  2620. /* Search button */
  2621. labelStr = XmStringCreateLocalized((
  2622. (char *)_DTGETMESSAGE(2, 9,"Index...")));
  2623. mnemonic = ((char *)_DTGETMESSAGE(2, 10,"I"));
  2624. n = 0;
  2625. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2626. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2627. c[0] = hw->help_dialog.menu.keyBtn = XmCreatePushButtonGadget
  2628. (menupane3, "keyword", args, n);
  2629. XtAddCallback(hw->help_dialog.menu.keyBtn,XmNactivateCallback,
  2630. _DtHelpDisplayIndexCB, (XtPointer) hw);
  2631. XmStringFree(labelStr);
  2632. XtManageChildren(c, 1);
  2633. /*******************************************************
  2634. * Menupane: Navigate, and related buttons
  2635. *******************************************************/
  2636. n = 0;
  2637. XtSetArg(args[n], XmNmarginWidth, 0); ++n;
  2638. XtSetArg(args[n], XmNmarginHeight, 0); ++n;
  2639. menupane4 = XmCreatePulldownMenu(menuBar, "navigateMenu", args, n);
  2640. /* Add callback for Navigate Menu */
  2641. pHelpInfo = _DtHelpListAdd(DtHELP_NavigateMenu_STR,
  2642. (Widget) hw, &hw->help_dialog.help,
  2643. &hw->help_dialog.help.pHelpListHead);
  2644. XtAddCallback((Widget) menupane4 , XmNhelpCallback,
  2645. _DtHelpCB, (XtPointer) pHelpInfo);
  2646. /* Back Button */
  2647. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 13,"Backtrack")));
  2648. mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
  2649. n = 0;
  2650. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2651. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2652. c[0] = hw->help_dialog.menu.backBtn = XmCreatePushButtonGadget(menupane4,
  2653. "backTrack", args, n);
  2654. XtAddCallback(hw->help_dialog.menu.backBtn,XmNactivateCallback,
  2655. _DtHelpDisplayBackCB, (XtPointer) hw);
  2656. XtSetSensitive(hw->help_dialog.menu.backBtn, FALSE);
  2657. XmStringFree(labelStr);
  2658. /* Top Button */
  2659. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
  2660. mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
  2661. n = 0;
  2662. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2663. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2664. c[1] = hw->help_dialog.menu.topBtn = XmCreatePushButtonGadget(menupane4,
  2665. "homeTopic", args, n);
  2666. XtAddCallback(hw->help_dialog.menu.topBtn,XmNactivateCallback,
  2667. DisplayTopLevelCB, (XtPointer) hw);
  2668. XmStringFree(labelStr);
  2669. /* Place a menu break here */
  2670. n = 0;
  2671. c[2] = XmCreateSeparatorGadget(menupane4, "seporator",args, n);
  2672. /* History Button */
  2673. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 15,"History...")));
  2674. mnemonic = ((char *)_DTGETMESSAGE(2, 16,"H"));
  2675. n = 0;
  2676. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2677. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2678. c[3] = hw->help_dialog.menu.historyBtn = XmCreatePushButtonGadget(menupane4,
  2679. "history",args, n);
  2680. XtAddCallback(hw->help_dialog.menu.historyBtn,XmNactivateCallback,
  2681. _DtHelpDisplayHistoryCB, (XtPointer) hw);
  2682. XmStringFree(labelStr);
  2683. /* Manage all the children of this manu pane */
  2684. XtManageChildren(c, 4);
  2685. /*******************************************************
  2686. * Menupane: Help, and related buttons
  2687. *******************************************************/
  2688. n = 0;
  2689. XtSetArg(args[n], XmNmarginWidth, 0); ++n;
  2690. XtSetArg(args[n], XmNmarginHeight, 0); ++n;
  2691. menupane5 = XmCreatePulldownMenu(menuBar, "helpMenu", args, n);
  2692. /* Add callback for Help Menu */
  2693. pHelpInfo = _DtHelpListAdd(DtHELP_HelpMenu_STR,
  2694. (Widget) hw, &hw->help_dialog.help,
  2695. &hw->help_dialog.help.pHelpListHead);
  2696. XtAddCallback((Widget) menupane5, XmNhelpCallback,
  2697. _DtHelpCB, (XtPointer) pHelpInfo);
  2698. /* On HELP button */
  2699. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 17,"Overview - Using Help")));
  2700. mnemonic = ((char *)_DTGETMESSAGE(2, 18,"v"));
  2701. n = 0;
  2702. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2703. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2704. c[0] = helpBtn1 = XmCreatePushButtonGadget(menupane5,
  2705. "usingHelp", args, n);
  2706. pHelpInfo = _DtHelpListAdd(DtHELP_onHelpMenu_STR,
  2707. (Widget) hw, &hw->help_dialog.help,
  2708. &hw->help_dialog.help.pHelpListHead);
  2709. XtAddCallback(helpBtn1, XmNactivateCallback,
  2710. _DtHelpCB, (XtPointer) pHelpInfo);
  2711. XmStringFree(labelStr);
  2712. /* Place a menu break here */
  2713. n = 0;
  2714. c[1] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
  2715. /* On Table Of Contents Help button */
  2716. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2,19,"Table Of Contents")));
  2717. mnemonic = ((char *)_DTGETMESSAGE(2, 20, "C"));
  2718. n = 0;
  2719. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2720. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2721. c[2] = helpBtn2 = XmCreatePushButtonGadget(menupane5,
  2722. "tableOfContents", args, n);
  2723. pHelpInfo = _DtHelpListAdd(DtHELP_onTableOfContenseMenu_STR,
  2724. (Widget) hw, &hw->help_dialog.help,
  2725. &hw->help_dialog.help.pHelpListHead);
  2726. XtAddCallback(helpBtn2, XmNactivateCallback,
  2727. _DtHelpCB, (XtPointer) pHelpInfo);
  2728. XmStringFree(labelStr);
  2729. /* On Tasks Help button */
  2730. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 21,"Tasks")));
  2731. mnemonic = ((char *)_DTGETMESSAGE(2, 22, "T"));
  2732. n = 0;
  2733. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2734. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2735. c[3] = helpBtn3 = XmCreatePushButtonGadget(menupane5,
  2736. "tasks", args, n);
  2737. pHelpInfo = _DtHelpListAdd(DtHELP_onTasksMenu_STR,
  2738. (Widget) hw, &hw->help_dialog.help,
  2739. &hw->help_dialog.help.pHelpListHead);
  2740. XtAddCallback(helpBtn3, XmNactivateCallback,
  2741. _DtHelpCB, (XtPointer) pHelpInfo);
  2742. XmStringFree(labelStr);
  2743. /* On Reference button */
  2744. labelStr = XmStringCreateLocalized(((char *)
  2745. _DTGETMESSAGE(2, 23,"Reference")));
  2746. mnemonic = ((char *)_DTGETMESSAGE(2, 24,"R"));
  2747. n = 0;
  2748. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2749. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2750. c[4] = helpBtn4 = XmCreatePushButtonGadget(menupane5,
  2751. "reference",args, n);
  2752. pHelpInfo = _DtHelpListAdd(DtHELP_onReferenceMenu_STR,
  2753. (Widget) hw, &hw->help_dialog.help,
  2754. &hw->help_dialog.help.pHelpListHead);
  2755. XtAddCallback(helpBtn4, XmNactivateCallback,
  2756. _DtHelpCB, (XtPointer) pHelpInfo);
  2757. XmStringFree(labelStr);
  2758. /* On Mouse & Keyboard button */
  2759. labelStr = XmStringCreateLocalized(((char *)
  2760. _DTGETMESSAGE(2, 25,"Mouse and Keyboard")));
  2761. mnemonic = ((char *)_DTGETMESSAGE(2, 26,"M"));
  2762. n = 0;
  2763. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2764. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2765. c[5] = helpBtn5 = XmCreatePushButtonGadget(menupane5,
  2766. "reference",args, n);
  2767. pHelpInfo = _DtHelpListAdd(DtHELP_onMouseAndKeysMenu_STR,
  2768. (Widget) hw, &hw->help_dialog.help,
  2769. &hw->help_dialog.help.pHelpListHead);
  2770. XtAddCallback(helpBtn5, XmNactivateCallback,
  2771. _DtHelpCB, (XtPointer) pHelpInfo);
  2772. XmStringFree(labelStr);
  2773. /* Place a menu break here */
  2774. n = 0;
  2775. c[6] = XmCreateSeparatorGadget(menupane5, "seporator",args, n);
  2776. /* On Version */
  2777. labelStr = XmStringCreateLocalized(((char *)
  2778. _DTGETMESSAGE(2, 27,"About Help")));
  2779. mnemonic = ((char *)_DTGETMESSAGE(2, 28,"A"));
  2780. n = 0;
  2781. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2782. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2783. c[7] = helpBtn6 = XmCreatePushButtonGadget(menupane5,
  2784. "reference",args, n);
  2785. pHelpInfo = _DtHelpListAdd(DtHELP_onVersionMenu_STR,
  2786. (Widget) hw, &hw->help_dialog.help,
  2787. &hw->help_dialog.help.pHelpListHead);
  2788. XtAddCallback(helpBtn6, XmNactivateCallback,
  2789. _DtHelpCB, (XtPointer) pHelpInfo);
  2790. XmStringFree(labelStr);
  2791. /* Manage the children for the Help menu pane */
  2792. XtManageChildren(c, 8);
  2793. /* Create Cascade buttons for menubar */
  2794. /* File Menu */
  2795. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 29,"File")));
  2796. mnemonic = ((char *)_DTGETMESSAGE(2, 30,"F"));
  2797. n = 0;
  2798. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2799. XtSetArg(args[n], XmNsubMenuId, menupane1); n++;
  2800. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2801. c[0] = XmCreateCascadeButton(menuBar,"file",args, n);
  2802. XmStringFree(labelStr);
  2803. /* Edit Menu */
  2804. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 37,"Edit")));
  2805. mnemonic = ((char *)_DTGETMESSAGE(2, 38,"E"));
  2806. n = 0;
  2807. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2808. XtSetArg(args[n], XmNsubMenuId, menupane2); n++;
  2809. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2810. c[1] = XmCreateCascadeButton(menuBar, "edit", args, n);
  2811. XmStringFree(labelStr);
  2812. /* Search Menu */
  2813. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 31,"Search")));
  2814. mnemonic = ((char *)_DTGETMESSAGE(2, 32,"S"));
  2815. n = 0;
  2816. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2817. XtSetArg(args[n], XmNsubMenuId, menupane3); n++;
  2818. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2819. c[2] = XmCreateCascadeButton(menuBar, "search", args, n);
  2820. XmStringFree(labelStr);
  2821. /* Navigate Menu */
  2822. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 33,"Navigate")));
  2823. mnemonic = ((char *)_DTGETMESSAGE(2, 34,"N"));
  2824. n = 0;
  2825. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2826. XtSetArg(args[n], XmNsubMenuId, menupane4); n++;
  2827. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2828. c[3] = XmCreateCascadeButton(menuBar, "navigate", args, n);
  2829. XmStringFree(labelStr);
  2830. /* Help Menu */
  2831. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 35,"Help")));
  2832. mnemonic = ((char *)_DTGETMESSAGE(2, 36,"H"));
  2833. n = 0;
  2834. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2835. XtSetArg(args[n], XmNsubMenuId, menupane5); n++;
  2836. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2837. c[4] = cascadeB5 = XmCreateCascadeButton(menuBar, "help", args, n);
  2838. XmStringFree(labelStr);
  2839. XtManageChildren(c, 5);
  2840. /* Attaches the Help menupane to the right side */
  2841. n = 0;
  2842. XtSetArg (args[n], XmNmenuHelpWidget, cascadeB5); n++;
  2843. XtSetValues (menuBar, args, n);
  2844. return(menuBar);
  2845. } /* End SetupHelpDialogMenus */
  2846. /*********************************************************************
  2847. * Function: CreatePopupMenu
  2848. *
  2849. * This procedure builds the popup menu for the display area
  2850. *
  2851. **********************************************************************/
  2852. static Widget CreatePopupMenu(
  2853. Widget nw)
  2854. {
  2855. Widget popup;
  2856. Widget c[10];
  2857. Arg args[10];
  2858. int n;
  2859. XmString labelStr;
  2860. DtHelpDialogWidget hw = (DtHelpDialogWidget) nw;
  2861. DtHelpListStruct *pHelpInfo;
  2862. char *mnemonic;
  2863. int numButtons = XGetPointerMapping(XtDisplay(nw),(unsigned char *)NULL, 0);
  2864. /* Build the popup */
  2865. /* If no Btn3 then use Btn2 to post the menu */
  2866. n = 0;
  2867. if (numButtons < 3) {
  2868. XtSetArg(args[n], XmNwhichButton, Button2); n++;
  2869. }
  2870. popup = XmCreatePopupMenu (
  2871. _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea),
  2872. "popup", args, n);
  2873. /* Add our button three event handler to our newly created display area */
  2874. XtAddEventHandler(
  2875. _DtHelpDisplayAreaWidget(hw->help_dialog.help.pDisplayArea),
  2876. ButtonPressMask, FALSE,
  2877. (XtEventHandler)ProcessBMenuBackCB, hw);
  2878. /* Add Help callback for Popup Menu */
  2879. pHelpInfo = _DtHelpListAdd(DtHELP_PopupMenu_STR,
  2880. (Widget) hw, &hw->help_dialog.help,
  2881. &hw->help_dialog.help.pHelpListHead);
  2882. XtAddCallback((Widget) popup, XmNhelpCallback,
  2883. _DtHelpCB, (XtPointer) pHelpInfo);
  2884. /* Build the popup menu items */
  2885. /* Popup Label*/
  2886. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(3, 4,"Help")));
  2887. n = 0;
  2888. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2889. c[0] = XmCreateLabelGadget(popup, "popupLabel", args, n);
  2890. XmStringFree(labelStr);
  2891. /* Place a menu break here */
  2892. n = 0;
  2893. c[1] = XmCreateSeparatorGadget(popup, "seporator",args, n);
  2894. /* Back Button */
  2895. labelStr = XmStringCreateLocalized(((char *) _DTGETMESSAGE(2, 13,"Backtrack")));
  2896. mnemonic = ((char *)_DTGETMESSAGE(2, 14,"B"));
  2897. n = 0;
  2898. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2899. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2900. c[2] = hw->help_dialog.menu.popupBackBtn = XmCreatePushButtonGadget(popup,
  2901. "backTrack", args, n);
  2902. XmStringFree(labelStr);
  2903. XtAddCallback(hw->help_dialog.menu.popupBackBtn,XmNactivateCallback,
  2904. _DtHelpDisplayBackCB, (XtPointer) hw);
  2905. XtSetSensitive(hw->help_dialog.menu.popupBackBtn, FALSE);
  2906. /* Top Button */
  2907. labelStr = XmStringCreateLocalized(((char *)_DTGETMESSAGE(2, 11,"Home Topic")));
  2908. mnemonic = ((char *)_DTGETMESSAGE(2, 12,"T"));
  2909. n = 0;
  2910. XtSetArg(args[n], XmNlabelString, labelStr); n++;
  2911. XtSetArg(args[n], XmNmnemonic, mnemonic[0]); n++;
  2912. c[3] = hw->help_dialog.menu.popupTopBtn = XmCreatePushButtonGadget(popup,
  2913. "homeTopic", args, n);
  2914. XmStringFree(labelStr);
  2915. XtAddCallback(hw->help_dialog.menu.popupTopBtn,XmNactivateCallback,
  2916. DisplayTopLevelCB, (XtPointer) hw);
  2917. XtManageChildren(c, 4);
  2918. return(popup);
  2919. }