diff options
author | joye <joye> | 2014-06-06 19:12:24 (GMT) |
---|---|---|
committer | joye <joye> | 2014-06-06 19:12:24 (GMT) |
commit | 90d2d35560b9009999f107a05a6e309fa992e8f6 (patch) | |
tree | 81e6b24e2dfecf6b1982742190711d8922c7e4be /src | |
parent | 16214040ab0fc38785746aae73c59b8741b14d74 (diff) | |
download | blt-90d2d35560b9009999f107a05a6e309fa992e8f6.zip blt-90d2d35560b9009999f107a05a6e309fa992e8f6.tar.gz blt-90d2d35560b9009999f107a05a6e309fa992e8f6.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrPSOutput.C | 7 | ||||
-rw-r--r-- | src/bltGrText.C | 36 |
2 files changed, 31 insertions, 12 deletions
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C index 6e101d9..d747d13 100644 --- a/src/bltGrPSOutput.C +++ b/src/bltGrPSOutput.C @@ -814,6 +814,13 @@ void PostScript::prolog() " stroke\n" "} def\n" "\n" +"/DrawText {\n" +" 0 0 moveto\n" +" %[(hi) (world)] { \n" +" (hi) show\n" +" %} forall \n" +"} bind def \n" +"\n" "/EndText {\n" " %Stack :\n" " grestore\n" diff --git a/src/bltGrText.C b/src/bltGrText.C index 44b3aca..c132f43 100644 --- a/src/bltGrText.C +++ b/src/bltGrText.C @@ -134,32 +134,44 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) { TextStyleOptions* ops = (TextStyleOptions*)ops_; - cerr << x << ',' << y << '=' << text << endl; if (!text || !(*text)) return; int w1, h1; Tk_TextLayout layout = Tk_ComputeTextLayout(ops->font, text, -1, -1, ops->justify, 0, &w1, &h1); + // Point2d rr = rotateText(x, y, w1, h1); + double w2, h2; + graphPtr_->getBoundingBox(w1, h1, ops->angle, &w2, &h2, NULL); + + Point2d rr = graphPtr_->anchorPoint(x, y, w2, h2, ops->anchor); + rr.x += w2*.5; + rr.y += h2*.5; Tk_FontMetrics fm; Tk_GetFontMetrics(ops->font, &fm); - // %Stack : w h theta centerX centerY - psPtr->format("%d %d %g %g %g BeginText\n", w1, h1, ops->angle, double(x), double(y)); psPtr->setFont(ops->font); psPtr->setForeground(ops->color); - Tcl_ResetResult(graphPtr_->interp_); - Tk_TextLayoutToPostscript(graphPtr_->interp_, layout); - const char* ss = Blt::dupstr(Tcl_GetStringResult(graphPtr_->interp_)); - Tcl_ResetResult(graphPtr_->interp_); - // %Stack : str strWidth x y - int width = Tk_TextWidth(ops->font, ss, strlen(ss)); - psPtr->format("%s %d %g %g DrawAdjText\n", ss, width, 0., 0.); - delete [] ss; + int width = Tk_TextWidth(ops->font, text, strlen(text)); + psPtr->format("%d %d %g %g %g BeginText\n", w1, h1, ops->angle, rr.x, rr.y); + psPtr->format("(%s) %d %g %g DrawAdjText\n",text, width, 0. , h1*.5); + psPtr->append("EndText\n"); + - psPtr->format("EndText\n"); + // psPtr->append("gsave\n"); + // psPtr->format("%g %g %g [\n", ops->angle, x, y); + // cerr << ops->angle << ' ' << x << ' ' << y << " [" << endl; + // Tcl_ResetResult(graphPtr_->interp_); + // Tk_TextLayoutToPostscript(graphPtr_->interp_, layout); + // const char* ss = Tcl_GetStringResult(graphPtr_->interp_); + // psPtr->append(ss); + // cerr << ss << endl; + Tcl_ResetResult(graphPtr_->interp_); + // psPtr->format("] %d %g %g %s %s DrawText\n", fm.linespace, xx/-2.0, yy/2.0, justify, "false"); + // cerr << "] " << fm.linespace << ' ' << xx/-2.0 << ' ' << yy/2.0 << ' ' << justify << " false DrawText" << endl; + // psPtr->append("grestore\n"); // psPtr->printText(text, x, y); } |