Debian Codegraph @

gui/XEchelle/src/extin_dialog.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 Massachusetts Ave, Cambridge,
17 MA 02139, USA.
18
19 Correspondence 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 extin_dialog.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 Uxextin_dialog;
67 swidget Uxform16;
68 swidget Uxform17;
69 swidget UxpushButton34;
70 swidget UxpushButton35;
71 swidget Uxlb_output_extin;
72 swidget Uxtf_output_extin;
73 swidget Uxlb_airmass;
74 swidget Uxtf_airmass;
75 } _UxCextin_dialog;
76
77 #define extin_dialog UxExtin_dialogContext->Uxextin_dialog
78 #define form16 UxExtin_dialogContext->Uxform16
79 #define form17 UxExtin_dialogContext->Uxform17
80 #define pushButton34 UxExtin_dialogContext->UxpushButton34
81 #define pushButton35 UxExtin_dialogContext->UxpushButton35
82 #define lb_output_extin UxExtin_dialogContext->Uxlb_output_extin
83 #define tf_output_extin UxExtin_dialogContext->Uxtf_output_extin
84 #define lb_airmass UxExtin_dialogContext->Uxlb_airmass
85 #define tf_airmass UxExtin_dialogContext->Uxtf_airmass
86
87 static _UxCextin_dialog *UxExtin_dialogContext;
88
89 extern void CallbackDialog();
90
91
92 /*******************************************************************************
93 Forward declarations of functions that are defined later in this file.
94 *******************************************************************************/
95
96 swidget create_extin_dialog();
97
98 /*******************************************************************************
99 The following are callback functions.
100 *******************************************************************************/
101
102 static void activateCB_pushButton34( UxWidget, UxClientData, UxCallbackArg )
103 Widget UxWidget;
104 XtPointer UxClientData, UxCallbackArg;
105 {
106 _UxCextin_dialog *UxSaveCtx, *UxContext;
107 swidget UxThisWidget;
108
109 UxThisWidget = UxWidgetToSwidget( UxWidget );
110 UxSaveCtx = UxExtin_dialogContext;
111 UxExtin_dialogContext = UxContext =
112 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
113 {
114 CallbackDialog();
115 }
116 UxExtin_dialogContext = UxSaveCtx;
117 }
118
119 static void activateCB_pushButton35( UxWidget, UxClientData, UxCallbackArg )
120 Widget UxWidget;
121 XtPointer UxClientData, UxCallbackArg;
122 {
123 _UxCextin_dialog *UxSaveCtx, *UxContext;
124 swidget UxThisWidget;
125
126 UxThisWidget = UxWidgetToSwidget( UxWidget );
127 UxSaveCtx = UxExtin_dialogContext;
128 UxExtin_dialogContext = UxContext =
129 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
130 {
131 UxPopdownInterface(UxFindSwidget("extin_dialog"));
132 }
133 UxExtin_dialogContext = UxSaveCtx;
134 }
135
136 static void activateCB_tf_output_extin( UxWidget, UxClientData, UxCallbackArg )
137 Widget UxWidget;
138 XtPointer UxClientData, UxCallbackArg;
139 {
140 _UxCextin_dialog *UxSaveCtx, *UxContext;
141 swidget UxThisWidget;
142
143 UxThisWidget = UxWidgetToSwidget( UxWidget );
144 UxSaveCtx = UxExtin_dialogContext;
145 UxExtin_dialogContext = UxContext =
146 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
147 {
148 CallbackDialog();
149 }
150 UxExtin_dialogContext = UxSaveCtx;
151 }
152
153 static void losingFocusCB_tf_output_extin( UxWidget, UxClientData, UxCallbackArg )
154 Widget UxWidget;
155 XtPointer UxClientData, UxCallbackArg;
156 {
157 _UxCextin_dialog *UxSaveCtx, *UxContext;
158 swidget UxThisWidget;
159
160 UxThisWidget = UxWidgetToSwidget( UxWidget );
161 UxSaveCtx = UxExtin_dialogContext;
162 UxExtin_dialogContext = UxContext =
163 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
164 {
165 char *text;
166 extern char Session[];
167
168 text = XmTextGetString(UxWidget);
169 strcpy(Session, text);
170
171 XtFree(text);
172 }
173 UxExtin_dialogContext = UxSaveCtx;
174 }
175
176 static void activateCB_tf_airmass( UxWidget, UxClientData, UxCallbackArg )
177 Widget UxWidget;
178 XtPointer UxClientData, UxCallbackArg;
179 {
180 _UxCextin_dialog *UxSaveCtx, *UxContext;
181 swidget UxThisWidget;
182
183 UxThisWidget = UxWidgetToSwidget( UxWidget );
184 UxSaveCtx = UxExtin_dialogContext;
185 UxExtin_dialogContext = UxContext =
186 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
187 {
188 CallbackDialog();
189 }
190 UxExtin_dialogContext = UxSaveCtx;
191 }
192
193 static void losingFocusCB_tf_airmass( UxWidget, UxClientData, UxCallbackArg )
194 Widget UxWidget;
195 XtPointer UxClientData, UxCallbackArg;
196 {
197 _UxCextin_dialog *UxSaveCtx, *UxContext;
198 swidget UxThisWidget;
199
200 UxThisWidget = UxWidgetToSwidget( UxWidget );
201 UxSaveCtx = UxExtin_dialogContext;
202 UxExtin_dialogContext = UxContext =
203 (_UxCextin_dialog *) UxGetContext( UxThisWidget );
204 {
205 char *text;
206 extern char Session[];
207
208 text = XmTextGetString(UxWidget);
209 strcpy(Session, text);
210
211 XtFree(text);
212 }
213 UxExtin_dialogContext = UxSaveCtx;
214 }
215
216 /*******************************************************************************
217 The 'init_' function sets the private properties for all the
218 swidgets to the values specified in the Property Table.
219 Some properties need to be set after the X widgets have been
220 created and the setting of these properties is done in the
221 'build_' function after the UxCreateWidget call.
222 *******************************************************************************/
223
224 static void _Uxinit_extin_dialog()
225 {
226 UxPutBackground( extin_dialog, WindowBackground );
227 UxPutGeometry( extin_dialog, "+100+100" );
228 UxPutKeyboardFocusPolicy( extin_dialog, "pointer" );
229 UxPutTitle( extin_dialog, "" );
230 UxPutHeight( extin_dialog, 135 );
231 UxPutWidth( extin_dialog, 342 );
232 UxPutY( extin_dialog, 121 );
233 UxPutX( extin_dialog, 102 );
234
235 UxPutBackground( form16, WindowBackground );
236 UxPutHeight( form16, 138 );
237 UxPutWidth( form16, 408 );
238 UxPutY( form16, 0 );
239 UxPutX( form16, 0 );
240 UxPutUnitType( form16, "pixels" );
241 UxPutResizePolicy( form16, "resize_none" );
242
243 UxPutBackground( form17, ButtonBackground );
244 UxPutHeight( form17, 40 );
245 UxPutWidth( form17, 340 );
246 UxPutY( form17, 96 );
247 UxPutX( form17, 0 );
248 UxPutResizePolicy( form17, "resize_none" );
249
250 UxPutLabelString( pushButton34, "Ok" );
251 UxPutForeground( pushButton34, ApplyForeground );
252 UxPutFontList( pushButton34, BoldTextFont );
253 UxPutBackground( pushButton34, ButtonBackground );
254 UxPutHeight( pushButton34, 30 );
255 UxPutWidth( pushButton34, 80 );
256 UxPutY( pushButton34, 4 );
257 UxPutX( pushButton34, 8 );
258
259 UxPutLabelString( pushButton35, "Cancel" );
260 UxPutForeground( pushButton35, CancelForeground );
261 UxPutFontList( pushButton35, BoldTextFont );
262 UxPutBackground( pushButton35, ButtonBackground );
263 UxPutHeight( pushButton35, 30 );
264 UxPutWidth( pushButton35, 80 );
265 UxPutY( pushButton35, 4 );
266 UxPutX( pushButton35, 100 );
267
268 UxPutForeground( lb_output_extin, TextForeground );
269 UxPutAlignment( lb_output_extin, "alignment_beginning" );
270 UxPutLabelString( lb_output_extin, "Output image :" );
271 UxPutFontList( lb_output_extin, TextFont );
272 UxPutBackground( lb_output_extin, LabelBackground );
273 UxPutHeight( lb_output_extin, 30 );
274 UxPutWidth( lb_output_extin, 104 );
275 UxPutY( lb_output_extin, 56 );
276 UxPutX( lb_output_extin, 10 );
277
278 UxPutForeground( tf_output_extin, TextForeground );
279 UxPutHighlightOnEnter( tf_output_extin, "true" );
280 UxPutFontList( tf_output_extin, TextFont );
281 UxPutBackground( tf_output_extin, TextBackground );
282 UxPutHeight( tf_output_extin, 34 );
283 UxPutWidth( tf_output_extin, 210 );
284 UxPutY( tf_output_extin, 54 );
285 UxPutX( tf_output_extin, 118 );
286
287 UxPutForeground( lb_airmass, TextForeground );
288 UxPutAlignment( lb_airmass, "alignment_beginning" );
289 UxPutLabelString( lb_airmass, "Airmass value :" );
290 UxPutFontList( lb_airmass, TextFont );
291 UxPutBackground( lb_airmass, LabelBackground );
292 UxPutHeight( lb_airmass, 30 );
293 UxPutWidth( lb_airmass, 106 );
294 UxPutY( lb_airmass, 20 );
295 UxPutX( lb_airmass, 10 );
296
297 UxPutForeground( tf_airmass, TextForeground );
298 UxPutHighlightOnEnter( tf_airmass, "true" );
299 UxPutFontList( tf_airmass, TextFont );
300 UxPutBackground( tf_airmass, TextBackground );
301 UxPutHeight( tf_airmass, 34 );
302 UxPutWidth( tf_airmass, 108 );
303 UxPutY( tf_airmass, 18 );
304 UxPutX( tf_airmass, 118 );
305
306 }
307
308 /*******************************************************************************
309 The 'build_' function creates all the swidgets and X widgets,
310 and sets their properties to the values specified in the
311 Property Editor.
312 *******************************************************************************/
313
314 static swidget _Uxbuild_extin_dialog()
315 {
316 /* Create the swidgets */
317
318 extin_dialog = UxCreateApplicationShell( "extin_dialog", NO_PARENT );
319 UxPutContext( extin_dialog, UxExtin_dialogContext );
320
321 form16 = UxCreateForm( "form16", extin_dialog );
322 form17 = UxCreateForm( "form17", form16 );
323 pushButton34 = UxCreatePushButton( "pushButton34", form17 );
324 pushButton35 = UxCreatePushButton( "pushButton35", form17 );
325 lb_output_extin = UxCreateLabel( "lb_output_extin", form16 );
326 tf_output_extin = UxCreateTextField( "tf_output_extin", form16 );
327 lb_airmass = UxCreateLabel( "lb_airmass", form16 );
328 tf_airmass = UxCreateTextField( "tf_airmass", form16 );
329
330 _Uxinit_extin_dialog();
331
332 /* Create the X widgets */
333
334 UxCreateWidget( extin_dialog );
335 UxCreateWidget( form16 );
336 UxCreateWidget( form17 );
337 UxCreateWidget( pushButton34 );
338 UxCreateWidget( pushButton35 );
339 UxCreateWidget( lb_output_extin );
340 UxCreateWidget( tf_output_extin );
341 UxCreateWidget( lb_airmass );
342 UxCreateWidget( tf_airmass );
343
344 UxAddCallback( pushButton34, XmNactivateCallback,
345 activateCB_pushButton34,
346 (XtPointer) UxExtin_dialogContext );
347
348 UxAddCallback( pushButton35, XmNactivateCallback,
349 activateCB_pushButton35,
350 (XtPointer) UxExtin_dialogContext );
351
352 UxAddCallback( tf_output_extin, XmNactivateCallback,
353 activateCB_tf_output_extin,
354 (XtPointer) UxExtin_dialogContext );
355 UxAddCallback( tf_output_extin, XmNlosingFocusCallback,
356 losingFocusCB_tf_output_extin,
357 (XtPointer) UxExtin_dialogContext );
358
359 UxAddCallback( tf_airmass, XmNactivateCallback,
360 activateCB_tf_airmass,
361 (XtPointer) UxExtin_dialogContext );
362 UxAddCallback( tf_airmass, XmNlosingFocusCallback,
363 losingFocusCB_tf_airmass,
364 (XtPointer) UxExtin_dialogContext );
365
366
367 /* Finally, call UxRealizeInterface to create the X windows
368 for the widgets created above. */
369
370 UxRealizeInterface( extin_dialog );
371
372 return ( extin_dialog );
373 }
374
375 /*******************************************************************************
376 The following function includes the code that was entered
377 in the 'Initial Code' and 'Final Code' sections of the
378 Declarations Editor. This function is called from the
379 'Interface function' below.
380 *******************************************************************************/
381
382 static swidget _Ux_create_extin_dialog()
383 {
384 swidget rtrn;
385 _UxCextin_dialog *UxContext;
386
387 UxExtin_dialogContext = UxContext =
388 (_UxCextin_dialog *) UxMalloc( sizeof(_UxCextin_dialog) );
389
390 rtrn = _Uxbuild_extin_dialog();
391
392 return(rtrn);
393 }
394
395 /*******************************************************************************
396 The following is the 'Interface function' which is the
397 external entry point for creating this interface.
398 This function should be called from your application or from
399 a callback function.
400 *******************************************************************************/
401
402 swidget create_extin_dialog()
403 {
404 swidget _Uxrtrn;
405
406 _Uxrtrn = _Ux_create_extin_dialog();
407
408 return ( _Uxrtrn );
409 }
410
411 /*******************************************************************************
412 END OF FILE
413 *******************************************************************************/
414