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

Linux Cross Reference
Tina4/src/Xm/tw_svalue.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 svalue_call(Tw_callback * twc)
 12 {
 13     void    (*set) () = (void (*) ()) twc->data2;
 14     char   *string = XmTextGetString(twc->widget);
 15 
 16     (*set) (string);
 17     XtFree(string);
 18 }
 19 
 20 static void svalue_cmnd(Tw_callback * twc, char *args)
 21 {
 22     void    (*set) () = (void (*) ()) twc->data2;
 23     char    string[64];
 24 
 25     (void) sscanf(args, "%*s %s", string);
 26     (*set) (string);
 27     tw_text_set(twc->widget, string);
 28 }
 29 
 30 static void svalue_prnt(FILE * fp, Tw_callback * twc)
 31 {
 32     char    (*get) () = (char (*) ()) twc->data1;
 33 
 34     (void) fprintf(fp, "%s %s\n", twc->name, (*get) ());
 35 }
 36 
 37 void *tw_svalue(char *name, char *(*get) ( /* ??? */ ), void (*set) ( /* ??? */ ), int nchars)
 38 {
 39     char    string[64];
 40     XmString xmstring;
 41     int     nargs;
 42     Arg     wargs[1];
 43     int     w, h;
 44     Tw_callback *twc;
 45     Widget  panel = tw_get_panel(), label, text;
 46     char   *fullname = tw_extend_fullname(tw_get_toolname(), name);
 47 
 48     xmstring = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
 49     nargs = 0;
 50     XtSetArg(wargs[nargs], XmNlabelString, xmstring);
 51     nargs++;
 52     label = XtCreateManagedWidget("twlabel", xmLabelWidgetClass,
 53                                   panel, wargs, nargs);
 54     XmStringFree(xmstring);
 55 
 56     w = tw_charwidth(2.0 + strlen(name));
 57     h = tw_charheight(1.0);
 58     tw_set_entry(label, w, h);
 59 
 60     nargs = 0;
 61     XtSetArg(wargs[nargs], XmNcolumns, nchars);
 62     nargs++;
 63     text = XtCreateManagedWidget("twtext", xmTextWidgetClass,
 64                                  panel, wargs, nargs);
 65     (void) sprintf(string, "%s", (*get) ());
 66     XmTextSetString(text, string);
 67 
 68     twc = tw_callback_make(fullname, tw_get_tool(), text,
 69                            svalue_call, svalue_cmnd, svalue_prnt, (void (*) ()) NULL, (void *) get, (void *) set);
 70     XtAddCallback(text, XmNvalueChangedCallback, (void *) tw_callback, (XtPointer) twc);
 71 
 72     w = tw_charwidth(4.0 + nchars);
 73     h = tw_charheight(2.5);
 74     tw_set_entry(text, w, h);
 75 
 76     return (twc);
 77 }
 78 
 79 void    tw_svalue_reset(void *ptwc)
 80 {
 81     Tw_callback *twc = ptwc;
 82     char    *(*get) () = (char * (*) ()) twc->data2;
 83     char *     string = get();
 84     XmTextSetString(twc->widget, string);
 85 }
 86 

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