Avoid -Wdouble-promotion warnings

This commit is contained in:
Paul Cornett
2020-10-14 11:07:55 -07:00
parent 97655e5b21
commit b5a554b9a6
44 changed files with 208 additions and 201 deletions

View File

@@ -1205,7 +1205,7 @@ void MyCanvas::DrawGraphics(wxGraphicsContext* gc)
{
gc->PushState(); // save this new current state so we can
// pop back to it at the end of the loop
wxImage::RGBValue val = wxImage::HSVtoRGB(wxImage::HSVValue(float(angle)/360, 1, 1));
wxImage::RGBValue val = wxImage::HSVtoRGB(wxImage::HSVValue(angle / 360.0, 1, 1));
gc->SetBrush(wxBrush(wxColour(val.red, val.green, val.blue, 64)));
gc->SetPen(wxPen(wxColour(val.red, val.green, val.blue, 128)));

View File

@@ -150,7 +150,7 @@ TestGLContext::TestGLContext(wxGLCanvas *canvas)
// set viewing projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.5f, 0.5f, -0.5f, 0.5f, 1.0f, 3.0f);
glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3);
// create the textures to use for cube sides: they will be reused by all
// canvases (which is probably not critical in the case of simple textures
@@ -362,13 +362,13 @@ void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
glDrawBuffer( GL_BACK_LEFT );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.47f, 0.53f, -0.5f, 0.5f, 1.0f, 3.0f);
glFrustum(-0.47, 0.53, -0.5, 0.5, 1, 3);
canvas.DrawRotatedCube(m_xangle, m_yangle);
CheckGLError();
glDrawBuffer( GL_BACK_RIGHT );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.53f, 0.47f, -0.5f, 0.5f, 1.0f, 3.0f);
glFrustum(-0.53, 0.47, -0.5, 0.5, 1, 3);
canvas.DrawRotatedCube(m_xangle, m_yangle);
CheckGLError();
}

View File

@@ -293,19 +293,19 @@ void TestGLCanvas::OnChar(wxKeyEvent& event)
return;
case WXK_LEFT:
m_yrot -= 15.0;
m_yrot -= 15;
break;
case WXK_RIGHT:
m_yrot += 15.0;
m_yrot += 15;
break;
case WXK_UP:
m_xrot += 15.0;
m_xrot += 15;
break;
case WXK_DOWN:
m_xrot -= 15.0;
m_xrot -= 15;
break;
case 's': case 'S':
@@ -349,8 +349,8 @@ void TestGLCanvas::OnMouseEvent(wxMouseEvent& event)
}
else
{
m_yrot += (event.GetX() - last_x)*1.0;
m_xrot += (event.GetY() - last_y)*1.0;
m_yrot += event.GetX() - last_x;
m_xrot += event.GetY() - last_y;
Refresh(false);
}
last_x = event.GetX();

View File

