~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to gui/XFilter/src/AskShell.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: midas@eso.org
 
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
        AskShell.c
 
31
 
 
32
.VERSION
 
33
 090826         last modif
 
34
 
 
35
*******************************************************************************/
 
36
 
 
37
#include <stdio.h>
 
38
#include "UxLib.h"
 
39
#include "UxText.h"
 
40
#include "UxLabel.h"
 
41
#include "UxSep.h"
 
42
#include "UxPushB.h"
 
43
#include "UxForm.h"
 
44
#include "UxApplSh.h"
 
45
 
 
46
/*******************************************************************************
 
47
        Includes, Defines, and Global variables from the Declarations Editor:
 
48
*******************************************************************************/
 
49
 
 
50
#include <ExternResources.h> 
 
51
#include <global.h>
 
52
#include <model.h>
 
53
 
 
54
extern struct s_gui G;
 
55
 
 
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
 
60
        correct instance.
 
61
 
 
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
*******************************************************************************/
 
68
 
 
69
typedef struct
 
70
{
 
71
        swidget UxformAsk;
 
72
        swidget UxformAsk2;
 
73
        swidget UxOkAsk;
 
74
        swidget UxCancelAsk;
 
75
        swidget UxseparatorAsk;
 
76
        swidget UxlabelAsk;
 
77
        swidget UxtextAsk;
 
78
} _UxCAskShell;
 
79
 
 
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
 
87
 
 
88
static _UxCAskShell     *UxAskShellContext;
 
89
 
 
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();
 
93
 
 
94
 
 
95
 
 
96
 
 
97
swidget AskShell;
 
98
 
 
99
/*******************************************************************************
 
100
        The following are translation tables.
 
101
*******************************************************************************/
 
102
 
 
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";
 
109
 
 
110
/*******************************************************************************
 
111
        Forward declarations of functions that are defined later in this file.
 
112
*******************************************************************************/
 
113
 
 
114
swidget create_AskShell();
 
115
 
 
116
/*******************************************************************************
 
117
        The following are Action functions.
 
118
*******************************************************************************/
 
119
 
 
120
static void     action_ChooseListUpL( UxWidget, UxEvent, UxParams, p_UxNumParams )
 
121
        Widget          UxWidget;
 
122
        XEvent          *UxEvent;
 
123
        String          *UxParams;
 
124
        Cardinal        *p_UxNumParams;
 
125
{
 
126
        _UxCAskShell            *UxSaveCtx, *UxContext;
 
127
        swidget                 UxThisWidget;
 
128
 
 
129
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
130
        UxSaveCtx = UxAskShellContext;
 
131
        UxAskShellContext = UxContext =
 
132
                        (_UxCAskShell *) UxGetContext( UxThisWidget );
 
133
        {
 
134
        extern swidget scrolledchoose;
 
135
        extern struct s_gui    G;
 
136
        
 
137
        strcpy(G.sel_type,"trans_load");
 
138
        
 
139
        SetFileList( UxGetWidget(scrolledchoose),1, "*.trans" );
 
140
        
 
141
        UxPopupInterface(UxFindSwidget("ChooseList"),no_grab);
 
142
        
 
143
        }
 
144
        UxAskShellContext = UxSaveCtx;
 
145
}
 
146
 
 
147
/*******************************************************************************
 
148
        The following are callback functions.
 
149
*******************************************************************************/
 
150
 
 
151
static void     activateCB_OkAsk( UxWidget, UxClientData, UxCallbackArg )
 
152
        Widget          UxWidget;
 
153
        XtPointer       UxClientData, UxCallbackArg;
 
