Avoid some -Wfloat-conversion warnings
This commit is contained in:
@@ -1072,28 +1072,28 @@ void MyCanvas::DrawWithLogicalOps(wxDC& dc)
|
||||
#if wxDRAWING_DC_SUPPORTS_ALPHA || wxUSE_GRAPHICS_CONTEXT
|
||||
void MyCanvas::DrawAlpha(wxDC& dc)
|
||||
{
|
||||
wxDouble margin = 20 ;
|
||||
wxDouble width = 180 ;
|
||||
const int margin = 20;
|
||||
const int width = 180;
|
||||
wxDouble radius = 30 ;
|
||||
|
||||
dc.SetPen( wxPen( wxColour( 128, 0, 0 ), 12 ));
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
|
||||
wxRect r(margin,margin+width*0.66,width,width) ;
|
||||
wxRect r(margin, margin + width * 2 / 3, width, width);
|
||||
|
||||
dc.DrawRoundedRectangle( r.x, r.y, r.width, r.width, radius ) ;
|
||||
|
||||
dc.SetPen( wxPen( wxColour( 0, 0, 128 ), 12));
|
||||
dc.SetBrush( wxColour(0, 0, 255, 192) );
|
||||
|
||||
r.Offset( width * 0.8 , - width * 0.66 ) ;
|
||||
r.Offset(width * 4 / 5, -width * 2 / 3);
|
||||
|
||||
dc.DrawRoundedRectangle( r.x, r.y, r.width, r.width, radius ) ;
|
||||
|
||||
dc.SetPen( wxPen( wxColour( 128, 128, 0 ), 12));
|
||||
dc.SetBrush( wxBrush( wxColour( 192, 192, 0, 192)));
|
||||
|
||||
r.Offset( width * 0.8 , width *0.5 ) ;
|
||||
r.Offset(width * 4 / 5, width / 2);
|
||||
|
||||
dc.DrawRoundedRectangle( r.x, r.y, r.width, r.width, radius ) ;
|
||||
|
||||
|
||||
@@ -2777,8 +2777,7 @@ void GridFrame::OnGridRender( wxCommandEvent& event )
|
||||
if ( styleRender & wxGRID_DRAW_COLS_HEADER )
|
||||
sizeRender.y += grid->GetColLabelSize();
|
||||
|
||||
sizeRender.x *= zoom;
|
||||
sizeRender.y *= zoom;
|
||||
sizeRender *= zoom;
|
||||
|
||||
// delete any existing render frame and create new one
|
||||
wxWindow* win = FindWindowByName( "frameRender" );
|
||||
|
||||
@@ -240,8 +240,8 @@ private:
|
||||
dc.DrawBitmap
|
||||
(
|
||||
m_bitmap,
|
||||
dc.DeviceToLogicalX((size.x - m_zoom*m_bitmap.GetWidth())/2),
|
||||
dc.DeviceToLogicalY((size.y - m_zoom*m_bitmap.GetHeight())/2),
|
||||
dc.DeviceToLogicalX((size.x - int(m_zoom * m_bitmap.GetWidth())) / 2),
|
||||
dc.DeviceToLogicalY((size.y - int(m_zoom * m_bitmap.GetHeight())) / 2),
|
||||
true /* use mask */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ bool DXFRenderer::ParseEntities(wxInputStream& stream)
|
||||
state = 2;
|
||||
else if (state > 0)
|
||||
{
|
||||
const double d=ToDouble(line2);
|
||||
const float d = float(ToDouble(line2));
|
||||
|
||||
if (line1 == "10")
|
||||
v[0].x = d;
|
||||
@@ -670,7 +670,7 @@ void DXFRenderer::Render() const
|
||||
{
|
||||
DXFLine *line = (DXFLine *)p;
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(c.Red()/255.0,c.Green()/255.0,c.Blue()/255.0);
|
||||
glColor3f(c.Red()/255.0f, c.Green()/255.0f, c.Blue()/255.0f);
|
||||
glVertex3f(line->v0.x, line->v0.y, line->v0.z);
|
||||
glVertex3f(line->v1.x, line->v1.y, line->v1.z);
|
||||
glEnd();
|
||||
@@ -679,7 +679,7 @@ void DXFRenderer::Render() const
|
||||
{
|
||||
DXFFace *face = (DXFFace *)p;
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(c.Red()/255.0,c.Green()/255.0,c.Blue()/255.0);
|
||||
glColor3f(c.Red()/255.0f, c.Green()/255.0f, c.Blue()/255.0f);
|
||||
glNormal3f(face->n.x, face->n.y, face->n.z);
|
||||
glVertex3f(face->v0.x, face->v0.y, face->v0.z);
|
||||
glVertex3f(face->v1.x, face->v1.y, face->v1.z);
|
||||
|
||||
@@ -383,7 +383,7 @@ private:
|
||||
dc.DrawText(notImplementedText, x2, y);
|
||||
else
|
||||
renderer.DrawChoice(this, dc,
|
||||
wxRect(x2, y, width, 1.5*GetCharHeight()), m_flags);
|
||||
wxRect(x2, y, width, GetCharHeight() * 3 / 2), m_flags);
|
||||
}
|
||||
|
||||
int m_flags;
|
||||
|
||||
@@ -952,7 +952,7 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = GetClientSize().GetWidth() * 0.8;
|
||||
int width = GetClientSize().GetWidth() * 4 / 5;
|
||||
splitter->SplitVertically(m_richTextCtrl, styleListCtrl, width);
|
||||
splitter->SetSashGravity(0.8);
|
||||
}
|
||||
|
||||
@@ -484,10 +484,10 @@ void MyPage::OnDraw(wxDC& dc)
|
||||
double padding = (double)txtPad / sqrt(2.0);
|
||||
txtX = 150;
|
||||
txtY = 200;
|
||||
dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top
|
||||
dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW));
|
||||
dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
|
||||
dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
|
||||
dc.DrawLine(txtX - int(padding), txtY, txtX + int(lenW), txtY - int(lenW)); // top
|
||||
dc.DrawLine(txtX + int(lenW), txtY - int(lenW), txtX - int(padding + lenH + lenW), txtY + int(lenH - lenW));
|
||||
dc.DrawLine(txtX - int(padding), txtY, txtX - int(padding + lenH), txtY + int(lenH));
|
||||
dc.DrawLine(txtX - int(padding + lenH), txtY + int(lenH), txtX - int(padding + lenH + lenW), txtY + int(lenH - lenW)); // bottom
|
||||
dc.DrawRotatedText(txtStr, txtX, txtY, 45);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ bool wxAffineMatrix2D::Invert()
|
||||
{
|
||||
const wxDouble det = m_11*m_22 - m_12*m_21;
|
||||
|
||||
if ( !det )
|
||||
if ( det == 0 )
|
||||
return false;
|
||||
|
||||
wxDouble ex = (m_21*m_ty - m_22*m_tx) / det;
|
||||
|
||||
@@ -759,8 +759,8 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
wxCoord dx = x + w / 2.0;
|
||||
wxCoord dy = y + h / 2.0;
|
||||
wxCoord dx = x + w / 2;
|
||||
wxCoord dy = y + h / 2;
|
||||
wxDouble factor = ((wxDouble) w) / h;
|
||||
m_graphicContext->PushState();
|
||||
m_graphicContext->Translate(dx, dy);
|
||||
@@ -1455,7 +1455,7 @@ wxRect wxGCDCImpl::MSWApplyGDIPlusTransform(const wxRect& r) const
|
||||
m_graphicContext->GetTransform().TransformPoint(&x, &y);
|
||||
|
||||
wxRect rect(r);
|
||||
rect.Offset(x, y);
|
||||
rect.Offset(int(x), int(y));
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ wxImage wxImage::ResampleBox(int width, int height) const
|
||||
// Calculate the average from the sum and number of averaged pixels
|
||||
if (src_alpha)
|
||||
{
|
||||
if (sum_a)
|
||||
if (sum_a != 0)
|
||||
{
|
||||
dst_data[0] = (unsigned char)(sum_r / sum_a);
|
||||
dst_data[1] = (unsigned char)(sum_g / sum_a);
|
||||
@@ -1054,7 +1054,7 @@ wxImage wxImage::ResampleBicubic(int width, int height) const
|
||||
// of double data type and are rounded here for accuracy
|
||||
if ( src_alpha )
|
||||
{
|
||||
if ( sum_a )
|
||||
if (sum_a != 0)
|
||||
{
|
||||
dst_data[0] = (unsigned char)(sum_r / sum_a + 0.5);
|
||||
dst_data[1] = (unsigned char)(sum_g / sum_a + 0.5);
|
||||
|
||||
@@ -1335,14 +1335,14 @@ void wxPostScriptDCImpl::DrawAnyText(const wxWX2MBbuf& textbuf, wxCoord textDesc
|
||||
" dup stringwidth rlineto\n"
|
||||
" stroke\n"
|
||||
" grestore\n",
|
||||
-YLOG2DEVREL(textDescent - m_underlinePosition),
|
||||
-YLOG2DEVREL(textDescent - int(m_underlinePosition)),
|
||||
m_underlineThickness );
|
||||
buffer.Replace( ",", "." );
|
||||
PsPrint( buffer );
|
||||
}
|
||||
PsPrint( " show\n" ); // x y
|
||||
// Advance to the beginning of th next line.
|
||||
buffer.Printf( " %f add moveto\n", -YLOG2DEVREL(lineHeight) );
|
||||
buffer.Printf( " %f add moveto\n", -YLOG2DEVREL(int(lineHeight)) );
|
||||
buffer.Replace( ",", "." );
|
||||
PsPrint( buffer );
|
||||
// Execute above statements for all elements of the array
|
||||
|
||||
@@ -1156,7 +1156,7 @@ wxCairoFontData::wxCairoFontData(wxGraphicsRenderer* renderer,
|
||||
const wxColour& col) :
|
||||
wxGraphicsObjectRefData(renderer)
|
||||
#ifdef __WXGTK__
|
||||
, m_wxfont(wxFontInfo(wxSize(sizeInPixels, sizeInPixels))
|
||||
, m_wxfont(wxFontInfo(wxSize(int(sizeInPixels), int(sizeInPixels)))
|
||||
.AllFlags(flags).FaceName(facename))
|
||||
#endif
|
||||
{
|
||||
@@ -2506,7 +2506,7 @@ void wxCairoContext::Init(cairo_t *context)
|
||||
// Factor" in Gnome Tweaks, "Force font DPI" in KDE System Settings or
|
||||
// GDK_DPI_SCALE environment variable).
|
||||
GdkScreen* screen = gdk_screen_get_default();
|
||||
m_fontScalingFactor = screen ? gdk_screen_get_resolution(screen) / 96.0 : 1.0;
|
||||
m_fontScalingFactor = screen ? float(gdk_screen_get_resolution(screen) / 96.0) : 1.0f;
|
||||
#endif
|
||||
|
||||
m_context = context;
|
||||
@@ -3067,7 +3067,7 @@ bool wxCairoContext::SetCompositionMode(wxCompositionMode op)
|
||||
|
||||
void wxCairoContext::BeginLayer(wxDouble opacity)
|
||||
{
|
||||
m_layerOpacities.push_back(opacity);
|
||||
m_layerOpacities.push_back(float(opacity));
|
||||
cairo_push_group(m_context);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,10 +85,10 @@ void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
wxFAIL_MSG("Unknown scale mode");
|
||||
}
|
||||
|
||||
wxASSERT_MSG(w, wxS("Unknown scale mode"));
|
||||
|
||||
wxDouble x = (drawSize.x - w) / 2;
|
||||
wxDouble y = (drawSize.y - h) / 2;
|
||||
#if wxUSE_GRAPHICS_CONTEXT
|
||||
|
||||
@@ -4647,8 +4647,8 @@ gtk_dataview_motion_notify_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventMotion *gdk_event,
|
||||
wxDataViewCtrl *dv )
|
||||
{
|
||||
int x = gdk_event->x;
|
||||
int y = gdk_event->y;
|
||||
int x = int(gdk_event->x);
|
||||
int y = int(gdk_event->y);
|
||||
if (gdk_event->is_hint)
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
|
||||
@@ -374,7 +374,7 @@ void wxSpinCtrlGTKBase::DoSetRange(double minVal, double maxVal)
|
||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||
|
||||
// Negative values in the range are allowed only if base == 10
|
||||
if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(minVal, maxVal, GetBase()) )
|
||||
if ( !wxSpinCtrlImpl::IsBaseCompatibleWithRange(int(minVal), int(maxVal), GetBase()) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1980,7 +1980,7 @@ scroll_event(GtkWidget* widget, GdkEventScroll* gdk_event, wxWindow* win)
|
||||
}
|
||||
}
|
||||
bool handled = false;
|
||||
if (delta_x)
|
||||
if (delta_x != 0)
|
||||
{
|
||||
event.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
|
||||
event.m_wheelRotation = int(event.m_wheelDelta * delta_x);
|
||||
@@ -1991,7 +1991,7 @@ scroll_event(GtkWidget* widget, GdkEventScroll* gdk_event, wxWindow* win)
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if (delta_y)
|
||||
if (delta_y != 0)
|
||||
{
|
||||
event.m_wheelAxis = wxMOUSE_WHEEL_VERTICAL;
|
||||
event.m_wheelRotation = int(event.m_wheelDelta * -delta_y);
|
||||
@@ -3367,8 +3367,8 @@ wxEmitPressAndTapEvent(GdkEventTouch* gdk_event, wxWindow* win)
|
||||
// Update touch point as the touch corresponding to "press" is moving
|
||||
if ( data->m_touchSequence == gdk_event->sequence )
|
||||
{
|
||||
data->m_lastTouchPoint.x = gdk_event->x;
|
||||
data->m_lastTouchPoint.y = gdk_event->y;
|
||||
data->m_lastTouchPoint.x = int(gdk_event->x);
|
||||
data->m_lastTouchPoint.y = int(gdk_event->y);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3483,8 +3483,8 @@ touch_callback(GtkWidget* widget, GdkEventTouch* gdk_event, wxWindow* win)
|
||||
if ( data->m_touchCount == 1 )
|
||||
{
|
||||
data->m_lastTouchTime = gdk_event->time;
|
||||
data->m_lastTouchPoint.x = gdk_event->x;
|
||||
data->m_lastTouchPoint.y = gdk_event->y;
|
||||
data->m_lastTouchPoint.x = int(gdk_event->x);
|
||||
data->m_lastTouchPoint.y = int(gdk_event->y);
|
||||
|
||||
// Save the sequence which identifies touch corresponding to "press"
|
||||
data->m_touchSequence = gdk_event->sequence;
|
||||
|
||||
@@ -2959,7 +2959,7 @@ void wxTextCtrl::MSWSetRichZoom()
|
||||
|
||||
// apply the new zoom ratio, Windows uses a default denominator of 100, so
|
||||
// do it here as well
|
||||
num = 100 * ratio;
|
||||
num = UINT(100 * ratio);
|
||||
denom = 100;
|
||||
::SendMessage(GetHWND(), EM_SETZOOM, (WPARAM)num, (LPARAM)denom);
|
||||
}
|
||||
@@ -3238,7 +3238,7 @@ bool wxTextCtrl::MSWSetCharFormat(const wxTextAttr& style, long start, long end)
|
||||
wxFont font(style.GetFont());
|
||||
|
||||
LOGFONT lf = font.GetNativeFontInfo()->lf;
|
||||
cf.yHeight = 20 * font.GetFractionalPointSize(); // 1 pt = 20 twips
|
||||
cf.yHeight = LONG(20 * font.GetFractionalPointSize()); // 1 pt = 20 twips
|
||||
cf.bCharSet = lf.lfCharSet;
|
||||
cf.bPitchAndFamily = lf.lfPitchAndFamily;
|
||||
wxStrlcpy(cf.szFaceName, lf.lfFaceName, WXSIZEOF(cf.szFaceName));
|
||||
|
||||
@@ -1315,7 +1315,7 @@ OSStatus wxOSXRegionToRectsSetterCallback(
|
||||
if (message == kHIShapeEnumerateRect)
|
||||
{
|
||||
RegionToRectsCallbackData *cb = (RegionToRectsCallbackData*) data ;
|
||||
cb->m_rects[cb->m_current++] = wxRect( rect->origin.x , rect->origin.y , rect->size.width , rect->size.height ) ;
|
||||
cb->m_rects[cb->m_current++] = wxRect(int(rect->origin.x), int(rect->origin.y), int(rect->size.width), int(rect->size.height)) ;
|
||||
}
|
||||
|
||||
return noErr;
|
||||
|
||||
@@ -309,7 +309,7 @@ int wxBitmapRefData::GetWidth() const
|
||||
if ( m_hBitmap )
|
||||
return (int) CGBitmapContextGetWidth(m_hBitmap);
|
||||
else
|
||||
return (int) wxOSXGetImageSize(m_nsImage).width * m_scaleFactor;
|
||||
return int(wxOSXGetImageSize(m_nsImage).width * m_scaleFactor);
|
||||
}
|
||||
|
||||
int wxBitmapRefData::GetHeight() const
|
||||
@@ -319,7 +319,7 @@ int wxBitmapRefData::GetHeight() const
|
||||
if ( m_hBitmap )
|
||||
return (int) CGBitmapContextGetHeight(m_hBitmap);
|
||||
else
|
||||
return (int) wxOSXGetImageSize(m_nsImage).height * m_scaleFactor;
|
||||
return int(wxOSXGetImageSize(m_nsImage).height * m_scaleFactor);
|
||||
}
|
||||
|
||||
int wxBitmapRefData::GetDepth() const
|
||||
@@ -966,8 +966,8 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
|
||||
if ( HasAlpha() )
|
||||
ret.UseAlpha() ;
|
||||
|
||||
int destwidth = rect.width*scale ;
|
||||
int destheight = rect.height*scale ;
|
||||
int destwidth = int(rect.width * scale);
|
||||
int destheight = int(rect.height * scale);
|
||||
|
||||
{
|
||||
const unsigned char* sourcedata = static_cast<const unsigned char*>(GetBitmapData()->GetRawAccess());
|
||||
|
||||
@@ -200,9 +200,9 @@ void wxColour::GetRGBColor(RGBColor* col) const
|
||||
{
|
||||
wxCHECK_RET( IsOk(), "invalid colour" );
|
||||
|
||||
col->red = M_COLDATA->Red() * 65535.0;
|
||||
col->blue = M_COLDATA->Blue() * 65535.0;
|
||||
col->green = M_COLDATA->Green() * 65535.0;
|
||||
col->red = static_cast<unsigned short>(M_COLDATA->Red() * 65535);
|
||||
col->blue = static_cast<unsigned short>(M_COLDATA->Blue() * 65535);
|
||||
col->green = static_cast<unsigned short>(M_COLDATA->Green() * 65535);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ wxArrayVideoModes wxDisplayImplMacOSX::GetModes(const wxVideoMode& mode) const
|
||||
CGDisplayModeGetWidth(theValue),
|
||||
CGDisplayModeGetHeight(theValue),
|
||||
wxOSXCGDisplayModeGetBitsPerPixel(theValue),
|
||||
CGDisplayModeGetRefreshRate(theValue));
|
||||
int(CGDisplayModeGetRefreshRate(theValue)));
|
||||
|
||||
if (theMode.Matches( mode ))
|
||||
resultModes.Add( theMode );
|
||||
@@ -358,7 +358,7 @@ wxVideoMode wxDisplayImplMacOSX::GetCurrentMode() const
|
||||
CGDisplayModeGetWidth(theValue),
|
||||
CGDisplayModeGetHeight(theValue),
|
||||
wxOSXCGDisplayModeGetBitsPerPixel(theValue),
|
||||
CGDisplayModeGetRefreshRate(theValue));
|
||||
int(CGDisplayModeGetRefreshRate(theValue)));
|
||||
}
|
||||
|
||||
bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode )
|
||||
@@ -385,7 +385,7 @@ bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode )
|
||||
CGDisplayModeGetWidth(theValue),
|
||||
CGDisplayModeGetHeight(theValue),
|
||||
wxOSXCGDisplayModeGetBitsPerPixel(theValue),
|
||||
CGDisplayModeGetRefreshRate(theValue));
|
||||
int(CGDisplayModeGetRefreshRate(theValue)));
|
||||
|
||||
if ( theMode.GetWidth() == mode.GetWidth() && theMode.GetHeight() == mode.GetHeight() &&
|
||||
( mode.GetDepth() == 0 || theMode.GetDepth() == mode.GetDepth() ) &&
|
||||
|
||||
@@ -5101,7 +5101,7 @@ bool wxPropertyGrid::HandleMouseMove( int x, unsigned int y,
|
||||
imageWidth = bmp.GetWidth();
|
||||
int hMax = m_lineHeight - wxPG_CUSTOM_IMAGE_SPACINGY - 1;
|
||||
if ( bmp.GetHeight() > hMax )
|
||||
imageWidth *= (double)hMax / bmp.GetHeight();
|
||||
imageWidth = int(double(imageWidth) * hMax / bmp.GetHeight());
|
||||
}
|
||||
|
||||
if ( m_colHover == 0 )
|
||||
|
||||
@@ -71,7 +71,7 @@ wxBitmap MakeResizedBitmap(const wxBitmap& original, wxSize size)
|
||||
scale = 2.0;
|
||||
|
||||
wxImage img(original.ConvertToImage());
|
||||
img.Rescale(scale * size.GetWidth(), scale * size.GetHeight(), wxIMAGE_QUALITY_HIGH);
|
||||
img.Rescale(int(scale * size.GetWidth()), int(scale * size.GetHeight()), wxIMAGE_QUALITY_HIGH);
|
||||
return wxBitmap(img, -1, scale);
|
||||
}
|
||||
|
||||
|
||||
@@ -700,7 +700,7 @@ bool wxRibbonPanel::Realize()
|
||||
scale = 2.0;
|
||||
|
||||
wxImage img(m_minimised_icon.ConvertToImage());
|
||||
img.Rescale(scale * bitmap_size.GetWidth(), scale * bitmap_size.GetHeight(), wxIMAGE_QUALITY_HIGH);
|
||||
img.Rescale(int(scale * bitmap_size.GetWidth()), int(scale * bitmap_size.GetHeight()), wxIMAGE_QUALITY_HIGH);
|
||||
m_minimised_icon_resized = wxBitmap(img, -1, scale);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user