diff options
author | joye <joye> | 2014-03-07 21:56:45 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-07 21:56:45 (GMT) |
commit | 678308d0f0b6cd1445e304d417b0e897fc848a79 (patch) | |
tree | 0af27c881a20402554d273f2f0b48f2586c836f6 | |
parent | 649b4a8bc4f2e55467f57b41afba375c4a240f1c (diff) | |
download | blt-678308d0f0b6cd1445e304d417b0e897fc848a79.zip blt-678308d0f0b6cd1445e304d417b0e897fc848a79.tar.gz blt-678308d0f0b6cd1445e304d417b0e897fc848a79.tar.bz2 |
*** empty log message ***
-rw-r--r-- | src/bltGrAxis.C | 68 | ||||
-rw-r--r-- | src/bltGrAxis.h | 2 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 2 | ||||
-rw-r--r-- | src/bltGraph.C | 1 | ||||
-rw-r--r-- | tests/axis.tcl | 3 |
5 files changed, 58 insertions, 18 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index d90bae9..926a593 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -182,9 +182,10 @@ static Tcl_Obj* LimitGetProc(ClientData clientData, Tk_Window tkwin, static Tk_CustomOptionSetProc FormatSetProc; static Tk_CustomOptionGetProc FormatGetProc; +static Tk_CustomOptionFreeProc FormatFreeProc; Tk_ObjCustomOption formatObjOption = { - "format", FormatSetProc, FormatGetProc, NULL, NULL, NULL + "format", FormatSetProc, FormatGetProc, NULL, FormatFreeProc, NULL }; static int FormatSetProc(ClientData clientData, Tcl_Interp* interp, @@ -205,7 +206,7 @@ static int FormatSetProc(ClientData clientData, Tcl_Interp* interp, return TCL_ERROR; } if (axisPtr->limitsFormats) - free(axisPtr->limitsFormats); + Tcl_Free((char*)axisPtr->limitsFormats); axisPtr->limitsFormats = argv; axisPtr->nFormats = argc; @@ -229,6 +230,12 @@ static Tcl_Obj* FormatGetProc(ClientData clientData, Tk_Window tkwin, return objPtr; } +static void FormatFreeProc(ClientData clientData, Tk_Window tkwin, char* ptr) +{ + // if (ptr && *ptr) + // Tcl_Free(*(char**)ptr); +} + static Tk_CustomOptionSetProc UseSetProc; static Tk_CustomOptionGetProc UseGetProc; Tk_ObjCustomOption useObjOption = @@ -382,6 +389,41 @@ static Tcl_Obj* TicksGetProc(ClientData clientData, Tk_Window tkwin, return Tcl_NewListObj(0, NULL); } +static Tk_CustomOptionSetProc ObjectSetProc; +static Tk_CustomOptionGetProc ObjectGetProc; +static Tk_CustomOptionFreeProc ObjectFreeProc; +Tk_ObjCustomOption objectObjOption = + { + "object", ObjectSetProc, ObjectGetProc, NULL, ObjectFreeProc, NULL, + }; + +static int ObjectSetProc(ClientData clientData, Tcl_Interp* interp, + Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec, + int offset, char* save, int flags) +{ + Tcl_Obj** objectPtr = (Tcl_Obj**)(widgRec + offset); + Tcl_IncrRefCount(*objPtr); + if (*objectPtr) + Tcl_DecrRefCount(*objectPtr); + *objectPtr = *objPtr; + + return TCL_OK; +} + +static Tcl_Obj* ObjectGetProc(ClientData clientData, Tk_Window tkwin, + char *widgRec, int offset) +{ + Tcl_Obj** objectPtr = (Tcl_Obj**)(widgRec + offset); + return *objectPtr; +} + +static void ObjectFreeProc(ClientData clientData, Tk_Window tkwin, char* ptr) +{ + Tcl_Obj** objectPtr = (Tcl_Obj**)ptr; + if (*objectPtr) + Tcl_DecrRefCount(*objectPtr); +} + static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "ActiveForeground", STD_ACTIVE_FOREGROUND, -1, Tk_Offset(Axis, activeFgColor), 0, NULL, 0}, @@ -447,9 +489,9 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-logscale", "logScale", "LogScale", "no", -1, Tk_Offset(Axis, logScale), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-loosemin", "looseMin", "LooseMin", - "yes", -1, Tk_Offset(Axis, looseMin), 0, NULL, 0}, + "no", -1, Tk_Offset(Axis, looseMin), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-loosemax", "looseMax", "LooseMax", - "yes", -1, Tk_Offset(Axis, looseMax), 0, NULL, 0}, + "no", -1, Tk_Offset(Axis, looseMax), 0, NULL, 0}, {TK_OPTION_CUSTOM, "-majorticks", "majorTicks", "MajorTicks", NULL, -1, Tk_Offset(Axis, t1Ptr), TK_OPTION_NULL_OK, &majorTicksObjOption, 0}, @@ -464,12 +506,9 @@ static Tk_OptionSpec optionSpecs[] = { "flat", -1, Tk_Offset(Axis, relief), 0, NULL, 0}, {TK_OPTION_DOUBLE, "-rotate", "rotate", "Rotate", "0", -1, Tk_Offset(Axis, tickAngle), 0, NULL, 0}, - /* - {TK_OPTION_CUSTOM, "-scrollcommand", "scrollCommand", "ScrollCommand", - NULL, Tk_Offset(Axis, scrollCmdObjPtr), - ALL_GRAPHS | TK_OPTION_NULL_OK, - &objectOption}, - */ + {TK_OPTION_CUSTOM, "-scrollcommand", "scrollCommand", "ScrollCommand", + NULL, -1, Tk_Offset(Axis, scrollCmdObjPtr), + TK_OPTION_NULL_OK, &objectObjOption, 0}, {TK_OPTION_PIXELS, "-scrollincrement", "scrollIncrement", "ScrollIncrement", "10", -1, Tk_Offset(Axis, scrollUnits), 0, NULL, 0}, {TK_OPTION_CUSTOM, "-scrollmax", "scrollMax", "ScrollMax", @@ -1732,11 +1771,11 @@ static void LogScaleAxis(Axis *axisPtr, double min, double max) * is log scale. */ nMinor = 10; } - if (axisPtr->looseMin && !isnan(axisPtr->reqMin)) { + if (!axisPtr->looseMin || (axisPtr->looseMin && !isnan(axisPtr->reqMin))) { tickMin = min; nMajor++; } - if (axisPtr->looseMax && !isnan(axisPtr->reqMax)) { + if (!axisPtr->looseMax || (axisPtr->looseMax && !isnan(axisPtr->reqMax))) { tickMax = max; } } @@ -1795,10 +1834,10 @@ static void LinearScaleAxis(Axis *axisPtr, double min, double max) * option). The axis limit is always at the selected limit (otherwise we * assume that user would have picked a different number). */ - if (axisPtr->looseMin && !isnan(axisPtr->reqMin)) + if (!axisPtr->looseMin || (axisPtr->looseMin && !isnan(axisPtr->reqMin))) axisMin = min; - if (axisPtr->looseMax && !isnan(axisPtr->reqMax)) + if (!axisPtr->looseMax || (axisPtr->looseMax && !isnan(axisPtr->reqMax))) axisMax = max; SetAxisRange(&axisPtr->axisRange, axisMin, axisMax); @@ -3943,3 +3982,4 @@ static Tcl_Obj *AxisToObjProc(ClientData clientData, Tcl_Interp* interp, const char* name = axisPtr ? axisPtr->obj.name : ""; return Tcl_NewStringObj(name, -1); } + diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index ba97fad..f4a1ee9 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -99,7 +99,7 @@ typedef struct { * values on the axis in descending * order, from high to low. */ - int looseMin, looseMax; /* If non-zero, axis range extends to + int looseMin, looseMax; /* If zero, axis range extends to * the outer major ticks, otherwise at * the limits of the data values. This * is overriddened by setting the -min diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 89d99a5..b056cb1 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -673,7 +673,7 @@ Element * Blt_LineElement(Graph* graphPtr, const char* name, ClassId 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 - elemPtr->label = ckalloc(strlen(name)+1); + elemPtr->label = Tcl_Alloc(strlen(name)+1); if (name) strcpy((char*)elemPtr->label,(char*)name); diff --git a/src/bltGraph.C b/src/bltGraph.C index bb468fb..66a4d0e 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -1203,7 +1203,6 @@ static void DrawPlot(Graph* graphPtr, Drawable drawable) } Blt_DrawAxisLimits(graphPtr, drawable); Blt_DrawElements(graphPtr, drawable); - /* Blt_DrawAxes(graphPtr, drawable); */ } void Blt_MapGraph(Graph* graphPtr) diff --git a/tests/axis.tcl b/tests/axis.tcl index 346f1a5..ab3d647 100644 --- a/tests/axis.tcl +++ b/tests/axis.tcl @@ -36,7 +36,8 @@ bltTest2 $graph xaxis -labeloffset yes #bltTest2 $graph xaxis -limitsformat bltTest2 $graph xaxis -linewidth 2 bltTest2 $graph xaxis -logscale yes -#bltTest2 $graph xaxis -loose +#bltTest2 $graph xaxis -loosemin +#bltTest2 $graph xaxis -loosemax #bltTest2 $graph xaxis -majorticks #bltTest2 $graph xaxis -max #bltTest2 $graph xaxis -min |