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

« back to all changes in this revision

Viewing changes to gui/XAlice/src/SaveAsShell.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 Massachusetts Ave, Cambridge, 
 
17
  MA 02139, USA.
 
18
 
 
19
  Correspondence 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
.VERSION
 
28
 090825         last modif
 
29
 
 
30
===========================================================================*/
 
31
 
 
32
 
 
33
/*******************************************************************************
 
34
        SaveAsShell.c
 
35
 
 
36
*******************************************************************************/
 
37
 
 
38
#include <stdio.h>
 
39
#include "UxLib.h"
 
40
#include "UxSep.h"
 
41
#include "UxPushB.h"
 
42
#include "UxText.h"
 
43
#include "UxLabel.h"
 
44
#include "UxForm.h"
 
45
#include "UxTopSh.h"
 
46
 
 
47
/*******************************************************************************
 
48
        Includes, Defines, and Global variables from the Declarations Editor:
 
49
*******************************************************************************/
 
50
 
 
51
#include <ExternResources.h>
 
52
#include <alice_global.h>
 
53
#include <alice_help.h>
 
54
 
 
55
/*******************************************************************************
 
56
        The definition of the context structure:
 
57
        If you create multiple instances of your interface, the context
 
58
        structure ensures that your callbacks use the variables for the
 
59
        correct instance.
 
60
 
 
61
        For each swidget in the interface, each argument to the Interface
 
62
        function, and each variable in the Instance Specific section of the
 
63
        Declarations Editor, there is an entry in the context structure.
 
64
        and a #define.  The #define makes the variable name refer to the
 
65
        corresponding entry in the context structure.
 
66
*******************************************************************************/
 
67
 
 
68
typedef struct
 
69
{
 
70
        swidget UxSaveAsShell;
 
71
        swidget UxSaveAsTopForm;
 
72
        swidget UxTextLabel;
 
73
        swidget UxSaveAsText;
 
74
        swidget UxSaveAsForm2;
 
75
        swidget UxSaveAsSeparator;
 
76
} _UxCSaveAsShell;
 
77
 
 
78
#define SaveAsShell             UxSaveAsShellContext->UxSaveAsShell
 
79
#define SaveAsTopForm           UxSaveAsShellContext->UxSaveAsTopForm
 
80
#define TextLabel               UxSaveAsShellContext->UxTextLabel
 
81
#define SaveAsText              UxSaveAsShellContext->UxSaveAsText
 
82
#define SaveAsForm2             UxSaveAsShellContext->UxSaveAsForm2
 
83
#define SaveAsSeparator         UxSaveAsShellContext->UxSaveAsSeparator
 
84
 
 
85
static _UxCSaveAsShell  *UxSaveAsShellContext;
 
86
 
 
87
extern void save_file();
 
88
 
 
89
 
 
90
 
 
91
swidget OkSaveAs;
 
92
swidget CancelSaveAs;
 
93
 
 
94
/*******************************************************************************
 
95
        The following are translation tables.
 
96
*******************************************************************************/
 
97
 
 
98
static char     *SaveTextTab = "#override\n\
 
99
<Key>Delete:delete-previous-character()\n\
 
100
<Key>BackSpace:delete-previous-character()\n\
 
101
<Key>osfBackSpace:delete-previous-character()\n\
 
102
<Key>osfDelete:delete-previous-character()\n";
 
103
 
 
104
/*******************************************************************************
 
105
        Forward declarations of functions that are defined later in this file.
 
106
*******************************************************************************/
 
107
 
 
108
swidget create_SaveAsShell();
 
109
 
 
110
/*******************************************************************************
 
111
        The following are callback functions.
 
112
*******************************************************************************/
 
113
 
 
114
static void     createCB_SaveAsText( UxWidget, UxClientData, UxCallbackArg )
 
115
        Widget          UxWidget;
 
116
        XtPointer       UxClientData, UxCallbackArg;
 
