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 Massachusetts Ave, Cambridge,
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
30
===========================================================================*/
33
/*******************************************************************************
36
*******************************************************************************/
47
/*******************************************************************************
48
Includes, Defines, and Global variables from the Declarations Editor:
49
*******************************************************************************/
51
#include <ExternResources.h>
52
#include <alice_global.h>
53
#include <alice_help.h>
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
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
*******************************************************************************/
70
swidget UxSaveAsShell;
71
swidget UxSaveAsTopForm;
74
swidget UxSaveAsForm2;
75
swidget UxSaveAsSeparator;
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
85
static _UxCSaveAsShell *UxSaveAsShellContext;
87
extern void save_file();
94
/*******************************************************************************
95
The following are translation tables.
96
*******************************************************************************/
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";
104
/*******************************************************************************
105
Forward declarations of functions that are defined later in this file.
106
*******************************************************************************/
108
swidget create_SaveAsShell();
110
/*******************************************************************************
111
The following are callback functions.
112
*******************************************************************************/
114
static void createCB_SaveAsText( UxWidget, UxClientData, UxCallbackArg )
116
XtPointer UxClientData, UxCallbackArg;
118
_UxCSaveAsShell *UxSaveCtx, *UxContext;
119
swidget UxThisWidget;
121
UxThisWidget = UxWidgetToSwidget( UxWidget );
122
UxSaveCtx = UxSaveAsShellContext;
123
UxSaveAsShellContext = UxContext =
124
(_UxCSaveAsShell *) UxGetContext( UxThisWidget );
126
UxPutText(UxFindSwidget("SaveAsText"),"noname.bdf" );
128
UxSaveAsShellContext = UxSaveCtx;
131
static void activateCB_OkSaveAs( UxWidget, UxClientData, UxCallbackArg )
133
XtPointer UxClientData, UxCallbackArg;
135
_UxCSaveAsShell *UxSaveCtx, *UxContext;
136
swidget UxThisWidget;
138
UxThisWidget = UxWidgetToSwidget( UxWidget );
139
UxSaveCtx = UxSaveAsShellContext;
140
UxSaveAsShellContext = UxContext =
141
(_UxCSaveAsShell *) UxGetContext( UxThisWidget );
143
strcpy(specSaveName,UxGetText(UxFindSwidget("SaveAsText")));
144
save_file(specSaveName);
145
UxPopdownInterface(UxFindSwidget("SaveAsShell"));
148
UxSaveAsShellContext = UxSaveCtx;
151
static void activateCB_CancelSaveAs( UxWidget, UxClientData, UxCallbackArg )
153
XtPointer UxClientData, UxCallbackArg;
155
_UxCSaveAsShell *UxSaveCtx, *UxContext;
156
swidget UxThisWidget;
158
UxThisWidget = UxWidgetToSwidget( UxWidget );
159
UxSaveCtx = UxSaveAsShellContext;
160
UxSaveAsShellContext = UxContext =
161
(_UxCSaveAsShell *) UxGetContext( UxThisWidget );
163
UxPopdownInterface(UxFindSwidget("SaveAsShell"));
165
UxSaveAsShellContext = UxSaveCtx;
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
*******************************************************************************/
176
static void _Uxinit_SaveAsShell()
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 );
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" );
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 );
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 );
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" );
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 );
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 );
242
UxPutBackground( SaveAsSeparator, ButtonBackground );
243
UxPutHeight( SaveAsSeparator, 10 );
244
UxPutWidth( SaveAsSeparator, 300 );
245
UxPutY( SaveAsSeparator, 72 );
246
UxPutX( SaveAsSeparator, 0 );
250
/*******************************************************************************
251
The 'build_' function creates all the swidgets and X widgets,
252
and sets their properties to the values specified in the
254
*******************************************************************************/
256
static swidget _Uxbuild_SaveAsShell()
258
/* Create the swidgets */
260
SaveAsShell = UxCreateTopLevelShell( "SaveAsShell", NO_PARENT );
261
UxPutContext( SaveAsShell, UxSaveAsShellContext );
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 );
271
_Uxinit_SaveAsShell();
273
/* Create the X widgets */
275
UxCreateWidget( SaveAsShell );
276
UxCreateWidget( SaveAsTopForm );
277
UxCreateWidget( TextLabel );
278
UxCreateWidget( SaveAsText );
279
createCB_SaveAsText( UxGetWidget( SaveAsText ),
280
(XtPointer) UxSaveAsShellContext, (XtPointer) NULL );
282
UxCreateWidget( SaveAsForm2 );
283
UxCreateWidget( OkSaveAs );
284
UxCreateWidget( CancelSaveAs );
285
UxCreateWidget( SaveAsSeparator );
287
UxAddCallback( OkSaveAs, XmNactivateCallback,
289
(XtPointer) UxSaveAsShellContext );
291
UxAddCallback( CancelSaveAs, XmNactivateCallback,
292
activateCB_CancelSaveAs,
293
(XtPointer) UxSaveAsShellContext );
296
/* Finally, call UxRealizeInterface to create the X windows
297
for the widgets created above. */
299
UxRealizeInterface( SaveAsShell );
301
return ( SaveAsShell );
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
*******************************************************************************/
311
static swidget _Ux_create_SaveAsShell()
314
_UxCSaveAsShell *UxContext;
316
UxSaveAsShellContext = UxContext =
317
(_UxCSaveAsShell *) UxMalloc( sizeof(_UxCSaveAsShell) );
319
rtrn = _Uxbuild_SaveAsShell();
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
329
*******************************************************************************/
331
swidget create_SaveAsShell()
335
_Uxrtrn = _Ux_create_SaveAsShell();
340
/*******************************************************************************
342
*******************************************************************************/