Fix some harmless MSVC compiler warnings

This fixes warnings C4244 ('=': conversion from 'int' to 'xxx', possible
loss of data) and C4267 (conversion from 'size_t' to 'int', possible
loss of data) from the MSVC compiler (Version 19.29.30136 for x64) when
compiling in 64-bits.

Note that these warnings are disabled in wx/defs.h by default and so
only happen when saving/restoring the warning settings using the
appropriate pragmas before/after including wx headers.

Closes #22462.
This commit is contained in:
Randalphwa
2022-05-26 21:20:29 -07:00
committed by Vadim Zeitlin
parent 1da8377f17
commit 385acccebb
4 changed files with 7 additions and 5 deletions

View File

@@ -86,7 +86,7 @@ protected:
void UpdateSelectedPage(size_t newsel) wxOVERRIDE
{
GetChoiceCtrl()->Select(newsel);
GetChoiceCtrl()->Select(static_cast<int>(newsel));
}
wxBookCtrlEvent* CreatePageChangingEvent() const wxOVERRIDE;

View File

@@ -265,7 +265,7 @@ public:
// -----------------
virtual unsigned int GetCount() const wxOVERRIDE
{ return m_items.GetCount(); }
{ return static_cast<unsigned int>(m_items.GetCount()); }
virtual wxString GetString(unsigned int n) const wxOVERRIDE;

View File

@@ -368,7 +368,8 @@ public:
/**
Constructor taking value and units flag.
*/
wxTextAttrDimension(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; m_flags = units|wxTEXT_ATTR_VALUE_VALID; }
wxTextAttrDimension(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value;
m_flags = static_cast<wxTextAttrDimensionFlags>(units | wxTEXT_ATTR_VALUE_VALID); }
/**
Resets the dimension value and flags.
@@ -426,7 +427,8 @@ public:
/**
Sets the integer value and units.
*/
void SetValue(int value, wxTextAttrUnits units) { m_value = value; m_flags = units | wxTEXT_ATTR_VALUE_VALID; }
void SetValue(int value, wxTextAttrUnits units) { m_value = value;
m_flags = static_cast<wxTextAttrDimensionFlags>(units | wxTEXT_ATTR_VALUE_VALID); }
/**
Sets the dimension.

View File

@@ -178,7 +178,7 @@ public:
/**
Returns the number of items.
*/
int GetCount() const { return m_objects.GetCount(); }
int GetCount() const { return static_cast<int>(m_objects.GetCount()); }
wxRichTextObjectPtrArray m_objects;
wxArrayString m_labels;