-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPUXMOUTP.c
250 lines (220 loc) · 10.3 KB
/
PUXMOUTP.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*PUXMOUTP*/
/*3456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678*/
#include "PKIN.h"
#include "PKINDLOG.h"
/****CANCEL_CB()**************************************************************/
XtCallbackProc CANCEL_CB(Widget w,XtPointer client_data,XtPointer call_data)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
XtUnmanageChild(w); /*remove the file dialog widget from the screen*/
XtDestroyWidget(w); /*destroy the file dialog widget*/
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
return(NULL);
}
/*___CANCEL_CB()_____________________________________________________________*/
/****fileout_OK_CB()**********************************************************/
XtCallbackProc fileout_OK_CB(Widget w,XtPointer client_data,XtPointer call_data)
/* Widget w; */
/* caddr_t client_data; */
/* XmAnyCallbackStruct *call_data; */
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
char *filename;
int j;
XmFileSelectionBoxCallbackStruct *cbs =
(XmFileSelectionBoxCallbackStruct *)call_data;
XtUnmanageChild(w); /*remove the file dialog widget from the screen*/
XtDestroyWidget(w); /*destroy the file dialog widget*/
/*retrieve the filename character string from the compound string format*/
XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename);
for(j=0; j<256; j++)
{
OutfileStr[j] = filename[j];
if(OutfileStr[j]=='\0') break;
}
Lgot_outfilename = 1;
prepareoutputfile();
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
return(NULL);
}
/*___fileout_OK_CB()_________________________________________________________*/
/****openoutput()*************************************************************/
int openoutput(void)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
static Widget fileoutdialog=NULL; /*static to remember if dialog created*/
XmString xmstring;
/* invoke the standard dialog for finding a file */
/* "word" holds message, "OutfileStr" has suggested file name */
{/*always create dialog*/ /*See D.A.Young,1994,pg238*/
n = 0;
XtSetArg(args[n], XmNvisual, progvisual); n++;
XtSetArg(args[n], XmNdepth, progdepth); n++;
XtSetArg(args[n], XmNcolormap, colormap); n++;
fileoutdialog =
XmCreateFileSelectionDialog(grafwindow,"openFileDialog",args,n);
XtAddCallback(fileoutdialog,XmNokCallback
,(XtCallbackProc)fileout_OK_CB,NULL);
XtAddCallback(fileoutdialog,XmNcancelCallback
,(XtCallbackProc)CANCEL_CB,NULL);
}/*always create dialog*/
/*force the filter Directory and file mask as specified for this task*/
xmstring = XmStringCreateSimple(DirStr);
XmFileSelectionDoSearch(fileoutdialog,xmstring);
XmStringFree(xmstring);
/*Now set the invented file name as a starting suggestion*/
sprintf(word,"output kinemage file:");
xmstring = XmStringCreateSimple(word);
XtVaSetValues(fileoutdialog,XmNselectionLabelString,xmstring,NULL);
XmStringFree(xmstring);
xmstring = XmStringCreateSimple(OutfileStr);
XtVaSetValues(fileoutdialog,XmNtextString,xmstring,NULL);
XmStringFree(xmstring);
XtManageChild(fileoutdialog); /*puts the file dialog widget on screen */
/* return(1); 130121 move out of conditional to avoid compiler warning*/
return(1);
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
return(0); // this return(0) has two purposes: 1) prevents a compiler warning, function must have return even if the whole ifdef-endif block isn't present, 2) returning non-1 gives a different behavior from when it works right (block otherwise returns 1). SML DCR 20151028
}
/*___openoutput()____________________________________________________________*/
/****scriptfile_OK_CB()*******************************************************/
XtCallbackProc scriptfile_OK_CB(Widget w,XtPointer client_da,XtPointer call_data)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
char *filename;
int j;
XmFileSelectionBoxCallbackStruct *cbs =
(XmFileSelectionBoxCallbackStruct *)call_data;
XtUnmanageChild(w); /*remove the file dialog widget from the screen*/
XtDestroyWidget(w); /*destroy the file dialog widget*/
/*retrieve the filename character string from the compound string format*/
XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename);
for(j=0; j<256; j++)
{
ScriptoutStr[j] = filename[j];
if(ScriptoutStr[j]=='\0') break;
}
/*if a previous file is open, close it*/
/*c*/ if(fpscriptout != NULL) fclose(fpscriptout);
/*c*/ if ((fpscriptout = fopen(ScriptoutStr,"w")) == NULL)
{
/*c*/ sprintf(alertstr,"Prekin failed to open file: \n%s "
,ScriptoutStr);
/*Ms*/ DoReportDialog();
Lrangecontrols = 0; /*go on past rangecontrols*/
Lscriptout = 0; /*can't write a script file*/
}
else /* file opened, write header into it */
{
/*c*/ fprintf(fpscriptout,"{script for coord file: %s }"EOLO,NameStr);
Lscriptout = 1; /*can write a script file*/
Lrangecontrols = 1; /*still rangecontrols*/
}
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
Lwaiting = 0;
return(NULL);
}
/*___scriptfile_OK_CB()______________________________________________________*/
/****openscriptout()*********************************************************/
int openscriptout(void)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
static Widget scriptfiledialog=NULL; /*static to remember if dialog created*/
XmString xmstring;
Lopenscriptout = 0; /*don't want to return to here*/
Lscriptout = 0; /*presume no file until proven open*/
Lrangecontrols = 0;
/*presume go on past rangecontrol unless can write script*/
{/*always create dialog*/ /*See D.A.Young,1994,pg238*/
n = 0;
XtSetArg(args[n], XmNvisual, progvisual); n++;
XtSetArg(args[n], XmNdepth, progdepth); n++;
XtSetArg(args[n], XmNcolormap, colormap); n++;
scriptfiledialog =
XmCreateFileSelectionDialog(grafwindow,"ScriptFileDialog",args,n);
XtAddCallback(scriptfiledialog,XmNokCallback
,(XtCallbackProc)scriptfile_OK_CB,NULL);
XtAddCallback(scriptfiledialog,XmNcancelCallback
,(XtCallbackProc)CANCEL_CB,NULL);
}/*always create dialog*/
sprintf(word,"save script file as:");
xmstring = XmStringCreateSimple(word);
XtVaSetValues(scriptfiledialog,XmNselectionLabelString,xmstring,NULL);
XmStringFree(xmstring);
xmstring = XmStringCreateSimple(ScriptoutStr);
XtVaSetValues(scriptfiledialog,XmNtextString,xmstring,NULL);
XmStringFree(xmstring);
XtManageChild(scriptfiledialog); /*puts the file dialog widget on screen */
Lwaiting = 1;
/* return(1); 130121 move out of conditional to avoid compile warning*/
return(1);
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
return(0); // this return(0) has two purposes: 1) prevents a compiler warning, function must have return even if the whole ifdef-endif block isn't present, 2) returning non-1 gives a different behavior from when it works right (block otherwise returns 1). SML DCR 20151028
}
/*___openscriptout()________________________________________________________*/
/****helpfile_OK_CB()*******************************************************/
XtCallbackProc helpfile_OK_CB(Widget w,XtPointer client_da,XtPointer call_data)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
char *filename;
int j;
XmFileSelectionBoxCallbackStruct *cbs =
(XmFileSelectionBoxCallbackStruct *)call_data;
XtUnmanageChild(w); /*remove the file dialog widget from the screen*/
XtDestroyWidget(w); /*destroy the file dialog widget*/
XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename);
for(j=0; j<256; j++)
{
helpoutStr[j] = filename[j];
if(helpoutStr[j]=='\0') break;
}
/*if a previous file is open, close it*/
if(fphelpout != NULL) fclose(fphelpout);
if ((fphelpout = fopen(helpoutStr,"w")) == NULL)
{
sprintf(alertstr,"Prekin failed to open file: \n%s",helpoutStr);
DoReportDialog();
Lhelpoutopen = 0; /*can't write a help file*/
}
else /* file opened */
{
Lhelpoutopen = 1;
}
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
Lwaiting = 0;
return(NULL);
}
/*___helpfile_OK_CB()______________________________________________________*/
/****openhelpout()*********************************************************/
int openhelpout(void)
{
#ifdef UNIX_MOTIF /*060324 re compile with NOGUI, requires Lquiet=1*/
static Widget helpfiledialog=NULL; /*static to remember if dialog created*/
XmString xmstring;
sprintf(helpoutStr,"prekinhelp.html");
Lhelpoutopen = 0; /*don't want to return to here*/
{/*always create dialog*/ /*See D.A.Young,1994,pg238*/
n = 0;
XtSetArg(args[n], XmNvisual, progvisual); n++;
XtSetArg(args[n], XmNdepth, progdepth); n++;
XtSetArg(args[n], XmNcolormap, colormap); n++;
helpfiledialog =
XmCreateFileSelectionDialog(grafwindow,"HelpFileDialog",args,n);
XtAddCallback(helpfiledialog,XmNokCallback
,(XtCallbackProc)helpfile_OK_CB,NULL);
XtAddCallback(helpfiledialog,XmNcancelCallback
,(XtCallbackProc)CANCEL_CB,NULL);
}/*always create dialog*/
sprintf(word,"save help file as:");
xmstring = XmStringCreateSimple(word);
XtVaSetValues(helpfiledialog,XmNselectionLabelString,xmstring,NULL);
XmStringFree(xmstring);
xmstring = XmStringCreateSimple(helpoutStr);
XtVaSetValues(helpfiledialog,XmNtextString,xmstring,NULL);
XmStringFree(xmstring);
XtManageChild(helpfiledialog); /*puts the file dialog widget on screen */
Lwaiting = 1;
#endif /* UNIX_MOTIF 060324 re compile with NOGUI, requires Lquiet=1*/
return(1);
}
/*___openhelpout()________________________________________________________*/