summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-08 22:46:48 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-08 22:46:48 +0300
commit6d4da51f0fdcecc2d4398f60dbca43f499fdbe16 (patch)
treec71c7c6e49ed36a55c6b6a2b1ba70073300634dd /src/gui/widgets
parent4125ac707288a244a7175b755d74dd963e762f56 (diff)
downloadmv-6d4da51f0fdcecc2d4398f60dbca43f499fdbe16.tar.gz
mv-6d4da51f0fdcecc2d4398f60dbca43f499fdbe16.tar.bz2
mv-6d4da51f0fdcecc2d4398f60dbca43f499fdbe16.tar.xz
mv-6d4da51f0fdcecc2d4398f60dbca43f499fdbe16.zip
Fix code style in gui.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/browserbox.cpp4
-rw-r--r--src/gui/widgets/emotepage.cpp4
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp11
-rw-r--r--src/gui/widgets/layout.h29
-rw-r--r--src/gui/widgets/tabbedarea.cpp13
-rw-r--r--src/gui/widgets/tabbedarea.h4
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp3
-rw-r--r--src/gui/widgets/textbox.cpp4
-rw-r--r--src/gui/widgets/textfield.cpp8
11 files changed, 45 insertions, 41 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 2696bcdbc..25b5444fc 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -289,7 +289,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
// discard older rows when a row limit has been set
if (mMaxRows > 0 && !mTextRows.empty())
{
- while (mTextRows.size() > mMaxRows)
+ while (mTextRows.size() > static_cast<size_t>(mMaxRows))
{
mTextRows.pop_front();
int cnt = mTextRowLinksCount.front();
@@ -740,7 +740,7 @@ int BrowserBox::calcHeight()
if (mEmotes)
{
const size_t sz = mEmotes->size();
- if (static_cast<unsigned>(cid) < sz)
+ if (static_cast<size_t>(cid) < sz)
{
Image *const img = mEmotes->get(cid);
if (img)
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index cbdd50cab..68d508a5a 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -129,8 +129,8 @@ int EmotePage::getIndexFromGrid(const int x, const int y) const
if (x < 0 || x > width || y < 0 || y > mDimension.height)
return -1;
const int cols = width / emoteWidth;
- const unsigned int index = (y / emoteHeight) * cols + (x / emoteWidth);
- if (index >= mEmotes->size())
+ const int index = (y / emoteHeight) * cols + (x / emoteWidth);
+ if (index >= static_cast<int>(mEmotes->size()))
return -1;
return index;
}
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index c731e86d8..5331eab42 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -220,7 +220,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &event)
mEmotePopup->setVisible(false);
- if (static_cast<unsigned>(index) < mEmoteImg.size() && mEmoteImg[index])
+ if (static_cast<size_t>(index) < mEmoteImg.size() && mEmoteImg[index])
{
const EmoteSprite *const sprite = mEmoteImg[index];
mEmotePopup->show(viewport->getMouseX(), viewport->getMouseY(),
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index f24be7737..4a944c276 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -145,12 +145,13 @@ namespace
if (!pair1 || !pair2)
return false;
- const int t1 = pair1->mItem->getInfo().getType();
- const int t2 = pair2->mItem->getInfo().getType();
+ const ItemInfo &info1 = pair1->mItem->getInfo();
+ const ItemInfo &info2 = pair2->mItem->getInfo();
+ const ItemType t1 = info1.getType();
+ const ItemType t2 = info2.getType();
if (t1 == t2)
{
- return (pair1->mItem->getInfo().getName()
- < pair2->mItem->getInfo().getName());
+ return (info1.getName() < info2.getName());
}
return t1 < t2;
}
@@ -645,7 +646,7 @@ void ItemContainer::updateMatrix()
return;
delete []mShowMatrix;
- mShowMatrix = new int[mGridRows * mGridColumns];
+ mShowMatrix = new int[static_cast<size_t>(mGridRows * mGridColumns)];
std::vector<ItemIdPair*> sortedItems;
int i = 0;
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 27af0840d..c9092f8bd 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -198,49 +198,52 @@ class LayoutCell
/**
* Sets the horizontal alignment of the cell content.
*/
- LayoutCell &setHAlign(Alignment a)
+ LayoutCell &setHAlign(const Alignment a)
{ mAlign[0] = a; return *this; }
/**
* Sets the vertical alignment of the cell content.
*/
- LayoutCell &setVAlign(Alignment a)
+ LayoutCell &setVAlign(const Alignment a)
{ mAlign[1] = a; return *this; }
/**
* @see LayoutArray::at
*/
- LayoutCell &at(int x, int y) A_WARN_UNUSED
+ LayoutCell &at(const int x, const int y) A_WARN_UNUSED
{ return getArray().at(x, y); }
/**
* @see LayoutArray::place
*/
- LayoutCell &place(Widget *wg, int x, int y, int w = 1, int h = 1)
+ LayoutCell &place(Widget *wg,
+ const int x, const int y,
+ const int w = 1, const int h = 1)
{ return getArray().place(wg, x, y, w, h); }
/**
* @see LayoutArray::matchColWidth
*/
- void matchColWidth(int n1, int n2)
+ void matchColWidth(const int n1, const int n2)
{ getArray().matchColWidth(n1, n2); }
/**
* @see LayoutArray::setColWidth
*/
- void setColWidth(int n, int w)
+ void setColWidth(const int n, const int w)
{ getArray().setColWidth(n, w); }
/**
* @see LayoutArray::setRowHeight
*/
- void setRowHeight(int n, int h)
+ void setRowHeight(const int n, const int h)
{ getArray().setRowHeight(n, h); }
/**
* @see LayoutArray::extend.
*/
- void extend(int x, int y, int w, int h)
+ void extend(const int x, const int y,
+ const int w, const int h)
{ getArray().extend(x, y, w, h); }
/**
@@ -258,10 +261,10 @@ class LayoutCell
int getHeight() const A_WARN_UNUSED
{ return mExtent[1]; }
- void setWidth(int w)
+ void setWidth(const int w)
{ mExtent[0] = w; }
- void setHeight(int h)
+ void setHeight(const int h)
{ mExtent[1] = h; }
enum
@@ -280,8 +283,8 @@ class LayoutCell
{
mExtent[0] = 0;
mExtent[1] = 0;
- mAlign[0] = 0;
- mAlign[1] = 0;
+ mAlign[0] = LEFT;
+ mAlign[1] = LEFT;
mNbFill[0] = 0;
mNbFill[1] = 0;
mSize[0] = 0;
@@ -313,7 +316,7 @@ class LayoutCell
int mHPadding;
int mVPadding;
int mExtent[2];
- int mAlign[2];
+ Alignment mAlign[2];
int mNbFill[2];
int mType;
};
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index cd439a95a..5596bdd21 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -266,7 +266,7 @@ void TabbedArea::addTab(Image *const image, Widget *const widget)
addTab(tab, widget);
}
-bool TabbedArea::isTabSelected(const unsigned int index) const
+bool TabbedArea::isTabSelected(const size_t index) const
{
if (index >= mTabs.size())
return false;
@@ -289,7 +289,7 @@ bool TabbedArea::isTabSelected(const Tab *const tab) const
return mSelectedTab == tab;
}
-void TabbedArea::setSelectedTabByIndex(const unsigned int index)
+void TabbedArea::setSelectedTabByIndex(const size_t index)
{
if (index >= mTabs.size())
return;
@@ -383,14 +383,13 @@ void TabbedArea::mousePressed(MouseEvent &event)
void TabbedArea::setSelectedTab(Tab *const tab)
{
- unsigned int i;
- for (i = 0; i < mTabs.size(); i++)
+ for (size_t i = 0; i < mTabs.size(); i++)
{
if (mTabs[i].first == mSelectedTab)
mWidgetContainer->remove(mTabs[i].second);
}
- for (i = 0; i < mTabs.size(); i++)
+ for (size_t i = 0; i < mTabs.size(); i++)
{
if (mTabs[i].first == tab)
{
@@ -518,7 +517,7 @@ void TabbedArea::updateVisibleTabsWidth()
for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
{
if (mTabs[i].first)
- mVisibleTabsWidth += mTabs[i].first->getWidth();
+ mVisibleTabsWidth += static_cast<int>(mTabs[i].first->getWidth());
}
}
@@ -616,7 +615,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
}
else if (eventId == "shift_right")
{
- if (mTabScrollIndex < mTabs.size() - 1)
+ if (static_cast<size_t>(mTabScrollIndex) < mTabs.size() - 1)
++mTabScrollIndex;
}
adjustTabPositions();
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 578128abf..f28a4a17b 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -142,7 +142,7 @@ class TabbedArea final : public ActionListener,
void addTab(Image *const image, Widget *const widget);
- bool isTabSelected(const unsigned int index) const A_WARN_UNUSED;
+ bool isTabSelected(const size_t index) const A_WARN_UNUSED;
bool isTabSelected(const Tab *const tab) const A_WARN_UNUSED;
@@ -165,7 +165,7 @@ class TabbedArea final : public ActionListener,
void setSelectedTab(Tab *const tab);
- void setSelectedTabByIndex(const unsigned int index);
+ void setSelectedTabByIndex(const size_t index);
int getSelectedTabIndex() const A_WARN_UNUSED;
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 4d2845656..eb7e163f0 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -78,8 +78,8 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
}
else
{
- unsigned sel = config.getIntValue("selectedJoystick");
- if (sel >= mNamesModel->size())
+ unsigned int sel = config.getIntValue("selectedJoystick");
+ if (sel >= static_cast<unsigned int>(mNamesModel->size()))
sel = 0;
mNamesDropDown->setSelected(sel);
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 77a758cb4..613e2c7f0 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -134,7 +134,8 @@ public:
mWidgets.push_back(widget);
DropDown *const choicebox = new DropDown(this, mListModel);
- choicebox->setSelected(player_relations.getRelation(name));
+ choicebox->setSelected(static_cast<int>(
+ player_relations.getRelation(name)));
mWidgets.push_back(choicebox);
}
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index d616ecd0d..c03835a0e 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -457,7 +457,7 @@ void TextBox::draw(Graphics* graphics)
{
// Move the text one pixel so we can have a caret before a letter.
font->drawString(graphics, mTextRows[i], 1,
- static_cast<int>(i * fontHeight));
+ static_cast<int>(i * static_cast<size_t>(fontHeight)));
}
BLOCK_END("TextBox::draw")
}
@@ -626,5 +626,5 @@ void TextBox::adjustSize()
}
setWidth(width + 1);
- setHeight(static_cast<int>(font->getHeight() * mTextRows.size()));
+ setHeight(font->getHeight() * static_cast<int>(mTextRows.size()));
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 342e97ee8..db194419e 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -557,12 +557,12 @@ void TextField::caretDelete()
void TextField::handlePaste()
{
std::string text = getText();
- size_t caretPos = getCaretPosition();
+ size_t caretPos = static_cast<size_t>(getCaretPosition());
if (retrieveBuffer(text, caretPos))
{
setText(text);
- setCaretPosition(static_cast<unsigned>(caretPos));
+ setCaretPosition(static_cast<unsigned int>(caretPos));
}
}
@@ -744,9 +744,9 @@ void TextField::focusLost(const Event &event A_UNUSED)
void TextField::setText(const std::string& text)
{
- const size_t sz = text.size();
+ const unsigned int sz = static_cast<unsigned int>(text.size());
if (sz < mCaretPosition)
- mCaretPosition = static_cast<unsigned int>(sz);
+ mCaretPosition = sz;
mText = text;
}