| 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 |
resid_dialog.c |
| 31 |
|
| 32 |
.VERSION |
| 33 |
090825 last modif |
| 34 |
|
| 35 |
*******************************************************************************/ |
| 36 |
|
| 37 |
#include <stdio.h> |
| 38 |
#include "UxLib.h" |
| 39 |
#include "UxTogB.h" |
| 40 |
#include "UxTextF.h" |
| 41 |
#include "UxLabel.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 |
|
| 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 Uxresid_dialog; |
| 68 |
swidget Uxform18; |
| 69 |
swidget Uxform19; |
| 70 |
swidget UxpushButton29; |
| 71 |
swidget UxpushButton36; |
| 72 |
swidget Uxlabel25; |
| 73 |
swidget Uxtf_residual; |
| 74 |
swidget Uxtg_residual; |
| 75 |
} _UxCresid_dialog; |
| 76 |
|
| 77 |
#define resid_dialog UxResid_dialogContext->Uxresid_dialog |
| 78 |
#define form18 UxResid_dialogContext->Uxform18 |
| 79 |
#define form19 UxResid_dialogContext->Uxform19 |
| 80 |
#define pushButton29 UxResid_dialogContext->UxpushButton29 |
| 81 |
#define pushButton36 UxResid_dialogContext->UxpushButton36 |
| 82 |
#define label25 UxResid_dialogContext->Uxlabel25 |
| 83 |
#define tf_residual UxResid_dialogContext->Uxtf_residual |
| 84 |
#define tg_residual UxResid_dialogContext->Uxtg_residual |
| 85 |
|
| 86 |
static _UxCresid_dialog *UxResid_dialogContext; |
| 87 |
|
| 88 |
extern int AppendDialogText(); |
| 89 |
|
| 90 |
|
| 91 |
/******************************************************************************* |
| 92 |
Forward declarations of functions that are defined later in this file. |
| 93 |
*******************************************************************************/ |
| 94 |
|
| 95 |
swidget create_resid_dialog(); |
| 96 |
|
| 97 |
/******************************************************************************* |
| 98 |
The following are callback functions. |
| 99 |
*******************************************************************************/ |
| 100 |
|
| 101 |
static void activateCB_pushButton29( UxWidget, UxClientData, UxCallbackArg ) |
| 102 |
Widget UxWidget; |
| 103 |
XtPointer UxClientData, UxCallbackArg; |
| 104 |
{ |
| 105 |
_UxCresid_dialog *UxSaveCtx, *UxContext; |
| 106 |
swidget UxThisWidget; |
| 107 |
|
| 108 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 109 |
UxSaveCtx = UxResid_dialogContext; |
| 110 |
UxResid_dialogContext = UxContext = |
| 111 |
(_UxCresid_dialog *) UxGetContext( UxThisWidget ); |
| 112 |
{ |
| 113 |
#include <spec_comm.h> |
| 114 |
|
| 115 |
char command[256]; |
| 116 |
char *text; |
| 117 |
extern char Plotmode[]; |
| 118 |
|
| 119 |
strcpy(Plotmode, C_PLOT_RESID); |
| 120 |
if ( XmToggleButtonGetState(UxGetWidget(UxFindSwidget("tg_residual")))) |
| 121 |
sprintf(command, "%sALL", C_PLOT_RESID); |
| 122 |
else { |
| 123 |
text = XmTextGetString(UxGetWidget(UxFindSwidget("tf_residual"))); |
| 124 |
sprintf(command, "%s%s", C_PLOT_RESID, text); |
| 125 |
XtFree(text); |
| 126 |
} |
| 127 |
AppendDialogText(command); |
| 128 |
UxPopdownInterface(UxFindSwidget("resid_dialog")); |
| 129 |
} |
| 130 |
UxResid_dialogContext = UxSaveCtx; |
| 131 |
} |
| 132 |
|
| 133 |
static void activateCB_pushButton36( UxWidget, UxClientData, UxCallbackArg ) |
| 134 |
Widget UxWidget; |
| 135 |
XtPointer UxClientData, UxCallbackArg; |
| 136 |
{ |
| 137 |
_UxCresid_dialog *UxSaveCtx, *UxContext; |
| 138 |
swidget UxThisWidget; |
| 139 |
|
| 140 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 141 |
UxSaveCtx = UxResid_dialogContext; |
| 142 |
UxResid_dialogContext = UxContext = |
| 143 |
(_UxCresid_dialog *) UxGetContext( UxThisWidget ); |
| 144 |
{ |
| 145 |
UxPopdownInterface(UxFindSwidget("resid_dialog")); |
| 146 |
} |
| 147 |
UxResid_dialogContext = UxSaveCtx; |
| 148 |
} |
| 149 |
|
| 150 |
static void valueChangedCB_tg_residual( UxWidget, UxClientData, UxCallbackArg ) |
| 151 |
Widget UxWidget; |
| 152 |
XtPointer UxClientData, UxCallbackArg; |
| 153 |
{ |
| 154 |
_UxCresid_dialog *UxSaveCtx, *UxContext; |
| 155 |
swidget UxThisWidget; |
| 156 |
|
| 157 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 158 |
UxSaveCtx = UxResid_dialogContext; |
| 159 |
UxResid_dialogContext = UxContext = |
| 160 |
(_UxCresid_dialog *) UxGetContext( UxThisWidget ); |
| 161 |
{ |
| 162 |
extern int AllResidual; |
| 163 |
|
| 164 |
AllResidual = XmToggleButtonGetState(UxWidget); |
| 165 |
XtSetSensitive(UxGetWidget(UxFindSwidget("tf_residual")), !AllResidual); |
| 166 |
} |
| 167 |
UxResid_dialogContext = UxSaveCtx; |
| 168 |
} |
| 169 |
|
| 170 |
/******************************************************************************* |
| 171 |
The 'init_' function sets the private properties for all the |
| 172 |
swidgets to the values specified in the Property Table. |
| 173 |
Some properties need to be set after the X widgets have been |
| 174 |
created and the setting of these properties is done in the |
| 175 |
'build_' function after the UxCreateWidget call. |
| 176 |
*******************************************************************************/ |
| 177 |
|
| 178 |
static void _Uxinit_resid_dialog() |
| 179 |
{ |
| 180 |
UxPutBackground( resid_dialog, WindowBackground ); |
| 181 |
UxPutGeometry( resid_dialog, "+180+360" ); |
| 182 |
UxPutKeyboardFocusPolicy( resid_dialog, "pointer" ); |
| 183 |
UxPutTitle( resid_dialog, "Residuals plot" ); |
| 184 |
UxPutHeight( resid_dialog, 105 ); |
| 185 |
UxPutWidth( resid_dialog, 246 ); |
| 186 |
UxPutY( resid_dialog, 121 ); |
| 187 |
UxPutX( resid_dialog, 102 ); |
| 188 |
|
| 189 |
UxPutBackground( form18, WindowBackground ); |
| 190 |
UxPutHeight( form18, 348 ); |
| 191 |
UxPutWidth( form18, 408 ); |
| 192 |
UxPutY( form18, 0 ); |
| 193 |
UxPutX( form18, 0 ); |
| 194 |
UxPutUnitType( form18, "pixels" ); |
| 195 |
UxPutResizePolicy( form18, "resize_none" ); |
| 196 |
|
| 197 |
UxPutBackground( form19, ButtonBackground ); |
| 198 |
UxPutHeight( form19, 40 ); |
| 199 |
UxPutWidth( form19, 452 ); |
| 200 |
UxPutY( form19, 62 ); |
| 201 |
UxPutX( form19, 0 ); |
| 202 |
UxPutResizePolicy( form19, "resize_none" ); |
| 203 |
|
| 204 |
UxPutLabelString( pushButton29, "Ok" ); |
| 205 |
UxPutForeground( pushButton29, ApplyForeground ); |
| 206 |
UxPutFontList( pushButton29, BoldTextFont ); |
| 207 |
UxPutBackground( pushButton29, ButtonBackground ); |
| 208 |
UxPutHeight( pushButton29, 30 ); |
| 209 |
UxPutWidth( pushButton29, 80 ); |
| 210 |
UxPutY( pushButton29, 4 ); |
| 211 |
UxPutX( pushButton29, 8 ); |
| 212 |
|
| 213 |
UxPutLabelString( pushButton36, "Cancel" ); |
| 214 |
UxPutForeground( pushButton36, CancelForeground ); |
| 215 |
UxPutFontList( pushButton36, BoldTextFont ); |
| 216 |
UxPutBackground( pushButton36, ButtonBackground ); |
| 217 |
UxPutHeight( pushButton36, 30 ); |
| 218 |
UxPutWidth( pushButton36, 80 ); |
| 219 |
UxPutY( pushButton36, 4 ); |
| 220 |
UxPutX( pushButton36, 100 ); |
| 221 |
|
| 222 |
UxPutForeground( label25, TextForeground ); |
| 223 |
UxPutAlignment( label25, "alignment_beginning" ); |
| 224 |
UxPutLabelString( label25, "Row number :" ); |
| 225 |
UxPutFontList( label25, TextFont ); |
| 226 |
UxPutBackground( label25, LabelBackground ); |
| 227 |
UxPutHeight( label25, 36 ); |
| 228 |
UxPutWidth( label25, 94 ); |
| 229 |
UxPutY( label25, 10 ); |
| 230 |
UxPutX( label25, 22 ); |
| 231 |
|
| 232 |
UxPutForeground( tf_residual, TextForeground ); |
| 233 |
UxPutHighlightOnEnter( tf_residual, "true" ); |
| 234 |
UxPutFontList( tf_residual, TextFont ); |
| 235 |
UxPutBackground( tf_residual, TextBackground ); |
| 236 |
UxPutHeight( tf_residual, 40 ); |
| 237 |
UxPutWidth( tf_residual, 54 ); |
| 238 |
UxPutY( tf_residual, 8 ); |
| 239 |
UxPutX( tf_residual, 120 ); |
| 240 |
|
| 241 |
UxPutIndicatorSize( tg_residual, 16 ); |
| 242 |
UxPutHighlightOnEnter( tg_residual, "true" ); |
| 243 |
UxPutForeground( tg_residual, TextForeground ); |
| 244 |
UxPutSelectColor( tg_residual, SelectColor ); |
| 245 |
UxPutSet( tg_residual, "false" ); |
| 246 |
UxPutLabelString( tg_residual, "ALL" ); |
| 247 |
UxPutFontList( tg_residual, TextFont ); |
| 248 |
UxPutBackground( tg_residual, WindowBackground ); |
| 249 |
UxPutHeight( tg_residual, 36 ); |
| 250 |
UxPutWidth( tg_residual, 60 ); |
| 251 |
UxPutY( tg_residual, 10 ); |
| 252 |
UxPutX( tg_residual, 176 ); |
| 253 |
|
| 254 |
} |
| 255 |
|
| 256 |
/******************************************************************************* |
| 257 |
The 'build_' function creates all the swidgets and X widgets, |
| 258 |
and sets their properties to the values specified in the |
| 259 |
Property Editor. |
| 260 |
*******************************************************************************/ |
| 261 |
|
| 262 |
static swidget _Uxbuild_resid_dialog() |
| 263 |
{ |
| 264 |
/* Create the swidgets */ |
| 265 |
|
| 266 |
resid_dialog = UxCreateApplicationShell( "resid_dialog", NO_PARENT ); |
| 267 |
UxPutContext( resid_dialog, UxResid_dialogContext ); |
| 268 |
|
| 269 |
form18 = UxCreateForm( "form18", resid_dialog ); |
| 270 |
form19 = UxCreateForm( "form19", form18 ); |
| 271 |
pushButton29 = UxCreatePushButton( "pushButton29", form19 ); |
| 272 |
pushButton36 = UxCreatePushButton( "pushButton36", form19 ); |
| 273 |
label25 = UxCreateLabel( "label25", form18 ); |
| 274 |
tf_residual = UxCreateTextField( "tf_residual", form18 ); |
| 275 |
tg_residual = UxCreateToggleButton( "tg_residual", form18 ); |
| 276 |
|
| 277 |
_Uxinit_resid_dialog(); |
| 278 |
|
| 279 |
/* Create the X widgets */ |
| 280 |
|
| 281 |
UxCreateWidget( resid_dialog ); |
| 282 |
UxCreateWidget( form18 ); |
| 283 |
UxCreateWidget( form19 ); |
| 284 |
UxCreateWidget( pushButton29 ); |
| 285 |
UxCreateWidget( pushButton36 ); |
| 286 |
UxCreateWidget( label25 ); |
| 287 |
UxCreateWidget( tf_residual ); |
| 288 |
UxCreateWidget( tg_residual ); |
| 289 |
|
| 290 |
UxAddCallback( pushButton29, XmNactivateCallback, |
| 291 |
activateCB_pushButton29, |
| 292 |
(XtPointer) UxResid_dialogContext ); |
| 293 |
|
| 294 |
UxAddCallback( pushButton36, XmNactivateCallback, |
| 295 |
activateCB_pushButton36, |
| 296 |
(XtPointer) UxResid_dialogContext ); |
| 297 |
|
| 298 |
UxAddCallback( tg_residual, XmNvalueChangedCallback, |
| 299 |
valueChangedCB_tg_residual, |
| 300 |
(XtPointer) UxResid_dialogContext ); |
| 301 |
|
| 302 |
|
| 303 |
/* Finally, call UxRealizeInterface to create the X windows |
| 304 |
for the widgets created above. */ |
| 305 |
|
| 306 |
UxRealizeInterface( resid_dialog ); |
| 307 |
|
| 308 |
return ( resid_dialog ); |
| 309 |
} |
| 310 |
|
| 311 |
/******************************************************************************* |
| 312 |
The following function includes the code that was entered |
| 313 |
in the 'Initial Code' and 'Final Code' sections of the |
| 314 |
Declarations Editor. This function is called from the |
| 315 |
'Interface function' below. |
| 316 |
*******************************************************************************/ |
| 317 |
|
| 318 |
static swidget _Ux_create_resid_dialog() |
| 319 |
{ |
| 320 |
swidget rtrn; |
| 321 |
_UxCresid_dialog *UxContext; |
| 322 |
|
| 323 |
UxResid_dialogContext = UxContext = |
| 324 |
(_UxCresid_dialog *) UxMalloc( sizeof(_UxCresid_dialog) ); |
| 325 |
|
| 326 |
rtrn = _Uxbuild_resid_dialog(); |
| 327 |
|
| 328 |
return(rtrn); |
| 329 |
} |
| 330 |
|
| 331 |
/******************************************************************************* |
| 332 |
The following is the 'Interface function' which is the |
| 333 |
external entry point for creating this interface. |
| 334 |
This function should be called from your application or from |
| 335 |
a callback function. |
| 336 |
*******************************************************************************/ |
| 337 |
|
| 338 |
swidget create_resid_dialog() |
| 339 |
{ |
| 340 |
swidget _Uxrtrn; |
| 341 |
|
| 342 |
_Uxrtrn = _Ux_create_resid_dialog(); |
| 343 |
|
| 344 |
return ( _Uxrtrn ); |
| 345 |
} |
| 346 |
|
| 347 |
/******************************************************************************* |
| 348 |
END OF FILE |
| 349 |
*******************************************************************************/ |
| 350 |
|