diff options
Diffstat (limited to 'src/bltGrPenBar.C')
-rw-r--r-- | src/bltGrPenBar.C | 161 |
1 files changed, 85 insertions, 76 deletions
diff --git a/src/bltGrPenBar.C b/src/bltGrPenBar.C index ca56d29..6625b24 100644 --- a/src/bltGrPenBar.C +++ b/src/bltGrPenBar.C @@ -31,42 +31,44 @@ static Tk_OptionSpec barPenOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, fill), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, -1, 0, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - STD_BORDERWIDTH, -1, Tk_Offset(BarPen, borderWidth), 0, NULL, 0}, + STD_BORDERWIDTH, -1, Tk_Offset(BarPenOptions, borderWidth), 0, NULL, 0}, {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", - NULL, -1, Tk_Offset(BarPen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(BarPenOptions, errorBarColor), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth","ErrorBarWidth", - "1", -1, Tk_Offset(BarPen, errorBarLineWidth), 0, NULL, 0}, + "1", -1, Tk_Offset(BarPenOptions, errorBarLineWidth), 0, NULL, 0}, {TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap", - "2", -1, Tk_Offset(BarPen, errorBarCapWidth), 0, NULL, 0}, + "2", -1, Tk_Offset(BarPenOptions, errorBarCapWidth), 0, NULL, 0}, {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, outlineColor), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", - "raised", -1, Tk_Offset(BarPen, relief), 0, NULL, 0}, + "raised", -1, Tk_Offset(BarPenOptions, relief), 0, NULL, 0}, {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", - "both", -1, Tk_Offset(BarPen, errorBarShow), 0, &fillObjOption, 0}, + "both", -1, Tk_Offset(BarPenOptions, errorBarShow), 0, &fillObjOption, 0}, {TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues", - "none", -1, Tk_Offset(BarPen, valueShow), 0, &fillObjOption, 0}, + "none", -1, Tk_Offset(BarPenOptions, valueShow), 0, &fillObjOption, 0}, {TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple", - NULL, -1, Tk_Offset(BarPen, stipple), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(BarPenOptions, stipple), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", - "s", -1, Tk_Offset(BarPen, valueStyle.anchor), 0, NULL, 0}, + "s", -1, Tk_Offset(BarPenOptions, valueStyle.anchor), 0, NULL, 0}, {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, valueStyle.color), 0, NULL, 0}, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, valueStyle.color), + 0, NULL, 0}, {TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont", - STD_FONT_SMALL, -1, Tk_Offset(BarPen, valueStyle.font), 0, NULL, 0}, + STD_FONT_SMALL, -1, Tk_Offset(BarPenOptions, valueStyle.font), 0, NULL, 0}, {TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat", - "%g", -1, Tk_Offset(BarPen, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, + "%g", -1, Tk_Offset(BarPenOptions, valueFormat), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate", - "0", -1, Tk_Offset(BarPen, valueStyle.angle), 0, NULL, 0}, + "0", -1, Tk_Offset(BarPenOptions, valueStyle.angle), 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; @@ -82,88 +84,95 @@ Pen* CreateBarPen(Graph* graphPtr, const char *penName) void InitBarPen(Graph* graphPtr, BarPen* penPtr, const char* penName) { + BarPenOptions* ops = (BarPenOptions*)penPtr->ops; + penPtr->configProc = ConfigureBarPenProc; penPtr->destroyProc = DestroyBarPenProc; penPtr->classId = CID_ELEM_BAR; penPtr->name = Blt_Strdup(penName); - Blt_Ts_InitStyle(penPtr->valueStyle); + Blt_Ts_InitStyle(ops->valueStyle); penPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs); } -int ConfigureBarPenProc(Graph* graphPtr, Pen *basePtr) +int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr) { - BarPen* penPtr = (BarPen*)basePtr; - int screenNum = Tk_ScreenNumber(graphPtr->tkwin); - XGCValues gcValues; - unsigned long gcMask; - GC newGC; + BarPen* bpPtr = (BarPen*)penPtr; + BarPenOptions* ops = (BarPenOptions*)bpPtr->ops; // outlineGC - gcMask = GCForeground | GCLineWidth; - gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); - - if (penPtr->outlineColor) - gcValues.foreground = penPtr->outlineColor->pixel; - else if (penPtr->fill) - gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; - - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->outlineGC) - Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - penPtr->outlineGC = newGC; - - newGC = NULL; - if (penPtr->stipple != None) { - // Handle old-style -stipple specially - gcMask = GCForeground | GCBackground | GCFillStyle | GCStipple; - gcValues.foreground = BlackPixel(graphPtr->display, screenNum); - gcValues.background = WhitePixel(graphPtr->display, screenNum); - if (penPtr->fill) - gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; - else if (penPtr->outlineColor) - gcValues.foreground = penPtr->outlineColor->pixel; - - gcValues.stipple = penPtr->stipple; - gcValues.fill_style = FillStippled; - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + { + unsigned long gcMask = GCForeground | GCLineWidth; + XGCValues gcValues; + gcValues.line_width = LineWidth(ops->errorBarLineWidth); + if (ops->outlineColor) + gcValues.foreground = ops->outlineColor->pixel; + else if (ops->fill) + gcValues.foreground = Tk_3DBorderColor(ops->fill)->pixel; + GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (bpPtr->outlineGC) + Tk_FreeGC(graphPtr->display, bpPtr->outlineGC); + bpPtr->outlineGC = newGC; + } + + // fillGC + { + GC newGC = NULL; + if (ops->stipple != None) { + // Handle old-style -stipple specially + unsigned long gcMask = + GCForeground | GCBackground | GCFillStyle | GCStipple; + XGCValues gcValues; + int screenNum = Tk_ScreenNumber(graphPtr->tkwin); + gcValues.foreground = BlackPixel(graphPtr->display, screenNum); + gcValues.background = WhitePixel(graphPtr->display, screenNum); + if (ops->fill) + gcValues.foreground = Tk_3DBorderColor(ops->fill)->pixel; + else if (ops->outlineColor) + gcValues.foreground = ops->outlineColor->pixel; + gcValues.stipple = ops->stipple; + gcValues.fill_style = FillStippled; + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + } + if (bpPtr->fillGC) + Tk_FreeGC(graphPtr->display, bpPtr->fillGC); + bpPtr->fillGC = newGC; } - if (penPtr->fillGC) - Tk_FreeGC(graphPtr->display, penPtr->fillGC); - penPtr->fillGC = newGC; // errorBarGC - gcMask = GCForeground | GCLineWidth; - XColor* colorPtr = penPtr->errorBarColor; - if (!colorPtr) - colorPtr = penPtr->outlineColor; - gcValues.foreground = colorPtr->pixel; - gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - penPtr->errorBarGC = newGC; + { + unsigned long gcMask = GCForeground | GCLineWidth; + XColor* colorPtr = ops->errorBarColor; + if (!colorPtr) + colorPtr = ops->outlineColor; + XGCValues gcValues; + gcValues.foreground = colorPtr->pixel; + gcValues.line_width = LineWidth(ops->errorBarLineWidth); + GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (bpPtr->errorBarGC) + Tk_FreeGC(graphPtr->display, bpPtr->errorBarGC); + bpPtr->errorBarGC = newGC; + } return TCL_OK; } -void DestroyBarPenProc(Graph* graphPtr, Pen* basePtr) +void DestroyBarPenProc(Graph* graphPtr, Pen* penPtr) { - BarPen* penPtr = (BarPen*)basePtr; - - Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); - if (penPtr->outlineGC) - Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - - if (penPtr->fillGC) - Tk_FreeGC(graphPtr->display, penPtr->fillGC); - - if (penPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - - Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); + BarPen* bpPtr = (BarPen*)penPtr; + BarPenOptions* ops = (BarPenOptions*)bpPtr->ops; + + Blt_Ts_FreeStyle(graphPtr->display, &ops->valueStyle); + if (bpPtr->outlineGC) + Tk_FreeGC(graphPtr->display, bpPtr->outlineGC); + if (bpPtr->fillGC) + Tk_FreeGC(graphPtr->display, bpPtr->fillGC); + if (bpPtr->errorBarGC) + Tk_FreeGC(graphPtr->display, bpPtr->errorBarGC); + + Tk_FreeConfigOptions((char*)bpPtr, bpPtr->optionTable, graphPtr->tkwin); } |