summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-01-31 22:59:46 (GMT)
committerjoye <joye>2014-01-31 22:59:46 (GMT)
commitd904537ffe8ef5d6d66cbce0870ff811222b3eb4 (patch)
tree3d738484a9a7461e5b55cc90ad1b5f54196342e5 /src
parent6a50bfd45784a86f63bcfb69657083f3a5da67a8 (diff)
downloadblt-d904537ffe8ef5d6d66cbce0870ff811222b3eb4.zip
blt-d904537ffe8ef5d6d66cbce0870ff811222b3eb4.tar.gz
blt-d904537ffe8ef5d6d66cbce0870ff811222b3eb4.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltConfig.C15
-rw-r--r--src/bltGrMisc.C17
-rw-r--r--src/bltGraph.C135
-rw-r--r--src/bltGraph.h11
4 files changed, 90 insertions, 88 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C
index 3f9f0b3..f031086 100644
--- a/src/bltConfig.C
+++ b/src/bltConfig.C
@@ -82,7 +82,6 @@
#include <stdarg.h>
#include "bltInt.h"
-#include "bltWindow.h"
#include "bltBgStyle.h"
/* STATE */
@@ -1615,7 +1614,19 @@ Blt_ConfigureComponentFromObj(
* Create component if a child window by the component's name
* doesn't already exist.
*/
- tkwin = Blt_FindChild(parent, tmpName);
+ {
+ TkWindow *winPtr;
+ TkWindow *parentPtr = (TkWindow *)parent;
+
+ for (winPtr = parentPtr->childList; winPtr != NULL;
+ winPtr = winPtr->nextPtr) {
+ if (strcmp(tmpName, winPtr->nameUid) == 0) {
+ tkwin = (Tk_Window)winPtr;
+ }
+ }
+ tkwin = NULL;
+ }
+
if (tkwin == NULL) {
tkwin = Tk_CreateWindow(interp, parent, tmpName, (char *)NULL);
isTemporary = TRUE;
diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C
index 2c3e9c6..84fe991 100644
--- a/src/bltGrMisc.C
+++ b/src/bltGrMisc.C
@@ -682,22 +682,9 @@ GC Blt_GetPrivateGC(Tk_Window tkwin, unsigned long gcMask, XGCValues *valuePtr)
pixmap = None;
drawable = Tk_WindowId(tkwin);
display = Tk_Display(tkwin);
- if (drawable == None) {
- Drawable root;
- int depth;
+ if (drawable == None)
+ drawable = Tk_RootWindow(tkwin);
- root = Tk_RootWindow(tkwin);
- depth = Tk_Depth(tkwin);
-
- if (depth == DefaultDepth(display, Tk_ScreenNumber(tkwin))) {
- drawable = root;
- } else {
- pixmap = Tk_GetPixmap(display, root, 1, 1, depth);
- drawable = pixmap;
- Blt_SetDrawableAttribs(display, drawable, 1, 1, depth,
- Tk_Colormap(tkwin), Tk_Visual(tkwin));
- }
- }
gc = XCreateGC(display, drawable, gcMask, valuePtr);
if (pixmap != None) {
Tk_FreePixmap(display, pixmap);
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 72e076e..7de704d 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -122,23 +122,23 @@ extern Blt_CustomOption bltBarModeOption;
#define DEF_GRAPH_WIDTH "5i"
static Tk_OptionSpec optionSpecs[] = {
- {TK_OPTION_DOUBLE, "-aspect", "aspect", "Aspect", DEF_GRAPH_ASPECT_RATIO,
+ {TK_OPTION_DOUBLE, "-aspect", "aspect", "Aspect",
+ DEF_GRAPH_ASPECT_RATIO,
-1, Tk_Offset(Graph, aspect), 0, NULL, 0},
- {TK_OPTION_DOUBLE, "-barwidth", "barWidth", "BarWidth", DEF_GRAPH_BAR_WIDTH,
+ {TK_OPTION_DOUBLE, "-barwidth", "barWidth", "BarWidth",
+ DEF_GRAPH_BAR_WIDTH,
-1, Tk_Offset(Graph, barWidth), 0, NULL, 0},
{TK_OPTION_DOUBLE, "-baseline", "baseline", "Baseline",
DEF_GRAPH_BAR_BASELINE,
-1, Tk_Offset(Graph, baseline), 0, NULL, 0},
- {TK_OPTION_SYNONYM, "-bd", "borderWidth", NULL, NULL,
- -1, 0, 0, NULL, 0},
- {TK_OPTION_SYNONYM, "-bg", "background", NULL, NULL,
- -1, 0, 0, NULL, 0},
- {TK_OPTION_SYNONYM, "-bm", "bottomMargin", NULL, NULL,
- -1, 0, 0, NULL, 0},
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
+ -1, 0, 0, "-borderwidth", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEF_GRAPH_BORDERWIDTH,
-1, Tk_Offset(Graph, borderWidth), 0, NULL, 0},
- {TK_OPTION_PIXELS, "-bottommargin", "bottomMargin", "Margin",
+ {TK_OPTION_SYNONYM, "-bm", NULL, NULL, NULL,
+ -1, 0, 0, "-bottommargin", 0},
+ {TK_OPTION_PIXELS, "-bottommargin", "bottomMargin", "BottomMargin",
DEF_GRAPH_MARGIN,
-1, Tk_Offset(Graph, bottomMargin.reqSize), 0, NULL, 0},
{TK_OPTION_STRING, "-bottomvariable", "bottomVariable", "BottomVariable",
@@ -152,12 +152,6 @@ static Tk_OptionSpec optionSpecs[] = {
-1, Tk_Offset(Graph, doubleBuffer), 0, NULL, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_GRAPH_CURSOR,
-1, Tk_Offset(Graph, cursor), TK_OPTION_NULL_OK, NULL, 0},
- {TK_OPTION_STRING, "-data", "data", "Data", NULL,
- -1, Tk_Offset(Graph, data), 0, NULL, 0},
- {TK_OPTION_STRING, "-datacommand", "dataCommand", "DataCommand", NULL,
- -1, Tk_Offset(Graph, dataCmd), 0, NULL, 0},
- {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL,
- -1, 0, 0, NULL, 0},
{TK_OPTION_FONT, "-font", "font", "Font", DEF_GRAPH_FONT,
-1, Tk_Offset(Graph, titleTextStyle.font), 0, NULL, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
@@ -185,8 +179,8 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING, "-leftvariable", "leftVariable", "LeftVariable",
DEF_GRAPH_MARGIN_VAR,
-1, Tk_Offset(Graph, leftMargin.varName), TK_OPTION_NULL_OK, NULL, 0},
- {TK_OPTION_SYNONYM, "-lm", "leftMargin", NULL, NULL,
- -1, 0, 0, NULL, 0},
+ {TK_OPTION_SYNONYM, "-lm", NULL, NULL, NULL,
+ -1, 0, 0, "-leftmargin", 0},
{TK_OPTION_PIXELS, "-plotborderwidth", "plotBorderWidth", "PlotBorderWidth",
DEF_GRAPH_PLOT_BORDERWIDTH,
-1, Tk_Offset(Graph, plotBW), 0, NULL, 0},
@@ -204,8 +198,8 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING, "-rightvariable", "rightVariable", "RightVariable",
DEF_GRAPH_MARGIN_VAR,
-1, Tk_Offset(Graph, rightMargin.varName), TK_OPTION_NULL_OK, NULL, 0},
- {TK_OPTION_SYNONYM, "-rm", "rightMargin", NULL, NULL,
- -1, 0, 0, NULL, 0},
+ {TK_OPTION_SYNONYM, "-rm", NULL, NULL, NULL,
+ -1, 0, 0, "-rightmargin", 0},
{TK_OPTION_BOOLEAN, "-stackaxes", "stackAxes", "StackAxes",
DEF_GRAPH_STACK_AXES,
-1, Tk_Offset(Graph, stackAxes), 0, NULL, 0},
@@ -214,9 +208,9 @@ static Tk_OptionSpec optionSpecs[] = {
-1, Tk_Offset(Graph, takeFocus), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-title", "title", "Title", DEF_GRAPH_TITLE,
-1, Tk_Offset(Graph, title), TK_OPTION_NULL_OK, NULL, 0},
- {TK_OPTION_SYNONYM, "-tm", "topMargin", NULL, NULL,
- -1, 0, 0, NULL, 0},
- {TK_OPTION_PIXELS, "-topmargin", "topMargin", "Margin", DEF_GRAPH_MARGIN,
+ {TK_OPTION_SYNONYM, "-tm", NULL, NULL, NULL,
+ -1, 0, 0, "-topmargin", 0},
+ {TK_OPTION_PIXELS, "-topmargin", "topMargin", "TopMargin", DEF_GRAPH_MARGIN,
-1, Tk_Offset(Graph, topMargin.reqSize), 0, NULL, 0},
{TK_OPTION_STRING, "-topvariable", "topVariable", "TopVariable",
DEF_GRAPH_MARGIN_VAR,
@@ -270,10 +264,6 @@ static Blt_ConfigSpec configSpecs[] = {
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
DEF_GRAPH_CURSOR, Tk_Offset(Graph, cursor), BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_STRING, "-data", "data", "Data",
- (char*)NULL, Tk_Offset(Graph, data), BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_STRING, "-datacommand", "dataCommand", "DataCommand",
- (char*)NULL, Tk_Offset(Graph, dataCmd), BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_SYNONYM, "-fg", "foreground", (char*)NULL, (char*)NULL, 0, 0},
{BLT_CONFIG_FONT, "-font", "font", "Font",
DEF_GRAPH_FONT, Tk_Offset(Graph, titleTextStyle.font), 0},
@@ -359,11 +349,14 @@ static Tcl_FreeProc DestroyGraph;
static Tk_EventProc GraphEventProc;
Tcl_ObjCmdProc Blt_GraphInstCmdProc;
-static Blt_BindPickProc PickEntry;
-static Tcl_ObjCmdProc BarchartCmd;
-static Tcl_ObjCmdProc GraphCmd;
+static Tcl_ObjCmdProc BarchartObjCmd;
+static Tcl_CmdDeleteProc BarchartObjDelete;
+static Tcl_ObjCmdProc GraphObjCmd;
+static Tcl_CmdDeleteProc GraphObjDelete;
static Tcl_CmdDeleteProc GraphInstCmdDeleteProc;
+static Blt_BindPickProc PickEntry;
+
/*
*---------------------------------------------------------------------------
*
@@ -439,13 +432,8 @@ static void GraphEventProc(ClientData clientData, XEvent* eventPtr)
Blt_EventuallyRedrawGraph(graphPtr);
}
} else if (eventPtr->type == DestroyNotify) {
- if (graphPtr->tkwin)
- printf("GraphEventProc: %s\n", Tk_PathName(graphPtr->tkwin));
- else
- printf("GraphEventProc: none\n");
-
if (graphPtr->tkwin != NULL) {
- // Tk_FreeConfigOptions(graphPtr, graphPtr->optionTable, graphPtr->tkwin);
+ //Tk_FreeConfigOptions(graphPtr, graphPtr->optionTable, graphPtr->tkwin);
graphPtr->tkwin = NULL;
Tcl_DeleteCommandFromToken(graphPtr->interp, graphPtr->cmdToken);
}
@@ -462,10 +450,6 @@ static void GraphEventProc(ClientData clientData, XEvent* eventPtr)
static void GraphInstCmdDeleteProc(ClientData clientData)
{
Graph* graphPtr = clientData;
- if (graphPtr->tkwin)
- printf("GraphInstCmdDeleteProc: %s\n", Tk_PathName(graphPtr->tkwin));
- else
- printf("GraphInstCmdDeleteProc: none\n");
// NULL indicates window has already been destroyed.
if (graphPtr->tkwin != NULL) {
@@ -762,10 +746,6 @@ static void ConfigureGraph(Graph* graphPtr)
static void DestroyGraph(char* dataPtr)
{
Graph* graphPtr = (Graph*)dataPtr;
- if (graphPtr->tkwin)
- printf("DestroyGraph: %s\n", Tk_PathName(graphPtr->tkwin));
- else
- printf("DestroyGraph: none\n");
Blt_FreeOptions(configSpecs, (char*)graphPtr, graphPtr->display, 0);
/*
@@ -799,10 +779,19 @@ static void DestroyGraph(char* dataPtr)
free(graphPtr);
}
-static Graph* CreateGraph(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
- ClassId classId)
+static Graph* CreateGraph(ClientData clientData, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[], ClassId classId)
{
- printf("CreateGraph: %s\n",Tcl_GetString(objv[1]));
+ Tk_OptionTable optionTable = (Tk_OptionTable)clientData;
+ if (!optionTable) {
+ optionTable = Tk_CreateOptionTable(interp, optionSpecs);
+ char* name = Tcl_GetString(objv[0]);
+ Tcl_CmdInfo info;
+ Tcl_GetCommandInfo(interp, name, &info);
+ info.objClientData = (ClientData)optionTable;
+ Tcl_SetCommandInfo(interp, name, &info);
+ }
+
Tk_Window tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
Tcl_GetString(objv[1]),
(char*)NULL);
@@ -813,9 +802,11 @@ static Graph* CreateGraph(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
/* Initialize the graph data structure. */
+ graphPtr->interp = interp;
graphPtr->tkwin = tkwin;
graphPtr->display = Tk_Display(tkwin);
- graphPtr->interp = interp;
+ graphPtr->cmdToken = NULL;
+ graphPtr->optionTable = optionTable;
graphPtr->classId = classId;
graphPtr->backingStore = TRUE;
graphPtr->doubleBuffer = TRUE;
@@ -867,10 +858,6 @@ static Graph* CreateGraph(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
objv + 2, (char*)graphPtr, 0) != TCL_OK)
goto error;
-
- // if (Tk_InitOptions(interp, graphPtr, graphPtr->optionsTable, tkwin))
- // goto error;
-
if (Blt_DefaultAxes(graphPtr) != TCL_OK)
goto error;
@@ -892,6 +879,10 @@ static Graph* CreateGraph(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
graphPtr->cmdToken = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[1]),
Blt_GraphInstCmdProc, graphPtr,
GraphInstCmdDeleteProc);
+
+ // if (Tk_InitOptions(interp, graphPtr, graphPtr->optionTable, tkwin))
+ // goto error;
+
ConfigureGraph(graphPtr);
graphPtr->bindTable = Blt_CreateBindingTable(interp, tkwin, graphPtr,
PickEntry, Blt_GraphTags);
@@ -1188,8 +1179,8 @@ int Blt_GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, int objc,
return result;
}
-static int NewGraph(Tcl_Interp*interp, int objc, Tcl_Obj* const objv[],
- ClassId classId)
+static int NewGraph(ClientData clientData, Tcl_Interp*interp,
+ int objc, Tcl_Obj* const objv[], ClassId classId)
{
if (objc < 2) {
Tcl_AppendResult(interp, "wrong # args: should be \"",
@@ -1198,22 +1189,39 @@ static int NewGraph(Tcl_Interp*interp, int objc, Tcl_Obj* const objv[],
return TCL_ERROR;
}
- if (!CreateGraph(interp, objc, objv, classId))
+ if (!CreateGraph(clientData, interp, objc, objv, classId))
return TCL_ERROR;
return TCL_OK;
}
-static int GraphCmd(ClientData clientData, Tcl_Interp* interp, int objc,
- Tcl_Obj* const objv[])
+static void DeleteGraph(ClientData clientData)
+{
+ Tk_OptionTable optionTable = (Tk_OptionTable)clientData;
+ if (clientData)
+ Tk_DeleteOptionTable(optionTable);
+}
+
+static int GraphObjCmd(ClientData clientData, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[])
+{
+ return NewGraph(clientData, interp, objc, objv, CID_ELEM_LINE);
+}
+
+static void GraphObjDelete(ClientData clientData)
+{
+ DeleteGraph(clientData);
+}
+
+static int BarchartObjCmd(ClientData clientData, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[])
{
- return NewGraph(interp, objc, objv, CID_ELEM_LINE);
+ return NewGraph(clientData, interp, objc, objv, CID_ELEM_BAR);
}
-static int BarchartCmd(ClientData clientData, Tcl_Interp* interp, int objc,
- Tcl_Obj* const objv[])
+static void BarchartObjDelete(ClientData clientData)
{
- return NewGraph(interp, objc, objv, CID_ELEM_BAR);
+ DeleteGraph(clientData);
}
/*
@@ -1528,9 +1536,10 @@ static void DisplayGraph(ClientData clientData)
int Blt_GraphCmdInitProc(Tcl_Interp* interp)
{
- printf("Blt_GraphCmdInitProc\n");
- static Blt_InitCmdSpec graphSpec = {"graph", GraphCmd, };
- static Blt_InitCmdSpec barchartSpec = {"barchart", BarchartCmd, };
+ static Blt_InitCmdSpec graphSpec =
+ {"graph", GraphObjCmd, GraphObjDelete, NULL};
+ static Blt_InitCmdSpec barchartSpec =
+ {"barchart", BarchartObjCmd, BarchartObjDelete, NULL};
if (Blt_InitCmd(interp, "::blt", &graphSpec) != TCL_OK)
return TCL_ERROR;
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 46e20b2..390c67a 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -33,7 +33,6 @@
#define _BLT_GRAPH_H
#include "bltInt.h"
-#include "bltWindow.h"
#include "bltBind.h"
#include "bltChain.h"
#include "bltPs.h"
@@ -268,7 +267,6 @@ typedef struct {
*---------------------------------------------------------------------------
*/
struct _Graph {
- unsigned int flags; /* Flags; see below for definitions. */
Tcl_Interp *interp; /* Interpreter associated with graph */
Tk_Window tkwin; /* Window that embodies the graph.
* NULL means that the window has been
@@ -278,9 +276,8 @@ struct _Graph {
* release resources after tkwin has
* already gone away. */
Tcl_Command cmdToken; /* Token for graph's widget command. */
- const char *data; /* This value isn't used in C code.
- * It may be used in TCL bindings to
- * associate extra data. */
+ Tk_OptionTable optionTable;
+ ClassId classId; /* Default element type */
Tk_Cursor cursor;
int inset; /* Sum of focus highlight and 3-D
* border. Indicates how far to
@@ -288,6 +285,7 @@ struct _Graph {
* of the window. */
int borderWidth; /* Width of the exterior border */
int relief; /* Relief of the exterior border. */
+ unsigned int flags; /* Flags; see below for definitions. */
Blt_Background normalBg; /* 3-D border used to delineate the
* plot surface and outer edge of
* window. */
@@ -326,7 +324,6 @@ struct _Graph {
} elements, markers, axes;
Tcl_HashTable dataTables; /* Hash table of datatable clients. */
- ClassId classId; /* Default element type */
Blt_BindTable bindTable;
int nextMarkerId; /* Tracks next marker identifier
* available */
@@ -415,8 +412,6 @@ struct _Graph {
* ways: aligned, overlap, infront, or
* stacked. */
int maxBarSetSize;
- const char *dataCmd; /* New data callback? */
- Tk_OptionTable optionTable;
};
/*