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

Linux Cross Reference
Tina4/src/Xv/tw_choice.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     (*twc->func) (value);
 29 }
 30 
 31 static void choice_cmnd(Tw_callback * twc, char *args)
 32 {
 33     int value;
 34     (void) sscanf(args, "%*s %d", &value);
 35     (*twc->func) (value);
 36 
 37     xv_set(twc->window, PANEL_VALUE, value, NULL);
 38 }
 39 
 40 static void choice_prnt(FILE * fp, Tw_callback * twc)
 41 {
 42     int value = (int) twc->data1;
 43     (void) fprintf(fp, "%s %d %d\n", twc->name, value);
 44 }
 45 
 46 Tw_callback *tw_choice(char *name,...)
 47 {
 48     va_list ap;
 49     void (*func) ();
 50     int value;
 51     char *names[10];
 52     Panel_item choice;
 53     Panel panel = tw_get_panel();
 54     Bool newrow = tw_get_newrow();
 55     int i, row;
 56     Tw_callback *twc;
 57     char *fullname;
 58     panel = tw_get_panel();
 59     newrow = tw_get_newrow();
 60 
 61     for (i = 0; i < 10; i++)
 62         names[i] = NULL;
 63 
 64     va_start(ap, name);
 65 
 66     func = (void (*) ()) va_arg(ap, void *);
 67     value = va_arg(ap, int);
 68 
 69     for (i = 0; (names[i] = va_arg(ap, char *)) != NULL; i++);
 70     va_end(ap);
 71 
 72     choice = (Panel_item) xv_create(panel, PANEL_CHOICE,
 73                                     PANEL_CHOOSE_ONE, TRUE,
 74                                     PANEL_VALUE, value,
 75                                     PANEL_LABEL_STRING, name,
 76                                     PANEL_CHOICE_STRINGS,
 77                      names[0], names[1], names[2], names[3], names[4],
 78                names[5], names[6], names[7], names[8], names[9], NULL,
 79                                     NULL);
 80 
 81     fullname = tw_extend_fullname(tw_get_toolname(), name);
 82     twc = tw_callback_make(fullname, choice,
 83     choice_call, choice_cmnd, choice_prnt, func, (void *) value, NULL);
 84 
 85     xv_set(choice,
 86            PANEL_NOTIFY_PROC, tw_panel_callback,
 87            PANEL_CLIENT_DATA, twc,
 88            NULL);
 89 
 90     if (newrow)
 91     {
 92         row = tw_get_row();
 93         xv_set(choice,
 94                XV_X, xv_col(panel, 0),
 95                XV_Y, xv_row(panel, row),
 96                NULL);
 97         tw_set_newrow(false);
 98     }
 99     (*func) (value);
100     return(twc);
101 }
102 
103 void tw_choice_reset(Tw_callback * twc, int value)
104 {
105     if (twc == NULL)
106         return;
107     xv_set(twc->window, PANEL_VALUE, value, NULL);
108 }
109 

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