| 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 |
sh_airmass.c |
| 31 |
|
| 32 |
.VERSION |
| 33 |
090819 last modif |
| 34 |
|
| 35 |
*******************************************************************************/ |
| 36 |
|
| 37 |
#include <stdio.h> |
| 38 |
#include "UxLib.h" |
| 39 |
#include "UxPushB.h" |
| 40 |
#include "UxText.h" |
| 41 |
#include "UxRowCol.h" |
| 42 |
#include "UxScrW.h" |
| 43 |
#include "UxForm.h" |
| 44 |
#include "UxTopSh.h" |
| 45 |
|
| 46 |
/******************************************************************************* |
| 47 |
Includes, Defines, and Global variables from the Declarations Editor: |
| 48 |
*******************************************************************************/ |
| 49 |
|
| 50 |
#include <ExternResources.h> |
| 51 |
|
| 52 |
/******************************************************************************* |
| 53 |
The definition of the context structure: |
| 54 |
If you create multiple instances of your interface, the context |
| 55 |
structure ensures that your callbacks use the variables for the |
| 56 |
correct instance. |
| 57 |
|
| 58 |
For each swidget in the interface, each argument to the Interface |
| 59 |
function, and each variable in the Instance Specific section of the |
| 60 |
Declarations Editor, there is an entry in the context structure. |
| 61 |
and a #define. The #define makes the variable name refer to the |
| 62 |
corresponding entry in the context structure. |
| 63 |
*******************************************************************************/ |
| 64 |
|
| 65 |
typedef struct |
| 66 |
{ |
| 67 |
swidget UxAirmassShell; |
| 68 |
swidget Uxform4; |
| 69 |
swidget UxscrolledWindow2; |
| 70 |
swidget UxrowColumn2; |
| 71 |
swidget Uxt_airmass_name; |
| 72 |
swidget Uxt_airmass_value; |
| 73 |
swidget Uxpb_airmass_ok; |
| 74 |
swidget Uxpb_airmass_cancel; |
| 75 |
} _UxCAirmassShell; |
| 76 |
|
| 77 |
#define AirmassShell UxAirmassShellContext->UxAirmassShell |
| 78 |
#define form4 UxAirmassShellContext->Uxform4 |
| 79 |
#define scrolledWindow2 UxAirmassShellContext->UxscrolledWindow2 |
| 80 |
#define rowColumn2 UxAirmassShellContext->UxrowColumn2 |
| 81 |
#define t_airmass_name UxAirmassShellContext->Uxt_airmass_name |
| 82 |
#define t_airmass_value UxAirmassShellContext->Uxt_airmass_value |
| 83 |
#define pb_airmass_ok UxAirmassShellContext->Uxpb_airmass_ok |
| 84 |
#define pb_airmass_cancel UxAirmassShellContext->Uxpb_airmass_cancel |
| 85 |
|
| 86 |
static _UxCAirmassShell *UxAirmassShellContext; |
| 87 |
|
| 88 |
extern void UpdateAirmassValues(), ExecuteReduce(); |
| 89 |
|
| 90 |
/******************************************************************************* |
| 91 |
Forward declarations of functions that are defined later in this file. |
| 92 |
*******************************************************************************/ |
| 93 |
|
| 94 |
swidget create_AirmassShell(); |
| 95 |
|
| 96 |
/******************************************************************************* |
| 97 |
Auxiliary code from the Declarations Editor: |
| 98 |
*******************************************************************************/ |
| 99 |
|
| 100 |
swidget AirmassNameSwidget() |
| 101 |
{ |
| 102 |
return(t_airmass_name); |
| 103 |
} |
| 104 |
|
| 105 |
swidget AirmassValueSwidget() |
| 106 |
{ |
| 107 |
return(t_airmass_value); |
| 108 |
} |
| 109 |
|
| 110 |
/******************************************************************************* |
| 111 |
The following are callback functions. |
| 112 |
*******************************************************************************/ |
| 113 |
|
| 114 |
static void activateCB_pb_airmass_ok( UxWidget, UxClientData, UxCallbackArg ) |
| 115 |
Widget UxWidget; |
| 116 |
XtPointer UxClientData, UxCallbackArg; |
| 117 |
{ |
| 118 |
_UxCAirmassShell *UxSaveCtx, *UxContext; |
| 119 |
swidget UxThisWidget; |
| 120 |
|
| 121 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 122 |
UxSaveCtx = UxAirmassShellContext; |
| 123 |
UxAirmassShellContext = UxContext = |
| 124 |
(_UxCAirmassShell *) UxGetContext( UxThisWidget ); |
| 125 |
{ |
| 126 |
extern int ExecuteCaller; |
| 127 |
|
| 128 |
UxPopdownInterface(UxFindSwidget("AirmassShell")); |
| 129 |
UpdateAirmassValues(); |
| 130 |
if ( ExecuteCaller ) |
| 131 |
ExecuteReduce(); |
| 132 |
} |
| 133 |
UxAirmassShellContext = UxSaveCtx; |
| 134 |
} |
| 135 |
|
| 136 |
static void activateCB_pb_airmass_cancel( UxWidget, UxClientData, UxCallbackArg ) |
| 137 |
Widget UxWidget; |
| 138 |
XtPointer UxClientData, UxCallbackArg; |
| 139 |
{ |
| 140 |
_UxCAirmassShell *UxSaveCtx, *UxContext; |
| 141 |
swidget UxThisWidget; |
| 142 |
|
| 143 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 144 |
UxSaveCtx = UxAirmassShellContext; |
| 145 |
UxAirmassShellContext = UxContext = |
| 146 |
(_UxCAirmassShell *) UxGetContext( UxThisWidget ); |
| 147 |
{ |
| 148 |
UxPopdownInterface(UxFindSwidget("AirmassShell")); |
| 149 |
|
| 150 |
} |
| 151 |
UxAirmassShellContext = UxSaveCtx; |
| 152 |
} |
| 153 |
|
| 154 |
/******************************************************************************* |
| 155 |
The 'init_' function sets the private properties for all the |
| 156 |
swidgets to the values specified in the Property Table. |
| 157 |
Some properties need to be set after the X widgets have been |
| 158 |
created and the setting of these properties is done in the |
| 159 |
'build_' function after the UxCreateWidget call. |
| 160 |
*******************************************************************************/ |
| 161 |
|
| 162 |
static void _Uxinit_AirmassShell() |
| 163 |
{ |
| 164 |
UxPutGeometry( AirmassShell, "+100+100" ); |
| 165 |
UxPutBackground( AirmassShell, WindowBackground ); |
| 166 |
UxPutKeyboardFocusPolicy( AirmassShell, "pointer" ); |
| 167 |
UxPutTitle( AirmassShell, "Airmass form" ); |
| 168 |
UxPutHeight( AirmassShell, 252 ); |
| 169 |
UxPutWidth( AirmassShell, 428 ); |
| 170 |
UxPutY( AirmassShell, 381 ); |
| 171 |
UxPutX( AirmassShell, 684 ); |
| 172 |
|
| 173 |
UxPutBackground( form4, WindowBackground ); |
| 174 |
UxPutHeight( form4, 248 ); |
| 175 |
UxPutWidth( form4, 420 ); |
| 176 |
UxPutY( form4, 2 ); |
| 177 |
UxPutX( form4, 2 ); |
| 178 |
UxPutUnitType( form4, "pixels" ); |
| 179 |
UxPutResizePolicy( form4, "resize_none" ); |
| 180 |
|
| 181 |
UxPutBackground( scrolledWindow2, WindowBackground ); |
| 182 |
UxPutScrollBarPlacement( scrolledWindow2, "bottom_left" ); |
| 183 |
UxPutHeight( scrolledWindow2, 211 ); |
| 184 |
UxPutWidth( scrolledWindow2, 424 ); |
| 185 |
UxPutY( scrolledWindow2, 2 ); |
| 186 |
UxPutX( scrolledWindow2, 0 ); |
| 187 |
UxPutScrollingPolicy( scrolledWindow2, "automatic" ); |
| 188 |
|
| 189 |
UxPutEntryAlignment( rowColumn2, "alignment_beginning" ); |
| 190 |
UxPutBackground( rowColumn2, WindowBackground ); |
| 191 |
UxPutOrientation( rowColumn2, "horizontal" ); |
| 192 |
UxPutHeight( rowColumn2, 202 ); |
| 193 |
UxPutWidth( rowColumn2, 394 ); |
| 194 |
UxPutY( rowColumn2, 53 ); |
| 195 |
UxPutX( rowColumn2, 59 ); |
| 196 |
|
| 197 |
UxPutEditable( t_airmass_name, "false" ); |
| 198 |
UxPutForeground( t_airmass_name, TextForeground ); |
| 199 |
UxPutCursorPositionVisible( t_airmass_name, "false" ); |
| 200 |
UxPutEditMode( t_airmass_name, "multi_line_edit" ); |
| 201 |
UxPutFontList( t_airmass_name, SmallFont ); |
| 202 |
UxPutBackground( t_airmass_name, TextBackground ); |
| 203 |
UxPutHeight( t_airmass_name, 781 ); |
| 204 |
UxPutWidth( t_airmass_name, 298 ); |
| 205 |
UxPutY( t_airmass_name, 7 ); |
| 206 |
UxPutX( t_airmass_name, 3 ); |
| 207 |
|
| 208 |
UxPutForeground( t_airmass_value, TextForeground ); |
| 209 |
UxPutEditMode( t_airmass_value, "multi_line_edit" ); |
| 210 |
UxPutBackground( t_airmass_value, TextBackground ); |
| 211 |
UxPutFontList( t_airmass_value, SmallFont ); |
| 212 |
UxPutHeight( t_airmass_value, 524 ); |
| 213 |
UxPutWidth( t_airmass_value, 90 ); |
| 214 |
UxPutY( t_airmass_value, 4 ); |
| 215 |
UxPutX( t_airmass_value, 304 ); |
| 216 |
|
| 217 |
UxPutForeground( pb_airmass_ok, ApplyForeground ); |
| 218 |
UxPutHighlightOnEnter( pb_airmass_ok, "true" ); |
| 219 |
UxPutHighlightColor( pb_airmass_ok, "red" ); |
| 220 |
UxPutFontList( pb_airmass_ok, BoldTextFont ); |
| 221 |
UxPutLabelString( pb_airmass_ok, "Ok" ); |
| 222 |
UxPutBackground( pb_airmass_ok, ButtonBackground ); |
| 223 |
UxPutHeight( pb_airmass_ok, 32 ); |
| 224 |
UxPutWidth( pb_airmass_ok, 82 ); |
| 225 |
UxPutY( pb_airmass_ok, 216 ); |
| 226 |
UxPutX( pb_airmass_ok, 19 ); |
| 227 |
|
| 228 |
UxPutForeground( pb_airmass_cancel, CancelForeground ); |
| 229 |
UxPutHighlightOnEnter( pb_airmass_cancel, "true" ); |
| 230 |
UxPutHighlightColor( pb_airmass_cancel, ButtonForeground ); |
| 231 |
UxPutLabelString( pb_airmass_cancel, "Cancel" ); |
| 232 |
UxPutFontList( pb_airmass_cancel, BoldTextFont ); |
| 233 |
UxPutBackground( pb_airmass_cancel, ButtonBackground ); |
| 234 |
UxPutHeight( pb_airmass_cancel, 32 ); |
| 235 |
UxPutWidth( pb_airmass_cancel, 82 ); |
| 236 |
UxPutY( pb_airmass_cancel, 216 ); |
| 237 |
UxPutX( pb_airmass_cancel, 108 ); |
| 238 |
|
| 239 |
} |
| 240 |
|
| 241 |
/******************************************************************************* |
| 242 |
The 'build_' function creates all the swidgets and X widgets, |
| 243 |
and sets their properties to the values specified in the |
| 244 |
Property Editor. |
| 245 |
*******************************************************************************/ |
| 246 |
|
| 247 |
static swidget _Uxbuild_AirmassShell() |
| 248 |
{ |
| 249 |
/* Create the swidgets */ |
| 250 |
|
| 251 |
AirmassShell = UxCreateTopLevelShell( "AirmassShell", NO_PARENT ); |
| 252 |
UxPutContext( AirmassShell, UxAirmassShellContext ); |
| 253 |
|
| 254 |
form4 = UxCreateForm( "form4", AirmassShell ); |
| 255 |
scrolledWindow2 = UxCreateScrolledWindow( "scrolledWindow2", form4 ); |
| 256 |
rowColumn2 = UxCreateRowColumn( "rowColumn2", scrolledWindow2 ); |
| 257 |
t_airmass_name = UxCreateText( "t_airmass_name", rowColumn2 ); |
| 258 |
t_airmass_value = UxCreateText( "t_airmass_value", rowColumn2 ); |
| 259 |
pb_airmass_ok = UxCreatePushButton( "pb_airmass_ok", form4 ); |
| 260 |
pb_airmass_cancel = UxCreatePushButton( "pb_airmass_cancel", form4 ); |
| 261 |
|
| 262 |
_Uxinit_AirmassShell(); |
| 263 |
|
| 264 |
/* Create the X widgets */ |
| 265 |
|
| 266 |
UxCreateWidget( AirmassShell ); |
| 267 |
UxCreateWidget( form4 ); |
| 268 |
UxCreateWidget( scrolledWindow2 ); |
| 269 |
UxCreateWidget( rowColumn2 ); |
| 270 |
UxCreateWidget( t_airmass_name ); |
| 271 |
UxCreateWidget( t_airmass_value ); |
| 272 |
UxCreateWidget( pb_airmass_ok ); |
| 273 |
UxCreateWidget( pb_airmass_cancel ); |
| 274 |
|
| 275 |
UxAddCallback( pb_airmass_ok, XmNactivateCallback, |
| 276 |
activateCB_pb_airmass_ok, |
| 277 |
(XtPointer) UxAirmassShellContext ); |
| 278 |
|
| 279 |
UxAddCallback( pb_airmass_cancel, XmNactivateCallback, |
| 280 |
activateCB_pb_airmass_cancel, |
| 281 |
(XtPointer) UxAirmassShellContext ); |
| 282 |
|
| 283 |
|
| 284 |
/* Finally, call UxRealizeInterface to create the X windows |
| 285 |
for the widgets created above. */ |
| 286 |
|
| 287 |
UxRealizeInterface( AirmassShell ); |
| 288 |
|
| 289 |
return ( AirmassShell ); |
| 290 |
} |
| 291 |
|
| 292 |
/******************************************************************************* |
| 293 |
The following function includes the code that was entered |
| 294 |
in the 'Initial Code' and 'Final Code' sections of the |
| 295 |
Declarations Editor. This function is called from the |
| 296 |
'Interface function' below. |
| 297 |
*******************************************************************************/ |
| 298 |
|
| 299 |
static swidget _Ux_create_AirmassShell() |
| 300 |
{ |
| 301 |
swidget rtrn; |
| 302 |
_UxCAirmassShell *UxContext; |
| 303 |
|
| 304 |
UxAirmassShellContext = UxContext = |
| 305 |
(_UxCAirmassShell *) UxMalloc( sizeof(_UxCAirmassShell) ); |
| 306 |
|
| 307 |
rtrn = _Uxbuild_AirmassShell(); |
| 308 |
|
| 309 |
return(rtrn); |
| 310 |
} |
| 311 |
|
| 312 |
/******************************************************************************* |
| 313 |
The following is the 'Interface function' which is the |
| 314 |
external entry point for creating this interface. |
| 315 |
This function should be called from your application or from |
| 316 |
a callback function. |
| 317 |
*******************************************************************************/ |
| 318 |
|
| 319 |
swidget create_AirmassShell() |
| 320 |
{ |
| 321 |
swidget _Uxrtrn; |
| 322 |
|
| 323 |
_Uxrtrn = _Ux_create_AirmassShell(); |
| 324 |
|
| 325 |
return ( _Uxrtrn ); |
| 326 |
} |
| 327 |
|
| 328 |
/******************************************************************************* |
| 329 |
END OF FILE |
| 330 |
*******************************************************************************/ |
| 331 |
|