diff options
Diffstat (limited to 'src/guichan')
-rw-r--r-- | src/guichan/include/guichan/sdl/sdlpixel.hpp | 4 | ||||
-rw-r--r-- | src/guichan/sdl/sdlgraphics.cpp | 23 | ||||
-rw-r--r-- | src/guichan/sdl/sdlimage.cpp | 4 | ||||
-rw-r--r-- | src/guichan/widgets/scrollarea.cpp | 8 | ||||
-rw-r--r-- | src/guichan/widgets/slider.cpp | 4 | ||||
-rw-r--r-- | src/guichan/widgets/tabbedarea.cpp | 2 | ||||
-rw-r--r-- | src/guichan/widgets/textbox.cpp | 31 | ||||
-rw-r--r-- | src/guichan/widgets/window.cpp | 2 |
8 files changed, 42 insertions, 36 deletions
diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp index f56100b4a..23298ef37 100644 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp @@ -244,8 +244,8 @@ namespace gcn break; case 2: - *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel, *(Uint32 *)p, - color.a, surface->format); + *reinterpret_cast<Uint16*>(p) = SDLAlpha16(pixel, + *reinterpret_cast<Uint32*>(p), color.a, surface->format); break; case 3: diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp index c8cec6370..ae61a0432 100644 --- a/src/guichan/sdl/sdlgraphics.cpp +++ b/src/guichan/sdl/sdlgraphics.cpp @@ -283,7 +283,8 @@ namespace gcn SDL_LockSurface(mTarget); - Uint8 *p = (Uint8 *)mTarget->pixels + y * mTarget->pitch + x1 * bpp; + Uint8 *p = static_cast<Uint8*>(mTarget->pixels) + + y * mTarget->pitch + x1 * bpp; Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, @@ -298,7 +299,7 @@ namespace gcn case 2: { - Uint16* q = (Uint16*)p; + Uint16* q = reinterpret_cast<Uint16*>(p); for (; x1 <= x2; ++x1) *(q++) = pixel; break; @@ -329,7 +330,7 @@ namespace gcn case 4: { - Uint32* q = (Uint32*)p; + Uint32 *q = reinterpret_cast<Uint32*>(p); for (; x1 <= x2; ++x1) { if (mAlpha) @@ -395,7 +396,8 @@ namespace gcn SDL_LockSurface(mTarget); - Uint8 *p = (Uint8 *)mTarget->pixels + y1 * mTarget->pitch + x * bpp; + Uint8 *p = static_cast<Uint8*>(mTarget->pixels) + + y1 * mTarget->pitch + x * bpp; Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b); @@ -411,9 +413,9 @@ namespace gcn break; case 2: - for (; y1 <= y2; ++y1) + for (; y1 <= y2; ++ y1) { - *(Uint16*)p = pixel; + *reinterpret_cast<Uint16*>(p) = pixel; p += mTarget->pitch; } break; @@ -445,9 +447,14 @@ namespace gcn for (; y1 <= y2; ++y1) { if (mAlpha) - *(Uint32*)p = SDLAlpha32(pixel, *(Uint32*)p, mColor.a); + { + *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel, + *reinterpret_cast<Uint32*>(p), mColor.a); + } else - *(Uint32*)p = pixel; + { + *reinterpret_cast<Uint32*>(p) = pixel; + } p += mTarget->pitch; } break; diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index 4f9b9565c..cf8505c4e 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -142,8 +142,8 @@ namespace gcn { Uint8 r, g, b, a; - SDL_GetRGBA(((unsigned int*)mSurface->pixels)[i], mSurface->format, - &r, &g, &b, &a); + SDL_GetRGBA((static_cast<unsigned int*>(mSurface->pixels)[i]), + mSurface->format, &r, &g, &b, &a); if (a != 255) { diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 451288c77..21f7b5930 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -325,12 +325,12 @@ namespace gcn if (y < getVerticalMarkerDimension().y) { setVerticalScrollAmount(getVerticalScrollAmount() - - (int)(getChildrenArea().height * 0.95)); + - static_cast<int>(getChildrenArea().height * 0.95)); } else { setVerticalScrollAmount(getVerticalScrollAmount() - + (int)(getChildrenArea().height * 0.95)); + + static_cast<int>(getChildrenArea().height * 0.95)); } } else if (getHorizontalMarkerDimension().isPointInRect(x, y)) @@ -345,12 +345,12 @@ namespace gcn if (x < getHorizontalMarkerDimension().x) { setHorizontalScrollAmount(getHorizontalScrollAmount() - - (int)(getChildrenArea().width * 0.95)); + - static_cast<int>(getChildrenArea().width * 0.95)); } else { setHorizontalScrollAmount(getHorizontalScrollAmount() - + (int)(getChildrenArea().width * 0.95)); + + static_cast<int>(getChildrenArea().width * 0.95)); } } } diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index 16f7cd8be..36f067eab 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -245,7 +245,7 @@ namespace gcn else w = getHeight(); - double pos = v / ((double)w - getMarkerLength()); + double pos = v / (static_cast<double>(w) - getMarkerLength()); return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); } @@ -257,7 +257,7 @@ namespace gcn else v = getHeight(); - int w = (int)((v - getMarkerLength()) + int w = static_cast<int>((v - getMarkerLength()) * (value - getScaleStart()) / (getScaleEnd() - getScaleStart())); diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index 7af00c4c4..3e7178548 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -320,7 +320,7 @@ namespace gcn int index = getSelectedTabIndex(); index++; - if (index >= (int)mTabs.size()) + if (index >= static_cast<int>(mTabs.size())) return; else setSelectedTab(mTabs[index].first); diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index e78ea91a3..c2cd5586f 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -155,7 +155,7 @@ namespace gcn { mCaretRow = mouseEvent.getY() / getFont()->getHeight(); - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast<int>(mTextRows.size())) mCaretRow = mTextRows.size() - 1; mCaretColumn = getFont()->getStringIndexAt( @@ -193,11 +193,11 @@ namespace gcn else if (key.getValue() == Key::RIGHT) { ++mCaretColumn; - if (mCaretColumn > (int)mTextRows[mCaretRow].size()) + if (mCaretColumn > static_cast<int>(mTextRows[mCaretRow].size())) { - ++mCaretRow; + ++ mCaretRow; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast<int>(mTextRows.size())) { mCaretRow = mTextRows.size() - 1; if (mCaretRow < 0) @@ -254,14 +254,15 @@ namespace gcn --mCaretRow; } else if (key.getValue() == Key::DELETE - && mCaretColumn < (int)mTextRows[mCaretRow].size() - && mEditable) + && mCaretColumn < static_cast<int>( + mTextRows[mCaretRow].size()) && mEditable) { mTextRows[mCaretRow].erase(mCaretColumn, 1); } else if (key.getValue() == Key::DELETE - && mCaretColumn == (int)mTextRows[mCaretRow].size() - && mCaretRow < ((int)mTextRows.size() - 1) + && mCaretColumn == static_cast<int>( + mTextRows[mCaretRow].size()) + && mCaretRow < (static_cast<int>(mTextRows.size()) - 1) && mEditable) { mTextRows[mCaretRow] += mTextRows[mCaretRow + 1]; @@ -291,7 +292,7 @@ namespace gcn / getFont()->getHeight(); mCaretRow += rowsPerPage; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast<int>(mTextRows.size())) mCaretRow = mTextRows.size() - 1; } } @@ -305,7 +306,7 @@ namespace gcn && mEditable) { mTextRows[mCaretRow].insert(mCaretColumn, - std::string(1, (char)key.getValue())); + std::string(1, static_cast<char>(key.getValue()))); ++ mCaretColumn; } @@ -332,9 +333,7 @@ namespace gcn void TextBox::setCaretPosition(unsigned int position) { - int row; - - for (row = 0; row < (int)mTextRows.size(); row++) + for (int row = 0; row < static_cast<int>(mTextRows.size()); row ++) { if (position <= mTextRows[row].size()) { @@ -373,7 +372,7 @@ namespace gcn { mCaretRow = row; - if (mCaretRow >= (int)mTextRows.size()) + if (mCaretRow >= static_cast<int>(mTextRows.size())) mCaretRow = mTextRows.size() - 1; if (mCaretRow < 0) @@ -391,7 +390,7 @@ namespace gcn { mCaretColumn = column; - if (mCaretColumn > (int)mTextRows[mCaretRow].size()) + if (mCaretColumn > static_cast<int>(mTextRows[mCaretRow].size())) mCaretColumn = mTextRows[mCaretRow].size(); if (mCaretColumn < 0) @@ -431,7 +430,7 @@ namespace gcn int i; std::string text; - for (i = 0; i < (int)mTextRows.size() - 1; ++i) + for (i = 0; i < static_cast<int>(mTextRows.size()) - 1; ++ i) text = text + mTextRows[i] + "\n"; text = text + mTextRows[i]; diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index d7c5809e6..c7ed8a69e 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -137,7 +137,7 @@ namespace gcn mDragOffsetX = mouseEvent.getX(); mDragOffsetY = mouseEvent.getY(); - mMoved = mouseEvent.getY() <= (int)mTitleBarHeight; + mMoved = mouseEvent.getY() <= static_cast<int>(mTitleBarHeight); } void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED) |