DtFuncs.sh.src 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. # $XConsortium: DtFuncs.sh.src /main/1 1995/11/01 15:49:09 rswiston $
  2. #
  3. # COMPONENT_NAME: desktop
  4. #
  5. # FUNCTIONS: DtkshAddButtons
  6. # DtkshFloatBottom
  7. # DtkshFloatLeft
  8. # DtkshFloatRight
  9. # DtkshFloatTop
  10. # DtkshLeftOf
  11. # DtkshOver
  12. # DtkshRightOf
  13. # DtkshSetReturnKeyControls
  14. # DtkshUnder
  15. #
  16. # ORIGINS: 27,118,119,120,121
  17. #
  18. # This module contains IBM CONFIDENTIAL code. -- (IBM
  19. # Confidential Restricted when combined with the aggregated
  20. # modules for this product)
  21. # OBJECT CODE ONLY SOURCE MATERIALS
  22. #
  23. # (C) COPYRIGHT International Business Machines Corp. 1995
  24. # All Rights Reserved
  25. # US Government Users Restricted Rights - Use, duplication or
  26. # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  27. #
  28. ###############################################################################
  29. # (c) Copyright 1993, 1994 Hewlett-Packard Company
  30. # (c) Copyright 1993, 1994 International Business Machines Corp.
  31. # (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  32. # (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  33. # Novell, Inc.
  34. ###############################################################################
  35. ###############################################################################
  36. #
  37. # DtkshAddButtons - Convenience function for adding 1 or more buttons of the
  38. # same kind into a composite widget. Most frequently
  39. # used to add a collection of buttons into a menupane.
  40. #
  41. # Usages:
  42. #
  43. # DtkshAddButtons parent widgetClass label1 callback1 [label2 callback2 ...]
  44. #
  45. # DtkshAddButtons [-w] parent widgetClass variable1 label1 callback1 \
  46. # [variable2 label2 callback2 ...]
  47. #
  48. # The "-w" option indicates that the convenience function should return
  49. # the widget handle for each of the created buttons. The widget handle
  50. # is returned in the specified environment variable.
  51. #
  52. # The widgetClass can be one of the following, and will default to the
  53. # XmPushButtonGadget class, if not specified:
  54. #
  55. # XmPushButton
  56. # XmPushButtonGadget
  57. # XmToggleButton
  58. # XmToggleButtonGadget
  59. # XmCascadeButton
  60. # XmCascadeButtonGadget
  61. #
  62. # Examples:
  63. #
  64. # DtkshAddButtons $MENU XmPushButtonGadget Open do_Open Save do_Save Quit exit
  65. #
  66. # DtkshAddButtons -w $MENU XmPushButtonGadget B1 Open do_Open B2 Save do_Save
  67. #
  68. DtkshAddButtons()
  69. {
  70. typeset parent widgetClass callback returnWidget="false" TMP=""
  71. typeset -i paramCount=2
  72. if [ $# -ge 1 ] && [ x"$1" = "x-w" ]; then
  73. returnWidget=true
  74. paramCount=3
  75. shift
  76. fi
  77. if [ $# -lt 2 ]; then
  78. return 1
  79. fi
  80. parent=$1
  81. shift
  82. widgetClass=${1:-XmPushButtonGadget}
  83. shift
  84. case $widgetClass in
  85. XmPushButtonGadget) callback=activateCallback;;
  86. XmPushButton) callback=activateCallback;;
  87. XmToggleButtonGadget) callback=valueChangedCallback;;
  88. XmToggleButton) callback=valueChangedCallback;;
  89. XmCascadeButtonGadget) callback=activateCallback;;
  90. XmCascadeButton) callback=activateCallback;;
  91. *) return 1
  92. esac
  93. while [ $# -ge $paramCount ]
  94. do
  95. if [ "$returnWidget" = true ]; then
  96. if [ ! "$3" = "" ]; then
  97. XtCreateManagedWidget "$1" "$1" $widgetClass "$parent" \
  98. labelString:"$2" ${callback}:"$3"
  99. else
  100. XtCreateManagedWidget "$1" "$1" $widgetClass "$parent" \
  101. labelString:"$2"
  102. fi
  103. shift 3
  104. else
  105. if [ ! "$2" = "" ]; then
  106. XtCreateManagedWidget Id "btn" $widgetClass "$parent" \
  107. labelString:"$1" ${callback}:"$2"
  108. else
  109. XtCreateManagedWidget Id "btn" $widgetClass "$parent" \
  110. labelString:"$1"
  111. fi
  112. shift 2
  113. fi
  114. done
  115. return 0
  116. }
  117. ###############################################################################
  118. #
  119. # DtkshSetReturnKeyControls - Convenience function for configuring a text
  120. # widget (within a form!) so that the Return key does not
  121. # activate the default button within the form, but instead
  122. # moves the focus to the next text widget within the form.
  123. # This is useful if you have a window which contains a
  124. # series of text fields, and the default button should not
  125. # be activated until the user presses the Return key in the
  126. # last text field.
  127. #
  128. # Usage:
  129. #
  130. # DtkshSetReturnKeyControls textWidgetId nextTextWidgetId formWidgetId \
  131. # defaultButtonId
  132. #
  133. # The textWidgetId parameter specifies the widget which is to be configured
  134. # to catch the 'Return' key, and force the focus to move to the next text
  135. # widget (as indicated by the nextTextWidgetId parameter). The formWidgetId
  136. # parameter specifies the form which contains the default button, and should
  137. # be the parent of the two text widgets. The defaultButtonId indicates which
  138. # component is to be treated as the default button within the form.
  139. #
  140. # Examples:
  141. #
  142. # DtkshSetReturnKeyControls $TEXT1 $TEXT2 $FORM $OK
  143. # DtkshSetReturnKeyControls $TEXT2 $TEXT3 $FORM $OK
  144. #
  145. DtkshSetReturnKeyControls()
  146. {
  147. if [ $# -ne 4 ]; then
  148. return 1
  149. fi
  150. XtAddCallback $1 focusCallback "XtSetValues $3 defaultButton:NULL"
  151. XtAddCallback $1 losingFocusCallback "XtSetValues $3 defaultButton:$4"
  152. XtOverrideTranslations $1 \
  153. "Ctrl<Key>Return:ksh_eval(\"XmProcessTraversal $2 TRAVERSE_CURRENT\")
  154. <Key>Return:ksh_eval(\"XmProcessTraversal $2 TRAVERSE_CURRENT\")"
  155. return 0
  156. }
  157. ###############################################################################
  158. #
  159. # DtkshUnder
  160. # DtkshOver
  161. # DtkshRightOf
  162. # DtkshLeftOf - Convenience functions for specifying form constraints.
  163. # This set of functions allow a component to be attached
  164. # to one of the edges of another component.
  165. #
  166. # Usages:
  167. #
  168. # DtkshUnder widgetId [offset]
  169. # DtkshOver widgetId [offset]
  170. # DtkshRightOf widgetId [offset]
  171. # DtkshLeftOf widgetId [offset]
  172. #
  173. # The widgetId parameter specifies the widget to which the current
  174. # component is to be attached. The offset value is optional, and
  175. # defaults to 0 if not specified.
  176. #
  177. # Examples:
  178. #
  179. # XtCreateManagedWidget BUTTON2 button2 XmPushButton $FORM \
  180. # labelString:"Exit" \
  181. # $(DtkshUnder $BUTTON1)
  182. #
  183. DtkshUnder()
  184. {
  185. if [ $# -lt 1 ]; then
  186. return 1
  187. fi
  188. echo "topWidget:$1 topAttachment:ATTACH_WIDGET topOffset:${2:-0}"
  189. }
  190. DtkshOver()
  191. {
  192. if [ $# -lt 1 ]; then
  193. return 1
  194. fi
  195. echo "bottomWidget:$1 bottomAttachment:ATTACH_WIDGET bottomOffset:${2:-0}"
  196. }
  197. DtkshRightOf()
  198. {
  199. if [ $# -lt 1 ]; then
  200. return 1
  201. fi
  202. echo "leftWidget:$1 leftAttachment:ATTACH_WIDGET leftOffset:${2:-0}"
  203. }
  204. DtkshLeftOf()
  205. {
  206. if [ $# -lt 1 ]; then
  207. return 1
  208. fi
  209. echo "rightWidget:$1 rightAttachment:ATTACH_WIDGET rightOffset:${2:-0}"
  210. }
  211. ###############################################################################
  212. #
  213. # DtkshFloatRight
  214. # DtkshFloatLeft
  215. # DtkshFloatTop
  216. # DtkshFloatBottom - Convenience functions for specifying form constraints.
  217. # This set of functions allow a component to be positioned
  218. # independent of the other components within the form.
  219. # As the form grows or shrinks, the component maintains
  220. # its relative position within the form. The component
  221. # may still grow or shrink, depending upon the other form
  222. # constraints which have been specified for the component.
  223. #
  224. # Usages:
  225. #
  226. # DtkshFloatRight [position]
  227. # DtkshFloatLeft [position]
  228. # DtkshFloatTop [position]
  229. # DtkshFloatBottom [position]
  230. #
  231. # The optional position parameter specifies the relative position
  232. # to which the indicated edge of the component will be positioned.
  233. # A default position is used, if not specified.
  234. #
  235. # Examples:
  236. #
  237. # XtCreateManagedWidget BUTTON1 button1 XmPushButton $FORM \
  238. # labelString:"Ok" \
  239. # $(DtkshUnder $SEPARATOR) \
  240. # $(DtkshFloatLeft 10) \
  241. # $(DtkshFloatRight 40)
  242. #
  243. DtkshFloatRight()
  244. {
  245. echo "rightAttachment:ATTACH_POSITION rightPosition:${1:-0}"
  246. }
  247. DtkshFloatLeft()
  248. {
  249. echo "leftAttachment:ATTACH_POSITION leftPosition:${1:-0}"
  250. }
  251. DtkshFloatTop()
  252. {
  253. echo "topAttachment:ATTACH_POSITION topPosition:${1:-0}"
  254. }
  255. DtkshFloatBottom()
  256. {
  257. echo "bottomAttachment:ATTACH_POSITION bottomPosition:${1:-0}"
  258. }
  259. ###############################################################################
  260. #
  261. # DtkshAnchorRight
  262. # DtkshAnchorLeft
  263. # DtkshAnchorTop
  264. # DtkshAnchorBottom - Convenience functions for specifying form constraints.
  265. # This set of functions allow a component to be attached
  266. # to one of the edges of the form in such a fashion that
  267. # as the form grows or shrinks, the component's position
  268. # does not change. However, depending upon the other
  269. # form constaints set on this component, the component
  270. # may still grow or shrink in size.
  271. #
  272. # Usages:
  273. #
  274. # DtkshAnchorRight [offset]
  275. # DtkshAnchorLeft [offset]
  276. # DtkshAnchorTop [offset]
  277. # DtkshAnchorBottom [offset]
  278. #
  279. # The optional offset parameter specifies how far from the edge
  280. # of the form the component should be positioned. If an offset
  281. # is not specified, then 0 is user.
  282. #
  283. # Examples:
  284. #
  285. # XtCreateManagedWidget BUTTON1 button1 XmPushButton $FORM \
  286. # labelString:"Ok" \
  287. # $(DtkshUnder $SEPARATOR) \
  288. # $(DtkshAnchorLeft 10) \
  289. # $(DtkshAnchorBottom 10)
  290. #
  291. DtkshAnchorRight()
  292. {
  293. echo "rightAttachment:ATTACH_FORM rightOffset:${1:-0}"
  294. }
  295. DtkshAnchorLeft()
  296. {
  297. echo "leftAttachment:ATTACH_FORM leftOffset:${1:-0}"
  298. }
  299. DtkshAnchorTop()
  300. {
  301. echo "topAttachment:ATTACH_FORM topOffset:${1:-0}"
  302. }
  303. DtkshAnchorBottom()
  304. {
  305. echo "bottomAttachment:ATTACH_FORM bottomOffset:${1:-0}"
  306. }
  307. ###############################################################################
  308. #
  309. # DtkshSpanWidth
  310. # DtkshSpanHeight - Convenience functions for specifying form constraints.
  311. # This set of functions allow a component to be configured
  312. # such that it spans either the full height or width of
  313. # the form widget. This effect is accomplished by attaching
  314. # two edges of the component (top & bottom for DtkshSpanHeight,
  315. # and left and right for DtkshSpanWidth) to the form. The
  316. # component will typically resize whenever the form is
  317. # resized.
  318. #
  319. # Usages:
  320. #
  321. # DtkshSpanWidth [offset]
  322. # DtkshSpanHeight [offset]
  323. #
  324. # The optional offset parameter specifies how far from the edge
  325. # of the form the component should be positioned. If an offset
  326. # is not specified, then 0 is user.
  327. #
  328. # Examples:
  329. #
  330. # XtCreateManagedWidget SEPARATOR $FORM XmSeparator \
  331. # $(DtkshSpanWidth 1 1)
  332. #
  333. DtkshSpanWidth()
  334. {
  335. echo "leftAttachment:ATTACH_FORM leftOffset:${1:-0} \
  336. rightAttachment:ATTACH_FORM rightOffset:${2:-0}"
  337. }
  338. DtkshSpanHeight()
  339. {
  340. echo "topAttachment:ATTACH_FORM topOffset:${1:-0} \
  341. bottomAttachment:ATTACH_FORM bottomOffset:${2:-0}"
  342. }
  343. ###############################################################################
  344. #
  345. # DtkshDisplayInformationDialog
  346. # DtkshDisplayQuestionDialog
  347. # DtkshDisplayWarningDialog
  348. # DtkshDisplayWorkingDialog
  349. # DtkshDisplayErrorDialog - Convenience functions for creating a single
  350. # instance of each of the flavors of the Motif
  351. # feedback dialog. If an instance of the requested
  352. # type of dialog already exists, then it will be
  353. # reused. The parent of the dialog is obtained
  354. # from the environment variable $TOPLEVEL, which
  355. # should be set by the calling shell script. The
  356. # handle for the requested dialog is returned in
  357. # one of the following environment variables:
  358. #
  359. # _DT_ERROR_DIALOG_HANDLE
  360. # _DT_QUESTION_DIALOG_HANDLE
  361. # _DT_WORKING_DIALOG_HANDLE
  362. # _DT_WARNING_DIALOG_HANDLE
  363. # _DT_INFORMATION_DIALOG_HANDLE
  364. #
  365. # WARNING: IF ATTACHING YOUR OWN CALLBACKS TO THE DIALOG
  366. # BUTTONS, DO NOT DESTROY THE DIALOG WHEN YOU
  367. # ARE DONE WITH IT; SIMPLY UNMANAGE THE DIALOG,
  368. # SO THAT IT CAN BE USED AT A LATER TIME.
  369. #
  370. # Usages:
  371. #
  372. # DtDisplay*Dialog title message okCallback closeCallback helpCallback \
  373. # dialogStyle
  374. #
  375. # The "Ok" button is always managed, and by default will simply unmanage
  376. # the dialog. The "Cancel" and "Help" buttons are only managed when a
  377. # callback is supplied for them.
  378. #
  379. # The "dialogStyle" parameter accepts any of the standard resource settings
  380. # supported by the bulletin board widget.
  381. #
  382. # Examples:
  383. #
  384. # DtkshDisplayErrorDialog "Read Error" "Unable to read the file" \
  385. # "OkCallback" "CancelCallback" "" \
  386. # DIALOG_PRIMARY_APPLICATION_MODAL
  387. #
  388. # Global feedback dialog handles
  389. _DT_ERROR_DIALOG_HANDLE=""
  390. _DT_QUESTION_DIALOG_HANDLE=""
  391. _DT_WORKING_DIALOG_HANDLE=""
  392. _DT_WARNING_DIALOG_HANDLE=""
  393. _DT_INFORMATION_DIALOG_HANDLE=""
  394. _DT_TMP_DIALOG_HANDLE=""
  395. DtkshDisplayErrorDialog()
  396. {
  397. _DtDisplayFeedbackDialog "$_DT_ERROR_DIALOG_HANDLE" "Error" "${@:-}"
  398. if [ "$_DT_ERROR_DIALOG_HANDLE" = "" ] ; then
  399. _DT_ERROR_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  400. fi
  401. return 0
  402. }
  403. DtkshDisplayQuestionDialog()
  404. {
  405. _DtDisplayFeedbackDialog "$_DT_QUESTION_DIALOG_HANDLE" "Question" "${@:-}"
  406. if [ "$_DT_QUESTION_DIALOG_HANDLE" = "" ] ; then
  407. _DT_QUESTION_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  408. fi
  409. return 0
  410. }
  411. DtkshDisplayWorkingDialog()
  412. {
  413. _DtDisplayFeedbackDialog "$_DT_WORKING_DIALOG_HANDLE" "Working" "${@:-}"
  414. if [ "$_DT_WORKING_DIALOG_HANDLE" = "" ] ; then
  415. _DT_WORKING_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  416. fi
  417. return 0
  418. }
  419. DtkshDisplayWarningDialog()
  420. {
  421. _DtDisplayFeedbackDialog "$_DT_WARNING_DIALOG_HANDLE" "Warning" "${@:-}"
  422. if [ "$_DT_WARNING_DIALOG_HANDLE" = "" ] ; then
  423. _DT_WARNING_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  424. fi
  425. return 0
  426. }
  427. DtkshDisplayInformationDialog()
  428. {
  429. _DtDisplayFeedbackDialog "$_DT_INFORMATION_DIALOG_HANDLE" "Information" \
  430. "${@:-}"
  431. if [ "$_DT_INFORMATION_DIALOG_HANDLE" = "" ] ; then
  432. _DT_INFORMATION_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  433. fi
  434. return 0
  435. }
  436. ###############################################################################
  437. #
  438. # DtkshDisplayQuickHelpDialog
  439. # DtkshDisplayHelpDialog - Convenience functions for creating a single
  440. # instance of a help dialog and a quick help
  441. # dialog. If an instance of the requested type
  442. # of help dialog already exists, then it will be
  443. # reused. The parent of the dialog is obtained
  444. # from the environment variable $TOPLEVEL, which
  445. # should be set by the calling shell script. The
  446. # handle for the requested dialog is returned in
  447. # one of the following environment variables:
  448. #
  449. # _DT_HELP_DIALOG_HANDLE
  450. # _DT_QUICK_HELP_DIALOG_HANDLE
  451. #
  452. # WARNING: DO NOT DESTROY THIS DIALOG, UNLESS YOU ALSO CLEAR THE
  453. # CORRESPONDING ENVIRONMENT VARIABLE, SO THAT THIS CODE
  454. # WILL NOT ATTEMPT TO REUSE THE DIALOG AGAIN.
  455. #
  456. # Usages:
  457. #
  458. # DtDisplay*HelpDialog title helpType helpInformation [locationId]
  459. #
  460. # The meaning of the parameters is dependent upon the value specified
  461. # for the 'helpType' parameter. There meanings are explained below:
  462. #
  463. # helpType = HELP_TYPE_TOPIC
  464. # helpInformation = help volume name
  465. # locationId = help topic location id
  466. #
  467. # helpType = HELP_TYPE_STRING
  468. # helpInformation = help string
  469. # locationId = <not used>
  470. #
  471. # helpType = HELP_TYPE_DYNAMIC_STRING
  472. # helpInformation = help string
  473. # locationId = <not used>
  474. #
  475. # helpType = HELP_TYPE_MAN_PAGE
  476. # helpInformation = man page name
  477. # locationId = <not used>
  478. #
  479. # helpType = HELP_TYPE_FILE
  480. # helpInformation = help file name
  481. # locationId = <not used>
  482. #
  483. # Examples:
  484. #
  485. # DtkshDisplayHelpDialog "Help On Dtksh" HELP_TYPE_FILE "HelpFileName"
  486. #
  487. # Global help dialog handles
  488. _DT_HELP_DIALOG_HANDLE=""
  489. _DT_QUICK_HELP_DIALOG_HANDLE=""
  490. DtkshDisplayQuickHelpDialog()
  491. {
  492. _DtkshDisplayHelpDialog "$_DT_QUICK_HELP_DIALOG_HANDLE" "Quick" "${@:-}"
  493. if [ "$_DT_QUICK_HELP_DIALOG_HANDLE" = "" ] ; then
  494. _DT_QUICK_HELP_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  495. fi
  496. }
  497. DtkshDisplayHelpDialog()
  498. {
  499. _DtkshDisplayHelpDialog "$_DT_HELP_DIALOG_HANDLE" "" "${@:-}"
  500. if [ "$_DT_HELP_DIALOG_HANDLE" = "" ] ; then
  501. _DT_HELP_DIALOG_HANDLE=$_DT_TMP_DIALOG_HANDLE
  502. fi
  503. }
  504. ##############################################################################
  505. #
  506. # This internal shell function performs most of the work required to
  507. # create an instance of a feedback dialog (error, warning, information,
  508. # working and question). It will reuse an existing instance of the
  509. # requested type of feedback dialog, if one has already been created;
  510. # otherwise, it will create a new one.
  511. #
  512. # The "Ok" button is always managed, and by default will simply unpost
  513. # the dialog. The "Cancel" and "Help" buttons are only managed if the
  514. # callers specifies a callback for the butttons. Both the "Ok" and
  515. # "Cancel" buttons rely on the fact that the 'autoUnpost' resource for
  516. # the dialog is 'True'.
  517. #
  518. # The implied parent of the dialog is identified by the environment
  519. # variable '$TOPLEVEL'.
  520. #
  521. # The incoming parameters are defined as follows (note that $1 and $2 are
  522. # defined by the convenience function which is calling us, while $3 - $8
  523. # are the parameters which were passed by the caller to the convenience
  524. # function:
  525. #
  526. # $1 = existing dialog handle, or "" if first time
  527. # $2 = type of feedback dialog (Information, Question, Working, ... )
  528. # $3 = dialog title
  529. # $4 = message string
  530. # $5 = okCallback
  531. # $6 = cancelCallback
  532. # $7 = helpCallback
  533. # $8 = dialogStyle
  534. #
  535. _DtDisplayFeedbackDialog()
  536. {
  537. if [ "$1" = "" ]; then
  538. XmCreate${2}Dialog _DT_TMP_DIALOG_HANDLE $TOPLEVEL "$2"
  539. else
  540. _DT_TMP_DIALOG_HANDLE=$1
  541. fi
  542. XtSetValues $_DT_TMP_DIALOG_HANDLE \
  543. dialogTitle:"${3:-$2}" \
  544. messageString:"${4:- }" \
  545. dialogStyle:"${8:-DIALOG_MODELESS}"
  546. if [ $# -ge 5 ] && [ "$5" != "" ]; then
  547. XtSetValues $_DT_TMP_DIALOG_HANDLE okCallback:"$5"
  548. fi
  549. if [ $# -lt 6 ] || [ "$6" = "" ]; then
  550. XtUnmanageChild $(XmMessageBoxGetChild "-" $_DT_TMP_DIALOG_HANDLE \
  551. DIALOG_CANCEL_BUTTON)
  552. else
  553. XtSetValues $_DT_TMP_DIALOG_HANDLE cancelCallback:"$6"
  554. fi
  555. if [ $# -lt 7 ] || [ "$7" = "" ]; then
  556. XtUnmanageChild $(XmMessageBoxGetChild "-" $_DT_TMP_DIALOG_HANDLE \
  557. DIALOG_HELP_BUTTON)
  558. else
  559. XtSetValues $_DT_TMP_DIALOG_HANDLE helpCallback:"$7"
  560. fi
  561. _DtkshPositionDialog "$1"
  562. XtManageChild $_DT_TMP_DIALOG_HANDLE
  563. return 0
  564. }
  565. ##############################################################################
  566. #
  567. # This internal shell function performs most of the work required to
  568. # create an instance of a help dialog (regular help or quick help)
  569. # It will reuse an existing instance of the requested type of help
  570. # dialog, if one has already been created; otherwise, it will create
  571. # a new one.
  572. #
  573. # The implied parent of the dialog is identified by the environment
  574. # variable '$TOPLEVEL'.
  575. #
  576. # The incoming parameters are defined as follows (note that $1 and $2 are
  577. # defined by the convenience function which is calling us, while $3 - $6
  578. # are the parameters which were passed by the caller to the convenience
  579. # function:
  580. #
  581. # $1 = existing dialog handle, or "" if first time
  582. # $2 = type of help dialog (Quick or "")
  583. # $3 = dialog title
  584. # $4 = help type
  585. # $5 = help information:
  586. # help volume (if help type = HELP_TYPE_TOPIC)
  587. # help string (if help type = HELP_TYPE_STRING)
  588. # help string (if help type = HELP_TYPE_DYNAMIC_STRING)
  589. # man page name (if help type = HELP_TYPE_MAN_PAGE)
  590. # help file name (if help type = HELP_TYPE_FILE)
  591. # $6 = help location Id (if help type = HELP_TYPE_TOPIC)
  592. #
  593. _DtkshDisplayHelpDialog()
  594. {
  595. typeset helpType ARG1="" ARG2="" ARG3=""
  596. typeset helpType VAL1="" VAL2="" VAL3=""
  597. helpType="${4:-HELP_TYPE_TOPIC}"
  598. ARG1="helpType:"
  599. VAL1="$helpType"
  600. case $helpType in
  601. HELP_TYPE_TOPIC) ARG2="helpVolume:"
  602. VAL2="${5:-}"
  603. ARG3="locationId:"
  604. VAL3="${6:-_HOMETOPIC}";;
  605. HELP_TYPE_STRING) ARG2="stringData:"
  606. VAL2="${5:-}";;
  607. HELP_TYPE_DYNAMIC_STRING) ARG2="stringData:"
  608. VAL2="${5:-}";;
  609. HELP_TYPE_MAN_PAGE) ARG2="manPage:"
  610. VAL2="${5:-}";;
  611. HELP_TYPE_FILE) ARG2="helpFile:"
  612. VAL2="${5:-}";;
  613. *) return 1;;
  614. esac
  615. if [ "$1" = "" ]; then
  616. if [ "$ARG3" != "" ]; then
  617. DtCreateHelp${2}Dialog _DT_TMP_DIALOG_HANDLE $TOPLEVEL "$2" \
  618. "${ARG1}${VAL1}" "${ARG2}${VAL2}" "${ARG3}${VAL3}"
  619. else
  620. DtCreateHelp${2}Dialog _DT_TMP_DIALOG_HANDLE $TOPLEVEL "$2" \
  621. "${ARG1}${VAL1}" "${ARG2}${VAL2}"
  622. fi
  623. else
  624. _DT_TMP_DIALOG_HANDLE=$1
  625. if [ "$ARG3" != "" ]; then
  626. XtSetValues $_DT_TMP_DIALOG_HANDLE \
  627. "${ARG1}${VAL1}" "${ARG2}${VAL2}" "${ARG3}${VAL3}"
  628. else
  629. XtSetValues $_DT_TMP_DIALOG_HANDLE \
  630. "${ARG1}${VAL1}" "${ARG2}${VAL2}"
  631. fi
  632. fi
  633. if [ "$2" = "Quick" ]; then
  634. XtSetSensitive $(DtHelpQuickDialogGetChild "-" $_DT_TMP_DIALOG_HANDLE \
  635. HELP_QUICK_HELP_BUTTON) false
  636. fi
  637. XtSetValues $(XtParent "-" $_DT_TMP_DIALOG_HANDLE) title:"${3:-Help}"
  638. _DtkshPositionDialog "$1"
  639. XtManageChild $_DT_TMP_DIALOG_HANDLE
  640. return 0
  641. }
  642. ##############################################################################
  643. #
  644. # This internal shell function takes care of positioning the dialog so
  645. # that it is centered over the window for which it is transient; if the
  646. # window it is transient for is not currently managed, then the window
  647. # will be positioned over in the center of the screen.
  648. #
  649. # Positioning does not occur that first time the dialog is posted; that
  650. # is taken care of automatically by Motif and the window manager. It
  651. # only needs to happen for subsequent postings.
  652. #
  653. _DtkshPositionDialog()
  654. {
  655. typeset -i WIDTH HEIGHT X_P Y_P WIDTH_P HEIGHT_P
  656. typeset -i finalX finalY
  657. if [ "$1" != "" ] && ! XtIsManaged $1 && XtIsShell $TOPLEVEL ; then
  658. XtGetValues $1 width:WIDTH height:HEIGHT
  659. if XtIsRealized $TOPLEVEL; then
  660. XtGetValues $TOPLEVEL x:X_P y:Y_P width:WIDTH_P height:HEIGHT_P
  661. (( finalX=$X_P+($WIDTH_P-$WIDTH)/2 ))
  662. (( finalY=$Y_P+($HEIGHT_P-$HEIGHT)/2 ))
  663. else
  664. (( finalX=($(XWidthOfScreen "-" $(XtScreen "-" $1) )-$WIDTH)/2 ))
  665. (( finalY=($(XHeightOfScreen "-" $(XtScreen "-" $1) )-$HEIGHT)/2 ))
  666. fi
  667. XtSetValues $(XtParent "-" $1) x:$finalX y:$finalY
  668. fi
  669. }