~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/Xv/tw_dchoice.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <math.h>
  5 #include <tina/sys.h>
  6 #include <tina/math.h>
  7 #include <tina/tw.h>
  8 #include <tina/tv.h>
  9 #include <tina/tvfuncs.h>
 10 #include <tina/tv_screen.h>
 11 #include <xview/xview.h>
 12 #include <xview/frame.h>
 13 #include <xview/panel.h>
 14 #include <xview/textsw.h>
 15 #include <xview/font.h>
 16 #include <xview/canvas.h>
 17 #include <xview/cms.h>
 18 #include <xview/xv_xrect.h>
 19 #include <xview/openmenu.h>
 20 #include <tina/Xvfuncs.h>
 21 #include <tina/X11funcs.h>
 22 
 23 
 24 
 25 static void choice_call(Tw_callback * twc)
 26 {
 27     int     value = (int) twc->data1;
 28     void   *data = twc->data2;
 29 
 30     (*twc->func) (value, data);
 31 }
 32 
 33 static void choice_cmnd(Tw_callback * twc, char *args)
 34 {
 35     int     value;
 36     void   *data = twc->data2;
 37 
 38     (void) sscanf(args, "%*s %d", &value);
 39     twc->data1 = (void *) value;
 40     (*twc->func) (value, data);
 41 
 42     xv_set(twc->window, PANEL_VALUE, value, NULL);
 43 }
 44 
 45 static void choice_prnt(FILE * fp, Tw_callback * twc)
 46 {
 47     int     value = (int) twc->data1;
 48 
 49     (void) fprintf(fp, "%s %d %d\n", twc->name, value);
 50 }
 51 
 52 #ifndef ANSIFYING
 53 #ifdef __STRICT_ANSI__
 54 
 55 void    tw_data_choice(char *name,...)
 56 {
 57     va_list ap;
 58     void    (*func) ();
 59     int     value;
 60     void   *data;
 61     char   *names[10];
 62     Panel_item choice;
 63     Panel   panel = tw_get_panel();
 64     Bool    newrow = tw_get_newrow();
 65     int     i, row;
 66     Tw_callback *twc;
 67     char   *fullname;
 68 
 69     panel = tw_get_panel();
 70     newrow = tw_get_newrow();
 71 
 72     for (i = 0; i < 10; i++)
 73         names[i] = NULL;
 74 
 75     va_start(ap, name);
 76 
 77     func = (void (*) ()) va_arg(ap, void *);
 78     value = va_arg(ap, int);
 79     data = va_arg(ap, void *);
 80 
 81     for (i = 0; (names[i] = va_arg(ap, char *)) != NULL; i++);
 82     va_end(ap);
 83 
 84     choice = (Panel_item) xv_create(panel, PANEL_CHOICE,
 85                                     PANEL_CHOOSE_ONE, TRUE,
 86                                     PANEL_VALUE, value,
 87                                     PANEL_LABEL_STRING, name,
 88                                     PANEL_CHOICE_STRINGS,
 89                      names[0], names[1], names[2], names[3], names[4],
 90                names[5], names[6], names[7], names[8], names[9], NULL,
 91                                     NULL);
 92 
 93     fullname = tw_extend_fullname(tw_get_toolname(), name);
 94     twc = tw_callback_make(fullname, choice,
 95                            choice_call, choice_cmnd, choice_prnt, func, (void *) value, (void *) data);
 96 
 97     xv_set(choice,
 98            PANEL_NOTIFY_PROC, tw_panel_callback,
 99            PANEL_CLIENT_DATA, twc,
100            NULL);
101 
102     if (newrow)
103     {
104         row = tw_get_row();
105         xv_set(choice,
106                XV_X, xv_col(panel, 0),
107                XV_Y, xv_row(panel, row),
108                NULL);
109         tw_set_newrow(false);
110     }
111     (*func) (value, data);
112 }
113 
114 #else
115 
116 void    tw_data_choice(va_alist) va_dcl
117 {
118     va_list ap;
119     void    (*func) ();
120     int     value;
121     void   *data;
122     char   *name, *names[10];
123     Panel_item choice;
124     Panel   panel = tw_get_panel();
125     Bool    newrow = tw_get_newrow();
126     int     i, row;
127     Tw_callback *twc;
128     char   *fullname;
129 
130     panel = tw_get_panel();
131     newrow = tw_get_newrow();
132 
133     for (i = 0; i < 10; i++)
134         names[i] = NULL;
135 
136     va_start(ap);
137     name = va_arg(ap, char *);
138     func = (void (*) ()) va_arg(ap, void *);
139     value = va_arg(ap, int);
140     data = va_arg(ap, void *);
141 
142     for (i = 0; (names[i] = va_arg(ap, char *)) != NULL; i++);
143     va_end(ap);
144 
145     choice = (Panel_item) xv_create(panel, PANEL_CHOICE,
146                                     PANEL_CHOOSE_ONE, TRUE,
147                                     PANEL_VALUE, value,
148                                     PANEL_LABEL_STRING, name,
149                                     PANEL_CHOICE_STRINGS,
150                      names[0], names[1], names[2], names[3], names[4],
151                names[5], names[6], names[7], names[8], names[9], NULL,
152                                     NULL);
153 
154     fullname = tw_extend_fullname(tw_get_toolname(), name);
155     twc = tw_callback_make(fullname, choice,
156                            choice_call, choice_cmnd, choice_prnt, func, (void *) value, (void *) data);
157 
158     xv_set(choice,
159            PANEL_NOTIFY_PROC, tw_panel_callback,
160            PANEL_CLIENT_DATA, twc,
161            NULL);
162 
163     if (newrow)
164     {
165         row = tw_get_row();
166         xv_set(choice,
167                XV_X, xv_col(panel, 0),
168                XV_Y, xv_row(panel, row),
169                NULL);
170         tw_set_newrow(false);
171     }
172     (*func) (value, data);
173 }
174 
175 #endif                          /* __STRICT_ANSI__ */
176 #endif                          /* ANSIFYING */
177 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.