117
{
 
118
        _UxCSaveAsShell         *UxSaveCtx, *UxContext;
 
119
        swidget                 UxThisWidget;
 
120
 
 
121
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
122
        UxSaveCtx = UxSaveAsShellContext;
 
123
        UxSaveAsShellContext = UxContext =
 
124
                        (_UxCSaveAsShell *) UxGetContext( UxThisWidget );
 
125
        {
 
126
        UxPutText(UxFindSwidget("SaveAsText"),"noname.bdf" );
 
127
        }
 
128
        UxSaveAsShellContext = UxSaveCtx;
 
129
}
 
130
 
 
131
static void     activateCB_OkSaveAs( UxWidget, UxClientData, UxCallbackArg )
 
132
        Widget          UxWidget;
 
133
        XtPointer       UxClientData, UxCallbackArg;
 
134
{
 
135
        _UxCSaveAsShell         *UxSaveCtx, *UxContext;
 
136
        swidget                 UxThisWidget;
 
137
 
 
138
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
139
        UxSaveCtx = UxSaveAsShellContext;
 
140
        UxSaveAsShellContext = UxContext =
 
141
                        (_UxCSaveAsShell *) UxGetContext( UxThisWidget );
 
142
        {
 
143
        strcpy(specSaveName,UxGetText(UxFindSwidget("SaveAsText")));
 
144
        save_file(specSaveName);
 
145
        UxPopdownInterface(UxFindSwidget("SaveAsShell"));
 
146
        
 
147
        }
 
148
        UxSaveAsShellContext = UxSaveCtx;
 
149
}
 
150
 
 
151
static void     activateCB_CancelSaveAs( UxWidget, UxClientData, UxCallbackArg )
 
152
        Widget          UxWidget;
 
153
        XtPointer       UxClientData, UxCallbackArg;
 
154
{
 
155
        _UxCSaveAsShell         *UxSaveCtx, *UxContext;
 
156
        swidget                 UxThisWidget;
 
157
 
 
158
        UxThisWidget = UxWidgetToSwidget( UxWidget );
 
159
        UxSaveCtx = UxSaveAsShellContext;
 
160
        UxSaveAsShellContext = UxContext =
 
161
                        (_UxCSaveAsShell *) UxGetContext( UxThisWidget );
 
162
        {
 
163
        UxPopdownInterface(UxFindSwidget("SaveAsShell"));
 
164
        }
 
165
        UxSaveAsShellContext = UxSaveCtx;
 
166
}
 
167
 
 
168
/*******************************************************************************
 
169
        The 'init_' function sets the private properties for all the
 
170
        swidgets to the values specified in the Property Table.
 
171
        Some properties need to be set after the X widgets have been
 
172
        created and the setting of these properties is done in the
 
173
        'build_' function after the UxCreateWidget call.
 
174
*******************************************************************************/
 
175
 
 
176
static void     _Uxinit_SaveAsShell()
 
