diff options
author | joye <joye> | 2014-04-08 22:15:17 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-08 22:15:17 (GMT) |
commit | 928fcad06c562bd8731e83c1fc2d6433e42b28e2 (patch) | |
tree | 983f3df1298448d3089a86c88c3417ace9f77c06 /src | |
parent | f02d29d63f5b7c6172d918f96806f4ce7edbc0a7 (diff) | |
download | blt-928fcad06c562bd8731e83c1fc2d6433e42b28e2.zip blt-928fcad06c562bd8731e83c1fc2d6433e42b28e2.tar.gz blt-928fcad06c562bd8731e83c1fc2d6433e42b28e2.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrLegd.C | 111 |
1 files changed, 46 insertions, 65 deletions
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 8414fb7..7a5d76b 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -487,86 +487,71 @@ void Legend::map(int plotWidth, int plotHeight) void Legend::draw(Drawable drawable) { - Blt_ChainLink link; - Tk_FontMetrics fontMetrics; LegendOptions* ops = (LegendOptions*)ops_; - Pixmap pixmap; - Tk_Window tkwin; - int count; - int symbolSize, xMid, yMid; - int x, y, w, h; - int xLabel, yStart, xSymbol, ySymbol; - if ((ops->hide) || (nEntries_ == 0)) return; SetLegendOrigin(this); - tkwin = graphPtr_->tkwin; - w = width_; - h = height_; + Tk_Window tkwin = graphPtr_->tkwin; + int w = width_; + int h = height_; - pixmap = Tk_GetPixmap(graphPtr_->display, Tk_WindowId(tkwin), w, h, - Tk_Depth(tkwin)); + Pixmap pixmap = Tk_GetPixmap(graphPtr_->display, Tk_WindowId(tkwin), w, h, + Tk_Depth(tkwin)); - if (ops->normalBg) { + if (ops->normalBg) Tk_Fill3DRectangle(tkwin, pixmap, ops->normalBg, 0, 0, w, h, 0, TK_RELIEF_FLAT); - } + else if (site_ & LEGEND_PLOTAREA_MASK) { - /* - * Legend background is transparent and is positioned over the the - * plot area. Either copy the part of the background from the backing - * store pixmap or (if no backing store exists) just fill it with the - * background color of the plot. - */ - if (graphPtr_->cache != None) { + // Legend background is transparent and is positioned over the the + // plot area. Either copy the part of the background from the backing + // store pixmap or (if no backing store exists) just fill it with the + // background color of the plot. + if (graphPtr_->cache != None) XCopyArea(graphPtr_->display, graphPtr_->cache, pixmap, graphPtr_->drawGC, x_, y_, w, h, 0, 0); - } else { + else Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->plotBg, 0, 0, w, h, TK_RELIEF_FLAT, 0); - } } - else { - /* - * The legend is located in one of the margins or the external window. - */ + else + // The legend is located in one of the margins Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->normalBg, 0, 0, w, h, 0, TK_RELIEF_FLAT); - } + + Tk_FontMetrics fontMetrics; Tk_GetFontMetrics(ops->style.font, &fontMetrics); - symbolSize = fontMetrics.ascent; - xMid = symbolSize + 1 + ops->entryBW; - yMid = (symbolSize / 2) + 1 + ops->entryBW; - xLabel = 2 * symbolSize + ops->entryBW + ops->ixPad + 2 * LABEL_PAD; - ySymbol = yMid + ops->iyPad; - xSymbol = xMid + LABEL_PAD; + int symbolSize = fontMetrics.ascent; + int xMid = symbolSize + 1 + ops->entryBW; + int yMid = (symbolSize / 2) + 1 + ops->entryBW; + int xLabel = 2 * symbolSize + ops->entryBW + ops->ixPad + 2 * LABEL_PAD; + int ySymbol = yMid + ops->iyPad; + int xSymbol = xMid + LABEL_PAD; - x = ops->xPad + ops->borderWidth; - y = ops->yPad + ops->borderWidth; + int x = ops->xPad + ops->borderWidth; + int y = ops->yPad + ops->borderWidth; Blt_DrawText(tkwin, pixmap, ops->title, &ops->titleStyle, x, y); if (titleHeight_ > 0) y += titleHeight_ + ops->yPad; - count = 0; - yStart = y; - for (link = Blt_Chain_FirstLink(graphPtr_->elements.displayList); - link != NULL; link = Blt_Chain_NextLink(link)) { - int isSelected; - + int count = 0; + int yStart = y; + for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr_->elements.displayList); link != NULL; link = Blt_Chain_NextLink(link)) { Element* elemPtr = (Element*)Blt_Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); if (elemOps->label == NULL) continue; - isSelected = EntryIsSelected(this, elemPtr); + int isSelected = EntryIsSelected(this, elemPtr); if (elemPtr->flags & LABEL_ACTIVE) { Tk_Fill3DRectangle(tkwin, pixmap, ops->activeBg, x, y, entryWidth_, entryHeight_, ops->entryBW, ops->activeRelief); - } else if (isSelected) { + } + else if (isSelected) { XColor* fg = (flags & FOCUS) ? ops->selInFocusFgColor : ops->selOutFocusFgColor; Tk_3DBorder bg = (flags & FOCUS) ? @@ -575,14 +560,14 @@ void Legend::draw(Drawable drawable) Tk_Fill3DRectangle(tkwin, pixmap, bg, x, y, entryWidth_, entryHeight_, ops->selBW, ops->selRelief); - } else { + } + else { Blt_Ts_SetForeground(ops->style, ops->fgColor); - if (elemOps->legendRelief != TK_RELIEF_FLAT) { + if (elemOps->legendRelief != TK_RELIEF_FLAT) Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->normalBg, x, y, entryWidth_, entryHeight_, ops->entryBW, elemOps->legendRelief); - } } elemPtr->drawSymbol(pixmap, x + xSymbol, y + ySymbol, symbolSize); Blt_DrawText(tkwin, pixmap, elemOps->label, &ops->style, @@ -591,11 +576,8 @@ void Legend::draw(Drawable drawable) count++; if (focusPtr_ == elemPtr) { /* Focus outline */ if (isSelected) { - XColor* color; - - color = (flags & FOCUS) ? - ops->selInFocusFgColor : - ops->selOutFocusFgColor; + XColor* color = (flags & FOCUS) ? + ops->selInFocusFgColor : ops->selOutFocusFgColor; XSetForeground(graphPtr_->display, focusGC_, color->pixel); } @@ -607,32 +589,31 @@ void Legend::draw(Drawable drawable) ops->focusColor->pixel); } } - /* Check when to move to the next column */ - if ((count % nRows_) > 0) { + // Check when to move to the next column + if ((count % nRows_) > 0) y += entryHeight_; - } else { + else { x += entryWidth_; y = yStart; } } - /* - * Draw the border and/or background of the legend. - */ + Tk_3DBorder bg = ops->normalBg; if (bg == NULL) bg = graphPtr_->normalBg; - /* Disable crosshairs before redisplaying to the screen */ - if (site_ & LEGEND_PLOTAREA_MASK) { + // Disable crosshairs before redisplaying to the screen + if (site_ & LEGEND_PLOTAREA_MASK) Blt_DisableCrosshairs(graphPtr_); - } + Tk_Draw3DRectangle(tkwin, pixmap, bg, 0, 0, w, h, ops->borderWidth, ops->relief); XCopyArea(graphPtr_->display, pixmap, drawable, graphPtr_->drawGC, 0, 0, w, h, x_, y_); - if (site_ & LEGEND_PLOTAREA_MASK) { + + if (site_ & LEGEND_PLOTAREA_MASK) Blt_EnableCrosshairs(graphPtr_); - } + Tk_FreePixmap(graphPtr_->display, pixmap); graphPtr_->flags &= ~DRAW_LEGEND; } |