summaryrefslogtreecommitdiff
path: root/src/guichan
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
committerReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
commit490862919d79369112c75955a9c36ff8a081efd3 (patch)
tree6fe89466b9c53ba811f298174e6d787bbae71e09 /src/guichan
parentdff814619d63496acd3c4e8730b828b5d4d931fb (diff)
parentd873da3e8e57480016596f714845c1bc7e712e68 (diff)
downloadmv-490862919d79369112c75955a9c36ff8a081efd3.tar.gz
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.bz2
mv-490862919d79369112c75955a9c36ff8a081efd3.tar.xz
mv-490862919d79369112c75955a9c36ff8a081efd3.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/guichan')
-rw-r--r--src/guichan/color.cpp18
-rw-r--r--src/guichan/defaultfont.cpp2
-rw-r--r--src/guichan/focushandler.cpp20
-rw-r--r--src/guichan/include/guichan/actionlistener.hpp7
-rw-r--r--src/guichan/include/guichan/deathlistener.hpp7
-rw-r--r--src/guichan/include/guichan/focushandler.hpp3
-rw-r--r--src/guichan/include/guichan/focuslistener.hpp12
-rw-r--r--src/guichan/include/guichan/graphics.hpp9
-rw-r--r--src/guichan/include/guichan/keylistener.hpp12
-rw-r--r--src/guichan/include/guichan/listmodel.hpp3
-rw-r--r--src/guichan/include/guichan/mouselistener.hpp6
-rw-r--r--src/guichan/include/guichan/sdl/sdlpixel.hpp26
-rw-r--r--src/guichan/include/guichan/widget.hpp18
-rw-r--r--src/guichan/include/guichan/widgetlistener.hpp19
-rw-r--r--src/guichan/include/guichan/widgets/listbox.hpp3
-rw-r--r--src/guichan/include/guichan/widgets/slider.hpp3
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp23
-rw-r--r--src/guichan/sdl/sdlimage.cpp8
-rw-r--r--src/guichan/widgets/scrollarea.cpp8
-rw-r--r--src/guichan/widgets/slider.cpp4
-rw-r--r--src/guichan/widgets/tabbedarea.cpp2
-rw-r--r--src/guichan/widgets/textbox.cpp31
-rw-r--r--src/guichan/widgets/window.cpp2
23 files changed, 143 insertions, 103 deletions
diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp
index d3dc7a738..f58e7b58e 100644
--- a/src/guichan/color.cpp
+++ b/src/guichan/color.cpp
@@ -97,23 +97,23 @@ namespace gcn
b - color.b,
255);
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
+ result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
+ result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
+ result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
return result;
}
Color Color::operator*(float value) const
{
- Color result((int)(r * value),
- (int)(g * value),
- (int)(b * value),
+ Color result(static_cast<int>(r * value),
+ static_cast<int>(g * value),
+ static_cast<int>(b * value),
a);
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
+ result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
+ result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
+ result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
return result;
}
diff --git a/src/guichan/defaultfont.cpp b/src/guichan/defaultfont.cpp
index 8871d51de..70901bc8e 100644
--- a/src/guichan/defaultfont.cpp
+++ b/src/guichan/defaultfont.cpp
@@ -89,7 +89,7 @@ namespace gcn
int DefaultFont::getStringIndexAt(const std::string& text, int x) const
{
- if (x > (int)text.size() * 8)
+ if (x > static_cast<int>(text.size() * 8))
return text.size();
return x / 8;
diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp
index 832a201ad..e3610fb1e 100644
--- a/src/guichan/focushandler.cpp
+++ b/src/guichan/focushandler.cpp
@@ -158,7 +158,7 @@ namespace gcn
{
int i;
int focusedWidget = -1;
- for (i = 0; i < (int)mWidgets.size(); ++i)
+ for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -167,7 +167,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = (int)mWidgets.size();
+ i = static_cast<int>(mWidgets.size());
do
{
++ focusedWidget;
@@ -180,7 +180,7 @@ namespace gcn
-- i;
- if (focusedWidget >= (int)mWidgets.size())
+ if (focusedWidget >= static_cast<int>(mWidgets.size()))
focusedWidget = 0;
if (focusedWidget == focused)
@@ -213,7 +213,7 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < (int)mWidgets.size(); ++ i)
+ for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -222,7 +222,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = (int)mWidgets.size();
+ i = static_cast<int>(mWidgets.size());
do
{
-- focusedWidget;
@@ -342,7 +342,7 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < (int)mWidgets.size(); ++i)
+ for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -352,7 +352,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = (int)mWidgets.size();
+ i = static_cast<int>(mWidgets.size());
do
{
++ focusedWidget;
@@ -365,7 +365,7 @@ namespace gcn
-- i;
- if (focusedWidget >= (int)mWidgets.size())
+ if (focusedWidget >= static_cast<int>(mWidgets.size()))
focusedWidget = 0;
if (focusedWidget == focused)
@@ -411,7 +411,7 @@ namespace gcn
int i;
int focusedWidget = -1;
- for (i = 0; i < (int)mWidgets.size(); ++i)
+ for (i = 0; i < static_cast<int>(mWidgets.size()); ++ i)
{
if (mWidgets[i] == mFocusedWidget)
focusedWidget = i;
@@ -421,7 +421,7 @@ namespace gcn
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
- i = (int)mWidgets.size();
+ i = static_cast<int>(mWidgets.size());
do
{
-- focusedWidget;
diff --git a/src/guichan/include/guichan/actionlistener.hpp b/src/guichan/include/guichan/actionlistener.hpp
index 28373f2df..5991486a7 100644
--- a/src/guichan/include/guichan/actionlistener.hpp
+++ b/src/guichan/include/guichan/actionlistener.hpp
@@ -67,7 +67,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~ActionListener() { }
+ virtual ~ActionListener()
+ { }
/**
* Called when an action is recieved from a widget. It is used
@@ -86,8 +87,8 @@ namespace gcn
* You should not be able to make an instance of ActionListener,
* therefore its constructor is protected.
*/
- ActionListener() { }
-
+ ActionListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/deathlistener.hpp b/src/guichan/include/guichan/deathlistener.hpp
index 5e983e02d..b2061e036 100644
--- a/src/guichan/include/guichan/deathlistener.hpp
+++ b/src/guichan/include/guichan/deathlistener.hpp
@@ -66,7 +66,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~DeathListener() { }
+ virtual ~DeathListener()
+ { }
/**
* Called when a widget dies. It is used to be able to recieve
@@ -83,8 +84,8 @@ namespace gcn
* You should not be able to make an instance of DeathListener,
* therefore its constructor is protected.
*/
- DeathListener() { }
-
+ DeathListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/focushandler.hpp b/src/guichan/include/guichan/focushandler.hpp
index 4caba6f7b..9fa7ddeb7 100644
--- a/src/guichan/include/guichan/focushandler.hpp
+++ b/src/guichan/include/guichan/focushandler.hpp
@@ -80,7 +80,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~FocusHandler() { };
+ virtual ~FocusHandler()
+ { };
/**
* Requests focus for a widget. Focus will only be granted to a widget
diff --git a/src/guichan/include/guichan/focuslistener.hpp b/src/guichan/include/guichan/focuslistener.hpp
index 9ec53b860..3876e8518 100644
--- a/src/guichan/include/guichan/focuslistener.hpp
+++ b/src/guichan/include/guichan/focuslistener.hpp
@@ -72,21 +72,24 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~FocusListener() { }
+ virtual ~FocusListener()
+ { }
/**
* Called when a widget gains focus.
*
* @param event Discribes the event.
*/
- virtual void focusGained(const Event& event A_UNUSED) { };
+ virtual void focusGained(const Event& event A_UNUSED)
+ { };
/**
* Called when a widget loses focus.
*
* @param event Discribes the event.
*/
- virtual void focusLost(const Event& event A_UNUSED) { };
+ virtual void focusLost(const Event& event A_UNUSED)
+ { };
protected:
/**
@@ -95,7 +98,8 @@ namespace gcn
* You should not be able to make an instance of FocusListener,
* therefore its constructor is protected.
*/
- FocusListener() { }
+ FocusListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/graphics.hpp b/src/guichan/include/guichan/graphics.hpp
index efefa3d73..d10c63ae1 100644
--- a/src/guichan/include/guichan/graphics.hpp
+++ b/src/guichan/include/guichan/graphics.hpp
@@ -113,7 +113,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~Graphics() { }
+ virtual ~Graphics()
+ { }
/**
* Initializes drawing. Called by the Gui when Gui::draw() is called.
@@ -126,7 +127,8 @@ namespace gcn
*
* @see _endDraw, Gui::draw
*/
- virtual void _beginDraw() { }
+ virtual void _beginDraw()
+ { }
/**
* Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
@@ -137,7 +139,8 @@ namespace gcn
*
* @see _beginDraw, Gui::draw
*/
- virtual void _endDraw() { }
+ virtual void _endDraw()
+ { }
/**
* Pushes a clip area onto the stack. The x and y coordinates in the
diff --git a/src/guichan/include/guichan/keylistener.hpp b/src/guichan/include/guichan/keylistener.hpp
index a6d6f851d..9f90a1ffc 100644
--- a/src/guichan/include/guichan/keylistener.hpp
+++ b/src/guichan/include/guichan/keylistener.hpp
@@ -70,7 +70,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~KeyListener() { }
+ virtual ~KeyListener()
+ { }
/**
* Called if a key is pressed when the widget has keyboard focus.
@@ -79,14 +80,16 @@ namespace gcn
*
* @param keyEvent Discribes the event.
*/
- virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) { }
+ virtual void keyPressed(KeyEvent& keyEvent A_UNUSED)
+ { }
/**
* Called if a key is released when the widget has keyboard focus.
*
* @param keyEvent Discribes the event.
*/
- virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) { }
+ virtual void keyReleased(KeyEvent& keyEvent A_UNUSED)
+ { }
protected:
/**
@@ -95,7 +98,8 @@ namespace gcn
* You should not be able to make an instance of KeyListener,
* therefore its constructor is protected.
*/
- KeyListener() { }
+ KeyListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/listmodel.hpp b/src/guichan/include/guichan/listmodel.hpp
index 612a5d4bd..bf139afb1 100644
--- a/src/guichan/include/guichan/listmodel.hpp
+++ b/src/guichan/include/guichan/listmodel.hpp
@@ -65,7 +65,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~ListModel() { }
+ virtual ~ListModel()
+ { }
/**
* Gets the number of elements in the list.
diff --git a/src/guichan/include/guichan/mouselistener.hpp b/src/guichan/include/guichan/mouselistener.hpp
index 2f12ecdac..b78f529e9 100644
--- a/src/guichan/include/guichan/mouselistener.hpp
+++ b/src/guichan/include/guichan/mouselistener.hpp
@@ -69,7 +69,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~MouseListener() { }
+ virtual ~MouseListener()
+ { }
/**
* Called when the mouse has entered into the widget area.
@@ -183,7 +184,8 @@ namespace gcn
* You should not be able to make an instance of MouseListener,
* therefore its constructor is protected.
*/
- MouseListener() { }
+ MouseListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp
index a0221ca7c..23298ef37 100644
--- a/src/guichan/include/guichan/sdl/sdlpixel.hpp
+++ b/src/guichan/include/guichan/sdl/sdlpixel.hpp
@@ -68,7 +68,8 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
unsigned int color = 0;
@@ -79,7 +80,7 @@ namespace gcn
break;
case 2:
- color = *(Uint16 *)p;
+ color = *reinterpret_cast<Uint16*>(p);
break;
case 3:
@@ -90,7 +91,7 @@ namespace gcn
break;
case 4:
- color = *(Uint32 *)p;
+ color = *reinterpret_cast<Uint32*>(p);
break;
default:
@@ -123,7 +124,8 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
@@ -134,7 +136,7 @@ namespace gcn
break;
case 2:
- *(Uint16 *)p = pixel;
+ *reinterpret_cast<Uint16*>(p) = pixel;
break;
case 3:
@@ -153,7 +155,7 @@ namespace gcn
break;
case 4:
- *(Uint32 *)p = pixel;
+ *reinterpret_cast<Uint32*>(p) = pixel;
break;
default:
@@ -199,7 +201,7 @@ namespace gcn
unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
* (255 - a)) >> 8;
- return (unsigned short)((b & f->Rmask)
+ return static_cast<unsigned short>((b & f->Rmask)
| (g & f->Gmask) | (r & f->Bmask));
}
@@ -230,7 +232,8 @@ namespace gcn
SDL_LockSurface(surface);
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+ Uint8 *p = static_cast<Uint8*>(surface->pixels)
+ + y * surface->pitch + x * bpp;
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
@@ -241,8 +244,8 @@ namespace gcn
break;
case 2:
- *(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:
@@ -275,7 +278,8 @@ namespace gcn
break;
case 4:
- *(Uint32 *)p = SDLAlpha32(pixel, *(Uint32 *)p, color.a);
+ *reinterpret_cast<Uint32*>(p) = SDLAlpha32(pixel,
+ *reinterpret_cast<Uint32*>(p), color.a);
break;
default:
break;
diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp
index 69126e3df..b6146b791 100644
--- a/src/guichan/include/guichan/widget.hpp
+++ b/src/guichan/include/guichan/widget.hpp
@@ -173,7 +173,8 @@ namespace gcn
* @see Gui::logic
* @since 0.1.0
*/
- virtual void logic() { }
+ virtual void logic()
+ { }
/**
* Gets the widget's parent container.
@@ -686,7 +687,8 @@ namespace gcn
*
* @since 0.1.0
*/
- virtual void fontChanged() { }
+ virtual void fontChanged()
+ { }
/**
* Checks if a widget exists or not, that is if it still exists
@@ -895,7 +897,8 @@ namespace gcn
* @see moveToBottom
* @since 0.1.0
*/
- virtual void moveToTop(Widget* widget A_UNUSED) { };
+ virtual void moveToTop(Widget* widget A_UNUSED)
+ { };
/**
* Moves a widget in this widget to the bottom of this widget.
@@ -905,7 +908,8 @@ namespace gcn
* @see moveToTop
* @since 0.1.0
*/
- virtual void moveToBottom(Widget* widget A_UNUSED) { };
+ virtual void moveToBottom(Widget* widget A_UNUSED)
+ { };
/**
* Focuses the next widget in the widget.
@@ -913,7 +917,8 @@ namespace gcn
* @see moveToBottom
* @since 0.1.0
*/
- virtual void focusNext() { };
+ virtual void focusNext()
+ { };
/**
* Focuses the previous widget in the widget.
@@ -921,7 +926,8 @@ namespace gcn
* @see moveToBottom
* @since 0.1.0
*/
- virtual void focusPrevious() { };
+ virtual void focusPrevious()
+ { };
/**
* Tries to show a specific part of a widget by moving it. Used if the
diff --git a/src/guichan/include/guichan/widgetlistener.hpp b/src/guichan/include/guichan/widgetlistener.hpp
index 0ede5b871..f0cb60fd3 100644
--- a/src/guichan/include/guichan/widgetlistener.hpp
+++ b/src/guichan/include/guichan/widgetlistener.hpp
@@ -74,7 +74,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~WidgetListener() { }
+ virtual ~WidgetListener()
+ { }
/**
* Invoked when a widget changes its size.
@@ -82,7 +83,8 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
- virtual void widgetResized(const Event& event A_UNUSED) { }
+ virtual void widgetResized(const Event& event A_UNUSED)
+ { }
/**
* Invoked when a widget is moved.
@@ -90,7 +92,8 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
- virtual void widgetMoved(const Event& event A_UNUSED) { }
+ virtual void widgetMoved(const Event& event A_UNUSED)
+ { }
/**
* Invoked when a widget is hidden, i.e it's set to be
@@ -99,7 +102,8 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
- virtual void widgetHidden(const Event& event A_UNUSED) { }
+ virtual void widgetHidden(const Event& event A_UNUSED)
+ { }
/**
* Invoked when a widget is shown, i.e it's set to be
@@ -108,7 +112,8 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
- virtual void widgetShown(const Event& event A_UNUSED) { }
+ virtual void widgetShown(const Event& event A_UNUSED)
+ { }
protected:
/**
@@ -117,8 +122,8 @@ namespace gcn
* You should not be able to make an instance of WidgetListener,
* therefore its constructor is protected.
*/
- WidgetListener() { }
-
+ WidgetListener()
+ { }
};
}
diff --git a/src/guichan/include/guichan/widgets/listbox.hpp b/src/guichan/include/guichan/widgets/listbox.hpp
index 1e73c2214..ce056acbd 100644
--- a/src/guichan/include/guichan/widgets/listbox.hpp
+++ b/src/guichan/include/guichan/widgets/listbox.hpp
@@ -89,7 +89,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~ListBox() { }
+ virtual ~ListBox()
+ { }
/**
* Gets the selected item as an index in the list model.
diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp
index 77b0b8806..a22c36844 100644
--- a/src/guichan/include/guichan/widgets/slider.hpp
+++ b/src/guichan/include/guichan/widgets/slider.hpp
@@ -94,7 +94,8 @@ namespace gcn
/**
* Destructor.
*/
- virtual ~Slider() { }
+ virtual ~Slider()
+ { }
/**
* Sets the scale of the slider.
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 e4aadc465..cf8505c4e 100644
--- a/src/guichan/sdl/sdlimage.cpp
+++ b/src/guichan/sdl/sdlimage.cpp
@@ -130,8 +130,8 @@ namespace gcn
for (i = 0; i < mSurface->w * mSurface->h; ++i)
{
- if (((unsigned int*)mSurface->pixels)[i] == SDL_MapRGB(
- mSurface->format, 255, 0, 255))
+ if ((static_cast<unsigned int*>(mSurface->pixels))[i]
+ == SDL_MapRGB(mSurface->format, 255, 0, 255))
{
hasPink = true;
break;
@@ -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)