summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-02-24 20:22:12 (GMT)
committerjoye <joye>2014-02-24 20:22:12 (GMT)
commit6ab7e481cab0fb3bf8d04db5af44394e514773fa (patch)
tree797230625779c31f1b969c3c3b2638b6fb5744ce /src
parent81d64674f0c91ca6714b2ff4d67ab362bf1d467a (diff)
downloadblt-6ab7e481cab0fb3bf8d04db5af44394e514773fa.zip
blt-6ab7e481cab0fb3bf8d04db5af44394e514773fa.tar.gz
blt-6ab7e481cab0fb3bf8d04db5af44394e514773fa.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltConfig.C47
-rw-r--r--src/bltConfig.h1
-rw-r--r--src/bltGrElemBar.C6
-rw-r--r--src/bltGrElemLine.C272
-rw-r--r--src/bltGrElemOp.C437
-rw-r--r--src/bltGrElemOp.h1
-rw-r--r--src/bltGrPenOp.C237
7 files changed, 513 insertions, 488 deletions
diff --git a/src/bltConfig.C b/src/bltConfig.C
index a263ac1..b77d502 100644
--- a/src/bltConfig.C
+++ b/src/bltConfig.C
@@ -209,14 +209,57 @@ static Tcl_Obj* DashesGetProc(ClientData clientData, Tk_Window tkwin,
{
Blt_Dashes* dashesPtr = (Blt_Dashes*)(widgRec + offset);
- Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj**)NULL);
Tcl_Obj* ll[12];
int ii=0;
while (dashesPtr->values[ii]) {
ll[ii] = Tcl_NewIntObj(dashesPtr->values[ii]);
ii++;
}
- Tcl_SetListObj(listObjPtr, ii, ll);
+ return Tcl_NewListObj(ii, ll);
+};
+
+// List
+static Tk_CustomOptionSetProc ListSetProc;
+static Tk_CustomOptionGetProc ListGetProc;
+Tk_ObjCustomOption listObjOption =
+ {
+ "list", ListSetProc, ListGetProc, NULL, NULL, NULL
+ };
+
+static int ListSetProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ const char*** listPtr = (const char***)(widgRec + offset);
+
+ const char** argv;
+ int argc;
+ if (Tcl_SplitList(interp, Tcl_GetString(*objPtr), &argc, &argv) != TCL_OK)
+ return TCL_ERROR;
+
+ if (*listPtr != NULL) {
+ Tcl_Free((void*)(*listPtr));
+ *listPtr = NULL;
+ }
+ *listPtr = argv;
+
+ return TCL_OK;
+};
+
+static Tcl_Obj* ListGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ const char*** listPtr = (const char***)(widgRec + offset);
+
+ // count how many
+ int cnt=0;
+ for (const char** p = *listPtr; *p != NULL; p++,cnt++) {}
+
+ Tcl_Obj** ll = calloc(cnt,sizeof(Tcl_Obj*));
+ for (int ii=0; ii<cnt; ii++)
+ ll[ii] = Tcl_NewStringObj(*listPtr[ii], -1);
+ Tcl_Obj* listObjPtr = Tcl_NewListObj(cnt, ll);
+ free(ll);
return listObjPtr;
};
diff --git a/src/bltConfig.h b/src/bltConfig.h
index 4529bdc..e8863c1 100644
--- a/src/bltConfig.h
+++ b/src/bltConfig.h
@@ -176,6 +176,7 @@ typedef struct {
extern Tk_ObjCustomOption backgroundObjOption;
extern Tk_ObjCustomOption pointObjOption;
extern Tk_ObjCustomOption dashesObjOption;
+extern Tk_ObjCustomOption listObjOption;
extern Blt_CustomOption stateOption;
extern Blt_CustomOption dashesOption;
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index be28d14..a115fe3 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -232,6 +232,8 @@ extern Blt_CustomOption bltBarStylesOption;
//***
+extern Tk_ObjCustomOption pairsObjOption;
+
static Tk_OptionSpec barElemOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
DEF_BAR_BACKGROUND,
@@ -248,6 +250,8 @@ static Tk_OptionSpec barElemOptionSpecs[] = {
-1, Tk_Offset(BarElement, builtinPen.borderWidth), 0, NULL, 0},
{TK_OPTION_SYNONYM, "-color", NULL, NULL, NULL,
-1, 0, 0, "-background", 0},
+ {TK_OPTION_CUSTOM, "-data", "data", "Data",
+ NULL, -1, 0, 0, &pairsObjOption, 0},
{TK_OPTION_PIXELS,"-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
DEF_BAR_ERRORBAR_LINE_WIDTH,
-1, Tk_Offset(BarElement, builtinPen.errorBarLineWidth), 0, NULL, 0},
@@ -334,8 +338,10 @@ static Blt_ConfigSpec barElemConfigSpecs[] = {
Tk_Offset(BarElement, builtinPen.errorBarCapWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_SYNONYM, "-fg", "foreground", (char *)NULL, (char *)NULL, 0, 0},
+ /*
{BLT_CONFIG_CUSTOM, "-data", "data", "Data", (char *)NULL, 0, 0,
&bltValuePairsOption},
+ */
{BLT_CONFIG_SYNONYM, "-fill", "background", (char *)NULL,
(char *)NULL, 0, 0},
{BLT_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index 9fc4dbe..1dbe082 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -380,117 +380,66 @@ extern Blt_CustomOption bltLinePenOption;
extern Blt_CustomOption bltXAxisOption;
extern Blt_CustomOption bltYAxisOption;
-#define DEF_LINE_ACTIVE_PEN "activeLine"
-#define DEF_LINE_AXIS_X "x"
-#define DEF_LINE_AXIS_Y "y"
-#define DEF_LINE_DASHES NULL
-#define DEF_LINE_DATA NULL
-#define DEF_LINE_FILL_COLOR "defcolor"
-#define DEF_LINE_HIDE "no"
-#define DEF_LINE_LABEL NULL
-#define DEF_LINE_LABEL_RELIEF "flat"
-#define DEF_LINE_MAX_SYMBOLS "0"
-#define DEF_LINE_OFFDASH_COLOR NULL
-#define DEF_LINE_OUTLINE_COLOR "defcolor"
-#define DEF_LINE_OUTLINE_WIDTH "1"
-#define DEF_LINE_PATTERN_BG NULL
-#define DEF_LINE_PATTERN_FG black
-#define DEF_LINE_PEN_COLOR navyblue
-#define DEF_LINE_PEN_DIRECTION "both"
-#define DEF_LINE_PEN_WIDTH "1"
-#define DEF_LINE_PIXELS "0.1i"
-#define DEF_LINE_REDUCE "0.0"
-#define DEF_LINE_SCALE_SYMBOLS "yes"
-#define DEF_LINE_SMOOTH "linear"
-#define DEF_LINE_STATE "normal"
-#define DEF_LINE_STIPPLE NULL
-#define DEF_LINE_STYLES ""
-#define DEF_LINE_SYMBOL "none"
-#define DEF_LINE_TAGS "all"
-#define DEF_LINE_X_DATA NULL
-#define DEF_LINE_Y_DATA NULL
-
-#define DEF_LINE_ERRORBAR_COLOR "defcolor"
-#define DEF_LINE_ERRORBAR_LINE_WIDTH "1"
-#define DEF_LINE_ERRORBAR_CAP_WIDTH "1"
-#define DEF_LINE_SHOW_ERRORBARS "both"
-
-#define DEF_PEN_ACTIVE_COLOR bblue
-#define DEF_PEN_DASHES NULL
-#define DEF_PEN_FILL_COLOR "defcolor"
-#define DEF_PEN_LINE_WIDTH "1"
-#define DEF_PEN_NORMAL_COLOR navyblue
-#define DEF_PEN_OFFDASH_COLOR NULL
-#define DEF_PEN_OUTLINE_COLOR "defcolor"
-#define DEF_PEN_OUTLINE_WIDTH "1"
-#define DEF_PEN_PIXELS "0.1i"
-#define DEF_PEN_SHOW_VALUES "no"
-#define DEF_PEN_SYMBOL "none"
-#define DEF_PEN_TYPE "line"
-#define DEF_PEN_VALUE_ANCHOR "s"
-#define DEF_PEN_VALUE_ANGLE 0
-#define DEF_PEN_VALUE_COLOR black
-#define DEF_PEN_VALUE_FONT STD_FONT_NUMBERS
-#define DEF_PEN_VALUE_FORMAT "%g"
-#define DEF_PEN_WIDTH "1"
-
//***
+extern Tk_ObjCustomOption linePenObjOption;
+extern Tk_ObjCustomOption pairsObjOption;
+
static Tk_OptionSpec lineElemOptionSpecs[] = {
+ {TK_OPTION_CUSTOM, "-activepen", "activePen", "ActivePen",
+ NULL, -1, Tk_Offset(LineElement, activePenPtr),
+ BLT_CONFIG_NULL_OK, &linePenObjOption, 0},
{TK_OPTION_COLOR, "-areaforeground", "areaForeground", "AreaForeground",
- DEF_LINE_PATTERN_FG,
- -1, Tk_Offset(LineElement, fillFgColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineElement, fillFgColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-areabackground", "areaBackground", "AreaBackground",
- DEF_LINE_PATTERN_BG,
- -1, Tk_Offset(LineElement, fillBg), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineElement, fillBg),
+ TK_OPTION_NULL_OK, NULL, 0},
+ {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
+ "all", -1, Tk_Offset(LineElement, obj.tags),
+ TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_COLOR, "-color", "color", "Color",
- DEF_LINE_PEN_COLOR,
- -1, Tk_Offset(LineElement, builtinPen.traceColor), 0, NULL, 0},
+ navyblue, -1, Tk_Offset(LineElement, builtinPen.traceColor), 0, NULL, 0},
+ {TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
+ NULL, -1, Tk_Offset(LineElement, builtinPen.traceDashes),
+ TK_OPTION_NULL_OK, &dashesObjOption, 0},
+ {TK_OPTION_CUSTOM, "-data", "data", "Data",
+ NULL, -1, 0, 0, &pairsObjOption, 0},
{TK_OPTION_PIXELS,"-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- DEF_LINE_ERRORBAR_LINE_WIDTH,
- -1, Tk_Offset(LineElement, builtinPen.errorBarLineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElement, builtinPen.errorBarLineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- DEF_LINE_ERRORBAR_CAP_WIDTH,
- -1, Tk_Offset(LineElement, builtinPen.errorBarCapWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElement, builtinPen.errorBarCapWidth), 0, NULL, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
- DEF_LINE_LABEL,
- -1, Tk_Offset(LineElement, label), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineElement, label),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief",
- DEF_LINE_LABEL_RELIEF,
- -1, Tk_Offset(LineElement, legendRelief), 0, NULL, 0},
+ "flat", -1, Tk_Offset(LineElement, legendRelief), 0, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- DEF_LINE_PEN_WIDTH,
- -1, Tk_Offset(LineElement, builtinPen.traceWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElement, builtinPen.traceWidth), 0, NULL, 0},
{TK_OPTION_INT, "-maxsymbols", "maxSymbols", "MaxSymbols",
- DEF_LINE_MAX_SYMBOLS,
- -1, Tk_Offset(LineElement, reqMaxSymbols), 0, NULL, 0},
+ 0, -1, Tk_Offset(LineElement, reqMaxSymbols), 0, NULL, 0},
{TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- DEF_LINE_OUTLINE_WIDTH,
- -1, Tk_Offset(LineElement, builtinPen.symbol.outlineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElement, builtinPen.symbol.outlineWidth), 0, NULL, 0},
+ {TK_OPTION_CUSTOM, "-pen", "pen", "Pen",
+ NULL, -1, Tk_Offset(LineElement, normalPenPtr),
+ TK_OPTION_NULL_OK, &linePenObjOption, 0},
{TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels",
- DEF_LINE_PIXELS,
- -1, Tk_Offset(LineElement, builtinPen.symbol.size), 0, NULL, 0},
+ "0.1i", -1, Tk_Offset(LineElement, builtinPen.symbol.size), 0, NULL, 0},
{TK_OPTION_DOUBLE, "-reduce", "reduce", "Reduce",
- DEF_LINE_REDUCE,
- -1, Tk_Offset(LineElement, rTolerance), 0, NULL, 0},
+ 0, -1, Tk_Offset(LineElement, rTolerance), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-scalesymbols", "scaleSymbols", "ScaleSymbols",
- DEF_LINE_SCALE_SYMBOLS,
- -1, Tk_Offset(LineElement, scaleSymbols), 0, NULL, 0},
+ "yes", -1, Tk_Offset(LineElement, scaleSymbols), 0, NULL, 0},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- DEF_PEN_VALUE_ANCHOR,
- -1, Tk_Offset(LineElement, builtinPen.valueStyle.anchor), 0, NULL, 0},
+ "s", -1, Tk_Offset(LineElement, builtinPen.valueStyle.anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- DEF_PEN_VALUE_COLOR,
- -1, Tk_Offset(LineElement, builtinPen.valueStyle.color), 0, NULL, 0},
+ "black", -1, Tk_Offset(LineElement, builtinPen.valueStyle.color),0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- DEF_PEN_VALUE_FONT,
- -1, Tk_Offset(LineElement, builtinPen.valueStyle.font), 0, NULL, 0},
+ STD_FONT_NUMBERS, -1, Tk_Offset(LineElement, builtinPen.valueStyle.font),
+ 0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- DEF_PEN_VALUE_FORMAT,
- -1, Tk_Offset(LineElement, builtinPen.valueFormat), 0, NULL, 0},
+ "%g", -1, Tk_Offset(LineElement, builtinPen.valueFormat), 0, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- DEF_PEN_VALUE_ANGLE,
- -1, Tk_Offset(LineElement, builtinPen.valueStyle.angle), 0, NULL, 0},
+ 0, -1, Tk_Offset(LineElement, builtinPen.valueStyle.angle), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -501,113 +450,115 @@ Blt_CustomOption bitmaskLineElemHideOption =
static Blt_ConfigSpec lineElemConfigSpecs[] = {
{BLT_CONFIG_CUSTOM, "-activepen", "activePen", "ActivePen",
- DEF_LINE_ACTIVE_PEN, Tk_Offset(LineElement, activePenPtr),
+ "activeLine", Tk_Offset(LineElement, activePenPtr),
BLT_CONFIG_NULL_OK, &bltLinePenOption},
{BLT_CONFIG_COLOR, "-areaforeground", "areaForeground", "AreaForeground",
- DEF_LINE_PATTERN_FG, Tk_Offset(LineElement, fillFgColor),
+ "black", Tk_Offset(LineElement, fillFgColor),
BLT_CONFIG_NULL_OK},
{BLT_CONFIG_BORDER, "-areabackground", "areaBackground",
- "AreaBackground", DEF_LINE_PATTERN_BG, Tk_Offset(LineElement, fillBg),
+ "AreaBackground", NULL, Tk_Offset(LineElement, fillBg),
BLT_CONFIG_NULL_OK},
- {BLT_CONFIG_CUSTOM, "-bindtags", "bindTags", "BindTags", DEF_LINE_TAGS,
+ {BLT_CONFIG_CUSTOM, "-bindtags", "bindTags", "BindTags", "all",
Tk_Offset(LineElement, obj.tags), BLT_CONFIG_NULL_OK,
&listOption},
- {BLT_CONFIG_COLOR, "-color", "color", "Color", DEF_LINE_PEN_COLOR,
+ {BLT_CONFIG_COLOR, "-color", "color", "Color", navyblue,
Tk_Offset(LineElement, builtinPen.traceColor), 0},
- {BLT_CONFIG_CUSTOM, "-dashes", "dashes", "Dashes", DEF_LINE_DASHES,
+ {BLT_CONFIG_CUSTOM, "-dashes", "dashes", "Dashes", NULL,
Tk_Offset(LineElement, builtinPen.traceDashes), BLT_CONFIG_NULL_OK,
&dashesOption},
- {BLT_CONFIG_CUSTOM, "-data", "data", "Data", DEF_LINE_DATA, 0, 0,
+ /*
+ {BLT_CONFIG_CUSTOM, "-data", "data", "Data", NULL, 0, 0,
&bltValuePairsOption},
+ */
{BLT_CONFIG_CUSTOM, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- DEF_LINE_ERRORBAR_COLOR,
+ "defcolor",
Tk_Offset(LineElement, builtinPen.errorBarColor), 0, &bltColorOption},
{BLT_CONFIG_PIXELS,"-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- DEF_LINE_ERRORBAR_LINE_WIDTH,
+ "1",
Tk_Offset(LineElement, builtinPen.errorBarLineWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- DEF_LINE_ERRORBAR_CAP_WIDTH,
+ "1",
Tk_Offset(LineElement, builtinPen.errorBarCapWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", DEF_LINE_FILL_COLOR,
+ {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", "defcolor",
Tk_Offset(LineElement, builtinPen.symbol.fillColor),
BLT_CONFIG_NULL_OK, &bltColorOption},
- {BLT_CONFIG_CUSTOM, "-hide", "hide", "Hide", DEF_LINE_HIDE,
+ {BLT_CONFIG_CUSTOM, "-hide", "hide", "Hide", "no",
Tk_Offset(LineElement, flags), BLT_CONFIG_DONT_SET_DEFAULT,
&bitmaskLineElemHideOption},
{BLT_CONFIG_STRING, "-label", "label", "Label", (char *)NULL,
Tk_Offset(LineElement, label), BLT_CONFIG_NULL_OK},
{BLT_CONFIG_RELIEF, "-legendrelief", "legendRelief", "LegendRelief",
- DEF_LINE_LABEL_RELIEF, Tk_Offset(LineElement, legendRelief),
+ "flat", Tk_Offset(LineElement, legendRelief),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- DEF_LINE_PEN_WIDTH, Tk_Offset(LineElement, builtinPen.traceWidth),
+ "1", Tk_Offset(LineElement, builtinPen.traceWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_CUSTOM, "-mapx", "mapX", "MapX",
- DEF_LINE_AXIS_X, Tk_Offset(LineElement, axes.x), 0, &bltXAxisOption},
+ "x", Tk_Offset(LineElement, axes.x), 0, &bltXAxisOption},
{BLT_CONFIG_CUSTOM, "-mapy", "mapY", "MapY",
- DEF_LINE_AXIS_Y, Tk_Offset(LineElement, axes.y), 0, &bltYAxisOption},
+ "y", Tk_Offset(LineElement, axes.y), 0, &bltYAxisOption},
{BLT_CONFIG_INT, "-maxsymbols", "maxSymbols", "MaxSymbols",
- DEF_LINE_MAX_SYMBOLS, Tk_Offset(LineElement, reqMaxSymbols),
+ "0", Tk_Offset(LineElement, reqMaxSymbols),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_CUSTOM, "-offdash", "offDash", "OffDash",
- DEF_LINE_OFFDASH_COLOR,
+ NULL,
Tk_Offset(LineElement, builtinPen.traceOffColor),
BLT_CONFIG_NULL_OK, &bltColorOption},
{BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline",
- DEF_LINE_OUTLINE_COLOR,
+ "defcolor",
Tk_Offset(LineElement, builtinPen.symbol.outlineColor),
0, &bltColorOption},
{BLT_CONFIG_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- DEF_LINE_OUTLINE_WIDTH,
+ "1",
Tk_Offset(LineElement, builtinPen.symbol.outlineWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_CUSTOM, "-pen", "pen", "Pen", (char *)NULL,
Tk_Offset(LineElement, normalPenPtr), BLT_CONFIG_NULL_OK,
&bltLinePenOption},
- {BLT_CONFIG_PIXELS, "-pixels", "pixels", "Pixels", DEF_LINE_PIXELS,
+ {BLT_CONFIG_PIXELS, "-pixels", "pixels", "Pixels", "0.1i",
Tk_Offset(LineElement, builtinPen.symbol.size), GRAPH | STRIPCHART},
{BLT_CONFIG_DOUBLE, "-reduce", "reduce", "Reduce",
- DEF_LINE_REDUCE, Tk_Offset(LineElement, rTolerance),
+ 0, Tk_Offset(LineElement, rTolerance),
GRAPH | STRIPCHART | BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_BOOLEAN, "-scalesymbols", "scaleSymbols", "ScaleSymbols",
- DEF_LINE_SCALE_SYMBOLS, Tk_Offset(LineElement, scaleSymbols),
+ "yes", Tk_Offset(LineElement, scaleSymbols),
BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_CUSTOM, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- DEF_LINE_SHOW_ERRORBARS,
+ "both",
Tk_Offset(LineElement, builtinPen.errorBarShow),
BLT_CONFIG_DONT_SET_DEFAULT, &fillOption},
{BLT_CONFIG_CUSTOM, "-showvalues", "showValues", "ShowValues",
- DEF_PEN_SHOW_VALUES, Tk_Offset(LineElement, builtinPen.valueShow),
+ "no", Tk_Offset(LineElement, builtinPen.valueShow),
BLT_CONFIG_DONT_SET_DEFAULT, &fillOption},
- {BLT_CONFIG_CUSTOM, "-smooth", "smooth", "Smooth", DEF_LINE_SMOOTH,
+ {BLT_CONFIG_CUSTOM, "-smooth", "smooth", "Smooth", "linear",
Tk_Offset(LineElement, reqSmooth), BLT_CONFIG_DONT_SET_DEFAULT,
&smoothOption},
- {BLT_CONFIG_CUSTOM, "-state", "state", "State", DEF_LINE_STATE,
+ {BLT_CONFIG_CUSTOM, "-state", "state", "State", "normal",
Tk_Offset(LineElement, state), BLT_CONFIG_DONT_SET_DEFAULT, &stateOption},
- {BLT_CONFIG_CUSTOM, "-styles", "styles", "Styles", DEF_LINE_STYLES,
+ {BLT_CONFIG_CUSTOM, "-styles", "styles", "Styles", "",
Tk_Offset(LineElement, stylesPalette), 0, &bltLineStylesOption},
- {BLT_CONFIG_CUSTOM, "-symbol", "symbol", "Symbol", DEF_LINE_SYMBOL,
+ {BLT_CONFIG_CUSTOM, "-symbol", "symbol", "Symbol", "none",
Tk_Offset(LineElement, builtinPen.symbol),
BLT_CONFIG_DONT_SET_DEFAULT, &symbolOption},
- {BLT_CONFIG_CUSTOM, "-trace", "trace", "Trace", DEF_LINE_PEN_DIRECTION,
+ {BLT_CONFIG_CUSTOM, "-trace", "trace", "Trace", "both",
Tk_Offset(LineElement, penDir),
BLT_CONFIG_DONT_SET_DEFAULT, &penDirOption},
{BLT_CONFIG_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- DEF_PEN_VALUE_ANCHOR,
+ "s",
Tk_Offset(LineElement, builtinPen.valueStyle.anchor), 0},
{BLT_CONFIG_COLOR, "-valuecolor", "valueColor", "ValueColor",
- DEF_PEN_VALUE_COLOR,
+ black,
Tk_Offset(LineElement, builtinPen.valueStyle.color), 0},
{BLT_CONFIG_FONT, "-valuefont", "valueFont", "ValueFont",
- DEF_PEN_VALUE_FONT,
+ STD_FONT_NUMBERS,
Tk_Offset(LineElement, builtinPen.valueStyle.font), 0},
{BLT_CONFIG_STRING, "-valueformat", "valueFormat", "ValueFormat",
- DEF_PEN_VALUE_FORMAT, Tk_Offset(LineElement, builtinPen.valueFormat),
+ "%g", Tk_Offset(LineElement, builtinPen.valueFormat),
BLT_CONFIG_NULL_OK},
{BLT_CONFIG_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- DEF_PEN_VALUE_ANGLE,
+ 0,
Tk_Offset(LineElement, builtinPen.valueStyle.angle), 0},
{BLT_CONFIG_CUSTOM, "-weights", "weights", "Weights", (char *)NULL,
Tk_Offset(LineElement, w), 0, &bltValuesOption},
@@ -638,99 +589,99 @@ static Blt_ConfigSpec lineElemConfigSpecs[] = {
static Tk_OptionSpec linePenOptionSpecs[] = {
{TK_OPTION_COLOR, "-color", "color", "Color",
- DEF_PEN_ACTIVE_COLOR,
+ bblue,
-1, Tk_Offset(LinePen, traceColor), 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- DEF_LINE_ERRORBAR_LINE_WIDTH,
+ "1",
-1, Tk_Offset(LinePen, errorBarLineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- DEF_LINE_ERRORBAR_CAP_WIDTH,
+ "1",
-1, Tk_Offset(LinePen, errorBarCapWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- DEF_PEN_WIDTH,
+ "1",
-1, Tk_Offset(LinePen, traceWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- DEF_PEN_OUTLINE_WIDTH,
+ "1",
-1, Tk_Offset(LinePen, symbol.outlineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels",
- DEF_PEN_PIXELS,
+ "0.1i",
-1, Tk_Offset(LinePen, symbol.size), 0, NULL, 0},
{TK_OPTION_STRING, "-type", "type", "Type",
- DEF_PEN_TYPE,
+ "line",
-1, Tk_Offset(Pen, typeId), 0, NULL, 0},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- DEF_PEN_VALUE_ANCHOR,
+ "s",
-1, Tk_Offset(LinePen, valueStyle.anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- DEF_PEN_VALUE_COLOR,
+ black,
-1, Tk_Offset(LinePen, valueStyle.color), 0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- DEF_PEN_VALUE_FONT,
+ STD_FONT_NUMBERS,
-1, Tk_Offset(LinePen, valueStyle.font), 0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- DEF_PEN_VALUE_FORMAT,
+ "%g",
-1, Tk_Offset(LinePen, valueFormat), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- DEF_PEN_VALUE_ANGLE,
+ 0,
-1, Tk_Offset(LinePen, valueStyle.angle), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
static Blt_ConfigSpec linePenConfigSpecs[] = {
- {BLT_CONFIG_COLOR, "-color", "color", "Color", DEF_PEN_ACTIVE_COLOR,
+ {BLT_CONFIG_COLOR, "-color", "color", "Color", bblue,
Tk_Offset(LinePen, traceColor), ACTIVE_PEN},
- {BLT_CONFIG_COLOR, "-color", "color", "Color", DEF_PEN_NORMAL_COLOR,
+ {BLT_CONFIG_COLOR, "-color", "color", "Color", navyblue,
Tk_Offset(LinePen, traceColor), NORMAL_PEN},
- {BLT_CONFIG_CUSTOM, "-dashes", "dashes", "Dashes", DEF_PEN_DASHES,
+ {BLT_CONFIG_CUSTOM, "-dashes", "dashes", "Dashes", NULL,
Tk_Offset(LinePen, traceDashes), BLT_CONFIG_NULL_OK | ALL_PENS,
&dashesOption},
{BLT_CONFIG_CUSTOM, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- DEF_LINE_ERRORBAR_COLOR, Tk_Offset(LinePen, errorBarColor),
+ "defcolor", Tk_Offset(LinePen, errorBarColor),
ALL_PENS, &bltColorOption},
{BLT_CONFIG_PIXELS, "-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- DEF_LINE_ERRORBAR_LINE_WIDTH, Tk_Offset(LinePen, errorBarLineWidth),
+ "1", Tk_Offset(LinePen, errorBarLineWidth),
ALL_PENS | BLT_CONFIG_DONT_SET_DEFAULT},
{BLT_CONFIG_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- DEF_LINE_ERRORBAR_CAP_WIDTH, Tk_Offset(LinePen, errorBarCapWidth),
+ "1", Tk_Offset(LinePen, errorBarCapWidth),
BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", DEF_PEN_FILL_COLOR,
+ {BLT_CONFIG_CUSTOM, "-fill", "fill", "Fill", "defcolor",
Tk_Offset(LinePen, symbol.fillColor), BLT_CONFIG_NULL_OK | ALL_PENS,
&bltColorOption},
{BLT_CONFIG_PIXELS, "-linewidth", "lineWidth", "LineWidth",
NULL, Tk_Offset(LinePen, traceWidth),
ALL_PENS| BLT_CONFIG_DONT_SET_DEFAULT},
- {BLT_CONFIG_CUSTOM, "-offdash", "offDash", "OffDash", DEF_PEN_OFFDASH_COLOR,
+ {BLT_CONFIG_CUSTOM, "-offdash", "offDash", "OffDash", NULL,
Tk_Offset(LinePen, traceOffColor), BLT_CONFIG_NULL_OK | ALL_PENS,
&bltColorOption},
- {BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline", DEF_PEN_OUTLINE_COLOR,
+ {BLT_CONFIG_CUSTOM, "-outline", "outline", "Outline", "defcolor",
Tk_Offset(LinePen, symbol.outlineColor), ALL_PENS, &bltColorOption},
{BLT_CONFIG_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- DEF_PEN_OUTLINE_WIDTH, Tk_Offset(LinePen, symbol.outlineWidth),
+ "1", Tk_Offset(LinePen, symbol.outlineWidth),
BLT_CONFIG_DONT_SET_DEFAULT | ALL_PENS},
- {BLT_CONFIG_PIXELS, "-pixels", "pixels", "Pixels", DEF_PEN_PIXELS,
+ {BLT_CONFIG_PIXELS, "-pixels", "pixels", "Pixels", "0.1i",
Tk_Offset(LinePen, symbol.size), ALL_PENS},
{BLT_CONFIG_CUSTOM, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- DEF_LINE_SHOW_ERRORBARS, Tk_Offset(LinePen, errorBarShow),
+ "both", Tk_Offset(LinePen, errorBarShow),
BLT_CONFIG_DONT_SET_DEFAULT, &fillOption},
{BLT_CONFIG_CUSTOM, "-showvalues", "showValues", "ShowValues",
- DEF_PEN_SHOW_VALUES, Tk_Offset(LinePen, valueShow),
+ "no", Tk_Offset(LinePen, valueShow),
ALL_PENS | BLT_CONFIG_DONT_SET_DEFAULT, &fillOption},
- {BLT_CONFIG_CUSTOM, "-symbol", "symbol", "Symbol", DEF_PEN_SYMBOL,
+ {BLT_CONFIG_CUSTOM, "-symbol", "symbol", "Symbol", "none",
Tk_Offset(LinePen, symbol), BLT_CONFIG_DONT_SET_DEFAULT | ALL_PENS,
&symbolOption},
- {BLT_CONFIG_STRING, "-type", (char *)NULL, (char *)NULL, DEF_PEN_TYPE,
+ {BLT_CONFIG_STRING, "-type", (char *)NULL, (char *)NULL, "line",
Tk_Offset(Pen, typeId), ALL_PENS | BLT_CONFIG_NULL_OK},
{BLT_CONFIG_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- DEF_PEN_VALUE_ANCHOR, Tk_Offset(LinePen, valueStyle.anchor), ALL_PENS},
+ "s", Tk_Offset(LinePen, valueStyle.anchor), ALL_PENS},
{BLT_CONFIG_COLOR, "-valuecolor", "valueColor", "ValueColor",
- DEF_PEN_VALUE_COLOR, Tk_Offset(LinePen, valueStyle.color), ALL_PENS},
+ black, Tk_Offset(LinePen, valueStyle.color), ALL_PENS},
{BLT_CONFIG_FONT, "-valuefont", "valueFont", "ValueFont",
- DEF_PEN_VALUE_FONT, Tk_Offset(LinePen, valueStyle.font), ALL_PENS},
+ STD_FONT_NUMBERS, Tk_Offset(LinePen, valueStyle.font), ALL_PENS},
{BLT_CONFIG_STRING, "-valueformat", "valueFormat", "ValueFormat",
- DEF_PEN_VALUE_FORMAT, Tk_Offset(LinePen, valueFormat),
+ "%g", Tk_Offset(LinePen, valueFormat),
ALL_PENS | BLT_CONFIG_NULL_OK},
{BLT_CONFIG_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- DEF_PEN_VALUE_ANGLE, Tk_Offset(LinePen, valueStyle.angle), ALL_PENS},
+ 0, Tk_Offset(LinePen, valueStyle.angle), ALL_PENS},
{BLT_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0}
};
@@ -1212,9 +1163,9 @@ 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") == 0)
penPtr->flags = ACTIVE_PEN;
- }
+
return (Pen *)penPtr;
}
@@ -4284,5 +4235,8 @@ Element * Blt_LineElement(Graph *graphPtr, const char *name, ClassId classId)
InitLinePen(graphPtr, elemPtr->builtinPenPtr);
bltLineStylesOption.clientData = (ClientData)sizeof(LineStyle);
+ Tk_InitOptions(graphPtr->interp, (char*)elemPtr->builtinPenPtr,
+ elemPtr->builtinPenPtr->optionTable, graphPtr->tkwin);
+
return (Element *)elemPtr;
}
diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C
index d6383da..409ad0e 100644
--- a/src/bltGrElemOp.C
+++ b/src/bltGrElemOp.C
@@ -40,12 +40,82 @@
#include "bltInt.h"
#include "bltGraph.h"
#include "bltOp.h"
-
-#define GRAPH_KEY "BLT Graph Data"
+#include "bltGrElem.h"
/* Ignore elements that aren't in the display list or have been deleted. */
#define IGNORE_ELEMENT(e) (((e)->link == NULL) || ((e)->flags & DELETE_PENDING))
+static int ParseValues(Tcl_Interp *interp, Tcl_Obj *objPtr, int *nValuesPtr,
+ double **arrayPtr);
+static void FreeDataValues(ElemValues *valuesPtr);
+static void FindRange(ElemValues *valuesPtr);
+
+// Value Pairs
+static Tk_CustomOptionSetProc PairsSetProc;
+static Tk_CustomOptionGetProc PairsGetProc;
+Tk_ObjCustomOption pairsObjOption =
+ {
+ "pairs", PairsSetProc, PairsGetProc, NULL, NULL, NULL
+ };
+
+static int PairsSetProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ double *values;
+ int nValues;
+ if (ParseValues(interp, *objPtr, &nValues, &values) != TCL_OK)
+ return TCL_ERROR;
+
+ if (nValues & 1) {
+ Tcl_AppendResult(interp, "odd number of data points", (char *)NULL);
+ free(values);
+ return TCL_ERROR;
+ }
+
+ nValues /= 2;
+ size_t newSize = nValues * sizeof(double);
+
+ Element* elemPtr = (Element*)widgRec;
+ FreeDataValues(&elemPtr->x);
+ FreeDataValues(&elemPtr->y);
+
+ if (newSize > 0) {
+ elemPtr->x.values = malloc(newSize);
+ elemPtr->y.values = malloc(newSize);
+ elemPtr->x.nValues = elemPtr->y.nValues = nValues;
+ int ii=0;
+ for (double* p = values; ii<nValues; ii++) {
+ elemPtr->x.values[ii] = *p++;
+ elemPtr->y.values[ii] = *p++;
+ }
+ free(values);
+ FindRange(&elemPtr->x);
+ FindRange(&elemPtr->y);
+ }
+
+ return TCL_OK;
+};
+
+static Tcl_Obj* PairsGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ Element *elemPtr = (Element*)widgRec;
+ int length = NUMBEROFPOINTS(elemPtr);
+
+ Tcl_Obj** ll = calloc(2*length,sizeof(Tcl_Obj*));
+ for (int ii=0, jj=0; ii<length; ii++) {
+ ll[jj++] = Tcl_NewDoubleObj(elemPtr->x.values[ii]);
+ ll[jj++] = Tcl_NewDoubleObj(elemPtr->y.values[ii]);
+ }
+ Tcl_Obj* listObjPtr = Tcl_NewListObj(2*length, ll);
+ free(ll);
+
+ return listObjPtr;
+};
+
+/* Along */
+
static Blt_OptionParseProc ObjToAlong;
static Blt_OptionPrintProc AlongToObj;
static Blt_CustomOption alongOption =
@@ -59,13 +129,6 @@ Blt_CustomOption bltValuesOption =
{
ObjToValues, ValuesToObj, FreeValues, (ClientData)0
};
-static Blt_OptionFreeProc FreeValuePairs;
-static Blt_OptionParseProc ObjToValuePairs;
-static Blt_OptionPrintProc ValuePairsToObj;
-Blt_CustomOption bltValuePairsOption =
- {
- ObjToValuePairs, ValuePairsToObj, FreeValuePairs, (ClientData)0
- };
static Blt_OptionFreeProc FreeStyles;
static Blt_OptionParseProc ObjToStyles;
@@ -80,12 +143,8 @@ Blt_CustomOption bltBarStylesOption =
ObjToStyles, StylesToObj, FreeStyles, (ClientData)0,
};
-#include "bltGrElem.h"
-
static Blt_VectorChangedProc VectorChangedProc;
-static void FindRange(ElemValues *valuesPtr);
-static void FreeDataValues(ElemValues *valuesPtr);
static Tcl_FreeProc FreeElement;
static int ElementObjConfigure(Tcl_Interp *interp, Graph* graphPtr,
@@ -252,7 +311,8 @@ static void FreeDataValues(ElemValues *valuesPtr)
{
switch (valuesPtr->type) {
case ELEM_SOURCE_VECTOR:
- FreeVectorSource(valuesPtr); break;
+ FreeVectorSource(valuesPtr);
+ break;
case ELEM_SOURCE_VALUES:
break;
}
@@ -405,74 +465,6 @@ static Tcl_Obj *ValuesToObj(ClientData clientData, Tcl_Interp *interp,
return Tcl_NewStringObj("", 0);
}
-static void FreeValuePairs(ClientData clientData, Display *display,
- char *widgRec, int offset)
-{
- Element *elemPtr = (Element *)widgRec;
-
- FreeDataValues(&elemPtr->x);
- FreeDataValues(&elemPtr->y);
-}
-
-static int ObjToValuePairs(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj *objPtr, char *widgRec,
- int offset, int flags)
-{
- Element *elemPtr = (Element *)widgRec;
- double *values;
- int nValues;
- size_t newSize;
-
- if (ParseValues(interp, objPtr, &nValues, &values) != TCL_OK) {
- return TCL_ERROR;
- }
- if (nValues & 1) {
- Tcl_AppendResult(interp, "odd number of data points", (char *)NULL);
- free(values);
- return TCL_ERROR;
- }
- nValues /= 2;
- newSize = nValues * sizeof(double);
- FreeDataValues(&elemPtr->x); /* Release the current data sources. */
- FreeDataValues(&elemPtr->y);
- if (newSize > 0) {
- double *p;
- int i;
-
- elemPtr->x.values = malloc(newSize);
- elemPtr->y.values = malloc(newSize);
- elemPtr->x.nValues = elemPtr->y.nValues = nValues;
- for (p = values, i = 0; i < nValues; i++) {
- elemPtr->x.values[i] = *p++;
- elemPtr->y.values[i] = *p++;
- }
- free(values);
- FindRange(&elemPtr->x);
- FindRange(&elemPtr->y);
- }
- return TCL_OK;
-}
-
-static Tcl_Obj *ValuePairsToObj(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, char *widgRec, int offset,
- int flags)
-{
- Element *elemPtr = (Element *)widgRec;
- Tcl_Obj *listObjPtr;
- int i;
- int length;
-
- length = NUMBEROFPOINTS(elemPtr);
- listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
- for (i = 0; i < length; i++) {
- Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewDoubleObj(elemPtr->x.values[i]));
- Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewDoubleObj(elemPtr->y.values[i]));
- }
- return listObjPtr;
-}
-
static int ObjToAlong(ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj *objPtr, char *widgRec,
int offset, int flags)
@@ -716,6 +708,8 @@ static void DestroyElement(Element *elemPtr)
Blt_DeleteBindings(graphPtr->bindTable, elemPtr);
Blt_Legend_RemoveElement(graphPtr, elemPtr);
+ FreeDataValues(&elemPtr->x);
+ FreeDataValues(&elemPtr->y);
/*
* Call the element's own destructor to release the memory and
* resources allocated for it.
@@ -780,18 +774,16 @@ static int CreateElement(Graph *graphPtr, Tcl_Interp *interp, int objc,
default:
return TCL_ERROR;
}
+ if (!elemPtr)
+ return TCL_ERROR;
+
elemPtr->hashPtr = hPtr;
Tcl_SetHashValue(hPtr, elemPtr);
- /*
- if (Blt_ConfigureComponentFromObj(interp, graphPtr->tkwin,
- elemPtr->obj.name, "Element", elemPtr->configSpecs, objc - 4, objv + 4,
- (char *)elemPtr, 0) != 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;
- }
- */
- (*elemPtr->procsPtr->configProc) (graphPtr, elemPtr);
+ }
elemPtr->link = Blt_Chain_Append(graphPtr->elements.displayList, elemPtr);
graphPtr->flags |= CACHE_DIRTY;
@@ -920,6 +912,126 @@ void Blt_ActiveElementsToPostScript( Graph *graphPtr, Blt_Ps ps)
}
}
+ClientData Blt_MakeElementTag(Graph *graphPtr, const char *tagName)
+{
+ Tcl_HashEntry *hPtr;
+ int isNew;
+
+ hPtr = Tcl_CreateHashEntry(&graphPtr->elements.tagTable, tagName, &isNew);
+ return Tcl_GetHashKey(&graphPtr->elements.tagTable, hPtr);
+}
+
+static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[])
+{
+ if (objc != 5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "cget option");
+ return TCL_ERROR;
+ }
+
+ Element *elemPtr;
+ if (Blt_GetElement(interp, graphPtr, objv[3], &elemPtr) != TCL_OK)
+ return TCL_ERROR;
+
+ Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)elemPtr,
+ elemPtr->optionTable,
+ objv[4], graphPtr->tkwin);
+ if (objPtr == NULL)
+ return TCL_ERROR;
+ else
+ Tcl_SetObjResult(interp, objPtr);
+ return TCL_OK;
+}
+
+static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[])
+{
+ Element* elemPtr;
+ if (Blt_GetElement(interp, graphPtr, objv[3], &elemPtr) != TCL_OK)
+ return TCL_ERROR;
+
+ if (objc <= 5) {
+ Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)elemPtr,
+ elemPtr->optionTable,
+ (objc == 5) ? objv[4] : NULL,
+ graphPtr->tkwin);
+ if (objPtr == NULL)
+ return TCL_ERROR;
+ else
+ Tcl_SetObjResult(interp, objPtr);
+ return TCL_OK;
+ }
+ else
+ return ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4);
+}
+
+static int ElementObjConfigure(Tcl_Interp *interp, Graph* graphPtr,
+ Element* elemPtr,
+ int objc, Tcl_Obj* const objv[])
+{
+ Tk_SavedOptions savedOptions;
+ int mask =0;
+ int error;
+ Tcl_Obj* errorResult;
+
+ for (error=0; error<=1; error++) {
+ if (!error) {
+ if (Tk_SetOptions(interp, (char*)elemPtr, elemPtr->optionTable,
+ objc, objv, graphPtr->tkwin, &savedOptions, &mask)
+ != TCL_OK)
+ continue;
+ }
+ else {
+ errorResult = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(errorResult);
+ Tk_RestoreSavedOptions(&savedOptions);
+ }
+
+ graphPtr->flags |= mask;
+ graphPtr->flags |= CACHE_DIRTY;
+ if ((*elemPtr->procsPtr->configProc) (graphPtr, elemPtr) != TCL_OK)
+ return TCL_ERROR;
+ Blt_EventuallyRedrawGraph(graphPtr);
+
+ break;
+ }
+
+ if (!error) {
+ Tk_FreeSavedOptions(&savedOptions);
+ return TCL_OK;
+ }
+ else {
+ Tcl_SetObjResult(interp, errorResult);
+ Tcl_DecrRefCount(errorResult);
+ return TCL_ERROR;
+ }
+}
+ /*
+ if (Blt_ConfigModified(elemPtr->configSpecs, "-hide", (char *)NULL)) {
+ graphPtr->flags |= RESET_AXES;
+ elemPtr->flags |= MAP_ITEM;
+ }
+ */
+ /* If data points or axes have changed, reset the axes (may
+ * affect autoscaling) and recalculate the screen points of
+ * the element. */
+
+ /*
+ if (Blt_ConfigModified(elemPtr->configSpecs, "-*data", "-map*", "-x",
+ "-y", (char *)NULL)) {
+ graphPtr->flags |= RESET_WORLD;
+ elemPtr->flags |= MAP_ITEM;
+ }
+ */
+ /* The new label may change the size of the legend */
+ /*
+ if (Blt_ConfigModified(elemPtr->configSpecs, "-label", (char *)NULL)) {
+ graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD);
+ }
+ */
+
+// Ops
+
static int ActivateOp(Graph *graphPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const *objv)
{
@@ -974,15 +1086,6 @@ static int ActivateOp(Graph *graphPtr, Tcl_Interp *interp,
return TCL_OK;
}
-ClientData Blt_MakeElementTag(Graph *graphPtr, const char *tagName)
-{
- Tcl_HashEntry *hPtr;
- int isNew;
-
- hPtr = Tcl_CreateHashEntry(&graphPtr->elements.tagTable, tagName, &isNew);
- return Tcl_GetHashKey(&graphPtr->elements.tagTable, hPtr);
-}
-
static int BindOp(Graph *graphPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const *objv)
{
@@ -1012,57 +1115,6 @@ static int CreateOp(Graph *graphPtr, Tcl_Interp *interp,
return CreateElement(graphPtr, interp, objc, objv, classId);
}
-static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
- int objc, Tcl_Obj* const objv[])
-{
- if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "cget option");
- return TCL_ERROR;
- }
-
- Element *elemPtr;
- if (Blt_GetElement(interp, graphPtr, objv[3], &elemPtr) != TCL_OK)
- return TCL_ERROR;
-
- Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)elemPtr,
- elemPtr->optionTable,
- objv[4], graphPtr->tkwin);
- if (objPtr == NULL)
- return TCL_ERROR;
- else
- Tcl_SetObjResult(interp, objPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ClosestOp --
- *
- * Find the element closest to the specified screen coordinates.
- * Options:
- * -halo Consider points only with this maximum distance
- * from the picked coordinate.
- * -interpolate Find closest point along element traces, not just
- * data points.
- * -along
- *
- * Results:
- * A standard TCL result. If an element could be found within
- * the halo distance, the interpreter result is "1", otherwise
- * "0". If a closest element exists, the designated TCL array
- * variable will be set with the following information:
- *
- * 1) the element name,
- * 2) the index of the closest point,
- * 3) the distance (in screen coordinates) from the picked X-Y
- * coordinate and the closest point,
- * 4) the X coordinate (graph coordinate) of the closest point,
- * 5) and the Y-coordinate.
- *
- *---------------------------------------------------------------------------
- */
-
static Blt_ConfigSpec closestSpecs[] = {
{BLT_CONFIG_PIXELS, "-halo", (char *)NULL, (char *)NULL,
(char *)NULL, Tk_Offset(ClosestSearch, halo), 0},
@@ -1185,93 +1237,6 @@ static int ClosestOp(Graph *graphPtr, Tcl_Interp *interp,
return TCL_OK;
}
-static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
- int objc, Tcl_Obj* const objv[])
-{
- Element* elemPtr;
- if (Blt_GetElement(interp, graphPtr, objv[3], &elemPtr) != TCL_OK)
- return TCL_ERROR;
-
- if (objc <= 5) {
- Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)elemPtr,
- elemPtr->optionTable,
- (objc == 5) ? objv[4] : NULL,
- graphPtr->tkwin);
- if (objPtr == NULL)
- return TCL_ERROR;
- else
- Tcl_SetObjResult(interp, objPtr);
- return TCL_OK;
- }
- else
- return ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4);
-}
-
-static int ElementObjConfigure(Tcl_Interp *interp, Graph* graphPtr,
- Element* elemPtr,
- int objc, Tcl_Obj* const objv[])
-{
- Tk_SavedOptions savedOptions;
- int mask =0;
- int error;
- Tcl_Obj* errorResult;
-
- for (error=0; error<=1; error++) {
- if (!error) {
- if (Tk_SetOptions(interp, (char*)elemPtr, elemPtr->optionTable,
- objc, objv, graphPtr->tkwin, &savedOptions, &mask)
- != TCL_OK)
- continue;
- }
- else {
- errorResult = Tcl_GetObjResult(interp);
- Tcl_IncrRefCount(errorResult);
- Tk_RestoreSavedOptions(&savedOptions);
- }
-
- graphPtr->flags |= mask;
- graphPtr->flags |= CACHE_DIRTY;
- if ((*elemPtr->procsPtr->configProc) (graphPtr, elemPtr) != TCL_OK)
- return TCL_ERROR;
- Blt_EventuallyRedrawGraph(graphPtr);
-
- break;
- }
-
- if (!error) {
- Tk_FreeSavedOptions(&savedOptions);
- return TCL_OK;
- }
- else {
- Tcl_SetObjResult(interp, errorResult);
- Tcl_DecrRefCount(errorResult);
- return TCL_ERROR;
- }
-}
- /*
- if (Blt_ConfigModified(elemPtr->configSpecs, "-hide", (char *)NULL)) {
- graphPtr->flags |= RESET_AXES;
- elemPtr->flags |= MAP_ITEM;
- }
- */
- /* If data points or axes have changed, reset the axes (may
- * affect autoscaling) and recalculate the screen points of
- * the element. */
-
- /*
- if (Blt_ConfigModified(elemPtr->configSpecs, "-*data", "-map*", "-x",
- "-y", (char *)NULL)) {
- graphPtr->flags |= RESET_WORLD;
- elemPtr->flags |= MAP_ITEM;
- }
- */
- /* The new label may change the size of the legend */
- /*
- if (Blt_ConfigModified(elemPtr->configSpecs, "-label", (char *)NULL)) {
- graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD);
- }
- */
-
static int DeactivateOp(Graph *graphPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const *objv)
{
diff --git a/src/bltGrElemOp.h b/src/bltGrElemOp.h
index d5db973..de35d67 100644
--- a/src/bltGrElemOp.h
+++ b/src/bltGrElemOp.h
@@ -196,7 +196,6 @@ typedef struct {
double min, max;
} ElemValues;
-
struct _Element {
GraphObj obj; /* Must be first field in element. */
unsigned int flags;
diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C
index e6307e0..2489e52 100644
--- a/src/bltGrPenOp.C
+++ b/src/bltGrPenOp.C
@@ -43,13 +43,63 @@
typedef int (GraphPenProc)(Tcl_Interp *interp, Graph *graphPtr, int objc,
Tcl_Obj *const *objv);
-static Blt_OptionFreeProc FreeColor;
-static Blt_OptionParseProc ObjToColor;
-static Blt_OptionPrintProc ColorToObj;
-Blt_CustomOption bltColorOption = {
- ObjToColor, ColorToObj, FreeColor, (ClientData)0
+//***
+
+static Tk_CustomOptionSetProc PenSetProc;
+static Tk_CustomOptionGetProc PenGetProc;
+Tk_ObjCustomOption barPenObjOption =
+ {
+ "barPen", PenSetProc, PenGetProc, NULL, NULL, (ClientData)CID_ELEM_BAR
+ };
+Tk_ObjCustomOption linePenObjOption =
+ {
+ "linePen", PenSetProc, PenGetProc, NULL, NULL, (ClientData)CID_ELEM_LINE
+ };
+
+static int PenSetProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec,
+ int offset, char* save, int flags)
+{
+ Pen** penPtrPtr = (Pen**)(widgRec + offset);
+ const char* string = Tcl_GetString(*objPtr);
+ if ((string[0] == '\0') && (flags & TK_OPTION_NULL_OK)) {
+ Blt_FreePen(*penPtrPtr);
+ *penPtrPtr = NULL;
+ }
+ else {
+ Pen *penPtr;
+ Graph *graphPtr = Blt_GetGraphFromWindowData(tkwin);
+ ClassId classId = (ClassId)clientData; /* Element type. */
+
+ if (classId == CID_NONE)
+ classId = graphPtr->classId;
+
+ if (Blt_GetPenFromObj(interp, graphPtr, objPtr, classId, &penPtr)
+ != TCL_OK)
+ return TCL_ERROR;
+
+ Blt_FreePen(*penPtrPtr);
+ *penPtrPtr = penPtr;
+ }
+
+ return TCL_OK;
};
+static Tcl_Obj* PenGetProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, int offset)
+{
+ Pen* penPtr = *(Pen**)(widgRec + offset);
+
+ if (penPtr == NULL) {
+ return Tcl_NewStringObj("", -1);
+ }
+ else {
+ return Tcl_NewStringObj(penPtr->name, -1);
+ }
+};
+
+//***
+
static Blt_OptionFreeProc FreePen;
static Blt_OptionParseProc ObjToPen;
static Blt_OptionPrintProc PenToObj;
@@ -60,94 +110,94 @@ Blt_CustomOption bltLinePenOption = {
ObjToPen, PenToObj, FreePen, (ClientData)CID_ELEM_LINE
};
+static Blt_OptionFreeProc FreeColor;
+static Blt_OptionParseProc ObjToColor;
+static Blt_OptionPrintProc ColorToObj;
+Blt_CustomOption bltColorOption = {
+ ObjToColor, ColorToObj, FreeColor, (ClientData)0
+};
+
/*ARGSUSED*/
static void
-FreeColor(
+FreePen(
ClientData clientData, /* Not used. */
Display *display, /* Not used. */
char *widgRec,
int offset)
{
- XColor *colorPtr = *(XColor **)(widgRec + offset);
+ Pen **penPtrPtr = (Pen **)(widgRec + offset);
- if ((colorPtr != NULL) && (colorPtr != COLOR_DEFAULT)) {
- Tk_FreeColor(colorPtr);
+ if (*penPtrPtr != NULL) {
+ Blt_FreePen(*penPtrPtr);
}
}
/*
*---------------------------------------------------------------------------
-
- * ObjToColor --
*
- * Convert the string representation of a color into a XColor pointer.
+ * ObjToPen --
+ *
+ * Convert the color value into a string.
*
* Results:
- * The return value is a standard TCL result. The color pointer is
- * written into the widget record.
+ * The string representing the symbol color is returned.
*
*---------------------------------------------------------------------------
*/
/*ARGSUSED*/
static int
-ObjToColor(
+ObjToPen(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Interpreter to send results back to */
Tk_Window tkwin, /* Not used. */
- Tcl_Obj *objPtr, /* String representing color */
+ Tcl_Obj *objPtr, /* String representing pen */
char *widgRec, /* Widget record */
int offset, /* Offset to field in structure */
int flags)
{
- XColor **colorPtrPtr = (XColor **)(widgRec + offset);
- XColor *colorPtr;
+ Pen **penPtrPtr = (Pen **)(widgRec + offset);
const char *string;
- char c;
- int length;
- string = Tcl_GetStringFromObj(objPtr, &length);
- c = string[0];
+ string = Tcl_GetString(objPtr);
+ if ((string[0] == '\0') && (flags & BLT_CONFIG_NULL_OK)) {
+ Blt_FreePen(*penPtrPtr);
+ *penPtrPtr = NULL;
+ } else {
+ Pen *penPtr;
+ Graph *graphPtr;
+ ClassId classId = (ClassId)clientData; /* Element type. */
- if ((c == '\0') && (flags & BLT_CONFIG_NULL_OK)) {
- if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
- Tk_FreeColor(*colorPtrPtr);
+ graphPtr = Blt_GetGraphFromWindowData(tkwin);
+ assert(graphPtr);
+
+ if (classId == CID_NONE) {
+ classId = graphPtr->classId;
}
- *colorPtrPtr = NULL;
- return TCL_OK;
- }
- if ((c == 'd') && (strncmp(string, "defcolor", length) == 0)) {
- if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
- Tk_FreeColor(*colorPtrPtr);
+ if (Blt_GetPenFromObj(interp, graphPtr, objPtr, classId, &penPtr)
+ != TCL_OK) {
+ return TCL_ERROR;
}
- *colorPtrPtr = COLOR_DEFAULT;
- return TCL_OK;
- }
- colorPtr = Tk_AllocColorFromObj(interp, tkwin, objPtr);
- if (colorPtr == NULL) {
- return TCL_ERROR;
- }
- if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
- Tk_FreeColor(*colorPtrPtr);
+ Blt_FreePen(*penPtrPtr);
+ *penPtrPtr = penPtr;
}
- *colorPtrPtr = colorPtr;
return TCL_OK;
}
/*
*---------------------------------------------------------------------------
*
- * ColorToObj --
+ * PenToObj --
*
- * Convert the color value into a string.
+ * Parse the name of the name.
*
* Results:
- * The string representing the symbol color is returned.
+ * The return value is a standard TCL result.
*
*---------------------------------------------------------------------------
*/
/*ARGSUSED*/
static Tcl_Obj *
-ColorToObj(
+PenToObj(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Not used. */
Tk_Window tkwin, /* Not used. */
@@ -155,100 +205,103 @@ ColorToObj(
int offset, /* Offset to field in structure */
int flags) /* Not used. */
{
- XColor *colorPtr = *(XColor **)(widgRec + offset);
- Tcl_Obj *objPtr;
+ Pen *penPtr = *(Pen **)(widgRec + offset);
- if (colorPtr == NULL) {
- objPtr = Tcl_NewStringObj("", -1);
- } else if (colorPtr == COLOR_DEFAULT) {
- objPtr = Tcl_NewStringObj("defcolor", -1);
+ if (penPtr == NULL) {
+ return Tcl_NewStringObj("", -1);
} else {
- objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
+ return Tcl_NewStringObj(penPtr->name, -1);
}
- return objPtr;
}
/*ARGSUSED*/
static void
-FreePen(
+FreeColor(
ClientData clientData, /* Not used. */
Display *display, /* Not used. */
char *widgRec,
int offset)
{
- Pen **penPtrPtr = (Pen **)(widgRec + offset);
+ XColor *colorPtr = *(XColor **)(widgRec + offset);
- if (*penPtrPtr != NULL) {
- Blt_FreePen(*penPtrPtr);
+ if ((colorPtr != NULL) && (colorPtr != COLOR_DEFAULT)) {
+ Tk_FreeColor(colorPtr);
}
}
/*
*---------------------------------------------------------------------------
+
+ * ObjToColor --
*
- * ObjToPen --
- *
- * Convert the color value into a string.
+ * Convert the string representation of a color into a XColor pointer.
*
* Results:
- * The string representing the symbol color is returned.
+ * The return value is a standard TCL result. The color pointer is
+ * written into the widget record.
*
*---------------------------------------------------------------------------
*/
/*ARGSUSED*/
static int
-ObjToPen(
+ObjToColor(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Interpreter to send results back to */
Tk_Window tkwin, /* Not used. */
- Tcl_Obj *objPtr, /* String representing pen */
+ Tcl_Obj *objPtr, /* String representing color */
char *widgRec, /* Widget record */
int offset, /* Offset to field in structure */
int flags)
{
- Pen **penPtrPtr = (Pen **)(widgRec + offset);
+ XColor **colorPtrPtr = (XColor **)(widgRec + offset);
+ XColor *colorPtr;
const char *string;
+ char c;
+ int length;
- string = Tcl_GetString(objPtr);
- if ((string[0] == '\0') && (flags & BLT_CONFIG_NULL_OK)) {
- Blt_FreePen(*penPtrPtr);
- *penPtrPtr = NULL;
- } else {
- Pen *penPtr;
- Graph *graphPtr;
- ClassId classId = (ClassId)clientData; /* Element type. */
-
- graphPtr = Blt_GetGraphFromWindowData(tkwin);
- assert(graphPtr);
+ string = Tcl_GetStringFromObj(objPtr, &length);
+ c = string[0];
- if (classId == CID_NONE) {
- classId = graphPtr->classId;
+ if ((c == '\0') && (flags & BLT_CONFIG_NULL_OK)) {
+ if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
+ Tk_FreeColor(*colorPtrPtr);
}
- if (Blt_GetPenFromObj(interp, graphPtr, objPtr, classId, &penPtr)
- != TCL_OK) {
- return TCL_ERROR;
+ *colorPtrPtr = NULL;
+ return TCL_OK;
+ }
+ if ((c == 'd') && (strncmp(string, "defcolor", length) == 0)) {
+ if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
+ Tk_FreeColor(*colorPtrPtr);
}
- Blt_FreePen(*penPtrPtr);
- *penPtrPtr = penPtr;
+ *colorPtrPtr = COLOR_DEFAULT;
+ return TCL_OK;
+ }
+ colorPtr = Tk_AllocColorFromObj(interp, tkwin, objPtr);
+ if (colorPtr == NULL) {
+ return TCL_ERROR;
}
+ if ((*colorPtrPtr != NULL) && (*colorPtrPtr != COLOR_DEFAULT)) {
+ Tk_FreeColor(*colorPtrPtr);
+ }
+ *colorPtrPtr = colorPtr;
return TCL_OK;
}
/*
*---------------------------------------------------------------------------
*
- * PenToObj --
+ * ColorToObj --
*
- * Parse the name of the name.
+ * Convert the color value into a string.
*
* Results:
- * The return value is a standard TCL result.
+ * The string representing the symbol color is returned.
*
*---------------------------------------------------------------------------
*/
/*ARGSUSED*/
static Tcl_Obj *
-PenToObj(
+ColorToObj(
ClientData clientData, /* Not used. */
Tcl_Interp *interp, /* Not used. */
Tk_Window tkwin, /* Not used. */
@@ -256,13 +309,17 @@ PenToObj(
int offset, /* Offset to field in structure */
int flags) /* Not used. */
{
- Pen *penPtr = *(Pen **)(widgRec + offset);
+ XColor *colorPtr = *(XColor **)(widgRec + offset);
+ Tcl_Obj *objPtr;
- if (penPtr == NULL) {
- return Tcl_NewStringObj("", -1);
+ if (colorPtr == NULL) {
+ objPtr = Tcl_NewStringObj("", -1);
+ } else if (colorPtr == COLOR_DEFAULT) {
+ objPtr = Tcl_NewStringObj("defcolor", -1);
} else {
- return Tcl_NewStringObj(penPtr->name, -1);
+ objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
}
+ return objPtr;
}
/*