Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / xtas / xtas_init.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : XTAS Version 5 */
6 /* Fichier : xtas_init.c */
7 /* */
8 /* (c) copyright 1991-1998 Laboratoire LIP6 equipe ASIM */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
11 /* */
12 /* Author(s) : Lionel PROTZENKO Date : 01/08/1997 */
13 /* */
14 /* Modified by : Date : ../../.... */
15 /* Modified by : Date : ../../.... */
16 /* Modified by : Date : ../../.... */
17 /* */
18 /*--------------------------------------------------------------------------*/
19 /* */
20 /* */
21 /*--------------------------------------------------------------------------*/
22
23 /*--------------------------------------------------------------------------*/
24 /* INCLUDE FILES */
25 /*--------------------------------------------------------------------------*/
26 #include "xtas.h"
27
28 /*--------------------------------------------------------------------------*/
29 /* */
30 /* */
31 /*--------------------------------------------------------------------------*/
32 XtAppContext XtasApplicationContext;
33 char XTAS_SWITCH_COLOR_MAP = 'N';
34
35 char *WORK_LIB_SAVE = NULL;
36 char *spi_sfx = "spi";
37 char *vhd_sfx = "vhd";
38 char *vlg_sfx = "vlg";
39
40 Widget XtasTopLevel;
41 Widget XtasMainWindow;
42 Widget XtasDeskMainForm;
43 Widget XtasFrontWidget;
44
45 XalMessageWidgetStruct *XtasErrorWidget;
46 XalMessageWidgetStruct *XtasWarningWidget;
47 XalMessageWidgetStruct *XtasTraceWidget;
48 XalMessageWidgetStruct *XtasNotYetWidget;
49
50 XtasMainInfoStruct *XtasMainParam ;
51
52 static String XtasFallBacks[] = {
53 "*background : Grey",
54 "*pathMode : XmPATH_MODE_RELATIVE",
55 "xtas.*.menuBar*background : gray64",
56 "xtas.*.main*XtasInfosBox.background : Grey",
57 "xtas.*.main*XtasLogoForm*background : gray64",
58 "xtas.*.main*XtasMainTitles*background : gray64",
59 "xtas.*.main*XtasMainTitles*foreground : Maroon",
60 "xtas.*.XalExit.foreground : Red",
61 "xtas.*.XalErrorBox.foreground : Red",
62 "xtas.*.XalWarningBox.foreground : DarkOliveGreen",
63 "xtas.*.XalOnVersion.foreground : Blue",
64 "xtas.*.XtasMainState.foreground : DarkOliveGreen",
65 "xtas.*.XtasStateForm.borderColor : DarkOliveGreen",
66 "xtas.*.XtasUserField.foreground : royal blue",
67 "xtas.*.XtasUserField.background : PeachPuff",
68 "xtas.*.XtasDrawingArea.background : Black",
69 "xtas.*.XtasHelpField.foreground : royal blue",
70 "xtas.*.XtasHelpField.background : PeachPuff",
71 "xtas.*XtasTextualDisplay*background : PeachPuff",
72 "xtas.*XtasTextualDisplay*foreground : royal blue",
73 "xtas.*XtasTextualDisplay*listSizePolicy : XmCONSTANT",
74 "xtas.*.XtasRequesterBox.Text.background : PeachPuff",
75 "xtas.*.XtasRequesterBox.FilterText.background : PeachPuff",
76 /*
77 "xtas.x : 100",
78 "xtas.y : 300",
79 "xtas.minWidth : 540",
80 "xtas.maxWidth : 660",
81 "xtas.minHeight: 180",
82 "xtas.maxHeight: 335",
83 */
84 "xtas.title : "XTAS_NAME" Main Desk Window",
85 "xtas.iconName : "XTAS_NAME,
86 "xtas.*.main.*.fontList: -*-helvetica-bold-r-normal--14-*",
87 "xtas.*fontList: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-*",
88 "xtas.*.XtasTextualDisplay.*.fontList: -*-fixed-medium-r-normal-*-13-*-*-*-*-*-iso8859-*",
89 "xtas.*.main.*.XtasShellSubForm.*.fontList: -*-helvetica-bold-r-normal--12-*",
90 "xtas.*.XalMessageScrolled.*.fontList: -*-fixed-medium-r-normal-*-14-*-*-*-*-*-iso8859-*",
91 NULL };
92
93 #ifdef AVERTEC_LICENSE
94 /*---------------------------------------------------------------------------*/
95 /* */
96 /* FUNCTION : XtasAvtlicence */
97 /* */
98 /* IN ARGS : None */
99 /* */
100 /* OUT ARGS : ( void ) */
101 /* */
102 /* OBJECT : Call to avt licence server */
103 /* */
104 /*---------------------------------------------------------------------------*/
105 void XtasAvtlicence()
106 {
107 if(avt_givetoken("HITAS_LICENSE_SERVER","xtas") != AVT_VALID_TOKEN)
108 XtasExit(1) ;
109 XtAppAddTimeOut( XtasApplicationContext,60000,XtasAvtlicence,NULL);
110 }
111 #endif
112
113 /*---------------------------------------------------------------------------*/
114 /* */
115 /* FUNCTION : XtasPresent */
116 /* */
117 /* IN ARGS : None */
118 /* */
119 /* OUT ARGS : ( void ) */
120 /* */
121 /* OBJECT : Call to alliancebanner */
122 /* */
123 /*---------------------------------------------------------------------------*/
124 void XtasPresent()
125 {
126
127 #ifdef AVERTEC_LICENSE
128 if(avt_givetoken("HITAS_LICENSE_SERVER","xtas") != AVT_VALID_TOKEN)
129 XtasExit(1) ;
130 #endif
131
132 avt_banner(XTAS_NAME,XTAS_ABOUT,"1998");
133 }
134
135
136 /*---------------------------------------------------------------------------*/
137 /* */
138 /* FUNCTION : XtasInitMainParam */
139 /* */
140 /* IN ARGS : .widget : The widget on which the event occurs. */
141 /* .client_data : Not significant. */
142 /* .call_data : Not significant. */
143 /* */
144 /* OUT ARGS : ( void ) */
145 /* */
146 /* OBJECT : The callback function for the Front Page push button. */
147 /* In this fuction, we build the main window widgets. */
148 /* */
149 /*---------------------------------------------------------------------------*/
150 XtasMainInfoStruct *XtasInitMainParam()
151 {
152 XtasMainInfoStruct *param ;
153
154 param = (XtasMainInfoStruct *)mbkalloc(sizeof(XtasMainInfoStruct)) ;
155 param->ttvfig = NULL ;
156 param->stbfig = NULL ;
157 param->befig = NULL ;
158 return(param) ;
159 }
160
161 /*---------------------------------------------------------------------------*/
162 /* */
163 /* FUNCTION : XtasFrontCallback */
164 /* */
165 /* IN ARGS : .widget : The widget on which the event occurs. */
166 /* .client_data : Not significant. */
167 /* .call_data : Not significant. */
168 /* */
169 /* OUT ARGS : ( void ) */
170 /* */
171 /* OBJECT : The callback function for the Front Page push button. */
172 /* In this fuction, we build the main window widgets. */
173 /* */
174 /*---------------------------------------------------------------------------*/
175 void XtasInitializeWindows()
176 {
177 Widget XtasDeskMenuWidget, version_form;
178 Arg args[20];
179 int n;
180
181 XtasInitializeSignalsWindow();
182
183 XtasDeskMainForm = XtasCreateDesk( XtasDeskMainForm );
184 version_form = XtNameToWidget (XtasDeskMainForm, "*XtasVersionForm");
185 HelpFather = XtasDeskMainForm ;
186 XtasDeskMenuWidget = XtasCreateMainMenus( XtasMainWindow );
187 XtManageChild( XtasDeskMenuWidget );
188
189 /*---------------------------------*/
190 /* Use the Motif default areas set */
191 /*---------------------------------*/
192 XmMainWindowSetAreas( XtasMainWindow,
193 XtasDeskMenuWidget,
194 (Widget) NULL,
195 (Widget) NULL,
196 (Widget) NULL,
197 XtasDeskMainForm );
198
199 /*------------------------------------------------------------------*/
200 /* Creates a Motif Error and Warning Boxs and AllianceFrontPage */
201 /*------------------------------------------------------------------*/
202 XtasErrorWidget = XalCreateErrorBox( XtasDeskMainForm );
203 XtasWarningWidget = XalCreateWarningBox( XtasDeskMainForm );
204 XtasNotYetWidget = XalCreateWarningBox( XtasDeskMainForm );
205 XtasTraceWidget = XalCreateTraceBox( XtasDeskMainForm );
206 XalFrontPage( version_form,
207 NULL,
208 AVERTEC_VERSION,
209 PATCH_NUM,
210 "XTAS",
211 XTAS_ABOUT);
212
213 n = 0;
214 XtSetArg( args[n], XmNallowShellResize, False ); n++;
215 XtSetValues( XtasTopLevel, args, n );
216
217 XalForceUpdate( XtasTopLevel );
218 }
219
220 /*---------------------------------------------------------------------------*/
221 /* */
222 /* FUNCTION : XtasEnv */
223 /* */
224 /* */
225 /*---------------------------------------------------------------------------*/
226 void XtasEnv( void )
227 {
228 char *c;
229 #ifdef AVERTEC
230 avtenv() ;
231 #endif
232
233 mbkenv() ; /* sinon => traitement normal */
234 /* forcage de SCALE_X: la variable d'environnement ne sert plus */
235 if(V_INT_TAB[__MBK_SCALE_X].VALUE == NULL)
236 SCALE_X = 10000 ;
237 else
238 {
239 if(SCALE_X < 1000)
240 SCALE_X = 1000 ;
241 }
242
243 cnsenv() ;
244
245 yagenv(tas_yaginit) ;
246 fclenv() ;
247
248 elpenv() ;
249 mccenv() ;
250
251 tlcenv() ;
252 rcnenv();
253 rcx_env();
254 stb_env();
255 stb_ctk_env() ;
256
257 tas_setenv();
258 tmaenv(0);
259
260 libenv() ;
261 tlfenv() ;
262 cbhenv() ;
263 ttvenv() ;
264
265 Xyaggetenv();
266
267 if ((c=V_STR_TAB[__MBK_SPI_SUFFIX].VALUE)!=NULL) spi_sfx=c;
268 if ((c=V_STR_TAB[__MVL_FILE_SUFFIX].VALUE)!=NULL) vhd_sfx=c;
269 if ((c=V_STR_TAB[__MGL_FILE_SUFFIX].VALUE)!=NULL) vlg_sfx=c;
270
271 XTAS_DISPLAY_NEW = V_BOOL_TAB[__XTAS_TEXT_DISPLAY].VALUE;
272
273 }
274
275 /*---------------------------------------------------------------------------*/
276 /* */
277 /* FUNCTION : XtasAppInit */
278 /* */
279 /* IN ARGS : None */
280 /* */
281 /* OUT ARGS : ( void ) */
282 /* */
283 /* OBJECT : Initialization of graphics variables. */
284 /* */
285 /*---------------------------------------------------------------------------*/
286 void XtasAppInit( void )
287 {
288
289 char avertec_version[128];
290
291 /*------------------------------------*/
292 /* Set MBK environnement variables */
293 /*------------------------------------*/
294 XtasEnv() ;
295
296 XalBitmaps = Xtas_bitmaps ;
297
298 XtasPresent();
299
300 sprintf (avertec_version,"%g%s", AVT_VERSION, PATCH_NUM) ;
301
302 /*--------------------------------------------------*/
303 /* Prepare the message for the Help On Version box */
304 /*--------------------------------------------------*/
305 XtasOnVersion = (char *)mbkalloc( strlen(XTAS_ABOUT) + strlen( avertec_version ) + 2 );
306 strcpy( XtasOnVersion, XTAS_ABOUT );
307 strcat( XtasOnVersion, "\n" );
308 strcat( XtasOnVersion, avertec_version );
309 }
310
311 /*---------------------------------------------------------------------------*/
312 /* */
313 /* FUNCTION : XtasInitializeRessources */
314 /* */
315 /* IN ARGS : .You can give some X resources in your argv. They will be */
316 /* passed to the X server in the XtVaAppInitialize call. */
317 /* */
318 /* OUT ARGS : ( void ) */
319 /* */
320 /* OBJECT : initialise the main widget */
321 /* */
322 /*---------------------------------------------------------------------------*/
323 void XtasInitializeRessources( argc, argv )
324 int *argc;
325 char *argv[];
326 {
327 int n;
328 Arg args[10];
329 Colormap XtasColorMap;
330 Display *ADisplay;
331 Screen *AScreen;
332
333 MBK_EXIT_KILL = 'Y';
334
335 XtasAppInit( );
336
337 XtasTopLevel = XtVaAppInitialize( &XtasApplicationContext,
338 "Xtas",
339 NULL,
340 0,
341 argc,
342 argv,
343 XtasFallBacks,
344 NULL );
345
346 n = 0;
347 /*
348 XtSetArg( args[n], XmNx , 100 ); n++;
349 XtSetArg( args[n], XmNy , 100 ); n++;
350 XtSetArg( args[n], XmNwidth , 660 ); n++;
351 XtSetArg( args[n], XmNheight , 320 ); n++;
352 */
353
354 ADisplay = XtDisplay(XtasTopLevel);
355 AScreen = XtScreen(XtasTopLevel);
356 XtasColorMap = DefaultColormapOfScreen(AScreen);
357
358 if (XTAS_SWITCH_COLOR_MAP == 'Y') {
359 XtasColorMap = XCopyColormapAndFree(ADisplay, XtasColorMap);
360 XInstallColormap(ADisplay, XtasColorMap);
361 XtSetArg( args[n], XmNcolormap, XtasColorMap); n++;
362 }
363
364 XtSetValues( XtasTopLevel, args, n );
365
366 XalSetIcon( XtasTopLevel );
367
368 XtasMainWindow = XtVaCreateManagedWidget( "XtasMainWindow",
369 xmMainWindowWidgetClass,
370 XtasTopLevel,
371 NULL
372 );
373
374 XtasDeskMainForm = XtVaCreateManagedWidget( "XtasDeskMainForm",
375 xmFormWidgetClass,
376 XtasMainWindow,
377 XmNfractionBase,
378 200,
379 NULL );
380
381 XtasMainParam = XtasInitMainParam() ;
382
383 XtasInitializeWindows();
384
385 XtasSetXyagleQuitFOnction() ;
386 XyagCreateMainWindow(XtasTopLevel,XtasApplicationContext,&XtasColorMap) ;
387
388 XtRealizeWidget( XtasTopLevel );
389
390 #ifdef AVERTEC_LICENSE
391 XtasAvtlicence() ;
392 #endif
393
394 XtasInitFileErr() ;
395 }