summaryrefslogtreecommitdiff
path: root/src/guichan
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-07 19:34:52 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-07 19:34:52 +0300
commit9e83411f7e4147d09af5a5006888dcc187ea0ef8 (patch)
treec084bdf8afabc6220779645dcb5dbf71af6a151f /src/guichan
parentbc7d91cc0c9c0f6dcad01d612932c6899afb5514 (diff)
downloadmanaverse-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.gz
manaverse-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.bz2
manaverse-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.xz
manaverse-9e83411f7e4147d09af5a5006888dcc187ea0ef8.zip
Fix some warnings under gcc 4.7.
Diffstat (limited to 'src/guichan')
-rw-r--r--src/guichan/basiccontainer.cpp24
-rw-r--r--src/guichan/focushandler.cpp68
-rw-r--r--src/guichan/graphics.cpp4
-rw-r--r--src/guichan/gui.cpp100
-rw-r--r--src/guichan/image.cpp4
-rw-r--r--src/guichan/sdl/sdlgraphics.cpp4
-rw-r--r--src/guichan/sdl/sdlimage.cpp18
-rw-r--r--src/guichan/widget.cpp36
-rw-r--r--src/guichan/widgets/dropdown.cpp16
-rw-r--r--src/guichan/widgets/icon.cpp8
-rw-r--r--src/guichan/widgets/imagebutton.cpp8
-rw-r--r--src/guichan/widgets/listbox.cpp8
-rw-r--r--src/guichan/widgets/scrollarea.cpp14
-rw-r--r--src/guichan/widgets/tab.cpp6
-rw-r--r--src/guichan/widgets/tabbedarea.cpp16
-rw-r--r--src/guichan/widgets/textbox.cpp4
-rw-r--r--src/guichan/widgets/window.cpp2
17 files changed, 165 insertions, 175 deletions
diff --git a/src/guichan/basiccontainer.cpp b/src/guichan/basiccontainer.cpp
index 439535c9a..a36ab5f9b 100644
--- a/src/guichan/basiccontainer.cpp
+++ b/src/guichan/basiccontainer.cpp
@@ -173,7 +173,7 @@ namespace gcn
Rectangle r = getChildrenArea();
if (!r.isPointInRect(x, y))
- return NULL;
+ return nullptr;
x -= r.x;
y -= r.y;
@@ -188,7 +188,7 @@ namespace gcn
}
}
- return NULL;
+ return nullptr;
}
void BasicContainer::logic()
@@ -200,7 +200,7 @@ namespace gcn
{
Widget::_setFocusHandler(focusHandler);
- if (mInternalFocusHandler != NULL)
+ if (mInternalFocusHandler)
return;
WidgetListConstIterator iter;
@@ -214,7 +214,7 @@ namespace gcn
{
mWidgets.push_back(widget);
- if (mInternalFocusHandler == NULL)
+ if (!mInternalFocusHandler)
widget->_setFocusHandler(_getFocusHandler());
else
widget->_setFocusHandler(mInternalFocusHandler);
@@ -231,8 +231,8 @@ namespace gcn
if (*iter == widget)
{
mWidgets.erase(iter);
- widget->_setFocusHandler(NULL);
- widget->_setParent(NULL);
+ widget->_setFocusHandler(nullptr);
+ widget->_setParent(nullptr);
widget->removeDeathListener(this);
return;
}
@@ -247,8 +247,8 @@ namespace gcn
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter)
{
- (*iter)->_setFocusHandler(NULL);
- (*iter)->_setParent(NULL);
+ (*iter)->_setFocusHandler(nullptr);
+ (*iter)->_setParent(nullptr);
(*iter)->removeDeathListener(this);
}
@@ -327,7 +327,7 @@ namespace gcn
WidgetListConstIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++ iter)
{
- if (mInternalFocusHandler == NULL)
+ if (!mInternalFocusHandler)
(*iter)->_setFocusHandler(_getFocusHandler());
else
(*iter)->_setFocusHandler(mInternalFocusHandler);
@@ -345,15 +345,15 @@ namespace gcn
BasicContainer *basicContainer
= dynamic_cast<BasicContainer*>(*iter);
- if (basicContainer != NULL)
+ if (basicContainer)
{
Widget *widget = basicContainer->findWidgetById(id);
- if (widget != NULL)
+ if (widget)
return widget;
}
}
- return NULL;
+ return nullptr;
}
}
diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp
index 367eed6b1..b1da9e77e 100644
--- a/src/guichan/focushandler.cpp
+++ b/src/guichan/focushandler.cpp
@@ -56,24 +56,21 @@
namespace gcn
{
FocusHandler::FocusHandler() :
- mFocusedWidget(NULL),
- mModalFocusedWidget(NULL),
- mModalMouseInputFocusedWidget(NULL),
- mDraggedWidget(NULL),
- mLastWidgetWithMouse(NULL),
- mLastWidgetWithModalFocus(NULL),
- mLastWidgetWithModalMouseInputFocus(NULL),
- mLastWidgetPressed(NULL)
+ mFocusedWidget(nullptr),
+ mModalFocusedWidget(nullptr),
+ mModalMouseInputFocusedWidget(nullptr),
+ mDraggedWidget(nullptr),
+ mLastWidgetWithMouse(nullptr),
+ mLastWidgetWithModalFocus(nullptr),
+ mLastWidgetWithModalMouseInputFocus(nullptr),
+ mLastWidgetPressed(nullptr)
{
}
void FocusHandler::requestFocus(Widget* widget)
{
- if (widget == NULL
- || widget == mFocusedWidget)
- {
+ if (!widget || widget == mFocusedWidget)
return;
- }
unsigned int i = 0;
int toBeFocusedIndex = -1;
@@ -95,7 +92,7 @@ namespace gcn
{
mFocusedWidget = mWidgets.at(toBeFocusedIndex);
- if (oldFocused != NULL)
+ if (oldFocused)
{
Event focusEvent(oldFocused);
distributeFocusLostEvent(focusEvent);
@@ -108,21 +105,18 @@ namespace gcn
void FocusHandler::requestModalFocus(Widget* widget)
{
- if (mModalFocusedWidget != NULL && mModalFocusedWidget != widget)
+ if (mModalFocusedWidget && mModalFocusedWidget != widget)
throw GCN_EXCEPTION("Another widget already has modal focus.");
mModalFocusedWidget = widget;
- if (mFocusedWidget != NULL
- && !mFocusedWidget->isModalFocused())
- {
+ if (mFocusedWidget && !mFocusedWidget->isModalFocused())
focusNone();
- }
}
void FocusHandler::requestModalMouseInputFocus(Widget* widget)
{
- if (mModalMouseInputFocusedWidget != NULL
+ if (mModalMouseInputFocusedWidget
&& mModalMouseInputFocusedWidget != widget)
{
throw GCN_EXCEPTION("Another widget already has "
@@ -135,13 +129,13 @@ namespace gcn
void FocusHandler::releaseModalFocus(Widget* widget)
{
if (mModalFocusedWidget == widget)
- mModalFocusedWidget = NULL;
+ mModalFocusedWidget = nullptr;
}
void FocusHandler::releaseModalMouseInputFocus(Widget* widget)
{
if (mModalMouseInputFocusedWidget == widget)
- mModalMouseInputFocusedWidget = NULL;
+ mModalMouseInputFocusedWidget = nullptr;
}
Widget* FocusHandler::getFocused() const
@@ -212,7 +206,7 @@ namespace gcn
{
if (mWidgets.empty())
{
- mFocusedWidget = NULL;
+ mFocusedWidget = nullptr;
return;
}
@@ -275,9 +269,7 @@ namespace gcn
void FocusHandler::remove(Widget* widget)
{
if (isFocused(widget))
- {
- mFocusedWidget = NULL;
- }
+ mFocusedWidget = nullptr;
WidgetIterator iter;
@@ -292,41 +284,41 @@ namespace gcn
if (mDraggedWidget == widget)
{
- mDraggedWidget = NULL;
+ mDraggedWidget = nullptr;
return;
}
if (mLastWidgetWithMouse == widget)
{
- mLastWidgetWithMouse = NULL;
+ mLastWidgetWithMouse = nullptr;
return;
}
if (mLastWidgetWithModalFocus == widget)
{
- mLastWidgetWithModalFocus = NULL;
+ mLastWidgetWithModalFocus = nullptr;
return;
}
if (mLastWidgetWithModalMouseInputFocus == widget)
{
- mLastWidgetWithModalMouseInputFocus = NULL;
+ mLastWidgetWithModalMouseInputFocus = nullptr;
return;
}
if (mLastWidgetPressed == widget)
{
- mLastWidgetPressed = NULL;
+ mLastWidgetPressed = nullptr;
return;
}
}
void FocusHandler::focusNone()
{
- if (mFocusedWidget != NULL)
+ if (mFocusedWidget)
{
Widget* focused = mFocusedWidget;
- mFocusedWidget = NULL;
+ mFocusedWidget = nullptr;
Event focusEvent(focused);
distributeFocusLostEvent(focusEvent);
@@ -335,7 +327,7 @@ namespace gcn
void FocusHandler::tabNext()
{
- if (mFocusedWidget != NULL)
+ if (mFocusedWidget)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -343,7 +335,7 @@ namespace gcn
if (mWidgets.empty())
{
- mFocusedWidget = NULL;
+ mFocusedWidget = nullptr;
return;
}
@@ -380,7 +372,7 @@ namespace gcn
if (mWidgets.at(focusedWidget)->isFocusable() &&
mWidgets.at(focusedWidget)->isTabInEnabled() &&
- (mModalFocusedWidget == NULL ||
+ (!mModalFocusedWidget ||
mWidgets.at(focusedWidget)->isModalFocused()))
{
done = true;
@@ -404,7 +396,7 @@ namespace gcn
void FocusHandler::tabPrevious()
{
- if (mFocusedWidget != NULL)
+ if (mFocusedWidget)
{
if (!mFocusedWidget->isTabOutEnabled())
return;
@@ -412,7 +404,7 @@ namespace gcn
if (mWidgets.empty())
{
- mFocusedWidget = NULL;
+ mFocusedWidget = nullptr;
return;
}
@@ -449,7 +441,7 @@ namespace gcn
if (mWidgets.at(focusedWidget)->isFocusable() &&
mWidgets.at(focusedWidget)->isTabInEnabled() &&
- (mModalFocusedWidget == NULL ||
+ (!mModalFocusedWidget ||
mWidgets.at(focusedWidget)->isModalFocused()))
{
done = true;
diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp
index d09050a10..c57b5d5c0 100644
--- a/src/guichan/graphics.cpp
+++ b/src/guichan/graphics.cpp
@@ -57,7 +57,7 @@ namespace gcn
{
Graphics::Graphics() :
- mFont(NULL)
+ mFont(nullptr)
{
}
@@ -155,7 +155,7 @@ namespace gcn
void Graphics::drawText(const std::string& text, int x, int y,
Alignment alignment)
{
- if (mFont == NULL)
+ if (!mFont)
throw GCN_EXCEPTION("No font set.");
switch (alignment)
diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp
index 0c81182ea..810a983c4 100644
--- a/src/guichan/gui.cpp
+++ b/src/guichan/gui.cpp
@@ -63,9 +63,9 @@
namespace gcn
{
Gui::Gui() :
- mTop(NULL),
- mGraphics(NULL),
- mInput(NULL),
+ mTop(nullptr),
+ mGraphics(nullptr),
+ mInput(nullptr),
mTabbing(true),
mShiftPressed(false),
mMetaPressed(false),
@@ -84,17 +84,17 @@ namespace gcn
Gui::~Gui()
{
if (Widget::widgetExists(mTop))
- setTop(NULL);
+ setTop(nullptr);
delete mFocusHandler;
- mFocusHandler = 0;
+ mFocusHandler = nullptr;
}
void Gui::setTop(Widget* top)
{
- if (mTop != NULL)
- mTop->_setFocusHandler(NULL);
- if (top != NULL)
+ if (mTop)
+ mTop->_setFocusHandler(nullptr);
+ if (top)
top->_setFocusHandler(mFocusHandler);
mTop = top;
@@ -127,13 +127,13 @@ namespace gcn
void Gui::logic()
{
- if (mTop == NULL)
+ if (!mTop)
throw GCN_EXCEPTION("No top widget set");
handleModalFocus();
handleModalMouseInputFocus();
- if (mInput != NULL)
+ if (mInput)
{
mInput->_pollInput();
@@ -147,9 +147,9 @@ namespace gcn
void Gui::draw()
{
- if (mTop == NULL)
+ if (!mTop)
throw GCN_EXCEPTION("No top widget set");
- if (mGraphics == NULL)
+ if (!mGraphics)
throw GCN_EXCEPTION("No graphics set");
if (!mTop->isVisible())
@@ -250,7 +250,7 @@ namespace gcn
mControlPressed = keyInput.isControlPressed();
mAltPressed = keyInput.isAltPressed();
- KeyEvent keyEventToGlobalKeyListeners(NULL,
+ KeyEvent keyEventToGlobalKeyListeners(nullptr,
mShiftPressed,
mControlPressed,
mAltPressed,
@@ -270,7 +270,7 @@ namespace gcn
bool keyEventConsumed = false;
// Send key inputs to the focused widgets
- if (mFocusHandler->getFocused() != NULL)
+ if (mFocusHandler->getFocused())
{
KeyEvent keyEvent(getKeyEventSource(),
mShiftPressed,
@@ -400,7 +400,7 @@ namespace gcn
// widget with modal mouse input focus, hence we need to check if
// that's the case. If it's not we should simply ignore to send any
// mouse entered events.
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& widget == mFocusHandler->getModalMouseInputFocused()
&& Widget::widgetExists(widget))
{
@@ -411,11 +411,11 @@ namespace gcn
|| x + widget->getWidth() <= mouseInput.getX()
|| y + widget->getHeight() <= mouseInput.getY())
{
- parent = NULL;
+ parent = nullptr;
}
}
- while (parent != NULL)
+ while (parent)
{
parent = (Widget*)widget->getParent();
@@ -453,7 +453,7 @@ namespace gcn
parent = (Widget*)swap->getParent();
}
- if (mFocusHandler->getDraggedWidget() != NULL)
+ if (mFocusHandler->getDraggedWidget())
{
distributeMouseEvent(mFocusHandler->getDraggedWidget(),
MouseEvent::DRAGGED,
@@ -479,15 +479,15 @@ namespace gcn
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget() != NULL)
+ if (mFocusHandler->getDraggedWidget())
sourceWidget = mFocusHandler->getDraggedWidget();
int sourceWidgetX, sourceWidgetY;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
- if ((mFocusHandler->getModalFocused() != NULL
+ if ((mFocusHandler->getModalFocused()
&& sourceWidget->isModalFocused())
- || mFocusHandler->getModalFocused() == NULL)
+ || !mFocusHandler->getModalFocused())
{
sourceWidget->requestFocus();
}
@@ -522,7 +522,7 @@ namespace gcn
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget() != NULL)
+ if (mFocusHandler->getDraggedWidget())
sourceWidget = mFocusHandler->getDraggedWidget();
int sourceWidgetX, sourceWidgetY;
@@ -540,7 +540,7 @@ namespace gcn
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget() != NULL)
+ if (mFocusHandler->getDraggedWidget())
sourceWidget = mFocusHandler->getDraggedWidget();
int sourceWidgetX, sourceWidgetY;
@@ -558,10 +558,10 @@ namespace gcn
Widget* sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
- if (mFocusHandler->getDraggedWidget() != NULL)
+ if (mFocusHandler->getDraggedWidget())
{
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
- mFocusHandler->setLastWidgetPressed(NULL);
+ mFocusHandler->setLastWidgetPressed(nullptr);
sourceWidget = mFocusHandler->getDraggedWidget();
}
@@ -584,7 +584,7 @@ namespace gcn
mouseInput.getX(),
mouseInput.getY());
- mFocusHandler->setLastWidgetPressed(NULL);
+ mFocusHandler->setLastWidgetPressed(nullptr);
}
else
{
@@ -592,8 +592,8 @@ namespace gcn
mClickCount = 0;
}
- if (mFocusHandler->getDraggedWidget() != NULL)
- mFocusHandler->setDraggedWidget(NULL);
+ if (mFocusHandler->getDraggedWidget())
+ mFocusHandler->setDraggedWidget(nullptr);
}
Widget* Gui::getWidgetAt(int x, int y)
@@ -602,7 +602,7 @@ namespace gcn
Widget* parent = mTop;
Widget* child = mTop;
- while (child != NULL)
+ while (child)
{
Widget* swap = child;
int parentX, parentY;
@@ -618,7 +618,7 @@ namespace gcn
{
Widget* widget = getWidgetAt(x, y);
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& !widget->isModalMouseInputFocused())
{
return mFocusHandler->getModalMouseInputFocused();
@@ -631,8 +631,8 @@ namespace gcn
{
Widget* widget = mFocusHandler->getFocused();
- while (widget->_getInternalFocusHandler() != NULL
- && widget->_getInternalFocusHandler()->getFocused() != NULL)
+ while (widget->_getInternalFocusHandler()
+ && widget->_getInternalFocusHandler()->getFocused())
{
widget = widget->_getInternalFocusHandler()->getFocused();
}
@@ -651,14 +651,14 @@ namespace gcn
Widget* parent = source;
Widget* widget = source;
- if (mFocusHandler->getModalFocused() != NULL
+ if (mFocusHandler->getModalFocused()
&& !widget->isModalFocused()
&& !force)
{
return;
}
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& !widget->isModalMouseInputFocused()
&& !force)
{
@@ -676,7 +676,7 @@ namespace gcn
y,
mClickCount);
- while (parent != NULL)
+ while (parent)
{
// If the widget has been removed due to input
// cancel the distribution.
@@ -746,7 +746,7 @@ namespace gcn
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (mFocusHandler->getModalFocused() != NULL
+ if (mFocusHandler->getModalFocused()
&& !widget->isModalFocused())
{
break;
@@ -754,7 +754,7 @@ namespace gcn
// If a non modal mouse input focused widget has been reach
// and we have modal mouse input focus cancel the distribution.
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& !widget->isModalMouseInputFocused())
{
break;
@@ -767,26 +767,24 @@ namespace gcn
Widget* parent = keyEvent.getSource();
Widget* widget = keyEvent.getSource();
- if (mFocusHandler->getModalFocused() != NULL
+ if (mFocusHandler->getModalFocused()
&& !widget->isModalFocused())
{
return;
}
- if (mFocusHandler->getModalMouseInputFocused() != NULL
+ if (mFocusHandler->getModalMouseInputFocused()
&& !widget->isModalMouseInputFocused())
{
return;
}
- while (parent != NULL)
+ while (parent)
{
// If the widget has been removed due to input
// cancel the distribution.
if (!Widget::widgetExists(widget))
- {
break;
- }
parent = (Widget*)widget->getParent();
@@ -821,7 +819,7 @@ namespace gcn
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
- if (mFocusHandler->getModalFocused() != NULL
+ if (mFocusHandler->getModalFocused()
&& !widget->isModalFocused())
{
break;
@@ -857,8 +855,7 @@ namespace gcn
// Check if modal mouse input focus has been gained by a widget.
if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused())
- && (mFocusHandler->getLastWidgetWithModalMouseInputFocus()
- == NULL))
+ && (!mFocusHandler->getLastWidgetWithModalMouseInputFocus()))
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalMouseInputFocus(
@@ -867,11 +864,10 @@ namespace gcn
// Check if modal mouse input focus has been released.
else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused())
- && (mFocusHandler->getLastWidgetWithModalMouseInputFocus()
- != NULL))
+ && (mFocusHandler->getLastWidgetWithModalMouseInputFocus()))
{
handleModalFocusReleased();
- mFocusHandler->setLastWidgetWithModalMouseInputFocus(NULL);
+ mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr);
}
}
@@ -880,7 +876,7 @@ namespace gcn
// Check if modal focus has been gained by a widget.
if ((mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused())
- && (mFocusHandler->getLastWidgetWithModalFocus() == NULL))
+ && (!mFocusHandler->getLastWidgetWithModalFocus()))
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalFocus(
@@ -889,10 +885,10 @@ namespace gcn
// Check if modal focus has been released.
else if ((mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused())
- && (mFocusHandler->getLastWidgetWithModalFocus() != NULL))
+ && (mFocusHandler->getLastWidgetWithModalFocus()))
{
handleModalFocusReleased();
- mFocusHandler->setLastWidgetWithModalFocus(NULL);
+ mFocusHandler->setLastWidgetWithModalFocus(nullptr);
}
}
@@ -930,7 +926,7 @@ namespace gcn
Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
Widget* parent = widget;
- while (parent != NULL)
+ while (parent)
{
parent = (Widget*)widget->getParent();
diff --git a/src/guichan/image.cpp b/src/guichan/image.cpp
index 2c15151a2..837840435 100644
--- a/src/guichan/image.cpp
+++ b/src/guichan/image.cpp
@@ -55,7 +55,7 @@
namespace gcn
{
- ImageLoader* Image::mImageLoader = NULL;
+ ImageLoader* Image::mImageLoader = nullptr;
Image::Image()
{
@@ -78,7 +78,7 @@ namespace gcn
Image* Image::load(const std::string& filename,
bool convertToDisplayFormat)
{
- if (mImageLoader == NULL)
+ if (!mImageLoader)
{
throw GCN_EXCEPTION("Trying to load an image but "
"no image loader is set.");
diff --git a/src/guichan/sdl/sdlgraphics.cpp b/src/guichan/sdl/sdlgraphics.cpp
index 28aface0e..67aa657cd 100644
--- a/src/guichan/sdl/sdlgraphics.cpp
+++ b/src/guichan/sdl/sdlgraphics.cpp
@@ -65,7 +65,7 @@ namespace gcn
{
SDLGraphics::SDLGraphics() :
- mTarget(0),
+ mTarget(nullptr),
mAlpha(false)
{
}
@@ -155,7 +155,7 @@ namespace gcn
const SDLImage* srcImage = dynamic_cast<const SDLImage*>(image);
- if (srcImage == NULL)
+ if (!srcImage)
{
throw GCN_EXCEPTION("Trying to draw an image of unknown format,"
" must be an SDLImage.");
diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp
index 12c5571cf..156b399b3 100644
--- a/src/guichan/sdl/sdlimage.cpp
+++ b/src/guichan/sdl/sdlimage.cpp
@@ -50,6 +50,8 @@
#include "guichan/exception.hpp"
#include "guichan/sdl/sdlpixel.hpp"
+#include "debug.h"
+
namespace gcn
{
SDLImage::SDLImage(SDL_Surface* surface, bool autoFree)
@@ -71,7 +73,7 @@ namespace gcn
int SDLImage::getWidth() const
{
- if (mSurface == NULL)
+ if (!mSurface)
{
throw GCN_EXCEPTION("Trying to get the width of "
"a non loaded image.");
@@ -82,7 +84,7 @@ namespace gcn
int SDLImage::getHeight() const
{
- if (mSurface == NULL)
+ if (!mSurface)
{
throw GCN_EXCEPTION("Trying to get the height of "
"a non loaded image.");
@@ -93,7 +95,7 @@ namespace gcn
Color SDLImage::getPixel(int x, int y)
{
- if (mSurface == NULL)
+ if (!mSurface)
{
throw GCN_EXCEPTION("Trying to get a pixel from a "
"non loaded image.");
@@ -104,7 +106,7 @@ namespace gcn
void SDLImage::putPixel(int x, int y, const Color& color)
{
- if (mSurface == NULL)
+ if (!mSurface)
{
throw GCN_EXCEPTION("Trying to put a pixel in a "
"non loaded image.");
@@ -115,7 +117,7 @@ namespace gcn
void SDLImage::convertToDisplayFormat()
{
- if (mSurface == NULL)
+ if (!mSurface)
{
throw GCN_EXCEPTION("Trying to convert a non loaded image "
"to display format.");
@@ -155,16 +157,16 @@ namespace gcn
{
tmp = SDL_DisplayFormatAlpha(mSurface);
SDL_FreeSurface(mSurface);
- mSurface = NULL;
+ mSurface = nullptr;
}
else
{
tmp = SDL_DisplayFormat(mSurface);
SDL_FreeSurface(mSurface);
- mSurface = NULL;
+ mSurface = nullptr;
}
- if (tmp == NULL)
+ if (!tmp)
throw GCN_EXCEPTION("Unable to convert image to display format.");
if (hasPink)
diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp
index 1b2b3295b..571644aa4 100644
--- a/src/guichan/widget.cpp
+++ b/src/guichan/widget.cpp
@@ -66,7 +66,7 @@
namespace gcn
{
- Font* Widget::mGlobalFont = NULL;
+ Font* Widget::mGlobalFont = nullptr;
DefaultFont Widget::mDefaultFont;
std::list<Widget*> Widget::mWidgets;
std::set<Widget*> Widget::mWidgetsSet;
@@ -76,16 +76,16 @@ namespace gcn
mBackgroundColor(0xffffff),
mBaseColor(0x808090),
mSelectionColor(0xc3d9ff),
- mFocusHandler(NULL),
- mInternalFocusHandler(NULL),
- mParent(NULL),
+ mFocusHandler(nullptr),
+ mInternalFocusHandler(nullptr),
+ mParent(nullptr),
mFrameSize(0),
mFocusable(false),
mVisible(true),
mTabIn(true),
mTabOut(true),
mEnabled(true),
- mCurrentFont(NULL)
+ mCurrentFont(nullptr)
{
mWidgets.push_back(this);
mWidgetsSet.insert(this);
@@ -103,7 +103,7 @@ namespace gcn
(*iter)->death(event);
}
- _setFocusHandler(NULL);
+ _setFocusHandler(nullptr);
mWidgets.remove(this);
mWidgetsSet.erase(this);
@@ -272,7 +272,7 @@ namespace gcn
void Widget::requestFocus()
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
{
throw GCN_EXCEPTION("No focushandler set (did you add "
"the widget to the gui?).");
@@ -455,9 +455,9 @@ namespace gcn
Font* Widget::getFont() const
{
- if (mCurrentFont == NULL)
+ if (!mCurrentFont)
{
- if (mGlobalFont == NULL)
+ if (!mGlobalFont)
return &mDefaultFont;
return mGlobalFont;
@@ -473,7 +473,7 @@ namespace gcn
std::list<Widget*>::const_iterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
- if ((*iter)->mCurrentFont == NULL)
+ if (!(*iter)->mCurrentFont)
(*iter)->fontChanged();
}
}
@@ -531,7 +531,7 @@ namespace gcn
void Widget::requestModalFocus()
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
{
throw GCN_EXCEPTION("No focushandler set (did you add "
"the widget to the gui?).");
@@ -542,7 +542,7 @@ namespace gcn
void Widget::requestModalMouseInputFocus()
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
{
throw GCN_EXCEPTION("No focushandler set (did you add "
"the widget to the gui?).");
@@ -553,7 +553,7 @@ namespace gcn
void Widget::releaseModalFocus()
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
return;
mFocusHandler->releaseModalFocus(this);
@@ -561,7 +561,7 @@ namespace gcn
void Widget::releaseModalMouseInputFocus()
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
return;
mFocusHandler->releaseModalMouseInputFocus(this);
@@ -569,7 +569,7 @@ namespace gcn
bool Widget::isModalFocused() const
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
{
throw GCN_EXCEPTION("No focushandler set (did you add "
"the widget to the gui?).");
@@ -586,7 +586,7 @@ namespace gcn
bool Widget::isModalMouseInputFocused() const
{
- if (mFocusHandler == NULL)
+ if (!mFocusHandler)
{
throw GCN_EXCEPTION("No focushandler set (did you add "
"the widget to the gui?).");
@@ -603,7 +603,7 @@ namespace gcn
Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED)
{
- return NULL;
+ return nullptr;
}
const std::list<MouseListener*>& Widget::_getMouseListeners()
@@ -712,7 +712,7 @@ namespace gcn
void Widget::showPart(Rectangle rectangle)
{
- if (mParent != NULL)
+ if (mParent)
mParent->showWidgetPart(this, rectangle);
}
}
diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp
index 3ecbd75d8..17513931f 100644
--- a/src/guichan/widgets/dropdown.cpp
+++ b/src/guichan/widgets/dropdown.cpp
@@ -68,8 +68,8 @@ namespace gcn
setInternalFocusHandler(&mInternalFocusHandler);
- mInternalScrollArea = (scrollArea == NULL);
- mInternalListBox = (listBox == NULL);
+ mInternalScrollArea = (!scrollArea);
+ mInternalListBox = (!listBox);
if (mInternalScrollArea)
mScrollArea = new ScrollArea();
@@ -110,16 +110,16 @@ namespace gcn
if (mInternalScrollArea)
{
delete mScrollArea;
- mScrollArea = 0;
+ mScrollArea = nullptr;
}
if (mInternalListBox)
{
delete mListBox;
- mListBox = 0;
+ mListBox = nullptr;
}
- setInternalFocusHandler(NULL);
+ setInternalFocusHandler(nullptr);
}
int DropDown::getSelected() const
@@ -223,10 +223,10 @@ namespace gcn
void DropDown::adjustHeight()
{
- if (mScrollArea == NULL)
+ if (!mScrollArea)
throw GCN_EXCEPTION("Scroll area has been deleted.");
- if (mListBox == NULL)
+ if (!mListBox)
throw GCN_EXCEPTION("List box has been deleted.");
int listBoxHeight = mListBox->getHeight();
@@ -296,7 +296,7 @@ namespace gcn
void DropDown::death(const Event& event)
{
if (event.getSource() == mScrollArea)
- mScrollArea = NULL;
+ mScrollArea = nullptr;
BasicContainer::death(event);
}
diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp
index 2983c7c29..13a9f1309 100644
--- a/src/guichan/widgets/icon.cpp
+++ b/src/guichan/widgets/icon.cpp
@@ -56,14 +56,14 @@
namespace gcn
{
Icon::Icon()
- : mImage(0)
+ : mImage(nullptr)
, mInternalImage(false)
{
setSize(0, 0);
}
Icon::Icon(const std::string& filename)
- : mImage(0),
+ : mImage(nullptr),
mInternalImage(false)
{
mImage = Image::load(filename);
@@ -85,7 +85,7 @@ namespace gcn
if (mInternalImage)
{
delete mImage;
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -107,7 +107,7 @@ namespace gcn
void Icon::draw(Graphics* graphics)
{
- if (mImage != NULL)
+ if (mImage)
{
const int x = (getWidth() - mImage->getWidth()) / 2;
const int y = (getHeight() - mImage->getHeight()) / 2;
diff --git a/src/guichan/widgets/imagebutton.cpp b/src/guichan/widgets/imagebutton.cpp
index 2f4c5dcde..feeed795d 100644
--- a/src/guichan/widgets/imagebutton.cpp
+++ b/src/guichan/widgets/imagebutton.cpp
@@ -55,7 +55,7 @@
namespace gcn
{
ImageButton::ImageButton() :
- mImage(0),
+ mImage(nullptr),
mInternalImage(false)
{
setWidth(0);
@@ -63,7 +63,7 @@ namespace gcn
}
ImageButton::ImageButton(const std::string& filename) :
- mImage(0),
+ mImage(nullptr),
mInternalImage(false)
{
mImage = Image::load(filename);
@@ -85,7 +85,7 @@ namespace gcn
if (mInternalImage)
{
delete mImage;
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -94,7 +94,7 @@ namespace gcn
if (mInternalImage)
{
delete mImage;
- mImage = 0;
+ mImage = nullptr;
}
mImage = image;
diff --git a/src/guichan/widgets/listbox.cpp b/src/guichan/widgets/listbox.cpp
index 95f04fc68..80989cc72 100644
--- a/src/guichan/widgets/listbox.cpp
+++ b/src/guichan/widgets/listbox.cpp
@@ -61,7 +61,7 @@ namespace gcn
{
ListBox::ListBox() :
mSelected(-1),
- mListModel(NULL),
+ mListModel(nullptr),
mWrappingEnabled(false)
{
setWidth(100);
@@ -88,7 +88,7 @@ namespace gcn
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
- if (mListModel == NULL)
+ if (!mListModel)
return;
graphics->setColor(getForegroundColor());
@@ -161,7 +161,7 @@ namespace gcn
void ListBox::setSelected(int selected)
{
- if (mListModel == NULL)
+ if (!mListModel)
{
mSelected = -1;
}
@@ -286,7 +286,7 @@ namespace gcn
void ListBox::adjustSize()
{
- if (mListModel != NULL)
+ if (mListModel)
setHeight(getRowHeight() * mListModel->getNumberOfElements());
}
diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp
index 7dc7566c0..574308b7c 100644
--- a/src/guichan/widgets/scrollarea.cpp
+++ b/src/guichan/widgets/scrollarea.cpp
@@ -138,12 +138,12 @@ namespace gcn
ScrollArea::~ScrollArea()
{
- setContent(NULL);
+ setContent(nullptr);
}
void ScrollArea::setContent(Widget* widget)
{
- if (widget != NULL)
+ if (widget)
{
clear();
add(widget);
@@ -162,7 +162,7 @@ namespace gcn
if (!mWidgets.empty())
return *mWidgets.begin();
- return NULL;
+ return nullptr;
}
void ScrollArea::setHorizontalScrollPolicy(ScrollPolicy hPolicy)
@@ -240,7 +240,7 @@ namespace gcn
{
checkPolicies();
- if (getContent() == NULL)
+ if (!getContent())
return 0;
int value = getContent()->getWidth() - getChildrenArea().width +
@@ -256,7 +256,7 @@ namespace gcn
{
checkPolicies();
- if (getContent() == NULL)
+ if (!getContent())
return 0;
int value;
@@ -790,7 +790,7 @@ namespace gcn
setVerticalScrollAmount(getVerticalScrollAmount());
setHorizontalScrollAmount(getHorizontalScrollAmount());
- if (getContent() != NULL)
+ if (getContent())
{
getContent()->setPosition(-mHScroll + getContent()->getFrameSize(),
-mVScroll + getContent()->getFrameSize());
@@ -1126,7 +1126,7 @@ namespace gcn
if (getChildrenArea().isPointInRect(x, y))
return getContent();
- return NULL;
+ return nullptr;
}
void ScrollArea::mouseWheelMovedUp(MouseEvent& mouseEvent)
diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp
index 9b7424748..768e2c695 100644
--- a/src/guichan/widgets/tab.cpp
+++ b/src/guichan/widgets/tab.cpp
@@ -59,7 +59,7 @@ namespace gcn
{
Tab::Tab() :
mHasMouse(false),
- mTabbedArea(NULL)
+ mTabbedArea(nullptr)
{
mLabel = new Label();
mLabel->setPosition(4, 4);
@@ -71,7 +71,7 @@ namespace gcn
Tab::~Tab()
{
delete mLabel;
- mLabel = 0;
+ mLabel = nullptr;
}
void Tab::adjustSize()
@@ -79,7 +79,7 @@ namespace gcn
setSize(mLabel->getWidth() + 8,
mLabel->getHeight() + 8);
- if (mTabbedArea != NULL)
+ if (mTabbedArea)
mTabbedArea->adjustTabPositions();
}
diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp
index 3c556eeca..4ee164778 100644
--- a/src/guichan/widgets/tabbedarea.cpp
+++ b/src/guichan/widgets/tabbedarea.cpp
@@ -62,7 +62,7 @@
namespace gcn
{
TabbedArea::TabbedArea() :
- mSelectedTab(NULL),
+ mSelectedTab(nullptr),
mOpaque(false)
{
setFocusable(true);
@@ -83,14 +83,14 @@ namespace gcn
remove(mWidgetContainer);
delete mTabContainer;
- mTabContainer = 0;
+ mTabContainer = nullptr;
delete mWidgetContainer;
- mWidgetContainer = 0;
+ mWidgetContainer = nullptr;
for (unsigned int i = 0; i < mTabsToDelete.size(); i++)
{
delete mTabsToDelete[i];
- mTabsToDelete[i] = 0;
+ mTabsToDelete[i] = nullptr;
}
}
@@ -102,7 +102,7 @@ namespace gcn
mTabContainer->add(tab);
mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
- if (mSelectedTab == NULL)
+ if (!mSelectedTab)
setSelectedTab(tab);
adjustTabPositions();
@@ -224,7 +224,7 @@ namespace gcn
// If a tab is selected, remove the line right underneath
// the selected tab.
- if (mSelectedTab != NULL)
+ if (mSelectedTab)
{
graphics->setColor(getBaseColor());
graphics->drawLine(mSelectedTab->getX() + 1,
@@ -332,7 +332,7 @@ namespace gcn
{
Tab* tab = dynamic_cast<Tab*>(event.getSource());
- if (tab != NULL)
+ if (tab)
removeTab(tab);
else
BasicContainer::death(event);
@@ -343,7 +343,7 @@ namespace gcn
Widget* source = actionEvent.getSource();
Tab* tab = dynamic_cast<Tab*>(source);
- if (tab == NULL)
+ if (!tab)
{
throw GCN_EXCEPTION("Received an action from a "
"widget that's not a tab!");
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index 35fbf5437..7b5b03ab8 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -270,7 +270,7 @@ namespace gcn
{
Widget* par = getParent();
- if (par != NULL)
+ if (par)
{
int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -284,7 +284,7 @@ namespace gcn
{
Widget* par = getParent();
- if (par != NULL)
+ if (par)
{
int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp
index 550b23749..1c46b2283 100644
--- a/src/guichan/widgets/window.cpp
+++ b/src/guichan/widgets/window.cpp
@@ -130,7 +130,7 @@ namespace gcn
if (mouseEvent.getSource() != this)
return;
- if (getParent() != NULL)
+ if (getParent())
getParent()->moveToTop(this);
mDragOffsetX = mouseEvent.getX();