| 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 |
file_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 "UxPushB.h" |
| 42 |
#include "UxForm.h" |
| 43 |
#include "UxTopSh.h" |
| 44 |
|
| 45 |
/******************************************************************************* |
| 46 |
Includes, Defines, and Global variables from the Declarations Editor: |
| 47 |
*******************************************************************************/ |
| 48 |
|
| 49 |
#include <ExternResources.h> |
| 50 |
|
| 51 |
/******************************************************************************* |
| 52 |
The definition of the context structure: |
| 53 |
If you create multiple instances of your interface, the context |
| 54 |
structure ensures that your callbacks use the variables for the |
| 55 |
correct instance. |
| 56 |
|
| 57 |
For each swidget in the interface, each argument to the Interface |
| 58 |
function, and each variable in the Instance Specific section of the |
| 59 |
Declarations Editor, there is an entry in the context structure. |
| 60 |
and a #define. The #define makes the variable name refer to the |
| 61 |
corresponding entry in the context structure. |
| 62 |
*******************************************************************************/ |
| 63 |
|
| 64 |
typedef struct |
| 65 |
{ |
| 66 |
swidget Uxfile_list; |
| 67 |
swidget Uxform6; |
| 68 |
swidget UxpushButton9; |
| 69 |
swidget UxscrolledWindow1; |
| 70 |
swidget Uxsl_file_list; |
| 71 |
} _UxCfile_list; |
| 72 |
|
| 73 |
#define file_list UxFile_listContext->Uxfile_list |
| 74 |
#define form6 UxFile_listContext->Uxform6 |
| 75 |
#define pushButton9 UxFile_listContext->UxpushButton9 |
| 76 |
#define scrolledWindow1 UxFile_listContext->UxscrolledWindow1 |
| 77 |
#define sl_file_list UxFile_listContext->Uxsl_file_list |
| 78 |
|
| 79 |
static _UxCfile_list *UxFile_listContext; |
| 80 |
|
| 81 |
extern void ChoiceList(); |
| 82 |
|
| 83 |
|
| 84 |
/******************************************************************************* |
| 85 |
Forward declarations of functions that are defined later in this file. |
| 86 |
*******************************************************************************/ |
| 87 |
|
| 88 |
swidget create_file_list(); |
| 89 |
|
| 90 |
/******************************************************************************* |
| 91 |
The following are callback functions. |
| 92 |
*******************************************************************************/ |
| 93 |
|
| 94 |
static void activateCB_pushButton9( UxWidget, UxClientData, UxCallbackArg ) |
| 95 |
Widget UxWidget; |
| 96 |
XtPointer UxClientData, UxCallbackArg; |
| 97 |
{ |
| 98 |
_UxCfile_list *UxSaveCtx, *UxContext; |
| 99 |
swidget UxThisWidget; |
| 100 |
|
| 101 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 102 |
UxSaveCtx = UxFile_listContext; |
| 103 |
UxFile_listContext = UxContext = |
| 104 |
(_UxCfile_list *) UxGetContext( UxThisWidget ); |
| 105 |
{ |
| 106 |
extern swidget FileListInterface; |
| 107 |
|
| 108 |
UxPopdownInterface(FileListInterface); |
| 109 |
} |
| 110 |
UxFile_listContext = UxSaveCtx; |
| 111 |
} |
| 112 |
|
| 113 |
static void createCB_sl_file_list( UxWidget, UxClientData, UxCallbackArg ) |
| 114 |
Widget UxWidget; |
| 115 |
XtPointer UxClientData, UxCallbackArg; |
| 116 |
{ |
| 117 |
_UxCfile_list *UxSaveCtx, *UxContext; |
| 118 |
swidget UxThisWidget; |
| 119 |
|
| 120 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 121 |
UxSaveCtx = UxFile_listContext; |
| 122 |
UxFile_listContext = UxContext = |
| 123 |
(_UxCfile_list *) UxGetContext( UxThisWidget ); |
| 124 |
{ |
| 125 |
extern Widget FileListWidget; |
| 126 |
|
| 127 |
FileListWidget = UxWidget; |
| 128 |
} |
| 129 |
UxFile_listContext = UxSaveCtx; |
| 130 |
} |
| 131 |
|
| 132 |
static void browseSelectionCB_sl_file_list( UxWidget, UxClientData, UxCallbackArg ) |
| 133 |
Widget UxWidget; |
| 134 |
XtPointer UxClientData, UxCallbackArg; |
| 135 |
{ |
| 136 |
_UxCfile_list *UxSaveCtx, *UxContext; |
| 137 |
swidget UxThisWidget; |
| 138 |
|
| 139 |
UxThisWidget = UxWidgetToSwidget( UxWidget ); |
| 140 |
UxSaveCtx = UxFile_listContext; |
| 141 |
UxFile_listContext = UxContext = |
| 142 |
(_UxCfile_list *) UxGetContext( UxThisWidget ); |
| 143 |
{ |
| 144 |
char *choice; |
| 145 |
XmListCallbackStruct *cbs; |
| 146 |
|
| 147 |
cbs = (XmListCallbackStruct *)UxCallbackArg; |
| 148 |
XmStringGetLtoR(cbs->item, XmSTRING_DEFAULT_CHARSET, &choice); |
| 149 |
|
| 150 |
ChoiceList(choice); |
| 151 |
|
| 152 |
} |
| 153 |
UxFile_listContext = UxSaveCtx; |
| 154 |
} |
| 155 |
|
| 156 |
/******************************************************************************* |
| 157 |
The 'init_' function sets the private properties for all the |
| 158 |
swidgets to the values specified in the Property Table. |
| 159 |
Some properties need to be set after the X widgets have been |
| 160 |
created and the setting of these properties is done in the |
| 161 |
'build_' function after the UxCreateWidget call. |
| 162 |
*******************************************************************************/ |
| 163 |
|
| 164 |
static void _Uxinit_file_list() |
| 165 |
{ |
| 166 |
UxPutTitle( file_list, "List selection" ); |
| 167 |
UxPutGeometry( file_list, "+100+100" ); |
| 168 |
UxPutBackground( file_list, "AntiqueWhite" ); |
| 169 |
UxPutKeyboardFocusPolicy( file_list, "pointer" ); |
| 170 |
UxPutIconName( file_list, "List selection" ); |
| 171 |
UxPutHeight( file_list, 353 ); |
| 172 |
UxPutWidth( file_list, 260 ); |
| 173 |
UxPutY( file_list, 321 ); |
| 174 |
UxPutX( file_list, 302 ); |
| 175 |
|
| 176 |
UxPutBackground( form6, ApplicBackground ); |
| 177 |
UxPutHeight( form6, 352 ); |
| 178 |
UxPutWidth( form6, 214 ); |
| 179 |
UxPutY( form6, 0 ); |
| 180 |
UxPutX( form6, 0 ); |
| 181 |
UxPutUnitType( form6, "pixels" ); |
| 182 |
UxPutResizePolicy( form6, "resize_none" ); |
| 183 |
|
| 184 |
UxPutForeground( pushButton9, ButtonForeground ); |
| 185 |
UxPutLabelString( pushButton9, "Cancel" ); |
| 186 |
UxPutFontList( pushButton9, BoldTextFont ); |
| 187 |
UxPutBackground( pushButton9, ButtonBackground ); |
| 188 |
UxPutHeight( pushButton9, 35 ); |
| 189 |
UxPutWidth( pushButton9, 260 ); |
| 190 |
UxPutY( pushButton9, 318 ); |
| 191 |
UxPutX( pushButton9, 0 ); |
| 192 |
|
| 193 |
UxPutWidth( scrolledWindow1, 270 ); |
| 194 |
UxPutHeight( scrolledWindow1, 316 ); |
| 195 |
UxPutBackground( scrolledWindow1, ListBackground ); |
| 196 |
UxPutScrollBarPlacement( scrolledWindow1, "bottom_left" ); |
| 197 |
UxPutShadowThickness( scrolledWindow1, 0 ); |
| 198 |
UxPutScrollBarDisplayPolicy( scrolledWindow1, "static" ); |
| 199 |
UxPutVisualPolicy( scrolledWindow1, "variable" ); |
| 200 |
UxPutY( scrolledWindow1, 2 ); |
| 201 |
UxPutX( scrolledWindow1, 21 ); |
| 202 |
UxPutScrollingPolicy( scrolledWindow1, "application_defined" ); |
| 203 |
|
| 204 |
UxPutForeground( sl_file_list, ListForeground ); |
| 205 |
UxPutVisibleItemCount( sl_file_list, 19 ); |
| 206 |
UxPutFontList( sl_file_list, SmallFont ); |
| 207 |
UxPutBackground( sl_file_list, TextBackground ); |
| 208 |
UxPutListSizePolicy( sl_file_list, "variable" ); |
| 209 |
UxPutScrollBarDisplayPolicy( sl_file_list, "static" ); |
| 210 |
UxPutHeight( sl_file_list, 316 ); |
| 211 |
UxPutWidth( sl_file_list, 191 ); |
| 212 |
|
| 213 |
} |
| 214 |
|
| 215 |
/******************************************************************************* |
| 216 |
The 'build_' function creates all the swidgets and X widgets, |
| 217 |
and sets their properties to the values specified in the |
| 218 |
Property Editor. |
| 219 |
*******************************************************************************/ |
| 220 |
|
| 221 |
static swidget _Uxbuild_file_list() |
| 222 |
{ |
| 223 |
/* Create the swidgets */ |
| 224 |
|
| 225 |
file_list = UxCreateTopLevelShell( "file_list", NO_PARENT ); |
| 226 |
UxPutContext( file_list, UxFile_listContext ); |
| 227 |
|
| 228 |
form6 = UxCreateForm( "form6", file_list ); |
| 229 |
pushButton9 = UxCreatePushButton( "pushButton9", form6 ); |
| 230 |
scrolledWindow1 = UxCreateScrolledWindow( "scrolledWindow1", form6 ); |
| 231 |
sl_file_list = UxCreateScrolledList( "sl_file_list", scrolledWindow1 ); |
| 232 |
|
| 233 |
_Uxinit_file_list(); |
| 234 |
|
| 235 |
/* Create the X widgets */ |
| 236 |
|
| 237 |
UxCreateWidget( file_list ); |
| 238 |
UxCreateWidget( form6 ); |
| 239 |
UxCreateWidget( pushButton9 ); |
| 240 |
UxPutLeftOffset( scrolledWindow1, 2 ); |
| 241 |
UxPutLeftAttachment( scrolledWindow1, "attach_form" ); |
| 242 |
UxPutRightOffset( scrolledWindow1, 2 ); |
| 243 |
UxPutRightAttachment( scrolledWindow1, "attach_form" ); |
| 244 |
UxCreateWidget( scrolledWindow1 ); |
| 245 |
|
| 246 |
UxCreateWidget( sl_file_list ); |
| 247 |
createCB_sl_file_list( UxGetWidget( sl_file_list ), |
| 248 |
(XtPointer) UxFile_listContext, (XtPointer) NULL ); |
| 249 |
|
| 250 |
|
| 251 |
UxAddCallback( pushButton9, XmNactivateCallback, |
| 252 |
activateCB_pushButton9, |
| 253 |
(XtPointer) UxFile_listContext ); |
| 254 |
|
| 255 |
UxAddCallback( sl_file_list, XmNbrowseSelectionCallback, |
| 256 |
browseSelectionCB_sl_file_list, |
| 257 |
(XtPointer) UxFile_listContext ); |
| 258 |
|
| 259 |
|
| 260 |
/* Finally, call UxRealizeInterface to create the X windows |
| 261 |
for the widgets created above. */ |
| 262 |
|
| 263 |
UxRealizeInterface( file_list ); |
| 264 |
|
| 265 |
return ( file_list ); |
| 266 |
} |
| 267 |
|
| 268 |
/******************************************************************************* |
| 269 |
The following function includes the code that was entered |
| 270 |
in the 'Initial Code' and 'Final Code' sections of the |
| 271 |
Declarations Editor. This function is called from the |
| 272 |
'Interface function' below. |
| 273 |
*******************************************************************************/ |
| 274 |
|
| 275 |
static swidget _Ux_create_file_list() |
| 276 |
{ |
| 277 |
swidget rtrn; |
| 278 |
_UxCfile_list *UxContext; |
| 279 |
|
| 280 |
UxFile_listContext = UxContext = |
| 281 |
(_UxCfile_list *) UxMalloc( sizeof(_UxCfile_list) ); |
| 282 |
|
| 283 |
rtrn = _Uxbuild_file_list(); |
| 284 |
|
| 285 |
return(rtrn); |
| 286 |
} |
| 287 |
|
| 288 |
/******************************************************************************* |
| 289 |
The following is the 'Interface function' which is the |
| 290 |
external entry point for creating this interface. |
| 291 |
This function should be called from your application or from |
| 292 |
a callback function. |
| 293 |
*******************************************************************************/ |
| 294 |
|
| 295 |
swidget create_file_list() |
| 296 |
{ |
| 297 |
swidget _Uxrtrn; |
| 298 |
|
| 299 |
_Uxrtrn = _Ux_create_file_list(); |
| 300 |
|
| 301 |
return ( _Uxrtrn ); |
| 302 |
} |
| 303 |
|
| 304 |
/******************************************************************************* |
| 305 |
END OF FILE |
| 306 |
*******************************************************************************/ |
| 307 |
|