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