1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
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.
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.
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,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
29
/*******************************************************************************
35
*******************************************************************************/
46
/*******************************************************************************
47
Includes, Defines, and Global variables from the Declarations Editor:
48
*******************************************************************************/
50
#include <ExternResources.h>
54
extern struct s_gui G;
56
/*******************************************************************************
57
The definition of the context structure:
58
If you create multiple instances of your interface, the context
59
structure ensures that your callbacks use the variables for the
62
For each swidget in the interface, each argument to the Interface
63
function, and each variable in the Instance Specific section of the
64
Declarations Editor, there is an entry in the context structure.
65
and a #define. The #define makes the variable name refer to the
66
corresponding entry in the context structure.
67
*******************************************************************************/
75
swidget UxseparatorAsk;
80
#define formAsk UxAskShellContext->UxformAsk
81
#define formAsk2 UxAskShellContext->UxformAsk2
82
#define OkAsk UxAskShellContext->UxOkAsk
83
#define CancelAsk UxAskShellContext->UxCancelAsk
84
#define separatorAsk UxAskShellContext->UxseparatorAsk
85
#define labelAsk UxAskShellContext->UxlabelAsk
86
#define textAsk UxAskShellContext->UxtextAsk
88
static _UxCAskShell *UxAskShellContext;
90
extern void s_esoccd(), s_esofilter(), create_bbody();
91
extern void create_flux(), create_csp(), save_filt();
92
extern void save_curve(), save_mod(), SetFileList();
99
/*******************************************************************************
100
The following are translation tables.
101
*******************************************************************************/
103
static char *chooseTL = "#override\n\
104
<Btn3Down>:ChooseListUpL()\n\
105
<Key>Delete:delete-previous-character()\n\
106
<Key>BackSpace:delete-previous-character()\n\
107
<Key>osfDelete:delete-previous-character()\n\
108
<Key>osfBackSpace:delete-previous-character()\n";
110
/*******************************************************************************
111
Forward declarations of functions that are defined later in this file.
112
*******************************************************************************/
114
swidget create_AskShell();
116
/*******************************************************************************
117
The following are Action functions.
118
*******************************************************************************/
120
static void action_ChooseListUpL( UxWidget, UxEvent, UxParams, p_UxNumParams )
124
Cardinal *p_UxNumParams;
126
_UxCAskShell *UxSaveCtx, *UxContext;
127
swidget UxThisWidget;
129
UxThisWidget = UxWidgetToSwidget( UxWidget );
130
UxSaveCtx = UxAskShellContext;
131
UxAskShellContext = UxContext =
132
(_UxCAskShell *) UxGetContext( UxThisWidget );
134
extern swidget scrolledchoose;
135
extern struct s_gui G;
137
strcpy(G.sel_type,"trans_load");
139
SetFileList( UxGetWidget(scrolledchoose),1, "*.trans" );
141
UxPopupInterface(UxFindSwidget("ChooseList"),no_grab);
144
UxAskShellContext = UxSaveCtx;
147
/*******************************************************************************
148
The following are callback functions.
149
*******************************************************************************/
151
static void activateCB_OkAsk( UxWidget, UxClientData, UxCallbackArg )
153
XtPointer UxClientData, UxCallbackArg;
155
_UxCAskShell *UxSaveCtx, *UxContext;
156
swidget UxThisWidget;
158
UxThisWidget = UxWidgetToSwidget( UxWidget );
159
UxSaveCtx = UxAskShellContext;
160
UxAskShellContext = UxContext =
161
(_UxCAskShell *) UxGetContext( UxThisWidget );
164
extern char Printer[];
167
UxPopdownInterface(UxFindSwidget("ChooseList"));
168
UxPopdownInterface(UxFindSwidget("AskShell"));
170
if (sscanf(UxGetText(textAsk),"%s",again)==1)
173
if(!strcmp(G.sel_type,"trans_save"))
175
else if(!strcmp(G.sel_type,"curve_save"))
177
else if(!strcmp(G.sel_type,"extract_curve"))
179
else if(!strcmp(G.sel_type,"filter_save"))
181
else if (!strcmp(G.sel_type,"ised"))
183
else if (!strcmp(G.sel_type,"flux"))
185
else if (!strcmp(G.sel_type,"bbody"))
187
else if (!strcmp(G.sel_type,"printer"))
189
else if (!strcmp(G.sel_type,"esofilter"))
191
else if (!strcmp(G.sel_type,"esoccd"))
194
UxAskShellContext = UxSaveCtx;
197
static void activateCB_CancelAsk( UxWidget, UxClientData, UxCallbackArg )
199
XtPointer UxClientData, UxCallbackArg;
201
_UxCAskShell *UxSaveCtx, *UxContext;
202
swidget UxThisWidget;
204
UxThisWidget = UxWidgetToSwidget( UxWidget );
205
UxSaveCtx = UxAskShellContext;
206
UxAskShellContext = UxContext =
207
(_UxCAskShell *) UxGetContext( UxThisWidget );
209
UxPopdownInterface(AskShell);
211
UxAskShellContext = UxSaveCtx;
214
static void modifyVerifyCB_textAsk( UxWidget, UxClientData, UxCallbackArg )
216
XtPointer UxClientData, UxCallbackArg;
218
_UxCAskShell *UxSaveCtx, *UxContext;
219
swidget UxThisWidget;
221
UxThisWidget = UxWidgetToSwidget( UxWidget );
222
UxSaveCtx = UxAskShellContext;
223
UxAskShellContext = UxContext =
224
(_UxCAskShell *) UxGetContext( UxThisWidget );
228
UxAskShellContext = UxSaveCtx;
231
static void losingFocusCB_textAsk( UxWidget, UxClientData, UxCallbackArg )
233
XtPointer UxClientData, UxCallbackArg;
235
_UxCAskShell *UxSaveCtx, *UxContext;
236
swidget UxThisWidget;
238
UxThisWidget = UxWidgetToSwidget( UxWidget );
239
UxSaveCtx = UxAskShellContext;
240
UxAskShellContext = UxContext =
241
(_UxCAskShell *) UxGetContext( UxThisWidget );
247
sscanf(UxGetText(textAsk),"%s",Ask);
251
UxAskShellContext = UxSaveCtx;
254
/*******************************************************************************
255
The 'init_' function sets the private properties for all the
256
swidgets to the values specified in the Property Table.
257
Some properties need to be set after the X widgets have been
258
created and the setting of these properties is done in the
259
'build_' function after the UxCreateWidget call.
260
*******************************************************************************/
262
static void _Uxinit_AskShell()
264
UxPutBackground( AskShell, "grey80" );
265
UxPutBorderColor( AskShell, WindowBackground );
266
UxPutIconName( AskShell, "AskShell" );
267
UxPutKeyboardFocusPolicy( AskShell, "pointer" );
268
UxPutTitle( AskShell, "Ask" );
269
UxPutHeight( AskShell, 105 );
270
UxPutWidth( AskShell, 400 );
271
UxPutY( AskShell, 500 );
272
UxPutX( AskShell, 600 );
274
UxPutBorderColor( formAsk, WindowBackground );
275
UxPutBackground( formAsk, WindowBackground );
276
UxPutHeight( formAsk, 100 );
277
UxPutWidth( formAsk, 490 );
278
UxPutY( formAsk, 0 );
279
UxPutX( formAsk, 0 );
280
UxPutUnitType( formAsk, "pixels" );
281
UxPutResizePolicy( formAsk, "resize_none" );
283
UxPutBorderColor( formAsk2, ButtonBackground );
284
UxPutBackground( formAsk2, ButtonBackground );
285
UxPutHeight( formAsk2, 40 );
286
UxPutWidth( formAsk2, 490 );
287
UxPutY( formAsk2, 120 );
288
UxPutX( formAsk2, 0 );
289
UxPutResizePolicy( formAsk2, "resize_none" );
291
UxPutLabelString( OkAsk, "Ok" );
292
UxPutForeground( OkAsk, ApplyForeground );
293
UxPutFontList( OkAsk, BoldTextFont );
294
UxPutBorderColor( OkAsk, ButtonBackground );
295
UxPutBackground( OkAsk, ButtonBackground );
296
UxPutHeight( OkAsk, 30 );
297
UxPutWidth( OkAsk, 80 );
301
UxPutLabelString( CancelAsk, "Cancel" );
302
UxPutForeground( CancelAsk, CancelForeground );
303
UxPutFontList( CancelAsk, BoldTextFont );
304
UxPutBorderColor( CancelAsk, ButtonBackground );
305
UxPutBackground( CancelAsk, ButtonBackground );
306
UxPutHeight( CancelAsk, 30 );
307
UxPutWidth( CancelAsk, 80 );
308
UxPutY( CancelAsk, 4 );
309
UxPutX( CancelAsk, 120 );
311
UxPutBorderColor( separatorAsk, WindowBackground );
312
UxPutBackground( separatorAsk, WindowBackground );
313
UxPutHeight( separatorAsk, 10 );
314
UxPutWidth( separatorAsk, 492 );
315
UxPutY( separatorAsk, 110 );
316
UxPutX( separatorAsk, 0 );
318
UxPutForeground( labelAsk, TextForeground );
319
UxPutAlignment( labelAsk, "alignment_beginning" );
320
UxPutLabelString( labelAsk, "Ask :" );
321
UxPutFontList( labelAsk, TextFont );
322
UxPutBorderColor( labelAsk, LabelBackground );
323
UxPutBackground( labelAsk, LabelBackground );
324
UxPutHeight( labelAsk, 30 );
325
UxPutWidth( labelAsk, 125 );
326
UxPutY( labelAsk, 12 );
327
UxPutX( labelAsk, 10 );
329
UxPutTranslations( textAsk, chooseTL );
330
UxPutSelectionArrayCount( textAsk, 3 );
331
UxPutMaxLength( textAsk, 200 );
332
UxPutForeground( textAsk, TextForeground );
333
UxPutFontList( textAsk, TextFont );
334
UxPutBorderColor( textAsk, TextBackground );
335
UxPutBackground( textAsk, TextBackground );
336
UxPutHeight( textAsk, 35 );
337
UxPutWidth( textAsk, 220 );
338
UxPutY( textAsk, 10 );
339
UxPutX( textAsk, 260 );
343
/*******************************************************************************
344
The 'build_' function creates all the swidgets and X widgets,
345
and sets their properties to the values specified in the
347
*******************************************************************************/
349
static swidget _Uxbuild_AskShell()
351
/* Create the swidgets */
353
AskShell = UxCreateApplicationShell( "AskShell", NO_PARENT );
354
UxPutContext( AskShell, UxAskShellContext );
356
formAsk = UxCreateForm( "formAsk", AskShell );
357
formAsk2 = UxCreateForm( "formAsk2", formAsk );
358
OkAsk = UxCreatePushButton( "OkAsk", formAsk2 );
359
CancelAsk = UxCreatePushButton( "CancelAsk", formAsk2 );
360
separatorAsk = UxCreateSeparator( "separatorAsk", formAsk );
361
labelAsk = UxCreateLabel( "labelAsk", formAsk );
362
textAsk = UxCreateText( "textAsk", formAsk );
366
/* Create the X widgets */
368
UxCreateWidget( AskShell );
369
UxCreateWidget( formAsk );
370
UxPutRightAttachment( formAsk2, "attach_form" );
371
UxPutLeftAttachment( formAsk2, "attach_form" );
372
UxPutTopOffset( formAsk2, 60 );
373
UxPutTopAttachment( formAsk2, "attach_form" );
374
UxCreateWidget( formAsk2 );
376
UxPutLeftOffset( OkAsk, 20 );
377
UxPutLeftAttachment( OkAsk, "attach_form" );
378
UxCreateWidget( OkAsk );
380
UxPutLeftOffset( CancelAsk, 120 );
381
UxPutLeftAttachment( CancelAsk, "attach_form" );
382
UxPutRightOffset( CancelAsk, 55 );
383
UxPutRightAttachment( CancelAsk, "attach_none" );
384
UxCreateWidget( CancelAsk );
386
UxPutTopOffset( separatorAsk, 50 );
387
UxPutTopAttachment( separatorAsk, "attach_form" );
388
UxPutRightAttachment( separatorAsk, "attach_form" );
389
UxPutLeftAttachment( separatorAsk, "attach_form" );
390
UxCreateWidget( separatorAsk );
392
UxPutTopOffset( labelAsk, 12 );
393
UxPutTopAttachment( labelAsk, "attach_form" );
394
UxPutLeftOffset( labelAsk, 10 );
395
UxPutLeftAttachment( labelAsk, "attach_form" );
396
UxCreateWidget( labelAsk );
398
UxPutTopOffset( textAsk, 10 );
399
UxPutTopAttachment( textAsk, "attach_form" );
400
UxPutRightOffset( textAsk, 10 );
401
UxPutRightAttachment( textAsk, "attach_form" );
402
UxPutLeftOffset( textAsk, 260 );
403
UxCreateWidget( textAsk );
406
UxAddCallback( OkAsk, XmNactivateCallback,
408
(XtPointer) UxAskShellContext );
410
UxAddCallback( CancelAsk, XmNactivateCallback,
411
activateCB_CancelAsk,
412
(XtPointer) UxAskShellContext );
414
UxAddCallback( textAsk, XmNmodifyVerifyCallback,
415
modifyVerifyCB_textAsk,
416
(XtPointer) UxAskShellContext );
417
UxAddCallback( textAsk, XmNlosingFocusCallback,
418
losingFocusCB_textAsk,
419
(XtPointer) UxAskShellContext );
422
/* Finally, call UxRealizeInterface to create the X windows
423
for the widgets created above. */
425
UxRealizeInterface( AskShell );
430
/*******************************************************************************
431
The following function includes the code that was entered
432
in the 'Initial Code' and 'Final Code' sections of the
433
Declarations Editor. This function is called from the
434
'Interface function' below.
435
*******************************************************************************/
437
static swidget _Ux_create_AskShell()
440
_UxCAskShell *UxContext;
442
UxAskShellContext = UxContext =
443
(_UxCAskShell *) UxMalloc( sizeof(_UxCAskShell) );
445
rtrn = _Uxbuild_AskShell();
450
/*******************************************************************************
451
The following is the 'Interface function' which is the
452
external entry point for creating this interface.
453
This function should be called from your application or from
455
*******************************************************************************/
457
swidget create_AskShell()
460
static int _Uxinit = 0;
464
static XtActionsRec _Uxactions[] = {
465
{ "ChooseListUpL", action_ChooseListUpL }
468
XtAppAddActions( UxAppContext,
470
XtNumber(_Uxactions) );
475
_Uxrtrn = _Ux_create_AskShell();
480
/*******************************************************************************
482
*******************************************************************************/