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

Linux Cross Reference
Tina4/src/Xm/tw_ivalue.c

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

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/math.h>
  6 #include <tina/tv.h>
  7 #include  <tina/mtw.h>
  8 #include  <tina/tv_screen.h>
  9 #include <tina/Xmfuncs.h>
 10 
 11 static void ivalue_call(Tw_callback * twc)
 12 {
 13     int     i;
 14     void    (*set) () = (void (*) ()) twc->data2;
 15     char   *string = XmTextGetString(twc->widget);
 16 
 17     if (sscanf(string, "%d", &i) == 1)
 18         (*set) (i);
 19     XtFree(string);
 20 }
 21 
 22 static void ivalue_cmnd(Tw_callback * twc, char *args)
 23 {
 24     int     i;
 25     void    (*set) () = (void (*) ()) twc->data2;
 26     char    string[64];
 27 
 28     (void) sscanf(args, "%*s %d", &i);
 29     (*set) (i);
 30     (void) sscanf(args, "%*s %s", string);
 31     tw_text_set(twc->widget, string);
 32 }
 33 
 34 static void ivalue_prnt(FILE * fp, Tw_callback * twc)
 35 {
 36     int     (*get) () = (int (*) ()) twc->data1;
 37 
 38     (void) fprintf(fp, "%s %d\n", twc->name, (*get) ());
 39 }
 40 
 41 void *tw_ivalue(char *name, int (*get) ( /* ??? */ ), void (*set) ( /* ??? */ ), int nchars)
 42 {
 43     char    string[64];
 44     XmString xmstring;
 45     int     nargs;
 46     Arg     wargs[1];
 47     int     w, h;
 48     Tw_callback *twc;
 49     Widget  panel = tw_get_panel(), label, text;
 50     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 51 
 52     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
 53     nargs = 0;
 54     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
 55     nargs++;
 56     label = XtCreateManagedWidget("twlabel", xmLabelWidgetClass,
 57                                   panel, wargs, nargs);
 58     XmStringFree(xmstring);
 59 
 60     w = tw_charwidth(2.0 + strlen(name));
 61     h = tw_charheight(1.0);
 62     tw_set_entry(label, w, h);
 63 
 64     nargs = 0;
 65     XtSetArg(wargs[nargs], XmNcolumns, nchars);
 66     nargs++;
 67     text = XtCreateManagedWidget("twtext", xmTextWidgetClass,
 68                                  panel, wargs, nargs);
 69     (void) sprintf(string, "%d", (*get) ());
 70     XmTextSetString(text, string);
 71 
 72     twc = tw_callback_make(fullname, tw_get_tool(), text,
 73                            ivalue_call, ivalue_cmnd, ivalue_prnt, (void (*) ()) NULL, (void *) get, (void *) set);
 74     XtAddCallback(text, XmNvalueChangedCallback, (void *) tw_callback, (XtPointer) twc);
 75 
 76     w = tw_charwidth(4.0 + nchars);
 77     h = tw_charheight(2.5);
 78     tw_set_entry(text, w, h);
 79 
 80     return (twc);
 81 }
 82 
 83 
 84 void    tw_ivalue_reset(void *ptwc)
 85 {
 86     Tw_callback *twc = ptwc;
 87     int    (*get) () = (int (*) ()) twc->data2;
 88     int     i = get();
 89     char string[64];
 90     sprintf(string, "%d", i);
 91     XmTextSetString(twc->widget, string);
 92 }
 93 

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