From 2aa54d47d66b5cda0dca2b743e11c954581a7b99 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 12 Jul 2013 14:12:31 +0000 Subject: [PATCH] Fix warnings about implicit float or double to int conversions in wxMSW. Make the conversions explicit as these warnings are harmless. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/bitmap.h | 5 +++-- src/generic/spinctlg.cpp | 2 +- src/msw/spinctrl.cpp | 2 +- src/msw/uiaction.cpp | 6 ++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index f4e6cb4..3f7ca53 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -13,6 +13,7 @@ #define _WX_BITMAP_H_ #include "wx/msw/gdiimage.h" +#include "wx/math.h" #include "wx/palette.h" class WXDLLIMPEXP_FWD_CORE wxBitmap; @@ -145,7 +146,7 @@ public: virtual bool Create(int width, int height, const wxDC& dc); virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); virtual bool CreateScaled(int w, int h, int d, double logicalScale) - { return Create(w*logicalScale,h*logicalScale,d); } + { return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); } virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; @@ -175,7 +176,7 @@ public: virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); } virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); } virtual wxSize GetScaledSize() const - { return wxSize(GetScaledWidth(), GetScaledHeight()); } + { return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); } // implementation only from now on // ------------------------------- diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index ffeacd8..90d087d 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -284,7 +284,7 @@ wxSize wxSpinCtrlGenericBase::DoGetSizeFromTextSize(int xlen, int ylen) const wxSize tsize(xlen + sizeBtn.x + MARGIN, totalS.y); #if defined(__WXMSW__) - tsize.IncBy(0.4 * totalS.y + 4, 0); + tsize.IncBy(4*totalS.y/10 + 4, 0); #elif defined(__WXGTK__) tsize.IncBy(totalS.y + 10, 0); #endif // MSW GTK diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 038d298..8cea79b 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -731,7 +731,7 @@ wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const // that's too big. So never use the height calculated // from wxSpinButton::DoGetBestSize(). - wxSize tsize(xlen + sizeBtn.x + MARGIN_BETWEEN + 0.3 * y + 10, + wxSize tsize(xlen + sizeBtn.x + MARGIN_BETWEEN + 3*y/10 + 10, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); // Check if the user requested a non-standard height. diff --git a/src/msw/uiaction.cpp b/src/msw/uiaction.cpp index 5aff359..bc5bde1 100644 --- a/src/msw/uiaction.cpp +++ b/src/msw/uiaction.cpp @@ -65,8 +65,10 @@ bool wxUIActionSimulator::MouseMove(long x, long y) int displayx, displayy; wxDisplaySize(&displayx, &displayy); - int scaledx = ceil((float)x * 65535.0 / (displayx-1)); - int scaledy = ceil((float)y * 65535.0 / (displayy-1)); + // Casts are safe because x and y are supposed to be less than the display + // size, so there is no danger of overflow. + DWORD scaledx = static_cast(ceil(x * 65535.0 / (displayx-1))); + DWORD scaledy = static_cast(ceil(y * 65535.0 / (displayy-1))); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0); return true; -- 2.7.4