initial implementation.
[dyninst.git] / visiClients / barchart / src / barChartDriver.C
1 // barChartDriver.C
2
3 // $Log: barChartDriver.C,v $
4 // Revision 1.1  1994/09/29 19:50:51  tamches
5 // initial implementation.
6 // entrypoint for barchart C++ program.  we create new tcl
7 // commands (which will eventually call back to barChartTcl.C
8 // and from there barChart.C) and then launch barChart.tcl.
9 //
10
11 #include <stdlib.h>
12 #include <iostream.h>
13
14 #include <tcl.h>
15 #include <tk.h>
16 #include "dg2.h"
17 #include "barChartTcl.h"
18
19 void panic(char *msg) {
20    cerr << msg << endl;
21    exit(5);
22 }
23
24 extern "C" {
25    int Blt_Init(Tcl_Interp *);
26 }
27
28 Tcl_Interp *MainInterp;
29
30 int Tcl_AppInit(Tcl_Interp *interp) {
31    // tk library's main() will call this routine for us.  We must perform all
32    // needed initializations here...
33
34    MainInterp = interp; // needed by Dg
35
36    if (TCL_ERROR == Tcl_Init(interp))
37       return TCL_ERROR;
38
39    if (TCL_ERROR == Tk_Init(interp))
40       return TCL_ERROR;
41
42 //   if (TCL_ERROR == Blt_Init(interp))
43 //      // for blt_drag n' drop
44 //      return TCL_ERROR;
45
46    if (TCL_ERROR == Dg2_Init(interp))
47       // installs lots of tcl and C++ callbacks
48       return TCL_ERROR;
49
50    tcl_RcFileName = "~/.wishrc";
51
52    // Install our new tcl commands
53    Tcl_CreateCommand(interp, "resizeCallback", resizeCallbackCommand,
54                      NULL, // ClientData
55                      deleteDummyProc);
56
57    Tcl_CreateCommand(interp, "exposeCallback", exposeCallbackCommand,
58                      NULL, // ClientData
59                      deleteDummyProc);
60
61    Tcl_CreateCommand(interp, "xAxisHasChanged", xAxisHasChangedCommand,
62                      NULL, // ClientData
63                      deleteDummyProc);
64
65    Tcl_CreateCommand(interp, "yAxisHasChanged", yAxisHasChangedCommand,
66                      NULL, // ClientData
67                      deleteDummyProc);
68
69    Tcl_CreateCommand(interp, "newScrollPosition", newScrollPositionCommand,
70                      NULL, // ClientData
71                      deleteDummyProc);
72
73    Tcl_CreateCommand(interp, "dataFormatHasChanged", dataFormatHasChangedCommand,
74                      NULL, // ClientData
75                      deleteDummyProc);
76
77    Tcl_CreateCommand(interp, "launchBarChart", launchBarChartCommand,
78                      NULL, // ClientData
79                      deleteLaunchBarChartCommand);
80
81    return TCL_OK;
82 }
83
84 // we use main() from the tk library, which is rigged to call
85 // int Tcl_AppInit(Tcl_Interp *) which gives us a change to install
86 // new tcl commands.
87
88 extern int main(int argc, char **argv);
89 int (*dummy)(int, char**) = main; // make use of main() to ensure it gets linked in...