diff options
author | joye <joye> | 2014-02-27 21:40:32 (GMT) |
---|---|---|
committer | joye <joye> | 2014-02-27 21:40:32 (GMT) |
commit | c89110414f32df48dde2ebb3f87675e56bcad2ce (patch) | |
tree | 666abc256b541662c3edb11f0ecc8d9472154fbf /src | |
parent | 85357383e09ee385367db64b51d72daf8de66a6f (diff) | |
download | blt-c89110414f32df48dde2ebb3f87675e56bcad2ce.zip blt-c89110414f32df48dde2ebb3f87675e56bcad2ce.tar.gz blt-c89110414f32df48dde2ebb3f87675e56bcad2ce.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 12 | ||||
-rw-r--r-- | src/bltGrElemBar.C | 21 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 15 | ||||
-rw-r--r-- | src/bltGrElemOp.C | 7 | ||||
-rw-r--r-- | src/bltGrPenOp.C | 40 | ||||
-rw-r--r-- | src/bltGraph.C | 12 |
6 files changed, 38 insertions, 69 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 9bc1f1e..9048a71 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -123,18 +123,6 @@ static int AxisSetProc(ClientData clientData, Tcl_Interp *interp, int offset, char* save, int flags) { Axis** axisPtrPtr = (Axis**)(widgRec + offset); - - if (flags & BLT_CONFIG_NULL_OK) { - const char* string; - - string = Tcl_GetString(*objPtr); - if (string[0] == '\0') { - ReleaseAxis(*axisPtrPtr); - *axisPtrPtr = NULL; - return TCL_OK; - } - } - Graph* graphPtr = Blt_GetGraphFromWindowData(tkwin); ClassId classId = (ClassId)clientData; Axis* axisPtr; diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 6e5681c..a6b2c81 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -238,7 +238,7 @@ extern Tk_ObjCustomOption yAxisObjOption; static Tk_OptionSpec barElemOptionSpecs[] = { {TK_OPTION_CUSTOM, "-activepen", "activePen", "ActivePen", "activeBar", -1, Tk_Offset(BarElement, activePenPtr), - BLT_CONFIG_NULL_OK, &barPenObjOption, 0}, + TK_OPTION_NULL_OK, &barPenObjOption, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement, builtinPen.fill), 0, NULL, 0}, @@ -381,8 +381,8 @@ Element* Blt_BarElement(Graph* graphPtr, const char* name, ClassId classId) { BarElement *elemPtr = calloc(1, sizeof(BarElement)); elemPtr->procsPtr = &barProcs; - Blt_GraphSetObjectClass(&elemPtr->obj, classId); elemPtr->obj.name = Blt_Strdup(name); + Blt_GraphSetObjectClass(&elemPtr->obj, classId); elemPtr->obj.graphPtr = graphPtr; // this is an option and will be freed via Tk_FreeConfigOptions // By default an element's name and label are the same @@ -392,14 +392,14 @@ Element* Blt_BarElement(Graph* graphPtr, const char* name, ClassId classId) elemPtr->builtinPenPtr = &elemPtr->builtinPen; InitBarPen(graphPtr, elemPtr->builtinPenPtr); + Tk_InitOptions(graphPtr->interp, (char*)elemPtr->builtinPenPtr, + elemPtr->builtinPenPtr->optionTable, graphPtr->tkwin); elemPtr->stylePalette = Blt_Chain_Create(); elemPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, barElemOptionSpecs); - Tk_InitOptions(graphPtr->interp, (char*)elemPtr, elemPtr->optionTable, - graphPtr->tkwin); - return (Element *)elemPtr; + return (Element*)elemPtr; } Pen* Blt_BarPen(Graph* graphPtr, const char *penName) @@ -407,7 +407,7 @@ Pen* Blt_BarPen(Graph* graphPtr, const char *penName) BarPen* penPtr = calloc(1, sizeof(BarPen)); InitBarPen(graphPtr, penPtr); penPtr->name = Blt_Strdup(penName); - if (strcmp(penName, "activeBar") == 0) + if (!strcmp(penName, "activeBar")) penPtr->flags = ACTIVE_PEN; return (Pen*)penPtr; @@ -415,21 +415,14 @@ Pen* Blt_BarPen(Graph* graphPtr, const char *penName) static void InitBarPen(Graph* graphPtr, BarPen* penPtr) { - /* Generic fields common to all pen types. */ penPtr->configProc = ConfigurePenProc; penPtr->destroyProc = DestroyPenProc; penPtr->flags = NORMAL_PEN; - /* Initialize fields specific to bar pens. */ + Blt_Ts_InitStyle(penPtr->valueStyle); - penPtr->relief = TK_RELIEF_RAISED; - penPtr->valueShow = SHOW_NONE; - penPtr->borderWidth = 2; - penPtr->errorBarShow = SHOW_BOTH; penPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs); - Tk_InitOptions(graphPtr->interp, (char*)penPtr, penPtr->optionTable, - graphPtr->tkwin); } static void DestroyBarProc(Graph* graphPtr, Element* basePtr) diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index fba2aa0..2ead2d6 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -675,16 +675,16 @@ Element * Blt_LineElement(Graph *graphPtr, const char *name, ClassId classId) if (name) strcpy((char*)elemPtr->label,(char*)name); - elemPtr->stylePalette = Blt_Chain_Create(); elemPtr->builtinPenPtr = &elemPtr->builtinPen; InitLinePen(graphPtr, elemPtr->builtinPenPtr); + Tk_InitOptions(graphPtr->interp, (char*)elemPtr->builtinPenPtr, + elemPtr->builtinPenPtr->optionTable, graphPtr->tkwin); + elemPtr->stylePalette = Blt_Chain_Create(); elemPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, lineElemOptionSpecs); - Tk_InitOptions(graphPtr->interp, (char*)elemPtr, elemPtr->optionTable, - graphPtr->tkwin); - return (Element *)elemPtr; + return (Element*)elemPtr; } Pen* Blt_LinePen(Graph* graphPtr, const char* penName) @@ -693,10 +693,10 @@ Pen* Blt_LinePen(Graph* graphPtr, const char* penName) InitLinePen(graphPtr, penPtr); penPtr->name = Blt_Strdup(penName); penPtr->classId = CID_ELEM_LINE; - if (strcmp(penName, "activeLine") == 0) + if (!strcmp(penName, "activeLine")) penPtr->flags = ACTIVE_PEN; - return (Pen *)penPtr; + return (Pen*)penPtr; } static void InitLinePen(Graph* graphPtr, LinePen* penPtr) @@ -706,15 +706,12 @@ static void InitLinePen(Graph* graphPtr, LinePen* penPtr) penPtr->flags = NORMAL_PEN; Blt_Ts_InitStyle(penPtr->valueStyle); - penPtr->name = ""; penPtr->symbol.bitmap = None; penPtr->symbol.mask = None; penPtr->symbol.type = SYMBOL_NONE; penPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, linePenOptionSpecs); - Tk_InitOptions(graphPtr->interp, (char*)penPtr, penPtr->optionTable, - graphPtr->tkwin); } static void DestroyLineProc(Graph* graphPtr, Element* basePtr) diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 624354a..fda4f9e 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -318,7 +318,7 @@ static int CreateElement(Graph *graphPtr, Tcl_Interp *interp, int objc, if (!elemPtr) return TCL_ERROR; - if (ElementObjConfigure(interp,graphPtr, elemPtr, objc-4, objv+4) != TCL_OK) { + if ((Tk_InitOptions(graphPtr->interp, (char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (ElementObjConfigure(interp,graphPtr, elemPtr, objc-4, objv+4) != TCL_OK)) { DestroyElement(elemPtr); return TCL_ERROR; } @@ -1052,10 +1052,9 @@ static int GetPenStyleFromObj(Tcl_Interp *interp, Graph *graphPtr, } return TCL_ERROR; } - if (Blt_GetPenFromObj(interp, graphPtr, objv[0], classId, &penPtr) - != TCL_OK) { + if (Blt_GetPenFromObj(interp, graphPtr, objv[0], classId, &penPtr) != TCL_OK) return TCL_ERROR; - } + if (objc == 3) { double min, max; diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index d91d68a..d6a4064 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -82,8 +82,7 @@ static int PenSetProc(ClientData clientData, Tcl_Interp *interp, if (classId == CID_NONE) classId = graphPtr->classId; - if (Blt_GetPenFromObj(interp, graphPtr, *objPtr, classId, &penPtr) - != TCL_OK) + if (Blt_GetPenFromObj(interp, graphPtr, *objPtr, classId,&penPtr) != TCL_OK) return TCL_ERROR; Blt_FreePen(*penPtrPtr); @@ -137,7 +136,7 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, penPtr->graphPtr = graphPtr; penPtr->classId = classId; - if (PenObjConfigure(interp, graphPtr, penPtr, objc-4, objv+4) != TCL_OK) { + if ((Tk_InitOptions(graphPtr->interp, (char*)penPtr, penPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (PenObjConfigure(interp, graphPtr, penPtr, objc-4, objv+4) != TCL_OK)) { DestroyPen(penPtr); return TCL_ERROR; } @@ -405,36 +404,29 @@ void Blt_FreePen(Pen *penPtr) int Blt_GetPenFromObj(Tcl_Interp *interp, Graph *graphPtr, Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr) { - Tcl_HashEntry *hPtr; - Pen *penPtr; - const char *name; - - penPtr = NULL; - name = Tcl_GetString(objPtr); - hPtr = Tcl_FindHashEntry(&graphPtr->penTable, name); + Pen *penPtr = NULL; + const char *name = Tcl_GetString(objPtr); + Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&graphPtr->penTable, name); if (hPtr != NULL) { penPtr = Tcl_GetHashValue(hPtr); - if (penPtr->flags & DELETE_PENDING) { + if (penPtr->flags & DELETE_PENDING) penPtr = NULL; - } } - if (penPtr == NULL) { - if (interp != NULL) { - Tcl_AppendResult(interp, "can't find pen \"", name, "\" in \"", - Tk_PathName(graphPtr->tkwin), "\"", (char *)NULL); - } + + if (!penPtr) { + Tcl_AppendResult(interp, "can't find pen \"", name, "\" in \"", + Tk_PathName(graphPtr->tkwin), "\"", (char *)NULL); return TCL_ERROR; } - classId = CID_ELEM_LINE; + if (penPtr->classId != classId) { - if (interp != NULL) { - Tcl_AppendResult(interp, "pen \"", name, - "\" is the wrong type (is \"", - Blt_GraphClassName(penPtr->classId), "\"", ", wanted \"", - Blt_GraphClassName(classId), "\")", (char *)NULL); - } + Tcl_AppendResult(interp, "pen \"", name, + "\" is the wrong type (is \"", + Blt_GraphClassName(penPtr->classId), "\"", ", wanted \"", + Blt_GraphClassName(classId), "\")", (char *)NULL); return TCL_ERROR; } + penPtr->refCount++; *penPtrPtr = penPtr; return TCL_OK; diff --git a/src/bltGraph.C b/src/bltGraph.C index 4d479f2..a0e4b8e 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -45,19 +45,18 @@ #include "bltGrElem.h" static const char* objectClassNames[] = { - "unknown", + "none", "XAxis", "YAxis", "BarElement", - "ContourElement", "LineElement", - "StripElement", "BitmapMarker", "ImageMarker", "LineMarker", "PolygonMarker", "TextMarker", "WindowMarker", + "LegendEntry" }; // Defs @@ -364,7 +363,7 @@ int Blt_GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, return result; } -// called by Tcl_DeleteCommandx +// called by Tcl_DeleteCommand static void GraphInstCmdDeleteProc(ClientData clientData) { Graph* graphPtr = clientData; @@ -385,10 +384,11 @@ static void DestroyGraph(char* dataPtr) Blt_DestroyPens(graphPtr); Blt_DestroyPageSetup(graphPtr); Blt_DestroyBarSets(graphPtr); - if (graphPtr->bindTable != NULL) + + if (graphPtr->bindTable) Blt_DestroyBindingTable(graphPtr->bindTable); - if (graphPtr->drawGC != NULL) + if (graphPtr->drawGC) Tk_FreeGC(graphPtr->display, graphPtr->drawGC); Blt_Ts_FreeStyle(graphPtr->display, &graphPtr->titleTextStyle); |