diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:52:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-30 19:52:16 +0300 |
commit | 88c6a0aa757df0ec38bc67f2cf314f8be3efd0ce (patch) | |
tree | b35a28cd317e2895c063749180b98edfe223c032 /src/gui/widgets | |
parent | c24fefa91a1416a4dad7fd97d67cefa51f9eb97c (diff) | |
download | manaplus-88c6a0aa757df0ec38bc67f2cf314f8be3efd0ce.tar.gz manaplus-88c6a0aa757df0ec38bc67f2cf314f8be3efd0ce.tar.bz2 manaplus-88c6a0aa757df0ec38bc67f2cf314f8be3efd0ce.tar.xz manaplus-88c6a0aa757df0ec38bc67f2cf314f8be3efd0ce.zip |
Fix code style in gui.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/characterdisplay.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 28 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/textbox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/window.h | 6 |
8 files changed, 33 insertions, 28 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 4d4a51ca4..2696bcdbc 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -629,7 +629,8 @@ int BrowserBox::calcHeight() const Color col[2] = { getThemeCharColor(c, valid), - getThemeCharColor(c | 0x80, valid) + getThemeCharColor(static_cast<signed char>( + c | 0x80), valid) }; if (c == '>') diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index a5cf2379e..941249560 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -132,7 +132,8 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) if (!name.empty()) { mPopup->show(mouseX, mouseY, name, strprintf(_("Level: %u"), - mCharacter->data.mAttributes[PlayerInfo::LEVEL]), + static_cast<uint32_t>( + mCharacter->data.mAttributes[PlayerInfo::LEVEL])), strprintf(_("Money: %s"), Units::formatCurrency( mCharacter->data.mAttributes[PlayerInfo::MONEY]).c_str())); } diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 7245ddd19..89bcc7485 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -89,14 +89,14 @@ void ExtendedListBox::draw(Graphics *graphics) if (insideWidth < strWidth) { - const int strSize = str.size(); - int divPos = strSize / 2; + const size_t strSize = str.size(); + size_t divPos = strSize / 2; if (divPos > 0 && static_cast<unsigned char>( str[divPos - 1]) >= 0xc0) { divPos --; } - for (int d = divPos; d > 10; d --) + for (size_t d = divPos; d > 10; d --) { if (str[d] == 32) { @@ -116,11 +116,11 @@ void ExtendedListBox::draw(Graphics *graphics) } mHeight = y + height; - const int itemsSz = mListItems.size(); - const int selSz = mSelectedItems.size(); + const size_t itemsSz = mListItems.size(); + const size_t selSz = mSelectedItems.size(); int minY = -1; int maxY = -1; - for (int f = 0; f < selSz; f ++) + for (size_t f = 0; f < selSz; f ++) { const ExtendedListBoxItem &item = mSelectedItems[f]; const int y1 = item.y; @@ -138,7 +138,7 @@ void ExtendedListBox::draw(Graphics *graphics) width - pad2, maxY - minY + height)); } - for (int f = 0; f < itemsSz; ++f) + for (size_t f = 0; f < itemsSz; ++f) { const ExtendedListBoxItem &item = mListItems[f]; const int row1 = item.row; @@ -156,7 +156,7 @@ void ExtendedListBox::draw(Graphics *graphics) graphics->setColorAll(mForegroundColor, mForegroundColor2); - for (int f = 0; f < itemsSz; ++f) + for (size_t f = 0; f < itemsSz; ++f) { const ExtendedListBoxItem &item = mListItems[f]; const int row1 = item.row; @@ -173,7 +173,7 @@ void ExtendedListBox::draw(Graphics *graphics) } } - for (int f = 0; f < selSz; ++f) + for (size_t f = 0; f < selSz; ++f) { const ExtendedListBoxItem &item = mSelectedItems[f]; const int row1 = item.row; @@ -191,7 +191,7 @@ void ExtendedListBox::draw(Graphics *graphics) graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); - for (int f = 0; f < selSz; ++f) + for (size_t f = 0; f < selSz; ++f) { const ExtendedListBoxItem &item = mSelectedItems[f]; const int row1 = item.row; @@ -225,8 +225,8 @@ int ExtendedListBox::getSelectionByMouse(const int y) const return ListBox::getSelectionByMouse(y); const int height = mRowHeight; - const int itemsSz = mListItems.size(); - for (int f = 0; f < itemsSz; f ++) + const size_t itemsSz = mListItems.size(); + for (size_t f = 0; f < itemsSz; f ++) { const ExtendedListBoxItem &item = mListItems[f]; const int y2 = item.y; @@ -234,8 +234,8 @@ int ExtendedListBox::getSelectionByMouse(const int y) const return item.row; } - const int selSz = mSelectedItems.size(); - for (int f = 0; f < selSz; f ++) + const size_t selSz = mSelectedItems.size(); + for (size_t f = 0; f < selSz; f ++) { const ExtendedListBoxItem &item = mSelectedItems[f]; const int y2 = item.y; diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 1a9067378..398ebb7b9 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -45,10 +45,10 @@ class PlayerBox final : public Widget, * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - explicit PlayerBox(Widget2 *const widget, - Being *const being, - const std::string &skin = "", - const std::string &selectedSkin = ""); + PlayerBox(Widget2 *const widget, + Being *const being, + const std::string &skin = "", + const std::string &selectedSkin = ""); explicit PlayerBox(Widget2 *const widget, const std::string &skin = "", diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index afff6dcf9..ba192d4bc 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -38,8 +38,8 @@ class SpellShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - explicit SpellShortcutContainer(Widget2 *const widget, - const unsigned number); + SpellShortcutContainer(Widget2 *const widget, + const unsigned number); A_DELETE_COPY(SpellShortcutContainer) diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index b1849e801..d616ecd0d 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -456,7 +456,8 @@ void TextBox::draw(Graphics* graphics) for (size_t i = 0, sz = mTextRows.size(); i < sz; i++) { // Move the text one pixel so we can have a caret before a letter. - font->drawString(graphics, mTextRows[i], 1, i * fontHeight); + font->drawString(graphics, mTextRows[i], 1, + static_cast<int>(i * fontHeight)); } BLOCK_END("TextBox::draw") } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index f89d2ead2..342e97ee8 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -253,7 +253,7 @@ void TextField::keyPressed(KeyEvent &event) { std::string str = event.getText(); mText.insert(mCaretPosition, str); - mCaretPosition += str.size(); + mCaretPosition += static_cast<unsigned int>(str.size()); event.consume(); fixScroll(); if (mSendAlwaysEvents) @@ -679,7 +679,7 @@ void TextField::fixScroll() void TextField::setCaretPosition(unsigned int position) { - const unsigned int sz = mText.size(); + const unsigned int sz = static_cast<unsigned int>(mText.size()); if (position > sz) mCaretPosition = static_cast<int>(sz); else @@ -746,7 +746,7 @@ void TextField::setText(const std::string& text) { const size_t sz = text.size(); if (sz < mCaretPosition) - mCaretPosition = sz; + mCaretPosition = static_cast<unsigned int>(sz); mText = text; } diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 1795f2843..a14f960cd 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -104,8 +104,10 @@ class Window : public BasicContainer2, * a window will never go below its parent window. * @param skin The location where the window's skin XML can be found. */ - Window(const std::string &caption = "Window", const bool modal = false, - Window *const parent = nullptr, std::string skin = ""); + explicit Window(const std::string &caption = "Window", + const bool modal = false, + Window *const parent = nullptr, + std::string skin = ""); A_DELETE_COPY(Window) |