summaryrefslogtreecommitdiff
path: root/src/gui/base
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-16 21:28:08 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-16 21:28:08 +0300
commit82ac4641828ec7387863bb18cf4493190c4cc68f (patch)
tree54fa2aeeff83109ca289894bf08bc767084050a3 /src/gui/base
parent07e8275965ccb989e3bcc288e2440bffcbca4a8e (diff)
downloadmanaverse-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.gz
manaverse-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.bz2
manaverse-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.xz
manaverse-82ac4641828ec7387863bb18cf4493190c4cc68f.zip
Remove Exception class.
Diffstat (limited to 'src/gui/base')
-rw-r--r--src/gui/base/basiccontainer.cpp10
-rw-r--r--src/gui/base/exception.cpp120
-rw-r--r--src/gui/base/exception.hpp196
-rw-r--r--src/gui/base/focushandler.cpp9
-rw-r--r--src/gui/base/gui.cpp7
-rw-r--r--src/gui/base/widget.cpp26
-rw-r--r--src/gui/base/widgets/button.cpp1
-rw-r--r--src/gui/base/widgets/container.cpp1
-rw-r--r--src/gui/base/widgets/label.cpp1
-rw-r--r--src/gui/base/widgets/scrollarea.cpp9
-rw-r--r--src/gui/base/widgets/window.cpp1
11 files changed, 16 insertions, 365 deletions
diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp
index 7a937fb42..4a745dc63 100644
--- a/src/gui/base/basiccontainer.cpp
+++ b/src/gui/base/basiccontainer.cpp
@@ -69,7 +69,6 @@
#include <algorithm>
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/mouseinput.hpp"
@@ -96,8 +95,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::moveToBottom(Widget* widget)
@@ -106,11 +103,10 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), widget);
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
mWidgets.insert(mWidgets.begin(), widget);
-// mWidgets.push_front(widget);
}
void BasicContainer::death(const Event& event)
@@ -119,7 +115,7 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource());
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
}
@@ -260,8 +256,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::clear()
diff --git a/src/gui/base/exception.cpp b/src/gui/base/exception.cpp
deleted file mode 100644
index 998db928d..000000000
--- a/src/gui/base/exception.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "gui/base/exception.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Exception::Exception()
- : mFunction("?"),
- mMessage(""),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message)
- : mFunction("?"),
- mMessage(message),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line)
- : mFunction(function),
- mMessage(message),
- mFilename(filename),
- mLine(line)
- {
- }
-
- const std::string& Exception::getFunction() const
- {
- return mFunction;
- }
-
- const std::string& Exception::getMessage() const
- {
- return mMessage;
- }
-
- const std::string& Exception::getFilename() const
- {
- return mFilename;
- }
-
- unsigned int Exception::getLine() const
- {
- return mLine;
- }
-} // namespace gcn
diff --git a/src/gui/base/exception.hpp b/src/gui/base/exception.hpp
deleted file mode 100644
index a60152c96..000000000
--- a/src/gui/base/exception.hpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_EXCEPTION_HPP
-#define GCN_EXCEPTION_HPP
-
-#include <string>
-
-#include "localconsts.h"
-
-#ifndef __FUNCTION__
-#define __FUNCTION__ "?"
-#endif
-
-/*
- * A macro used to create a standard exception object.
- * What it basicly does is that it creates a new exception
- * and automatically sets the filename and line number where
- * the exception occured by using other compiler macros.
- */
-#define GCN_EXCEPTION(mess) gcn::Exception(mess, \
- __FUNCTION__, \
- __FILE__, \
- __LINE__)
-
-namespace gcn
-{
-
- /**
- * An exception containing a message, a file and a line number
- * where the exception occured. Guichan will only throw exceptions
- * of this class.
- *
- * You can use this class for your own exceptions that has
- * something to do with a GUI exception. A nifty feature of the
- * excpetion class is that it can tell you from which line and
- * file it was thrown. To make things easier when throwing
- * exceptions there exists a macro for creating exceptions
- * which automatically sets the filename and line number.
- *
- * EXAMPLE: @code
- * throw GCN_EXCEPTION("my error message");
- * @endcode
- */
- class Exception final
- {
- public:
- /**
- * Constructor.
- */
- Exception();
-
- /**
- * Constructor.
- *
- * @param message The error message of the exception.
- */
- explicit Exception(const std::string& message);
-
- /**
- * Constructor.
- *
- * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead.
- * This constructor merely exists for the GCN_EXCEPTION macro to
- * use.
- *
- * @param message The error message of the exception.
- * @param function The function name where the exception occured.
- * @param filename The name of the file where the exception occured.
- * @param line The line number in the source code where the exception
- * occured.
- */
- Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line);
-
- /**
- * Gets the function name where the exception occured.
- *
- * @return The function name where the exception occured.
- */
- const std::string& getFunction() const A_WARN_UNUSED;
-
- /**
- * Gets the error message of the exception.
- *
- * @return The error message of the exception.
- */
- const std::string& getMessage() const A_WARN_UNUSED;
-
- /**
- * Gets the filename where the exception occured.
- *
- * @return The filename where the exception occured.
- */
- const std::string& getFilename() const A_WARN_UNUSED;
-
- /**
- * Gets the line number where the exception occured.
- *
- * @return The line number where the exception occured.
- */
- unsigned int getLine() const A_WARN_UNUSED;
-
- protected:
- /**
- * Holds the name of the function name where the
- * exception occured.
- */
- std::string mFunction;
-
- /**
- * Holds the error message of the exception.
- */
- std::string mMessage;
-
- /**
- * Holds the filename where the exception occured.
- */
- std::string mFilename;
-
- /**
- * Holds the line number where the exception occured.
- */
- unsigned int mLine;
- };
-} // namespace gcn
-
-#endif // end GCN_EXCEPTION_HPP
-
-/*
- * "Final Fantasy XI is the BEST!... It's even better then water!"
- * - Astrolite
- * I believe it's WoW now days.
- */
diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp
index ff149bf99..3c6978e70 100644
--- a/src/gui/base/focushandler.cpp
+++ b/src/gui/base/focushandler.cpp
@@ -67,7 +67,6 @@
#include "gui/base/focushandler.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/widget.hpp"
#include "listeners/focuslistener.h"
@@ -106,7 +105,7 @@ namespace gcn
}
if (toBeFocusedIndex < 0)
- throw GCN_EXCEPTION("Trying to focus a none existing widget.");
+ return;
Widget *const oldFocused = mFocusedWidget;
@@ -128,10 +127,9 @@ namespace gcn
void FocusHandler::requestModalFocus(Widget* widget)
{
if (mModalFocusedWidget && mModalFocusedWidget != widget)
- throw GCN_EXCEPTION("Another widget already has modal focus.");
+ return;
mModalFocusedWidget = widget;
-
if (mFocusedWidget && !mFocusedWidget->isModalFocused())
focusNone();
}
@@ -141,8 +139,7 @@ namespace gcn
if (mModalMouseInputFocusedWidget
&& mModalMouseInputFocusedWidget != widget)
{
- throw GCN_EXCEPTION("Another widget already has "
- "modal input focus.");
+ return;
}
mModalMouseInputFocusedWidget = widget;
diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp
index f16048bbb..e6fc79856 100644
--- a/src/gui/base/gui.cpp
+++ b/src/gui/base/gui.cpp
@@ -68,7 +68,6 @@
#include "gui/base/gui.hpp"
#include "gui/base/basiccontainer.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/input.hpp"
#include "gui/base/keyinput.hpp"
@@ -532,7 +531,7 @@ namespace gcn
(*it)->mouseClicked(mouseEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown mouse event type.");
+ break;
}
}
@@ -608,7 +607,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
}
}
@@ -641,7 +640,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
if (keyEvent.isConsumed())
diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp
index 6083fb35a..e0f33d498 100644
--- a/src/gui/base/widget.cpp
+++ b/src/gui/base/widget.cpp
@@ -71,7 +71,6 @@
#include "gui/base/basiccontainer.hpp"
#include "events/event.h"
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/keyinput.hpp"
#include "gui/base/mouseinput.hpp"
@@ -276,10 +275,7 @@ namespace gcn
void Widget::requestFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
if (isFocusable())
mFocusHandler->requestFocus(this);
@@ -521,10 +517,7 @@ namespace gcn
void Widget::requestModalFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
mFocusHandler->requestModalFocus(this);
}
@@ -532,10 +525,7 @@ namespace gcn
void Widget::requestModalMouseInputFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
mFocusHandler->requestModalMouseInputFocus(this);
}
@@ -559,10 +549,7 @@ namespace gcn
bool Widget::isModalFocused() const
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return false;
if (mParent)
{
@@ -576,10 +563,7 @@ namespace gcn
bool Widget::isModalMouseInputFocused() const
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return false;
if (mParent)
{
diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp
index 8cf49da4b..1276b82b2 100644
--- a/src/gui/base/widgets/button.cpp
+++ b/src/gui/base/widgets/button.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/button.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp
index d72f2a682..6026b920d 100644
--- a/src/gui/base/widgets/container.cpp
+++ b/src/gui/base/widgets/container.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/container.hpp"
-#include "gui/base/exception.hpp"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp
index f4576d908..c23666eac 100644
--- a/src/gui/base/widgets/label.cpp
+++ b/src/gui/base/widgets/label.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/label.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp
index ffcaffdb1..f76226bc5 100644
--- a/src/gui/base/widgets/scrollarea.cpp
+++ b/src/gui/base/widgets/scrollarea.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/scrollarea.hpp"
-#include "gui/base/exception.hpp"
#include "render/graphics.h"
@@ -300,8 +299,6 @@ namespace gcn
{
if (width > 0)
mScrollbarWidth = width;
- else
- throw GCN_EXCEPTION("Width should be greater then 0.");
}
int ScrollArea::getScrollbarWidth() const
@@ -446,7 +443,7 @@ namespace gcn
break;
default:
- throw GCN_EXCEPTION("Horizontal scroll policy invalid.");
+ break;
}
switch (mVPolicy)
@@ -471,7 +468,7 @@ namespace gcn
}
break;
default:
- throw GCN_EXCEPTION("Vertical scroll policy invalid.");
+ break;
}
}
@@ -491,7 +488,7 @@ namespace gcn
{
const Widget *const content = getContent();
if (widget != content)
- throw GCN_EXCEPTION("Widget not content widget");
+ return;
BasicContainer::showWidgetPart(widget, area);
diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp
index 02611f819..9207fe449 100644
--- a/src/gui/base/widgets/window.cpp
+++ b/src/gui/base/widgets/window.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/window.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "gui/base/mouseinput.hpp"