summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-02-27 20:14:52 (GMT)
committerjoye <joye>2014-02-27 20:14:52 (GMT)
commit85357383e09ee385367db64b51d72daf8de66a6f (patch)
treea803d065c3e0feb6563c5916c1d833a92d4505e0 /src
parent91feec10acb03284ca49a1e670ef8e291e2871fe (diff)
downloadblt-85357383e09ee385367db64b51d72daf8de66a6f.zip
blt-85357383e09ee385367db64b51d72daf8de66a6f.tar.gz
blt-85357383e09ee385367db64b51d72daf8de66a6f.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrElemBar.C16
-rw-r--r--src/bltGrElemLine.C106
-rw-r--r--src/bltGrElemOp.C5
-rw-r--r--src/bltGrHairs.C20
-rw-r--r--src/bltGrLegd.C370
-rw-r--r--src/bltGrLegd.h1
-rw-r--r--src/bltGraph.C10
-rw-r--r--src/bltGraph.h9
8 files changed, 186 insertions, 351 deletions
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 45e5263..6e5681c 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -384,8 +384,12 @@ Element* Blt_BarElement(Graph* graphPtr, const char* name, ClassId classId)
Blt_GraphSetObjectClass(&elemPtr->obj, classId);
elemPtr->obj.name = Blt_Strdup(name);
elemPtr->obj.graphPtr = graphPtr;
- /* By default, an element's name and label are the same. */
- elemPtr->label = Blt_Strdup(name);
+ // this is an option and will be freed via Tk_FreeConfigOptions
+ // By default an element's name and label are the same
+ elemPtr->label = ckalloc(strlen(name)+1);
+ if (name)
+ strcpy((char*)elemPtr->label,(char*)name);
+
elemPtr->builtinPenPtr = &elemPtr->builtinPen;
InitBarPen(graphPtr, elemPtr->builtinPenPtr);
elemPtr->stylePalette = Blt_Chain_Create();
@@ -431,8 +435,6 @@ static void InitBarPen(Graph* graphPtr, BarPen* penPtr)
static void DestroyBarProc(Graph* graphPtr, Element* basePtr)
{
BarElement* elemPtr = (BarElement*)basePtr;
- Tk_FreeConfigOptions((char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin);
- Tk_DeleteOptionTable(elemPtr->optionTable);
DestroyPenProc(graphPtr, (Pen*)&elemPtr->builtinPen);
if (elemPtr->activePenPtr != NULL)
@@ -448,13 +450,13 @@ static void DestroyBarProc(Graph* graphPtr, Element* basePtr)
if (elemPtr->activeIndices != NULL) {
free(elemPtr->activeIndices);
}
+
+ Tk_FreeConfigOptions((char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin);
}
static void DestroyPenProc(Graph* graphPtr, Pen* basePtr)
{
BarPen* penPtr = (BarPen*)basePtr;
- Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
- Tk_DeleteOptionTable(penPtr->optionTable);
Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle);
if (penPtr->outlineGC != NULL) {
@@ -466,6 +468,8 @@ static void DestroyPenProc(Graph* graphPtr, Pen* basePtr)
if (penPtr->errorBarGC != NULL) {
Tk_FreeGC(graphPtr->display, penPtr->errorBarGC);
}
+
+ Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
}
// Configure
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index a1a542b..fba2aa0 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -80,32 +80,13 @@ typedef struct {
} MapInfo;
/* Symbol types for line elements */
-typedef enum {SYMBOL_NONE, SYMBOL_SQUARE, SYMBOL_CIRCLE, SYMBOL_DIAMOND,
- SYMBOL_PLUS, SYMBOL_CROSS, SYMBOL_SPLUS, SYMBOL_SCROSS,
- SYMBOL_TRIANGLE, SYMBOL_ARROW, SYMBOL_BITMAP, SYMBOL_IMAGE
+typedef enum {
+ SYMBOL_NONE, SYMBOL_SQUARE, SYMBOL_CIRCLE, SYMBOL_DIAMOND, SYMBOL_PLUS,
+ SYMBOL_CROSS, SYMBOL_SPLUS, SYMBOL_SCROSS, SYMBOL_TRIANGLE, SYMBOL_ARROW,
+ SYMBOL_BITMAP, SYMBOL_IMAGE
} SymbolType;
typedef struct {
- const char *name;
- unsigned int minChars;
- SymbolType type;
-} GraphSymbolType;
-
-static GraphSymbolType graphSymbols[] = {
- { "arrow", 1, SYMBOL_ARROW, },
- { "circle", 2, SYMBOL_CIRCLE, },
- { "cross", 2, SYMBOL_CROSS, },
- { "diamond", 1, SYMBOL_DIAMOND, },
- { "none", 1, SYMBOL_NONE, },
- { "plus", 1, SYMBOL_PLUS, },
- { "scross", 2, SYMBOL_SCROSS, },
- { "splus", 2, SYMBOL_SPLUS, },
- { "square", 2, SYMBOL_SQUARE, },
- { "triangle", 1, SYMBOL_TRIANGLE, },
- { NULL, 0, 0 },
-};
-
-typedef struct {
SymbolType type; /* Type of symbol to be drawn/printed */
int size; /* Requested size of symbol in pixels */
@@ -380,6 +361,26 @@ static Tk_ObjCustomOption styleObjOption =
};
+typedef struct {
+ const char *name;
+ unsigned int minChars;
+ SymbolType type;
+} GraphSymbolType;
+
+static GraphSymbolType graphSymbols[] = {
+ { "arrow", 1, SYMBOL_ARROW, },
+ { "circle", 2, SYMBOL_CIRCLE, },
+ { "cross", 2, SYMBOL_CROSS, },
+ { "diamond", 1, SYMBOL_DIAMOND, },
+ { "none", 1, SYMBOL_NONE, },
+ { "plus", 1, SYMBOL_PLUS, },
+ { "scross", 2, SYMBOL_SCROSS, },
+ { "splus", 2, SYMBOL_SPLUS, },
+ { "square", 2, SYMBOL_SQUARE, },
+ { "triangle", 1, SYMBOL_TRIANGLE, },
+ { NULL, 0, 0 },
+};
+
static Tk_CustomOptionSetProc SymbolSetProc;
static Tk_CustomOptionGetProc SymbolGetProc;
Tk_ObjCustomOption symbolObjOption =
@@ -528,7 +529,8 @@ static Tk_OptionSpec lineElemOptionSpecs[] = {
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
"no", -1, Tk_Offset(LineElement, hide), 0, NULL, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
- NULL, -1, Tk_Offset(LineElement, label), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineElement, label),
+ TK_OPTION_NULL_OK | TK_OPTION_DONT_SET_DEFAULT, NULL, 0},
{TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief",
"flat", -1, Tk_Offset(LineElement, legendRelief), 0, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
@@ -667,8 +669,12 @@ Element * Blt_LineElement(Graph *graphPtr, const char *name, ClassId classId)
Blt_GraphSetObjectClass(&elemPtr->obj, classId);
elemPtr->flags = SCALE_SYMBOL;
elemPtr->obj.graphPtr = graphPtr;
- /* By default an element's name and label are the same. */
- elemPtr->label = Blt_Strdup(name);
+ // this is an option and will be freed via Tk_FreeConfigOptions
+ // By default an element's name and label are the same
+ elemPtr->label = ckalloc(strlen(name)+1);
+ if (name)
+ strcpy((char*)elemPtr->label,(char*)name);
+
elemPtr->stylePalette = Blt_Chain_Create();
elemPtr->builtinPenPtr = &elemPtr->builtinPen;
InitLinePen(graphPtr, elemPtr->builtinPenPtr);
@@ -700,17 +706,10 @@ static void InitLinePen(Graph* graphPtr, LinePen* penPtr)
penPtr->flags = NORMAL_PEN;
Blt_Ts_InitStyle(penPtr->valueStyle);
- penPtr->errorBarLineWidth = 1;
- penPtr->errorBarShow = SHOW_BOTH;
penPtr->name = "";
penPtr->symbol.bitmap = None;
penPtr->symbol.mask = None;
- penPtr->symbol.outlineColor = NULL;
- penPtr->symbol.fillColor = NULL;
- penPtr->symbol.outlineWidth = 1;
- penPtr->traceWidth = 1;
penPtr->symbol.type = SYMBOL_NONE;
- penPtr->valueShow = SHOW_NONE;
penPtr->optionTable =
Tk_CreateOptionTable(graphPtr->interp, linePenOptionSpecs);
@@ -721,50 +720,47 @@ static void InitLinePen(Graph* graphPtr, LinePen* penPtr)
static void DestroyLineProc(Graph* graphPtr, Element* basePtr)
{
LineElement* elemPtr = (LineElement*)basePtr;
- Tk_FreeConfigOptions((char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin);
- Tk_DeleteOptionTable(elemPtr->optionTable);
DestroyPenProc(graphPtr, (Pen *)&elemPtr->builtinPen);
- if (elemPtr->activePenPtr != NULL)
+ if (elemPtr->activePenPtr)
Blt_FreePen((Pen *)elemPtr->activePenPtr);
- if (elemPtr->normalPenPtr != NULL)
+ if (elemPtr->normalPenPtr)
Blt_FreePen((Pen *)elemPtr->normalPenPtr);
ResetLine(elemPtr);
- if (elemPtr->stylePalette != NULL) {
+ if (elemPtr->stylePalette) {
Blt_FreeStylePalette(elemPtr->stylePalette);
Blt_Chain_Destroy(elemPtr->stylePalette);
}
- if (elemPtr->activeIndices != NULL) {
+ if (elemPtr->activeIndices)
free(elemPtr->activeIndices);
- }
- if (elemPtr->fillPts != NULL) {
+
+ if (elemPtr->fillPts)
free(elemPtr->fillPts);
- }
- if (elemPtr->fillGC != NULL) {
+
+ if (elemPtr->fillGC)
Tk_FreeGC(graphPtr->display, elemPtr->fillGC);
- }
+
+ Tk_FreeConfigOptions((char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin);
}
static void DestroyPenProc(Graph* graphPtr, Pen* basePtr)
{
LinePen* penPtr = (LinePen*)basePtr;
- Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
- Tk_DeleteOptionTable(penPtr->optionTable);
Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle);
- if (penPtr->symbol.outlineGC != NULL) {
+ if (penPtr->symbol.outlineGC)
Tk_FreeGC(graphPtr->display, penPtr->symbol.outlineGC);
- }
- if (penPtr->symbol.fillGC != NULL) {
+
+ if (penPtr->symbol.fillGC)
Tk_FreeGC(graphPtr->display, penPtr->symbol.fillGC);
- }
- if (penPtr->errorBarGC != NULL) {
+
+ if (penPtr->errorBarGC)
Tk_FreeGC(graphPtr->display, penPtr->errorBarGC);
- }
- if (penPtr->traceGC != NULL) {
+
+ if (penPtr->traceGC)
Blt_FreePrivateGC(graphPtr->display, penPtr->traceGC);
- }
+
if (penPtr->symbol.bitmap != None) {
Tk_FreeBitmap(graphPtr->display, penPtr->symbol.bitmap);
penPtr->symbol.bitmap = None;
@@ -773,6 +769,8 @@ static void DestroyPenProc(Graph* graphPtr, Pen* basePtr)
Tk_FreeBitmap(graphPtr->display, penPtr->symbol.mask);
penPtr->symbol.mask = None;
}
+
+ Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
}
// Configure
diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C
index f0f0b24..624354a 100644
--- a/src/bltGrElemOp.C
+++ b/src/bltGrElemOp.C
@@ -362,8 +362,9 @@ static void DestroyElement(Element *elemPtr)
if (elemPtr->obj.name)
free((void*)(elemPtr->obj.name));
- if (elemPtr->label)
- free((void*)(elemPtr->label));
+ // should already been freed via Tk_FreeConfigOptions
+ // if (elemPtr->label)
+ // free((void*)(elemPtr->label));
free(elemPtr);
}
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C
index c43efc4..4c5ddd3 100644
--- a/src/bltGrHairs.C
+++ b/src/bltGrHairs.C
@@ -99,23 +99,17 @@ int Blt_CreateCrosshairs(Graph* graphPtr)
return TCL_OK;
}
-void Blt_DeleteCrosshairs(Graph* graphPtr)
-{
- Crosshairs *chPtr = graphPtr->crosshairs;
- if (chPtr != NULL)
- Tk_FreeConfigOptions((char*)chPtr, chPtr->optionTable, graphPtr->tkwin);
-}
-
void Blt_DestroyCrosshairs(Graph* graphPtr)
{
Crosshairs *chPtr = graphPtr->crosshairs;
- if (chPtr != NULL) {
- Tk_DeleteOptionTable(chPtr->optionTable);
- if (chPtr->gc != NULL)
- Blt_FreePrivateGC(graphPtr->display, chPtr->gc);
+ if (!chPtr)
+ return;
- free(chPtr);
- }
+ if (chPtr->gc)
+ Blt_FreePrivateGC(graphPtr->display, chPtr->gc);
+
+ Tk_FreeConfigOptions((char*)chPtr, chPtr->optionTable, graphPtr->tkwin);
+ free(chPtr);
}
// Configure
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index 0797e3c..db80796 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -115,7 +115,7 @@ struct _Legend {
* of legend */
XColor *fgColor;
Tk_3DBorder activeBg; /* Active legend entry background
- * color. */
+ * color. */
XColor *activeFgColor;
int activeRelief; /* 3-D effect on active entry. */
int entryBW; /* Border width around each entry in
@@ -228,59 +228,59 @@ Tk_ObjCustomOption positionObjOption =
};
static int PositionSetProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
- int offset, char* save, int flags)
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
{
- Legend* legendPtr = (Legend*)widgRec;
- int length;
- const char* string = Tcl_GetStringFromObj(*objPtr, &length);
- char c;
- c = string[0];
- if (c == '\0') {
- legendPtr->site = LEGEND_RIGHT;
- } else if ((c == 'l') && (strncmp(string, "leftmargin", length) == 0)) {
- legendPtr->site = LEGEND_LEFT;
- } else if ((c == 'r') && (strncmp(string, "rightmargin", length) == 0)) {
- legendPtr->site = LEGEND_RIGHT;
- } else if ((c == 't') && (strncmp(string, "topmargin", length) == 0)) {
- legendPtr->site = LEGEND_TOP;
- } else if ((c == 'b') && (strncmp(string, "bottommargin", length) == 0)) {
- legendPtr->site = LEGEND_BOTTOM;
- } else if ((c == 'p') && (strncmp(string, "plotarea", length) == 0)) {
- legendPtr->site = LEGEND_PLOT;
- } else if (c == '@') {
- char *comma;
- long x, y;
- int result;
+ Legend* legendPtr = (Legend*)widgRec;
+ int length;
+ const char* string = Tcl_GetStringFromObj(*objPtr, &length);
+ char c;
+ c = string[0];
+ if (c == '\0') {
+ legendPtr->site = LEGEND_RIGHT;
+ } else if ((c == 'l') && (strncmp(string, "leftmargin", length) == 0)) {
+ legendPtr->site = LEGEND_LEFT;
+ } else if ((c == 'r') && (strncmp(string, "rightmargin", length) == 0)) {
+ legendPtr->site = LEGEND_RIGHT;
+ } else if ((c == 't') && (strncmp(string, "topmargin", length) == 0)) {
+ legendPtr->site = LEGEND_TOP;
+ } else if ((c == 'b') && (strncmp(string, "bottommargin", length) == 0)) {
+ legendPtr->site = LEGEND_BOTTOM;
+ } else if ((c == 'p') && (strncmp(string, "plotarea", length) == 0)) {
+ legendPtr->site = LEGEND_PLOT;
+ } else if (c == '@') {
+ char *comma;
+ long x, y;
+ int result;
- comma = strchr(string + 1, ',');
- if (comma == NULL) {
- Tcl_AppendResult(interp, "bad screen position \"", string,
- "\": should be @x,y", (char *)NULL);
- return TCL_ERROR;
- }
- x = y = 0;
- *comma = '\0';
- result = ((Tcl_ExprLong(interp, string + 1, &x) == TCL_OK) &&
- (Tcl_ExprLong(interp, comma + 1, &y) == TCL_OK));
- *comma = ',';
- if (!result) {
- return TCL_ERROR;
- }
- legendPtr->xReq = x;
- legendPtr->yReq = y;
- legendPtr->site = LEGEND_XY;
- } else if (c == '.') {
- if (CreateLegendWindow(interp, legendPtr, string) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "bad position \"", string, "\": should be \
+ comma = strchr(string + 1, ',');
+ if (comma == NULL) {
+ Tcl_AppendResult(interp, "bad screen position \"", string,
+ "\": should be @x,y", (char *)NULL);
+ return TCL_ERROR;
+ }
+ x = y = 0;
+ *comma = '\0';
+ result = ((Tcl_ExprLong(interp, string + 1, &x) == TCL_OK) &&
+ (Tcl_ExprLong(interp, comma + 1, &y) == TCL_OK));
+ *comma = ',';
+ if (!result) {
+ return TCL_ERROR;
+ }
+ legendPtr->xReq = x;
+ legendPtr->yReq = y;
+ legendPtr->site = LEGEND_XY;
+ } else if (c == '.') {
+ if (CreateLegendWindow(interp, legendPtr, string) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ } else {
+ Tcl_AppendResult(interp, "bad position \"", string, "\": should be \
\"leftmargin\", \"rightmargin\", \"topmargin\", \"bottommargin\", \
\"plotarea\", windowName or @x,y", (char *)NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
+ return TCL_ERROR;
+ }
+ return TCL_OK;
}
static Tcl_Obj* PositionGetProc(ClientData clientData, Tk_Window tkwin,
@@ -409,91 +409,74 @@ static Tk_OptionSpec optionSpecs[] = {
int Blt_CreateLegend(Graph* graphPtr)
{
- Legend *legendPtr = calloc(1, sizeof(Legend));
- graphPtr->legend = legendPtr;
- legendPtr->optionTable =Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
- legendPtr->graphPtr = graphPtr;
- legendPtr->tkwin = graphPtr->tkwin;
- legendPtr->xReq = legendPtr->yReq = -SHRT_MAX;
- legendPtr->relief = TK_RELIEF_SUNKEN;
- legendPtr->activeRelief = TK_RELIEF_FLAT;
- legendPtr->entryBW = 2;
- legendPtr->borderWidth = 2;
- legendPtr->ixPad = 1;
- legendPtr->iyPad = 1;
- legendPtr->xPad = 1;
- legendPtr->yPad = 1;
- legendPtr->anchor = TK_ANCHOR_N;
- legendPtr->site = LEGEND_RIGHT;
- legendPtr->selectMode = SELECT_MODE_MULTIPLE;
- Blt_Ts_InitStyle(legendPtr->style);
- Blt_Ts_InitStyle(legendPtr->titleStyle);
- legendPtr->style.justify = TK_JUSTIFY_LEFT;
- legendPtr->style.anchor = TK_ANCHOR_NW;
- legendPtr->titleStyle.justify = TK_JUSTIFY_LEFT;
- legendPtr->titleStyle.anchor = TK_ANCHOR_NW;
- legendPtr->bindTable = Blt_CreateBindingTable(graphPtr->interp,
- graphPtr->tkwin, graphPtr, PickEntryProc, Blt_GraphTags);
-
- Tcl_InitHashTable(&legendPtr->selectTable, TCL_ONE_WORD_KEYS);
- legendPtr->selected = Blt_Chain_Create();
- Tk_CreateSelHandler(legendPtr->tkwin, XA_PRIMARY, XA_STRING,
- SelectionProc, legendPtr, XA_STRING);
- legendPtr->selRelief = TK_RELIEF_FLAT;
- legendPtr->selBW = 1;
- legendPtr->onTime = 600;
- legendPtr->offTime = 300;
+ Legend *legendPtr = calloc(1, sizeof(Legend));
+ graphPtr->legend = legendPtr;
+ legendPtr->optionTable =Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
+ legendPtr->graphPtr = graphPtr;
+ legendPtr->tkwin = graphPtr->tkwin;
+ legendPtr->xReq = -SHRT_MAX;
+ legendPtr->yReq = -SHRT_MAX;
+ Blt_Ts_InitStyle(legendPtr->style);
+ Blt_Ts_InitStyle(legendPtr->titleStyle);
+ legendPtr->style.justify = TK_JUSTIFY_LEFT;
+ legendPtr->style.anchor = TK_ANCHOR_NW;
+ legendPtr->titleStyle.justify = TK_JUSTIFY_LEFT;
+ legendPtr->titleStyle.anchor = TK_ANCHOR_NW;
+ legendPtr->bindTable = Blt_CreateBindingTable(graphPtr->interp,
+ graphPtr->tkwin, graphPtr, PickEntryProc, Blt_GraphTags);
- return TCL_OK;
-}
+ Tcl_InitHashTable(&legendPtr->selectTable, TCL_ONE_WORD_KEYS);
+ legendPtr->selected = Blt_Chain_Create();
+ Tk_CreateSelHandler(legendPtr->tkwin, XA_PRIMARY, XA_STRING,
+ SelectionProc, legendPtr, XA_STRING);
+ legendPtr->onTime = 600;
+ legendPtr->offTime = 300;
-void Blt_DeleteLegend(Graph* graphPtr)
-{
- Legend *legendPtr = graphPtr->legend;
- if (legendPtr != NULL)
- Tk_FreeConfigOptions((char*)legendPtr, legendPtr->optionTable,
- graphPtr->tkwin);
+ return TCL_OK;
}
void Blt_DestroyLegend(Graph *graphPtr)
{
Legend* legendPtr = graphPtr->legend;
- if (legendPtr == NULL)
+ if (!legendPtr)
return;
- Tk_DeleteOptionTable(legendPtr->optionTable);
Blt_Ts_FreeStyle(graphPtr->display, &legendPtr->style);
Blt_Ts_FreeStyle(graphPtr->display, &legendPtr->titleStyle);
Blt_DestroyBindingTable(legendPtr->bindTable);
- if (legendPtr->focusGC != NULL) {
+ if (legendPtr->focusGC)
Blt_FreePrivateGC(graphPtr->display, legendPtr->focusGC);
- }
- if (legendPtr->timerToken != NULL) {
+
+ if (legendPtr->timerToken)
Tcl_DeleteTimerHandler(legendPtr->timerToken);
- }
- if (legendPtr->tkwin != NULL) {
+
+ if (legendPtr->tkwin)
Tk_DeleteSelHandler(legendPtr->tkwin, XA_PRIMARY, XA_STRING);
- }
+
if (legendPtr->site == LEGEND_WINDOW) {
Tk_Window tkwin;
/* The graph may be in the process of being torn down */
- if (legendPtr->cmdToken != NULL) {
+ if (legendPtr->cmdToken) {
Tcl_DeleteCommandFromToken(graphPtr->interp, legendPtr->cmdToken);
- }
- if (legendPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayLegend, legendPtr);
- legendPtr->flags &= ~REDRAW_PENDING;
- }
- tkwin = legendPtr->tkwin;
- legendPtr->tkwin = NULL;
- if (tkwin != NULL) {
- Tk_DeleteEventHandler(tkwin, ExposureMask | StructureNotifyMask,
- LegendEventProc, graphPtr);
- Tk_DestroyWindow(tkwin);
+
+ if (legendPtr->flags & REDRAW_PENDING) {
+ Tcl_CancelIdleCall(DisplayLegend, legendPtr);
+ legendPtr->flags &= ~REDRAW_PENDING;
+ }
+ tkwin = legendPtr->tkwin;
+ legendPtr->tkwin = NULL;
+ if (tkwin) {
+ Tk_DeleteEventHandler(tkwin, ExposureMask | StructureNotifyMask,
+ LegendEventProc, graphPtr);
+ Tk_DestroyWindow(tkwin);
+ }
}
}
+
+ Tk_FreeConfigOptions((char*)legendPtr, legendPtr->optionTable,
+ graphPtr->tkwin);
free(legendPtr);
}
@@ -507,7 +490,8 @@ static void LegendEventProc(ClientData clientData, XEvent *eventPtr)
if (eventPtr->xexpose.count == 0) {
Blt_Legend_EventuallyRedraw(graphPtr);
}
- } else if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
+ }
+ else if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
if (eventPtr->xfocus.detail == NotifyInferior) {
return;
}
@@ -524,12 +508,14 @@ static void LegendEventProc(ClientData clientData, XEvent *eventPtr)
BlinkCursorProc,
graphPtr);
}
- } else {
+ }
+ else {
legendPtr->cursorOn = FALSE;
legendPtr->timerToken = (Tcl_TimerToken)NULL;
}
Blt_Legend_EventuallyRedraw(graphPtr);
- } else if (eventPtr->type == DestroyNotify) {
+ }
+ else if (eventPtr->type == DestroyNotify) {
Graph *graphPtr = legendPtr->graphPtr;
if (legendPtr->site == LEGEND_WINDOW) {
@@ -549,7 +535,8 @@ static void LegendEventProc(ClientData clientData, XEvent *eventPtr)
graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD);
Blt_MoveBindingTable(legendPtr->bindTable, graphPtr->tkwin);
Blt_EventuallyRedrawGraph(graphPtr);
- } else if (eventPtr->type == ConfigureNotify) {
+ }
+ else if (eventPtr->type == ConfigureNotify) {
Blt_Legend_EventuallyRedraw(graphPtr);
}
}
@@ -602,7 +589,7 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
}
static int LegendObjConfigure(Tcl_Interp *interp, Graph* graphPtr,
- int objc, Tcl_Obj* const objv[])
+ int objc, Tcl_Obj* const objv[])
{
Legend* legendPtr = graphPtr->legend;
Tk_SavedOptions savedOptions;
@@ -1111,23 +1098,6 @@ void Blt_Legend_EventuallyRedraw(Graph *graphPtr)
}
}
-/*
- *---------------------------------------------------------------------------
- *
- * SelectCmdProc --
- *
- * Invoked at the next idle point whenever the current selection changes.
- * Executes some application-specific code in the -selectcommand option.
- * This provides a way for applications to handle selection changes.
- *
- * Results:
- * None.
- *
- * Side effects:
- * TCL code gets executed for some application-specific task.
- *
- *---------------------------------------------------------------------------
- */
static void SelectCmdProc(ClientData clientData)
{
Legend *legendPtr = clientData;
@@ -1145,23 +1115,6 @@ static void SelectCmdProc(ClientData clientData)
Tcl_Release(legendPtr);
}
-/*
- *---------------------------------------------------------------------------
- *
- * EventuallyInvokeSelectCmd --
- *
- * Queues a request to execute the -selectcommand code associated with
- * the widget at the next idle point. Invoked whenever the selection
- * changes.
- *
- * Results:
- * None.
- *
- * Side effects:
- * TCL code gets executed for some application-specific task.
- *
- *---------------------------------------------------------------------------
- */
static void EventuallyInvokeSelectCmd(Legend *legendPtr)
{
if ((legendPtr->flags & SELECT_PENDING) == 0) {
@@ -1181,30 +1134,12 @@ static void ClearSelection(Legend *legendPtr)
}
}
-/*
- *---------------------------------------------------------------------------
- *
- * LostSelectionProc --
- *
- * This procedure is called back by Tk when the selection is grabbed away
- * from a Text widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The existing selection is unhighlighted, and the window is marked as
- * not containing a selection.
- *
- *---------------------------------------------------------------------------
- */
static void LostSelectionProc(ClientData clientData)
{
Legend *legendPtr = clientData;
- if (legendPtr->exportSelection) {
+ if (legendPtr->exportSelection)
ClearSelection(legendPtr);
- }
}
static int CreateLegendWindow(Tcl_Interp *interp, Legend *legendPtr,
@@ -1480,32 +1415,6 @@ static ClientData PickEntryProc(ClientData clientData, int x, int y,
return NULL;
}
-/*
- *---------------------------------------------------------------------------
- *
- * Blt_MapLegend --
- *
- * Calculates the dimensions (width and height) needed for the legend.
- * Also determines the number of rows and columns necessary to list all
- * the valid element labels.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The following fields of the legend are calculated and set.
- *
- * nEntries - number of valid labels of elements in the
- * display list.
- * nRows - number of rows of entries
- * nColumns - number of columns of entries
- * entryHeight - height of each entry
- * entryWidth - width of each entry
- * height - width of legend (includes borders and padding)
- * width - height of legend (includes borders and padding)
- *
- *---------------------------------------------------------------------------
- */
void Blt_MapLegend(Graph *graphPtr, int plotWidth, int plotHeight)
{
Legend *legendPtr = graphPtr->legend;
@@ -2033,25 +1942,6 @@ static Element *GetLastElement(Graph *graphPtr)
return NULL;
}
-/*
- *---------------------------------------------------------------------------
- *
- * GetElementFromObj --
- *
- * Parse an index into an entry and return either its value or an error.
- *
- * Results:
- * A standard TCL result. If all went well, then *indexPtr is filled in
- * with the character index (into entryPtr) corresponding to string. The
- * index value is guaranteed to lie between 0 and the number of characters
- * in the string, inclusive. If an error occurs then an error message is
- * left in the interp's result.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
static int GetElementFromObj(Graph *graphPtr, Tcl_Obj *objPtr,
Element **elemPtrPtr)
{
@@ -2117,19 +2007,6 @@ static int GetElementFromObj(Graph *graphPtr, Tcl_Obj *objPtr,
return TCL_OK;
}
-/*
- *---------------------------------------------------------------------------
- *
- * SelectRange --
- *
- * Sets the selection flag for a range of nodes. The range is determined
- * by two pointers which designate the first/last nodes of the range.
- *
- * Results:
- * Always returns TCL_OK.
- *
- *---------------------------------------------------------------------------
- */
static int SelectRange(Legend *legendPtr, Element *fromPtr, Element *toPtr)
{
@@ -2203,26 +2080,6 @@ void Blt_Legend_RemoveElement(Graph *graphPtr, Element *elemPtr)
Blt_DeleteBindings(graphPtr->legend->bindTable, elemPtr);
}
-/*
- *---------------------------------------------------------------------------
- *
- * SelectionProc --
- *
- * This procedure is called back by Tk when the selection is requested by
- * someone. It returns part or all of the selection in a buffer provided
- * by the caller.
- *
- * Results:
- * The return value is the number of non-NULL bytes stored at buffer.
- * Buffer is filled (or partially filled) with a NUL-terminated string
- * containing part or all of the selection, as given by offset and
- * maxBytes.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
static int SelectionProc(ClientData clientData, int offset,
char *buffer, int maxBytes)
{
@@ -2270,23 +2127,6 @@ static int SelectionProc(ClientData clientData, int offset,
return MIN(nBytes, maxBytes);
}
-/*
- *---------------------------------------------------------------------------
- *
- * BlinkCursorProc --
- *
- * This procedure is called as a timer handler to blink the insertion
- * cursor off and on.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor gets turned on or off, redisplay gets invoked, and this
- * procedure reschedules itself.
- *
- *---------------------------------------------------------------------------
- */
static void BlinkCursorProc(ClientData clientData)
{
Graph *graphPtr = clientData;
diff --git a/src/bltGrLegd.h b/src/bltGrLegd.h
index d46f630..28dd254 100644
--- a/src/bltGrLegd.h
+++ b/src/bltGrLegd.h
@@ -50,7 +50,6 @@
extern int Blt_CreateLegend(Graph *graphPtr);
extern int Blt_ConfigureObjLegend(Graph *graphPtr,
int objc, Tcl_Obj* const objv[]);
-extern void Blt_DeleteLegend(Graph* graphPtr);
extern void Blt_DestroyLegend(Graph *graphPtr);
extern void Blt_DrawLegend(Graph *graphPtr, Drawable drawable);
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 697c3fe..4d479f2 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -367,7 +367,6 @@ int Blt_GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp,
// called by Tcl_DeleteCommandx
static void GraphInstCmdDeleteProc(ClientData clientData)
{
- printf("GraphInstCmdDeleteProc\n");
Graph* graphPtr = clientData;
if (!(graphPtr->flags & GRAPH_DELETED))
Tk_DestroyWindow(graphPtr->tkwin);
@@ -376,7 +375,6 @@ static void GraphInstCmdDeleteProc(ClientData clientData)
// called by Tcl_EventuallyFree and others
static void DestroyGraph(char* dataPtr)
{
- printf("DestroyGraph\n");
Graph* graphPtr = (Graph*)dataPtr;
Blt_DestroyCrosshairs(graphPtr);
@@ -412,18 +410,18 @@ static void GraphEventProc(ClientData clientData, XEvent* eventPtr)
graphPtr->flags |= REDRAW_WORLD;
Blt_EventuallyRedrawGraph(graphPtr);
}
+
} else if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
if (eventPtr->xfocus.detail != NotifyInferior) {
- if (eventPtr->type == FocusIn) {
+ if (eventPtr->type == FocusIn)
graphPtr->flags |= FOCUS;
- } else {
+ else
graphPtr->flags &= ~FOCUS;
- }
graphPtr->flags |= REDRAW_WORLD;
Blt_EventuallyRedrawGraph(graphPtr);
}
+
} else if (eventPtr->type == DestroyNotify) {
- printf("GraphEventProc:DestroyNotify\n");
if (!(graphPtr->flags & GRAPH_DELETED)) {
graphPtr->flags |= GRAPH_DELETED;
Tcl_DeleteCommandFromToken(graphPtr->interp, graphPtr->cmdToken);
diff --git a/src/bltGraph.h b/src/bltGraph.h
index e1228e9..900aa2a 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -455,6 +455,8 @@ struct _Graph {
#define DRAW_MARGINS (1<<13)/* 0x2000 */
#define CACHE_DIRTY (1<<14)/* 0x4000 */
+#define GRAPH_DELETED (1<<15)/* 0x4000 */
+
#define MAP_WORLD (MAP_ALL|RESET_AXES|GET_AXIS_GEOMETRY)
#define REDRAW_WORLD (DRAW_LEGEND)
#define RESET_WORLD (REDRAW_WORLD | MAP_WORLD)
@@ -467,9 +469,9 @@ extern int Blt_CreatePageSetup(Graph *graphPtr);
extern int Blt_ConfigurePageSetup(Graph *graphPtr);
extern int Blt_CreateCrosshairs(Graph *graphPtr);
-extern int Blt_ConfigureObjCrosshairs(Graph *graphPtr,
- int objc, Tcl_Obj* const objv[]);
-extern void Blt_DeleteCrosshairs(Graph* graphPtr);
+extern int Blt_ConfigureObjCrosshairs(Graph *graphPtr, int objc,
+ Tcl_Obj* const objv[]);
+extern void Blt_DestroyCrosshairs(Graph *graphPtr);
extern double Blt_InvHMap(Axis *axisPtr, double x);
@@ -498,7 +500,6 @@ extern void Blt_ReconfigureGraph(Graph *graphPtr);
extern void Blt_DestroyAxes(Graph *graphPtr);
-extern void Blt_DestroyCrosshairs(Graph *graphPtr);
extern void Blt_DestroyElements(Graph *graphPtr);