154
{
 
155
        _UxCAskShell            *UxSaveCtx, *UxContext;
 
156
        swidget                 UxThisWidget;
 
157
 
 
158
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
159
        UxSaveCtx = UxAskShellContext;
 
160
        UxAskShellContext = UxContext =
 
161
                        (_UxCAskShell *) UxGetContext( UxThisWidget );
 
162
        {
 
163
        extern  char    Ask[];
 
164
        extern  char    Printer[];
 
165
        char    again[50];
 
166
        
 
167
        UxPopdownInterface(UxFindSwidget("ChooseList"));
 
168
        UxPopdownInterface(UxFindSwidget("AskShell"));
 
169
        
 
170
        if (sscanf(UxGetText(textAsk),"%s",again)==1)
 
171
                strcpy(Ask,again);
 
172
        
 
173
        if(!strcmp(G.sel_type,"trans_save"))
 
174
                save_mod(Ask);
 
175
        else if(!strcmp(G.sel_type,"curve_save"))
 
176
                save_curve(Ask);
 
177
        else if(!strcmp(G.sel_type,"extract_curve"))
 
178
                save_curve(Ask);
 
179
        else if(!strcmp(G.sel_type,"filter_save"))
 
180
                save_filt(Ask);
 
181
        else if (!strcmp(G.sel_type,"ised"))
 
182
                 create_csp(Ask);
 
183
        else if (!strcmp(G.sel_type,"flux"))
 
184
                 create_flux(Ask);
 
185
        else if (!strcmp(G.sel_type,"bbody"))
 
186
                 create_bbody(Ask);
 
187
        else if (!strcmp(G.sel_type,"printer"))
 
188
                 strcpy(Printer,Ask);
 
189
        else if (!strcmp(G.sel_type,"esofilter"))
 
190
                 s_esofilter(Ask);
 
191
        else if (!strcmp(G.sel_type,"esoccd"))
 
192
                 s_esoccd(Ask);
 
193
        }
 
194
        UxAskShellContext = UxSaveCtx;
 
195
}
 
196
 
 
197
static void     activateCB_CancelAsk( UxWidget, UxClientData, UxCallbackArg )
 
198
        Widget          UxWidget;
 
199
        XtPointer       UxClientData, UxCallbackArg;
 
200
{
 
201
        _UxCAskShell            *UxSaveCtx, *UxContext;
 
202
        swidget                 UxThisWidget;
 
203
 
 
204
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
205
        UxSaveCtx = UxAskShellContext;
 
206
        UxAskShellContext = UxContext =
 
207
                        (_UxCAskShell *) UxGetContext( UxThisWidget );
 
208
        {
 
209
        UxPopdownInterface(AskShell);
 
210
        }
 
211
        UxAskShellContext = UxSaveCtx;
 
212
}
 
213
 
 
214
static void     modifyVerifyCB_textAsk( UxWidget, UxClientData, UxCallbackArg )
 
215
        Widget          UxWidget;
 
216
        XtPointer       UxClientData, UxCallbackArg;
 
217
{
 
218
        _UxCAskShell            *UxSaveCtx, *UxContext;
 
219
        swidget                 UxThisWidget;
 
220
 
 
221
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
222
        UxSaveCtx = UxAskShellContext;
 
223
        UxAskShellContext = UxContext =
 
224
                        (_UxCAskShell *) UxGetContext( UxThisWidget );
 
225
        {
 
226
        MOD_Ask = TRUE;
 
227
        }
 
228
        UxAskShellContext = UxSaveCtx;
 
229
}
 
230
 
 
231
static void     losingFocusCB_textAsk( UxWidget, UxClientData, UxCallbackArg )
 
232
        Widget          UxWidget;
 
233
        XtPointer       UxClientData, UxCallbackArg;
 
234
{
 
235
        _UxCAskShell            *UxSaveCtx, *UxContext;
 
236
        swidget                 UxThisWidget;
 
237
 
 
238
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
239
        UxSaveCtx = UxAskShellContext;
 
240
        UxAskShellContext = UxContext =
 
241
                        (_UxCAskShell *) UxGetContext( UxThisWidget );
 
242
        {
 
243
        extern char Ask[];
 
244
        
 
245
        if(MOD_Ask)
 
246
        { 
 
247
          sscanf(UxGetText(textAsk),"%s",Ask);
 
248
        }
 
249
        MOD_Ask=FALSE;
 
250
        }
 
251
        UxAskShellContext = UxSaveCtx;
 
252
}
 
253
 
 
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
*******************************************************************************/
 
261
 
 
262
static void     _Uxinit_AskShell()
 
263
{
 
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 );
 
273
 
 
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" );
 
282
 
 
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" );
 
290
 
 
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 );
 
298
        UxPutY( OkAsk, 4 );
 
299
        UxPutX( OkAsk, 98 );
 
300
 
 
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 );
 
310
 
 
311
        UxPutBorderColor( separatorAsk, WindowBackground );
 
312
        UxPutBackground( separatorAsk, WindowBackground );
 
313
        UxPutHeight( separatorAsk, 10 );
 
314
        UxPutWidth( separatorAsk, 492 );
 
315
        UxPutY( separatorAsk, 110 );
 
316
        UxPutX( separatorAsk, 0 );
 
317
 
 
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 );
 
328
 
 
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 );
 
340
 
 
341
}
 
342
 
 
343
/*******************************************************************************
 
344
        The 'build_' function creates all the swidgets and X widgets,
 
345
        and sets their properties to the values specified in the
 
346
        Property Editor.
 
347
*******************************************************************************/
 
