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

Linux Cross Reference
Tina4/src/Xv/tw_fglobal.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 fglobal_call(Tw_callback * twc)
 26 {
 27     double  x, *ptr = (double *) twc->data1;
 28     char   *string = (char *) xv_get(twc->window, PANEL_VALUE);
 29 
 30     if (sscanf(string, "%lf", &x) == 1)
 31         *ptr = x;
 32 }
 33 
 34 static void fglobal_cmnd(Tw_callback * twc, char *args)
 35 {
 36     double *ptr = (double *) twc->data1;
 37     char    string[64];
 38 
 39     (void) sscanf(args, "%*s %lf", ptr);
 40     (void) sscanf(args, "%*s %s", string);
 41     xv_set(twc->window, PANEL_VALUE, string, NULL);
 42 }
 43 
 44 static void fglobal_prnt(FILE * fp, Tw_callback * twc)
 45 {
 46     double  x = *(double *) twc->data1;
 47 
 48     (void) fprintf(fp, "%s %g\n", twc->name, x);
 49 }
 50 
 51 Tw_callback *tw_fglobal(char *name, double *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     double  value;
 59     Tw_callback *twc;
 60     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 61 
 62     value = *ptr;
 63     (void) sprintf(string, "%g", value);
 64     if (!strchr(string, '.') && !strchr(string, 'e'))
 65     {
 66         /* Ensure at least one decimal place is shown (JB 2/3/93) */
 67         (void) sprintf(string, "%.1f", value);
 68     }
 69     text = xv_create(panel, PANEL_TEXT,
 70                      PANEL_LABEL_STRING, name,
 71                      PANEL_VALUE_DISPLAY_LENGTH, nchars,
 72                      PANEL_VALUE, string,
 73                      PANEL_NOTIFY_LEVEL, PANEL_ALL,
 74                      NULL);
 75 
 76     twc = tw_callback_make(fullname, text,
 77                            fglobal_call, fglobal_cmnd, fglobal_prnt, (void (*) ()) NULL, (void *) ptr,
 78                            NULL);
 79 
 80     xv_set(text,
 81            PANEL_NOTIFY_PROC, tw_text_callback,
 82            PANEL_CLIENT_DATA, twc,
 83            NULL);
 84 
 85     if (newrow)
 86     {
 87         row = tw_get_row();
 88         xv_set(text,
 89                XV_X, xv_col(panel, 0),
 90                XV_Y, xv_row(panel, row),
 91                NULL);
 92         tw_set_newrow(false);
 93     }
 94     return (twc);
 95 }
 96 
 97 void    tw_fglobal_reset(Tw_callback * twc)
 98 {
 99     double *val;
100     char    string[64];
101 
102     if (twc == NULL)
103         return;
104 
105     val = (double *) twc->data1;
106     (void) sprintf(string, "%g", *val);
107     if (!strchr(string, '.') && !strchr(string, 'e'))
108     {
109         /* Ensure at least one decimal place is shown (JB 2/3/93) */
110         (void) sprintf(string, "%.1f", *val);
111     }
112     xv_set(twc->window, PANEL_VALUE, string, NULL);
113 }
114 

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