Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / xal / FrontPage.c
1 /****************************************************************************/
2 /* */
3 /* ALLIANCE CAD FRAMEWORK */
4 /* */
5 /* Tool : libXal Version 1.01 */
6 /* File : FrontPage.c */
7 /* */
8 /* (c) copyright 1993 MASI Laboratory. CAO & VLSI CAD Team */
9 /* All rights reserved. */
10 /* Support : e-mail cao-vlsi@masi.ibp.fr */
11 /* */
12 /* Author(s) : Nizar ABDALLAH Date : 02/02/1993 */
13 /* */
14 /* Modified by : Date : ../../.... */
15 /* Modified by : Date : ../../.... */
16 /* Modified by : Date : ../../.... */
17 /* */
18 /****************************************************************************/
19 /* */
20 /* This is a complicated function of the libXal library. In order to */
21 /* present a homogeneous aspect of all ALLIANCE cad framework tools, we can */
22 /* start by having the same front page. To use this function, each tool must*/
23 /* include <Xal101.h> file. */
24 /* */
25 /* Concerning the programming precautions, you must take care of reserving */
26 /* a main window of 850x450 and a minimum of 650x350 so that the front page */
27 /* may be entirely visible. */
28 /* */
29 /* The other advice is to add in your resource's list the following line : */
30 /* */
31 /* "*.XalToolName.foreground: Red" */
32 /* */
33 /* We choose to avoid hard-coding colors in our routines; We provide enough */
34 /* flexibility for the user to configure colors through resource databases */
35 /* or interactively in the application. */
36 /* */
37 /* We first wrote this function for all ALLIANCE Motif Tools. This explains */
38 /* why we have default values for most arguments. But you can pass whatever */
39 /* you like in order to use this function for other frameworks. */
40 /* */
41 /* The last obligation is to pass an xmFormWidgetClass widget as the parent */
42 /* so that all attachments could be correctly done. */
43 /* */
44 /* Note : The ToolName will appear as a PushButton. When pressed, the X */
45 /* server will call your callback function passed as argument. */
46 /* */
47 /****************************************************************************/
48
49
50 /*--------------------------------------------------------------------------*/
51 /* INCLUDE FILES */
52 /*--------------------------------------------------------------------------*/
53
54 #include <time.h>
55
56 /*----------------*/
57 /* Motif includes */
58 /*----------------*/
59 #include <Xm/Form.h>
60 #include <Xm/Frame.h>
61 #include <Xm/Label.h>
62 #include <Xm/LabelG.h>
63 #include <Xm/PushB.h>
64 #include <Xm/TextF.h>
65 #include <Xm/Text.h>
66
67 /*-----------------------------*/
68 /* Motif for Alliance includes */
69 /*-----------------------------*/
70 #include MUT_H
71
72 #include XAL_H
73 #include "Logo.h"
74
75
76 /*---------------------------------------------------------------------------*/
77 /* */
78 /* FUNCTION : XalFrontPage */
79 /* */
80 /* IN ARGS : .parent : Parent widget, MUST BE A FORM CLASS. */
81 /* .cad_title : 1st title; if NULL then "ALLIANCE CAD FRAMEWORK".*/
82 /* .tool_name : Tool Name; if NULL then "xxxxxx". */
83 /* .tool_title : Description; if NULL then BLANK. */
84 /* .version : Version; if NULL then "Version x.x". */
85 /* .right : Copyrights; if NULL then "(c) MASI...". */
86 /* .callback_func : Function to be executed when the tool */
87 /* name PushButton is pressed. */
88 /* */
89 /* OUT ARGS : The widget id of the frame that contains all the front page. */
90 /* */
91 /* OBJECT : Creates a front page within a frame widget. */
92 /* */
93 /*---------------------------------------------------------------------------*/
94 void XalFrontPage( parent, cad_title, cad_version, cad_patch, tool_name, tool_title )
95 Widget parent;
96 char *cad_title, *cad_version, *cad_patch, *tool_name, *tool_title;
97 {
98 Widget PixmapLabel;
99 Widget form_t, frame_widget, label_widget;
100 XmString text, text_bis, text_ter;
101 Display *dpy;
102 XmFontList fontlist;
103 XFontStruct *font;
104 Arg args[20];
105 int n, ecart;
106 time_t timer;
107 char day[4], month[4];
108 int year, nday, hour, minute, second;
109 char copyright[16];
110 char cad_versionpatch[1024];
111
112 char *def_cad_title = "AVERTEC Release ";
113 char *def_cad_version = "x.x";
114 char *def_cad_patch = "px";
115 char *def_tool_name = "xxxxxxxx";
116 char *def_tool_title = " ";
117 char *rights_1 = "\251 ";
118 char *rights_2 = "\nE-mail support: support@avertec.com";
119
120 time(&timer);
121 sscanf(ctime(&timer), "%s %s %d %d:%d:%d %d", day, month, &nday, &hour, &minute, &second, &year);
122
123 dpy = XtDisplay( parent );
124 font = XLoadQueryFont( dpy, "-*-helvetica-bold-o-*--24-*" );
125 fontlist = XmFontListCreate( font, "front_charset1" );
126 font = XLoadQueryFont( dpy, "-*-helvetica-bold-r-*--18-*" );
127 fontlist = XmFontListAdd( fontlist, font, "front_charset2" );
128 font = XLoadQueryFont( dpy, "-*-helvetica-bold-r-*--12-*" );
129 fontlist = XmFontListAdd( fontlist, font, "front_charset4" );
130
131
132 if ( cad_title == NULL ) cad_title = def_cad_title;
133 if ( cad_version == NULL ) cad_version = def_cad_version;
134 if ( cad_patch == NULL ) cad_patch = def_cad_patch;
135 if ( tool_name == NULL ) tool_name = def_tool_name;
136 if ( tool_title == NULL ) tool_title = def_tool_title;
137
138
139 /*----------------------------------------*/
140 /* Create frame widget to add a 3D effect */
141 /*----------------------------------------*/
142 n = 0;
143 XtSetArg( args[n], XmNtopAttachment, XmATTACH_POSITION ); n++;
144 XtSetArg( args[n], XmNtopPosition, 8 ); n++;
145 XtSetArg( args[n], XmNbottomAttachment, XmATTACH_POSITION ); n++;
146 XtSetArg( args[n], XmNbottomPosition, 92 ); n++;
147 XtSetArg( args[n], XmNleftAttachment, XmATTACH_POSITION ); n++;
148 XtSetArg( args[n], XmNleftPosition, 4 ); n++;
149 XtSetArg( args[n], XmNrightAttachment, XmATTACH_POSITION ); n++;
150 XtSetArg( args[n], XmNrightPosition, 96 ); n++;
151 frame_widget = XmCreateFrame( parent, "XalFrontFrame", args, n );
152 XtManageChild( frame_widget );
153
154 /*----------------------------------------------*/
155 /* Create a Form widget to manage child widgets */
156 /*----------------------------------------------*/
157 n = 0;
158 form_t = XtCreateManagedWidget( "XalFrontForm", xmFormWidgetClass, frame_widget, args, n );
159
160 /*--------------------------------------*/
161 /* Create an icon to make things pretty */
162 /*--------------------------------------*/
163 #ifndef AVERTEC
164 label_widget = XmCreateLabel( form_t, "ColorXtasLogo", args, n);
165 PixmapLabel = XalCreatePixmapLabel( label_widget, LogoAsim, NULL );
166 XtManageChild( PixmapLabel );
167 #endif
168
169
170
171 sprintf (cad_versionpatch, "%s%s", cad_version, cad_patch);
172
173 text_bis = XmStringCreateLtoR( cad_title, "front_charset2" );
174 text_ter = XmStringCreateLtoR( cad_versionpatch, "front_charset2" );
175 text = XmStringConcat( text_bis, text_ter );
176 label_widget = XtVaCreateManagedWidget( "XalCadTitle", xmLabelWidgetClass, form_t,
177 XmNfontList, fontlist,
178 XmNlabelString, text,
179 XmNtopAttachment, XmATTACH_POSITION,
180 XmNtopPosition, 10,
181 XmNrightAttachment, XmATTACH_POSITION,
182 XmNrightPosition, 100,
183 XmNleftAttachment, XmATTACH_POSITION,
184 XmNleftPosition, 0,
185 NULL);
186 XmStringFree( text_bis ); XmStringFree( text_ter ); XmStringFree( text );
187
188 ecart = strlen( tool_name ) * 3 / 2;
189 text = XmStringCreateLtoR( tool_name, "front_charset1" );
190 label_widget = XtVaCreateManagedWidget( "XalToolName", xmLabelWidgetClass, form_t,
191 XmNfontList, fontlist,
192 XmNlabelString, text,
193 XmNtopAttachment, XmATTACH_WIDGET,
194 XmNtopWidget, label_widget,
195 XmNtopOffset, 5,
196 XmNrightAttachment, XmATTACH_POSITION,
197 XmNrightPosition, 55+ecart,
198 XmNleftAttachment, XmATTACH_POSITION,
199 XmNleftPosition, 45-ecart,
200 NULL);
201
202 XmStringFree( text );
203
204 text = XmStringCreateLtoR( tool_title, "front_charset2" );
205 label_widget = XtVaCreateManagedWidget( "XalToolTitle", xmLabelWidgetClass, form_t,
206 XmNfontList, fontlist,
207 XmNlabelString, text,
208 XmNtopAttachment, XmATTACH_WIDGET,
209 XmNtopWidget, label_widget,
210 XmNtopOffset, 5,
211 XmNrightAttachment, XmATTACH_POSITION,
212 XmNrightPosition, 100,
213 XmNleftAttachment, XmATTACH_POSITION,
214 XmNleftPosition, 0,
215 NULL);
216 XmStringFree( text );
217
218 text = XmStringCreateLtoR( rights_1, "front_charset4" );
219 sprintf(copyright,"1998-%d",year);
220 text_bis = XmStringCreateLtoR( copyright, "front_charset4" );
221 text_ter = XmStringConcat( text, text_bis );
222 XmStringFree( text ); XmStringFree( text_bis );
223
224 text_bis = XmStringCreateLtoR( rights_2, "front_charset4" );
225 text = XmStringConcat( text_ter, text_bis );
226 label_widget = XtVaCreateManagedWidget( "XalToolRights", xmLabelWidgetClass, form_t,
227 XmNfontList, fontlist,
228 XmNlabelString, text,
229 XmNtopAttachment, XmATTACH_WIDGET,
230 XmNtopWidget, label_widget,
231 XmNtopOffset, 5,
232 XmNrightAttachment, XmATTACH_FORM,
233 XmNleftAttachment, XmATTACH_FORM,
234 // XmNbottomAttachment, XmATTACH_POSITION,
235 // XmNbottomPosition, 90,
236 NULL);
237 XmStringFree( text_bis ); XmStringFree( text_ter ); XmStringFree( text );
238
239 }
240
241