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    :                 Dialog.c                          |
33 |                                                             |
34 | Author  :                Jacomme Ludovic                    |
35 |                                                             |
36 | Date    :                  28.03.95                         |
37 |                                                             |
38 \------------------------------------------------------------*/
39 /*------------------------------------------------------------\
40 |                                                             |
41 |                         Include Files                       |
42 |                                                             |
43 \------------------------------------------------------------*/
44 
45 # include <stdio.h>
46 # include <string.h>
47 # include <Xm/Xm.h>
48 # include <Xm/FileSB.h>
49 # include <Xm/SelectioB.h>
50 # include <Xm/PushBG.h>
51 
52 # include "mut.h"
53 # include "mph.h"
54 # include "rds.h"
55 # include "rpr.h"
56 # include "rfm.h"
57 # include "GRM.h"
58 # include "GMX.h"
59 # include "GTB.h"
60 # include "GSB.h"
61 # include "GMT.h"
62 
63 # include "GMT_dialog.h"
64 # include "GMT_tools.h"
65 
66 /*------------------------------------------------------------\
67 |                                                             |
68 |                           Constants                         |
69 |                                                             |
70 \------------------------------------------------------------*/
71 /*------------------------------------------------------------\
72 |                                                             |
73 |                            Types                            |
74 |                                                             |
75 \------------------------------------------------------------*/
76 /*------------------------------------------------------------\
77 |                                                             |
78 |                          Variables                          |
79 |                                                             |
80 \------------------------------------------------------------*/
81 /*------------------------------------------------------------\
82 |                                                             |
83 |                          File Dialog                        |
84 |                                                             |
85 \------------------------------------------------------------*/
86 
87   GraalDialogItem GraalToolsLoadErrorDialog =
88 
89   {
90     "Load error file",
91     GRAAL_DIALOG_FILE,
92     (Widget)NULL,
93     (void *)CallbackToolsLoadErrorOk,
94     (XtPointer)NULL,
95     (void *)CallbackToolsLoadErrorCancel,
96     (XtPointer)NULL
97   };
98 
99   GraalDialogItem GraalToolsSavePixmapDialog =
100 
101   {
102     "Save xpm file As",
103     GRAAL_DIALOG_PROMPT,
104     (Widget)NULL,
105     (void *)CallbackToolsSavePixmapOk,
106     (XtPointer)NULL,
107     (void *)CallbackToolsSavePixmapCancel,
108     (XtPointer)NULL
109   };
110 
111 /*------------------------------------------------------------\
112 |                                                             |
113 |                          Functions                          |
114 |                                                             |
115 \------------------------------------------------------------*/
116 /*------------------------------------------------------------\
117 |                                                             |
118 |                  GraalBuildToolsDialog                      |
119 |                                                             |
120 \------------------------------------------------------------*/
121 
GraalBuildToolsDialog()122 void GraalBuildToolsDialog()
123 
124 {
125   rdsbegin();
126 
127   GraalBuildDialog( GraalMainWindow, &GraalToolsLoadErrorDialog  );
128   GraalBuildDialog( GraalMainWindow, &GraalToolsSavePixmapDialog );
129 
130   rdsend();
131 }
132 
133 /*------------------------------------------------------------\
134 |                                                             |
135 |                    CallbackToolsLoadErrorOk                 |
136 |                                                             |
137 \------------------------------------------------------------*/
138 
CallbackToolsLoadErrorOk(MyWidget,ClientData,FileStruct)139 void CallbackToolsLoadErrorOk( MyWidget, ClientData, FileStruct )
140 
141     Widget                            MyWidget;
142     caddr_t                           ClientData;
143     XmFileSelectionBoxCallbackStruct *FileStruct;
144 {
145   char *FileName;
146 
147   rdsbegin();
148 
149   XtUnmanageChild( GraalToolsLoadErrorDialog.WIDGET );
150 
151   GraalExitDialog();
152 
153   if ( FileStruct->value != NULL )
154   {
155     XmStringGetLtoR( FileStruct->value,
156                      XmSTRING_DEFAULT_CHARSET,
157                      &FileName
158                    );
159 
160     FileName = GraalPostTreatString( FileName );
161 
162     if ( FileName != (char *)NULL )
163     {
164       GraalToolsLoadError( FileName );
165 
166       GraalChangeEditMode( GRAAL_EDIT_MEASURE,
167                            GraalPromptEditMeasure );
168     }
169     else
170     {
171       GraalErrorMessage( GraalMainWindow, "Unable to load this file !" );
172     }
173   }
174 
175   rdsend();
176 }
177 
178 /*------------------------------------------------------------\
179 |                                                             |
180 |                    CallbackToolsLoadErrorCancel             |
181 |                                                             |
182 \------------------------------------------------------------*/
183 
CallbackToolsLoadErrorCancel(MyWidget,ClientData,FileStruct)184 void CallbackToolsLoadErrorCancel( MyWidget, ClientData, FileStruct )
185 
186     Widget                            MyWidget;
187     caddr_t                           ClientData;
188     XmFileSelectionBoxCallbackStruct *FileStruct;
189 {
190   rdsbegin();
191 
192   XtUnmanageChild( GraalToolsLoadErrorDialog.WIDGET );
193 
194   GraalExitDialog();
195 
196   rdsend();
197 }
198 
199 /*------------------------------------------------------------\
200 |                                                             |
201 |                  CallbackToolsSavePixmapOk                  |
202 |                                                             |
203 \------------------------------------------------------------*/
204 
CallbackToolsSavePixmapOk(MyWidget,ClientData,CallData)205 void CallbackToolsSavePixmapOk( MyWidget, ClientData, CallData )
206 
207     Widget                        MyWidget;
208     caddr_t                       ClientData;
209     XmSelectionBoxCallbackStruct *CallData;
210 {
211   char *FileName;
212 
213   rdsbegin();
214 
215   XmStringGetLtoR(  CallData->value,
216                     XmSTRING_DEFAULT_CHARSET,
217                    &FileName );
218 
219   FileName = GraalPostTreatString( FileName );
220 
221   XtUnmanageChild( GraalToolsSavePixmapDialog.WIDGET );
222 
223   GraalExitDialog();
224 
225   GraalToolsSavePixmap( FileName );
226 
227   rdsend();
228 }
229 
230 /*------------------------------------------------------------\
231 |                                                             |
232 |                CallbackToolsSavePixmapCancel                |
233 |                                                             |
234 \------------------------------------------------------------*/
235 
CallbackToolsSavePixmapCancel(MyWidget,ClientData,CallData)236 void CallbackToolsSavePixmapCancel( MyWidget, ClientData, CallData )
237 
238     Widget                        MyWidget;
239     caddr_t                       ClientData;
240     XmSelectionBoxCallbackStruct *CallData;
241 {
242   rdsbegin();
243 
244   XtUnmanageChild( GraalToolsSavePixmapDialog.WIDGET );
245 
246   GraalExitDialog();
247 
248   rdsend();
249 }
250