Avoid -Wdouble-promotion warnings in headers

This commit is contained in:
Paul Cornett
2020-07-20 08:12:02 -07:00
parent 516aed372b
commit de7ab5527b
5 changed files with 13 additions and 11 deletions

View File

@@ -305,7 +305,7 @@ public:
{ return DoWriteLong(key, value); } { return DoWriteLong(key, value); }
bool Write(const wxString& key, float value) bool Write(const wxString& key, float value)
{ return DoWriteDouble(key, value); } { return DoWriteDouble(key, double(value)); }
// Causes ambiguities in under OpenVMS // Causes ambiguities in under OpenVMS
#if !defined( __VMS ) #if !defined( __VMS )

View File

@@ -279,7 +279,7 @@ class wxGraphicsGradientStop
{ {
public: public:
wxGraphicsGradientStop(wxColour col = wxTransparentColour, wxGraphicsGradientStop(wxColour col = wxTransparentColour,
float pos = 0.) float pos = 0.0f)
: m_col(col), : m_col(col),
m_pos(pos) m_pos(pos)
{ {

View File

@@ -146,10 +146,10 @@ private:
*/ */
// No origin or extent // No origin or extent
bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0f);
// Optional origin and extent // Optional origin and extent
bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0f, bool useOriginAndExtent = true);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMetafileDataObject is a specialization of wxDataObject for metafile data // wxMetafileDataObject is a specialization of wxDataObject for metafile data

View File

@@ -122,10 +122,10 @@ private:
// No origin or extent // No origin or extent
#define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable #define wxMakeMetaFilePlaceable wxMakeMetafilePlaceable
bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0); bool WXDLLIMPEXP_CORE wxMakeMetafilePlaceable(const wxString& filename, float scale = 1.0f);
// Optional origin and extent // Optional origin and extent
bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0, bool useOriginAndExtent = true); bool WXDLLIMPEXP_CORE wxMakeMetaFilePlaceable(const wxString& filename, int x1, int y1, int x2, int y2, float scale = 1.0f, bool useOriginAndExtent = true);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMetafileDataObject is a specialization of wxDataObject for metafile data // wxMetafileDataObject is a specialization of wxDataObject for metafile data

View File

@@ -154,7 +154,7 @@ public:
void SetMin(ValueType min) void SetMin(ValueType min)
{ {
this->DoSetMin(min); this->DoSetMin(static_cast<LongestValueType>(min));
} }
ValueType GetMin() const ValueType GetMin() const
@@ -164,7 +164,7 @@ public:
void SetMax(ValueType max) void SetMax(ValueType max)
{ {
this->DoSetMax(max); this->DoSetMax(static_cast<LongestValueType>(max));
} }
ValueType GetMax() const ValueType GetMax() const
@@ -192,7 +192,7 @@ public:
if ( !control ) if ( !control )
return false; return false;
control->SetValue(NormalizeValue(*m_value)); control->SetValue(NormalizeValue(static_cast<LongestValueType>(*m_value)));
} }
return true; return true;
@@ -470,13 +470,15 @@ public:
} }
private: private:
typedef typename Base::LongestValueType LongestValueType;
void DoSetMinMax() void DoSetMinMax()
{ {
// NB: Do not use min(), it's not the smallest representable value for // NB: Do not use min(), it's not the smallest representable value for
// the floating point types but rather the smallest representable // the floating point types but rather the smallest representable
// positive value. // positive value.
this->DoSetMin(-std::numeric_limits<ValueType>::max()); this->DoSetMin(static_cast<LongestValueType>(-std::numeric_limits<ValueType>::max()));
this->DoSetMax( std::numeric_limits<ValueType>::max()); this->DoSetMax(static_cast<LongestValueType>( std::numeric_limits<ValueType>::max()));
} }
}; };