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

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

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

  1 /*
  2   tw_ivalue.c
  3 */
  4 
  5 #include <stdio.h>
  6 #include <tina/sys.h>
  7 #include <tcl.h>
  8 #include "tclWt.h"
  9 #include "tclWtPro.h"
 10 
 11 
 12 static void ivalue_call(Tw_callback *twc)
 13 {
 14 }
 15 
 16 
 17 static void ivalue_cmnd(Tw_callback * twc, char *args)
 18 {
 19         int    i;
 20         void (*set) () = (void (*)()) twc->data2;
 21         char   string[64];
 22 
 23         (void) sscanf(args, "%*s %d", &i);
 24         (*set) (i);
 25 }
 26 
 27 
 28 static void ivalue_prnt(FILE * fp, Tw_callback * twc)
 29 {
 30         int (*get) () = (int (*)()) twc->data1;
 31 
 32         (void) fprintf(fp, "%s %d\n", twc->name, (*get) ());
 33 }
 34 
 35 
 36 static char *ttcl_writetrace_ivalue(ClientData cdata, Tcl_Interp * interp,
 37                                                                                                                                                 char *name1, char *name2, int flags)
 38 {
 39         Tw_callback *twc = (Tw_callback *) cdata;
 40         void (*set) () = (void (*)()) twc->data2;
 41         int    i;
 42         char *tclvalue;
 43 
 44         tclvalue = Tcl_GetVar2(interp, name1, name2, flags);
 45 
 46         if (Tcl_GetInt(interp, tclvalue, &i) != TCL_OK)
 47                 return ("variable update failed");
 48 
 49         (*set) (i);
 50 
 51         return (NULL);
 52 }
 53 
 54 
 55 static char *ttcl_readtrace_ivalue(ClientData cdata, Tcl_Interp * interp,
 56                                                                                                                                          char *name1, char *name2, int flags)
 57 {
 58         Tw_callback *twc = (Tw_callback *) cdata;
 59         int (*get) () = (int (*)()) twc->data1;
 60         char ptr[64];
 61 
 62         if ((sprintf(ptr, "%d", (*get) ()) < 1) || 
 63                                 !Tcl_SetVar2(interp, name1, name2, ptr, flags))
 64                 return ("variable update failed");
 65         return (NULL);
 66 }
 67 
 68 
 69 
 70 Tw_callback *tw_ivalue(char *name, int (*get) ( /* ??? */ ),
 71                                                                                          void (*set) ( /* ??? */ ), int nchars)
 72 {
 73         Tcl_Interp *interp;
 74         Tw_callback *twc;
 75         char  ptr[64];
 76         char *fullname = tw_extend_fullname(tw_get_toolname(), name);
 77         char *tclname;
 78 
 79         if ((interp = ttcl_get_interp()) == NULL)
 80                 return;
 81 
 82         twc = tw_callback_make(fullname, NULL, ivalue_call, ivalue_cmnd,
 83                                                                                                  ivalue_prnt, (void (*)()) get, (void (*)()) set,
 84                                                                                                  NULL);
 85 
 86         tclname = ttcl_mkshellname(fullname, TTCLIVALUE);
 87 
 88         if ((sprintf(ptr, "%d", (*get) ()) < 1) || 
 89                                 !Tcl_SetVar(interp, tclname, ptr, 0))
 90         return (NULL);
 91 
 92         Tcl_TraceVar(interp, tclname, TCL_TRACE_WRITES, ttcl_writetrace_ivalue,
 93                                                          (ClientData) twc);
 94         Tcl_TraceVar(interp, tclname, TCL_TRACE_READS, ttcl_readtrace_ivalue,
 95                                                          (ClientData) twc);
 96 
 97         rfree(tclname);
 98         return (twc);
 99 
100 }
101 
102 void tw_ivalue_reset(Tw_callback * twc)
103 {
104 }
105 

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