summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2008-11-22 20:05:32 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2008-11-22 20:05:32 (GMT)
commitd018f5251d22906500e7f6b867ba151fdd4f589d (patch)
tree4c1f685abe81acb723e581ebb1a54635f639a27b /generic
parent08d210474dcf15c239160ca885bd7799ac618787 (diff)
downloadtk-d018f5251d22906500e7f6b867ba151fdd4f589d.zip
tk-d018f5251d22906500e7f6b867ba151fdd4f589d.tar.gz
tk-d018f5251d22906500e7f6b867ba151fdd4f589d.tar.bz2
Fixed up complaints from MSVC engendered by the last commit. In particular replaced round() which is a C99 function.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCanvText.c49
-rw-r--r--generic/tkFont.c20
2 files changed, 36 insertions, 33 deletions
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 474ed25..b92add0 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvText.c,v 1.33 2008/11/22 18:08:51 dkf Exp $
+ * RCS: @(#) $Id: tkCanvText.c,v 1.34 2008/11/22 20:05:32 patthoyts Exp $
*/
#include <stdio.h>
@@ -880,14 +880,14 @@ DisplayCanvText(
dy1 = y;
dx2 = width + 2 * textInfoPtr->selBorderWidth;
dy2 = height;
- points[0].x = drawableX + dx1*c + dy1*s;
- points[0].y = drawableY + dy1*c - dx1*s;
- points[1].x = drawableX + (dx1+dx2)*c + dy1*s;
- points[1].y = drawableY + dy1*c - (dx1+dx2)*s;
- points[2].x = drawableX + (dx1+dx2)*c + (dy1+dy2)*s;
- points[2].y = drawableY + (dy1+dy2)*c - (dx1+dx2)*s;
- points[3].x = drawableX + dx1*c + (dy1+dy2)*s;
- points[3].y = drawableY + (dy1+dy2)*c - dx1*s;
+ points[0].x = (short)(drawableX + dx1*c + dy1*s);
+ points[0].y = (short)(drawableY + dy1*c - dx1*s);
+ points[1].x = (short)(drawableX + (dx1+dx2)*c + dy1*s);
+ points[1].y = (short)(drawableY + dy1*c - (dx1+dx2)*s);
+ points[2].x = (short)(drawableX + (dx1+dx2)*c + (dy1+dy2)*s);
+ points[2].y = (short)(drawableY + (dy1+dy2)*c - (dx1+dx2)*s);
+ points[3].x = (short)(drawableX + dx1*c + (dy1+dy2)*s);
+ points[3].y = (short)(drawableY + (dy1+dy2)*c - dx1*s);
Tk_Fill3DPolygon(Tk_CanvasTkwin(canvas), drawable,
textInfoPtr->selBorder, points, 4,
textInfoPtr->selBorderWidth, TK_RELIEF_RAISED);
@@ -916,14 +916,14 @@ DisplayCanvText(
dy1 = y;
dx2 = textInfoPtr->insertWidth;
dy2 = height;
- points[0].x = drawableX + dx1*c + dy1*s;
- points[0].y = drawableY + dy1*c - dx1*s;
- points[1].x = drawableX + (dx1+dx2)*c + dy1*s;
- points[1].y = drawableY + dy1*c - (dx1+dx2)*s;
- points[2].x = drawableX + (dx1+dx2)*c + (dy1+dy2)*s;
- points[2].y = drawableY + (dy1+dy2)*c - (dx1+dx2)*s;
- points[3].x = drawableX + dx1*c + (dy1+dy2)*s;
- points[3].y = drawableY + (dy1+dy2)*c - dx1*s;
+ points[0].x = (short)(drawableX + dx1*c + dy1*s);
+ points[0].y = (short)(drawableY + dy1*c - dx1*s);
+ points[1].x = (short)(drawableX + (dx1+dx2)*c + dy1*s);
+ points[1].y = (short)(drawableY + dy1*c - (dx1+dx2)*s);
+ points[2].x = (short)(drawableX + (dx1+dx2)*c + (dy1+dy2)*s);
+ points[2].y = (short)(drawableY + (dy1+dy2)*c - (dx1+dx2)*s);
+ points[3].x = (short)(drawableX + dx1*c + (dy1+dy2)*s);
+ points[3].y = (short)(drawableY + (dy1+dy2)*c - dx1*s);
Tk_SetCaretPos(Tk_CanvasTkwin(canvas), points[0].x, points[0].y,
height);
@@ -1191,8 +1191,8 @@ TextToPoint(
px = pointPtr[0] - textPtr->drawOrigin[0];
py = pointPtr[1] - textPtr->drawOrigin[1];
value = (double) Tk_DistanceToTextLayout(textPtr->textLayout,
- (int) px*textPtr->cosine - py*textPtr->sine,
- (int) py*textPtr->cosine + px*textPtr->sine);
+ (int)(px*textPtr->cosine - py*textPtr->sine),
+ (int)(py*textPtr->cosine + px*textPtr->sine));
if ((state == TK_STATE_HIDDEN) || (textPtr->color == NULL) ||
(textPtr->text == NULL) || (*textPtr->text == 0)) {
@@ -1237,8 +1237,8 @@ TextToArea(
textPtr = (TextItem *) itemPtr;
return TkIntersectAngledTextLayout(textPtr->textLayout,
- (int) (rectPtr[0] + 0.5) - textPtr->drawOrigin[0],
- (int) (rectPtr[1] + 0.5) - textPtr->drawOrigin[1],
+ (int) ((rectPtr[0] + 0.5) - textPtr->drawOrigin[0]),
+ (int) ((rectPtr[1] + 0.5) - textPtr->drawOrigin[1]),
(int) (rectPtr[2] - rectPtr[0] + 0.5),
(int) (rectPtr[3] - rectPtr[1] + 0.5),
textPtr->angle);
@@ -1385,9 +1385,10 @@ GetTextIndex(
goto badIndex;
}
y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
- x += canvasPtr->scrollX1 - textPtr->drawOrigin[0];
- y += canvasPtr->scrollY1 - textPtr->drawOrigin[1];
- *indexPtr = Tk_PointToChar(textPtr->textLayout, x*c-y*s, y*c+x*s);
+ x += canvasPtr->scrollX1 - (int)textPtr->drawOrigin[0];
+ y += canvasPtr->scrollY1 - (int)textPtr->drawOrigin[1];
+ *indexPtr = Tk_PointToChar(textPtr->textLayout,
+ (int)(x*c-y*s), (int)(y*c+x*s));
} else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) {
if (*indexPtr < 0) {
*indexPtr = 0;
diff --git a/generic/tkFont.c b/generic/tkFont.c
index c3b0e72..961feac 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -10,12 +10,14 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFont.c,v 1.49 2008/11/22 18:08:51 dkf Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.50 2008/11/22 20:05:32 patthoyts Exp $
*/
#include "tkInt.h"
#include "tkFont.h"
+#define ROUND16(x) ((short)((x) + 0.5))
+
/*
* The following structure is used to keep track of all the fonts that exist
* in the current application. It must be stored in the TkMainInfo for the
@@ -2454,10 +2456,10 @@ TkUnderlineAngledTextLayout(
* minimizes roundoff errors.
*/
- points[0].x = x + round(xx*cosA + dy*sinA);
- points[0].y = y + round(dy*cosA - xx*sinA);
- points[1].x = x + round(xx*cosA + dy*sinA + width*cosA);
- points[1].y = y + round(dy*cosA - xx*sinA - width*sinA);
+ points[0].x = x + ROUND16(xx*cosA + dy*sinA);
+ points[0].y = y + ROUND16(dy*cosA - xx*sinA);
+ points[1].x = x + ROUND16(xx*cosA + dy*sinA + width*cosA);
+ points[1].y = y + ROUND16(dy*cosA - xx*sinA - width*sinA);
if (fontPtr->underlineHeight == 1) {
/*
* Thin underlines look better when rotated when drawn as a line
@@ -2466,13 +2468,13 @@ TkUnderlineAngledTextLayout(
XDrawLines(display, drawable, gc, points, 2, CoordModeOrigin);
} else {
- points[2].x = x + round(xx*cosA + dy*sinA + width*cosA
+ points[2].x = x + ROUND16(xx*cosA + dy*sinA + width*cosA
- fontPtr->underlineHeight*sinA);
- points[2].y = y + round(dy*cosA - xx*sinA - width*sinA
+ points[2].y = y + ROUND16(dy*cosA - xx*sinA - width*sinA
+ fontPtr->underlineHeight*cosA);
- points[3].x = x + round(xx*cosA + dy*sinA
+ points[3].x = x + ROUND16(xx*cosA + dy*sinA
- fontPtr->underlineHeight*sinA);
- points[3].y = y + round(dy*cosA - xx*sinA
+ points[3].y = y + ROUND16(dy*cosA - xx*sinA
+ fontPtr->underlineHeight*cosA);
points[4].x = points[0].x;
points[4].y = points[0].y;