177
{
 
178
        UxPutKeyboardFocusPolicy( SaveAsShell, "pointer" );
 
179
        UxPutIconName( SaveAsShell, "Save As" );
 
180
        UxPutHeight( SaveAsShell, 133 );
 
181
        UxPutWidth( SaveAsShell, 296 );
 
182
        UxPutY( SaveAsShell, 426 );
 
183
        UxPutX( SaveAsShell, 456 );
 
184
 
 
185
        UxPutBackground( SaveAsTopForm, WindowBackground );
 
186
        UxPutHeight( SaveAsTopForm, 110 );
 
187
        UxPutWidth( SaveAsTopForm, 142 );
 
188
        UxPutY( SaveAsTopForm, 62 );
 
189
        UxPutX( SaveAsTopForm, 76 );
 
190
        UxPutUnitType( SaveAsTopForm, "pixels" );
 
191
        UxPutResizePolicy( SaveAsTopForm, "resize_none" );
 
192
 
 
193
        UxPutHighlightColor( TextLabel, "Black" );
 
194
        UxPutForeground( TextLabel, TextForeground );
 
195
        UxPutLabelString( TextLabel, "Output file:" );
 
196
        UxPutFontList( TextLabel, TextFont );
 
197
        UxPutBackground( TextLabel, LabelBackground );
 
198
        UxPutHeight( TextLabel, 34 );
 
199
        UxPutWidth( TextLabel, 110 );
 
200
        UxPutY( TextLabel, 18 );
 
201
        UxPutX( TextLabel, 10 );
 
202
 
 
203
        UxPutHighlightColor( SaveAsText, "Black" );
 
204
        UxPutForeground( SaveAsText, TextForeground );
 
205
        UxPutTranslations( SaveAsText, SaveTextTab );
 
206
        UxPutFontList( SaveAsText, TextFont );
 
207
        UxPutBackground( SaveAsText, TextBackground );
 
208
        UxPutHeight( SaveAsText, 38 );
 
209
        UxPutWidth( SaveAsText, 152 );
 
210
        UxPutY( SaveAsText, 16 );
 
211
        UxPutX( SaveAsText, 126 );
 
212
 
 
213
        UxPutBackground( SaveAsForm2, ButtonBackground );
 
214
        UxPutHeight( SaveAsForm2, 52 );
 
215
        UxPutWidth( SaveAsForm2, 296 );
 
216
        UxPutY( SaveAsForm2, 80 );
 
217
        UxPutX( SaveAsForm2, 0 );
 
218
        UxPutResizePolicy( SaveAsForm2, "resize_none" );
 
219
 
 
220
        UxPutHighlightColor( OkSaveAs, "#000000" );
 
221
        UxPutHighlightOnEnter( OkSaveAs, "true" );
 
222
        UxPutLabelString( OkSaveAs, "Ok" );
 
223
        UxPutForeground( OkSaveAs, ButtonForeground );
 
224
        UxPutFontList( OkSaveAs, BoldTextFont );
 
225
        UxPutBackground( OkSaveAs, ButtonBackground );
 
226
        UxPutHeight( OkSaveAs, 30 );
 
227
        UxPutWidth( OkSaveAs, 90 );
 
228
        UxPutY( OkSaveAs, 10 );
 
229
        UxPutX( OkSaveAs, 20 );
 
230
 
 
231
        UxPutHighlightColor( CancelSaveAs, "#000000" );
 
232
        UxPutHighlightOnEnter( CancelSaveAs, "true" );
 
233
        UxPutLabelString( CancelSaveAs, "Cancel" );
 
234
        UxPutForeground( CancelSaveAs, CancelForeground );
 
235
        UxPutFontList( CancelSaveAs, BoldTextFont );
 
236
        UxPutBackground( CancelSaveAs, ButtonBackground );
 
237
        UxPutHeight( CancelSaveAs, 30 );
 
238
        UxPutWidth( CancelSaveAs, 90 );
 
239
        UxPutY( CancelSaveAs, 10 );
 
240
        UxPutX( CancelSaveAs, 126 );
 
241
 
 
242
        UxPutBackground( SaveAsSeparator, ButtonBackground );
 
243
        UxPutHeight( SaveAsSeparator, 10 );
 
244
        UxPutWidth( SaveAsSeparator, 300 );
 
245
        UxPutY( SaveAsSeparator, 72 );
 
246
        UxPutX( SaveAsSeparator, 0 );
 
247
 
 
248
}
 
249
 
 
250
/*******************************************************************************
 
251
        The 'build_' function creates all the swidgets and X widgets,
 
252
        and sets their properties to the values specified in the
 
253
        Property Editor.
 
254
*******************************************************************************/
 
255
 
 
256
static swidget  _Uxbuild_SaveAsShell()
 
