From f0e95132f27ceb901fbd779fafc798a1f67a06a6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 18 Jul 2012 01:51:36 +0300 Subject: Another warning fixes. --- src/guichan/defaultfont.cpp | 4 ++-- src/guichan/focushandler.cpp | 4 ++-- src/guichan/font.cpp | 2 +- src/guichan/include/guichan/platform.hpp | 6 +++--- src/guichan/widgets/textbox.cpp | 23 ++++++++++++----------- src/guichan/widgets/textfield.cpp | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) (limited to 'src/guichan') diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp index feeb91001..8d0b23623 100644 --- a/src/guichan/defaultfont.cpp +++ b/src/guichan/defaultfont.cpp @@ -64,7 +64,7 @@ namespace gcn int DefaultFont::getWidth(const std::string& text) const { - return 8*text.size(); + return static_cast(8 * text.size()); } int DefaultFont::drawGlyph(Graphics* graphics, @@ -88,7 +88,7 @@ namespace gcn int DefaultFont::getStringIndexAt(const std::string& text, int x) const { if (x > static_cast(text.size() * 8)) - return text.size(); + return static_cast(text.size()); return x / 8; } diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index 839c35cc1..393c08880 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -235,7 +235,7 @@ namespace gcn -- i; if (focusedWidget <= 0) - focusedWidget = mWidgets.size() - 1; + focusedWidget = static_cast(mWidgets.size() - 1); if (focusedWidget == focused) return; @@ -433,7 +433,7 @@ namespace gcn -- i; if (focusedWidget <= 0) - focusedWidget = mWidgets.size() - 1; + focusedWidget = static_cast(mWidgets.size() - 1); if (focusedWidget == focused) return; diff --git a/src/guichan/font.cpp b/src/guichan/font.cpp index 598b1610b..6fec94121 100644 --- a/src/guichan/font.cpp +++ b/src/guichan/font.cpp @@ -62,6 +62,6 @@ namespace gcn return i; } - return text.size(); + return static_cast(text.size()); } } diff --git a/src/guichan/include/guichan/platform.hpp b/src/guichan/include/guichan/platform.hpp index 9a18191d2..9e3d1338a 100644 --- a/src/guichan/include/guichan/platform.hpp +++ b/src/guichan/include/guichan/platform.hpp @@ -73,8 +73,8 @@ #define GCN_EXTENSION_DECLSPEC #endif -#ifndef NULL -#define NULL 0 -#endif +//#ifndef NULL +//#define NULL 0 +//#endif #endif // end GCN_PLATFORM_HPP diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 0103cdb99..6b03a1cb5 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -100,9 +100,9 @@ namespace gcn pos = text.find("\n", lastPos); if (pos != std::string::npos) - length = pos - lastPos; + length = static_cast(pos - lastPos); else - length = text.size() - lastPos; + length = static_cast(text.size() - lastPos); std::string sub = text.substr(lastPos, length); mTextRows.push_back(sub); lastPos = pos + 1; @@ -133,7 +133,8 @@ namespace gcn for (size_t i = 0; i < mTextRows.size(); i++) { // Move the text one pixel so we can have a caret before a letter. - graphics->drawText(mTextRows[i], 1, i * getFont()->getHeight()); + graphics->drawText(mTextRows[i], 1, + static_cast(i * getFont()->getHeight())); } } @@ -150,7 +151,7 @@ namespace gcn mCaretRow = mouseEvent.getY() / getFont()->getHeight(); if (mCaretRow >= static_cast(mTextRows.size())) - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast(mTextRows.size() - 1); mCaretColumn = getFont()->getStringIndexAt( mTextRows[mCaretRow], mouseEvent.getX()); @@ -177,7 +178,7 @@ namespace gcn } setWidth(width + 1); - setHeight(getFont()->getHeight() * mTextRows.size()); + setHeight(static_cast(getFont()->getHeight() * mTextRows.size())); } void TextBox::setCaretPosition(unsigned int position) @@ -197,8 +198,8 @@ namespace gcn } // position beyond end of text - mCaretRow = mTextRows.size() - 1; - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretRow = static_cast(mTextRows.size() - 1); + mCaretColumn = static_cast(mTextRows[mCaretRow].size()); } unsigned int TextBox::getCaretPosition() const @@ -206,7 +207,7 @@ namespace gcn int pos = 0, row; for (row = 0; row < mCaretRow; row++) - pos += mTextRows[row].size(); + pos += static_cast(mTextRows[row].size()); return pos + mCaretColumn; } @@ -222,7 +223,7 @@ namespace gcn mCaretRow = row; if (mCaretRow >= static_cast(mTextRows.size())) - mCaretRow = mTextRows.size() - 1; + mCaretRow = static_cast(mTextRows.size() - 1); if (mCaretRow < 0) mCaretRow = 0; @@ -240,7 +241,7 @@ namespace gcn mCaretColumn = column; if (mCaretColumn > static_cast(mTextRows[mCaretRow].size())) - mCaretColumn = mTextRows[mCaretRow].size(); + mCaretColumn = static_cast(mTextRows[mCaretRow].size()); if (mCaretColumn < 0) mCaretColumn = 0; @@ -268,7 +269,7 @@ namespace gcn unsigned int TextBox::getNumberOfRows() const { - return mTextRows.size(); + return static_cast(mTextRows.size()); } std::string TextBox::getText() const diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index b23722cc4..b74d2333f 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -83,7 +83,7 @@ namespace gcn void TextField::setText(const std::string& text) { if (text.size() < mCaretPosition) - mCaretPosition = text.size(); + mCaretPosition = static_cast(text.size()); mText = text; } @@ -151,7 +151,7 @@ namespace gcn void TextField::setCaretPosition(unsigned int position) { if (position > mText.size()) - mCaretPosition = mText.size(); + mCaretPosition = static_cast(mText.size()); else mCaretPosition = position; -- cgit v1.2.3-70-g09d2