summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tkCanvText.c49
-rw-r--r--generic/tkFont.c20
-rw-r--r--win/tkWinDraw.c3
-rw-r--r--win/tkWinFont.c14
5 files changed, 51 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index 81b169e..e861d70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-22 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * generic/tkCanvText.c: Fixed up complaints from MSVC engendered
+ * generic/tkFont.c: by the last commit. In particular replaced
+ * win/tkWinDraw.c: round() which is a C99 function.
+ * win/tkWinFont.c:
+
2008-11-22 Donal K. Fellows <dkf@users.sf.net>
TIP #119 IMPLEMENTATION
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;
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 15821f3..9d1a7cd 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinDraw.c,v 1.22 2008/11/08 18:44:40 dkf Exp $
+ * RCS: @(#) $Id: tkWinDraw.c,v 1.23 2008/11/22 20:05:32 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -19,7 +19,6 @@
* These macros convert between X's bizarre angle units to radians.
*/
-#define PI 3.14159265358979
#define XAngleToRadians(a) ((double)(a) / 64 * PI / 180);
/*
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 264acc2..9fa4963 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.44 2008/11/22 18:08:51 dkf Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.45 2008/11/22 20:05:32 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -1298,12 +1298,12 @@ TkpDrawAngledChars(
*/
PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
- BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
+ MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0xEA02E9);
PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
- BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
+ MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0x8A0E06);
/*
@@ -1319,7 +1319,7 @@ TkpDrawAngledChars(
SetTextAlign(dc, TA_LEFT | TA_BASELINE);
SetTextColor(dc, gc->foreground);
SetBkMode(dc, TRANSPARENT);
- MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
@@ -1345,7 +1345,7 @@ TkpDrawAngledChars(
MultiFontTextOut(dcMem, fontPtr, source, numBytes, 0, tm.tmAscent,
angle);
- BitBlt(dc, x, y - tm.tmAscent, size.cx, size.cy, dcMem,
+ BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, (DWORD) tkpWinBltModes[gc->function]);
/*