257
{
 
258
        /* Create the swidgets */
 
259
 
 
260
        SaveAsShell = UxCreateTopLevelShell( "SaveAsShell", NO_PARENT );
 
261
        UxPutContext( SaveAsShell, UxSaveAsShellContext );
 
262
 
 
263
        SaveAsTopForm = UxCreateForm( "SaveAsTopForm", SaveAsShell );
 
264
        TextLabel = UxCreateLabel( "TextLabel", SaveAsTopForm );
 
265
        SaveAsText = UxCreateText( "SaveAsText", SaveAsTopForm );
 
266
        SaveAsForm2 = UxCreateForm( "SaveAsForm2", SaveAsTopForm );
 
267
        OkSaveAs = UxCreatePushButton( "OkSaveAs", SaveAsForm2 );
 
268
        CancelSaveAs = UxCreatePushButton( "CancelSaveAs", SaveAsForm2 );
 
269
        SaveAsSeparator = UxCreateSeparator( "SaveAsSeparator", SaveAsTopForm );
 
270
 
 
271
        _Uxinit_SaveAsShell();
 
272
 
 
273
        /* Create the X widgets */
 
274
 
 
275
        UxCreateWidget( SaveAsShell );
 
276
        UxCreateWidget( SaveAsTopForm );
 
277
        UxCreateWidget( TextLabel );
 
278
        UxCreateWidget( SaveAsText );
 
279
        createCB_SaveAsText( UxGetWidget( SaveAsText ),
 
280
                        (XtPointer) UxSaveAsShellContext, (XtPointer) NULL );
 
281
 
 
282
        UxCreateWidget( SaveAsForm2 );
 
283
        UxCreateWidget( OkSaveAs );
 
284
        UxCreateWidget( CancelSaveAs );
 
285
        UxCreateWidget( SaveAsSeparator );
 
286
 
 
287
        UxAddCallback( OkSaveAs, XmNactivateCallback,
 
288
                        activateCB_OkSaveAs,
 
289
                        (XtPointer) UxSaveAsShellContext );
 
290
 
 
291
        UxAddCallback( CancelSaveAs, XmNactivateCallback,
 
292
                        activateCB_CancelSaveAs,
 
293
                        (XtPointer) UxSaveAsShellContext );
 
294
 
 
295
 
 
296
        /* Finally, call UxRealizeInterface to create the X windows
 
297
           for the widgets created above. */
 
298
 
 
299
        UxRealizeInterface( SaveAsShell );
 
300
 
 
301
        return ( SaveAsShell );
 
302
}
 
303
 
 
304
/*******************************************************************************
 
305
        The following function includes the code that was entered
 
306
        in the 'Initial Code' and 'Final Code' sections of the
 
307
        Declarations Editor. This function is called from the
 
308
        'Interface function' below.
 
309
*******************************************************************************/
 
310
 
 
311
static swidget  _Ux_create_SaveAsShell()
 
312
{
 
313
        swidget                 rtrn;
 
314
        _UxCSaveAsShell         *UxContext;
 
315
 
 
316
        UxSaveAsShellContext = UxContext =
 
317
                (_UxCSaveAsShell *) UxMalloc( sizeof(_UxCSaveAsShell) );
 
318
 
 
319
        rtrn = _Uxbuild_SaveAsShell();
 
320
 
 
321
        return(rtrn);
 
322
}
 
323
 
 
324
/*******************************************************************************
 
325
        The following is the 'Interface function' which is the
 
326
        external entry point for creating this interface.
 
327
        This function should be called from your application or from
 
328
        a callback function.
 
329
*******************************************************************************/
 
330
 
 
331
swidget create_SaveAsShell()
 
332
{
 
333
        swidget                 _Uxrtrn;
 
334
 
 
335
        _Uxrtrn = _Ux_create_SaveAsShell();
 
336
 
 
337
        return ( _Uxrtrn );
 
338
}
 
339
 
 
340
/*******************************************************************************
 
341
        END OF FILE
 
342
*******************************************************************************/
 
343