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

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

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

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

~ [ 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.