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

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