@@ -247,10 +247,10 @@ void TestGLCanvas::OnMouse(wxMouseEvent& event)
/* drag in progress, simulate trackball */
float spin_quat[4];
trackball(spin_quat,
(2.0*m_gldata.beginx - sz.x) / sz.x,
(sz.y - 2.0*m_gldata.beginy) / sz.y,
(2.0*event.GetX() - sz.x) / sz.x,
(sz.y - 2.0*event.GetY()) / sz.y);
(2 * m_gldata.beginx - sz.x) / sz.x,
(sz.y - 2 * m_gldata.beginy) / sz.y,
(2 * event.GetX() - sz.x) / sz.x,
(sz.y - 2 * event.GetY()) / sz.y);
add_quats(spin_quat, m_gldata.quat, m_gldata.quat);
@@ -315,7 +315,7 @@ void TestGLCanvas::ResetProjectionMode()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)ClientSize.x/ClientSize.y, 1.0, 100.0);
gluPerspective(45, double(ClientSize.x) / ClientSize.y, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

View File

@@ -113,7 +113,7 @@ vcross(const float *v1, const float *v2, float *cross)
float
vlength(const float *v)
{
return (float) sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
return (float) sqrt((double)(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]));
}
void
@@ -192,9 +192,9 @@ trackball(float q[4], float p1x, float p1y, float p2x, float p2y)
/*
* Avoid problems with out-of-control values...
*/
if (t > 1.0) t = 1.0;
if (t < -1.0) t = -1.0;
phi = 2.0f * (float) asin(t);
if (t > 1) t = 1;
if (t < -1) t = -1;
phi = 2 * (float) asin((double)t);
axis_to_quat(a,phi,q);
}
@@ -207,8 +207,8 @@ axis_to_quat(float a[3], float phi, float q[4])
{
vnormal(a);
vcopy(a, q);
vscale(q, (float) sin(phi/2.0));
q[3] = (float) cos(phi/2.0);
vscale(q, (float) sin((double)phi / 2));
q[3] = (float) cos((double)phi / 2);
}
/*
@@ -220,9 +220,9 @@ tb_project_to_sphere(float r, float x, float y)
{
float d, t, z;
d = (float) sqrt(x*x + y*y);
if (d < r * 0.70710678118654752440) { /* Inside sphere */
z = (float) sqrt(r*r - d*d);
d = (float) sqrt((double)(x*x + y*y));
if (d < r * 0.70710678118654752440f) { /* Inside sphere */
z = (float) sqrt((double)(r*r - d*d));
} else { /* On hyperbola */
t = r / 1.41421356237309504880f;
z = t*t / d;

View File

@@ -21,6 +21,7 @@ class myVec3
public:
myVec3() { x = y = z = 0.0 ;}
myVec3(double xd, double yd, double zd) : x(xd), y(yd), z(zd) {}
myVec3(float xd, float yd, float zd) : x(double(xd)), y(double(yd)), z(double(zd)) {}
~myVec3() {}
double x, y, z;

View File

@@ -1187,16 +1187,16 @@ void myOGLManager::SetStringOnPyr(const unsigned char* strImage, int iWidth, int
double edgeLen = MyDistance(myVec3(gVerts[0], gVerts[1], gVerts[2]),
myVec3(gVerts[6], gVerts[7], gVerts[8]));
GLfloat prop = ((GLfloat) iHeigh) / ((GLfloat) iWidth);
GLfloat rw = (GLfloat) (edgeLen / (1 + 4.0 * prop / sqrt(3.0)));
GLfloat rw = float(edgeLen) / (1 + 4 * prop / std::sqrt(3.0f));
GLfloat h = prop * rw;
GLfloat de = (GLfloat)(2.0 * h / sqrt(3.0));
GLfloat de = 2 * h / std::sqrt(3.0f);
// A bit of separation of the face so as to avoid z-fighting
GLfloat rY = gVerts[1] - (GLfloat)0.01; // Towards outside
GLfloat rY = gVerts[1] - 0.01f; // Towards outside
GLfloat sVerts[12];
// The image was created top to bottom, but OpenGL axis are bottom to top.
// The image would display upside down. We avoid it choosing the right
// order of vertices and texture coords. See myOGLString::SetStringWithVerts()
sVerts[0] = gVerts[6] + de; sVerts[1] = rY; sVerts[2] = gVerts[8] + h / (GLfloat)2.0;
sVerts[0] = gVerts[6] + de; sVerts[1] = rY; sVerts[2] = gVerts[8] + h / 2;
sVerts[3] = sVerts[0] ; sVerts[4] = rY; sVerts[5] = sVerts[2] + h;
sVerts[6] = sVerts[0] + rw; sVerts[7] = rY; sVerts[8] = sVerts[2];
sVerts[9] = sVerts[6] ; sVerts[10] = rY; sVerts[11] = sVerts[5];

View File

@@ -651,7 +651,7 @@ void MyPrintout::DrawPageTwo()
// scaling. The text point size _should_ be the right size but in fact is
// too small for some reason. This is a detail that will need to be
// addressed at some point but can be fudged for the moment.
float scale = (float)((float)ppiPrinterX/(float)ppiScreenX);
double scale = double(ppiPrinterX) / ppiScreenX;
// Now we have to check in case our real page size is reduced (e.g. because
// we're drawing to a print preview memory DC)
@@ -662,7 +662,7 @@ void MyPrintout::DrawPageTwo()
// If printer pageWidth == current DC width, then this doesn't change. But w
// might be the preview bitmap width, so scale down.
float overallScale = scale * (float)(w/(float)pageWidth);
double overallScale = scale * w / pageWidth;
dc->SetUserScale(overallScale, overallScale);
// Calculate conversion factor for converting millimetres into logical
@@ -672,11 +672,11 @@ void MyPrintout::DrawPageTwo()
// unscale to pass logical units to DrawLine.
// Draw 50 mm by 50 mm L shape
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.4));
float logUnits = (float)(50*logUnitsFactor);
double logUnitsFactor = ppiPrinterX / (scale * 25.4);
int logUnits = int(50 * logUnitsFactor);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine(50, 250, (long)(50.0 + logUnits), 250);
dc->DrawLine(50, 250, 50, (long)(250.0 + logUnits));
dc->DrawLine(50, 250, 50 + logUnits, 250);
dc->DrawLine(50, 250, 50, 250 + logUnits);
dc->SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
dc->SetBrush(*wxTRANSPARENT_BRUSH);
@@ -716,22 +716,22 @@ void MyPrintout::DrawPageTwo()
int pageWidthMM, pageHeightMM;
GetPageSizeMM(&pageWidthMM, &pageHeightMM);
float leftMarginLogical = (float)(logUnitsFactor*leftMargin);
float topMarginLogical = (float)(logUnitsFactor*topMargin);
float bottomMarginLogical = (float)(logUnitsFactor*(pageHeightMM - bottomMargin));
float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin));
int leftMarginLogical = int(logUnitsFactor * leftMargin);
int topMarginLogical = int(logUnitsFactor * topMargin);
int bottomMarginLogical = int(logUnitsFactor * (pageHeightMM - bottomMargin));
int rightMarginLogical = int(logUnitsFactor * (pageWidthMM - rightMargin));
dc->SetPen(* wxRED_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical,
(long)rightMarginLogical, (long)topMarginLogical);
dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
(long)rightMarginLogical, (long)bottomMarginLogical);
dc->DrawLine(leftMarginLogical, topMarginLogical,
rightMarginLogical, topMarginLogical);
dc->DrawLine(leftMarginLogical, bottomMarginLogical,
rightMarginLogical, bottomMarginLogical);
WritePageHeader(this, dc, "A header", logUnitsFactor);
}
// Writes a header on a page. Margin units are in millimetres.
bool MyPrintout::WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString&text, float mmToLogical)
bool MyPrintout::WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString&text, double mmToLogical)
{
int pageWidthMM, pageHeightMM;
@@ -742,19 +742,19 @@ bool MyPrintout::WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString&
int topMargin = 10;
int rightMargin = 10;
float leftMarginLogical = (float)(mmToLogical*leftMargin);
float topMarginLogical = (float)(mmToLogical*topMargin);
float rightMarginLogical = (float)(mmToLogical*(pageWidthMM - rightMargin));
int leftMarginLogical = int(mmToLogical * leftMargin);
int topMarginLogical = int(mmToLogical * topMargin);
int rightMarginLogical = int(mmToLogical * (pageWidthMM - rightMargin));
wxCoord xExtent, yExtent;
dc->GetTextExtent(text, &xExtent, &yExtent);
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
dc->DrawText(text, (long)xPos, (long)topMarginLogical);
int xPos = int(((((pageWidthMM - leftMargin - rightMargin) / 2.0) + leftMargin) * mmToLogical) - (xExtent / 2.0));
dc->DrawText(text, xPos, topMarginLogical);
dc->SetPen(* wxBLACK_PEN);
dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
(long)rightMarginLogical, (long)topMarginLogical+yExtent );
dc->DrawLine(leftMarginLogical, topMarginLogical + yExtent,
rightMarginLogical, topMarginLogical + yExtent);
return true;
}

View File

@@ -98,7 +98,7 @@ public:
void DrawPageTwo();
// Writes a header on a page. Margin units are in millimetres.
bool WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString& text, float mmToLogical);
bool WritePageHeader(wxPrintout *printout, wxDC *dc, const wxString& text, double mmToLogical);
private:
MyFrame *m_frame;

View File

