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    :                  menu.c                           |
33 |                                                             |
34 | Author  :                Jacomme Ludovic                    |
35 |                                                             |
36 | Date    :                  28.03.95                         |
37 |                                                             |
38 \------------------------------------------------------------*/
39 
40 # include <Xm/Xm.h>
41 # include <X11/Intrinsic.h>
42 # include <Xm/RowColumn.h>
43 # include <Xm/Label.h>
44 # include <Xm/SeparatoG.h>
45 # include <Xm/Separator.h>
46 
47 # include "mut.h"
48 # include "rds.h"
49 # include "GTB.h"
50 # include "GTB_menu.h"
51 
52 /*------------------------------------------------------------\
53 |                                                             |
54 |                         Include Files                       |
55 |                                                             |
56 \------------------------------------------------------------*/
57 /*------------------------------------------------------------\
58 |                                                             |
59 |                           Constants                         |
60 |                                                             |
61 \------------------------------------------------------------*/
62 /*------------------------------------------------------------\
63 |                                                             |
64 |                            Types                            |
65 |                                                             |
66 \------------------------------------------------------------*/
67 /*------------------------------------------------------------\
68 |                                                             |
69 |                          Variables                          |
70 |                                                             |
71 \------------------------------------------------------------*/
72 
73   static char MenuBuffer [ MENU_BUFFER_SIZE ];
74 
75 /*------------------------------------------------------------\
76 |                                                             |
77 |                          Functions                          |
78 |                                                             |
79 \------------------------------------------------------------*/
80 /*------------------------------------------------------------\
81 |                                                             |
82 |                       GraalBuildMenus                       |
83 |                                                             |
84 \------------------------------------------------------------*/
85 
GraalBuildMenus(Father,Menu)86 void GraalBuildMenus( Father, Menu )
87 
88      Widget          Father;
89      GraalMenuItem  *Menu;
90 {
91 
92   Widget   Button;
93   Widget   SubMenu;
94   XmString Text;
95   Arg      Args[ 2 ];
96   int      Counter;
97 
98   rdsbegin();
99 
100   for ( Counter = 0;
101         Menu[ Counter ].LABEL != NULL;
102         Counter++ )
103   {
104     if ( Menu[ Counter ].SEPARATOR == True )
105     {
106 	XtCreateManagedWidget( "Separator",
107                              xmSeparatorWidgetClass, Father,
108                              NULL                  ,
109                              0 );
110     }
111 
112     Button = XtVaCreateManagedWidget(  Menu[ Counter ].LABEL,
113                                        *Menu[ Counter ].CLASS, Father,
114                                        XmNmnemonic,
115                                        Menu[ Counter ].MNEMONIC,
116                                        NULL );
117     Menu[ Counter ].BUTTON = Button;
118 
119     if ( Menu[ Counter ].SHORT_KEY != NULL )
120     {
121       XtVaSetValues( Button,
122                      XmNaccelerator,
123                      Menu[ Counter ].SHORT_KEY,
124                      NULL );
125     }
126 
127     if ( Menu[ Counter ].SHORT_KEY != NULL )
128     {
129       Text = XmStringCreateSimple( Menu[ Counter ].SHORT_KEY_TEXT );
130 
131       XtVaSetValues( Button,
132                      XmNacceleratorText,
133                      Text,
134                      NULL );
135 
136       XmStringFree( Text );
137     }
138 
139     if ( Menu[ Counter ].CALLBACK != NULL )
140     {
141       XtAddCallback( Button,
142                      XmNactivateCallback,
143                      Menu[ Counter ].CALLBACK,
144                      Menu[ Counter ].CALLDATA );
145     }
146 
147     if ( Menu[ Counter ].HELP == True )
148     {
149 	XtSetArg( Args[ 0 ], XmNmenuHelpWidget, Button );
150 
151 	XtSetValues( Father, Args, 1 );
152     }
153 
154     if ( Menu[ Counter ].NEXT != NULL)
155     {
156 	strcpy( MenuBuffer, Menu[ Counter ].LABEL );
157 	strcat( MenuBuffer, " Menu"               );
158 
159       SubMenu = XmCreatePulldownMenu( Father,
160                                       MenuBuffer,
161                                       Args, 0 );
162 
163       Menu[ Counter ].MENU = SubMenu;
164 
165       if ( Menu[ Counter ].TITLE == True )
166       {
167 	  Text = XmStringCreateLtoR( MenuBuffer, XmSTRING_DEFAULT_CHARSET );
168 
169 	  XtVaCreateManagedWidget( "MenuTitle",
170                                  xmLabelWidgetClass,
171                                  SubMenu,
172                                  XmNlabelString, Text,
173                                  NULL );
174 
175         XmStringFree( Text );
176 
177         XtCreateManagedWidget( "Separator",
178                                xmSeparatorWidgetClass,
179                                SubMenu,
180                                NULL,
181                                0 );
182 	}
183 
184 	XtSetArg( Args[ 0 ], XmNsubMenuId, SubMenu );
185 	XtSetValues( Button, Args, 1 );
186 
187       GraalBuildMenus( SubMenu, Menu[ Counter ].NEXT );
188     }
189     else Menu[ Counter ].MENU = (Widget)NULL;
190   }
191 
192   rdsend();
193 }
194 
195