Fix warnings on FreeBSD
[oweals/cde.git] / cde / programs / ttsnoop / argChooser_stubs.C.src
1 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
2 //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company
3 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.
4 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
5 //%%  (c) Copyright 1993, 1994 Novell, Inc.
6 //%%  $XConsortium: argChooser_stubs.C.src /main/3 1995/11/06 17:12:12 rswiston $
7 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
8
9 /*
10  * File: argChooser_stubs.c
11  * Contains: Module callbacks and connection functions
12  *
13  * This file was generated by dtcodegen, from module argChooser
14  *
15  * Any text may be added between the DTB_USER_CODE_START and
16  * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
17  * are provided only as an aid.
18  *
19  *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **
20  *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **
21  *  ** DELETE THE GENERATED COMMENTS!                                 **
22  */
23
24 #include <stdio.h>
25 #include <Xm/Xm.h>
26 #include "dtb_utils.h"
27 #include "argChooser_ui.h"
28
29 /*
30  * Header files for cross-module connections
31  */
32 #include "ttsnoop_ui.h"
33
34
35 /**************************************************************************
36  *** DTB_USER_CODE_START
37  ***
38  *** All necessary header files have been included.
39  ***
40  *** Add include files, types, macros, externs, and user functions here.
41  ***/
42
43 #include <Xm/Text.h>
44 #include <Xm/TextF.h>
45 #include <Dt/SpinBox.h>
46 #include "DtTt.h"
47
48 void
49 _DtArgChooserSet(
50         _DtArgChooserAction     choice,
51         void *                  entity,
52         int                     nth,
53         Tt_mode                 mode,
54         Boolean                 noValue,
55         char *                  vtype,
56         char *                  val,
57         int                     ival
58 )
59 {
60         DtbArgChooserArgChooserInfo instance =
61                 &dtb_arg_chooser_arg_chooser;
62         if (! instance->initialized) {
63                 dtb_arg_chooser_arg_chooser_initialize(
64                         instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
65         }
66         Widget modeChoice;
67         switch (mode) {
68             default:
69             case TT_IN:
70                 modeChoice = instance->modeChoice_items.IN_item;
71                 break;
72             case TT_OUT:
73                 modeChoice = instance->modeChoice_items.OUT_item;
74                 break;
75             case TT_INOUT:
76                 modeChoice = instance->modeChoice_items.INOUT_item;
77                 break;
78         }
79         XtVaSetValues( instance->modeChoice, XmNmenuHistory, modeChoice, NULL );
80
81         Widget valType = instance->argValTypeChoice_items.None_item;
82         if (! noValue) {
83                 if (val != 0) {
84                         valType = instance->
85                                 argValTypeChoice_items.char_item;
86                 } else {
87                         valType = instance->
88                                 argValTypeChoice_items.int_item;
89                 }
90         }
91         XtVaSetValues( instance->argValTypeChoice, XmNmenuHistory, valType, NULL);
92
93         XmTextFieldSetString( instance->vtypeText, vtype );
94         XtVaSetValues( instance->argIvalBox, DtNposition, ival, NULL );
95         XtVaSetValues( instance->argValText, XmNvalue, val, NULL );
96
97         _DtArgChooserSet( choice, entity, nth );
98 }
99
100 void
101 _DtArgChooserSet(
102         _DtArgChooserAction     choice,
103         void *                  entity,
104         int                     nth
105 )
106 {
107         Boolean vtypeActive = True;
108         Boolean modeActive = True;
109         char *vtypeLabel = "vtype:";
110         char *okString;
111         char *title;
112         switch (choice) {
113             case _DtArgChoosePatternArgAdd:
114             case _DtArgChoosePatternIArgAdd:
115                 okString = "Add";
116                 title = "tt_pattern_arg_add";
117                 break;
118             case _DtArgChoosePatternContextAdd:
119             case _DtArgChoosePatternIContextAdd:
120                 okString = "Add";
121                 title = "tt_pattern_context_add";
122                 modeActive = False;
123                 vtypeLabel = "slot:";
124                 break;
125             case _DtArgChooseMessageArgAdd:
126             case _DtArgChooseMessageIArgAdd:
127                 okString = "Add";
128                 title = "tt_message_arg_add";
129                 break;
130             case _DtArgChooseMessageArgSet:
131             case _DtArgChooseMessageIArgSet:
132                 okString = "Set";
133                 title = "tt_message_arg_val_set";
134                 vtypeActive = False;
135                 modeActive = False;
136                 break;
137             case _DtArgChooseMessageContextSet:
138             case _DtArgChooseMessageIContextSet:
139                 okString = "Set";
140                 title = "tt_message_context_set";
141                 modeActive = False;
142                 vtypeLabel = "slot:";
143                 break;
144             default:
145                 return;
146         }
147         DtbArgChooserArgChooserInfo instance =
148                 &dtb_arg_chooser_arg_chooser;
149         if (! instance->initialized) {
150                 dtb_arg_chooser_arg_chooser_initialize(
151                         instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin );
152         }
153
154         DtTtSetLabel( instance->argChooserOkButton, okString );
155         XtVaSetValues( instance->argChooser, XmNtitle, title, NULL );
156         DtTtSetLabel( instance->vtypeText_label, vtypeLabel );
157         XtSetSensitive( instance->vtypeText, vtypeActive );
158         XtSetSensitive( instance->modeChoice, modeActive );
159
160         // Remember dialog mode, entity, nth
161         XtVaSetValues( instance->argChooserOkButton, XmNuserData, choice, NULL );
162         XtVaSetValues( instance->argChooserCancelButton,
163                        XmNuserData, entity, NULL );
164         XtVaSetValues( instance->argChooserHelpButton, XmNuserData, nth, NULL );
165
166         if (vtypeActive) {
167                 // Pre-select vtype text
168                 XmTextPosition last =
169                         XmTextFieldGetLastPosition( instance->vtypeText );
170                 Time when = XtLastTimestampProcessed(
171                                 XtDisplay( instance->vtypeText ));
172                 XmTextFieldSetSelection( instance->vtypeText, 0, last, when );
173         }
174
175         XtManageChild( instance->argChooser_shellform );
176 }
177
178 /*** DTB_USER_CODE_END
179  ***
180  *** End of user code section
181  ***
182  **************************************************************************/
183
184
185
186 void 
187 argChooser_argValTypeChoice_None_item_CB1(
188     Widget widget,
189     XtPointer clientData,
190     XtPointer callData
191 )
192 {
193     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
194     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
195     
196     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
197     
198     if (!(instance->initialized))
199     {
200         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
201     }
202
203     XtSetSensitive(instance->argIvalBox, False);
204     
205     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
206     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
207 }
208
209
210 void 
211 argChooser_argValTypeChoice_char_item_CB1(
212     Widget widget,
213     XtPointer clientData,
214     XtPointer callData
215 )
216 {
217     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
218     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
219     
220     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
221     
222     if (!(instance->initialized))
223     {
224         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
225     }
226
227     XtSetSensitive(instance->argIvalBox, False);
228     
229     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
230     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
231 }
232
233
234 void 
235 argChooser_argValTypeChoice_int_item_CB1(
236     Widget widget,
237     XtPointer clientData,
238     XtPointer callData
239 )
240 {
241     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
242     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
243     
244     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
245     
246     if (!(instance->initialized))
247     {
248         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
249     }
250
251     XtSetSensitive(instance->argIvalBox, True);
252     
253     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
254     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
255 }
256
257
258 void 
259 argChooser_argChooserOkButton_CB1(
260     Widget widget,
261     XtPointer clientData,
262     XtPointer callData
263 )
264 {
265     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
266     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
267     
268     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
269     
270     if (!(instance->initialized))
271     {
272         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
273     }
274     XtUnmanageChild(instance->argChooser_shellform);
275     
276     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
277     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
278 }
279
280
281 void 
282 argChooser_argChooserCancelButton_CB1(
283     Widget widget,
284     XtPointer clientData,
285     XtPointer callData
286 )
287 {
288     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
289     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
290     
291     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
292     
293     if (!(instance->initialized))
294     {
295         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
296     }
297     XtUnmanageChild(instance->argChooser_shellform);
298     
299     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
300     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
301 }
302
303
304 void 
305 argChooser_argValTypeChoice_None_item_CB2(
306     Widget widget,
307     XtPointer clientData,
308     XtPointer callData
309 )
310 {
311     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
312     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
313     
314     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
315     
316     if (!(instance->initialized))
317     {
318         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
319     }
320
321     XtSetSensitive(instance->argValText, False);
322     
323     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
324     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
325 }
326
327
328 void 
329 argChooser_argValTypeChoice_int_item_CB2(
330     Widget widget,
331     XtPointer clientData,
332     XtPointer callData
333 )
334 {
335     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
336     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
337     
338     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
339     
340     if (!(instance->initialized))
341     {
342         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
343     }
344
345     XtSetSensitive(instance->argValText, False);
346     
347     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
348     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
349 }
350
351
352 void 
353 argChooser_argValTypeChoice_char_item_CB2(
354     Widget widget,
355     XtPointer clientData,
356     XtPointer callData
357 )
358 {
359     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
360     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
361     
362     DtbArgChooserArgChooserInfo instance = (DtbArgChooserArgChooserInfo)clientData;
363     
364     if (!(instance->initialized))
365     {
366         dtb_arg_chooser_arg_chooser_initialize(instance, dtb_ttsnoop_ttsnoop_win.ttsnoopWin);
367     }
368
369     XtSetSensitive(instance->argValText, True);
370     
371     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
372     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
373 }
374
375
376 void 
377 argOkayed(
378     Widget widget,
379     XtPointer clientData,
380     XtPointer callData
381 )
382 {
383     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
384     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
385     
386     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
387     DtbArgChooserArgChooserInfo instance =
388             (DtbArgChooserArgChooserInfo)clientData;
389
390     int nth = 0;
391     Tt_message msg = 0;
392     Tt_pattern pat = 0;
393     _DtArgChooserAction choice = _DtArgChooseNone;
394
395     XtPointer pval;
396     XtVaGetValues( instance->argChooserOkButton, XmNuserData, &pval, NULL );
397     choice = (_DtArgChooserAction) (long) pval;
398     XtVaGetValues( instance->argChooserCancelButton, XmNuserData, &pval, NULL );
399     msg = (Tt_message)pval;
400     pat = (Tt_pattern)pval;
401     XtVaGetValues( instance->argChooserHelpButton, XmNuserData, &pval, NULL );
402     nth = (int) (long) pval;
403
404     char *vtype = XmTextFieldGetString( instance->vtypeText );
405     if ((vtype != 0) && (vtype[0] == '\0')) {
406             XtFree( vtype );
407             vtype = 0;
408     }
409
410     Widget modeWidget;
411     XtVaGetValues( instance->modeChoice, XmNmenuHistory, &modeWidget, NULL );
412     Tt_mode mode = TT_IN;
413     if (modeWidget == instance->modeChoice_items.OUT_item) {
414             mode = TT_OUT;
415     } else if (modeWidget == instance->modeChoice_items.INOUT_item) {
416             mode = TT_INOUT;
417     }
418
419     char *val = 0;
420     int ival = 0;
421     Widget valTypeWidget;
422     XtVaGetValues( instance->argValTypeChoice,
423                    XmNmenuHistory, &valTypeWidget, NULL );
424     if (valTypeWidget == instance->argValTypeChoice_items.char_item) {
425             val = XmTextGetString( instance->argValText );
426     } else if (valTypeWidget == instance->argValTypeChoice_items.int_item) {
427             // see _DtArgChooserAction invariant in DtTt.h
428             choice = (_DtArgChooserAction)(choice + 1);
429             XtVaGetValues( instance->argIvalBox, DtNposition, &ival, NULL );
430     }
431
432     switch (choice) {
433             Tt_status status;
434         case _DtArgChooseMessageArgAdd:
435         case _DtArgChooseMessageIArgAdd:
436         case _DtArgChooseMessageArgSet:
437         case _DtArgChooseMessageIArgSet:
438         case _DtArgChooseMessageContextSet:
439         case _DtArgChooseMessageIContextSet:
440             _DtTtMessageUpdate( msg, choice, nth, mode, vtype, val, ival );
441         case _DtArgChoosePatternArgAdd:
442         case _DtArgChoosePatternIArgAdd:
443         case _DtArgChoosePatternContextAdd:
444         case _DtArgChoosePatternIContextAdd:
445             _DtTtPatternUpdate( pat, choice, mode, vtype, val, ival );
446             break;
447         default:
448             break;
449     }
450     if (vtype != 0) XtFree( vtype );
451     if (val != 0) XtFree( val );
452     XtUnmanageChild(instance->argChooser_shellform);
453     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
454 }
455
456
457 void 
458 argHelp(
459     Widget widget,
460     XtPointer clientData,
461     XtPointer callData
462 )
463 {
464     /*** DTB_USER_CODE_START vvv Add C variables and code below vvv ***/
465     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
466     
467     /*** DTB_USER_CODE_START vvv Add C code below vvv ***/
468     DtbArgChooserArgChooserInfo instance =
469             (DtbArgChooserArgChooserInfo)clientData;
470     XtPointer val;
471     XtVaGetValues( instance->argChooserOkButton, XmNuserData, &val, NULL );
472     _DtArgChooserAction choice = (_DtArgChooserAction) (long) val;
473     Widget label = dtb_ttsnoop_ttsnoop_win.ttsnoopWin_label;
474     switch (choice) {
475         case _DtArgChoosePatternArgAdd:
476         case _DtArgChoosePatternIArgAdd:
477             _DtMan( label, "tt_pattern_arg_add" );
478             break;
479         case _DtArgChoosePatternContextAdd:
480         case _DtArgChoosePatternIContextAdd:
481             _DtMan( label, "tt_pattern_context_add" );
482             break;
483         case _DtArgChooseMessageArgAdd:
484         case _DtArgChooseMessageIArgAdd:
485             _DtMan( label, "tt_message_arg_add" );
486             break;
487         case _DtArgChooseMessageArgSet:
488         case _DtArgChooseMessageIArgSet:
489             _DtMan( label, "tt_message_arg_val_set" );
490             break;
491         case _DtArgChooseMessageContextSet:
492         case _DtArgChooseMessageIContextSet:
493             _DtMan( label, "tt_message_context_set" );
494             break;
495         default:
496             break;
497     }
498     /*** DTB_USER_CODE_END   ^^^ Add C code above ^^^ ***/
499 }
500
501
502
503 /**************************************************************************
504  *** DTB_USER_CODE_START
505  ***
506  *** All automatically-generated data and functions have been defined.
507  ***
508  *** Add new functions here, or at the top of the file.
509  ***/
510
511 /*** DTB_USER_CODE_END
512  ***
513  *** End of user code section
514  ***
515  **************************************************************************/
516
517