1 
2 /* srch_dlg.c - part of asedit program */
3 
4 /*
5  * Copyright 1991 - 1994,  Andrzej Stochniol, London, UK
6  *
7  * ASEDIT text editor, both binary and source (hereafter, Software) is
8  * copyrighted by Andrzej Stochniol (hereafter, AS) and ownership remains
9  * with AS.
10  *
11  * AS grants you (hereafter, Licensee) a license to use the Software
12  * for academic, research and internal business purposes only, without a
13  * fee.  Licensee may distribute the binary and source code (if released)
14  * to third parties provided that the copyright notice and this statement
15  * appears on all copies and that no charge is associated with such copies.
16  *
17  * Licensee may make derivative works.  However, if Licensee distributes
18  * any derivative work based on or derived from the Software, then
19  * Licensee will:
20  * (1) notify AS regarding its distribution of the derivative work, and
21  * (2) clearly notify users that such derivative work is a modified version
22  *      and not the original ASEDIT distributed by AS.
23  *
24  * Any Licensee wishing to make commercial use of the Software should
25  * contact AS to negotiate an appropriate license for such commercial use.
26  * Commercial use includes:
27  * (1) integration of all or part of the source code into a product for sale
28  *     or license by or on behalf of Licensee to third parties, or
29  * (2) distribution of the binary code or source code to third parties that
30  *     need it to utilize a commercial product sold or licensed by or on
31  *     behalf of Licensee.
32  *
33  * A. STOCHNIOL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS
34  * SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
35  * IMPLIED WARRANTY.  IN NO EVENT SHALL A. STOCHNIOL BE LIABLE FOR ANY
36  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
37  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
38  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
39  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40  *
41  * By using or copying this Software, Licensee agrees to abide by the
42  * copyright law and all other applicable laws, and the terms of this
43  * license.
44  * AS shall have the right to terminate this license immediately by
45  * written notice upon Licensee's breach of, or non-compliance with, any
46  * of its terms.  Licensee may be held legally responsible for any
47  * copyright infringement that is caused or encouraged by Licensee's
48  * failure to abide by the terms of this license.
49  *
50  *
51  * 	Andrzej Stochniol	(A.Stochniol@ic.ac.uk)
52  * 	30 Hatch Road
53  * 	London SW16 4PN
54  * 	UK
55  */
56 
57 #include <stdio.h>
58 #include <string.h>
59 
60 #include <Xm/MessageB.h>
61 #include <Xm/SelectioB.h>
62 #include <Xm/Form.h>
63 #include <Xm/Label.h>
64 #include <Xm/Text.h>
65 #include <Xm/Frame.h>
66 #include <Xm/RowColumn.h>
67 #include <Xm/ToggleB.h>
68 #include <Xm/ToggleBG.h>
69 
70 #include "asedit.h"
71 
72 /*****************************  CreateReplaceDialog  ************************
73 *
74 *	creates replace dialog out of a selection box
75 */
76 #ifdef _NO_PROTO
CreateReplaceDialog(win,parent,name,arglist,argcount)77 static Widget CreateReplaceDialog(win, parent, name, arglist, argcount)
78 	aseditWindowStruct *win;
79 	Widget parent;
80 	String name;
81 	Arg arglist[];
82 	int argcount;
83 #else  /* ! _NO_PROTO */
84 
85 static Widget CreateReplaceDialog( aseditWindowStruct *win,
86 		Widget parent, String name,
87 		Arg arglist[], int argcount )
88 #endif
89 {
90 	Widget kid[11];      		/* Children to manage */
91 	Arg al[15];         		/* Arg List */
92 	register int ac = 0;      	/* Arg Count */
93 	Dimension    h_space, v_space; 	/* horizontal and vertical space used
94 					   inside a form; !!! It *must* be defined as
95 					   Dimension! (when it was defined as int it worked
96 					   on RS6000 (Motif 1.0) but id did not work on Silicon Graphics
97 					   (Motif 1.1)  */
98 
99 	Widget form_text;	/* special form for label and text widgets
100 				   it consist of two rows "label - text" lines;
101 				   the second line is unmanagable to use that dialog
102 				   as a search dialog; this give us a unique set
103 				   of text to find plus switches like forward etc. */
104 
105 	Widget replace_dlg;		/* replace widget (local) - procedure returns it */
106 	Widget form;          		/* main form widget */
107 	Widget text_to_find_title;
108 	Widget options_title;
109 	Widget frame1;			/* frame used for option toggles */
110 	Widget options_row_column;
111 	Widget direction_title;
112 	Widget frame2;         		/* frame used for direction toggles */
113 	Widget direction_radio_box;
114 	Widget backward_toggle;
115 	Dimension width, labels_width;
116 
117 
118 	replace_dlg = XmCreatePromptDialog(parent, name, arglist, argcount);
119 
120 	/* manage the 4th button of prompt dialog */
121 	win->change_all_button = XmSelectionBoxGetChild (replace_dlg,
122 						 XmDIALOG_APPLY_BUTTON);
123 
124 	/* the title for the change_verify_button will be dynamically set
125 	   according to the use of the button in "Find" dialog or "Change" dialog */
126 	win->change_verify_button = XmSelectionBoxGetChild (replace_dlg,
127 						 XmDIALOG_OK_BUTTON);
128 
129 	/* get the cancel button .... */
130 	win->cancel_replace_dialog_button = XmSelectionBoxGetChild (replace_dlg,
131 						 XmDIALOG_CANCEL_BUTTON);
132 
133 
134 
135 	/*      Unmanage unneeded children.    */
136 	ac = 0;
137 	kid[ac++] = XmSelectionBoxGetChild (replace_dlg, XmDIALOG_TEXT);
138 	kid[ac++] = XmSelectionBoxGetChild (replace_dlg,
139 						     XmDIALOG_SELECTION_LABEL);
140 	XtUnmanageChildren (kid, ac);
141 
142 
143 
144 	/* create a form widget inside prompt dialog; inside that form
145 	   create appropriate control elements */
146 
147 	ac = 0;
148 	form = XmCreateForm ( replace_dlg, "form", al, ac );
149 
150 	ac = 0;
151 	XtSetArg(al[ac], XmNhorizontalSpacing, &h_space ); ac++;
152 	XtSetArg(al[ac], XmNverticalSpacing, &v_space ); ac++;
153 	XtGetValues(form, al, ac );	/* get the spacing used */
154 
155 
156 	/* when the 2 lines which contain a label and a text widget
157 	   each, were directly created inside a form and later the second
158 	   line was managed and unmanaged, when needed, we had problems and
159 	   the behaviour was inconsistent;
160 	   Therefore additional form (form_text) is created to "envelope" the
161 	   widgets mentioned above (19.11.1991) */
162 	ac = 0;
163 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_FORM); ac++;
164 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM); ac++;
165 	XtSetArg(al[ac], XmNrightAttachment,   XmATTACH_FORM); ac++;
166 	form_text = XmCreateForm ( form, "form_text", al, ac );
167 
168 	/* since 1.32 create the label and text widgets first, then set the geometry attachements */
169 
170 	ac = 0;
171 	text_to_find_title  = XmCreateLabel ( form_text, "text_to_find_title", al, ac );
172 	win->new_text_title = XmCreateLabel ( form_text, "new_text_title", al, ac );
173 	win->text_to_find   = XmCreateText ( form_text, "text_to_find", al, ac );
174 	win->new_text       = XmCreateText ( form_text, "new_text", al, ac );
175 
176 
177 	/* since 1.32 we use labels_width to set vertically position of the text widgets */
178 	/* get the labels_width for the two label widgets (i.e. the max width)*/
179 	ac =0;
180 	XtSetArg(al[ac], XmNwidth, &width); 	ac++;
181 	XtGetValues(text_to_find_title, al, ac);
182 	labels_width = width;
183 	XtGetValues(win->new_text_title, al, ac);
184 	if(width > labels_width)	labels_width = width;
185 
186 	/* set the 1st label attachments ... */
187 	ac = 0;
188 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM); ac++;
189 	XtSetArg(al[ac], XmNtopOffset, 0);		ac++;
190 	XtSetArg(al[ac], XmNbottomOffset, 0);		ac++;
191 	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET);	ac++;
192 	XtSetArg(al[ac], XmNtopWidget,  win->text_to_find);		ac++;
193 	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET);	ac++;
194 	XtSetArg(al[ac], XmNbottomWidget,  win->text_to_find);			ac++;
195 	XtSetValues(text_to_find_title, al, ac);
196 
197 	/* set the 1st text attachments ... */
198 	ac=0;
199 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_FORM); 	ac++;
200 	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); 	ac++;
201 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM);    ac++;
202 	XtSetArg(al[ac], XmNleftOffset,	     h_space+labels_width);ac++;
203 
204 	if(lstr.useOldColorSetup)
205 	    { XtSetArg(al[ac], XmNbackground,  select_menu_background);ac++; }
206 	XtSetValues(win->text_to_find, al, ac);
207 #if (XmVersion == 1000)
208 	XmAddTabGroup (win->text_to_find);
209 #endif
210 
211 
212 	/* set the 2nd label attachments ... */
213 	ac = 0;
214 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM); ac++;
215 	XtSetArg(al[ac], XmNtopOffset, 0);		ac++;
216 	XtSetArg(al[ac], XmNbottomOffset, 0);		ac++;
217 	XtSetArg(al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET);	ac++;
218 	XtSetArg(al[ac], XmNtopWidget,  win->new_text);			ac++;
219 	XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET);	ac++;
220 	XtSetArg(al[ac], XmNbottomWidget,  win->new_text);			ac++;
221 
222 
223 	XtSetValues(win->new_text_title, al, ac);
224 
225 	/* set the 2nd text attachments ... */
226 	ac=0;
227 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_WIDGET);	ac++;
228 	XtSetArg(al[ac], XmNtopOffset,       v_space); 		ac++;
229 	XtSetArg(al[ac], XmNtopWidget,       win->text_to_find); ac++;
230 	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); 	ac++;
231         XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM);    ac++;
232         XtSetArg(al[ac], XmNleftOffset,      h_space+labels_width);ac++;
233 
234 	if(lstr.useOldColorSetup)
235 	    { XtSetArg(al[ac], XmNbackground,  select_menu_background);ac++; }
236 
237 
238 	XtSetValues(win->new_text, al, ac);
239 #if (XmVersion == 1000)
240 	XmAddTabGroup (win->new_text);
241 #endif
242 
243 	ac = 0;
244 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_WIDGET);	ac++;
245 	XtSetArg(al[ac], XmNtopOffset,       v_space); 		ac++;
246 	XtSetArg(al[ac], XmNtopWidget,       form_text); 	ac++;
247 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM); 	ac++;
248 	options_title = XmCreateLabel ( form, "options_title", al, ac );
249 
250 
251 	ac=0;
252 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_WIDGET);	ac++;
253 	XtSetArg(al[ac], XmNtopWidget,       options_title); 	ac++;
254 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_FORM); 	ac++;
255 	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE);	ac++;
256 
257 	frame1 = XmCreateFrame ( form, "frame1", al, ac );
258 
259 	ac=0;
260 	/**XtSetArg (al[ac], XmNpacking, XmPACK_COLUMN);  ac++;
261 	XtSetArg (al[ac], XmNnumColumns, 1);  ac++; ***/
262 	options_row_column = XmCreateRowColumn(frame1, "options_row_column", al, ac );
263 #if (XmVersion == 1000)
264 	XmAddTabGroup (options_row_column);
265 #endif
266 
267 	ac=0;
268 	win->case_sensitive_toggle   = XmCreateToggleButton( options_row_column, "case_sensitive", al, ac );
269 	win->whole_words_only_toggle = XmCreateToggleButton( options_row_column, "whole_words", al, ac );
270 
271 	ac = 0;
272 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_WIDGET);	ac++;
273 	XtSetArg(al[ac], XmNtopOffset,       v_space); 		ac++;
274 	XtSetArg(al[ac], XmNtopWidget,       /*new_text*/
275 					     form_text); 	ac++;
276 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_WIDGET); 	ac++;
277 	XtSetArg(al[ac], XmNleftOffset,      20); 		ac++;
278 	XtSetArg(al[ac], XmNleftWidget,      frame1); 		ac++;
279 
280 	direction_title = XmCreateLabel ( form, "direction_title", al, ac );
281 
282 	ac=0;
283 	XtSetArg(al[ac], XmNtopAttachment,   XmATTACH_WIDGET);	ac++;
284 	XtSetArg(al[ac], XmNtopWidget,       direction_title); 	ac++;
285 	XtSetArg(al[ac], XmNleftAttachment,  XmATTACH_WIDGET); 	ac++;
286 	XtSetArg(al[ac], XmNleftOffset,      20); 		ac++;
287 	XtSetArg(al[ac], XmNleftWidget,      frame1); 		ac++;
288 	XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); 	ac++;
289 	frame2 = XmCreateFrame ( form, "frame2", al, ac );
290 	ac=0;
291 
292 	direction_radio_box = XmCreateRadioBox( frame2, "direction_radio_box", al, ac );
293 #if (XmVersion == 1000)
294 	XmAddTabGroup (direction_radio_box);
295 #endif
296 	ac=0;
297 	win->forward_toggle =  XmCreateToggleButtonGadget( direction_radio_box, "Forward", al, ac );
298 	backward_toggle = XmCreateToggleButtonGadget( direction_radio_box, "Backward", al, ac );
299 
300         checkRadioBoxSetting(direction_radio_box, 0);	/* check (& correct) the toggle button settings
301 							   done by the user through resources */
302 
303 
304 	/* manage the children and manage the manager parents as we ascend back up*/
305 
306 	ac = 0;
307 	kid[ac++] = win->case_sensitive_toggle;
308 	kid[ac++] = win->whole_words_only_toggle;
309 	XtManageChildren(kid, ac);
310 	XtManageChild(options_row_column);
311 
312 	ac = 0;
313 	kid[ac++] = win->forward_toggle;
314 	kid[ac++] = backward_toggle;
315 	XtManageChildren(kid, ac);
316 	XtManageChild(direction_radio_box);
317 
318 	ac = 0;
319 	kid[ac++] = text_to_find_title;
320 	kid[ac++] = win->text_to_find;
321 	kid[ac++] = win->new_text;
322 	kid[ac++] = win->new_text_title;
323 	XtManageChildren(kid, ac);
324 	XtManageChild(form_text);
325 
326 	ac = 0;
327 	kid[ac++] = options_title;
328 	kid[ac++] = frame1;
329 	kid[ac++] = direction_title;
330 	kid[ac++] = frame2;
331 	XtManageChildren(kid, ac);
332 
333 	/* now manage the whole form (it is always better to manage the manager
334 	   widgets after creating all theirs children) */
335 	XtManageChild(form);
336 
337 	return(replace_dlg);
338 
339 }	/* CreateReplaceDialog */
340 
341 /*****************************  show_replace_dialog  **************************
342 **
343 **  Show replace_dialog for the specified asedit window. If it does not exist yet
344 **  create it first as a child of menu_bar.
345 */
346 
347 #ifdef _NO_PROTO
show_replace_dialog(win)348 void show_replace_dialog (win)
349 	aseditWindowStruct *win;
350 #else  /* ! _NO_PROTO */
351 
352 void show_replace_dialog (aseditWindowStruct *win)
353 #endif
354 {
355     Arg			al[5];		/*  arg list		*/
356     register  int	ac = 0;		/*  arg count		*/
357 
358     if(win->replace_dialog == NULL)	/* first create the dialog */
359     {
360 	Widget 		kids[3];	/*  children widgets 	*/
361 
362 	/* create a replace dialog; the find dialog is obtained from the
363 	   replace dialog simply by unmanaging some widgets !!!
364 	   The title is dynamically assigned just before managing the widget!! */
365 
366 	ac = 0;
367 	XtSetArg (al[ac], XmNautoUnmanage, False);    ac++;
368 	win->replace_dialog = CreateReplaceDialog( win, win->menu_bar, "replace_dialog", al, ac);
369 
370 	XtAddCallback (win->replace_dialog, XmNokCallback,
371 			(XtCallbackProc)DialogOkCB, 	mk_asdat_w(win, DIALOG_FIND_OR_CHANGE) );
372 	XtAddCallback (win->replace_dialog, XmNcancelCallback,
373 			(XtCallbackProc)DialogCancelCB,mk_asdat_w(win, DIALOG_FIND_OR_CHANGE) );
374 	XtAddCallback (win->replace_dialog, XmNhelpCallback,
375 			(XtCallbackProc)HelpCB, 	mk_asdat_w(win, DIALOG_FIND_OR_CHANGE) );
376 	XtAddCallback (win->replace_dialog, XmNapplyCallback,
377 			(XtCallbackProc)DialogApplyCB, mk_asdat_w(win, DIALOG_FIND_OR_CHANGE) );
378 	/* set a special callback to set the focus to the text_to_find widget
379 	   when the dialog gets its first focus */
380 #ifndef XFOCUS_BUG
381 	XtAddCallback(win->replace_dialog, XmNfocusCallback,
382 			(XtCallbackProc)focusCB, (XtPointer)win->text_to_find);
383 #endif
384     }
385 
386     if(win->search_reason == MENU_FIND)   /* find operation */
387     {
388 	set_dialog_title(win->replace_dialog, (char *)lstr.find_dialogTitle);
389 	/* set appropriate title for the "OK" button ... */
390 	write_ls(win->change_verify_button, charset, "%s", (char *)lstr.find_next_label);
391 
392 	/* unmanage unneeded elements inside replace_dialog widgets */
393 	XtUnmanageChild( win->new_text);
394 	XtUnmanageChild( win->new_text_title);
395 	XtUnmanageChild( win->change_all_button);
396     }
397     else
398     {						/* replace operation */
399 	set_dialog_title(win->replace_dialog, (char *)lstr.change_dialogTitle);
400 	/* set appropriate title for the "OK" button ... */
401 	write_ls(win->change_verify_button, charset, "%s", (char *)lstr.find_n_verify_label);
402 
403 	/* manage some elements inside replace_dialog which
404 	   might have been unmanaged when used as a find option */
405 	XtManageChild( win->new_text);
406 	XtManageChild( win->new_text_title);
407 	XtManageChild( win->change_all_button);
408     }
409     /* set the starting position for the search */
410     ac = 0;
411     XtSetArg(al[ac], XmNcursorPosition, &(win->start_search_position) ); ac++;
412     XtGetValues(win->edit_text, al, ac);
413 
414     asManageDialog(win->replace_dialog);
415 
416     /* set the keyboard focus to the text_to_find each time the dialog pops-up */
417 #if (XmVersion == 1000)
418     _XmProcessTraversal( win->text_to_find, XmTRAVERSE_CURRENT);  /** private f. in Motif 1.0***/
419 #else
420     XmProcessTraversal( win->text_to_find, XmTRAVERSE_CURRENT);
421 #endif
422 
423 }   /* show_replace_dialog */
424 
425 /*****************************  show_change_prompt  **************************
426 **
427 **  Show change_prompt for the specified asedit window. If it does not exist yet
428 **  create it first as a child of menu_bar.
429 */
430 
431 #ifdef _NO_PROTO
show_change_prompt(win)432 void show_change_prompt (win)
433 	aseditWindowStruct *win;
434 #else  /* ! _NO_PROTO */
435 
436 void show_change_prompt (aseditWindowStruct *win)
437 #endif
438 {
439 
440     if(win->change_prompt == NULL)	/* first create the dialog */
441     {
442 	Arg		al[5];		/*  arg list		*/
443 	register  int	ac = 0;		/*  arg count		*/
444 
445 	/*    Create  change prompt   */
446 	ac = 0;
447 	XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); ac++;
448 	XtSetArg (al[ac], XmNautoUnmanage, False);    ac++;
449 
450 	win->change_prompt = create_4buttons_dialog (win->menu_bar, "change_prompt",
451 			xm_question_mark, /* if you do not want use any pixmap
452 				specify NULL pixmap like this:  (Pixmap) NULL, ***/
453 			 (char *)lstr.sq_change, al, ac);
454 
455 	XtAddCallback (win->change_prompt, XmNokCallback,
456 			(XtCallbackProc)DialogOkCB,	mk_asdat_w(win, DIALOG_CHANGE_PROMPT) );
457 	XtAddCallback (win->change_prompt, XmNapplyCallback,
458 			(XtCallbackProc)DialogApplyCB,	mk_asdat_w(win, DIALOG_CHANGE_PROMPT) );
459 	XtAddCallback (win->change_prompt, XmNcancelCallback,
460 			(XtCallbackProc)DialogCancelCB, mk_asdat_w(win, DIALOG_CHANGE_PROMPT) );
461 	XtAddCallback (win->change_prompt, XmNhelpCallback,
462 			(XtCallbackProc)HelpCB,		mk_asdat_w(win, DIALOG_CHANGE_PROMPT) );
463     }
464     /* make the buttons insensitive ...*/
465     set_change_buttons_sensitivity(win, False);
466     asManageDialog(win->change_prompt);
467 
468 }   /* show_change_prompt */
469 
470 
471 /**********************  create_continue_search_question  **********************
472 **
473 **  Create continue_search_question for the specified asedit window as a child
474 **  of menu_bar.
475 */
476 
477 #ifdef _NO_PROTO
create_continue_search_question(win)478 void create_continue_search_question (win)
479 	aseditWindowStruct *win;
480 #else  /* ! _NO_PROTO */
481 
482 void create_continue_search_question (aseditWindowStruct *win)
483 #endif
484 {
485     if(win->continue_search_question == NULL)	/* first create the dialog */
486     {
487 	Arg		al[5];		/*  arg list		*/
488 	register  int	ac = 0;		/*  arg count		*/
489  	XmString        xmstr;          /*  work XmString */
490 
491 	/* create continue_search_question widget */
492 	ac = 0;
493 	/* text will be set dynamically */
494 	xmstr = XmStringCreateLtoR("Continue...", charset);
495 	XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); ac++;
496 	XtSetArg (al[ac], XmNautoUnmanage, False);    ac++;
497 	XtSetArg(al[ac], XmNmessageString, xmstr );  ac++;
498 	win->continue_search_question = XmCreateQuestionDialog (win->menu_bar, "continue_search_question",al,ac);
499 	XmStringFree(xmstr);		/* free memory allocated for XmString */
500 
501 	XtAddCallback (win->continue_search_question, XmNokCallback,
502 			(XtCallbackProc)DialogOkCB, 	mk_asdat_w(win, QUESTION_CONTINUE_SEARCH) );
503 	XtAddCallback (win->continue_search_question, XmNcancelCallback,
504 			(XtCallbackProc)DialogCancelCB, mk_asdat_w(win, QUESTION_CONTINUE_SEARCH) );
505 	XtAddCallback (win->continue_search_question, XmNhelpCallback,
506 			(XtCallbackProc)HelpCB, 	mk_asdat_w(win, QUESTION_CONTINUE_SEARCH) );
507     }
508 
509 }   /* create_continue_search_question */
510 
511 /**********************  create_search_end_message  **********************
512 **
513 **  Create search_end_message for the specified asedit window as a child
514 **  of menu_bar.
515 */
516 
517 #ifdef _NO_PROTO
create_search_end_message(win)518 void create_search_end_message (win)
519 	aseditWindowStruct *win;
520 #else  /* ! _NO_PROTO */
521 
522 void create_search_end_message (aseditWindowStruct *win)
523 #endif
524 {
525 	Arg		al[5];		/*  arg list		*/
526 	register  int	ac = 0;		/*  arg count		*/
527 	XmString        xmstr;          /*  work XmString */
528 	Widget          kids[3];        /*  children widgets */
529 
530 	/* create search_end_message */
531 	ac = 0;
532 	xmstr = XmStringCreateLtoR("Change...", charset); /* text will be set dynamically */
533 	XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL); ac++;
534 	XtSetArg (al[ac], XmNautoUnmanage, False);    ac++;
535 	XtSetArg(al[ac], XmNmessageString, xmstr );  ac++;
536 	/* To dismiss dialog we use cancel button (label set in resources)
537 	   The default button needs to be set now to the Cancel button. Otherwise
538 	   when we press Enter the button won't change the colour to the select
539 	   colour etc. (the standard defaults to OK button)  - important for Motif 1.0*/
540 	XtSetArg(al[ac], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON); ac++;
541 
542 	win->search_end_message = XmCreateInformationDialog (win->menu_bar, "search_end_message",al,ac);
543 	XmStringFree(xmstr);		/* free memory allocated for XmString */
544 
545 	/* unmanage unneeded buttons */
546 	ac=0;
547 	kids[ac++] = XmMessageBoxGetChild(win->search_end_message, XmDIALOG_HELP_BUTTON);
548 	kids[ac++] = XmMessageBoxGetChild(win->search_end_message, XmDIALOG_OK_BUTTON);
549 	XtUnmanageChildren (kids, ac);
550 	XtAddCallback (win->search_end_message, XmNcancelCallback,
551 			(XtCallbackProc)DialogCancelCB, mk_asdat_w(win, MESSAGE_SEARCH_END) );
552 	/* lets add the help callback; because the help button is not managed this help
553 	   is only accessible with F1 (Help) key */
554 	XtAddCallback (win->search_end_message, XmNhelpCallback,
555 			(XtCallbackProc)HelpCB, mk_asdat_w(win, MESSAGE_SEARCH_END) );
556 
557 }	/* create_search_end_message */
558 
559 
560 
561 /*****************************  show_gotoline_dialog  **************************
562 **
563 **  Show gotoline_dialog for the specified asedit window. If it does not exist yet
564 **  create it first as a child of menu_bar.
565 */
566 
567 #ifdef _NO_PROTO
show_gotoline_dialog(win)568 void show_gotoline_dialog (win)
569 	aseditWindowStruct *win;
570 #else  /* ! _NO_PROTO */
571 
572 void show_gotoline_dialog (aseditWindowStruct *win)
573 #endif
574 {
575     if(win->gotoline_dialog == NULL)	/* first create the dialog */
576     {
577 	Arg		al[5];		/*  arg list		*/
578 	register  int	ac = 0;		/*  arg count		*/
579 	Widget 		text;		/*  text widget 	*/
580 
581 	/* Create go to line dialog ... */
582 	ac = 0;
583 	XtSetArg (al[ac], XmNautoUnmanage, False);    ac++;
584 	win->gotoline_dialog = XmCreatePromptDialog(win->menu_bar,"go_to_line", al, ac);
585 	XtAddCallback (win->gotoline_dialog, XmNokCallback,
586 			(XtCallbackProc)DialogOkCB, mk_asdat_w(win, DIALOG_GOTOLINE) );
587 	XtAddCallback (win->gotoline_dialog, XmNcancelCallback,
588 			(XtCallbackProc)DialogCancelCB, mk_asdat_w(win, DIALOG_GOTOLINE) );
589 	XtAddCallback (win->gotoline_dialog, XmNhelpCallback,
590 			(XtCallbackProc)HelpCB, mk_asdat_w(win, DIALOG_GOTOLINE) );
591 	/* set the colour for the editable text widget */
592 	text = XmSelectionBoxGetChild(win->gotoline_dialog, XmDIALOG_TEXT);
593 	if(lstr.useOldColorSetup)
594 	{
595 	    ac =0;
596 	    XtSetArg(al[ac], XmNbackground, select_menu_background); ac++;
597 	    XtSetValues(text, al, ac);
598 	}
599 
600 	setDefaultHomeEndTranslations(text);    /* it is a child of SelectionBox so
601                                                    set the translations for osfBeginLine
602                                                    and osfEndLine to the same as for standard
603                                                    text widgets
604                                                 */
605 
606 	/* add modify verify callback (we will use it to allow entering only numbers) */
607         XtAddCallback (text, XmNmodifyVerifyCallback,
608                         (XtCallbackProc)allowOnlyNumbersCB, (XtPointer)20 );	/* 20 digit number max */
609 
610 
611 	/* none of the following ways of setting traaversal works:
612 	  XmProcessTraversal( text, XmTRAVERSE_HOME);
613 					XmTRAVERSE_CURRENT
614 					XmTRAVERSE_NEXT_TAB_GROUP
615 	  They do not work because the dialog widget (and all of its ancestors)
616 	  does need to be realized BEFORE you call XmProcessTraversal !
617 	  The way around it is to register a special focus callback */
618 	/* set a special callback which will set the focus to the text widget
619 	   when the dialog gets its first focus */
620 #ifndef XFOCUS_BUG
621 	XtAddCallback(win->gotoline_dialog, XmNfocusCallback,
622 			(XtCallbackProc)focusCB, (XtPointer)text);
623 #endif
624     }
625 
626     asManageDialog(win->gotoline_dialog);
627 
628     /* set the keyboard focus to the text widget each time the dialog pops-up */
629 #if (XmVersion == 1000)
630     _XmProcessTraversal( XmSelectionBoxGetChild(win->gotoline_dialog, XmDIALOG_TEXT),
631 				 XmTRAVERSE_CURRENT);  /** private f. in Motif 1.0***/
632 #else
633     XmProcessTraversal( XmSelectionBoxGetChild(win->gotoline_dialog, XmDIALOG_TEXT),
634 				XmTRAVERSE_CURRENT);
635 #endif
636 
637 }   /* show_gotoline_dialog */
638 
639