SearchDlg.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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: SearchDlg.c /main/4 1996/08/28 16:51:52 drk $ */
  24. /**********************************<+>*************************************
  25. ***************************************************************************
  26. **
  27. ** File: SearchDlg.c
  28. **
  29. ** Project: Editor widget
  30. **
  31. ** Description: Routines which manipulate the dialogs associated with
  32. ** find/change functions.
  33. ** -----------
  34. **
  35. *******************************************************************
  36. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  37. * (c) Copyright 1993, 1994 International Business Machines Corp.
  38. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  39. * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
  40. ********************************************************************
  41. **
  42. **
  43. **************************************************************************
  44. **********************************<+>*************************************/
  45. #include "EditorP.h"
  46. #include <Xm/DialogS.h>
  47. #include <Xm/PushBG.h>
  48. #include <Xm/Separator.h>
  49. #include <Xm/Form.h>
  50. #include <Xm/ScrollBar.h>
  51. #include <Xm/List.h>
  52. #include <Xm/LabelG.h>
  53. #include <Xm/TextF.h>
  54. #include <Xm/MwmUtil.h>
  55. #include <Dt/DtMsgsP.h>
  56. static void ManageFind(
  57. DtEditorWidget pPriv);
  58. static void UnmanageFind(
  59. DtEditorWidget pPriv);
  60. static void CreateSearchDialog(
  61. DtEditorWidget pPriv);
  62. static void
  63. ManageFind(
  64. DtEditorWidget pPriv)
  65. {
  66. Arg al[10];
  67. int ac;
  68. ac = 0;
  69. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  70. XtSetArg(al[ac], XmNtopWidget, M_findText(pPriv)); ac++;
  71. XtSetArg(al[ac], XmNtopOffset, 10); ac++;
  72. XtSetValues(M_search_replaceLbl(pPriv), al, ac);
  73. XtManageChild(M_search_findLbl(pPriv));
  74. XtManageChild(M_findText(pPriv));
  75. }
  76. static void
  77. UnmanageFind(
  78. DtEditorWidget pPriv)
  79. {
  80. Arg al[10];
  81. int ac;
  82. XtUnmanageChild(M_search_findLbl(pPriv));
  83. XtUnmanageChild(M_findText(pPriv));
  84. ac = 0;
  85. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  86. XtSetArg(al[ac], XmNtopWidget, M_search_spellList(pPriv)); ac++;
  87. XtSetArg(al[ac], XmNtopOffset, 10); ac++;
  88. XtSetValues(M_search_replaceLbl(pPriv), al, ac);
  89. }
  90. /************************************************************************
  91. *
  92. * _DtEditorSearch - Post a dialog asking for search string
  93. *
  94. ************************************************************************/
  95. void
  96. _DtEditorSearch(
  97. DtEditorWidget pPriv,
  98. Boolean spell,
  99. Boolean createonly )
  100. {
  101. Arg al[10]; /* arg list */
  102. int ac; /* arg count */
  103. /* create the dialog if it is the first time */
  104. if ( !M_search_dialog(pPriv) )
  105. CreateSearchDialog(pPriv);
  106. if (!createonly)
  107. {
  108. /* Prepare to display the dialog */
  109. XtUnmanageChild(M_search_dialog(pPriv));
  110. /*
  111. * Turn off the Find, Change, and Change All buttons.
  112. * They will be turned on by the appropriate callback.
  113. */
  114. _DtEditorSetFindSensitivity(pPriv, False);
  115. _DtEditorSetReplaceSensitivity(pPriv, False);
  116. _DtEditorSetReplaceAllSensitivity(pPriv, False);
  117. /*
  118. * Clear the Change To field. If in Find/Change mode it will
  119. * be seeded with the last replace string, in Spell mode it will
  120. * remain blank.
  121. */
  122. XmTextFieldSetString( M_replaceText(pPriv), (char *)NULL );
  123. if (spell)
  124. {
  125. /*
  126. * Set it up as a Spell dialog
  127. */
  128. Position y;
  129. Dimension height, formHeight;
  130. M_search_dialogMode(pPriv) = SPELL;
  131. /*
  132. * Set the dialog title.
  133. * If DtNdialogTitle has been set then prepend it.
  134. */
  135. if ( E_dialogTitle(pPriv) != (XmString)NULL) {
  136. XmString titleStr = XmStringConcat( E_dialogTitle(pPriv),
  137. M_spellTitle(pPriv) );
  138. XtSetArg(al[0],XmNdialogTitle,titleStr);
  139. XtSetValues(M_search_dialog(pPriv), al, 1);
  140. XmStringFree( titleStr );
  141. }
  142. else {
  143. XtSetArg(al[0],XmNdialogTitle,M_spellTitle(pPriv));
  144. XtSetValues(M_search_dialog(pPriv), al, 1);
  145. }
  146. ac = 0;
  147. XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
  148. XtSetValues(XtParent(M_search_spellList(pPriv)), al, ac);
  149. XtManageChild(M_search_listLbl(pPriv));
  150. XtManageChild(XtParent(M_search_spellList(pPriv)));
  151. /*
  152. * Select first item in list which will cause its selectCB
  153. * to sensitize the Find button and clear the Change To field.
  154. */
  155. XmListSelectPos(M_search_spellList(pPriv), 1, True);
  156. /*
  157. * Hide the Find field & label
  158. */
  159. UnmanageFind(pPriv);
  160. ac = 0;
  161. XtSetArg(al[ac], XmNy, &y); ac++;
  162. XtSetArg(al[ac], XmNheight, &height); ac++;
  163. XtGetValues(XtParent(M_search_spellList(pPriv)), al, ac);
  164. ac = 0;
  165. XtSetArg(al[ac], XmNheight, &formHeight); ac++;
  166. XtGetValues(M_search_dialog(pPriv), al, ac);
  167. ac = 0;
  168. XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  169. XtSetArg(al[ac], XmNbottomOffset, formHeight - (y + height)); ac++;
  170. XtSetValues(XtParent(M_search_spellList(pPriv)), al, ac);
  171. }
  172. else
  173. {
  174. /*
  175. * Set it up as a Find/Change dialog
  176. */
  177. XEvent event;
  178. M_search_dialogMode(pPriv) = REPLACE;
  179. /*
  180. * Set the dialog title.
  181. * If DtNdialogTitle has been set then prepend it.
  182. */
  183. ac = 0;
  184. if ( E_dialogTitle(pPriv) != (XmString)NULL) {
  185. XmString titleStr = XmStringConcat( E_dialogTitle(pPriv),
  186. M_fndChngTitle(pPriv) );
  187. XtSetArg(al[0], XmNdialogTitle, titleStr);
  188. XtSetValues(M_search_dialog(pPriv), al, 1);
  189. XmStringFree( titleStr );
  190. }
  191. else {
  192. XtSetArg( al[0], XmNdialogTitle,M_fndChngTitle(pPriv) );
  193. XtSetValues(M_search_dialog(pPriv), al, 1);
  194. }
  195. /*
  196. * Show the Find field & label
  197. */
  198. ManageFind(pPriv);
  199. /*
  200. * Seed the Find field with the last string we searched for
  201. * and select it. This will cause _DtEditorFindTextChangedCB
  202. * to enable the Find & Change All buttons.
  203. */
  204. if ( M_search_string(pPriv) ) {
  205. XmTextFieldSetString(M_findText(pPriv),M_search_string(pPriv));
  206. event.xkey.time = XtLastTimestampProcessed(M_display(pPriv));
  207. XtCallActionProc( (Widget) M_findText(pPriv), "select-all",
  208. &event, (String *)NULL, 0 );
  209. }
  210. else
  211. XmTextFieldSetString( M_findText(pPriv), (char *)NULL );
  212. /*
  213. * Seed the Change To field with the last replacement string.
  214. */
  215. if ( M_replace_string(pPriv) )
  216. XmTextFieldSetString( M_replaceText(pPriv),
  217. M_replace_string(pPriv) );
  218. /*
  219. * Hide the list of misspelled words
  220. */
  221. XtUnmanageChild(M_search_listLbl(pPriv));
  222. XtUnmanageChild(XtParent(M_search_spellList(pPriv)));
  223. }
  224. /*
  225. * Display the dialog
  226. */
  227. XtManageChild(M_search_dialog(pPriv));
  228. }
  229. if (M_search_dialogMode(pPriv) == SPELL)
  230. XmProcessTraversal(M_replaceText(pPriv), XmTRAVERSE_CURRENT);
  231. else
  232. XmProcessTraversal(M_findText(pPriv), XmTRAVERSE_CURRENT);
  233. }
  234. static void
  235. CreateSearchDialog(
  236. DtEditorWidget pPriv)
  237. {
  238. Arg al[10]; /* arg list */
  239. int ac; /* arg count */
  240. Pixel textBackground, textForeground;
  241. XmString tmpStr1;
  242. /*
  243. * The Find/Change & the Spell dialogs are the same dialog with
  244. * various components unmanaged depending upon the mode of the
  245. * dialog. There is no reason why these could not be separate
  246. * dialogs if they need to be. All of the callbacks and routines
  247. * which manipulate these dialogs are aware of the dialog's mode and
  248. * could be split into two separate callbacks/routines.
  249. */
  250. /*
  251. * Match the background & foreground colors of the edit window
  252. * Don't use DtNtextBackground/Foreground directly because they
  253. * will be DtUNSPECIFIED.
  254. */
  255. ac = 0;
  256. XtSetArg(al[ac], XmNforeground, &textForeground); ac++;
  257. XtSetArg(al[ac], XmNbackground, &textBackground); ac++;
  258. XtGetValues(M_text(pPriv), al, ac);
  259. /*
  260. * Create the form dialog.
  261. */
  262. ac = 0;
  263. M_search_dialog(pPriv) = XmCreateFormDialog(M_topLevelShell(pPriv),
  264. "findDlg", al, ac);
  265. ac = 0;
  266. XtSetArg(al[ac], XmNautoUnmanage, False); ac++;
  267. XtSetValues(M_search_dialog(pPriv), al, ac);
  268. /*
  269. * When creating the fields & buttons use the appropriate label
  270. * resource (e.g. DtNchangeButtonLabel), if it has been set, then
  271. * clear the resource to save space. The field or button widget
  272. * will contain the actual value & it can be gotten from there,
  273. * if it is needed.
  274. *
  275. * If the appropriate resource has not been set, use its default
  276. * value from the message catalog.
  277. */
  278. /*
  279. * Create the list of misspelled words
  280. */
  281. ac = 0;
  282. if (E_misspelledListLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  283. /*
  284. * Use the resource value & clear it (to save space).
  285. */
  286. tmpStr1 = XmStringCopy(E_misspelledListLabel(pPriv));
  287. E_misspelledListLabel(pPriv) = (XmString) DtUNSPECIFIED;
  288. }
  289. else {
  290. /*
  291. * The resource has not been set so use its default value
  292. */
  293. tmpStr1 = XmStringCreateLocalized(MISSPELLED);
  294. }
  295. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  296. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  297. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  298. XtSetArg(al[ac], XmNfontList, E_labelFontList(pPriv)); ac++;
  299. M_search_listLbl(pPriv) = XmCreateLabelGadget(M_search_dialog(pPriv),
  300. "listLbl", al, ac);
  301. XmStringFree(tmpStr1);
  302. XtManageChild(M_search_listLbl(pPriv));
  303. ac = 0;
  304. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  305. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  306. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  307. XtSetArg(al[ac], XmNtopWidget, M_search_listLbl(pPriv)); ac++;
  308. XtSetArg(al[ac], XmNscrollingPolicy, XmAUTOMATIC); ac++;
  309. XtSetArg(al[ac], XmNfontList, E_textFontList(pPriv)); ac++;
  310. M_search_spellList(pPriv) = XmCreateScrolledList(M_search_dialog(pPriv),
  311. "spellList", al, ac);
  312. XtManageChild(M_search_spellList(pPriv));
  313. XtManageChild(XtParent(M_search_spellList(pPriv)));
  314. XtAddCallback( M_search_spellList(pPriv), XmNhelpCallback,
  315. (XtCallbackProc)_DtEditorHelpSearchSpellCB,
  316. (XtPointer)pPriv );
  317. /*
  318. * Create the find field & its label
  319. */
  320. ac = 0;
  321. if (E_findFieldLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  322. /*
  323. * Use the resource value & clear it (to save space).
  324. */
  325. tmpStr1 = XmStringCopy(E_findFieldLabel(pPriv));
  326. E_findFieldLabel(pPriv) = (XmString) DtUNSPECIFIED;
  327. }
  328. else {
  329. /*
  330. * The resource has not been set so use its default value
  331. */
  332. tmpStr1 = XmStringCreateLocalized(FIND_LABEL);
  333. }
  334. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  335. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  336. XtSetArg(al[ac], XmNtopOffset, 10); ac++;
  337. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  338. XtSetArg(al[ac], XmNfontList, E_labelFontList(pPriv)); ac++;
  339. M_search_findLbl(pPriv) = XmCreateLabelGadget(M_search_dialog(pPriv),
  340. "findLbl", al, ac);
  341. XmStringFree(tmpStr1);
  342. ac = 0;
  343. XtSetArg (al[ac], XmNbackground, textBackground); ac++;
  344. XtSetArg (al[ac], XmNforeground, textForeground); ac++;
  345. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  346. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  347. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  348. XtSetArg(al[ac], XmNtopWidget, M_search_findLbl(pPriv)); ac++;
  349. XtSetArg(al[ac], XmNtopOffset, 5); ac++;
  350. XtSetArg(al[ac], XmNfontList, E_textFontList(pPriv)); ac++;
  351. M_findText(pPriv) = XmCreateTextField(M_search_dialog(pPriv), "findTxt",
  352. al, ac);
  353. XtAddCallback( M_findText(pPriv), XmNhelpCallback,
  354. (XtCallbackProc)_DtEditorHelpSearchFindCB,
  355. (XtPointer)pPriv );
  356. /*
  357. * Create the Change To field & its label
  358. */
  359. ac = 0;
  360. if (E_changeFieldLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  361. /*
  362. * Use the resource value & clear it (to save space).
  363. */
  364. tmpStr1 = XmStringCopy(E_changeFieldLabel(pPriv));
  365. E_changeFieldLabel(pPriv) = (XmString) DtUNSPECIFIED;
  366. }
  367. else {
  368. /*
  369. * The resource has not been set so use its default value
  370. */
  371. tmpStr1 = XmStringCreateLocalized(CHANGE_LABEL);
  372. }
  373. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  374. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  375. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  376. XtSetArg(al[ac], XmNtopWidget, M_findText(pPriv)); ac++;
  377. XtSetArg(al[ac], XmNtopOffset, 10); ac++;
  378. XtSetArg(al[ac], XmNfontList, E_labelFontList(pPriv)); ac++;
  379. M_search_replaceLbl(pPriv) = XmCreateLabelGadget(M_search_dialog(pPriv),
  380. "repLbl", al, ac);
  381. XmStringFree(tmpStr1);
  382. XtManageChild(M_search_replaceLbl(pPriv));
  383. ac = 0;
  384. XtSetArg (al[ac], XmNbackground, textBackground); ac++;
  385. XtSetArg (al[ac], XmNforeground, textForeground); ac++;
  386. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  387. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  388. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  389. XtSetArg(al[ac], XmNtopWidget, M_search_replaceLbl(pPriv)); ac++;
  390. XtSetArg(al[ac], XmNtopOffset, 5); ac++;
  391. XtSetArg(al[ac], XmNfontList, E_textFontList(pPriv)); ac++;
  392. M_replaceText(pPriv) = XmCreateTextField(M_search_dialog(pPriv), "repTxt",
  393. al, ac);
  394. XtManageChild(M_replaceText(pPriv));
  395. XtAddCallback( M_replaceText(pPriv), XmNhelpCallback,
  396. (XtCallbackProc)_DtEditorHelpSearchChangeCB,
  397. (XtPointer)pPriv );
  398. /*
  399. * Only enable Change To field if the widget is editable
  400. */
  401. XtSetSensitive(M_search_replaceLbl(pPriv), M_editable(pPriv));
  402. XtSetSensitive(M_replaceText(pPriv), M_editable(pPriv));
  403. ac = 0;
  404. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  405. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  406. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  407. XtSetArg(al[ac], XmNtopWidget, M_replaceText(pPriv)); ac++;
  408. XtSetArg(al[ac], XmNtopOffset, 5); ac++;
  409. M_search_separator(pPriv) =
  410. XmCreateSeparator(M_search_dialog(pPriv), "separator",
  411. al, ac);
  412. XtManageChild(M_search_separator(pPriv));
  413. /*
  414. * Create the buttons & their labels
  415. */
  416. /* Find button */
  417. ac = 0;
  418. if (E_findButtonLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  419. /*
  420. * Use the resource value & clear it (to save space).
  421. */
  422. tmpStr1 = XmStringCopy(E_findButtonLabel(pPriv));
  423. E_findButtonLabel(pPriv) = (XmString) DtUNSPECIFIED;
  424. }
  425. else {
  426. /*
  427. * The resource has not been set so use its default value
  428. */
  429. tmpStr1 = XmStringCreateLocalized(FIND_BUTTON);
  430. }
  431. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  432. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
  433. XtSetArg(al[ac], XmNleftPosition, 2); ac++;
  434. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
  435. XtSetArg(al[ac], XmNrightPosition, 33); ac++;
  436. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  437. XtSetArg(al[ac], XmNtopWidget, M_search_separator(pPriv)); ac++;
  438. XtSetArg(al[ac], XmNtopOffset, 7); ac++;
  439. XtSetArg(al[ac], XmNfontList, E_buttonFontList(pPriv)); ac++;
  440. M_search_findBtn(pPriv) = XmCreatePushButtonGadget(M_search_dialog(pPriv),
  441. "findBtn", al, ac);
  442. XmStringFree(tmpStr1);
  443. XtManageChild(M_search_findBtn(pPriv));
  444. /* Change button */
  445. ac = 0;
  446. if (E_changeButtonLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  447. /*
  448. * Use the resource value & clear it (to save space).
  449. */
  450. tmpStr1 = XmStringCopy(E_changeButtonLabel(pPriv));
  451. E_changeButtonLabel(pPriv) = (XmString) DtUNSPECIFIED;
  452. }
  453. else {
  454. /*
  455. * The resource has not been set so use its default value
  456. */
  457. tmpStr1 = XmStringCreateLocalized(CHANGE_BUTTON);
  458. }
  459. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  460. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
  461. XtSetArg(al[ac], XmNleftPosition, 35); ac++;
  462. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
  463. XtSetArg(al[ac], XmNrightPosition, 66); ac++;
  464. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  465. XtSetArg(al[ac], XmNtopWidget, M_search_separator(pPriv)); ac++;
  466. XtSetArg(al[ac], XmNtopOffset, 7); ac++;
  467. XtSetArg(al[ac], XmNfontList, E_buttonFontList(pPriv)); ac++;
  468. M_search_replaceBtn(pPriv) = XmCreatePushButtonGadget(
  469. M_search_dialog(pPriv),
  470. "replBtn", al, ac);
  471. XmStringFree(tmpStr1);
  472. XtManageChild(M_search_replaceBtn(pPriv));
  473. /* Change All button */
  474. ac = 0;
  475. if (E_changeAllButtonLabel(pPriv) != (XmString) DtUNSPECIFIED) {
  476. /*
  477. * Use the resource value & clear it (to save space).
  478. */
  479. tmpStr1 = XmStringCopy(E_changeAllButtonLabel(pPriv));
  480. E_changeAllButtonLabel(pPriv) = (XmString) DtUNSPECIFIED;
  481. }
  482. else {
  483. /*
  484. * The resource has not been set so use its default value
  485. */
  486. tmpStr1 = XmStringCreateLocalized(CHNG_ALL_BUTTON);
  487. }
  488. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  489. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
  490. XtSetArg(al[ac], XmNleftPosition, 68); ac++;
  491. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
  492. XtSetArg(al[ac], XmNrightPosition, 98); ac++;
  493. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  494. XtSetArg(al[ac], XmNtopWidget, M_search_separator(pPriv)); ac++;
  495. XtSetArg(al[ac], XmNtopOffset, 7); ac++;
  496. XtSetArg(al[ac], XmNfontList, E_buttonFontList(pPriv)); ac++;
  497. M_search_replaceAllBtn(pPriv) = XmCreatePushButtonGadget(
  498. M_search_dialog(pPriv),
  499. "replAllBtn", al, ac);
  500. XmStringFree(tmpStr1);
  501. XtManageChild(M_search_replaceAllBtn(pPriv));
  502. /* Close button */
  503. ac = 0;
  504. tmpStr1 = XmStringCreateLocalized(CLOSE_BUTTON);
  505. XtSetArg(al[ac], XmNlabelString, tmpStr1); ac++;
  506. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
  507. XtSetArg(al[ac], XmNleftPosition, 13); ac++;
  508. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
  509. XtSetArg(al[ac], XmNrightPosition, 43); ac++;
  510. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  511. XtSetArg(al[ac], XmNtopWidget, M_search_findBtn(pPriv)); ac++;
  512. XtSetArg(al[ac], XmNtopOffset, 2); ac++;
  513. XtSetArg(al[ac], XmNfontList, E_buttonFontList(pPriv)); ac++;
  514. M_search_closeBtn(pPriv) = XmCreatePushButtonGadget(M_search_dialog(pPriv),
  515. "closeBtn", al, ac);
  516. XmStringFree(tmpStr1);
  517. XtManageChild(M_search_closeBtn(pPriv));
  518. ac = 0;
  519. tmpStr1 = XmStringCreateLocalized(HELP_BUTTON);
  520. XtSetArg (al[ac], XmNlabelString, tmpStr1); ac++;
  521. XtSetArg(al[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
  522. XtSetArg(al[ac], XmNleftPosition, 56); ac++;
  523. XtSetArg(al[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
  524. XtSetArg(al[ac], XmNrightPosition, 86); ac++;
  525. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  526. XtSetArg(al[ac], XmNtopWidget, M_search_findBtn(pPriv)); ac++;
  527. XtSetArg(al[ac], XmNtopOffset, 2); ac++;
  528. XtSetArg(al[ac], XmNfontList, E_buttonFontList(pPriv)); ac++;
  529. M_search_helpBtn(pPriv) = XmCreatePushButtonGadget(M_search_dialog(pPriv),
  530. "helpBtn", al, ac);
  531. XmStringFree(tmpStr1);
  532. XtManageChild(M_search_helpBtn(pPriv));
  533. XtRemoveAllCallbacks(M_search_spellList(pPriv), XmNbrowseSelectionCallback);
  534. XtAddCallback(M_search_spellList(pPriv), XmNbrowseSelectionCallback,
  535. (XtCallbackProc) _DtEditorMisspelledSelectCB, pPriv);
  536. XtAddCallback(M_search_spellList(pPriv), XmNdefaultActionCallback,
  537. (XtCallbackProc) _DtEditorMisspelledDblClickCB, pPriv);
  538. ac = 0;
  539. XtSetArg(al[ac], XmNvisibleItemCount, 4); ac++;
  540. XtSetValues(M_search_spellList(pPriv), al, ac);
  541. ac = 0;
  542. XtSetArg(al[ac], XmNheight, &M_search_buttonHeight(pPriv)); ac++;
  543. XtGetValues(M_search_helpBtn(pPriv), al, ac);
  544. ac = 0;
  545. XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  546. XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  547. XtSetArg(al[ac], XmNtopWidget, M_replaceText(pPriv)); ac++;
  548. XtSetArg(al[ac], XmNtopOffset, 5); ac++;
  549. XtSetArg(al[ac], XmNbottomOffset, 2 * M_search_buttonHeight(pPriv) + 35);
  550. ac++;
  551. XtSetValues(M_search_separator(pPriv), al, ac);
  552. XtAddCallback(M_search_findBtn(pPriv), XmNactivateCallback,
  553. (XtCallbackProc) _DtEditorDialogSearchCB,
  554. (XtPointer) pPriv);
  555. XtAddCallback(M_search_replaceBtn(pPriv), XmNactivateCallback,
  556. (XtCallbackProc) _DtEditorDialogReplaceCB,
  557. (XtPointer) pPriv);
  558. XtAddCallback(M_search_replaceAllBtn(pPriv), XmNactivateCallback,
  559. (XtCallbackProc) _DtEditorDialogReplaceAllCB,
  560. (XtPointer) pPriv);
  561. XtAddCallback(M_search_closeBtn(pPriv), XmNactivateCallback,
  562. (XtCallbackProc) _DtEditorDialogFindCancelCB,
  563. (XtPointer) pPriv);
  564. XtAddCallback(M_search_helpBtn(pPriv), XmNactivateCallback,
  565. (XtCallbackProc) _DtEditorHelpSearchCB,
  566. (XtPointer) pPriv);
  567. XtAddCallback(M_search_dialog(pPriv), XmNmapCallback,
  568. (XtCallbackProc) _DtEditorSearchMapCB, pPriv);
  569. XtAddCallback(M_findText(pPriv), XmNvalueChangedCallback,
  570. (XtCallbackProc)_DtEditorFindTextChangedCB, pPriv);
  571. XtAddCallback(M_replaceText(pPriv), XmNvalueChangedCallback,
  572. (XtCallbackProc)_DtEditorReplaceTextChangedCB, pPriv);
  573. XtAddCallback(M_search_dialog(pPriv), XmNhelpCallback,
  574. (XtCallbackProc) _DtEditorHelpSearchCB, (XtPointer)pPriv);
  575. XtSetArg(al[0], XmNdefaultButton, M_search_closeBtn(pPriv));
  576. XtSetValues(M_search_dialog(pPriv), al, 1);
  577. XtRealizeWidget(M_search_dialog(pPriv));
  578. } /* end CreateSearchDialog */