1 /*------------------------------------------------------------\
2 | |
3 | This file is part of the Alliance CAD System Copyright |
4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie|
5 | |
6 | Home page : http://www-asim.lip6.fr/alliance/ |
7 | E-mail : mailto:alliance-users@asim.lip6.fr |
8 | |
9 | This progam is free software; you can redistribute it |
10 | and/or modify it under the terms of the GNU General Public |
11 | License as published by the Free Software Foundation; |
12 | either version 2 of the License, or (at your option) any |
13 | later version. |
14 | |
15 | Alliance VLSI CAD System is distributed in the hope that |
16 | it will be useful, but WITHOUT ANY WARRANTY; |
17 | without even the implied warranty of MERCHANTABILITY or |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
19 | Public License for more details. |
20 | |
21 | You should have received a copy of the GNU General Public |
22 | License along with the GNU C Library; see the file COPYING. |
23 | If not, write to the Free Software Foundation, Inc., |
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
25 | |
26 \------------------------------------------------------------*/
27
28 /*------------------------------------------------------------\
29 | |
30 | Tool : GRAAL |
31 | |
32 | File : dialog.c |
33 | |
34 | Author : Jacomme Ludovic |
35 | |
36 | Date : 28.03.95 |
37 | |
38 \------------------------------------------------------------*/
39
40 /*------------------------------------------------------------\
41 | |
42 | Include Files |
43 | |
44 \------------------------------------------------------------*/
45
46 # include <Xm/Xm.h>
47 # include <Xm/FileSB.h>
48 # include <Xm/MessageB.h>
49 # include <Xm/SelectioB.h>
50 # include <Xm/SeparatoG.h>
51
52 # include "mph.h"
53 # include "mut.h"
54 # include "rds.h"
55 # include "GTB.h"
56 # include "GRM.h"
57 # include "GTB_dialog.h"
58
59 /*------------------------------------------------------------\
60 | |
61 | Constants |
62 | |
63 \------------------------------------------------------------*/
64 /*------------------------------------------------------------\
65 | |
66 | Types |
67 | |
68 \------------------------------------------------------------*/
69 /*------------------------------------------------------------\
70 | |
71 | Variables |
72 | |
73 \------------------------------------------------------------*/
74
75 static int GraalLockLoop = 0;
76
77 static GraalDialogItem GraalWarningDialog =
78
79 {
80 "Warning",
81 GRAAL_DIALOG_WARNING,
82 (Widget)NULL,
83 (void *)NULL,
84 (XtPointer)NULL,
85 (void *)NULL,
86 (XtPointer)NULL
87 };
88
89 static GraalDialogItem GraalErrorDialog =
90
91 {
92 "Error",
93 GRAAL_DIALOG_ERROR,
94 (Widget)NULL,
95 (void *)NULL,
96 (XtPointer)NULL,
97 (void *)NULL,
98 (XtPointer)NULL
99 };
100
101 /*------------------------------------------------------------\
102 | |
103 | Functions |
104 | |
105 \------------------------------------------------------------*/
106 /*------------------------------------------------------------\
107 | |
108 | GraalDestroyDialogCallback |
109 | |
110 \------------------------------------------------------------*/
111
GraalDestroyDialogCallback(MyWidget,ClientData,CallData)112 void GraalDestroyDialogCallback( MyWidget, ClientData, CallData )
113
114 Widget MyWidget;
115 caddr_t ClientData;
116 caddr_t CallData;
117 {
118 GraalLockLoop = 0;
119 GraalExitErrorMessage( 1 );
120 }
121
122 /*------------------------------------------------------------\
123 | |
124 | GraalExitDialogCallback |
125 | |
126 \------------------------------------------------------------*/
127
GraalExitDialogCallback()128 void GraalExitDialogCallback()
129
130 {
131 rdsbegin();
132
133 GraalExitDialog();
134
135 rdsend();
136 }
137
138 /*------------------------------------------------------------\
139 | |
140 | GraalBuildDialog |
141 | |
142 \------------------------------------------------------------*/
143
GraalBuildDialog(Father,Dialog)144 void GraalBuildDialog( Father, Dialog )
145
146 Widget Father;
147 GraalDialogItem *Dialog;
148 {
149 Arg Args[3];
150 XmString Label;
151
152 rdsbegin();
153
154 Label = XmStringCreateLtoR( Dialog->LABEL,
155 XmSTRING_DEFAULT_CHARSET );
156
157 if ( Dialog->TYPE < GRAAL_DIALOG_FILE )
158 {
159 XtSetArg( Args[0], XmNmessageString , Label);
160 }
161 else
162 {
163 XtSetArg( Args[0], XmNselectionLabelString, Label);
164 }
165
166 XtSetArg( Args[1], XmNdeleteResponse, XmDO_NOTHING );
167 XtSetArg( Args[2], XmNtitle, " " );
168
169 switch ( Dialog->TYPE )
170 {
171 case GRAAL_DIALOG_MESSAGE :
172
173 Dialog->WIDGET =
174
175 XmCreateMessageDialog( Father, Dialog->LABEL, Args, 3);
176
177 break;
178
179 case GRAAL_DIALOG_ERROR :
180
181 Dialog->WIDGET =
182
183 XmCreateErrorDialog( Father, Dialog->LABEL, Args, 3);
184
185 break;
186
187 case GRAAL_DIALOG_INFO :
188
189 Dialog->WIDGET =
190
191 XmCreateInformationDialog( Father, Dialog->LABEL, Args, 3);
192
193 break;
194
195 case GRAAL_DIALOG_QUESTION :
196
197 Dialog->WIDGET =
198
199 XmCreateQuestionDialog( Father, Dialog->LABEL, Args, 3);
200
201 break;
202
203 case GRAAL_DIALOG_WARNING :
204
205 Dialog->WIDGET =
206
207 XmCreateWarningDialog( Father, Dialog->LABEL, Args, 3);
208
209 break;
210
211 case GRAAL_DIALOG_WORKING :
212
213 Dialog->WIDGET =
214
215 XmCreateWorkingDialog( Father, Dialog->LABEL, Args, 3);
216
217 break;
218
219 case GRAAL_DIALOG_FILE :
220
221 Dialog->WIDGET =
222
223 XmCreateFileSelectionDialog( Father, Dialog->LABEL, Args, 3);
224
225 XtUnmanageChild( XmFileSelectionBoxGetChild( Dialog->WIDGET,
226 XmDIALOG_FILTER_LABEL ) );
227
228 XtUnmanageChild( XmFileSelectionBoxGetChild( Dialog->WIDGET,
229 XmDIALOG_FILTER_TEXT ) );
230
231 break;
232
233 case GRAAL_DIALOG_PROMPT :
234
235 Dialog->WIDGET =
236
237 XmCreatePromptDialog( Father, Dialog->LABEL, Args, 3);
238
239 XtUnmanageChild( XmSelectionBoxGetChild( Dialog->WIDGET,
240 XmDIALOG_HELP_BUTTON ) );
241 }
242
243 XmStringFree( Label );
244
245 XtAddCallback (Dialog->WIDGET, XmNdestroyCallback,
246 GraalDestroyDialogCallback, NULL );
247
248 if ( Dialog->TYPE < GRAAL_DIALOG_FILE )
249 {
250 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
251 XmDIALOG_HELP_BUTTON ) );
252 }
253
254 if ( ( Dialog->CALLBACK_OK == NULL ) &&
255 ( Dialog->CALLBACK_CANCEL == NULL ) )
256 {
257 XtAddCallback( Dialog->WIDGET, XmNokCallback,
258 GraalExitDialogCallback, NULL );
259 }
260 else
261 {
262 if ( Dialog->CALLBACK_OK == NULL )
263 {
264 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
265 XmDIALOG_OK_BUTTON ) );
266 }
267 else
268 {
269 XtAddCallback( Dialog->WIDGET, XmNokCallback,
270 Dialog->CALLBACK_OK,
271 Dialog->CALLDATA_OK );
272 }
273 }
274
275 if ( Dialog->CALLBACK_CANCEL == NULL )
276 {
277 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
278 XmDIALOG_CANCEL_BUTTON ) );
279 }
280 else
281 {
282 XtAddCallback( Dialog->WIDGET, XmNcancelCallback,
283 Dialog->CALLBACK_CANCEL,
284 Dialog->CALLDATA_CANCEL );
285 }
286
287 rdsend();
288 }
289
290 /*------------------------------------------------------------\
291 | |
292 | GraalLimitedLoop |
293 | |
294 \------------------------------------------------------------*/
295
GraalLimitedLoop(MyWidget)296 void GraalLimitedLoop( MyWidget )
297
298 Widget MyWidget;
299 {
300 Widget DialogShell, WShell;
301 XEvent Event;
302 XAnyEvent *AnyEvent;
303 XtAppContext Context;
304
305 rdsbegin();
306
307 Context = XtWidgetToApplicationContext( MyWidget );
308
309 GraalLockLoop = 1;
310
311 for ( WShell = MyWidget;
312 ! XtIsShell( WShell );
313 WShell = XtParent( WShell ) );
314
315 while( GraalLockLoop == 1 )
316 {
317 XtAppNextEvent( Context, &Event );
318
319 AnyEvent = (XAnyEvent *)( &Event );
320
321 for ( DialogShell = XtWindowToWidget( AnyEvent->display, AnyEvent->window );
322 ((DialogShell != NULL ) && (!XtIsShell( DialogShell )));
323 DialogShell = XtParent(DialogShell));
324
325 switch ( AnyEvent->type )
326 {
327 case ButtonPress :
328 case ButtonRelease :
329
330 if (WShell == DialogShell)
331 {
332 XtDispatchEventToWidget(
333 XtWindowToWidget( AnyEvent->display, AnyEvent->window ),
334 &Event );
335 }
336
337 break;
338
339 case KeyPress :
340 case KeyRelease :
341
342 if ( WShell != DialogShell )
343 {
344 AnyEvent->window = XtWindow( WShell );
345 }
346
347 default :
348
349 XtDispatchEvent( &Event );
350 }
351 }
352
353 rdsend();
354 }
355
356 /*------------------------------------------------------------\
357 | |
358 | GraalEnterDialog |
359 | |
360 \------------------------------------------------------------*/
361
GraalEnterDialog(Dialog)362 void GraalEnterDialog( Dialog )
363
364 GraalDialogItem *Dialog;
365 {
366 rdsbegin();
367
368 XtManageChild ( Dialog->WIDGET );
369
370 GraalLimitedLoop( Dialog->WIDGET );
371
372 XtUnmanageChild( Dialog->WIDGET );
373
374 rdsend();
375 }
376
377 /*------------------------------------------------------------\
378 | |
379 | GraalReEnterDialog |
380 | |
381 \------------------------------------------------------------*/
382
GraalReEnterDialog()383 void GraalReEnterDialog()
384 {
385 GraalLockLoop = 1;
386 }
387
388 /*------------------------------------------------------------\
389 | |
390 | GraalExitDialog |
391 | |
392 \------------------------------------------------------------*/
393
GraalExitDialog()394 void GraalExitDialog()
395
396 {
397 GraalLockLoop = 0;
398 }
399
400 /*------------------------------------------------------------\
401 | |
402 | GraalWarningMessage |
403 | |
404 \------------------------------------------------------------*/
405
GraalWarningMessage(Father,Subject)406 void GraalWarningMessage( Father, Subject )
407
408 Widget Father;
409 char *Subject;
410 {
411 XmString Label;
412
413 rdsbegin();
414
415 if ( GraalWarningDialog.WIDGET == (Widget)NULL )
416 {
417 GraalBuildDialog( Father, &GraalWarningDialog );
418 }
419
420 Label = XmStringCreateLtoR( Subject,
421 XmSTRING_DEFAULT_CHARSET );
422
423 XtVaSetValues( GraalWarningDialog.WIDGET,
424 XmNmessageString,
425 Label, NULL );
426
427 XmStringFree( Label );
428
429 GraalEnterDialog( &GraalWarningDialog );
430
431 rdsend();
432 }
433
434 /*------------------------------------------------------------\
435 | |
436 | GraalErrorMessage |
437 | |
438 \------------------------------------------------------------*/
439
GraalErrorMessage(Father,Subject)440 void GraalErrorMessage( Father, Subject )
441
442 Widget Father;
443 char *Subject;
444 {
445 XmString Label;
446
447 rdsbegin();
448
449 if ( GraalErrorDialog.WIDGET == (Widget)NULL )
450 {
451 GraalBuildDialog( Father, &GraalErrorDialog );
452 }
453
454 Label = XmStringCreateLtoR( Subject,
455 XmSTRING_DEFAULT_CHARSET );
456
457 XtVaSetValues( GraalErrorDialog.WIDGET,
458 XmNmessageString,
459 Label, NULL );
460
461 XmStringFree( Label );
462
463 GraalEnterDialog( &GraalErrorDialog );
464
465 rdsend();
466 }
467