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    :                  panel.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 <stdio.h>
47 # include <X11/Intrinsic.h>
48 # include <Xm/Xm.h>
49 # include <Xm/Frame.h>
50 # include <Xm/Form.h>
51 # include <Xm/List.h>
52 # include <Xm/Text.h>
53 # include <Xm/PushB.h>
54 # include <Xm/DialogS.h>
55 
56 # include "mut.h"
57 # include "aut.h"
58 # include "abl.h"
59 # include "bdd.h"
60 # include "fsm.h"
61 # include "XTB.h"
62 # include "XSB.h"
63 # include "XTB_panel.h"
64 # include "XTB_dialog.h"
65 
66 /*------------------------------------------------------------\
67 |                                                             |
68 |                           Constants                         |
69 |                                                             |
70 \------------------------------------------------------------*/
71 /*------------------------------------------------------------\
72 |                                                             |
73 |                            Types                            |
74 |                                                             |
75 \------------------------------------------------------------*/
76 /*------------------------------------------------------------\
77 |                                                             |
78 |                          Variables                          |
79 |                                                             |
80 \------------------------------------------------------------*/
81 
82   char *XfsmPanelButtonDisable = "xxxx";
83 
84 /*------------------------------------------------------------\
85 |                                                             |
86 |                          Functions                          |
87 |                                                             |
88 \------------------------------------------------------------*/
89 /*------------------------------------------------------------\
90 |                                                             |
91 |                       XfsmBuildPanel                       |
92 |                                                             |
93 \------------------------------------------------------------*/
94 
XfsmBuildPanel(Father,Panel)95 void XfsmBuildPanel( Father, Panel )
96 
97      Widget           Father;
98      XfsmPanelItem  *Panel;
99 {
100   Arg                   Args[13];
101   XfsmPanelButtonItem *Button;
102   char                 *Label;
103   int                   Counter;
104   int                   Fraction;
105   int                   X1;
106   int                   Y1;
107   int                   X2;
108   int                   Y2;
109   Pixmap                ButtonPixmap;
110 
111   autbegin();
112 
113   Fraction = Panel->ROW * Panel->COLUMN;
114 
115   XtSetArg( Args[0], XmNshadowType, XmSHADOW_ETCHED_IN );
116   XtSetArg( Args[1], XmNdeleteResponse, XmDO_NOTHING );
117   XtSetArg( Args[2], XmNtitle         , Panel->TITLE   );
118 
119   Panel->PANEL = XmCreateFormDialog( Father, Panel->TITLE, Args, 3);
120 
121   XtAddCallback( Panel->PANEL, XmNdestroyCallback,
122                  XfsmDestroyDialogCallback, NULL );
123 
124   Panel->PANEL_FORM = XtVaCreateManagedWidget( "",
125                                                xmFormWidgetClass,
126                                                Panel->PANEL,
127                                                XmNtopAttachment    , XmATTACH_FORM,
128                                                XmNbottomAttachment , XmATTACH_FORM,
129                                                XmNleftAttachment   , XmATTACH_FORM,
130                                                XmNrightAttachment  , XmATTACH_FORM,
131                                                XmNfractionBase     , 100,
132                                                NULL
133                                              );
134 
135   Panel->FRAME = XtVaCreateManagedWidget( "",
136                                           xmFrameWidgetClass,
137                                           Panel->PANEL_FORM,
138                                           XmNtopAttachment    , XmATTACH_FORM,
139                                           XmNbottomAttachment , XmATTACH_FORM,
140                                           XmNleftAttachment   , XmATTACH_FORM,
141                                           XmNrightAttachment  , XmATTACH_FORM,
142                                           NULL
143                                         );
144 
145   Panel->FORM  = XtVaCreateManagedWidget( "",
146                                           xmFormWidgetClass,
147                                           Panel->FRAME,
148                                           XmNtopAttachment    , XmATTACH_FORM,
149                                           XmNbottomAttachment , XmATTACH_FORM,
150                                           XmNleftAttachment   , XmATTACH_FORM,
151                                           XmNrightAttachment  , XmATTACH_FORM,
152                                           XmNfractionBase     , Fraction,
153                                           NULL
154                                         );
155   Button = Panel->LIST;
156 
157   for ( Counter = 0;
158         Button[ Counter ].LABEL != NULL;
159         Counter++ )
160   {
161     X1 = Button[ Counter ].X * Panel->ROW;
162     Y1 = Button[ Counter ].Y * Panel->COLUMN;
163     X2 = X1 + Button[ Counter ].DX * Panel->ROW;
164     Y2 = Y1 + Button[ Counter ].DY * Panel->COLUMN;
165 
166     if ( *Button[ Counter ].LABEL[0] != '\0' )
167     {
168       Label = *Button[ Counter ].LABEL;
169     }
170     else
171     {
172       Label = XfsmPanelButtonDisable;
173     }
174 
175     if ( ( Button[ Counter ].TEXT   != (char *)NULL ) &&
176          ( Button[ Counter ].BITMAP != (char *)NULL ) )
177     {
178       XtSetArg( Args[0]  , XmNtopAttachment         , XmATTACH_POSITION );
179       XtSetArg( Args[1]  , XmNtopPosition           , Y1 );
180       XtSetArg( Args[2]  , XmNbottomAttachment      , XmATTACH_POSITION );
181       XtSetArg( Args[3]  , XmNbottomPosition        , Y2 );
182       XtSetArg( Args[4]  , XmNrightAttachment       , XmATTACH_POSITION );
183       XtSetArg( Args[5]  , XmNrightPosition         , X2 );
184       XtSetArg( Args[6]  , XmNleftAttachment        , XmATTACH_POSITION );
185       XtSetArg( Args[7]  , XmNleftPosition          , X1 );
186       XtSetArg( Args[8]  , XmNscrollBarDisplayPolicy, XmSTATIC );
187       XtSetArg( Args[9]  , XmNscrollHorizontal      , True );
188       XtSetArg( Args[10] , XmNscrollVertical        , True );
189       XtSetArg( Args[11] , XmNlistSizePolicy        , XmCONSTANT );
190       XtSetArg( Args[12] , XmNselectionPolicy       , XmMULTIPLE_SELECT );
191 
192       Button[ Counter ].BUTTON =
193 
194         XmCreateScrolledList( Panel->FORM, Button[ Counter ].TEXT, Args, 13 );
195 
196       XtManageChild ( Button[ Counter ].BUTTON );
197     }
198     else
199     if ( Button[ Counter ].TEXT != (char *)NULL )
200     {
201       XtSetArg( Args[0] , XmNrows                 , 10                );
202       XtSetArg( Args[1] , XmNeditable             , False             );
203       XtSetArg( Args[2] , XmNeditMode             , XmMULTI_LINE_EDIT );
204       XtSetArg( Args[3] , XmNcursorPositionVisible, False             );
205       XtSetArg( Args[4] , XmNtopAttachment        , XmATTACH_POSITION );
206       XtSetArg( Args[5] , XmNtopPosition          , Y1                );
207       XtSetArg( Args[6] , XmNleftAttachment       , XmATTACH_POSITION );
208       XtSetArg( Args[7] , XmNleftPosition         , X1                );
209       XtSetArg( Args[8] , XmNbottomAttachment     , XmATTACH_POSITION );
210       XtSetArg( Args[9] , XmNbottomPosition       , Y2                );
211       XtSetArg( Args[10], XmNrightAttachment      , XmATTACH_POSITION );
212       XtSetArg( Args[11], XmNrightPosition        , X2                );
213 
214       Button[ Counter ].BUTTON =
215 
216         XmCreateScrolledText( Panel->FORM, Button[ Counter ].TEXT, Args, 12);
217 
218       XtManageChild ( Button[ Counter ].BUTTON );
219     }
220     else
221     if ( Button[ Counter ].BITMAP != (char *)NULL )
222     {
223       ButtonPixmap = XfsmCreatePixmap( Father,
224                                         Button[ Counter ].BITMAP,
225                                         Button[ Counter ].WIDTH,
226                                         Button[ Counter ].HEIGHT );
227       Button[ Counter ].BUTTON =
228 
229         XtVaCreateManagedWidget( Label,
230                                  xmPushButtonWidgetClass,
231                                  Panel->FORM,
232                                  XmNlabelType        , XmPIXMAP,
233                                  XmNlabelPixmap      , ButtonPixmap,
234                                  XmNleftAttachment   , XmATTACH_POSITION,
235                                  XmNleftPosition     , X1,
236                                  XmNrightAttachment  , XmATTACH_POSITION,
237                                  XmNrightPosition    , X2,
238                                  XmNtopAttachment    , XmATTACH_POSITION,
239                                  XmNtopPosition      , Y1,
240                                  XmNbottomAttachment , XmATTACH_POSITION,
241                                  XmNbottomPosition   , Y2,
242                                  NULL
243                                );
244     }
245     else
246     {
247       Button[ Counter ].BUTTON =
248 
249         XtVaCreateManagedWidget( Label,
250                                  xmPushButtonWidgetClass,
251                                  Panel->FORM,
252                                  XmNleftAttachment   , XmATTACH_POSITION,
253                                  XmNleftPosition     , X1,
254                                  XmNrightAttachment  , XmATTACH_POSITION,
255                                  XmNrightPosition    , X2,
256                                  XmNtopAttachment    , XmATTACH_POSITION,
257                                  XmNtopPosition      , Y1,
258                                  XmNbottomAttachment , XmATTACH_POSITION,
259                                  XmNbottomPosition   , Y2,
260                                  NULL
261                                );
262     }
263 
264 
265     if ( Label != XfsmPanelButtonDisable )
266     {
267       if ( Button[ Counter ].FOREGROUND != NULL )
268       {
269         XtVaSetValues ( Button[ Counter ].BUTTON              ,
270                         XtVaTypedArg                          , XmNforeground,
271                         XmRString                             ,
272                         *Button[ Counter ].FOREGROUND         ,
273                         strlen ( *Button[ Counter ].FOREGROUND ) + 1,
274                         NULL
275                       );
276       }
277 
278       if ( Button[ Counter ].BACKGROUND != NULL )
279       {
280         XtVaSetValues ( Button[ Counter ].BUTTON              ,
281                         XtVaTypedArg                          , XmNbackground,
282                         XmRString                             ,
283                         *Button[ Counter ].BACKGROUND         ,
284                         strlen ( *Button[ Counter ].BACKGROUND ) + 1,
285                         NULL
286                       );
287       }
288 
289       if ( Button[ Counter ].CALLBACK    != NULL )
290       {
291         if ( ( Button[ Counter ].TEXT   != (char *)NULL ) &&
292              ( Button[ Counter ].BITMAP != (char *)NULL ) )
293         {
294           XtAddCallback( Button[ Counter ].BUTTON,
295                          XmNdefaultActionCallback,
296                          Button[ Counter ].CALLBACK,
297                          (XtPointer)NULL );
298 
299           XtAddCallback( Button[ Counter ].BUTTON,
300                          XmNmultipleSelectionCallback,
301                          Button[ Counter ].CALLBACK,
302                          Button[ Counter ].CALLDATA );
303 
304         }
305         else
306         {
307           XtAddCallback( Button[ Counter ].BUTTON,
308                          XmNactivateCallback,
309                          Button[ Counter ].CALLBACK,
310                          Button[ Counter ].CALLDATA );
311         }
312       }
313     }
314     else
315     {
316       Button[ Counter ].BUTTON = NULL;
317     }
318   }
319 
320   XtVaSetValues( Panel->PANEL ,
321                  XmNresizable , False,
322                  XmNx         , Panel->X,
323                  XmNy         , Panel->Y,
324                  XmNheight    , Panel->HEIGHT,
325                  XmNwidth     , Panel->WIDTH,
326                  NULL );
327 
328   autend();
329 }
330 
331 /*------------------------------------------------------------\
332 |                                                             |
333 |                       XfsmEnterPanel                       |
334 |                                                             |
335 \------------------------------------------------------------*/
336 
XfsmEnterPanel(Panel)337 void XfsmEnterPanel( Panel )
338 
339    XfsmPanelItem  *Panel;
340 {
341   autbegin();
342 
343   XtManageChild( Panel->PANEL );
344 
345   if ( Panel->COMPUTE == 1 )
346   {
347     XtVaSetValues( Panel->PANEL ,
348                    XmNresizable , False,
349                    XmNx         , Panel->X,
350                    XmNy         , Panel->Y,
351                    XmNheight    , Panel->HEIGHT,
352                    XmNwidth     , Panel->WIDTH,
353                    NULL );
354 
355     Panel->COMPUTE = 0;
356   }
357 
358   Panel->MANAGED = 1;
359 
360   autend();
361 }
362 
363 /*------------------------------------------------------------\
364 |                                                             |
365 |                        XfsmExitPanel                       |
366 |                                                             |
367 \------------------------------------------------------------*/
368 
XfsmExitPanel(Panel)369 void XfsmExitPanel( Panel )
370 
371    XfsmPanelItem  *Panel;
372 {
373   autbegin();
374 
375   XtUnmanageChild( Panel->PANEL );
376 
377   Panel->MANAGED = 0;
378 
379   autend();
380 }
381