| 1 |
|
| 2 |
/******************************************************************************* |
| 3 |
SelectInstrument.c |
| 4 |
|
| 5 |
.VERSION |
| 6 |
090825 last modif |
| 7 |
|
| 8 |
|
| 9 |
*******************************************************************************/ |
| 10 |
|
| 11 |
#include <stdio.h> |
| 12 |
#include "UxLib.h" |
| 13 |
#include "UxSelBox.h" |
| 14 |
|
| 15 |
#include "midas_def.h" |
| 16 |
#include "str.h" |
| 17 |
|
| 18 |
/******************************************************************************* |
| 19 |
Includes, Defines, and Global variables from the Declarations Editor: |
| 20 |
*******************************************************************************/ |
| 21 |
|
| 22 |
#include <ExternResources.h> |
| 23 |
|
| 24 |
/******************************************************************************* |
| 25 |
The definition of the context structure: |
| 26 |
If you create multiple instances of your interface, the context |
| 27 |
structure ensures that your callbacks use the variables for the |
| 28 |
correct instance. |
| 29 |
|
| 30 |
For each swidget in the interface, each argument to the Interface |
| 31 |
function, and each variable in the Instance Specific section of the |
| 32 |
Declarations Editor, there is an entry in the context structure. |
| 33 |
and a #define. The #define makes the variable name refer to the |
| 34 |
corresponding entry in the context structure. |
| 35 |
*******************************************************************************/ |
| 36 |
|
| 37 |
typedef struct |
| 38 |
{ |
| 39 |
swidget UxSelectInstrument; |
| 40 |
} _UxCSelectInstrument; |
| 41 |
|
| 42 |
#define SelectInstrument UxSelectInstrumentContext->UxSelectInstrument |
| 43 |
|
| 44 |
static _UxCSelectInstrument *UxSelectInstrumentContext; |
| 45 |
|
| 46 |
extern int redecomp(); |
| 47 |
|
| 48 |
|
| 49 |
/******************************************************************************* |
| 50 |
Forward declarations of functions that are defined later in this file. |
| 51 |
*******************************************************************************/ |
| 52 |
|
| 53 |
swidget create_SelectInstrument(); |
| 54 |
|
| 55 |
/******************************************************************************* |
| 56 |
The following are callback functions. |
| 57 |
*******************************************************************************/ |
| 58 |
|
| 59 |
static void okCallback_SelectInstrument( UxWidget, UxClientData, UxCallbackArg ) |
| 60 |
Widget UxWidget; |
| 61 |
XtPointer UxClientData, UxCallbackArg; |
| 62 |
{ |
| 63 |
_UxCSelectInstrument *UxSaveCtx, *UxContext; |
| 64 |
swidget UxThisWidget; |
| 65 |
|
| 66 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 67 |
UxSaveCtx = UxSelectInstrumentContext; |
| 68 |
UxSelectInstrumentContext = UxContext = |
| 69 |
(_UxCSelectInstrument *) UxGetContext( UxThisWidget ); |
| 70 |
{ |
| 71 |
char *value; |
| 72 |
char descr[257]; |
| 73 |
extern swidget ilist; |
| 74 |
extern int tidost,doI; |
| 75 |
int uni,null,actval,index; |
| 76 |
XmSelectionBoxCallbackStruct *cbs; |
| 77 |
cbs = (XmSelectionBoxCallbackStruct *)UxCallbackArg; |
| 78 |
XmStringGetLtoR(cbs->value,XmSTRING_DEFAULT_CHARSET,&value); |
| 79 |
|
| 80 |
if ( doI) { |
| 81 |
UxPutText(UxFindSwidget("clas_t1"),value); |
| 82 |
oscfill(descr,257,'\0'); |
| 83 |
SCDRDC(tidost,value,1,1,256,&actval,descr,&uni,&null); |
| 84 |
index = strbskip(descr,' '); |
| 85 |
descr[index+1] = '\0'; |
| 86 |
UxPutText(UxFindSwidget("clas_t1"),value); |
| 87 |
UxPutText(UxFindSwidget("criteria"),descr); |
| 88 |
redecomp(descr); |
| 89 |
} |
| 90 |
else { |
| 91 |
UxPutText(UxFindSwidget("text3"),value); |
| 92 |
UxPopdownInterface(ilist); |
| 93 |
} |
| 94 |
} |
| 95 |
UxSelectInstrumentContext = UxSaveCtx; |
| 96 |
} |
| 97 |
|
| 98 |
static void createCB_SelectInstrument( UxWidget, UxClientData, UxCallbackArg ) |
| 99 |
Widget UxWidget; |
| 100 |
XtPointer UxClientData, UxCallbackArg; |
| 101 |
{ |
| 102 |
_UxCSelectInstrument *UxSaveCtx, *UxContext; |
| 103 |
swidget UxThisWidget; |
| 104 |
|
| 105 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 106 |
UxSaveCtx = UxSelectInstrumentContext; |
| 107 |
UxSelectInstrumentContext = UxContext = |
| 108 |
(_UxCSelectInstrument *) UxGetContext( UxThisWidget ); |
| 109 |
UxSelectInstrumentContext = UxSaveCtx; |
| 110 |
} |
| 111 |
|
| 112 |
static void cancelCB_SelectInstrument( UxWidget, UxClientData, UxCallbackArg ) |
| 113 |
Widget UxWidget; |
| 114 |
XtPointer UxClientData, UxCallbackArg; |
| 115 |
{ |
| 116 |
_UxCSelectInstrument *UxSaveCtx, *UxContext; |
| 117 |
swidget UxThisWidget; |
| 118 |
|
| 119 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 120 |
UxSaveCtx = UxSelectInstrumentContext; |
| 121 |
UxSelectInstrumentContext = UxContext = |
| 122 |
(_UxCSelectInstrument *) UxGetContext( UxThisWidget ); |
| 123 |
{ |
| 124 |
extern swidget ilist; |
| 125 |
UxPopdownInterface(ilist); |
| 126 |
} |
| 127 |
UxSelectInstrumentContext = UxSaveCtx; |
| 128 |
} |
| 129 |
|
| 130 |
/******************************************************************************* |
| 131 |
The 'init_' function sets the private properties for all the |
| 132 |
swidgets to the values specified in the Property Table. |
| 133 |
Some properties need to be set after the X widgets have been |
| 134 |
created and the setting of these properties is done in the |
| 135 |
'build_' function after the UxCreateWidget call. |
| 136 |
*******************************************************************************/ |
| 137 |
|
| 138 |
static void _Uxinit_SelectInstrument() |
| 139 |
{ |
| 140 |
UxPutListLabelString( SelectInstrument, "Instrument" ); |
| 141 |
UxPutMustMatch( SelectInstrument, "true" ); |
| 142 |
UxPutTextFontList( SelectInstrument, BoldTextFont ); |
| 143 |
UxPutLabelFontList( SelectInstrument, BoldTextFont ); |
| 144 |
UxPutButtonFontList( SelectInstrument, BoldTextFont ); |
| 145 |
UxPutBackground( SelectInstrument, WindowBackground ); |
| 146 |
UxPutHeight( SelectInstrument, 320 ); |
| 147 |
UxPutWidth( SelectInstrument, 260 ); |
| 148 |
UxPutY( SelectInstrument, 80 ); |
| 149 |
UxPutX( SelectInstrument, 400 ); |
| 150 |
UxPutUnitType( SelectInstrument, "pixels" ); |
| 151 |
UxPutResizePolicy( SelectInstrument, "resize_none" ); |
| 152 |
|
| 153 |
} |
| 154 |
|
| 155 |
/******************************************************************************* |
| 156 |
The 'build_' function creates all the swidgets and X widgets, |
| 157 |
and sets their properties to the values specified in the |
| 158 |
Property Editor. |
| 159 |
*******************************************************************************/ |
| 160 |
|
| 161 |
static swidget _Uxbuild_SelectInstrument() |
| 162 |
{ |
| 163 |
/* Create the swidgets */ |
| 164 |
|
| 165 |
SelectInstrument = UxCreateSelectionBox( "SelectInstrument", NO_PARENT ); |
| 166 |
UxPutContext( SelectInstrument, UxSelectInstrumentContext ); |
| 167 |
UxPutDefaultShell( SelectInstrument, "topLevelShell" ); |
| 168 |
|
| 169 |
|
| 170 |
_Uxinit_SelectInstrument(); |
| 171 |
|
| 172 |
/* Create the X widgets */ |
| 173 |
|
| 174 |
UxCreateWidget( SelectInstrument ); |
| 175 |
createCB_SelectInstrument( UxGetWidget( SelectInstrument ), |
| 176 |
(XtPointer) UxSelectInstrumentContext, (XtPointer) NULL ); |
| 177 |
|
| 178 |
|
| 179 |
UxAddCallback( SelectInstrument, XmNokCallback, |
| 180 |
okCallback_SelectInstrument, |
| 181 |
(XtPointer) UxSelectInstrumentContext ); |
| 182 |
UxAddCallback( SelectInstrument, XmNcancelCallback, |
| 183 |
cancelCB_SelectInstrument, |
| 184 |
(XtPointer) UxSelectInstrumentContext ); |
| 185 |
|
| 186 |
|
| 187 |
/* Finally, call UxRealizeInterface to create the X windows |
| 188 |
for the widgets created above. */ |
| 189 |
|
| 190 |
UxRealizeInterface( SelectInstrument ); |
| 191 |
|
| 192 |
return ( SelectInstrument ); |
| 193 |
} |
| 194 |
|
| 195 |
/******************************************************************************* |
| 196 |
The following function includes the code that was entered |
| 197 |
in the 'Initial Code' and 'Final Code' sections of the |
| 198 |
Declarations Editor. This function is called from the |
| 199 |
'Interface function' below. |
| 200 |
*******************************************************************************/ |
| 201 |
|
| 202 |
static swidget _Ux_create_SelectInstrument() |
| 203 |
{ |
| 204 |
swidget rtrn; |
| 205 |
_UxCSelectInstrument *UxContext; |
| 206 |
|
| 207 |
UxSelectInstrumentContext = UxContext = |
| 208 |
(_UxCSelectInstrument *) UxMalloc( sizeof(_UxCSelectInstrument) ); |
| 209 |
|
| 210 |
rtrn = _Uxbuild_SelectInstrument(); |
| 211 |
|
| 212 |
return(rtrn); |
| 213 |
} |
| 214 |
|
| 215 |
/******************************************************************************* |
| 216 |
The following is the 'Interface function' which is the |
| 217 |
external entry point for creating this interface. |
| 218 |
This function should be called from your application or from |
| 219 |
a callback function. |
| 220 |
*******************************************************************************/ |
| 221 |
|
| 222 |
swidget create_SelectInstrument() |
| 223 |
{ |
| 224 |
swidget _Uxrtrn; |
| 225 |
|
| 226 |
_Uxrtrn = _Ux_create_SelectInstrument(); |
| 227 |
|
| 228 |
return ( _Uxrtrn ); |
| 229 |
} |
| 230 |
|
| 231 |
/******************************************************************************* |
| 232 |
END OF FILE |
| 233 |
*******************************************************************************/ |
| 234 |
|