Permalink
Browse files

fix ALL the warnings

mostly just using more size_t. Also do some formatting around if statements
  • Loading branch information...
jacob1 committed Jan 17, 2015
1 parent efd69b2 commit ace9e36cc61d46a4ed415352af91f6819e9feafd
@@ -23,7 +23,7 @@ ContextMenu::ContextMenu(Component * source):
void ContextMenu::Show(ui::Point position)
{
for(int i = 0; i < buttons.size(); i++)
for (size_t i = 0; i < buttons.size(); i++)
{
RemoveComponent(buttons[i]);
delete buttons[i];
@@ -40,7 +40,7 @@ void ContextMenu::Show(ui::Point position)
Position = position;
int currentY = 1;
for(int i = 0; i < items.size(); i++)
for (size_t i = 0; i < items.size(); i++)
{
Button * tempButton = new Button(Point(1, currentY), Point(Size.X-2, 16), items[i].Text);
tempButton->Appearance = Appearance;
@@ -69,9 +69,9 @@ void ContextMenu::OnMouseDown(int x, int y, unsigned button)
void ContextMenu::SetItem(int id, std::string text)
{
for(int i = 0; i < items.size(); i++)
for (size_t i = 0; i < items.size(); i++)
{
if(items[i].ID == id)
if (items[i].ID == id)
{
items[i].Text = text;
break;
@@ -81,9 +81,9 @@ void ContextMenu::SetItem(int id, std::string text)
void ContextMenu::RemoveItem(int id)
{
for(int i = 0; i < items.size(); i++)
for (size_t i = 0; i < items.size(); i++)
{
if(items[i].ID == id)
if (items[i].ID == id)
{
items.erase(items.begin()+i);
break;
@@ -32,11 +32,11 @@ class DropDownWindow: public ui::Window {
appearance(dropDown->Appearance)
{
int currentY = 1;
for(int i = 0; i < dropDown->options.size(); i++)
for (size_t i = 0; i < dropDown->options.size(); i++)
{
Button * tempButton = new Button(Point(1, currentY), Point(Size.X-2, 16), dropDown->options[i].first);
tempButton->Appearance = appearance;
if(i)
if (i)
tempButton->Appearance.Border = ui::Border(0, 1, 1, 1);
tempButton->SetActionCallback(new ItemSelectedAction(this, dropDown->options[i].first));
AddComponent(tempButton);
@@ -51,10 +51,10 @@ class DropDownWindow: public ui::Window {
void setOption(std::string option)
{
dropDown->SetOption(option);
if(dropDown->callback)
if (dropDown->callback)
{
int optionIndex = 0;
for(optionIndex = 0; optionIndex < dropDown->options.size(); optionIndex++)
size_t optionIndex = 0;
for (optionIndex = 0; optionIndex < dropDown->options.size(); optionIndex++)
{
if(option == dropDown->options[optionIndex].first)
break;
@@ -138,9 +138,9 @@ void DropDown::OnMouseLeave(int x, int y)
void DropDown::SetOption(std::string option)
{
for(int i = 0; i < options.size(); i++)
for (size_t i = 0; i < options.size(); i++)
{
if(options[i].first == option)
if (options[i].first == option)
{
optionIndex = i;
TextPosition(options[optionIndex].first);
@@ -150,9 +150,9 @@ void DropDown::OnMouseLeave(int x, int y)
}
void DropDown::SetOption(int option)
{
for(int i = 0; i < options.size(); i++)
for (size_t i = 0; i < options.size(); i++)
{
if(options[i].second == option)
if (options[i].second == option)
{
optionIndex = i;
TextPosition(options[optionIndex].first);
@@ -162,21 +162,21 @@ void DropDown::OnMouseLeave(int x, int y)
}
void DropDown::AddOption(std::pair<std::string, int> option)
{
for(int i = 0; i < options.size(); i++)
for (size_t i = 0; i < options.size(); i++)
{
if(options[i] == option)
if (options[i] == option)
return;
}
options.push_back(option);
}
void DropDown::RemoveOption(std::string option)
{
start:
for(int i = 0; i < options.size(); i++)
for (size_t i = 0; i < options.size(); i++)
{
if(options[i].first == option)
if (options[i].first == option)
{
if(i == optionIndex)
if ((int)i == optionIndex)
optionIndex = -1;
options.erase(options.begin()+i);
goto start;
@@ -69,7 +69,7 @@ void Label::AutoHeight()
void Label::updateMultiline()
{
int lines = 1;
if(text.length()>0)
if (text.length()>0)
{
char * rawText = new char[text.length()+1];
std::copy(text.begin(), text.end(), rawText);
@@ -81,7 +81,7 @@ void Label::updateMultiline()
int wordWidth = 0;
int lineWidth = 0;
char * wordStart = NULL;
while(c = rawText[charIndex++])
while ((c = rawText[charIndex++]))
{
switch(c)
{
@@ -98,19 +98,19 @@ void Label::updateMultiline()
wordWidth += Graphics::CharWidth(c);
break;
}
if(pc == ' ')
if (pc == ' ')
{
wordStart = &rawText[charIndex-2];
}
if ((c != ' ' || pc == ' ') && lineWidth + wordWidth >= Size.X-(Appearance.Margin.Left+Appearance.Margin.Right))
{
if(wordStart && *wordStart)
if (wordStart && *wordStart)
{
*wordStart = '\n';
if (lineWidth != 0)
lineWidth = wordWidth;
}
else if(!wordStart)
else if (!wordStart)
{
rawText[charIndex-1] = '\n';
lineWidth = 0;
@@ -121,7 +121,7 @@ void Label::updateMultiline()
}
pc = c;
}
if(autoHeight)
if (autoHeight)
{
Size.Y = lines*12;
}
@@ -162,7 +162,7 @@ void Label::updateMultiline()
}
else
{
if(autoHeight)
if (autoHeight)
{
Size.Y = 12;
}
@@ -280,10 +280,10 @@ void Label::updateSelection()
{
std::string currentText;
if(selectionIndex0 < 0) selectionIndex0 = 0;
if(selectionIndex0 > text.length()) selectionIndex0 = text.length();
if(selectionIndex1 < 0) selectionIndex1 = 0;
if(selectionIndex1 > text.length()) selectionIndex1 = text.length();
if (selectionIndex0 < 0) selectionIndex0 = 0;
if (selectionIndex0 > (int)text.length()) selectionIndex0 = text.length();
if (selectionIndex1 < 0) selectionIndex1 = 0;
if (selectionIndex1 > (int)text.length()) selectionIndex1 = text.length();
if(selectionIndex0 == -1 || selectionIndex1 == -1)
{
@@ -75,9 +75,9 @@ Component* Panel::GetChild(unsigned idx)
void Panel::RemoveChild(Component* c)
{
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(children[i] == c)
if (children[i] == c)
{
//remove child from parent. Does not free memory
children.erase(children.begin() + i);
@@ -114,13 +114,13 @@ void Panel::Draw(const Point& screenPos)
#endif
// attempt to draw all children
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
// the component must be visible
if(children[i]->Visible)
if (children[i]->Visible)
{
//check if the component is in the screen, draw if it is
if( children[i]->Position.X + ViewportPosition.X + children[i]->Size.X >= 0 &&
if (children[i]->Position.X + ViewportPosition.X + children[i]->Size.X >= 0 &&
children[i]->Position.Y + ViewportPosition.Y + children[i]->Size.Y >= 0 &&
children[i]->Position.X + ViewportPosition.X < ui::Engine::Ref().GetWidth() &&
children[i]->Position.Y + ViewportPosition.Y < ui::Engine::Ref().GetHeight() )
@@ -222,7 +222,7 @@ void Panel::OnMouseClick(int localx, int localy, unsigned button)
void Panel::OnMouseDown(int x, int y, unsigned button)
{
XOnMouseDown(x, y, button);
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(!children[i]->Locked)
children[i]->OnMouseDown(x, y, button);
@@ -232,9 +232,9 @@ void Panel::OnMouseDown(int x, int y, unsigned button)
void Panel::OnMouseHover(int localx, int localy)
{
// check if hovering on children
for(int i = children.size() - 1; i >= 0; --i)
for (int i = children.size() - 1; i >= 0; --i)
{
if(!children[i]->Locked)
if (!children[i]->Locked)
{
if( localx >= children[i]->Position.X &&
localy >= children[i]->Position.Y &&
@@ -254,7 +254,7 @@ void Panel::OnMouseHover(int localx, int localy)
void Panel::OnMouseMoved(int localx, int localy, int dx, int dy)
{
XOnMouseMoved(localx, localy, dx, dy);
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(!children[i]->Locked)
children[i]->OnMouseMoved(localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y, dx, dy);
@@ -264,9 +264,9 @@ void Panel::OnMouseMoved(int localx, int localy, int dx, int dy)
void Panel::OnMouseMovedInside(int localx, int localy, int dx, int dy)
{
mouseInside = true;
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(!children[i]->Locked)
if (!children[i]->Locked)
{
Point local (localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y)
, prevlocal (local.X - dx, local.Y - dy);
@@ -344,7 +344,7 @@ void Panel::OnMouseUnclick(int localx, int localy, unsigned button)
}
//if a child wasn't clicked, send click to ourself
if(!childunclicked)
if (!childunclicked)
{
XOnMouseUnclick(localx, localy, button);
}
@@ -353,19 +353,19 @@ void Panel::OnMouseUnclick(int localx, int localy, unsigned button)
void Panel::OnMouseUp(int x, int y, unsigned button)
{
XOnMouseUp(x, y, button);
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(!children[i]->Locked)
if (!children[i]->Locked)
children[i]->OnMouseUp(x, y, button);
}
}
void Panel::OnMouseWheel(int localx, int localy, int d)
{
XOnMouseWheel(localx, localy, d);
for(int i = 0; i < children.size(); ++i)
for (size_t i = 0; i < children.size(); ++i)
{
if(!children[i]->Locked)
if (!children[i]->Locked)
children[i]->OnMouseWheel(localx - children[i]->Position.X - ViewportPosition.X, localy - children[i]->Position.Y - ViewportPosition.Y, d);
}
}
@@ -374,13 +374,13 @@ void Panel::OnMouseWheelInside(int localx, int localy, int d)
{
XOnMouseWheelInside(localx, localy, d);
//check if clicked a child
for(int i = children.size()-1; i >= 0 ; --i)
for (int i = children.size()-1; i >= 0 ; --i)
{
//child must be unlocked
if(!children[i]->Locked)
if (!children[i]->Locked)
{
//is mouse inside?
if( localx >= children[i]->Position.X + ViewportPosition.X &&
if (localx >= children[i]->Position.X + ViewportPosition.X &&
localy >= children[i]->Position.Y + ViewportPosition.Y &&
localx < children[i]->Position.X + ViewportPosition.X + children[i]->Size.X &&
localy < children[i]->Position.Y + ViewportPosition.Y + children[i]->Size.Y )
@@ -42,7 +42,7 @@ SaveButton::SaveButton(Point position, Point size, SaveInfo * save):
votes = format::NumberToString<int>(save->GetVotesUp()-save->GetVotesDown());
icon += 0xBB;
for (int j = 1; j < votes.length(); j++)
for (size_t j = 1; j < votes.length(); j++)
icon += 0xBC;
icon += 0xB9;
icon += 0xBA;
@@ -66,7 +66,7 @@ void Slider::OnMouseUp(int x, int y, unsigned button)
void Slider::SetColour(Colour col1, Colour col2)
{
pixel pix[2] = {PIXRGB(col1.Red, col1.Green, col1.Blue), PIXRGB(col2.Red, col2.Green, col2.Blue)};
pixel pix[2] = {(pixel)PIXRGB(col1.Red, col1.Green, col1.Blue), (pixel)PIXRGB(col2.Red, col2.Green, col2.Blue)};
float fl[2] = {0.0f, 1.0f};
if(bgGradient)
free(bgGradient);
Oops, something went wrong.

0 comments on commit ace9e36

Please sign in to comment.