00001 #include <tcl.h>
00002 #include <tk.h>
00003 #include <stdio.h>
00004 #include <string.h>
00005
00006 extern Tcl_Interp *MainTclInterp;
00007
00008 int
00009 ProgMeter_Create (char *title)
00010 {
00011 char tclstr[200];
00012 Tcl_Obj *tclcommand = NULL;
00013 int gaugenum;
00014 Tcl_Obj *objectresult = NULL;
00015
00016 sprintf (tclstr, "gauge_gui_add \"%s\"", title);
00017 tclcommand = Tcl_NewStringObj (tclstr, -1);
00018
00019 if (Tcl_EvalObj (MainTclInterp, tclcommand) != TCL_OK)
00020 {
00021 Tcl_BackgroundError (MainTclInterp);
00022 return 0;
00023 }
00024
00025 objectresult = Tcl_GetObjResult (MainTclInterp);
00026 if (Tcl_GetIntFromObj (MainTclInterp, objectresult, &gaugenum) != TCL_OK)
00027 {
00028 Tcl_BackgroundError (MainTclInterp);
00029 return 0;
00030 }
00031 else
00032 {
00033 return gaugenum;
00034 }
00035 }
00036
00037 int
00038 ProgMeter_Update (int gaugenum, double value)
00039 {
00040 char tclstr[200];
00041 Tcl_Obj *tclcommand = NULL;
00042 Tcl_Obj *objectresult = NULL;
00043 int cancelval;
00044
00045 sprintf (tclstr, "gauge_gui_update %d %f", gaugenum, value);
00046 if (Tcl_Eval (MainTclInterp, tclstr) != TCL_OK)
00047 {
00048 Tcl_BackgroundError (MainTclInterp);
00049 return -1;
00050 }
00051
00052 objectresult = Tcl_GetObjResult (MainTclInterp);
00053 if (Tcl_GetIntFromObj (MainTclInterp, objectresult, &cancelval) != TCL_OK)
00054 {
00055 Tcl_BackgroundError (MainTclInterp);
00056 return -1;
00057 }
00058 else
00059 {
00060 return cancelval;
00061 }
00062
00063 }
00064
00065 int
00066 ProgMeter_Destroy (int gaugenum)
00067 {
00068 char tclstr[200];
00069
00070 sprintf (tclstr, "gauge_gui_delete %d", gaugenum);
00071 if (Tcl_Eval (MainTclInterp, tclstr) != TCL_OK)
00072 {
00073 Tcl_BackgroundError (MainTclInterp);
00074 return 0;
00075 }
00076 else
00077 {
00078 return 1;
00079 }
00080 }