@@ -499,15 +499,15 @@ void SeeThroughFrame::OnPaint(wxPaintEvent& WXUNUSED(evt))
int xcount = 8;
int ycount = 8;
float xstep = 1. / xcount;
float ystep = 1. / ycount;
double xstep = 1.0 / xcount;
double ystep = 1.0 / ycount;
int width = GetClientSize().GetWidth();
int height = GetClientSize().GetHeight();
for ( float x = 0.; x < 1.; x += xstep )
for ( double x = 0; x < 1; x += xstep )
{
for ( float y = 0.; y < 1.; y += ystep )
for ( double y = 0; y < 1; y += ystep )
{
wxImage::RGBValue v = wxImage::HSVtoRGB(wxImage::HSVValue(x, 1., 1.));
dc.SetBrush(wxBrush(wxColour(v.red, v.green, v.blue,

View File

@@ -70,15 +70,16 @@ wxColor wxAuiLightContrastColour(const wxColour& c)
}
inline float wxAuiGetSRGB(float r) {
return r <= 0.03928 ? r/12.92 : pow((r+0.055)/1.055, 2.4);
return r <= 0.03928f ? r / 12.92f : std::pow((r + 0.055f) / 1.055f, 2.4f);
}
float wxAuiGetRelativeLuminance(const wxColour& c)
{
// based on https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
return 0.2126 * wxAuiGetSRGB(c.Red()/255.0)
+ 0.7152 * wxAuiGetSRGB(c.Green()/255.0)
+ 0.0722 * wxAuiGetSRGB(c.Blue()/255.0);
return
0.2126f * wxAuiGetSRGB(c.Red() / 255.0f) +
0.7152f * wxAuiGetSRGB(c.Green() / 255.0f) +
0.0722f * wxAuiGetSRGB(c.Blue() / 255.0f);
}
float wxAuiGetColourContrast(const wxColour& c1, const wxColour& c2)
@@ -86,7 +87,7 @@ float wxAuiGetColourContrast(const wxColour& c1, const wxColour& c2)
// based on https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html
float L1 = wxAuiGetRelativeLuminance(c1);
float L2 = wxAuiGetRelativeLuminance(c2);
return L1 > L2 ? (L1 + 0.05) / (L2 + 0.05) : (L2 + 0.05) / (L1 + 0.05);
return L1 > L2 ? (L1 + 0.05f) / (L2 + 0.05f) : (L2 + 0.05f) / (L1 + 0.05f);
}
// wxAuiBitmapFromBits() is a utility function that creates a

View File

@@ -82,7 +82,7 @@ wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size);
// (based on https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html)
static bool wxAuiHasSufficientContrast(const wxColour& c1, const wxColour& c2)
{
return wxAuiGetColourContrast(c1, c2) >= 4.5;
return wxAuiGetColourContrast(c1, c2) >= 4.5f;
}
// Pick a color that provides better contrast against the background

View File

@@ -187,9 +187,9 @@ bool wxConfigBase::Read(const wxString& key, float* val) const
if ( !Read(key, &temp) )
return false;
wxCHECK_MSG( fabs(temp) <= FLT_MAX, false,
wxCHECK_MSG( fabs(temp) <= double(FLT_MAX), false,
wxT("float overflow in wxConfig::Read") );
wxCHECK_MSG( (temp == 0.0) || (fabs(temp) >= FLT_MIN), false,
wxCHECK_MSG( temp == 0.0 || fabs(temp) >= double(FLT_MIN), false,
wxT("float underflow in wxConfig::Read") );
*val = static_cast<float>(temp);

View File

@@ -57,6 +57,11 @@ inline wxString NumStr(double f)
return wxString::FromCDouble(f, 2);
}
inline wxString NumStr(float f)
{
return NumStr(double(f));
}
// Return the colour representation as HTML-like "#rrggbb" string and also
// returns its alpha as opacity number in 0..1 range.
wxString Col2SVG(wxColour c, float* opacity = NULL)
@@ -546,7 +551,7 @@ void wxSVGFileDCImpl::Init(const wxString& filename, int width, int height,
s += wxS("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
s += wxS("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n\n");
s += wxS("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
s += wxString::Format(wxS(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d\">\n"), NumStr(float(m_width) / dpi * 2.54), NumStr(float(m_height) / dpi * 2.54), m_width, m_height);
s += wxString::Format(wxS(" width=\"%scm\" height=\"%scm\" viewBox=\"0 0 %d %d\">\n"), NumStr(m_width / dpi * 2.54), NumStr(m_height / dpi * 2.54), m_width, m_height);
s += wxString::Format(wxS("<title>%s</title>\n"), title);
s += wxString(wxS("<desc>Picture generated by wxSVG ")) + wxSVGVersion + wxS("</desc>\n\n");
s += wxS("<g style=\"fill:black; stroke:black; stroke-width:1\">\n");

View File

@@ -2168,7 +2168,7 @@ bool wxDocPrintout::OnPrintPage(int WXUNUSED(page))
// but in fact is too small for some reason. This is a detail that will
// need to be addressed at some point but can be fudged for the
// moment.
float scale = (float)((float)ppiPrinterX/(float)ppiScreenX);
double scale = double(ppiPrinterX) / ppiScreenX;
// Now we have to check in case our real page size is reduced
// (e.g. because we're drawing to a print preview memory DC)
@@ -2180,7 +2180,7 @@ bool wxDocPrintout::OnPrintPage(int WXUNUSED(page))
// If printer pageWidth == current DC width, then this doesn't
// change. But w might be the preview bitmap width, so scale down.
float overallScale = scale * (float)(w/(float)pageWidth);
double overallScale = scale * w / pageWidth;
dc->SetUserScale(overallScale, overallScale);
if (m_printoutView)

View File

@@ -443,7 +443,8 @@ void wxGLAPI::glFrustum(GLfloat left, GLfloat right, GLfloat bottom,
#if wxUSE_OPENGL_EMULATION
::glFrustumf(left, right, bottom, top, zNear, zFar);
#else
::glFrustum(left, right, bottom, top, zNear, zFar);
::glFrustum(double(left), double(right),
double(bottom), double(top), double(zNear), double(zFar));
#endif
}

View File

@@ -544,7 +544,7 @@ void wxGraphicsGradientStops::Add(const wxGraphicsGradientStop& stop)
}
}
if ( stop.GetPosition() == 1. )
if ( stop.GetPosition() == 1 )
{
m_stops.insert(m_stops.end() - 1, stop);
}

View File

@@ -1717,13 +1717,13 @@ wxImage::Paste(const wxImage & image, int x, int y,
float source_alpha = alpha_source_data[i] / 255.0f;
float light_left = (alpha_target_data[i] / 255.0f) * (1.0f - source_alpha);
float result_alpha = source_alpha + light_left;
alpha_target_data[i] = (unsigned char)((result_alpha * 255) +0.5);
alpha_target_data[i] = (unsigned char)((result_alpha * 255) + 0.5f);
for (int c = 3 * i; c < 3 * (i + 1); c++)
{
target_data[c] =
(unsigned char)(((source_data[c] * source_alpha +
target_data[c] * light_left) /
result_alpha) + 0.5);
result_alpha) + 0.5f);
}
}
}

View File

@@ -643,8 +643,8 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
if ( tiffRes != RESUNIT_NONE )
{
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, tiffRes);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, (float)xres);
TIFFSetField(tif, TIFFTAG_YRESOLUTION, (float)yres);
TIFFSetField(tif, TIFFTAG_XRESOLUTION, xres);
TIFFSetField(tif, TIFFTAG_YRESOLUTION, yres);
}

