| 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 |
lincat_list.c |
| 31 |
|
| 32 |
.VERSION |
| 33 |
090825 last modif |
| 34 |
|
| 35 |
*******************************************************************************/ |
| 36 |
|
| 37 |
#include <stdio.h> |
| 38 |
#include "UxLib.h" |
| 39 |
#include "UxScList.h" |
| 40 |
#include "UxScrW.h" |
| 41 |
#include "UxForm.h" |
| 42 |
#include "UxTopSh.h" |
| 43 |
|
| 44 |
/******************************************************************************* |
| 45 |
Includes, Defines, and Global variables from the Declarations Editor: |
| 46 |
*******************************************************************************/ |
| 47 |
|
| 48 |
#include <ExternResources.h> |
| 49 |
|
| 50 |
/******************************************************************************* |
| 51 |
The definition of the context structure: |
| 52 |
If you create multiple instances of your interface, the context |
| 53 |
structure ensures that your callbacks use the variables for the |
| 54 |
correct instance. |
| 55 |
|
| 56 |
For each swidget in the interface, each argument to the Interface |
| 57 |
function, and each variable in the Instance Specific section of the |
| 58 |
Declarations Editor, there is an entry in the context structure. |
| 59 |
and a #define. The #define makes the variable name refer to the |
| 60 |
corresponding entry in the context structure. |
| 61 |
*******************************************************************************/ |
| 62 |
|
| 63 |
typedef struct |
| 64 |
{ |
| 65 |
swidget Uxlincat_list; |
| 66 |
swidget Uxform9; |
| 67 |
swidget UxscrolledWindow2; |
| 68 |
swidget Uxsl_lincat_list; |
| 69 |
} _UxClincat_list; |
| 70 |
|
| 71 |
#define lincat_list UxLincat_listContext->Uxlincat_list |
| 72 |
#define form9 UxLincat_listContext->Uxform9 |
| 73 |
#define scrolledWindow2 UxLincat_listContext->UxscrolledWindow2 |
| 74 |
#define sl_lincat_list UxLincat_listContext->Uxsl_lincat_list |
| 75 |
|
| 76 |
static _UxClincat_list *UxLincat_listContext; |
| 77 |
|
| 78 |
extern int XmToggleButtonGetState(), AppendDialogText(); |
| 79 |
|
| 80 |
|
| 81 |
/******************************************************************************* |
| 82 |
Forward declarations of functions that are defined later in this file. |
| 83 |
*******************************************************************************/ |
| 84 |
|
| 85 |
swidget create_lincat_list(); |
| 86 |
|
| 87 |
/******************************************************************************* |
| 88 |
The following are callback functions. |
| 89 |
*******************************************************************************/ |
| 90 |
|
| 91 |
static void browseSelectionCB_sl_lincat_list( UxWidget, UxClientData, UxCallbackArg ) |
| 92 |
Widget UxWidget; |
| 93 |
XtPointer UxClientData, UxCallbackArg; |
| 94 |
{ |
| 95 |
_UxClincat_list *UxSaveCtx, *UxContext; |
| 96 |
swidget UxThisWidget; |
| 97 |
|
| 98 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 99 |
UxSaveCtx = UxLincat_listContext; |
| 100 |
UxLincat_listContext = UxContext = |
| 101 |
(_UxClincat_list *) UxGetContext( UxThisWidget ); |
| 102 |
{ |
| 103 |
#include <spec_comm.h> |
| 104 |
|
| 105 |
char command[256]; |
| 106 |
char *choice; |
| 107 |
XmListCallbackStruct *cbs; |
| 108 |
extern char Plotmode[]; |
| 109 |
|
| 110 |
cbs = (XmListCallbackStruct *)UxCallbackArg; |
| 111 |
|
| 112 |
XmStringGetLtoR(cbs->item, XmSTRING_DEFAULT_CHARSET, &choice); |
| 113 |
|
| 114 |
if ( XmToggleButtonGetState(UxGetWidget(UxFindSwidget("tg_twodopt"))) ) |
| 115 |
sprintf(command, "%s%s ? 2D", C_PLOT_DISTOR, choice); /* 2-D */ |
| 116 |
else |
| 117 |
sprintf(command, "%s%s", C_PLOT_DISTOR, choice); /* RBR */ |
| 118 |
|
| 119 |
AppendDialogText(command); |
| 120 |
strcpy(Plotmode, C_PLOT_DISTOR); |
| 121 |
|
| 122 |
XtFree(choice); |
| 123 |
UxPopdownInterface(UxFindSwidget("lincat_list")); |
| 124 |
|
| 125 |
} |
| 126 |
UxLincat_listContext = UxSaveCtx; |
| 127 |
} |
| 128 |
|
| 129 |
/******************************************************************************* |
| 130 |
The 'init_' function sets the private properties for all the |
| 131 |
swidgets to the values specified in the Property Table. |
| 132 |
Some properties need to be set after the X widgets have been |
| 133 |
created and the setting of these properties is done in the |
| 134 |
'build_' function after the UxCreateWidget call. |
| 135 |
*******************************************************************************/ |
| 136 |
|
| 137 |
static void _Uxinit_lincat_list() |
| 138 |
{ |
| 139 |
UxPutGeometry( lincat_list, "+100+100" ); |
| 140 |
UxPutBackground( lincat_list, "AntiqueWhite" ); |
| 141 |
UxPutKeyboardFocusPolicy( lincat_list, "pointer" ); |
| 142 |
UxPutIconName( lincat_list, "Wavelength selection" ); |
| 143 |
UxPutHeight( lincat_list, 355 ); |
| 144 |
UxPutWidth( lincat_list, 199 ); |
| 145 |
UxPutY( lincat_list, 236 ); |
| 146 |
UxPutX( lincat_list, 571 ); |
| 147 |
|
| 148 |
UxPutBackground( form9, ApplicBackground ); |
| 149 |
UxPutHeight( form9, 352 ); |
| 150 |
UxPutWidth( form9, 214 ); |
| 151 |
UxPutY( form9, 0 ); |
| 152 |
UxPutX( form9, 0 ); |
| 153 |
UxPutUnitType( form9, "pixels" ); |
| 154 |
UxPutResizePolicy( form9, "resize_none" ); |
| 155 |
|
| 156 |
UxPutWidth( scrolledWindow2, 160 ); |
| 157 |
UxPutHeight( scrolledWindow2, 350 ); |
| 158 |
UxPutBackground( scrolledWindow2, ListBackground ); |
| 159 |
UxPutScrollBarPlacement( scrolledWindow2, "bottom_left" ); |
| 160 |
UxPutShadowThickness( scrolledWindow2, 0 ); |
| 161 |
UxPutScrollBarDisplayPolicy( scrolledWindow2, "static" ); |
| 162 |
UxPutVisualPolicy( scrolledWindow2, "variable" ); |
| 163 |
UxPutY( scrolledWindow2, 2 ); |
| 164 |
UxPutX( scrolledWindow2, 2 ); |
| 165 |
UxPutScrollingPolicy( scrolledWindow2, "application_defined" ); |
| 166 |
|
| 167 |
UxPutForeground( sl_lincat_list, ListForeground ); |
| 168 |
UxPutVisibleItemCount( sl_lincat_list, 21 ); |
| 169 |
UxPutFontList( sl_lincat_list, SmallFont ); |
| 170 |
UxPutBackground( sl_lincat_list, TextBackground ); |
| 171 |
UxPutListSizePolicy( sl_lincat_list, "variable" ); |
| 172 |
UxPutScrollBarDisplayPolicy( sl_lincat_list, "static" ); |
| 173 |
UxPutHeight( sl_lincat_list, 352 ); |
| 174 |
UxPutWidth( sl_lincat_list, 238 ); |
| 175 |
|
| 176 |
} |
| 177 |
|
| 178 |
/******************************************************************************* |
| 179 |
The 'build_' function creates all the swidgets and X widgets, |
| 180 |
and sets their properties to the values specified in the |
| 181 |
Property Editor. |
| 182 |
*******************************************************************************/ |
| 183 |
|
| 184 |
static swidget _Uxbuild_lincat_list() |
| 185 |
{ |
| 186 |
/* Create the swidgets */ |
| 187 |
|
| 188 |
lincat_list = UxCreateTopLevelShell( "lincat_list", NO_PARENT ); |
| 189 |
UxPutContext( lincat_list, UxLincat_listContext ); |
| 190 |
|
| 191 |
form9 = UxCreateForm( "form9", lincat_list ); |
| 192 |
scrolledWindow2 = UxCreateScrolledWindow( "scrolledWindow2", form9 ); |
| 193 |
sl_lincat_list = UxCreateScrolledList( "sl_lincat_list", scrolledWindow2 ); |
| 194 |
|
| 195 |
_Uxinit_lincat_list(); |
| 196 |
|
| 197 |
/* Create the X widgets */ |
| 198 |
|
| 199 |
UxCreateWidget( lincat_list ); |
| 200 |
UxCreateWidget( form9 ); |
| 201 |
UxPutLeftOffset( scrolledWindow2, 2 ); |
| 202 |
UxPutLeftAttachment( scrolledWindow2, "attach_form" ); |
| 203 |
UxPutRightOffset( scrolledWindow2, 2 ); |
| 204 |
UxPutRightAttachment( scrolledWindow2, "attach_form" ); |
| 205 |
UxCreateWidget( scrolledWindow2 ); |
| 206 |
|
| 207 |
UxCreateWidget( sl_lincat_list ); |
| 208 |
|
| 209 |
UxAddCallback( sl_lincat_list, XmNbrowseSelectionCallback, |
| 210 |
browseSelectionCB_sl_lincat_list, |
| 211 |
(XtPointer) UxLincat_listContext ); |
| 212 |
|
| 213 |
|
| 214 |
/* Finally, call UxRealizeInterface to create the X windows |
| 215 |
for the widgets created above. */ |
| 216 |
|
| 217 |
UxRealizeInterface( lincat_list ); |
| 218 |
|
| 219 |
return ( lincat_list ); |
| 220 |
} |
| 221 |
|
| 222 |
/******************************************************************************* |
| 223 |
The following function includes the code that was entered |
| 224 |
in the 'Initial Code' and 'Final Code' sections of the |
| 225 |
Declarations Editor. This function is called from the |
| 226 |
'Interface function' below. |
| 227 |
*******************************************************************************/ |
| 228 |
|
| 229 |
static swidget _Ux_create_lincat_list() |
| 230 |
{ |
| 231 |
swidget rtrn; |
| 232 |
_UxClincat_list *UxContext; |
| 233 |
|
| 234 |
UxLincat_listContext = UxContext = |
| 235 |
(_UxClincat_list *) UxMalloc( sizeof(_UxClincat_list) ); |
| 236 |
|
| 237 |
rtrn = _Uxbuild_lincat_list(); |
| 238 |
|
| 239 |
return(rtrn); |
| 240 |
} |
| 241 |
|
| 242 |
/******************************************************************************* |
| 243 |
The following is the 'Interface function' which is the |
| 244 |
external entry point for creating this interface. |
| 245 |
This function should be called from your application or from |
| 246 |
a callback function. |
| 247 |
*******************************************************************************/ |
| 248 |
|
| 249 |
swidget create_lincat_list() |
| 250 |
{ |
| 251 |
swidget _Uxrtrn; |
| 252 |
|
| 253 |
_Uxrtrn = _Ux_create_lincat_list(); |
| 254 |
|
| 255 |
return ( _Uxrtrn ); |
| 256 |
} |
| 257 |
|
| 258 |
/******************************************************************************* |
| 259 |
END OF FILE |
| 260 |
*******************************************************************************/ |
| 261 |
|