Commit 25514589 authored by hybrid's avatar hybrid

Renamed core::round to core::round_ just as for the other replacement...

Renamed core::round to core::round_ just as for the other replacement functions already available in standard headers. Fixed a signed/unsigned warning.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@900 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a4c01959
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
#define floorf(X) floor(X) #define floorf(X) floor(X)
#define powf(X,Y) pow(X,Y) #define powf(X,Y) pow(X,Y)
#define fmodf(X,Y) fmod(X,Y) #define fmodf(X,Y) fmod(X,Y)
#if defined(_IRR_SOLARIS_PLATFORM_)
#define roundf(X) (floor( X + 0.5f ))
#else
#define roundf(X) round(X)
#endif
#endif #endif
namespace irr namespace irr
...@@ -233,7 +238,7 @@ namespace core ...@@ -233,7 +238,7 @@ namespace core
inline f32 round ( f32 x ) inline f32 round_( f32 x )
{ {
return roundf(x); return roundf(x);
} }
...@@ -393,11 +398,11 @@ namespace core ...@@ -393,11 +398,11 @@ namespace core
); );
#else #else
# warn IRRLICHT_FAST_MATH not supported. # warn IRRLICHT_FAST_MATH not supported.
return (s32) round(x); return (s32) round_(x);
#endif #endif
return t; return t;
#else // no fast math #else // no fast math
return (s32) round(x); return (s32) round_(x);
#endif #endif
} }
......
...@@ -24,7 +24,7 @@ namespace gui ...@@ -24,7 +24,7 @@ namespace gui
CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
IGUIElement* parent, s32 id, IGUIElement* parent, s32 id,
core::rect<s32> rectangle, bool getFocus, bool allowFocus) core::rect<s32> rectangle, bool getFocus, bool allowFocus)
: IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1), : IGUIContextMenu(environment, parent, id, rectangle), HighLighted(-1),
ChangeTime(0), EventParent(0), AllowFocus(allowFocus) ChangeTime(0), EventParent(0), AllowFocus(allowFocus)
{ {
#ifdef _DEBUG #ifdef _DEBUG
...@@ -44,7 +44,7 @@ CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment, ...@@ -44,7 +44,7 @@ CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
//! destructor //! destructor
CGUIContextMenu::~CGUIContextMenu() CGUIContextMenu::~CGUIContextMenu()
{ {
for (s32 i=0; i<(s32)Items.size(); ++i) for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu) if (Items[i].SubMenu)
Items[i].SubMenu->drop(); Items[i].SubMenu->drop();
} }
...@@ -84,7 +84,7 @@ s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool has ...@@ -84,7 +84,7 @@ s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool has
//! Adds a sub menu from an element that already exists. //! Adds a sub menu from an element that already exists.
void CGUIContextMenu::setSubMenu(s32 index, CGUIContextMenu* menu) void CGUIContextMenu::setSubMenu(s32 index, CGUIContextMenu* menu)
{ {
if (index >= (s32)Items.size() || index < 0) if ((u32)index >= Items.size())
return; return;
if (Items[index].SubMenu) if (Items[index].SubMenu)
...@@ -117,7 +117,7 @@ void CGUIContextMenu::addSeparator() ...@@ -117,7 +117,7 @@ void CGUIContextMenu::addSeparator()
//! Returns text of the menu item. //! Returns text of the menu item.
const wchar_t* CGUIContextMenu::getItemText(s32 idx) const wchar_t* CGUIContextMenu::getItemText(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return 0; return 0;
return Items[idx].Text.c_str(); return Items[idx].Text.c_str();
...@@ -127,7 +127,7 @@ const wchar_t* CGUIContextMenu::getItemText(s32 idx) ...@@ -127,7 +127,7 @@ const wchar_t* CGUIContextMenu::getItemText(s32 idx)
//! Sets text of the menu item. //! Sets text of the menu item.
void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text) void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return; return;
Items[idx].Text = text; Items[idx].Text = text;
...@@ -138,7 +138,7 @@ void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text) ...@@ -138,7 +138,7 @@ void CGUIContextMenu::setItemText(s32 idx, const wchar_t* text)
//! Returns if a menu item is enabled //! Returns if a menu item is enabled
bool CGUIContextMenu::isItemEnabled(s32 idx) bool CGUIContextMenu::isItemEnabled(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false; return false;
...@@ -151,7 +151,7 @@ bool CGUIContextMenu::isItemEnabled(s32 idx) ...@@ -151,7 +151,7 @@ bool CGUIContextMenu::isItemEnabled(s32 idx)
//! Returns if a menu item is checked //! Returns if a menu item is checked
bool CGUIContextMenu::isItemChecked(s32 idx) bool CGUIContextMenu::isItemChecked(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
{ {
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
return false; return false;
...@@ -165,7 +165,7 @@ bool CGUIContextMenu::isItemChecked(s32 idx) ...@@ -165,7 +165,7 @@ bool CGUIContextMenu::isItemChecked(s32 idx)
//! Sets if the menu item should be enabled. //! Sets if the menu item should be enabled.
void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled) void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return; return;
Items[idx].Enabled = enabled; Items[idx].Enabled = enabled;
...@@ -174,7 +174,7 @@ void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled) ...@@ -174,7 +174,7 @@ void CGUIContextMenu::setItemEnabled(s32 idx, bool enabled)
//! Sets if the menu item should be checked. //! Sets if the menu item should be checked.
void CGUIContextMenu::setItemChecked(s32 idx, bool checked ) void CGUIContextMenu::setItemChecked(s32 idx, bool checked )
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return; return;
Items[idx].Checked = checked; Items[idx].Checked = checked;
...@@ -184,7 +184,7 @@ void CGUIContextMenu::setItemChecked(s32 idx, bool checked ) ...@@ -184,7 +184,7 @@ void CGUIContextMenu::setItemChecked(s32 idx, bool checked )
//! Removes a menu item //! Removes a menu item
void CGUIContextMenu::removeItem(s32 idx) void CGUIContextMenu::removeItem(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return; return;
if (Items[idx].SubMenu) if (Items[idx].SubMenu)
...@@ -201,7 +201,7 @@ void CGUIContextMenu::removeItem(s32 idx) ...@@ -201,7 +201,7 @@ void CGUIContextMenu::removeItem(s32 idx)
//! Removes all menu items //! Removes all menu items
void CGUIContextMenu::removeAllItems() void CGUIContextMenu::removeAllItems()
{ {
for (s32 i=0; i<(s32)Items.size(); ++i) for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu) if (Items[i].SubMenu)
Items[i].SubMenu->drop(); Items[i].SubMenu->drop();
...@@ -269,7 +269,7 @@ void CGUIContextMenu::setVisible(bool visible) ...@@ -269,7 +269,7 @@ void CGUIContextMenu::setVisible(bool visible)
{ {
HighLighted = -1; HighLighted = -1;
ChangeTime = os::Timer::getTime(); ChangeTime = os::Timer::getTime();
for (s32 j=0; j<(s32)Items.size(); ++j) for (u32 j=0; j<Items.size(); ++j)
if (Items[j].SubMenu) if (Items[j].SubMenu)
Items[j].SubMenu->setVisible(false); Items[j].SubMenu->setVisible(false);
...@@ -551,6 +551,7 @@ void CGUIContextMenu::recalculateSize() ...@@ -551,6 +551,7 @@ void CGUIContextMenu::recalculateSize()
// recalculate submenus // recalculate submenus
for (i=0; i<(s32)Items.size(); ++i) for (i=0; i<(s32)Items.size(); ++i)
{
if (Items[i].SubMenu) if (Items[i].SubMenu)
{ {
// move submenu // move submenu
...@@ -561,6 +562,7 @@ void CGUIContextMenu::recalculateSize() ...@@ -561,6 +562,7 @@ void CGUIContextMenu::recalculateSize()
core::rect<s32>(width-5, Items[i].PosY, core::rect<s32>(width-5, Items[i].PosY,
width+w-5, Items[i].PosY+h)); width+w-5, Items[i].PosY+h));
} }
}
} }
...@@ -574,7 +576,7 @@ s32 CGUIContextMenu::getSelectedItem() ...@@ -574,7 +576,7 @@ s32 CGUIContextMenu::getSelectedItem()
//! \return Returns a pointer to the submenu of an item. //! \return Returns a pointer to the submenu of an item.
IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx) IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return 0; return 0;
return Items[idx].SubMenu; return Items[idx].SubMenu;
...@@ -584,7 +586,7 @@ IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx) ...@@ -584,7 +586,7 @@ IGUIContextMenu* CGUIContextMenu::getSubMenu(s32 idx)
//! Returns command id of a menu item //! Returns command id of a menu item
s32 CGUIContextMenu::getItemCommandId(s32 idx) s32 CGUIContextMenu::getItemCommandId(s32 idx)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return -1; return -1;
return Items[idx].CommandId; return Items[idx].CommandId;
...@@ -593,7 +595,7 @@ s32 CGUIContextMenu::getItemCommandId(s32 idx) ...@@ -593,7 +595,7 @@ s32 CGUIContextMenu::getItemCommandId(s32 idx)
//! Sets the command id of a menu item //! Sets the command id of a menu item
void CGUIContextMenu::setItemCommandId(s32 idx, s32 id) void CGUIContextMenu::setItemCommandId(s32 idx, s32 id)
{ {
if (idx < 0 || idx >= (s32)Items.size()) if ((u32)idx >= Items.size())
return; return;
Items[idx].CommandId = id; Items[idx].CommandId = id;
...@@ -603,14 +605,14 @@ void CGUIContextMenu::setItemCommandId(s32 idx, s32 id) ...@@ -603,14 +605,14 @@ void CGUIContextMenu::setItemCommandId(s32 idx, s32 id)
void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0)
{ {
IGUIElement::serializeAttributes(out,options); IGUIElement::serializeAttributes(out,options);
out->addPosition2d ("Position", Pos); out->addPosition2d("Position", Pos);
if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU ) if (Parent->getType() == EGUIET_CONTEXT_MENU || Parent->getType() == EGUIET_MENU )
{ {
IGUIContextMenu* ptr = (IGUIContextMenu*)Parent; IGUIContextMenu* ptr = (IGUIContextMenu*)Parent;
s32 i=0;
// find the position of this item in its parent's list // find the position of this item in its parent's list
for (; i<(s32)ptr->getItemCount() && ptr->getSubMenu(i) != this; ++i); s32 i;
for (i=0; i<ptr->getItemCount() && ptr->getSubMenu(i) != this; ++i);
out->addInt("ParentItem", i); out->addInt("ParentItem", i);
} }
...@@ -620,8 +622,7 @@ void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeRe ...@@ -620,8 +622,7 @@ void CGUIContextMenu::serializeAttributes(io::IAttributes* out, io::SAttributeRe
core::stringc tmp; core::stringc tmp;
s32 i=0; for (u32 i=0; i < Items.size(); ++i)
for (; i < (s32)Items.size(); ++i)
{ {
tmp = "IsSeparator"; tmp += i; tmp = "IsSeparator"; tmp += i;
out->addBool(tmp.c_str(), Items[i].IsSeparator); out->addBool(tmp.c_str(), Items[i].IsSeparator);
...@@ -655,8 +656,7 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR ...@@ -655,8 +656,7 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR
// read the item list // read the item list
s32 count = in->getAttributeAsInt("ItemCount"); s32 count = in->getAttributeAsInt("ItemCount");
s32 i=0; for (s32 i=0; i<count; ++i)
for (; i<(s32)count; ++i)
{ {
core::stringc tmp; core::stringc tmp;
core::stringw txt; core::stringw txt;
...@@ -685,9 +685,7 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR ...@@ -685,9 +685,7 @@ void CGUIContextMenu::deserializeAttributes(io::IAttributes* in, io::SAttributeR
} }
} }
recalculateSize(); recalculateSize();
} }
// because sometimes the element has no parent at click time // because sometimes the element has no parent at click time
...@@ -695,7 +693,7 @@ void CGUIContextMenu::setEventParent(IGUIElement *parent) ...@@ -695,7 +693,7 @@ void CGUIContextMenu::setEventParent(IGUIElement *parent)
{ {
EventParent = parent; EventParent = parent;
for (u32 i=0; i<(s32)Items.size(); ++i) for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu) if (Items[i].SubMenu)
{ {
Items[i].SubMenu->setEventParent(parent); Items[i].SubMenu->setEventParent(parent);
...@@ -704,7 +702,7 @@ void CGUIContextMenu::setEventParent(IGUIElement *parent) ...@@ -704,7 +702,7 @@ void CGUIContextMenu::setEventParent(IGUIElement *parent)
bool CGUIContextMenu::hasOpenSubMenu() bool CGUIContextMenu::hasOpenSubMenu()
{ {
for (s32 i=0; i<(s32)Items.size(); ++i) for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu) if (Items[i].SubMenu)
if ( Items[i].SubMenu->isVisible() ) if ( Items[i].SubMenu->isVisible() )
return true; return true;
...@@ -713,7 +711,7 @@ bool CGUIContextMenu::hasOpenSubMenu() ...@@ -713,7 +711,7 @@ bool CGUIContextMenu::hasOpenSubMenu()
void CGUIContextMenu::closeAllSubMenus() void CGUIContextMenu::closeAllSubMenus()
{ {
for (s32 i=0; i<(s32)Items.size(); ++i) for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu) if (Items[i].SubMenu)
Items[i].SubMenu->setVisible(false); Items[i].SubMenu->setVisible(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment