Debian Codegraph @

gui/XEchelle/src/file_selection.c

raw
1 /* @(#)file_selection.c 19.1 (ES0-DMD) 02/25/03 13:45:59 */
2 /*===========================================================================
3 Copyright (C) 1995 European Southern Observatory (ESO)
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free
17 Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
18 MA 02139, USA.
19
20 Corresponding concerning ESO-MIDAS should be addressed as follows:
21 Internet e-mail: [email protected]
22 Postal address: European Southern Observatory
23 Data Management Division
24 Karl-Schwarzschild-Strasse 2
25 D 85748 Garching bei Muenchen
26 GERMANY
27 ===========================================================================*/
28
29
30 /*******************************************************************************
31 file_selection.c
32
33 *******************************************************************************/
34
35 #include <stdio.h>
36 #include "UxLib.h"
37 #include "UxFsBox.h"
38 #include "UxApplSh.h"
39
40 /*******************************************************************************
41 Includes, Defines, and Global variables from the Declarations Editor:
42 *******************************************************************************/
43
44 #include <ExternResources.h>
45
46 /*******************************************************************************
47 The definition of the context structure:
48 If you create multiple instances of your interface, the context
49 structure ensures that your callbacks use the variables for the
50 correct instance.
51
52 For each swidget in the interface, each argument to the Interface
53 function, and each variable in the Instance Specific section of the
54 Declarations Editor, there is an entry in the context structure.
55 and a #define. The #define makes the variable name refer to the
56 corresponding entry in the context structure.
57 *******************************************************************************/
58
59 typedef struct
60 {
61 swidget Uxfile_selection;
62 swidget Uxfb_file_selection;
63 } _UxCfile_selection;
64
65 #define file_selection UxFile_selectionContext->Uxfile_selection
66 #define fb_file_selection UxFile_selectionContext->Uxfb_file_selection
67
68 static _UxCfile_selection *UxFile_selectionContext;
69
70
71 /*******************************************************************************
72 Forward declarations of functions that are defined later in this file.
73 *******************************************************************************/
74
75 swidget create_file_selection();
76
77 /*******************************************************************************
78 The following are callback functions.
79 *******************************************************************************/
80
81 static void cancelCB_fb_file_selection( UxWidget, UxClientData, UxCallbackArg )
82 Widget UxWidget;
83 XtPointer UxClientData, UxCallbackArg;
84 {
85 _UxCfile_selection *UxSaveCtx, *UxContext;
86 swidget UxThisWidget;
87
88 UxThisWidget = UxWidgetToSwidget( UxWidget );
89 UxSaveCtx = UxFile_selectionContext;
90 UxFile_selectionContext = UxContext =
91 (_UxCfile_selection *) UxGetContext( UxThisWidget );
92 {
93 extern swidget FileListInterface;
94 UxPopdownInterface (FileListInterface);
95 }
96 UxFile_selectionContext = UxSaveCtx;
97 }
98
99 static void okCallback_fb_file_selection( UxWidget, UxClientData, UxCallbackArg )
100 Widget UxWidget;
101 XtPointer UxClientData, UxCallbackArg;
102 {
103 _UxCfile_selection *UxSaveCtx, *UxContext;
104 swidget UxThisWidget;
105
106 UxThisWidget = UxWidgetToSwidget( UxWidget );
107 UxSaveCtx = UxFile_selectionContext;
108 UxFile_selectionContext = UxContext =
109 (_UxCfile_selection *) UxGetContext( UxThisWidget );
110 {
111 char s[128];
112 extern swidget TextFieldSwidget;
113 extern int FillTextField;
114
115 strcpy(s, UxGetTextString(UxThisWidget));
116 if ( FillTextField )
117 UxPutValue(TextFieldSwidget, s);
118 UxPopdownInterface(UxThisWidget);
119 }
120 UxFile_selectionContext = UxSaveCtx;
121 }
122
123 /*******************************************************************************
124 The 'init_' function sets the private properties for all the
125 swidgets to the values specified in the Property Table.
126 Some properties need to be set after the X widgets have been
127 created and the setting of these properties is done in the
128 'build_' function after the UxCreateWidget call.
129 *******************************************************************************/
130
131 static void _Uxinit_file_selection()
132 {
133 UxPutBackground( file_selection, ApplicBackground );
134 UxPutKeyboardFocusPolicy( file_selection, "pointer" );
135 UxPutDefaultFontList( file_selection, SmallFont );
136 UxPutTitle( file_selection, "List selection" );
137 UxPutIconName( file_selection, "List selection" );
138 UxPutGeometry( file_selection, "+100+100" );
139 UxPutHeight( file_selection, 320 );
140 UxPutWidth( file_selection, 346 );
141 UxPutY( file_selection, 388 );
142 UxPutX( file_selection, 612 );
143
144 UxPutListVisibleItemCount( fb_file_selection, 3 );
145 UxPutMinimizeButtons( fb_file_selection, "false" );
146 UxPutLabelFontList( fb_file_selection, BoldTextFont );
147 UxPutTextFontList( fb_file_selection, TextFont );
148 UxPutButtonFontList( fb_file_selection, BoldTextFont );
149 UxPutForeground( fb_file_selection, TextForeground );
150 UxPutBackground( fb_file_selection, WindowBackground );
151 UxPutHeight( fb_file_selection, 300 );
152 UxPutWidth( fb_file_selection, 345 );
153 UxPutUnitType( fb_file_selection, "pixels" );
154 UxPutResizePolicy( fb_file_selection, "resize_none" );
155
156 }
157
158 /*******************************************************************************
159 The 'build_' function creates all the swidgets and X widgets,
160 and sets their properties to the values specified in the
161 Property Editor.
162 *******************************************************************************/
163
164 static swidget _Uxbuild_file_selection()
165 {
166 /* Create the swidgets */
167
168 file_selection = UxCreateApplicationShell( "file_selection", NO_PARENT );
169 UxPutContext( file_selection, UxFile_selectionContext );
170
171 fb_file_selection = UxCreateFileSelectionBox( "fb_file_selection", file_selection );
172
173 _Uxinit_file_selection();
174
175 /* Create the X widgets */
176
177 UxCreateWidget( file_selection );
178 UxCreateWidget( fb_file_selection );
179
180 UxAddCallback( fb_file_selection, XmNcancelCallback,
181 cancelCB_fb_file_selection,
182 (XtPointer) UxFile_selectionContext );
183 UxAddCallback( fb_file_selection, XmNokCallback,
184 okCallback_fb_file_selection,
185 (XtPointer) UxFile_selectionContext );
186
187
188 /* Finally, call UxRealizeInterface to create the X windows
189 for the widgets created above. */
190
191 UxRealizeInterface( file_selection );
192
193 return ( file_selection );
194 }
195
196 /*******************************************************************************
197 The following function includes the code that was entered
198 in the 'Initial Code' and 'Final Code' sections of the
199 Declarations Editor. This function is called from the
200 'Interface function' below.
201 *******************************************************************************/
202
203 static swidget _Ux_create_file_selection()
204 {
205 swidget rtrn;
206 _UxCfile_selection *UxContext;
207
208 UxFile_selectionContext = UxContext =
209 (_UxCfile_selection *) UxMalloc( sizeof(_UxCfile_selection) );
210
211 rtrn = _Uxbuild_file_selection();
212
213 return(rtrn);
214 }
215
216 /*******************************************************************************
217 The following is the 'Interface function' which is the
218 external entry point for creating this interface.
219 This function should be called from your application or from
220 a callback function.
221 *******************************************************************************/
222
223 swidget create_file_selection()
224 {
225 swidget _Uxrtrn;
226
227 _Uxrtrn = _Ux_create_file_selection();
228
229 return ( _Uxrtrn );
230 }
231
232 /*******************************************************************************
233 END OF FILE
234 *******************************************************************************/
235