diff options
author | joye <joye> | 2014-04-09 19:59:10 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-09 19:59:10 (GMT) |
commit | fb2a886b39bb0f9f6d43d902109ef3830f1fe76e (patch) | |
tree | c92a22b6504189aebbe074dc83301b95b7920f5e /src | |
parent | c6c0a7fca7ce114ee7fa388ff2f18e3e7c49b2b1 (diff) | |
download | blt-fb2a886b39bb0f9f6d43d902109ef3830f1fe76e.zip blt-fb2a886b39bb0f9f6d43d902109ef3830f1fe76e.tar.gz blt-fb2a886b39bb0f9f6d43d902109ef3830f1fe76e.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 135 | ||||
-rw-r--r-- | src/bltGrLegd.C | 43 | ||||
-rw-r--r-- | src/bltGrText.h | 24 | ||||
-rw-r--r-- | src/bltGraph.C | 5 |
4 files changed, 111 insertions, 96 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index c9b784d..3259762 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -2444,20 +2444,23 @@ static void DrawAxis(Axis *axisPtr, Drawable drawable) TextStyle ts; Blt_Ts_InitStyle(ts); - Blt_Ts_SetAngle(ts, axisPtr->titleAngle); - Blt_Ts_SetFont(ts, axisPtr->titleFont); - Blt_Ts_SetPadding(ts, 1, 0); - Blt_Ts_SetAnchor(ts, axisPtr->titleAnchor); - Blt_Ts_SetJustify(ts, axisPtr->titleJustify); + ts.flags |= UPDATE_GC; + + ts.angle = axisPtr->titleAngle; + ts.font = axisPtr->titleFont; + ts.xPad = 1; + ts.yPad = 0; + ts.anchor = axisPtr->titleAnchor; + ts.justify = axisPtr->titleJustify; if (axisPtr->flags & ACTIVE) - Blt_Ts_SetForeground(ts, axisPtr->activeFgColor); + ts.color = axisPtr->activeFgColor; else - Blt_Ts_SetForeground(ts, axisPtr->titleColor); + ts.color = axisPtr->titleColor; if ((axisPtr->titleAngle == 90.0) || (axisPtr->titleAngle == 270.0)) - Blt_Ts_SetMaxLength(ts, axisPtr->height); + ts.maxLength = axisPtr->height; else - Blt_Ts_SetMaxLength(ts, axisPtr->width); + ts.maxLength = axisPtr->width; Blt_Ts_DrawText(graphPtr->tkwin, drawable, axisPtr->title, -1, &ts, (int)axisPtr->titlePos.x, (int)axisPtr->titlePos.y); @@ -2530,27 +2533,28 @@ static void DrawAxis(Axis *axisPtr, Drawable drawable) TextStyle ts; Blt_Ts_InitStyle(ts); - Blt_Ts_SetAngle(ts, axisPtr->tickAngle); - Blt_Ts_SetFont(ts, axisPtr->tickFont); - Blt_Ts_SetPadding(ts, 2, 0); - Blt_Ts_SetAnchor(ts, axisPtr->tickAnchor); + ts.flags |= UPDATE_GC; + + ts.angle = axisPtr->tickAngle; + ts.font = axisPtr->tickFont; + ts.xPad = 2; + ts.yPad = 0; + ts.anchor = axisPtr->tickAnchor; if (axisPtr->flags & ACTIVE) - Blt_Ts_SetForeground(ts, axisPtr->activeFgColor); + ts.color = axisPtr->activeFgColor; else - Blt_Ts_SetForeground(ts, axisPtr->tickColor); + ts.color = axisPtr->tickColor; for (link = Blt_Chain_FirstLink(axisPtr->tickLabels); link != NULL; link = Blt_Chain_NextLink(link)) { TickLabel *labelPtr = (TickLabel*)Blt_Chain_GetValue(link); - /* Draw major tick labels */ Blt_DrawText(graphPtr->tkwin, drawable, labelPtr->string, &ts, (int)labelPtr->anchorPos.x, (int)labelPtr->anchorPos.y); } } + if ((axisPtr->nSegments > 0) && (axisPtr->lineWidth > 0)) { GC gc = (axisPtr->flags & ACTIVE) ? axisPtr->activeTickGC : axisPtr->tickGC; - - // Draw the tick marks and axis line. Blt_Draw2DSegments(graphPtr->display, drawable, gc, axisPtr->segments, axisPtr->nSegments); } @@ -2570,27 +2574,33 @@ static void AxisToPostScript(Blt_Ps ps, Axis *axisPtr) TextStyle ts; Blt_Ts_InitStyle(ts); - Blt_Ts_SetAngle(ts, axisPtr->titleAngle); - Blt_Ts_SetFont(ts, axisPtr->titleFont); - Blt_Ts_SetPadding(ts, 1, 0); - Blt_Ts_SetAnchor(ts, axisPtr->titleAnchor); - Blt_Ts_SetJustify(ts, axisPtr->titleJustify); - Blt_Ts_SetForeground(ts, axisPtr->titleColor); + ts.flags |= UPDATE_GC; + + ts.angle = axisPtr->titleAngle; + ts.font = axisPtr->titleFont; + ts.xPad = 1; + ts.yPad = 0; + ts.anchor = axisPtr->titleAnchor; + ts.justify = axisPtr->titleJustify; + ts.color = axisPtr->titleColor; Blt_Ps_DrawText(ps, axisPtr->title, &ts, axisPtr->titlePos.x, axisPtr->titlePos.y); } + if (axisPtr->showTicks) { - Blt_ChainLink link; TextStyle ts; Blt_Ts_InitStyle(ts); - Blt_Ts_SetAngle(ts, axisPtr->tickAngle); - Blt_Ts_SetFont(ts, axisPtr->tickFont); - Blt_Ts_SetPadding(ts, 2, 0); - Blt_Ts_SetAnchor(ts, axisPtr->tickAnchor); - Blt_Ts_SetForeground(ts, axisPtr->tickColor); + ts.flags |= UPDATE_GC; + + ts.angle = axisPtr->tickAngle; + ts.font = axisPtr->tickFont; + ts.xPad = 2; + ts.yPad = 0; + ts.anchor = axisPtr->tickAnchor; + ts.color = axisPtr->tickColor; - for (link = Blt_Chain_FirstLink(axisPtr->tickLabels); link != NULL; + for (Blt_ChainLink link=Blt_Chain_FirstLink(axisPtr->tickLabels); link; link = Blt_Chain_NextLink(link)) { TickLabel *labelPtr = (TickLabel*)Blt_Chain_GetValue(link); Blt_Ps_DrawText(ps, labelPtr->string, &ts, labelPtr->anchorPos.x, @@ -3548,34 +3558,45 @@ void Blt_DrawAxisLimits(Graph* graphPtr, Drawable drawable) } if (maxPtr) { if (isHoriz) { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 90.0); - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_SE); + axisPtr->limitsTextStyle.angle = 90.0; + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_SE; + Blt_DrawText2(graphPtr->tkwin, drawable, maxPtr, - &axisPtr->limitsTextStyle, graphPtr->right, hMax, &textDim); + &axisPtr->limitsTextStyle, graphPtr->right, + hMax, &textDim); hMax -= (textDim.height + SPACING); - } else { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 0.0); - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_NW); + } + else { + axisPtr->limitsTextStyle.angle = 0.0; + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_NW; + Blt_DrawText2(graphPtr->tkwin, drawable, maxPtr, - &axisPtr->limitsTextStyle, vMax, graphPtr->top, &textDim); + &axisPtr->limitsTextStyle, vMax, + graphPtr->top, &textDim); vMax += (textDim.width + SPACING); } } if (minPtr) { - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_SW); + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_SW; + if (isHoriz) { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 90.0); + axisPtr->limitsTextStyle.angle = 90.0; + Blt_DrawText2(graphPtr->tkwin, drawable, minPtr, - &axisPtr->limitsTextStyle, graphPtr->left, hMin, &textDim); + &axisPtr->limitsTextStyle, graphPtr->left, + hMin, &textDim); hMin -= (textDim.height + SPACING); - } else { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 0.0); + } + else { + axisPtr->limitsTextStyle.angle = 0.0; + Blt_DrawText2(graphPtr->tkwin, drawable, minPtr, - &axisPtr->limitsTextStyle, vMin, graphPtr->bottom, &textDim); + &axisPtr->limitsTextStyle, vMin, + graphPtr->bottom, &textDim); vMin += (textDim.width + SPACING); } } - } /* Loop on axes */ + } } void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps) @@ -3607,14 +3628,17 @@ void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps) &textHeight); if ((textWidth > 0) && (textHeight > 0)) { if (axisPtr->obj.classId == CID_AXIS_X) { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 90.0); - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_SE); + axisPtr->limitsTextStyle.angle = 90.0; + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_SE; + Blt_Ps_DrawText(ps, string, &axisPtr->limitsTextStyle, (double)graphPtr->right, hMax); hMax -= (textWidth + SPACING); - } else { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 0.0); - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_NW); + } + else { + axisPtr->limitsTextStyle.angle = 0.0; + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_NW; + Blt_Ps_DrawText(ps, string, &axisPtr->limitsTextStyle, vMax, (double)graphPtr->top); vMax += (textWidth + SPACING); @@ -3626,14 +3650,17 @@ void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps) Blt_GetTextExtents(axisPtr->tickFont, 0, string, -1, &textWidth, &textHeight); if ((textWidth > 0) && (textHeight > 0)) { - Blt_Ts_SetAnchor(axisPtr->limitsTextStyle, TK_ANCHOR_SW); + axisPtr->limitsTextStyle.anchor = TK_ANCHOR_SW; if (axisPtr->obj.classId == CID_AXIS_X) { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 90.0); + axisPtr->limitsTextStyle.angle = 90.0; + Blt_Ps_DrawText(ps, string, &axisPtr->limitsTextStyle, (double)graphPtr->left, hMin); hMin -= (textWidth + SPACING); - } else { - Blt_Ts_SetAngle(axisPtr->limitsTextStyle, 0.0); + } + else { + axisPtr->limitsTextStyle.angle = 0.0; + Blt_Ps_DrawText(ps, string, &axisPtr->limitsTextStyle, vMin, (double)graphPtr->bottom); vMin += (textWidth + SPACING); diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index d52fb90..4fd2cb1 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -161,7 +161,8 @@ static Tk_OptionSpec optionSpecs[] = { "ActiveBorderWidth", STD_BORDERWIDTH, -1, Tk_Offset(LegendOptions, entryBW), 0, NULL, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "ActiveForeground", - STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, activeFgColor), 0, NULL, 0}, + STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, activeFgColor), + 0, NULL, 0}, {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "ActiveRelief", "flat", -1, Tk_Offset(LegendOptions, activeRelief), 0, NULL, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", @@ -194,10 +195,12 @@ static Tk_OptionSpec optionSpecs[] = { "1", -1, Tk_Offset(LegendOptions, iyPad), 0, NULL, 0}, {TK_OPTION_BORDER, "-nofocusselectbackground", "noFocusSelectBackground", "NoFocusSelectBackground", - STD_ACTIVE_BACKGROUND, -1, Tk_Offset(LegendOptions, selOutFocusBg), 0, NULL, 0}, + STD_ACTIVE_BACKGROUND, -1, Tk_Offset(LegendOptions, selOutFocusBg), + 0, NULL, 0}, {TK_OPTION_COLOR, "-nofocusselectforeground", "noFocusSelectForeground", "NoFocusSelectForeground", - STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, selOutFocusFgColor), 0, NULL,0}, + STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, selOutFocusFgColor), + 0, NULL,0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", "1", -1, Tk_Offset(LegendOptions, xPad), 0, NULL, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", @@ -212,26 +215,28 @@ static Tk_OptionSpec optionSpecs[] = { "0", -1, Tk_Offset(LegendOptions, reqRows), 0, NULL, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "SelectBackground", - STD_ACTIVE_BACKGROUND, -1, Tk_Offset(LegendOptions, selInFocusBg), 0, NULL, 0}, + STD_ACTIVE_BACKGROUND, -1, Tk_Offset(LegendOptions, selInFocusBg), + 0, NULL, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "SelectBorderWidth", "1", -1, Tk_Offset(LegendOptions, selBW), 0, NULL, 0}, {TK_OPTION_STRING, "-selectcommand", "selectCommand", "SelectCommand", NULL, -1, Tk_Offset(LegendOptions, selectCmd), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "SelectForeground", - STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, selInFocusFgColor), 0, NULL, 0}, + STD_ACTIVE_FOREGROUND, -1, Tk_Offset(LegendOptions, selInFocusFgColor), + 0, NULL, 0}, {TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode", - "multiple", -1, Tk_Offset(LegendOptions, selectMode), 0, &selectmodeObjOption, 0}, + "multiple", -1, Tk_Offset(LegendOptions, selectMode), + 0, &selectmodeObjOption, 0}, {TK_OPTION_RELIEF, "-selectrelief", "selectRelief", "SelectRelief", "flat", -1, Tk_Offset(LegendOptions, selRelief), 0, NULL, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", NULL, -1, Tk_Offset(LegendOptions, takeFocus), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING, "-title", "title", "Title", NULL, -1, Tk_Offset(LegendOptions, title), TK_OPTION_NULL_OK, NULL, 0}, - {TK_OPTION_ANCHOR, "-titleanchor", "titleAnchor", "TitleAnchor", - "nw", -1, Tk_Offset(LegendOptions, titleStyle.anchor), 0, NULL, 0}, {TK_OPTION_COLOR, "-titlecolor", "titleColor", "TitleColor", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(LegendOptions, titleStyle.color), 0, NULL, 0}, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(LegendOptions, titleStyle.color), + 0, NULL, 0}, {TK_OPTION_FONT, "-titlefont", "titleFont", "TitleFont", STD_FONT_SMALL, -1, Tk_Offset(LegendOptions, titleStyle.font), 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} @@ -320,7 +325,7 @@ void Legend::configure() { LegendOptions* ops = (LegendOptions*)ops_; - /* GC for active label. Dashed outline. */ + // GC for active label, Dashed outline unsigned long gcMask = GCForeground | GCLineStyle; XGCValues gcValues; gcValues.foreground = ops->focusColor->pixel; @@ -496,6 +501,10 @@ void Legend::draw(Drawable drawable) Pixmap pixmap = Tk_GetPixmap(graphPtr_->display, Tk_WindowId(tkwin), w, h, Tk_Depth(tkwin)); + // be sure to update style->gc, things might have changed + ops->style.flags |= UPDATE_GC; + ops->titleStyle.flags |= UPDATE_GC; + if (ops->normalBg) Tk_Fill3DRectangle(tkwin, pixmap, ops->normalBg, 0, 0, w, h, 0, TK_RELIEF_FLAT); @@ -535,7 +544,8 @@ void Legend::draw(Drawable drawable) int count = 0; int yStart = y; - for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr_->elements.displayList); link != NULL; link = Blt_Chain_NextLink(link)) { + for (Blt_ChainLink link=Blt_Chain_FirstLink(graphPtr_->elements.displayList); + link; link = Blt_Chain_NextLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); if (elemOps->label == NULL) @@ -552,13 +562,13 @@ void Legend::draw(Drawable drawable) ops->selInFocusFgColor : ops->selOutFocusFgColor; Tk_3DBorder bg = (flags & FOCUS) ? ops->selInFocusBg : ops->selOutFocusBg; - Blt_Ts_SetForeground(ops->style, fg); + ops->style.color = fg; Tk_Fill3DRectangle(tkwin, pixmap, bg, x, y, entryWidth_, entryHeight_, ops->selBW, ops->selRelief); } else { - Blt_Ts_SetForeground(ops->style, ops->fgColor); + ops->style.color = ops->fgColor; if (elemOps->legendRelief != TK_RELIEF_FLAT) Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->normalBg, x, y, entryWidth_, @@ -570,7 +580,7 @@ void Legend::draw(Drawable drawable) x + xLabel, y + ops->entryBW + ops->iyPad); count++; - if (focusPtr_ == elemPtr) { /* Focus outline */ + if (focusPtr_ == elemPtr) { if (isSelected) { XColor* color = (flags & FOCUS) ? ops->selInFocusFgColor : ops->selOutFocusFgColor; @@ -585,6 +595,7 @@ void Legend::draw(Drawable drawable) ops->focusColor->pixel); } } + // Check when to move to the next column if ((count % nRows_) > 0) y += entryHeight_; @@ -668,13 +679,13 @@ void Legend::print(Blt_Ps ps) continue; if (elemPtr->flags & LABEL_ACTIVE) { - Blt_Ts_SetForeground(ops->style, ops->activeFgColor); + ops->style.color = ops->activeFgColor; Blt_Ps_Fill3DRectangle(ps, ops->activeBg, x, y, entryWidth_, entryHeight_, ops->entryBW, ops->activeRelief); } else { - Blt_Ts_SetForeground(ops->style, ops->fgColor); + ops->style.color = ops->fgColor; if (elemOps->legendRelief != TK_RELIEF_FLAT) { Blt_Ps_Draw3DRectangle(ps, graphPtr_->normalBg, x, y, entryWidth_, diff --git a/src/bltGrText.h b/src/bltGrText.h index f01aa85..7cf876f 100644 --- a/src/bltGrText.h +++ b/src/bltGrText.h @@ -75,28 +75,6 @@ extern void Blt_DrawText2(Tk_Window tkwin, Drawable drawable, extern void Blt_Ts_DrawText(Tk_Window tkwin, Drawable drawable, const char *text, int textLen, TextStyle *tsPtr, int x, int y); -#define Blt_Ts_GetAnchor(ts) ((ts).anchor) -#define Blt_Ts_GetAngle(ts) ((ts).angle) -#define Blt_Ts_GetBackground(ts) ((ts).bg) -#define Blt_Ts_GetFont(ts) ((ts).font) -#define Blt_Ts_GetForeground(ts) ((ts).color) -#define Blt_Ts_GetJustify(ts) ((ts).justify) -#define Blt_Ts_GetLeader(ts) ((ts).leader) - -#define Blt_Ts_SetAnchor(ts, a) ((ts).anchor = (a)) -#define Blt_Ts_SetAngle(ts, r) ((ts).angle = (double)(r)) -#define Blt_Ts_SetBackground(ts, b) ((ts).bg = (b)) -#define Blt_Ts_SetFont(ts, f) \ - (((ts).font != (f)) ? ((ts).font = (f), (ts).flags |= UPDATE_GC) : 0) -#define Blt_Ts_SetForeground(ts, c) \ - (((ts).color != (c)) ? ((ts).color = (c), (ts).flags |= UPDATE_GC) : 0) -#define Blt_Ts_SetJustify(ts, j) ((ts).justify = (j)) -#define Blt_Ts_SetLeader(ts, l) ((ts).leader = (l)) -#define Blt_Ts_SetMaxLength(ts, l) ((ts).maxLength = (l)) -#define Blt_Ts_SetPadding(ts, x, y) ((ts).xPad = (x), (ts).yPad = (y)) -#define Blt_Ts_SetState(ts, s) ((ts).state = (s)) -#define Blt_Ts_SetUnderline(ts, ul) ((ts).underline = (ul)) - #define Blt_Ts_InitStyle(ts) \ ((ts).anchor = TK_ANCHOR_NW, \ (ts).color = (XColor*)NULL, \ @@ -112,4 +90,4 @@ extern void Blt_Ts_DrawText(Tk_Window tkwin, Drawable drawable, (ts).maxLength = -1, \ (ts).angle = 0.0) -#endif /* _BLT_TEXT_H */ +#endif diff --git a/src/bltGraph.C b/src/bltGraph.C index ae93c03..40e7556 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -297,7 +297,7 @@ static int NewGraph(ClientData clientData, Tcl_Interp*interp, graphPtr->rightMargin.site = MARGIN_RIGHT; Blt_Ts_InitStyle(graphPtr->titleTextStyle); - Blt_Ts_SetAnchor(graphPtr->titleTextStyle, TK_ANCHOR_N); + graphPtr->titleTextStyle.anchor = TK_ANCHOR_N; Tcl_InitHashTable(&graphPtr->axes.table, TCL_STRING_KEYS); Tcl_InitHashTable(&graphPtr->axes.tagTable, TCL_STRING_KEYS); @@ -527,8 +527,7 @@ static void ConfigureGraph(Graph* graphPtr) // clearing the margins with XFillRectangle // Margin XGCValues gcValues; - gcValues.foreground = - Blt_Ts_GetForeground(graphPtr->titleTextStyle)->pixel; + gcValues.foreground = graphPtr->titleTextStyle.color->pixel; gcValues.background = colorPtr->pixel; unsigned long gcMask = (GCForeground | GCBackground); GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); |