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

Linux Cross Reference
Tina4/src/Xv/tw_ivalue.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 ivalue_call(Tw_callback * twc)
 26 {
 27     int     x;
 28     void    (*set) () = (void (*) ()) twc->data2;
 29     char   *string = (char *) xv_get(twc->window, PANEL_VALUE);
 30 
 31     if (sscanf(string, "%d", &x) == 1)
 32         (*set) (x);
 33 }
 34 
 35 static void ivalue_cmnd(Tw_callback * twc, char *args)
 36 {
 37     int     x;
 38     void    (*set) () = (void (*) ()) twc->data2;
 39     char    string[64];
 40 
 41     (void) sscanf(args, "%*s %d", &x);
 42     (*set) (x);
 43     (void) sscanf(args, "%*s %s", string);
 44     xv_set(twc->window, PANEL_VALUE, string, NULL);
 45 }
 46 
 47 static void ivalue_prnt(FILE * fp, Tw_callback * twc)
 48 {
 49     int     (*get) () = (int (*) ()) twc->data1;
 50 
 51     (void) fprintf(fp, "%s %d\n", twc->name, (*get) ());
 52 }
 53 
 54 Tw_callback *tw_ivalue(char *name, int (*get) ( /* ??? */ ), void (*set) ( /* ??? */ ), int nchars)
 55 {
 56     Panel_item text;
 57     Panel   panel = tw_get_panel();
 58     Bool    newrow = tw_get_newrow();
 59     int     row;
 60     char    string[32];
 61     Tw_callback *twc;
 62     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 63 
 64     (void) sprintf(string, "%d", (*get) ());
 65 
 66     text = xv_create(panel, PANEL_TEXT,
 67                      PANEL_LABEL_STRING, name,
 68                      PANEL_VALUE_DISPLAY_LENGTH, nchars,
 69                      PANEL_VALUE, string,
 70                      PANEL_NOTIFY_LEVEL, PANEL_ALL,
 71                      NULL);
 72 
 73     twc = tw_callback_make(fullname, text,
 74                            ivalue_call, ivalue_cmnd, ivalue_prnt, (void (*) ()) NULL, (void *) get,
 75                            (void *) set);
 76 
 77     xv_set(text,
 78            PANEL_NOTIFY_PROC, tw_text_callback,
 79            PANEL_CLIENT_DATA, twc,
 80            NULL);
 81 
 82     if (newrow)
 83     {
 84         row = tw_get_row();
 85         xv_set(text,
 86                XV_X, xv_col(panel, 0),
 87                XV_Y, xv_row(panel, row),
 88                NULL);
 89         tw_set_newrow(false);
 90     }
 91     return (twc);
 92 }
 93 
 94 void    tw_ivalue_reset(Tw_callback * twc)
 95 {
 96     int     (*get) ();
 97     char    string[64];
 98 
 99     if (twc == NULL)
100         return;
101 
102     get = (int (*) ()) twc->data1;
103     (void) sprintf(string, "%d", get());
104     xv_set(twc->window, PANEL_VALUE, string, NULL);
105 }
106 

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