summaryrefslogtreecommitdiffstats
path: root/generic/tkbltGrText.C
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 09:20:28 (GMT)
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 11:40:48 (GMT)
commitf14d9dc7c790f40e897bf4f3afaacdde6509adac (patch)
tree9decc8ccfb18a38a94568feea8c9dc66e4ff6fd2 /generic/tkbltGrText.C
parent095e27e5a9b983b7a20ea6bc4b9f4989ddb9a160 (diff)
downloadblt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.zip
blt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.tar.gz
blt-f14d9dc7c790f40e897bf4f3afaacdde6509adac.tar.bz2
Enforce explicit downcasting of numeric values
As part of the change, upgrade tkblt internal structures from short/float to int/double, as those are artifacts of the legacy code relying on X. Downcast to short at the latest stage: when interfacing with X.
Diffstat (limited to 'generic/tkbltGrText.C')
-rw-r--r--generic/tkbltGrText.C19
1 files changed, 14 insertions, 5 deletions
diff --git a/generic/tkbltGrText.C b/generic/tkbltGrText.C
index 65725e7..1bed069 100644
--- a/generic/tkbltGrText.C
+++ b/generic/tkbltGrText.C
@@ -94,13 +94,18 @@ void TextStyle::drawText(Drawable drawable, const char *text, int x, int y)
Point2d rr = rotateText(x, y, w1, h1);
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6)
TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, ops->angle, 0, -1);
+ (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) {
+ return drawText(drawable, text, (int)x, (int)y);
+}
+
void TextStyle::drawText2(Drawable drawable, const char *text,
int x, int y, int* ww, int* hh)
{
@@ -118,10 +123,10 @@ void TextStyle::drawText2(Drawable drawable, const char *text,
Point2d rr = rotateText(x, y, w1, h1);
#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6)
TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, ops->angle, 0, -1);
+ (int)rr.x, (int)rr.y, ops->angle, 0, -1);
#else
Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout,
- rr.x, rr.y, 0, -1);
+ (int)rr.x, (int)rr.y, 0, -1);
#endif
double angle = fmod(ops->angle, 360.0);
@@ -131,8 +136,8 @@ void TextStyle::drawText2(Drawable drawable, const char *text,
if (angle != 0.0) {
double rotWidth, rotHeight;
graphPtr_->getBoundingBox(w1, h1, angle, &rotWidth, &rotHeight, NULL);
- w1 = rotWidth;
- h1 = rotHeight;
+ w1 = (int)rotWidth;
+ h1 = (int)rotHeight;
}
*ww = w1;
@@ -182,6 +187,10 @@ void TextStyle::printText(PSOutput* psPtr, const char *text, int x, int y)
psPtr->format("] %g %g %s DrawText\n", xx/-2.0, yy/-2.0, justify);
}
+void TextStyle::printText(PSOutput* psPtr, const char *text, double x, double y) {
+ return printText(psPtr, text, (int)x, (int)y);
+}
+
void TextStyle::resetStyle()
{
TextStyleOptions* ops = (TextStyleOptions*)ops_;