summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2018-10-26 12:00:00 (GMT)
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2018-10-26 12:00:00 (GMT)
commita56c48cda877fcd87a850ffed33a63be96c0796a (patch)
tree3ac769066d4573a1f4bde554e8a703ce3eb335b6
parent11d2be66bad300683f2a71ec5c1a716a501dde66 (diff)
downloadblt-a56c48cda877fcd87a850ffed33a63be96c0796a.zip
blt-a56c48cda877fcd87a850ffed33a63be96c0796a.tar.gz
blt-a56c48cda877fcd87a850ffed33a63be96c0796a.tar.bz2
Coalesce duplicate code
-rw-r--r--generic/tkbltGrText.C53
1 files changed, 18 insertions, 35 deletions
diff --git a/generic/tkbltGrText.C b/generic/tkbltGrText.C
index 1bed069..6f42ba3 100644
--- a/generic/tkbltGrText.C
+++ b/generic/tkbltGrText.C
@@ -78,32 +78,13 @@ TextStyle::~TextStyle()
free(ops_);
}
-void TextStyle::drawText(Drawable drawable, const char *text, int x, int y)
-{
- TextStyleOptions* ops = (TextStyleOptions*)ops_;
-
- if (!text || !(*text))
- return;
-
- if (!gc_)
- resetStyle();
-
- 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);
-#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6)
- TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout,
- (int)rr.x, (int)rr.y,
- ops->angle, 0, -1);
-#else
- Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, 0, -1);
-#endif
+void TextStyle::drawText(Drawable drawable, const char *text, double x, double y) {
+ drawText(drawable, text, (int)x, (int)y);
}
-void TextStyle::drawText(Drawable drawable, const char *text, double x, double y) {
- return drawText(drawable, text, (int)x, (int)y);
+void TextStyle::drawText(Drawable drawable, const char *text, int x, int y)
+{
+ drawTextBBox(drawable, text, x, y, NULL, NULL);
}
void TextStyle::drawText2(Drawable drawable, const char *text,
@@ -129,19 +110,21 @@ void TextStyle::drawText2(Drawable drawable, const char *text,
(int)rr.x, (int)rr.y, 0, -1);
#endif
- double angle = fmod(ops->angle, 360.0);
- if (angle < 0.0)
- angle += 360.0;
+ if (ww && hh) {
+ double angle = fmod(ops->angle, 360.0);
+ if (angle < 0.0)
+ angle += 360.0;
- if (angle != 0.0) {
- double rotWidth, rotHeight;
- graphPtr_->getBoundingBox(w1, h1, angle, &rotWidth, &rotHeight, NULL);
- w1 = (int)rotWidth;
- h1 = (int)rotHeight;
- }
+ if (angle != 0.0) {
+ double rotWidth, rotHeight;
+ graphPtr_->getBoundingBox(w1, h1, angle, &rotWidth, &rotHeight, NULL);
+ w1 = (int)rotWidth;
+ h1 = (int)rotHeight;
+ }
- *ww = w1;
- *hh = h1;
+ *ww = w1;
+ *hh = h1;
+ }
}
void TextStyle::printText(PSOutput* psPtr, const char *text, int x, int y)