348
 
 
349
static swidget  _Uxbuild_AskShell()
 
350
{
 
351
        /* Create the swidgets */
 
352
 
 
353
        AskShell = UxCreateApplicationShell( "AskShell", NO_PARENT );
 
354
        UxPutContext( AskShell, UxAskShellContext );
 
355
 
 
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 );
 
363
 
 
364
        _Uxinit_AskShell();
 
365
 
 
366
        /* Create the X widgets */
 
367
 
 
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 );
 
375
 
 
376
        UxPutLeftOffset( OkAsk, 20 );
 
377
        UxPutLeftAttachment( OkAsk, "attach_form" );
 
378
        UxCreateWidget( OkAsk );
 
379
 
 
380
        UxPutLeftOffset( CancelAsk, 120 );
 
381
        UxPutLeftAttachment( CancelAsk, "attach_form" );
 
382
        UxPutRightOffset( CancelAsk, 55 );
 
383
        UxPutRightAttachment( CancelAsk, "attach_none" );
 
384
        UxCreateWidget( CancelAsk );
 
385
 
 
386
        UxPutTopOffset( separatorAsk, 50 );
 
387
        UxPutTopAttachment( separatorAsk, "attach_form" );
 
388
        UxPutRightAttachment( separatorAsk, "attach_form" );
 
389
        UxPutLeftAttachment( separatorAsk, "attach_form" );
 
390
        UxCreateWidget( separatorAsk );
 
391
 
 
392
        UxPutTopOffset( labelAsk, 12 );
 
393
        UxPutTopAttachment( labelAsk, "attach_form" );
 
394
        UxPutLeftOffset( labelAsk, 10 );
 
395
        UxPutLeftAttachment( labelAsk, "attach_form" );
 
396
        UxCreateWidget( labelAsk );
 
397
 
 
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 );
 
404
 
 
405
 
 
406
        UxAddCallback( OkAsk, XmNactivateCallback,
 
407
                        activateCB_OkAsk,
 
408
                        (XtPointer) UxAskShellContext );
 
409
 
 
410
        UxAddCallback( CancelAsk, XmNactivateCallback,
 
411
                        activateCB_CancelAsk,
 
412
                        (XtPointer) UxAskShellContext );
 
413
 
 
414
        UxAddCallback( textAsk, XmNmodifyVerifyCallback,
 
415
                        modifyVerifyCB_textAsk,
 
416
                        (XtPointer) UxAskShellContext );
 
417
        UxAddCallback( textAsk, XmNlosingFocusCallback,
 
418
                        losingFocusCB_textAsk,
 
419
                        (XtPointer) UxAskShellContext );
 
420
 
 
421
 
 
422
        /* Finally, call UxRealizeInterface to create the X windows
 
423
           for the widgets created above. */
 
424
 
 
425
        UxRealizeInterface( AskShell );
 
426
 
 
427
        return ( AskShell );
 
428
}
 
429
 
 
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
*******************************************************************************/
 
436
 
 
437
static swidget  _Ux_create_AskShell()
 
438
{
 
439
        swidget                 rtrn;
 
440
        _UxCAskShell            *UxContext;
 
441
 
 
442
        UxAskShellContext = UxContext =
 
443
                (_UxCAskShell *) UxMalloc( sizeof(_UxCAskShell) );
 
444
 
 
445
        rtrn = _Uxbuild_AskShell();
 
446
 
 
447
        return(rtrn);
 
448
}
 
449
 
 
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
 
454
        a callback function.
 
455
*******************************************************************************/
 
456
 
 
457
swidget create_AskShell()
 
458
{
 
459
        swidget                 _Uxrtrn;
 
460
        static int              _Uxinit = 0;
 
461
 
 
462
        if ( ! _Uxinit )
 
463
        {
 
464
                static XtActionsRec     _Uxactions[] = {
 
465
                                { "ChooseListUpL", action_ChooseListUpL }
 
466
                                };
 
467
 
 
468
                XtAppAddActions( UxAppContext,
 
469
                                _Uxactions,
 
470
                                XtNumber(_Uxactions) );
 
471
 
 
472
                _Uxinit = 1;
 
473
        }
 
474
 
 
475
        _Uxrtrn = _Ux_create_AskShell();
 
476
 
 
477
        return ( _Uxrtrn );
 
478
}
 
479
 
 
480
/*******************************************************************************
 
481
        END OF FILE
 
482
*******************************************************************************/
 
483