Debian Codegraph @

gui/XEchelle/src/SessionShell.c

raw
1 /*===========================================================================
2 Copyright (C) 1995-2009 European Southern Observatory (ESO)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public
15 License along with this program; if not, write to the Free
16 Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
17 MA 02139, USA.
18
19 Corresponding concerning ESO-MIDAS should be addressed as follows:
20 Internet e-mail: [email protected]
21 Postal address: European Southern Observatory
22 Data Management Division
23 Karl-Schwarzschild-Strasse 2
24 D 85748 Garching bei Muenchen
25 GERMANY
26 ===========================================================================*/
27
28
29 /*******************************************************************************
30 SessionShell.c
31
32 .VERSION
33 090825 last modif
34
35 *******************************************************************************/
36
37 #include <stdio.h>
38 #include "UxLib.h"
39 #include "UxTextF.h"
40 #include "UxLabel.h"
41 #include "UxPushB.h"
42 #include "UxForm.h"
43 #include "UxApplSh.h"
44
45 /*******************************************************************************
46 Includes, Defines, and Global variables from the Declarations Editor:
47 *******************************************************************************/
48
49 #include <ExternResources.h>
50
51 /*******************************************************************************
52 The definition of the context structure:
53 If you create multiple instances of your interface, the context
54 structure ensures that your callbacks use the variables for the
55 correct instance.
56
57 For each swidget in the interface, each argument to the Interface
58 function, and each variable in the Instance Specific section of the
59 Declarations Editor, there is an entry in the context structure.
60 and a #define. The #define makes the variable name refer to the
61 corresponding entry in the context structure.
62 *******************************************************************************/
63
64 typedef struct
65 {
66 swidget Uxfile_dialog;
67 swidget Uxform12;
68 swidget Uxform13;
69 swidget UxpushButton25;
70 swidget UxpushButton26;
71 swidget Uxlb_file_dialog;
72 swidget Uxtf_file_dialog;
73 } _UxCfile_dialog;
74
75 #define file_dialog UxFile_dialogContext->Uxfile_dialog
76 #define form12 UxFile_dialogContext->Uxform12
77 #define form13 UxFile_dialogContext->Uxform13
78 #define pushButton25 UxFile_dialogContext->UxpushButton25
79 #define pushButton26 UxFile_dialogContext->UxpushButton26
80 #define lb_file_dialog UxFile_dialogContext->Uxlb_file_dialog
81 #define tf_file_dialog UxFile_dialogContext->Uxtf_file_dialog
82
83 static _UxCfile_dialog *UxFile_dialogContext;
84
85 extern void CallbackDialog();
86
87
88 /*******************************************************************************
89 Forward declarations of functions that are defined later in this file.
90 *******************************************************************************/
91
92 swidget create_file_dialog();
93
94 /*******************************************************************************
95 The following are callback functions.
96 *******************************************************************************/
97
98 static void activateCB_pushButton25( UxWidget, UxClientData, UxCallbackArg )
99 Widget UxWidget;
100 XtPointer UxClientData, UxCallbackArg;
101 {
102 _UxCfile_dialog *UxSaveCtx, *UxContext;
103 swidget UxThisWidget;
104
105 UxThisWidget = UxWidgetToSwidget( UxWidget );
106 UxSaveCtx = UxFile_dialogContext;
107 UxFile_dialogContext = UxContext =
108 (_UxCfile_dialog *) UxGetContext( UxThisWidget );
109 {
110 CallbackDialog();
111 }
112 UxFile_dialogContext = UxSaveCtx;
113 }
114
115 static void activateCB_pushButton26( UxWidget, UxClientData, UxCallbackArg )
116 Widget UxWidget;
117 XtPointer UxClientData, UxCallbackArg;
118 {
119 _UxCfile_dialog *UxSaveCtx, *UxContext;
120 swidget UxThisWidget;
121
122 UxThisWidget = UxWidgetToSwidget( UxWidget );
123 UxSaveCtx = UxFile_dialogContext;
124 UxFile_dialogContext = UxContext =
125 (_UxCfile_dialog *) UxGetContext( UxThisWidget );
126 {
127 UxPopdownInterface(UxFindSwidget("file_dialog"));
128 }
129 UxFile_dialogContext = UxSaveCtx;
130 }
131
132 static void activateCB_tf_file_dialog( UxWidget, UxClientData, UxCallbackArg )
133 Widget UxWidget;
134 XtPointer UxClientData, UxCallbackArg;
135 {
136 _UxCfile_dialog *UxSaveCtx, *UxContext;
137 swidget UxThisWidget;
138
139 UxThisWidget = UxWidgetToSwidget( UxWidget );
140 UxSaveCtx = UxFile_dialogContext;
141 UxFile_dialogContext = UxContext =
142 (_UxCfile_dialog *) UxGetContext( UxThisWidget );
143 {
144 CallbackDialog();
145 }
146 UxFile_dialogContext = UxSaveCtx;
147 }
148
149 static void losingFocusCB_tf_file_dialog( UxWidget, UxClientData, UxCallbackArg )
150 Widget UxWidget;
151 XtPointer UxClientData, UxCallbackArg;
152 {
153 _UxCfile_dialog *UxSaveCtx, *UxContext;
154 swidget UxThisWidget;
155
156 UxThisWidget = UxWidgetToSwidget( UxWidget );
157 UxSaveCtx = UxFile_dialogContext;
158 UxFile_dialogContext = UxContext =
159 (_UxCfile_dialog *) UxGetContext( UxThisWidget );
160 {
161 char *text;
162 extern char Session[];
163
164 text = XmTextGetString(UxWidget);
165 strcpy(Session, text);
166
167 XtFree(text);
168 }
169 UxFile_dialogContext = UxSaveCtx;
170 }
171
172 /*******************************************************************************
173 The 'init_' function sets the private properties for all the
174 swidgets to the values specified in the Property Table.
175 Some properties need to be set after the X widgets have been
176 created and the setting of these properties is done in the
177 'build_' function after the UxCreateWidget call.
178 *******************************************************************************/
179
180 static void _Uxinit_file_dialog()
181 {
182 UxPutBackground( file_dialog, WindowBackground );
183 UxPutGeometry( file_dialog, "+100+100" );
184 UxPutKeyboardFocusPolicy( file_dialog, "pointer" );
185 UxPutTitle( file_dialog, "" );
186 UxPutHeight( file_dialog, 105 );
187 UxPutWidth( file_dialog, 408 );
188 UxPutY( file_dialog, 121 );
189 UxPutX( file_dialog, 102 );
190
191 UxPutBackground( form12, WindowBackground );
192 UxPutHeight( form12, 348 );
193 UxPutWidth( form12, 408 );
194 UxPutY( form12, 0 );
195 UxPutX( form12, 0 );
196 UxPutUnitType( form12, "pixels" );
197 UxPutResizePolicy( form12, "resize_none" );
198
199 UxPutBackground( form13, ButtonBackground );
200 UxPutHeight( form13, 40 );
201 UxPutWidth( form13, 452 );
202 UxPutY( form13, 62 );
203 UxPutX( form13, 0 );
204 UxPutResizePolicy( form13, "resize_none" );
205
206 UxPutLabelString( pushButton25, "Ok" );
207 UxPutForeground( pushButton25, ApplyForeground );
208 UxPutFontList( pushButton25, BoldTextFont );
209 UxPutBackground( pushButton25, ButtonBackground );
210 UxPutHeight( pushButton25, 30 );
211 UxPutWidth( pushButton25, 80 );
212 UxPutY( pushButton25, 4 );
213 UxPutX( pushButton25, 8 );
214
215 UxPutLabelString( pushButton26, "Cancel" );
216 UxPutForeground( pushButton26, CancelForeground );
217 UxPutFontList( pushButton26, BoldTextFont );
218 UxPutBackground( pushButton26, ButtonBackground );
219 UxPutHeight( pushButton26, 30 );
220 UxPutWidth( pushButton26, 80 );
221 UxPutY( pushButton26, 4 );
222 UxPutX( pushButton26, 100 );
223
224 UxPutForeground( lb_file_dialog, TextForeground );
225 UxPutAlignment( lb_file_dialog, "alignment_beginning" );
226 UxPutLabelString( lb_file_dialog, "Output parameters file :" );
227 UxPutFontList( lb_file_dialog, TextFont );
228 UxPutBackground( lb_file_dialog, LabelBackground );
229 UxPutHeight( lb_file_dialog, 30 );
230 UxPutWidth( lb_file_dialog, 176 );
231 UxPutY( lb_file_dialog, 12 );
232 UxPutX( lb_file_dialog, 10 );
233
234 UxPutForeground( tf_file_dialog, TextForeground );
235 UxPutHighlightOnEnter( tf_file_dialog, "true" );
236 UxPutFontList( tf_file_dialog, TextFont );
237 UxPutBackground( tf_file_dialog, TextBackground );
238 UxPutHeight( tf_file_dialog, 34 );
239 UxPutWidth( tf_file_dialog, 210 );
240 UxPutY( tf_file_dialog, 10 );
241 UxPutX( tf_file_dialog, 190 );
242
243 }
244
245 /*******************************************************************************
246 The 'build_' function creates all the swidgets and X widgets,
247 and sets their properties to the values specified in the
248 Property Editor.
249 *******************************************************************************/
250
251 static swidget _Uxbuild_file_dialog()
252 {
253 /* Create the swidgets */
254
255 file_dialog = UxCreateApplicationShell( "file_dialog", NO_PARENT );
256 UxPutContext( file_dialog, UxFile_dialogContext );
257
258 form12 = UxCreateForm( "form12", file_dialog );
259 form13 = UxCreateForm( "form13", form12 );
260 pushButton25 = UxCreatePushButton( "pushButton25", form13 );
261 pushButton26 = UxCreatePushButton( "pushButton26", form13 );
262 lb_file_dialog = UxCreateLabel( "lb_file_dialog", form12 );
263 tf_file_dialog = UxCreateTextField( "tf_file_dialog", form12 );
264
265 _Uxinit_file_dialog();
266
267 /* Create the X widgets */
268
269 UxCreateWidget( file_dialog );
270 UxCreateWidget( form12 );
271 UxCreateWidget( form13 );
272 UxCreateWidget( pushButton25 );
273 UxCreateWidget( pushButton26 );
274 UxCreateWidget( lb_file_dialog );
275 UxCreateWidget( tf_file_dialog );
276
277 UxAddCallback( pushButton25, XmNactivateCallback,
278 activateCB_pushButton25,
279 (XtPointer) UxFile_dialogContext );
280
281 UxAddCallback( pushButton26, XmNactivateCallback,
282 activateCB_pushButton26,
283 (XtPointer) UxFile_dialogContext );
284
285 UxAddCallback( tf_file_dialog, XmNactivateCallback,
286 activateCB_tf_file_dialog,
287 (XtPointer) UxFile_dialogContext );
288 UxAddCallback( tf_file_dialog, XmNlosingFocusCallback,
289 losingFocusCB_tf_file_dialog,
290 (XtPointer) UxFile_dialogContext );
291
292
293 /* Finally, call UxRealizeInterface to create the X windows
294 for the widgets created above. */
295
296 UxRealizeInterface( file_dialog );
297
298 return ( file_dialog );
299 }
300
301 /*******************************************************************************
302 The following function includes the code that was entered
303 in the 'Initial Code' and 'Final Code' sections of the
304 Declarations Editor. This function is called from the
305 'Interface function' below.
306 *******************************************************************************/
307
308 static swidget _Ux_create_file_dialog()
309 {
310 swidget rtrn;
311 _UxCfile_dialog *UxContext;
312
313 UxFile_dialogContext = UxContext =
314 (_UxCfile_dialog *) UxMalloc( sizeof(_UxCfile_dialog) );
315
316 rtrn = _Uxbuild_file_dialog();
317
318 return(rtrn);
319 }
320
321 /*******************************************************************************
322 The following is the 'Interface function' which is the
323 external entry point for creating this interface.
324 This function should be called from your application or from
325 a callback function.
326 *******************************************************************************/
327
328 swidget create_file_dialog()
329 {
330 swidget _Uxrtrn;
331
332 _Uxrtrn = _Ux_create_file_dialog();
333
334 return ( _Uxrtrn );
335 }
336
337 /*******************************************************************************
338 END OF FILE
339 *******************************************************************************/
340