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 : XFSM |
31 | |
32 | File : dialog.c |
33 | |
34 | Authors : Jacomme Ludovic |
35 | |
36 | Date : 04.12.96 |
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 # include "mut.h"
52 # include "aut.h"
53 # include "abl.h"
54 # include "bdd.h"
55 # include "fsm.h"
56 # include "XTB.h"
57 # include "XSB.h"
58 # include "XFS.h"
59 # include "XTB_dialog.h"
60
61 /*------------------------------------------------------------\
62 | |
63 | Constants |
64 | |
65 \------------------------------------------------------------*/
66 /*------------------------------------------------------------\
67 | |
68 | Types |
69 | |
70 \------------------------------------------------------------*/
71 /*------------------------------------------------------------\
72 | |
73 | Variables |
74 | |
75 \------------------------------------------------------------*/
76
77 static int XfsmLockLoop = 0;
78
79 static XfsmDialogItem XfsmWarningDialog =
80
81 {
82 "Warning",
83 XFSM_DIALOG_WARNING,
84 (Widget)NULL,
85 (void *)NULL,
86 (XtPointer)NULL,
87 (void *)NULL,
88 (XtPointer)NULL
89 };
90
91 static XfsmDialogItem XfsmErrorDialog =
92
93 {
94 "Error",
95 XFSM_DIALOG_ERROR,
96 (Widget)NULL,
97 (void *)NULL,
98 (XtPointer)NULL,
99 (void *)NULL,
100 (XtPointer)NULL
101 };
102
103 /*------------------------------------------------------------\
104 | |
105 | Functions |
106 | |
107 \------------------------------------------------------------*/
108 /*------------------------------------------------------------\
109 | |
110 | XfsmDestroyDialogCallback |
111 | |
112 \------------------------------------------------------------*/
113
XfsmDestroyDialogCallback(MyWidget,ClientData,CallData)114 void XfsmDestroyDialogCallback( MyWidget, ClientData, CallData )
115
116 Widget MyWidget;
117 caddr_t ClientData;
118 caddr_t CallData;
119 {
120 XfsmLockLoop = 0;
121 XfsmExitErrorMessage( 1 );
122 }
123
124 /*------------------------------------------------------------\
125 | |
126 | XfsmExitDialogCallback |
127 | |
128 \------------------------------------------------------------*/
129
XfsmExitDialogCallback()130 void XfsmExitDialogCallback()
131
132 {
133 autbegin();
134
135 XfsmExitDialog();
136
137 autend();
138 }
139
140 /*------------------------------------------------------------\
141 | |
142 | XfsmBuildDialog |
143 | |
144 \------------------------------------------------------------*/
145
XfsmBuildDialog(Father,Dialog)146 void XfsmBuildDialog( Father, Dialog )
147
148 Widget Father;
149 XfsmDialogItem *Dialog;
150 {
151 Arg Args[3];
152 XmString Label;
153
154 autbegin();
155
156 Label = XmStringCreateLtoR( Dialog->LABEL,
157 XmSTRING_DEFAULT_CHARSET );
158
159 if ( Dialog->TYPE < XFSM_DIALOG_FILE )
160 {
161 XtSetArg( Args[0], XmNmessageString , Label);
162 }
163 else
164 {
165 XtSetArg( Args[0], XmNselectionLabelString, Label);
166 }
167
168 XtSetArg( Args[1], XmNdeleteResponse, XmDO_NOTHING );
169 XtSetArg( Args[2], XmNtitle, " " );
170
171 switch ( Dialog->TYPE )
172 {
173 case XFSM_DIALOG_MESSAGE :
174
175 Dialog->WIDGET =
176
177 XmCreateMessageDialog( Father, Dialog->LABEL, Args, 3);
178
179 break;
180
181 case XFSM_DIALOG_ERROR :
182
183 Dialog->WIDGET =
184
185 XmCreateErrorDialog( Father, Dialog->LABEL, Args, 3);
186
187 break;
188
189 case XFSM_DIALOG_INFO :
190
191 Dialog->WIDGET =
192
193 XmCreateInformationDialog( Father, Dialog->LABEL, Args, 3);
194
195 break;
196
197 case XFSM_DIALOG_QUESTION :
198
199 Dialog->WIDGET =
200
201 XmCreateQuestionDialog( Father, Dialog->LABEL, Args, 3);
202
203 break;
204
205 case XFSM_DIALOG_WARNING :
206
207 Dialog->WIDGET =
208
209 XmCreateWarningDialog( Father, Dialog->LABEL, Args, 3);
210
211 break;
212
213 case XFSM_DIALOG_WORKING :
214
215 Dialog->WIDGET =
216
217 XmCreateWorkingDialog( Father, Dialog->LABEL, Args, 3);
218
219 break;
220
221 case XFSM_DIALOG_FILE :
222
223 Dialog->WIDGET =
224
225 XmCreateFileSelectionDialog( Father, Dialog->LABEL, Args, 3);
226
227 XtUnmanageChild( XmFileSelectionBoxGetChild( Dialog->WIDGET,
228 XmDIALOG_FILTER_LABEL ) );
229
230 XtUnmanageChild( XmFileSelectionBoxGetChild( Dialog->WIDGET,
231 XmDIALOG_FILTER_TEXT ) );
232
233 break;
234
235 case XFSM_DIALOG_PROMPT :
236
237 Dialog->WIDGET =
238
239 XmCreatePromptDialog( Father, Dialog->LABEL, Args, 3);
240
241 XtUnmanageChild( XmSelectionBoxGetChild( Dialog->WIDGET,
242 XmDIALOG_HELP_BUTTON ) );
243 }
244
245 XmStringFree( Label );
246
247 XtAddCallback (Dialog->WIDGET, XmNdestroyCallback,
248 XfsmDestroyDialogCallback, NULL );
249
250 if ( Dialog->TYPE < XFSM_DIALOG_FILE )
251 {
252 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
253 XmDIALOG_HELP_BUTTON ) );
254 }
255
256 if ( ( Dialog->CALLBACK_OK == NULL ) &&
257 ( Dialog->CALLBACK_CANCEL == NULL ) )
258 {
259 XtAddCallback( Dialog->WIDGET, XmNokCallback,
260 XfsmExitDialogCallback, NULL );
261 }
262 else
263 {
264 if ( Dialog->CALLBACK_OK == NULL )
265 {
266 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
267 XmDIALOG_OK_BUTTON ) );
268 }
269 else
270 {
271 XtAddCallback( Dialog->WIDGET, XmNokCallback,
272 Dialog->CALLBACK_OK,
273 Dialog->CALLDATA_OK );
274 }
275 }
276
277 if ( Dialog->CALLBACK_CANCEL == NULL )
278 {
279 XtUnmanageChild( XmMessageBoxGetChild( Dialog->WIDGET,
280 XmDIALOG_CANCEL_BUTTON ) );
281 }
282 else
283 {
284 XtAddCallback( Dialog->WIDGET, XmNcancelCallback,
285 Dialog->CALLBACK_CANCEL,
286 Dialog->CALLDATA_CANCEL );
287 }
288
289 autend();
290 }
291
292 /*------------------------------------------------------------\
293 | |
294 | XfsmLimitedLoop |
295 | |
296 \------------------------------------------------------------*/
297
298 /*------------------------------------------------------------\
299 | |
300 | XfsmLimitedLoop |
301 | |
302 \------------------------------------------------------------*/
303
XfsmLimitedLoop(MyWidget)304 void XfsmLimitedLoop( MyWidget )
305
306 Widget MyWidget;
307 {
308 Widget DialogShell, WShell;
309 XEvent Event;
310 XAnyEvent *AnyEvent;
311 XtAppContext Context;
312
313 autbegin();
314
315 Context = XtWidgetToApplicationContext( MyWidget );
316
317 XfsmLockLoop = 1;
318
319 for ( WShell = MyWidget;
320 ! XtIsShell( WShell );
321 WShell = XtParent( WShell ) );
322
323 while( XfsmLockLoop == 1 )
324 {
325 XtAppNextEvent( Context, &Event );
326
327 AnyEvent = (XAnyEvent *)( &Event );
328
329 for ( DialogShell = XtWindowToWidget( AnyEvent->display, AnyEvent->window );
330 ((DialogShell != NULL ) && (!XtIsShell( DialogShell )));
331 DialogShell = XtParent(DialogShell));
332
333 switch ( AnyEvent->type )
334 {
335 case ButtonPress :
336 case ButtonRelease :
337
338 if ( WShell == DialogShell )
339 {
340 XtDispatchEventToWidget(
341 XtWindowToWidget( AnyEvent->display, AnyEvent->window ),
342 &Event );
343 }
344
345 break;
346
347 case KeyPress :
348 case KeyRelease :
349
350 if ( WShell != DialogShell )
351 {
352 AnyEvent->window = XtWindow( WShell );
353 }
354
355 default :
356
357 XtDispatchEvent( &Event );
358 }
359 }
360
361 autend();
362 }
363
364 /*------------------------------------------------------------\
365 | |
366 | XfsmEnterDialog |
367 | |
368 \------------------------------------------------------------*/
369
XfsmEnterDialog(Dialog)370 void XfsmEnterDialog( Dialog )
371
372 XfsmDialogItem *Dialog;
373 {
374 autbegin();
375
376 XtManageChild ( Dialog->WIDGET );
377
378 XfsmLimitedLoop( Dialog->WIDGET );
379
380 XtUnmanageChild( Dialog->WIDGET );
381
382 autend();
383 }
384
385 /*------------------------------------------------------------\
386 | |
387 | XfsmReEnterDialog |
388 | |
389 \------------------------------------------------------------*/
390
XfsmReEnterDialog()391 void XfsmReEnterDialog()
392 {
393 XfsmLockLoop = 1;
394 }
395
396 /*------------------------------------------------------------\
397 | |
398 | XfsmExitDialog |
399 | |
400 \------------------------------------------------------------*/
401
XfsmExitDialog()402 void XfsmExitDialog()
403
404 {
405 XfsmLockLoop = 0;
406 }
407
408 /*------------------------------------------------------------\
409 | |
410 | XfsmWarningMessage |
411 | |
412 \------------------------------------------------------------*/
413
XfsmWarningMessage(Father,Subject)414 void XfsmWarningMessage( Father, Subject )
415
416 Widget Father;
417 char *Subject;
418 {
419 XmString Label;
420
421 autbegin();
422
423 if ( XfsmWarningDialog.WIDGET == (Widget)NULL )
424 {
425 XfsmBuildDialog( Father, &XfsmWarningDialog );
426 }
427
428 Label = XmStringCreateLtoR( Subject,
429 XmSTRING_DEFAULT_CHARSET );
430
431 XtVaSetValues( XfsmWarningDialog.WIDGET,
432 XmNmessageString,
433 Label, NULL );
434
435 XmStringFree( Label );
436
437 XfsmEnterDialog( &XfsmWarningDialog );
438
439 autend();
440 }
441
442 /*------------------------------------------------------------\
443 | |
444 | XfsmErrorMessage |
445 | |
446 \------------------------------------------------------------*/
447
XfsmErrorMessage(Father,Subject)448 void XfsmErrorMessage( Father, Subject )
449
450 Widget Father;
451 char *Subject;
452 {
453 XmString Label;
454
455 autbegin();
456
457 if ( XfsmErrorDialog.WIDGET == (Widget)NULL )
458 {
459 XfsmBuildDialog( Father, &XfsmErrorDialog );
460 }
461
462 Label = XmStringCreateLtoR( Subject,
463 XmSTRING_DEFAULT_CHARSET );
464
465 XtVaSetValues( XfsmErrorDialog.WIDGET,
466 XmNmessageString,
467 Label, NULL );
468
469 XmStringFree( Label );
470
471 XfsmEnterDialog( &XfsmErrorDialog );
472
473 autend();
474 }
475