View File

@@ -680,9 +680,9 @@ void wxPrintout::FitThisSizeToPaper(const wxSize& imageSize)
GetPageSizePixels(&pw, &ph);
wxCoord w, h;
m_printoutDC->GetSize(&w, &h);
float scaleX = ((float(paperRect.width) * w) / (float(pw) * imageSize.x));
float scaleY = ((float(paperRect.height) * h) / (float(ph) * imageSize.y));
float actualScale = wxMin(scaleX, scaleY);
double scaleX = (double(paperRect.width) * w) / (double(pw) * imageSize.x);
double scaleY = (double(paperRect.height) * h) / (double(ph) * imageSize.y);
double actualScale = wxMin(scaleX, scaleY);
m_printoutDC->SetUserScale(actualScale, actualScale);
m_printoutDC->SetDeviceOrigin(0, 0);
wxRect logicalPaperRect = GetLogicalPaperRect();
@@ -697,9 +697,9 @@ void wxPrintout::FitThisSizeToPage(const wxSize& imageSize)
if (!m_printoutDC) return;
int w, h;
m_printoutDC->GetSize(&w, &h);
float scaleX = float(w) / imageSize.x;
float scaleY = float(h) / imageSize.y;
float actualScale = wxMin(scaleX, scaleY);
double scaleX = double(w) / imageSize.x;
double scaleY = double(h) / imageSize.y;
double actualScale = wxMin(scaleX, scaleY);
m_printoutDC->SetUserScale(actualScale, actualScale);
m_printoutDC->SetDeviceOrigin(0, 0);
}
@@ -725,9 +725,9 @@ void wxPrintout::FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageS
paperRect.height - wxRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
wxCoord w, h;
m_printoutDC->GetSize(&w, &h);
float scaleX = (float(pageMarginsRect.width) * w) / (float(pw) * imageSize.x);
float scaleY = (float(pageMarginsRect.height) * h) / (float(ph) * imageSize.y);
float actualScale = wxMin(scaleX, scaleY);
double scaleX = (double(pageMarginsRect.width) * w) / (double(pw) * imageSize.x);
double scaleY = (double(pageMarginsRect.height) * h) / (double(ph) * imageSize.y);
double actualScale = wxMin(scaleX, scaleY);
m_printoutDC->SetUserScale(actualScale, actualScale);
m_printoutDC->SetDeviceOrigin(0, 0);
wxRect logicalPageMarginsRect = GetLogicalPageMarginsRect(pageSetupData);
@@ -759,8 +759,8 @@ void wxPrintout::MapScreenSizeToPage()
m_printoutDC->GetSize(&w, &h);
int pageSizePixelsX, pageSizePixelsY;
GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY);
float userScaleX = (float(ppiPrinterX) * w) / (float(ppiScreenX) * pageSizePixelsX);
float userScaleY = (float(ppiPrinterY) * h) / (float(ppiScreenY) * pageSizePixelsY);
double userScaleX = (double(ppiPrinterX) * w) / (double(ppiScreenX) * pageSizePixelsX);
double userScaleY = (double(ppiPrinterY) * h) / (double(ppiScreenY) * pageSizePixelsY);
m_printoutDC->SetUserScale(userScaleX, userScaleY);
m_printoutDC->SetDeviceOrigin(0, 0);
}
@@ -785,8 +785,8 @@ void wxPrintout::MapScreenSizeToDevice()
m_printoutDC->GetSize(&w, &h);
int pageSizePixelsX, pageSizePixelsY;
GetPageSizePixels(&pageSizePixelsX, &pageSizePixelsY);
float userScaleX = float(w) / pageSizePixelsX;
float userScaleY = float(h) / pageSizePixelsY;
double userScaleX = double(w) / pageSizePixelsX;
double userScaleY = double(h) / pageSizePixelsY;
m_printoutDC->SetUserScale(userScaleX, userScaleY);
m_printoutDC->SetDeviceOrigin(0, 0);
}
@@ -1919,7 +1919,7 @@ void wxPrintPreviewBase::CalcRects(wxPreviewCanvas *canvas, wxRect& pageRect, wx
int canvasWidth, canvasHeight;
canvas->GetSize(&canvasWidth, &canvasHeight);
float zoomScale = float(m_currentZoom) / 100;
float zoomScale = m_currentZoom / 100.0f;
float screenPrintableWidth = zoomScale * m_pageWidth * m_previewScaleX;
float screenPrintableHeight = zoomScale * m_pageHeight * m_previewScaleY;
@@ -1931,10 +1931,10 @@ void wxPrintPreviewBase::CalcRects(wxPreviewCanvas *canvas, wxRect& pageRect, wx
paperRect.width = wxCoord(scaleX * devicePaperRect.width);
paperRect.height = wxCoord(scaleY * devicePaperRect.height);
paperRect.x = wxCoord((canvasWidth - paperRect.width)/ 2.0);
paperRect.x = (canvasWidth - paperRect.width) / 2;
if (paperRect.x < m_leftMargin)
paperRect.x = m_leftMargin;
paperRect.y = wxCoord((canvasHeight - paperRect.height)/ 2.0);
paperRect.y = (canvasHeight - paperRect.height) / 2;
if (paperRect.y < m_topMargin)
paperRect.y = m_topMargin;

View File

@@ -235,7 +235,7 @@ wxSizerItem::wxSizerItem(wxSizer *sizer,
m_border(border),
m_flag(flag),
m_id(wxID_NONE),
m_ratio(0.0),
m_ratio(0),
m_userData(userData)
{
ASSERT_VALID_SIZER_FLAGS( m_flag );
@@ -423,10 +423,10 @@ bool wxSizerItem::InformFirstDirection(int direction, int size, int availableOth
// the owned window (happens automatically).
if( (m_flag & wxSHAPED) && (m_flag & wxEXPAND) && direction )
{
if( !wxIsNullDouble(m_ratio) )
if ( m_ratio != 0 )
{
wxCHECK_MSG( m_proportion==0, false, wxT("Shaped item, non-zero proportion in wxSizerItem::InformFirstDirection()") );
if( direction==wxHORIZONTAL && !wxIsNullDouble(m_ratio) )
if ( direction == wxHORIZONTAL )
{
// Clip size so that we don't take too much
if( availableOtherDir>=0 && int(size/m_ratio)-m_minSize.y>availableOtherDir )
@@ -456,7 +456,7 @@ wxSize wxSizerItem::CalcMin()
// if we have to preserve aspect ratio _AND_ this is
// the first-time calculation, consider ret to be initial size
if ( (m_flag & wxSHAPED) && wxIsNullDouble(m_ratio) )
if ( (m_flag & wxSHAPED) && m_ratio == 0 )
SetRatio(m_minSize);
}
else if ( IsWindow() )
@@ -2542,7 +2542,7 @@ wxSize wxBoxSizer::CalcMin()
// part, to respect the children proportion. To satisfy the latter
// condition we must find the greatest min-size-to-proportion ratio for all
// elements with non-zero proportion.
float maxMinSizeToProp = 0.;
float maxMinSizeToProp = 0;
for ( wxSizerItemList::const_iterator i = m_children.begin();
i != m_children.end();
++i )

View File

@@ -476,7 +476,7 @@ bool wxVariantDoubleData::Write(wxOutputStream& str) const
bool wxVariantDoubleData::Read(wxInputStream& str)
{
wxTextInputStream s(str);
m_value = (float)s.ReadDouble();
m_value = s.ReadDouble();
return true;
}
#endif // wxUSE_STREAMS

View File

@@ -1170,7 +1170,7 @@ void wxPostScriptDCImpl::SetPSFont()
}
// Select font
float size = (float)m_font.GetPointSize() * GetFontPointSizeAdjustment(DPI);
double size = m_font.GetPointSize() * double(GetFontPointSizeAdjustment(DPI));
buffer.Printf( "%s findfont %f scalefont setfont\n", name.c_str(), size * m_scaleX );
buffer.Replace( ",", "." );
PsPrint( buffer );
@@ -2253,8 +2253,8 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string,
/* JC: calculate UnderlineThickness/UnderlinePosition */
m_underlinePosition = YLOG2DEVREL(int(UnderlinePosition * fontSize)) / 1000.0;
m_underlineThickness = YLOG2DEVREL(int(UnderlineThickness * fontSize)) / 1000.0;
m_underlinePosition = YLOG2DEVREL(int(UnderlinePosition * double(fontSize))) / 1000.0;
m_underlineThickness = YLOG2DEVREL(int(UnderlineThickness * double(fontSize))) / 1000.0;
}
@@ -2290,10 +2290,6 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string,
}
}
double widthSum = sum;
widthSum *= fontSize;
widthSum /= 1000.0F;
/* add descender to height (it is usually a negative value) */
//if (lastDescender != INT_MIN)
//{
@@ -2304,7 +2300,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string,
/* return size values */
if ( x )
*x = (wxCoord)widthSum;
*x = int(sum * fontSize) / 1000;
if ( y )
*y = (wxCoord)height;

View File

@@ -775,7 +775,7 @@ void wxCairoPenBrushBaseData::AddGradientStops(const wxGraphicsGradientStops& st
cairo_pattern_add_color_stop_rgba
(
m_pattern,
stop.GetPosition(),
double(stop.GetPosition()),
col.Red()/255.0,
col.Green()/255.0,
col.Blue()/255.0,
@@ -3015,7 +3015,7 @@ void wxCairoContext::EndLayer()
float opacity = m_layerOpacities.back();
m_layerOpacities.pop_back();
cairo_pop_group_to_source(m_context);
cairo_paint_with_alpha(m_context,opacity);
cairo_paint_with_alpha(m_context, double(opacity));
}
//-----------------------------------------------------------------------------

View File

@@ -106,17 +106,17 @@ bool wxButton::Create(wxWindow *parent,
g_object_ref(m_widget);
float x_alignment = 0.5;
float x_alignment = 0.5f;
if (HasFlag(wxBU_LEFT))
x_alignment = 0.0;
x_alignment = 0;
else if (HasFlag(wxBU_RIGHT))
x_alignment = 1.0;
x_alignment = 1;
float y_alignment = 0.5;
float y_alignment = 0.5f;
if (HasFlag(wxBU_TOP))
y_alignment = 0.0;
y_alignment = 0;
else if (HasFlag(wxBU_BOTTOM))
y_alignment = 1.0;
y_alignment = 1;
#ifdef __WXGTK4__
if (useLabel)

View File

@@ -2120,11 +2120,11 @@ void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
// horizontal alignment:
gfloat xalign = 0.0;
float xalign = 0;
if (align & wxALIGN_RIGHT)
xalign = 1.0;
xalign = 1;
else if (align & wxALIGN_CENTER_HORIZONTAL)
xalign = 0.5;
xalign = 0.5f;
GValue gvalue = G_VALUE_INIT;
g_value_init( &gvalue, G_TYPE_FLOAT );
@@ -2134,11 +2134,11 @@ void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
// vertical alignment:
gfloat yalign = 0.0;
float yalign = 0;
if (align & wxALIGN_BOTTOM)
yalign = 1.0;
yalign = 1;
else if (align & wxALIGN_CENTER_VERTICAL)
yalign = 0.5;
yalign = 0.5f;
GValue gvalue2 = G_VALUE_INIT;
g_value_init( &gvalue2, G_TYPE_FLOAT );
@@ -3392,12 +3392,12 @@ void wxDataViewColumn::SetAlignment( wxAlignment align )
{
GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column);
gfloat xalign = 0.0;
float xalign = 0;
if (align == wxALIGN_RIGHT)
xalign = 1.0;
xalign = 1;
if (align == wxALIGN_CENTER_HORIZONTAL ||
align == wxALIGN_CENTER)
xalign = 0.5;
xalign = 0.5f;
gtk_tree_view_column_set_alignment( column, xalign );
@@ -3409,9 +3409,9 @@ wxAlignment wxDataViewColumn::GetAlignment() const
{
gfloat xalign = gtk_tree_view_column_get_alignment( GTK_TREE_VIEW_COLUMN(m_column) );
if (xalign == 1.0)
if (xalign == 1)
return wxALIGN_RIGHT;
if (xalign == 0.5)
if (xalign == 0.5f)
return wxALIGN_CENTER_HORIZONTAL;
return wxALIGN_LEFT;

View File

@@ -128,14 +128,14 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
g_object_ref(m_widget);
// alignment
float x_alignment = 0.5;
float x_alignment = 0.5f;
if (HasFlag(wxHL_ALIGN_LEFT))
x_alignment = 0.0;
x_alignment = 0;
else if (HasFlag(wxHL_ALIGN_RIGHT))
x_alignment = 1.0;
x_alignment = 1;
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5);
gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5f);
wxGCC_WARNING_RESTORE()
// set to non empty strings both the url and the label

View File

@@ -626,17 +626,17 @@ wxWebViewWebKit::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
void wxWebViewWebKit::ZoomIn()
{
SetWebkitZoom(GetWebkitZoom() + 0.1);
SetWebkitZoom(GetWebkitZoom() + 0.1f);
}
void wxWebViewWebKit::ZoomOut()
{
SetWebkitZoom(GetWebkitZoom() - 0.1);
SetWebkitZoom(GetWebkitZoom() - 0.1f);
}
void wxWebViewWebKit::SetWebkitZoom(float level)
{
webkit_web_view_set_zoom_level(m_web_view, level);
webkit_web_view_set_zoom_level(m_web_view, double(level));
}
float wxWebViewWebKit::GetWebkitZoom() const
@@ -904,19 +904,19 @@ wxWebViewZoom wxWebViewWebKit::GetZoom() const
float zoom = GetWebkitZoom();
// arbitrary way to map float zoom to our common zoom enum
if (zoom <= 0.65)
if (zoom <= 0.65f)
{
return wxWEBVIEW_ZOOM_TINY;
}
if (zoom <= 0.90)
if (zoom <= 0.90f)
{
return wxWEBVIEW_ZOOM_SMALL;
}
if (zoom <= 1.15)
if (zoom <= 1.15f)
{
return wxWEBVIEW_ZOOM_MEDIUM;
}
if (zoom <= 1.45)
if (zoom <= 1.45f)
{
return wxWEBVIEW_ZOOM_LARGE;
}

View File

@@ -556,7 +556,7 @@ void wxHtmlTableCell::Layout(int w)
{
// Assign with, make sure not to drop below minWidth
if (maxWidth)
m_ColsInfo[i].pixwidth = (int)(wpix * (m_ColsInfo[i].maxWidth / (float)maxWidth) + 0.5);
m_ColsInfo[i].pixwidth = (int)(wpix * (m_ColsInfo[i].maxWidth / (float)maxWidth) + 0.5f);
else
m_ColsInfo[i].pixwidth = wpix / j;
@@ -568,13 +568,14 @@ void wxHtmlTableCell::Layout(int w)
if (!m_ColsInfo[r].width)
minRequired += m_ColsInfo[r].minWidth;
}
const int pixwidthPrev = m_ColsInfo[i].pixwidth;
m_ColsInfo[i].pixwidth = wxMax(wxMin(wpix - minRequired, m_ColsInfo[i].pixwidth), m_ColsInfo[i].minWidth);
if (maxWidth)
{
if (m_ColsInfo[i].pixwidth > (wpix * (m_ColsInfo[i].maxWidth / (float)maxWidth) + 0.5))
if (m_ColsInfo[i].pixwidth > pixwidthPrev)
{
int diff = (int)(m_ColsInfo[i].pixwidth - (wpix * m_ColsInfo[i].maxWidth / (float)maxWidth + 0.5));
int diff = m_ColsInfo[i].pixwidth - pixwidthPrev;
maxWidth += diff - m_ColsInfo[i].maxWidth;
}
else

View File

@@ -712,7 +712,7 @@ wxGDIPlusPenBrushBaseData::SetGradientStops(T *brush,
wxGraphicsGradientStop stop = stops.Item(numStops - i - 1);
colors[i] = wxColourToColor(stop.GetColour());
positions[i] = 1.0 - stop.GetPosition();
positions[i] = 1 - stop.GetPosition();
}
}
else
@@ -1147,7 +1147,7 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
REAL fontSize = !dpi.y
? REAL(font.GetPixelSize().GetHeight())
: REAL(font.GetFractionalPointSize()) * dpi.y / 72.0f;
: REAL(font.GetFractionalPointSize() * dpi.y / 72);
Init(font.GetFaceName(), fontSize, style, col);
}
@@ -2433,7 +2433,7 @@ wxGDIPlusPrintingContext::wxGDIPlusPrintingContext( wxGraphicsRenderer* renderer
// instead. Note that calling SetPageScale() does not have effect on
// non-printing DCs (that is, any other than wxPrinterDC or
// wxEnhMetaFileDC).
REAL dpiRatio = 100.0 / context->GetDpiY();
REAL dpiRatio = 100 / context->GetDpiY();
context->SetPageScale(dpiRatio);
}

View File

@@ -3114,7 +3114,7 @@ wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, c
FLOAT fontSize = !dpi.y
? FLOAT(font.GetPixelSize().GetHeight())
: FLOAT(font.GetFractionalPointSize()) * dpi.y / 72.0f;
: FLOAT(font.GetFractionalPointSize() * dpi.y / 72);
hr = wxDWriteFactory()->CreateTextFormat(
name,

View File

@@ -283,21 +283,21 @@ void wxMetafileDCImpl::SetMapMode(wxMappingMode mode)
// int mm_width = 0;
// int mm_height = 0;
float mm2pixelsX = 10.0;
float mm2pixelsY = 10.0;
const double mm2pixelsX = 10;
const double mm2pixelsY = 10;
switch (mode)
{
case wxMM_TWIPS:
{
m_logicalScaleX = (float)(twips2mm * mm2pixelsX);
m_logicalScaleY = (float)(twips2mm * mm2pixelsY);
m_logicalScaleX = twips2mm * mm2pixelsX;
m_logicalScaleY = twips2mm * mm2pixelsY;
break;
}
case wxMM_POINTS:
{
m_logicalScaleX = (float)(pt2mm * mm2pixelsX);
m_logicalScaleY = (float)(pt2mm * mm2pixelsY);
m_logicalScaleX = pt2mm * mm2pixelsX;
m_logicalScaleY = pt2mm * mm2pixelsY;
break;
}
case wxMM_METRIC:
@@ -308,8 +308,8 @@ void wxMetafileDCImpl::SetMapMode(wxMappingMode mode)
}
case wxMM_LOMETRIC:
{
m_logicalScaleX = (float)(mm2pixelsX/10.0);
m_logicalScaleY = (float)(mm2pixelsY/10.0);
m_logicalScaleX = mm2pixelsX / 10;
m_logicalScaleY = mm2pixelsY / 10;
break;
}
default:

View File

@@ -4887,7 +4887,7 @@ static void ScaleCoordIfSet(int& coord, float scaleFactor)
if ( coord != wxDefaultCoord )
{
const float coordScaled = coord * scaleFactor;
coord = scaleFactor > 1.0 ? ceil(coordScaled) : floor(coordScaled);
coord = int(scaleFactor > 1 ? std::ceil(coordScaled) : std::floor(coordScaled));
}
}

View File

@@ -978,12 +978,14 @@ bool wxNativeFontInfo::FromString(const wxString& s)
token = tokenizer.GetNextToken();
if ( !token.ToCDouble(&d) )
return false;
if ( d < 0 || d > FLT_MAX )
if ( d < 0 )
return false;
#ifdef __LP64__
// CGFloat is just double in this case.
m_ctSize = d;
#else // !__LP64__
if ( d > FLT_MAX )
return false;
m_ctSize = static_cast<CGFloat>(d);
#endif // __LP64__/!__LP64__

View File

@@ -684,7 +684,7 @@ wxMacCoreGraphicsPenBrushDataBase::CreateGradientFunction(const wxGraphicsGradie
{
const wxGraphicsGradientStop stop = stops.Item(i);
m_gradientComponents->comps[i].pos = stop.GetPosition();
m_gradientComponents->comps[i].pos = CGFloat(stop.GetPosition());
const wxColour col = stop.GetColour();
m_gradientComponents->comps[i].red = (CGFloat) (col.Red() / 255.0);

View File

@@ -224,7 +224,7 @@ unsigned wxDisplayFactoryMacOSX::GetCount()
int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p)
{
CGPoint thePoint = {(float)p.x, (float)p.y};
CGPoint thePoint = { CGFloat(p.x), CGFloat(p.y) };
CGDirectDisplayID theID;
CGDisplayCount theCount;
CGDisplayErr err = CGGetDisplaysWithPoint(thePoint, 1, &theID, &theCount);

View File

@@ -231,8 +231,8 @@ void wxRibbonAUIArtProvider::SetColourScheme(
wxRibbonHSLColour tertiary_hsl(tertiary);
// Map primary & secondary luminance from [0, 1] to [0.15, 0.85]
primary_hsl.luminance = float(cos(primary_hsl.luminance * M_PI) * -0.35 + 0.5);
secondary_hsl.luminance = float(cos(secondary_hsl.luminance * M_PI) * -0.35 + 0.5);
primary_hsl.luminance = std::cos(primary_hsl.luminance * float(M_PI)) * -0.35f + 0.5f;
secondary_hsl.luminance = std::cos(secondary_hsl.luminance * float(M_PI)) * -0.35f + 0.5f;
// TODO: Remove next line once this provider stops piggybacking MSW
wxRibbonMSWArtProvider::SetColourScheme(primary, secondary, tertiary);

View File

@@ -130,12 +130,12 @@ wxRibbonHSLColour::wxRibbonHSLColour(const wxColour& col)
if (Min == Max)
{
// colour is a shade of grey
hue = 0.0;
saturation = 0.0;
hue = 0;
saturation = 0;
}
else
{
if(luminance <= 0.5)
if (luminance <= 0.5f)
saturation = (Max - Min) / (Max + Min);
else
saturation = (Max - Min) / (2.0f - (Max + Min));
@@ -143,7 +143,7 @@ wxRibbonHSLColour::wxRibbonHSLColour(const wxColour& col)
if(Max == red)
{
hue = 60.0f * (green - blue) / (Max - Min);
if(hue < 0.0)
if (hue < 0)
hue += 360.0f;
}
else if(Max == green)
@@ -164,56 +164,56 @@ wxColour wxRibbonHSLColour::ToRGB() const
float _hue = (hue - float(floor(hue / 360.0f)) * 360.0f);
float _saturation = saturation;
float _luminance = luminance;
if(_saturation > 1.0) _saturation = 1.0;
if(_saturation < 0.0) _saturation = 0.0;
if(_luminance > 1.0) _luminance = 1.0;
if(_luminance < 0.0) _luminance = 0.0;
if (_saturation > 1) _saturation = 1;
if (_saturation < 0) _saturation = 0;
if (_luminance > 1) _luminance = 1;
if (_luminance < 0) _luminance = 0;
float red, blue, green;
if(_saturation == 0.0)
if (_saturation == 0)
{
// colour is a shade of grey
red = blue = green = _luminance;
}
else
{
float tmp2 = (_luminance < 0.5)
float tmp2 = (_luminance < 0.5f)
? _luminance * (1.0f + _saturation)
: (_luminance + _saturation) - (_luminance * _saturation);
float tmp1 = 2.0f * _luminance - tmp2;
float tmp3R = _hue + 120.0f;
if(tmp3R > 360.0)
if (tmp3R > 360)
tmp3R -= 360.0f;
if(tmp3R < 60.0)
if (tmp3R < 60)
red = tmp1 + (tmp2 - tmp1) * tmp3R / 60.0f;
else if(tmp3R < 180.0)
else if (tmp3R < 180)
red = tmp2;
else if(tmp3R < 240.0)
else if (tmp3R < 240)
red = tmp1 + (tmp2 - tmp1) * (240.0f - tmp3R) / 60.0f;
else
red = tmp1;
float tmp3G = _hue;
if(tmp3G > 360.0)
if (tmp3G > 360)
tmp3G -= 360.0f;
if(tmp3G < 60.0)
if (tmp3G < 60)
green = tmp1 + (tmp2 - tmp1) * tmp3G / 60.0f;
else if(tmp3G < 180.0)
else if (tmp3G < 180)
green = tmp2;
else if(tmp3G < 240.0)
else if (tmp3G < 240)
green = tmp1 + (tmp2 - tmp1) * (240.0f - tmp3G) / 60.0f;
else
green = tmp1;
float tmp3B = _hue + 240.0f;
if(tmp3B > 360.0)
if (tmp3B > 360)
tmp3B -= 360.0f;
if(tmp3B < 60.0)
if (tmp3B < 60)
blue = tmp1 + (tmp2 - tmp1) * tmp3B / 60.0f;
else if(tmp3B < 180.0)
else if (tmp3B < 180)
blue = tmp2;
else if(tmp3B < 240.0)
else if (tmp3B < 240)
blue = tmp1 + (tmp2 - tmp1) * (240.0f - tmp3B) / 60.0f;
else
blue = tmp1;

View File

@@ -333,17 +333,17 @@ void wxRibbonMSWArtProvider::SetColourScheme(
// Map primary saturation from [0, 1] to [.25, .75]
bool primary_is_gray = false;
static const double gray_saturation_threshold = 0.01;
static const float gray_saturation_threshold = 0.01f;
if(primary_hsl.saturation <= gray_saturation_threshold)
primary_is_gray = true;
else
{
primary_hsl.saturation = float(cos(primary_hsl.saturation * M_PI)
* -0.25 + 0.5);
primary_hsl.saturation = std::cos(primary_hsl.saturation * float(M_PI))
* -0.25f + 0.5f;
}
// Map primary luminance from [0, 1] to [.23, .83]
primary_hsl.luminance = float(cos(primary_hsl.luminance * M_PI) * -0.3 + 0.53);
primary_hsl.luminance = std::cos(primary_hsl.luminance * float(M_PI)) * -0.3f + 0.53f;
// Map secondary saturation from [0, 1] to [0.16, 0.84]
bool secondary_is_gray = false;
@@ -351,12 +351,12 @@ void wxRibbonMSWArtProvider::SetColourScheme(
secondary_is_gray = true;
else
{
secondary_hsl.saturation = float(cos(secondary_hsl.saturation * M_PI)
* -0.34 + 0.5);
secondary_hsl.saturation = std::cos(secondary_hsl.saturation * float(M_PI))
* -0.34f + 0.5f;
}
// Map secondary luminance from [0, 1] to [0.1, 0.9]
secondary_hsl.luminance = float(cos(secondary_hsl.luminance * M_PI) * -0.4 + 0.5);
secondary_hsl.luminance = std::cos(secondary_hsl.luminance * float(M_PI)) * -0.4f + 0.5f;
#define LikePrimary(h, s, l) \
primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \

View File

@@ -691,11 +691,11 @@ bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret
}
else if (unit == wxTEXT_ATTR_UNITS_TENTHS_MM)
{
float value = 0.0;
float value = 0;
wxSscanf(str.c_str(), wxT("%f"), &value);
// Convert from cm
// Do this in two steps, since using one step causes strange rounding error for VS 2010 at least.
float v = (value * 100.0);
float v = value * 100;
ret = (int) (v);
return true;
}
@@ -706,9 +706,9 @@ bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret
}
else if (unit == wxTEXT_ATTR_UNITS_HUNDREDTHS_POINT)
{
float value = 0.0;
float value = 0;
wxSscanf(str.c_str(), wxT("%f"), &value);
float v = (value * 100.0);
float v = value * 100;
ret = (int) (v);
}
else if (unit == wxTEXT_ATTR_UNITS_POINTS)

View File

@@ -331,7 +331,7 @@ void wxRichTextPrintout::CalculateScaling(wxDC* dc, wxRect& textRect, wxRect& he
// This scales the DC so that the printout roughly represents the
// the screen scaling.
float scale = (float)((float)ppiPrinterX/(float)ppiScreenX);
const double scale = double(ppiPrinterX) / ppiScreenX;
// Now we have to check in case our real page size is reduced
// (e.g. because we're drawing to a print preview memory DC)
@@ -342,13 +342,13 @@ void wxRichTextPrintout::CalculateScaling(wxDC* dc, wxRect& textRect, wxRect& he
// If printer pageWidth == current DC width, then this doesn't
// change. But w might be the preview bitmap width, so scale down.
float previewScale = (float)(w/(float)pageWidth);
float overallScale = scale * previewScale;
const double previewScale = double(w) / pageWidth;
const double overallScale = scale * previewScale;
// The dimensions used for indentation etc. have to be unscaled
// during printing to be correct when scaling is applied.
// Also, correct the conversions in wxRTC using DC instead of print DC.
m_richTextBuffer->SetScale(scale * float(dc->GetPPI().x)/float(ppiPrinterX));
m_richTextBuffer->SetScale(scale * dc->GetPPI().x / ppiPrinterX);
// Calculate margins
int marginLeft = wxRichTextObject::ConvertTenthsMMToPixels(ppiPrinterX, m_marginLeft);

View File

@@ -67,7 +67,7 @@ bool wxSpinButtonXmlHandler::CanHandle(wxXmlNode *node)
#include "wx/spinctrl.h"
static const float DEFAULT_INC = 1.;
static const float DEFAULT_INC = 1;
static void AddSpinCtrlStyles(wxXmlResourceHandler& handler)
{
@@ -134,10 +134,10 @@ wxObject *wxSpinCtrlDoubleXmlHandler::DoCreateResource()
GetText(wxS("value")),
GetPosition(), GetSize(),
GetStyle(wxS("style"), wxSP_ARROW_KEYS),
GetFloat(wxS("min"), (float)DEFAULT_MIN),
GetFloat(wxS("max"), (float)DEFAULT_MAX),
GetFloat(wxS("value"), (float)DEFAULT_VALUE),
GetFloat(wxS("inc"), DEFAULT_INC),
double(GetFloat(wxS("min"), DEFAULT_MIN)),
double(GetFloat(wxS("max"), DEFAULT_MAX)),
double(GetFloat(wxS("value"), DEFAULT_VALUE)),
double(GetFloat(wxS("inc"), DEFAULT_INC)),
GetName());
SetupWindow(control);

View File

@@ -55,11 +55,11 @@ wxObject *wxSplitterWindowXmlHandler::DoCreateResource()
long sashpos = GetDimension(wxT("sashpos"), 0);
long minpanesize = GetDimension(wxT("minsize"), -1);
float gravity = GetFloat(wxT("gravity"), 0.0);
float gravity = GetFloat(wxS("gravity"));
if (minpanesize != -1)
splitter->SetMinimumPaneSize(minpanesize);
if (gravity != 0.0)
splitter->SetSashGravity(gravity);
if (gravity != 0)
splitter->SetSashGravity(double(gravity));
wxWindow *win1 = NULL, *win2 = NULL;
wxXmlNode *n = m_node->GetChildren();

View File

@@ -1634,7 +1634,7 @@ float wxXmlResourceHandlerImpl::GetFloat(const wxString& param, float defaultv)
// strings in XRC always use C locale so make sure to use the
// locale-independent wxString::ToCDouble() and not ToDouble() which uses
// the current locale with a potentially different decimal point character
double value = defaultv;
double value = double(defaultv);
if (!str.empty())
{
if (!str.ToCDouble(&value))
@@ -2461,7 +2461,7 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
{
if (pointSize > 0)
{
font.SetFractionalPointSize(pointSize);
font.SetFractionalPointSize(double(pointSize));
if (HasParam(wxT("relativesize")))
{
ReportParamError
@@ -2492,7 +2492,7 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
}
else // not based on system font
{
font = wxFontInfo(pointSize)
font = wxFontInfo(double(pointSize))
.FaceName(facename)
.Family(ifamily)
.Style(istyle)