diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-07 01:53:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-07 01:53:51 +0300 |
commit | 2492b561385859b7ef76fe816a8dc845f0b9bd09 (patch) | |
tree | 62633f8cd7c027c2a8e1bae61264a79394aeb751 /src/gui | |
parent | ce14a018a6f66aa1309ebe71a8217082d83cd0da (diff) | |
download | manaverse-2492b561385859b7ef76fe816a8dc845f0b9bd09.tar.gz manaverse-2492b561385859b7ef76fe816a8dc845f0b9bd09.tar.bz2 manaverse-2492b561385859b7ef76fe816a8dc845f0b9bd09.tar.xz manaverse-2492b561385859b7ef76fe816a8dc845f0b9bd09.zip |
Fix some casts between signed and unsigned in some files.
Diffstat (limited to 'src/gui')
35 files changed, 238 insertions, 174 deletions
diff --git a/src/gui/color.cpp b/src/gui/color.cpp index 85c77f08e..3e82a1210 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -126,9 +126,9 @@ Color Color::operator-(const Color& color) const Color Color::operator*(const float value) const { - Color result(static_cast<int>(static_cast<float>(r) * value), - static_cast<int>(static_cast<float>(g) * value), - static_cast<int>(static_cast<float>(b) * value), + Color result(static_cast<unsigned int>(static_cast<float>(r) * value), + static_cast<unsigned int>(static_cast<float>(g) * value), + static_cast<unsigned int>(static_cast<float>(b) * value), a); result.r = (result.r > 255U ? 255U : result.r); diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h index de35570e2..2a3131fa3 100644 --- a/src/gui/fonts/font.h +++ b/src/gui/fonts/font.h @@ -120,10 +120,10 @@ class Font final void slowLogic(const int rnd) restrict2; - int getCreateCounter() const restrict2 noexcept A_WARN_UNUSED + unsigned int getCreateCounter() const restrict2 noexcept A_WARN_UNUSED { return mCreateCounter; } - int getDeleteCounter() const restrict2 noexcept A_WARN_UNUSED + unsigned int getDeleteCounter() const restrict2 noexcept A_WARN_UNUSED { return mDeleteCounter; } int getStringIndexAt(const std::string &restrict text, @@ -140,8 +140,8 @@ class Font final const int size); TTF_Font *restrict mFont; - unsigned mCreateCounter; - unsigned mDeleteCounter; + unsigned int mCreateCounter; + unsigned int mDeleteCounter; // Word surfaces cache int mCleanTime; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 1aa898a49..f10b386af 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -112,7 +112,7 @@ Gui::Gui() : mFocusHandler(new FocusHandler), mKeyListeners(), mLastMousePressButton(MouseButton::EMPTY), - mLastMousePressTimeStamp(0), + mLastMousePressTimeStamp(0U), mLastMouseX(0), mLastMouseY(0), mClickCount(1), @@ -501,7 +501,7 @@ void Gui::draw() } #endif Image *const mouseCursor = mMouseCursors->get( - static_cast<int>(mCursorType)); + static_cast<size_t>(mCursorType)); if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); @@ -638,7 +638,7 @@ void Gui::handleMouseMoved(const MouseInput &mouseInput) true, true); mClickCount = 1; - mLastMousePressTimeStamp = 0; + mLastMousePressTimeStamp = 0U; mWidgetWithMouseQueue.erase(iter); break; } @@ -741,7 +741,7 @@ void Gui::handleMousePressed(const MouseInput &mouseInput) const int x = mouseInput.getX(); const int y = mouseInput.getY(); const MouseButtonT button = mouseInput.getButton(); - const int timeStamp = mouseInput.getTimeStamp(); + const unsigned int timeStamp = mouseInput.getTimeStamp(); Widget *sourceWidget = getMouseEventSource(x, y); @@ -761,8 +761,9 @@ void Gui::handleMousePressed(const MouseInput &mouseInput) sourceWidget->requestFocus(); } - if (mDoubleClick && timeStamp - mLastMousePressTimeStamp < 250 - && mLastMousePressButton == button) + if (mDoubleClick && + timeStamp - mLastMousePressTimeStamp < 250U && + mLastMousePressButton == button) { mClickCount ++; } @@ -1466,7 +1467,7 @@ int Gui::getMousePressLength() const { if (!mLastMousePressTimeStamp) return 0; - int ticks = SDL_GetTicks(); + unsigned int ticks = SDL_GetTicks(); if (ticks > mLastMousePressTimeStamp) return ticks - mLastMousePressTimeStamp; return mLastMousePressTimeStamp - ticks; diff --git a/src/gui/gui.h b/src/gui/gui.h index 48bfd88b1..deb786b39 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -473,7 +473,7 @@ class Gui final /** * Holds the last mouse press time stamp. */ - int mLastMousePressTimeStamp; + unsigned int mLastMousePressTimeStamp; /** * Holds the last mouse x coordinate. diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp index 7ba88e9a8..88dee3c93 100644 --- a/src/gui/models/colormodel.cpp +++ b/src/gui/models/colormodel.cpp @@ -45,7 +45,7 @@ std::string ColorModel::getElementAt(int i) { if (i >= getNumberOfElements() || i < 0) return "???"; - return mNames[i]; + return mNames[static_cast<size_t>(i)]; } const ColorPair *ColorModel::getColorAt(const int i) const @@ -53,7 +53,7 @@ const ColorPair *ColorModel::getColorAt(const int i) const if (i >= static_cast<int>(mColors.size()) || i < 0) return &mColors[0]; - return &mColors[i]; + return &mColors[static_cast<size_t>(i)]; } void ColorModel::add(const std::string &name, const Color *const color1, diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp index d9b522d2d..ac65c8b21 100644 --- a/src/gui/models/extendednamesmodel.cpp +++ b/src/gui/models/extendednamesmodel.cpp @@ -42,7 +42,7 @@ std::string ExtendedNamesModel::getElementAt(int i) { if (i >= getNumberOfElements() || i < 0) return "???"; - return mNames[i]; + return mNames[static_cast<size_t>(i)]; } const Image *ExtendedNamesModel::getImageAt(int i) @@ -50,7 +50,7 @@ const Image *ExtendedNamesModel::getImageAt(int i) if (i >= static_cast<int>(mImages.size()) || i < 0) return nullptr; - return mImages[i]; + return mImages[static_cast<size_t>(i)]; } void ExtendedNamesModel::clear() diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h index 752bd7ea4..e74dcb69f 100644 --- a/src/gui/models/modelistmodel.h +++ b/src/gui/models/modelistmodel.h @@ -49,7 +49,7 @@ class ModeListModel final : public ListModel * Returns element from container. */ std::string getElementAt(int i) override final - { return mVideoModes[i]; } + { return mVideoModes[static_cast<size_t>(i)]; } /** * Returns the index corresponding to the given video mode. diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp index 468c9989b..a66cea6b2 100644 --- a/src/gui/models/namesmodel.cpp +++ b/src/gui/models/namesmodel.cpp @@ -42,7 +42,7 @@ std::string NamesModel::getElementAt(int i) { if (i >= getNumberOfElements() || i < 0) return "???"; - return mNames[i]; + return mNames[static_cast<size_t>(i)]; } void NamesModel::fillFromArray(const char *const *const arr, std::size_t sz) diff --git a/src/gui/palette.h b/src/gui/palette.h index 11799b7a8..ca5ab08ab 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -73,7 +73,7 @@ class Palette notfinal * @return the color char of the color with the given index */ inline char getColorChar(const int type) const A_WARN_UNUSED - { return mColors[type].ch; } + { return mColors[static_cast<size_t>(type)].ch; } /** * Updates all colors, that are non-static. diff --git a/src/gui/theme.h b/src/gui/theme.h index b8e8338c2..9e9badffa 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -133,7 +133,8 @@ class Theme final : public Palette, * @return the requested color */ inline const Color &getColor(ThemeColorIdT type, - const int alpha = 255) A_WARN_UNUSED + const unsigned int alpha = 255U) + A_WARN_UNUSED { if (static_cast<size_t>(type) >= mColors.size()) { diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 9d3f1f860..49c9fce31 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -162,7 +162,8 @@ class UserPalette final : public Palette, public ListModel * @return the requested color */ inline const Color &getColor(UserColorIdT type, - const int alpha = 255) A_WARN_UNUSED + const unsigned int alpha = 255U) + A_WARN_UNUSED { if (static_cast<size_t>(type) >= mColors.size()) { @@ -204,7 +205,8 @@ class UserPalette final : public Palette, public ListModel A_WARN_UNUSED { Color *const col = &mColors[static_cast<size_t>(type)].color; - col->a = mColors[static_cast<size_t>(type)].delay; + col->a = static_cast<unsigned int>( + mColors[static_cast<size_t>(type)].delay); return *col; } diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index fd14ba9e0..f867518a7 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -312,7 +312,7 @@ void BasicContainer::drawChildren(Graphics *restrict graphics) restrict2 if (widget->mFrameSize > 0) { Rect rec = widget->mDimension; - const int frame = widget->mFrameSize; + const int frame = static_cast<int>(widget->mFrameSize); const int frame2 = frame * 2; rec.x -= frame; rec.y -= frame; @@ -352,7 +352,7 @@ void BasicContainer::safeDrawChildren(Graphics *restrict graphics) restrict2 if (widget->mFrameSize > 0) { Rect rec = widget->mDimension; - const int frame = widget->mFrameSize; + const int frame = static_cast<int>(widget->mFrameSize); const int frame2 = frame * 2; rec.x -= frame; rec.y -= frame; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 9c5dcc77c..2a85748b2 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -99,7 +99,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, mYStart(0), mUpdateTime(-1), mPadding(0), - mNewLinePadding(15), + mNewLinePadding(15U), mItemPadding(0), mDataWidth(0), mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT)), @@ -132,7 +132,8 @@ BrowserBox::BrowserBox(const Widget2 *const widget, if (mSkin) { mPadding = mSkin->getPadding(); - mNewLinePadding = mSkin->getOption("newLinePadding", 15); + mNewLinePadding = static_cast<unsigned int>( + mSkin->getOption("newLinePadding", 15)); mItemPadding = mSkin->getOption("itemPadding"); if (mSkin->getOption("highlightBackground")) mHighMode |= BACKGROUND; @@ -205,7 +206,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) BrowserLink bLink; // Check for links in format "@@link|Caption@@" - const int sz = static_cast<int>(mTextRows.size()); + const unsigned int sz = mTextRows.size(); if (mEnableKeys) { @@ -234,7 +235,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) break; bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2)); bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1)); - bLink.y1 = sz * font->getHeight(); + bLink.y1 = static_cast<int>(sz) * font->getHeight(); bLink.y2 = bLink.y1 + font->getHeight(); if (bLink.caption.empty()) { @@ -310,8 +311,9 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) if (idx2 == std::string::npos) break; - const unsigned int newSize = atoi(newRow.substr( - idx1 + 2, idx2 - idx1 - 2).c_str()); + const unsigned int newSize = static_cast<unsigned int>( + atoi(newRow.substr( + idx1 + 2, idx2 - idx1 - 2).c_str())); std::string str = newRow.substr(0, idx1); while (str.size() < newSize) str.append(" "); @@ -372,30 +374,31 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) unsigned int y = 0; unsigned int nextChar; const char *const hyphen = "~"; - const int hyphenWidth = font->getWidth(hyphen); - unsigned x = 0; + const unsigned int hyphenWidth = static_cast<unsigned int>( + font->getWidth(hyphen)); + unsigned int x = 0; FOR_EACH (TextRowCIter, i, mTextRows) { std::string tempRow = *i; - for (unsigned int j = 0, sz = static_cast<unsigned int>( - tempRow.size()); j < sz; j++) + for (unsigned int j = 0, sz = tempRow.size(); j < sz; j++) { const std::string character = tempRow.substr(j, 1); - x += font->getWidth(character); + x += static_cast<unsigned int>(font->getWidth(character)); nextChar = j + 1; // Wraping between words (at blank spaces) if (nextChar < sz && tempRow.at(nextChar) == ' ') { - int nextSpacePos = static_cast<int>( + unsigned int nextSpacePos = static_cast<unsigned int>( tempRow.find(" ", (nextChar + 1))); if (nextSpacePos <= 0) - nextSpacePos = static_cast<int>(sz) - 1; + nextSpacePos = static_cast<unsigned int>(sz) - 1U; - const unsigned nextWordWidth = font->getWidth( + const unsigned int nextWordWidth = + static_cast<unsigned int>(font->getWidth( tempRow.substr(nextChar, - (nextSpacePos - nextChar))); + (nextSpacePos - nextChar)))); if ((x + nextWordWidth + 10) > static_cast<unsigned>(getWidth())) @@ -415,7 +418,8 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) } } - setHeight(fontHeight * (static_cast<int>(mTextRows.size()) + y)); + setHeight(fontHeight * (static_cast<int>( + static_cast<unsigned int>(mTextRows.size()) + y))); } else { @@ -506,7 +510,7 @@ void BrowserBox::draw(Graphics *graphics) { if ((mHighMode & BACKGROUND)) { - BrowserLink &link = mLinks[mSelectedLink]; + BrowserLink &link = mLinks[static_cast<size_t>(mSelectedLink)]; graphics->setColor(mHighlightColor); graphics->fillRectangle(Rect( link.x1, @@ -517,7 +521,7 @@ void BrowserBox::draw(Graphics *graphics) if ((mHighMode & UNDERLINE)) { - BrowserLink &link = mLinks[mSelectedLink]; + BrowserLink &link = mLinks[static_cast<size_t>(mSelectedLink)]; graphics->setColor(mHyperLinkColor); graphics->drawLine( link.x1, @@ -571,13 +575,13 @@ void BrowserBox::safeDraw(Graphics *graphics) int BrowserBox::calcHeight() { - unsigned int y = mPadding; + unsigned int y = static_cast<unsigned int>(mPadding); int wrappedLines = 0; int moreHeight = 0; int maxWidth = mDimension.width - mPadding; int link = 0; bool bold = false; - unsigned int wWidth = maxWidth; + unsigned int wWidth = static_cast<unsigned int>(maxWidth); if (maxWidth < 0) return 1; @@ -594,7 +598,7 @@ int BrowserBox::calcHeight() FOR_EACH (TextRowCIter, i, mTextRows) { - unsigned int x = mPadding; + unsigned int x = static_cast<unsigned int>(mPadding); const std::string row = *(i); bool wrapped = false; int objects = 0; @@ -603,14 +607,16 @@ int BrowserBox::calcHeight() if (row.find("---", 0) == 0) { const int dashWidth = fontWidthMinus; - for (x = mPadding; x < wWidth; x ++) + for (x = static_cast<unsigned int>(mPadding); x < wWidth; x ++) { - mLineParts.push_back(LinePart(x, y + mItemPadding, + mLineParts.push_back(LinePart(static_cast<int>(x), + static_cast<int>(y) + mItemPadding, selColor[0], selColor[1], "-", false)); - x += dashWidth - 2; + x += static_cast<unsigned int>(static_cast<int>( + dashWidth) - 2); } - y += fontHeight; + y += static_cast<unsigned int>(fontHeight); continue; } else if (mEnableImages && row.find("~~~", 0) == 0) @@ -623,9 +629,10 @@ int BrowserBox::calcHeight() if (img) { img->incRef(); - mLineParts.push_back(LinePart(x, y + mItemPadding, + mLineParts.push_back(LinePart(static_cast<int>(x), + static_cast<int>(y) + mItemPadding, selColor[0], selColor[1], img)); - y += img->getHeight() + 2; + y += static_cast<unsigned int>(img->getHeight() + 2); moreHeight += img->getHeight(); if (img->getWidth() > maxWidth) maxWidth = img->getWidth() + 2; @@ -638,7 +645,7 @@ int BrowserBox::calcHeight() prevColor[1] = selColor[1]; bold = false; - const int xPadding = mNewLinePadding + mPadding; + const int xPadding = static_cast<int>(mNewLinePadding) + mPadding; for (size_t start = 0, end = std::string::npos; start != std::string::npos; @@ -649,8 +656,8 @@ int BrowserBox::calcHeight() // Wrapped line continuation shall be indented if (wrapped) { - y += fontHeight; - x = xPadding; + y += static_cast<unsigned int>(fontHeight); + x = static_cast<unsigned int>(xPadding); wrapped = false; } @@ -758,14 +765,15 @@ int BrowserBox::calcHeight() if (c == '<' && link < static_cast<signed>(mLinks.size())) { - const int size = - font->getWidth(mLinks[link].caption) + 1; + const int size = font->getWidth( + mLinks[static_cast<size_t>(link)].caption) + 1; - BrowserLink &linkRef = mLinks[link]; - linkRef.x1 = x; - linkRef.y1 = y; + BrowserLink &linkRef = mLinks[static_cast<size_t>( + link)]; + linkRef.x1 = static_cast<int>(x); + linkRef.y1 = static_cast<int>(y); linkRef.x2 = linkRef.x1 + size; - linkRef.y2 = y + fontHeight - 1; + linkRef.y2 = static_cast<int>(y) + fontHeight - 1; link++; } @@ -796,11 +804,13 @@ int BrowserBox::calcHeight() const size_t sz = mEmotes->size(); if (static_cast<size_t>(cid) < sz) { - Image *const img = mEmotes->get(cid); + Image *const img = mEmotes->get( + static_cast<size_t>(cid)); if (img) { mLineParts.push_back(LinePart( - x, y + mItemPadding, + static_cast<int>(x), + static_cast<int>(y) + mItemPadding, selColor[0], selColor[1], img)); x += 18; } @@ -834,7 +844,7 @@ int BrowserBox::calcHeight() // Auto wrap mode if (mMode == AUTO_WRAP && wWidth > 0 && width > 0 - && (x + width + 10) > wWidth) + && (x + static_cast<unsigned int>(width) + 10) > wWidth) { bool forced = false; @@ -852,7 +862,7 @@ int BrowserBox::calcHeight() { forced = true; end = row.size(); - x += hyphenWidth; // Account for the wrap-notifier + x += static_cast<unsigned int>(hyphenWidth); continue; } @@ -867,13 +877,16 @@ int BrowserBox::calcHeight() else width = font->getWidth(part); } - while (end > start && width > 0 && (x + width + 10) > wWidth); + while (end > start && + width > 0 && + (x + static_cast<unsigned int>(width) + 10) > wWidth); if (forced) { - x -= hyphenWidth; // Remove the wrap-notifier accounting + x -= static_cast<unsigned int>(hyphenWidth); mLineParts.push_back(LinePart( - wWidth - hyphenWidth, y + mItemPadding, + static_cast<int>(wWidth) - hyphenWidth, + static_cast<int>(y) + mItemPadding, selColor[0], selColor[1], hyphen, bold)); end++; // Skip to the next character } @@ -886,7 +899,8 @@ int BrowserBox::calcHeight() wrappedLines++; } - mLineParts.push_back(LinePart(x, y + mItemPadding, + mLineParts.push_back(LinePart(static_cast<int>(x), + static_cast<int>(y) + mItemPadding, selColor[0], selColor[1], part.c_str(), bold)); if (bold) @@ -897,11 +911,11 @@ int BrowserBox::calcHeight() if (mMode == AUTO_WRAP && (width == 0 && !processed)) break; - x += width; + x += static_cast<unsigned int>(width); if (x > mDataWidth) mDataWidth = x; } - y += fontHeight; + y += static_cast<unsigned int>(fontHeight); } if (static_cast<signed>(wWidth) != maxWidth) setWidth(maxWidth); @@ -988,5 +1002,6 @@ void BrowserBox::selectSelection() return; } - mLinkHandler->handleLink(mLinks[mSelectedLink].link, nullptr); + mLinkHandler->handleLink(mLinks[static_cast<size_t>(mSelectedLink)].link, + nullptr); } diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index ba18aa5e2..7bff334c2 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -193,7 +193,7 @@ class BrowserBox final : public Widget, void setForegroundColorAll(const Color &color1, const Color &color2); - int getDataWidth() const A_WARN_UNUSED + unsigned int getDataWidth() const A_WARN_UNUSED { return mDataWidth; } void moveSelectionUp(); @@ -230,7 +230,7 @@ class BrowserBox final : public Widget, int mYStart; int mUpdateTime; int mPadding; - int mNewLinePadding; + unsigned int mNewLinePadding; int mItemPadding; unsigned int mDataWidth; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 533d30997..97291276b 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -425,7 +425,7 @@ void Button::loadImageSet(const std::string &imageName) return; mImages = new Image*[BUTTON_COUNT]; mImages[0] = nullptr; - for (int f = 0; f < BUTTON_COUNT; f ++) + for (size_t f = 0; f < BUTTON_COUNT; f ++) { Image *const img = mImageSet->get(f); if (img) diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 504ebae70..952b412a2 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -168,7 +168,7 @@ class Button final : public Widget, std::string getDescription() const A_WARN_UNUSED { return mDescription; } - unsigned getClickCount() const A_WARN_UNUSED + int getClickCount() const A_WARN_UNUSED { return mClickCount; } void setTag(int tag) @@ -309,7 +309,7 @@ class Button final : public Widget, */ Graphics::Alignment mAlignment; - unsigned mClickCount; + int mClickCount; /** * Holds the spacing between the border and the caption. diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 6c087663b..078f5bb48 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -36,10 +36,12 @@ ColorPage::ColorPage(const Widget2 *const widget, mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1; mRowHeight = 13; const Font *const font = getFont(); - mRowHeight = font->getHeight() + 2 * mItemPadding; + mRowHeight = static_cast<unsigned int>(font->getHeight() + + 2 * mItemPadding); if (mListModel) { - setHeight(getRowHeight() * mListModel->getNumberOfElements() + setHeight(static_cast<int>(getRowHeight()) * + mListModel->getNumberOfElements() + 2 * mPadding + 20); } } @@ -55,11 +57,11 @@ void ColorPage::draw(Graphics *graphics) const ColorModel *const model = static_cast<ColorModel* const>( mListModel); - mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); + mHighlightColor.a = static_cast<unsigned int>(mAlpha * 255.0F); updateAlpha(); Font *const font = getFont(); - const int rowHeight = getRowHeight(); + const int rowHeight = static_cast<int>(getRowHeight()); const int width = mDimension.width; if (mSelected >= 0) @@ -113,8 +115,9 @@ void ColorPage::adjustSize() BLOCK_START("ColorPage::adjustSize") if (mListModel) { - setHeight(getRowHeight() * mListModel->getNumberOfElements() - + 2 * mPadding + 20); + setHeight(static_cast<int>(getRowHeight()) * + mListModel->getNumberOfElements() + + 2 * mPadding + 20); } BLOCK_END("ColorPage::adjustSize") } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 3dd8c3fc9..629bda46b 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -150,7 +150,7 @@ DropDown::DropDown(const Widget2 *const widget, if (mSkin) { mSpacing = mSkin->getOption("spacing"); - mFrameSize = mSkin->getOption("frameSize"); + mFrameSize = static_cast<unsigned int>(mSkin->getOption("frameSize")); mPadding = mSkin->getPadding(); mImagePadding = mSkin->getOption("imagePadding"); } @@ -219,7 +219,7 @@ void DropDown::draw(Graphics* graphics) updateAlpha(); - const int alpha = static_cast<int>(mAlpha * 255.0F); + const unsigned int alpha = static_cast<unsigned int>(mAlpha * 255.0F); const int pad = 2 * mPadding; mHighlightColor.a = alpha; mShadowColor.a = alpha; @@ -294,7 +294,7 @@ void DropDown::safeDraw(Graphics* graphics) void DropDown::drawFrame(Graphics *graphics) { BLOCK_START("DropDown::drawFrame") - const int bs2 = getFrameSize(); + const int bs2 = static_cast<int>(getFrameSize()); const Rect &rect = mDimension; graphics->drawImageRect(0, 0, rect.width + bs2, rect.height + bs2, @@ -305,7 +305,7 @@ void DropDown::drawFrame(Graphics *graphics) void DropDown::safeDrawFrame(Graphics *graphics) { BLOCK_START("DropDown::drawFrame") - const int bs2 = getFrameSize(); + const int bs2 = static_cast<int>(getFrameSize()); const Rect &rect = mDimension; graphics->drawImageRect(0, 0, rect.width + bs2, rect.height + bs2, @@ -476,7 +476,7 @@ void DropDown::dropDown() int x = 0; int y = 0; getAbsolutePosition(x, y); - const int frame = mParent->getFrameSize(); + const int frame = static_cast<int>(mParent->getFrameSize()); const int pad = mPopup->getPadding(); const int pad2 = pad * 2; diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 2af16caf3..23daafb8e 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -31,7 +31,7 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget, ListModel *const listModel, const std::string &skin, - const int rowHeight) : + const unsigned int rowHeight) : ListBox(widget, listModel, skin), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), mSpacing(mSkin ? mSkin->getOption("spacing") : 0), @@ -59,7 +59,7 @@ void ExtendedListBox::draw(Graphics *graphics) updateAlpha(); Font *const font = getFont(); - const int height = mRowHeight; + const int height = static_cast<int>(mRowHeight); const int pad2 = 2 + mPadding; const int width = mDimension.width; int textPos = (height - font->getHeight()) / 2 + mPadding; @@ -130,7 +130,7 @@ void ExtendedListBox::draw(Graphics *graphics) if (minY != -1) { - mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); + mHighlightColor.a = static_cast<unsigned int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); graphics->fillRectangle(Rect(mPadding, minY + mPadding, width - pad2, maxY - minY + height)); @@ -233,7 +233,7 @@ int ExtendedListBox::getSelectionByMouse(const int y) const if (mListItems.empty() && mSelectedItems.empty()) return ListBox::getSelectionByMouse(y); - const int height = mRowHeight; + const int height = static_cast<int>(mRowHeight); const size_t itemsSz = mListItems.size(); for (size_t f = 0; f < itemsSz; f ++) { diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 22032af25..56950ca27 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -33,7 +33,7 @@ class ExtendedListBox final : public ListBox ExtendedListBox(const Widget2 *const widget, ListModel *const listModel, const std::string &skin, - const int rowHeight = 13); + const unsigned int rowHeight = 13); A_DELETE_COPY(ExtendedListBox) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index e0d584265..00f925aff 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -235,7 +235,7 @@ void GuiTable::draw(Graphics* graphics) const int y = rect.y; if (mOpaque) { - mBackgroundColor.a = static_cast<int>(mAlpha * 255.0F); + mBackgroundColor.a = static_cast<unsigned int>(mAlpha * 255.0F); graphics->setColor(mBackgroundColor); graphics->fillRectangle(Rect(0, 0, width, height)); } @@ -250,30 +250,41 @@ void GuiTable::draw(Graphics* graphics) if (first_row < 0) first_row = 0; - unsigned rows_nr = 1 + (height / rHeight); // May overestimate by one. - unsigned max_rows_nr; + unsigned int rows_nr = static_cast<unsigned int>(1 + + height / rHeight); // May overestimate by one. + unsigned int max_rows_nr; if (mModel->getRows() < first_row) - max_rows_nr = 0; + { + max_rows_nr = 0U; + } else - max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: + { + max_rows_nr = static_cast<unsigned int>( + mModel->getRows() - first_row); // clip if neccessary: + } if (max_rows_nr < rows_nr) rows_nr = max_rows_nr; // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. const unsigned first_column = 0; - const unsigned last_column1 = mModel->getColumns(); + const unsigned last_column1 = static_cast<unsigned int>( + mModel->getColumns()); int y_offset = first_row * rHeight; - for (unsigned r = first_row; r < first_row + rows_nr; ++r) + for (unsigned int r = static_cast<unsigned int>(first_row); + r < static_cast<unsigned int>(first_row) + rows_nr; + ++r) { int x_offset = 0; for (unsigned c = first_column; c + 1 <= last_column1; ++c) { - Widget *const widget = mModel->getElementAt(r, c); - const int cWidth = getColumnWidth(c); + Widget *const widget = mModel->getElementAt(static_cast<int>(r), + static_cast<int>(c)); + const int cWidth = static_cast<int>(getColumnWidth( + static_cast<int>(c))); if (widget) { Rect bounds(x_offset, y_offset, cWidth, rHeight); @@ -288,7 +299,8 @@ void GuiTable::draw(Graphics* graphics) if (mSelectedRow > -1) { - mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); + mHighlightColor.a = static_cast<unsigned int>( + mAlpha * 255.0F); graphics->setColor(mHighlightColor); if (mLinewiseMode && r == static_cast<unsigned>( @@ -341,7 +353,7 @@ void GuiTable::safeDraw(Graphics* graphics) const int y = rect.y; if (mOpaque) { - mBackgroundColor.a = static_cast<int>(mAlpha * 255.0F); + mBackgroundColor.a = static_cast<unsigned int>(mAlpha * 255.0F); graphics->setColor(mBackgroundColor); graphics->fillRectangle(Rect(0, 0, width, height)); } @@ -356,30 +368,41 @@ void GuiTable::safeDraw(Graphics* graphics) if (first_row < 0) first_row = 0; - unsigned rows_nr = 1 + (height / rHeight); // May overestimate by one. - unsigned max_rows_nr; + unsigned int rows_nr = static_cast<unsigned int>( + 1 + height / rHeight); // May overestimate by one. + unsigned int max_rows_nr; if (mModel->getRows() < first_row) + { max_rows_nr = 0; + } else - max_rows_nr = mModel->getRows() - first_row; // clip if neccessary: + { + max_rows_nr = static_cast<unsigned int>( + mModel->getRows() - first_row); // clip if neccessary: + } if (max_rows_nr < rows_nr) rows_nr = max_rows_nr; // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. - const unsigned first_column = 0; - const unsigned last_column1 = mModel->getColumns(); + const unsigned int first_column = 0; + const unsigned int last_column1 = static_cast<unsigned int>( + mModel->getColumns()); int y_offset = first_row * rHeight; - for (unsigned r = first_row; r < first_row + rows_nr; ++r) + for (unsigned int r = static_cast<unsigned int>(first_row); + r < static_cast<unsigned int>(first_row + static_cast<int>(rows_nr)); + ++r) { int x_offset = 0; for (unsigned c = first_column; c + 1 <= last_column1; ++c) { - Widget *const widget = mModel->getElementAt(r, c); - const int cWidth = getColumnWidth(c); + Widget *const widget = mModel->getElementAt(static_cast<int>(r), + static_cast<int>(c)); + const int cWidth = static_cast<int>(getColumnWidth( + static_cast<int>(c))); if (widget) { Rect bounds(x_offset, y_offset, cWidth, rHeight); @@ -394,7 +417,8 @@ void GuiTable::safeDraw(Graphics* graphics) if (mSelectedRow > -1) { - mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); + mHighlightColor.a = static_cast<unsigned int>( + mAlpha * 255.0F); graphics->setColor(mHighlightColor); if (mLinewiseMode && r == static_cast<unsigned>( diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp index 0464f1b47..74bbebd87 100644 --- a/src/gui/widgets/layoutarray.cpp +++ b/src/gui/widgets/layoutarray.cpp @@ -59,7 +59,7 @@ LayoutCell &LayoutArray::at(const int x, const int y, const int w, const int h) { resizeGrid(x + w, y + h); - LayoutCell *&cell = mCells[y][x]; + LayoutCell *&cell = mCells[static_cast<size_t>(y)][static_cast<size_t>(x)]; if (!cell) cell = new LayoutCell; return *cell; @@ -75,14 +75,14 @@ void LayoutArray::resizeGrid(int w, const int h) if (extH) { - mSizes[1].resize(h, LayoutType::DEF); - mCells.resize(h); + mSizes[1].resize(static_cast<size_t>(h), LayoutType::DEF); + mCells.resize(static_cast<size_t>(h)); if (!extW) w = static_cast<int>(mSizes[0].size()); } if (extW) - mSizes[0].resize(w, LayoutType::DEF); + mSizes[0].resize(static_cast<size_t>(w), LayoutType::DEF); std::vector <std::vector <LayoutCell *> >::iterator i = mCells.begin(); @@ -90,7 +90,7 @@ void LayoutArray::resizeGrid(int w, const int h) i_end = mCells.end(); while (i != i_end) { - i->resize(w, nullptr); + i->resize(static_cast<size_t>(w), nullptr); ++i; } } @@ -98,22 +98,23 @@ void LayoutArray::resizeGrid(int w, const int h) void LayoutArray::setColWidth(const int n, const int w) { resizeGrid(n + 1, 0); - mSizes[0][n] = w; + mSizes[0U][static_cast<size_t>(n)] = w; } void LayoutArray::setRowHeight(const int n, const int h) { resizeGrid(0, n + 1); - mSizes[1][n] = h; + mSizes[1][static_cast<size_t>(n)] = h; } void LayoutArray::matchColWidth(const int n1, const int n2) { resizeGrid(std::max(n1, n2) + 1, 0); const std::vector<int> widths = getSizes(0, LayoutType::DEF); - const int s = std::max(widths[n1], widths[n2]); - mSizes[0][n1] = s; - mSizes[0][n2] = s; + const int s = std::max(widths[static_cast<size_t>(n1)], + widths[static_cast<size_t>(n2)]); + mSizes[0][static_cast<size_t>(n1)] = s; + mSizes[0][static_cast<size_t>(n2)] = s; } void LayoutArray::extend(const int x, const int y, const int w, const int h) @@ -146,7 +147,8 @@ LayoutCell &LayoutArray::place(Widget *const widget, const int x, cell.mVPadding = 0; cell.mAlign[0] = LayoutCell::FILL; cell.mAlign[1] = LayoutCell::FILL; - int &cs = mSizes[0][x], &rs = mSizes[1][y]; + int &cs = mSizes[0][static_cast<size_t>(x)]; + int &rs = mSizes[1][static_cast<size_t>(y)]; if (cs == LayoutType::DEF && w == 1) cs = 0; if (rs == LayoutType::DEF && h == 1) @@ -203,7 +205,8 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const { for (int gridX = 0; gridX < gridW; ++gridX) { - const LayoutCell *const cell = mCells[gridY][gridX]; + const LayoutCell *const cell = mCells[static_cast<size_t>(gridY)] + [static_cast<size_t>(gridX)]; if (!cell || cell->mType == LayoutCell::NONE) continue; @@ -211,8 +214,8 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const { const int n = (dim == 0 ? gridX : gridY); const int s = cell->mSize[dim] + cell->mVPadding * 2; - if (s > sizes[n]) - sizes[n] = s; + if (s > sizes[static_cast<size_t>(n)]) + sizes[static_cast<size_t>(n)] = s; } } } @@ -225,16 +228,18 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const int nbFill = 0; for (int i = 0; i < nb; ++i) { - if (mSizes[dim][i] <= LayoutType::DEF) + if (mSizes[static_cast<size_t>(dim)][static_cast<size_t>(i)] + <= LayoutType::DEF) { ++nbFill; - if (mSizes[dim][i] == LayoutType::SET || - sizes[i] <= LayoutType::DEF) + if (mSizes[static_cast<size_t>(dim)][static_cast<size_t>(i)] == + LayoutType::SET || + sizes[static_cast<size_t>(i)] <= LayoutType::DEF) { - sizes[i] = 0; + sizes[static_cast<size_t>(i)] = 0; } } - upp -= sizes[i] + mSpacing; + upp -= sizes[static_cast<size_t>(i)] + mSpacing; } upp = upp + mSpacing; @@ -243,11 +248,14 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const for (int i = 0; i < nb; ++i) { - if (mSizes[dim][i] > LayoutType::DEF) + if (mSizes[static_cast<size_t>(dim)][static_cast<size_t>(i)] > + LayoutType::DEF) + { continue; + } const int s = upp / nbFill; - sizes[i] += s; + sizes[static_cast<size_t>(i)] += s; upp -= s; --nbFill; } @@ -262,8 +270,8 @@ int LayoutArray::getSize(const int dim) const const int nb = static_cast<int>(sizes.size()); for (int i = 0; i < nb; ++i) { - if (sizes[i] > LayoutType::DEF) - size += sizes[i]; + if (sizes[static_cast<size_t>(i)] > LayoutType::DEF) + size += sizes[static_cast<size_t>(i)]; size += mSpacing; } return size - mSpacing; @@ -286,16 +294,19 @@ void LayoutArray::reflow(const int nx, const int ny, int x = nx; for (int gridX = 0; gridX < gridW; ++gridX) { - LayoutCell *const cell = mCells[gridY][gridX]; + LayoutCell *const cell = mCells[static_cast<size_t>(gridY)] + [static_cast<size_t>(gridX)]; if (cell && cell->mType != LayoutCell::NONE) { int dx = x, dy = y, dw = 0, dh = 0; - align(dx, dw, 0, *cell, &widths[gridX], szW - gridX); - align(dy, dh, 1, *cell, &heights[gridY], szH - gridY); + align(dx, dw, 0, *cell, + &widths[static_cast<size_t>(gridX)], szW - gridX); + align(dy, dh, 1, *cell, + &heights[static_cast<size_t>(gridY)], szH - gridY); cell->reflow(dx, dy, dw, dh); } - x += widths[gridX] + mSpacing; + x += widths[static_cast<size_t>(gridX)] + mSpacing; } - y += heights[gridY] + mSpacing; + y += heights[static_cast<size_t>(gridY)] + mSpacing; } } diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index d7346b5b2..c827911eb 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -122,7 +122,8 @@ ListBox::ListBox(const Widget2 *const widget, } const Font *const font = getFont(); - mRowHeight = font->getHeight() + 2 * mItemPadding; + mRowHeight = static_cast<unsigned int>( + font->getHeight() + 2 * mItemPadding); } void ListBox::postInit() @@ -156,10 +157,10 @@ void ListBox::draw(Graphics *graphics) BLOCK_START("ListBox::draw") updateAlpha(); - mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); + mHighlightColor.a = static_cast<unsigned int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); Font *const font = getFont(); - const int rowHeight = getRowHeight(); + const int rowHeight = static_cast<int>(getRowHeight()); const int width = mDimension.width; if (mCenterText) @@ -358,8 +359,8 @@ void ListBox::adjustSize() BLOCK_START("ListBox::adjustSize") if (mListModel) { - setHeight(getRowHeight() * mListModel->getNumberOfElements() - + 2 * mPadding); + setHeight(static_cast<int>(getRowHeight()) * + mListModel->getNumberOfElements() + 2 * mPadding); } BLOCK_END("ListBox::adjustSize") } @@ -375,7 +376,7 @@ int ListBox::getSelectionByMouse(const int y) const { if (y < mPadding) return -1; - return static_cast<unsigned int>(y - mPadding) / getRowHeight(); + return (y - mPadding) / static_cast<int>(getRowHeight()); } void ListBox::setSelected(const int selected) @@ -399,9 +400,9 @@ void ListBox::setSelected(const int selected) if (mSelected < 0) scroll.y = 0; else - scroll.y = getRowHeight() * mSelected; + scroll.y = static_cast<int>(getRowHeight()) * mSelected; - scroll.height = getRowHeight(); + scroll.height = static_cast<int>(getRowHeight()); showPart(scroll); distributeValueChangedEvent(); diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp index cf9fa1548..a385e8387 100644 --- a/src/gui/widgets/passwordfield.cpp +++ b/src/gui/widgets/passwordfield.cpp @@ -29,9 +29,9 @@ PasswordField::PasswordField(const Widget2 *const widget, const std::string &text) : TextField(widget, text), - mPasswordChar(mSkin ? static_cast<unsigned char>( + mPasswordChar(mSkin ? static_cast<char>( mSkin->getOption("passwordChar", 42)) - : static_cast<unsigned char>(42U)) + : static_cast<char>(42)) { } diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 4ec0b079e..78b4f94ac 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -49,7 +49,7 @@ class PasswordField final : public TextField void safeDraw(Graphics *graphics) override final A_NONNULL(2); protected: - unsigned char mPasswordChar; + char mPasswordChar; }; #endif // GUI_WIDGETS_PASSWORDFIELD_H diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 5d720c459..03db3f97e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -161,7 +161,7 @@ void ProgressBar::draw(Graphics *graphics) } updateAlpha(); - mBackgroundColor.a = static_cast<int>(mAlpha * 255); + mBackgroundColor.a = static_cast<unsigned int>(mAlpha * 255); if (mRedraw || graphics->getRedraw()) { @@ -240,7 +240,7 @@ void ProgressBar::safeDraw(Graphics *graphics) } updateAlpha(); - mBackgroundColor.a = static_cast<int>(mAlpha * 255); + mBackgroundColor.a = static_cast<unsigned int>(mAlpha * 255); graphics->drawImageRect(0, 0, mDimension.width, mDimension.height, mSkin->getBorder()); diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 655ab8126..1477f94e7 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -91,7 +91,7 @@ void ShopListBox::draw(Graphics *graphics) if (settings.guiAlpha != mAlpha) mAlpha = settings.guiAlpha; - const int alpha = static_cast<int>(mAlpha * 255.0F); + const unsigned int alpha = static_cast<unsigned int>(mAlpha * 255.0F); Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index fc9a91e97..b9f90c949 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -282,7 +282,7 @@ int TextField::getValue() const if (value < mMinimum) return mMinimum; - if (value > static_cast<signed>(mMaximum)) + if (value > mMaximum) return mMaximum; return value; @@ -326,7 +326,8 @@ void TextField::keyPressed(KeyEvent &event) return; } } - else if (!mMaximum || mText.size() < mMaximum) + else if (!mMaximum || + static_cast<int>(mText.size()) < mMaximum) { int len; if (val < 128) diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 85d277a89..90fb0b571 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -131,7 +131,8 @@ class TextField notfinal : public Widget, /** * Set the range on the field if it is numeric */ - void setRange(const int min, const int max) + void setRange(const int min, + const int max) { mMinimum = min; mMaximum = max; @@ -274,7 +275,7 @@ class TextField notfinal : public Widget, static float mAlpha; static ImageRect skin; int mMinimum; - unsigned int mMaximum; + int mMaximum; int mLastEventPaste; int mPadding; bool mNumeric; diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index 4c5a8c59a..8e56a2477 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -36,7 +36,7 @@ class Widget2 notfinal } inline const Color &getThemeColor(const ThemeColorIdT type, - const int alpha = 255) + const unsigned int alpha = 255U) const A_WARN_UNUSED { return theme->getColor(type + mPaletteOffset, alpha); @@ -50,7 +50,7 @@ class Widget2 notfinal return Palette::BLACK; const ThemeColorIdT colorId = theme->getIdByChar(c, valid); if (valid) - return theme->getColor(colorId + mPaletteOffset, 255); + return theme->getColor(colorId + mPaletteOffset, 255U); else return Palette::BLACK; } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index e22ea3f60..02a13a249 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -202,7 +202,8 @@ Window::Window(const std::string &caption, { mCaptionAlign = Graphics::LEFT; } - setTitleBarHeight(getOption("titlebarHeight")); + setTitleBarHeight(static_cast<unsigned int>( + getOption("titlebarHeight"))); if (!mTitleBarHeight) mTitleBarHeight = mCaptionFont->getHeight() + mPadding; @@ -1287,8 +1288,10 @@ int Window::getResizeHandles(const MouseEvent &event) if (!mStickyButtonLock || !mSticky) { - if (mGrip && (y > mTitleBarHeight || (y < mPadding - && mTitleBarHeight > mPadding))) + if (mGrip && + (y > mTitleBarHeight || + (static_cast<int>(y) < mPadding && + static_cast<int>(mTitleBarHeight) > mPadding))) { if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this) @@ -1315,8 +1318,9 @@ bool Window::isResizeAllowed(const MouseEvent &event) const { const int y = event.getY(); - if (mGrip && (y > static_cast<int>(mTitleBarHeight) - || y < static_cast<int>(mPadding))) + if (mGrip && + (y > static_cast<int>(mTitleBarHeight) || + y < mPadding)) { const int x = event.getX(); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 277e971bb..22378b59a 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -481,7 +481,7 @@ class Window notfinal : public BasicContainer2, * @param padding The padding of the window. * @see getPadding */ - void setPadding(unsigned int padding) + void setPadding(int padding) { mPadding = padding; } /** @@ -491,7 +491,7 @@ class Window notfinal : public BasicContainer2, * @return The padding of the window. * @see setPadding */ - unsigned int getPadding() const + int getPadding() const { return mPadding; } /** @@ -605,7 +605,7 @@ class Window notfinal : public BasicContainer2, /** * Holds the padding of the window. */ - unsigned int mPadding; + int mPadding; /** * Holds the title bar height of the window. diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index c587d6708..ca880df2a 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -161,7 +161,7 @@ void WindowManager::initTitle() #endif } -void WindowManager::setFramerate(const int fpsLimit) +void WindowManager::setFramerate(const unsigned int fpsLimit) { if (!fpsLimit) return; diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h index 86ab520d7..a64478bb5 100644 --- a/src/gui/windowmanager.h +++ b/src/gui/windowmanager.h @@ -37,7 +37,7 @@ namespace WindowManager bool isKeyboardVisible(); - void setFramerate(const int fpsLimit); + void setFramerate(const unsigned int fpsLimit); int getFramerate() A_WARN_UNUSED; diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 941364e40..599d8115d 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -793,7 +793,7 @@ void ChangeDisplay::action(const ActionEvent &event) const int newbase = PlayerInfo::getStatBase(mId) + cnt; PlayerInfo::setStatBase(mId, newbase); - for (unsigned f = 0; f < mInc->getClickCount(); f ++) + for (int f = 0; f < mInc->getClickCount(); f ++) { playerHandler->increaseAttribute(mId); if (cnt != 1) |