| 1 |
|
| 2 |
/******************************************************************************* |
| 3 |
SelectFrame.c |
| 4 |
|
| 5 |
.VERSION |
| 6 |
090825 last modif |
| 7 |
|
| 8 |
*******************************************************************************/ |
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include "UxLib.h" |
| 12 |
#include "UxFsBox.h" |
| 13 |
|
| 14 |
/******************************************************************************* |
| 15 |
Includes, Defines, and Global variables from the Declarations Editor: |
| 16 |
*******************************************************************************/ |
| 17 |
|
| 18 |
#include <midas_def.h> |
| 19 |
#include <str.h> |
| 20 |
|
| 21 |
#include <ExternResources.h> |
| 22 |
|
| 23 |
extern void my_select(); |
| 24 |
|
| 25 |
char *filechoice; |
| 26 |
int fno; |
| 27 |
|
| 28 |
/******************************************************************************* |
| 29 |
The definition of the context structure: |
| 30 |
If you create multiple instances of your interface, the context |
| 31 |
structure ensures that your callbacks use the variables for the |
| 32 |
correct instance. |
| 33 |
|
| 34 |
For each swidget in the interface, each argument to the Interface |
| 35 |
function, and each variable in the Instance Specific section of the |
| 36 |
Declarations Editor, there is an entry in the context structure. |
| 37 |
and a #define. The #define makes the variable name refer to the |
| 38 |
corresponding entry in the context structure. |
| 39 |
*******************************************************************************/ |
| 40 |
|
| 41 |
typedef struct |
| 42 |
{ |
| 43 |
swidget UxSelectFrame; |
| 44 |
} _UxCSelectFrame; |
| 45 |
|
| 46 |
#define SelectFrame UxSelectFrameContext->UxSelectFrame |
| 47 |
|
| 48 |
static _UxCSelectFrame *UxSelectFrameContext; |
| 49 |
|
| 50 |
|
| 51 |
/******************************************************************************* |
| 52 |
Forward declarations of functions that are defined later in this file. |
| 53 |
*******************************************************************************/ |
| 54 |
|
| 55 |
swidget create_SelectFrame(); |
| 56 |
|
| 57 |
/******************************************************************************* |
| 58 |
The following are callback functions. |
| 59 |
*******************************************************************************/ |
| 60 |
|
| 61 |
static void cancelCB_SelectFrame( UxWidget, UxClientData, UxCallbackArg ) |
| 62 |
Widget UxWidget; |
| 63 |
XtPointer UxClientData, UxCallbackArg; |
| 64 |
{ |
| 65 |
_UxCSelectFrame *UxSaveCtx, *UxContext; |
| 66 |
swidget UxThisWidget; |
| 67 |
|
| 68 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 69 |
UxSaveCtx = UxSelectFrameContext; |
| 70 |
UxSelectFrameContext = UxContext = |
| 71 |
(_UxCSelectFrame *) UxGetContext( UxThisWidget ); |
| 72 |
{ |
| 73 |
extern swidget flist; |
| 74 |
UxPopdownInterface(flist); |
| 75 |
} |
| 76 |
UxSelectFrameContext = UxSaveCtx; |
| 77 |
} |
| 78 |
|
| 79 |
static void okCallback_SelectFrame( UxWidget, UxClientData, UxCallbackArg ) |
| 80 |
Widget UxWidget; |
| 81 |
XtPointer UxClientData, UxCallbackArg; |
| 82 |
{ |
| 83 |
_UxCSelectFrame *UxSaveCtx, *UxContext; |
| 84 |
swidget UxThisWidget; |
| 85 |
|
| 86 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 87 |
UxSaveCtx = UxSelectFrameContext; |
| 88 |
UxSelectFrameContext = UxContext = |
| 89 |
(_UxCSelectFrame *) UxGetContext( UxThisWidget ); |
| 90 |
{ |
| 91 |
Widget text; |
| 92 |
extern swidget flist; |
| 93 |
extern char *filechoice; |
| 94 |
|
| 95 |
int tid,col,i,j,len,kun; |
| 96 |
char name[200],*nm; |
| 97 |
text = XmFileSelectionBoxGetChild(UxWidget,XmDIALOG_TEXT); |
| 98 |
/*XmTextSetString(text,"File List copied into table sel_temp.tbl ");*/ |
| 99 |
|
| 100 |
if (filechoice) { |
| 101 |
TCTINI("sel_temp",F_IO_MODE,F_TRANS,1,fno,&tid); |
| 102 |
TCCINI(tid,D_C_FORMAT,200,"A15"," ","FILE",&col); |
| 103 |
len = 0 ; |
| 104 |
for (i=0; i<fno; i++) { |
| 105 |
j = strloc(filechoice +len,','); |
| 106 |
filechoice[len+j] = '\0'; |
| 107 |
j++; |
| 108 |
strcpy(name,filechoice+len); |
| 109 |
|
| 110 |
len += j; |
| 111 |
TCEWRC(tid,i+1,col,name); |
| 112 |
} |
| 113 |
TCTCLO(tid); |
| 114 |
UxPutText(UxFindSwidget("ost_t2"),"sel_temp.tbl"); |
| 115 |
} |
| 116 |
else { |
| 117 |
nm = XmTextGetString(text); |
| 118 |
UxPutText(UxFindSwidget("ost_t2"),nm); |
| 119 |
|
| 120 |
SCKWRC("INPUTC",1,"lola",1,4,&kun); |
| 121 |
} |
| 122 |
UxPopdownInterface(flist); |
| 123 |
} |
| 124 |
UxSelectFrameContext = UxSaveCtx; |
| 125 |
} |
| 126 |
|
| 127 |
static void applyCB_SelectFrame( UxWidget, UxClientData, UxCallbackArg ) |
| 128 |
Widget UxWidget; |
| 129 |
XtPointer UxClientData, UxCallbackArg; |
| 130 |
{ |
| 131 |
_UxCSelectFrame *UxSaveCtx, *UxContext; |
| 132 |
swidget UxThisWidget; |
| 133 |
|
| 134 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 135 |
UxSaveCtx = UxSelectFrameContext; |
| 136 |
UxSelectFrameContext = UxContext = |
| 137 |
(_UxCSelectFrame *) UxGetContext( UxThisWidget ); |
| 138 |
{ |
| 139 |
/*XmFileSelectionBoxCallbackStruct *cbs; |
| 140 |
char *filename; |
| 141 |
XmStringGetLtoR(cbs->value,XmSTRING_DEFAULT_CHARSET,&filename); |
| 142 |
printf("Filename: %s \n",filename); |
| 143 |
XtFree(filename);*/ |
| 144 |
} |
| 145 |
UxSelectFrameContext = UxSaveCtx; |
| 146 |
} |
| 147 |
|
| 148 |
static void createCB_SelectFrame( UxWidget, UxClientData, UxCallbackArg ) |
| 149 |
Widget UxWidget; |
| 150 |
XtPointer UxClientData, UxCallbackArg; |
| 151 |
{ |
| 152 |
_UxCSelectFrame *UxSaveCtx, *UxContext; |
| 153 |
swidget UxThisWidget; |
| 154 |
|
| 155 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 156 |
UxSaveCtx = UxSelectFrameContext; |
| 157 |
UxSelectFrameContext = UxContext = |
| 158 |
(_UxCSelectFrame *) UxGetContext( UxThisWidget ); |
| 159 |
{ |
| 160 |
Widget fl,tl; |
| 161 |
|
| 162 |
fl = XmFileSelectionBoxGetChild(UxGetWidget(UxFindSwidget("SelectFrame")),XmDIALOG_FILE_LIST); |
| 163 |
tl = XmFileSelectionBoxGetChild(UxGetWidget(UxFindSwidget("SelectFrame")),XmDIALOG_TEXT); |
| 164 |
XmTextSetString(tl,""); |
| 165 |
|
| 166 |
XtVaSetValues(fl,XmNselectionPolicy,XmEXTENDED_SELECT,NULL); |
| 167 |
XtAddCallback(fl,XmNextendedSelectionCallback,my_select,NULL); |
| 168 |
} |
| 169 |
UxSelectFrameContext = UxSaveCtx; |
| 170 |
} |
| 171 |
|
| 172 |
/******************************************************************************* |
| 173 |
The 'init_' function sets the private properties for all the |
| 174 |
swidgets to the values specified in the Property Table. |
| 175 |
Some properties need to be set after the X widgets have been |
| 176 |
created and the setting of these properties is done in the |
| 177 |
'build_' function after the UxCreateWidget call. |
| 178 |
*******************************************************************************/ |
| 179 |
|
| 180 |
static void _Uxinit_SelectFrame() |
| 181 |
{ |
| 182 |
UxPutDirectoryValid( SelectFrame, "true" ); |
| 183 |
UxPutTextString( SelectFrame, "" ); |
| 184 |
UxPutBottomShadowColor( SelectFrame, ButtonBackground ); |
| 185 |
UxPutButtonFontList( SelectFrame, BoldTextFont ); |
| 186 |
UxPutTextFontList( SelectFrame, BoldTextFont ); |
| 187 |
UxPutLabelFontList( SelectFrame, BoldTextFont ); |
| 188 |
UxPutBackground( SelectFrame, WindowBackground ); |
| 189 |
UxPutHeight( SelectFrame, 400 ); |
| 190 |
UxPutWidth( SelectFrame, 350 ); |
| 191 |
UxPutY( SelectFrame, 330 ); |
| 192 |
UxPutX( SelectFrame, 370 ); |
| 193 |
UxPutUnitType( SelectFrame, "pixels" ); |
| 194 |
UxPutResizePolicy( SelectFrame, "resize_none" ); |
| 195 |
|
| 196 |
} |
| 197 |
|
| 198 |
/******************************************************************************* |
| 199 |
The 'build_' function creates all the swidgets and X widgets, |
| 200 |
and sets their properties to the values specified in the |
| 201 |
Property Editor. |
| 202 |
*******************************************************************************/ |
| 203 |
|
| 204 |
static swidget _Uxbuild_SelectFrame() |
| 205 |
{ |
| 206 |
/* Create the swidgets */ |
| 207 |
|
| 208 |
SelectFrame = UxCreateFileSelectionBox( "SelectFrame", NO_PARENT ); |
| 209 |
UxPutContext( SelectFrame, UxSelectFrameContext ); |
| 210 |
UxPutDefaultShell( SelectFrame, "topLevelShell" ); |
| 211 |
|
| 212 |
|
| 213 |
_Uxinit_SelectFrame(); |
| 214 |
|
| 215 |
/* Create the X widgets */ |
| 216 |
|
| 217 |
UxCreateWidget( SelectFrame ); |
| 218 |
createCB_SelectFrame( UxGetWidget( SelectFrame ), |
| 219 |
(XtPointer) UxSelectFrameContext, (XtPointer) NULL ); |
| 220 |
|
| 221 |
|
| 222 |
UxAddCallback( SelectFrame, XmNcancelCallback, |
| 223 |
cancelCB_SelectFrame, |
| 224 |
(XtPointer) UxSelectFrameContext ); |
| 225 |
UxAddCallback( SelectFrame, XmNokCallback, |
| 226 |
okCallback_SelectFrame, |
| 227 |
(XtPointer) UxSelectFrameContext ); |
| 228 |
UxAddCallback( SelectFrame, XmNapplyCallback, |
| 229 |
applyCB_SelectFrame, |
| 230 |
(XtPointer) UxSelectFrameContext ); |
| 231 |
|
| 232 |
|
| 233 |
/* Finally, call UxRealizeInterface to create the X windows |
| 234 |
for the widgets created above. */ |
| 235 |
|
| 236 |
UxRealizeInterface( SelectFrame ); |
| 237 |
|
| 238 |
return ( SelectFrame ); |
| 239 |
} |
| 240 |
|
| 241 |
/******************************************************************************* |
| 242 |
The following function includes the code that was entered |
| 243 |
in the 'Initial Code' and 'Final Code' sections of the |
| 244 |
Declarations Editor. This function is called from the |
| 245 |
'Interface function' below. |
| 246 |
*******************************************************************************/ |
| 247 |
|
| 248 |
static swidget _Ux_create_SelectFrame() |
| 249 |
{ |
| 250 |
swidget rtrn; |
| 251 |
_UxCSelectFrame *UxContext; |
| 252 |
|
| 253 |
UxSelectFrameContext = UxContext = |
| 254 |
(_UxCSelectFrame *) UxMalloc( sizeof(_UxCSelectFrame) ); |
| 255 |
|
| 256 |
{ |
| 257 |
filechoice = (char * )0; |
| 258 |
rtrn = _Uxbuild_SelectFrame(); |
| 259 |
|
| 260 |
return(rtrn); |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
/******************************************************************************* |
| 265 |
The following is the 'Interface function' which is the |
| 266 |
external entry point for creating this interface. |
| 267 |
This function should be called from your application or from |
| 268 |
a callback function. |
| 269 |
*******************************************************************************/ |
| 270 |
|
| 271 |
swidget create_SelectFrame() |
| 272 |
{ |
| 273 |
swidget _Uxrtrn; |
| 274 |
|
| 275 |
_Uxrtrn = _Ux_create_SelectFrame(); |
| 276 |
|
| 277 |
return ( _Uxrtrn ); |
| 278 |
} |
| 279 |
|
| 280 |
/******************************************************************************* |
| 281 |
END OF FILE |
| 282 |
*******************************************************************************/ |
| 283 |
|