summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-30 02:10:59 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-30 02:10:59 +0300
commit46f0755975033f37eaae9db73c0e2b6499c2a923 (patch)
tree5c13c361ce4a4e4fd0e07fca1953c54637965666 /src/gui/widgets
parent1feb7f7edc5f8f383e594b256ef4cab0fae75b99 (diff)
downloadplus-46f0755975033f37eaae9db73c0e2b6499c2a923.tar.gz
plus-46f0755975033f37eaae9db73c0e2b6499c2a923.tar.bz2
plus-46f0755975033f37eaae9db73c0e2b6499c2a923.tar.xz
plus-46f0755975033f37eaae9db73c0e2b6499c2a923.zip
Add const to more classes.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp34
-rw-r--r--src/gui/widgets/browserbox.cpp49
-rw-r--r--src/gui/widgets/browserbox.h15
-rw-r--r--src/gui/widgets/button.cpp30
-rw-r--r--src/gui/widgets/button.h13
-rw-r--r--src/gui/widgets/channeltab.cpp2
-rw-r--r--src/gui/widgets/channeltab.h2
-rw-r--r--src/gui/widgets/chattab.cpp12
-rw-r--r--src/gui/widgets/chattab.h11
-rw-r--r--src/gui/widgets/checkbox.cpp13
-rw-r--r--src/gui/widgets/checkbox.h6
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/container.h2
-rw-r--r--src/gui/widgets/desktop.cpp8
-rw-r--r--src/gui/widgets/dropdown.cpp15
-rw-r--r--src/gui/widgets/dropdown.h6
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp22
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp10
-rw-r--r--src/gui/widgets/extendedlistbox.cpp9
-rw-r--r--src/gui/widgets/extendedlistbox.h2
-rw-r--r--src/gui/widgets/flowcontainer.cpp6
-rw-r--r--src/gui/widgets/flowcontainer.h2
-rw-r--r--src/gui/widgets/guitable.cpp42
-rw-r--r--src/gui/widgets/guitable.h6
-rw-r--r--src/gui/widgets/horizontcontainer.cpp8
-rw-r--r--src/gui/widgets/horizontcontainer.h2
-rw-r--r--src/gui/widgets/icon.cpp6
-rw-r--r--src/gui/widgets/icon.h4
-rw-r--r--src/gui/widgets/inttextfield.cpp14
-rw-r--r--src/gui/widgets/inttextfield.h12
-rw-r--r--src/gui/widgets/itemcontainer.cpp52
-rw-r--r--src/gui/widgets/itemcontainer.h13
32 files changed, 226 insertions, 204 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 2a009bcc6..a3a4a2334 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -93,12 +93,13 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
if (!mListModel || !player_node)
return;
- AvatarListModel *model = static_cast<AvatarListModel*>(mListModel);
+ AvatarListModel *const model = static_cast<AvatarListModel *const>(
+ mListModel);
// Guild *guild = dynamic_cast<Guild*>(model);
updateAlpha();
- Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
+ Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
graphics->setColor(mHighlightColor);
@@ -106,7 +107,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
const int fontHeight = getFont()->getHeight();
- Widget *parent = mParent;
+ const Widget *const parent = mParent;
const std::string name = player_node->getName();
@@ -116,14 +117,14 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
i < model->getNumberOfElements();
++i, y += fontHeight)
{
- Avatar *a = model->getAvatarAt(i);
+ const Avatar *const a = model->getAvatarAt(i);
if (!a)
continue;
if (a->getType() != MapItem::SEPARATOR)
{
// Draw online status
- Image *icon = a->getOnline() ? onlineIcon : offlineIcon;
+ const Image *const icon = a->getOnline() ? onlineIcon : offlineIcon;
if (icon)
graphics->drawImage(icon, 2, y + 1);
}
@@ -304,17 +305,18 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
return;
}
- int y = event.getY() / getFont()->getHeight();
+ const int y = event.getY() / getFont()->getHeight();
if (!mListModel || y > mListModel->getNumberOfElements())
return;
setSelected(y);
distributeActionEvent();
- int selected = getSelected();
- AvatarListModel *model = static_cast<AvatarListModel*>(mListModel);
+ const int selected = getSelected();
+ AvatarListModel *const model = static_cast<AvatarListModel *const>(
+ mListModel);
if (!model)
return;
- Avatar *ava = model->getAvatarAt(selected);
+ const Avatar *ava = model->getAvatarAt(selected);
if (!ava)
return;
@@ -322,8 +324,8 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
if (ava->getType() == AVATAR_PLAYER)
{
- Being* being = actorSpriteManager->findBeingByName(ava->getName(),
- Being::PLAYER);
+ const Being *const being = actorSpriteManager->findBeingByName(
+ ava->getName(), Being::PLAYER);
if (being)
actorSpriteManager->heal(being);
}
@@ -338,10 +340,10 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
case AVATAR_PLAYER:
{
- Avatar *avatar = model->getAvatarAt(selected);
+ const Avatar *const avatar = model->getAvatarAt(selected);
if (avatar)
{
- Being* being = actorSpriteManager->findBeingByName(
+ Being *const being = actorSpriteManager->findBeingByName(
avatar->getName(), Being::PLAYER);
if (being)
viewport->showPopup(being);
@@ -378,11 +380,11 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
default:
{
- Map *map = viewport->getMap();
+ const Map *const map = viewport->getMap();
ava = model->getAvatarAt(selected);
if (map && ava)
{
- MapItem *mapItem = map->findPortalXY(
+ MapItem *const mapItem = map->findPortalXY(
ava->getX(), ava->getY());
viewport->showPopup(mapItem);
}
@@ -394,7 +396,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
{
- ChatTab *tab = chatWindow->addWhisperTab(
+ const ChatTab *const tab = chatWindow->addWhisperTab(
model->getAvatarAt(selected)->getName(), true);
if (chatWindow && tab)
chatWindow->saveState();
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index f61851e1f..fded0cbe7 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -45,7 +45,7 @@
#include "debug.h"
-BrowserBox::BrowserBox(unsigned int mode, bool opaque):
+BrowserBox::BrowserBox(const unsigned int mode, const bool opaque) :
gcn::Widget(),
mLinkHandler(nullptr),
mMode(mode),
@@ -94,17 +94,17 @@ void BrowserBox::setOpaque(bool opaque)
mOpaque = opaque;
}
-void BrowserBox::setHighlightMode(unsigned int highMode)
+void BrowserBox::setHighlightMode(const unsigned int highMode)
{
mHighMode = highMode;
}
-void BrowserBox::addRow(const std::string &row, bool atTop)
+void BrowserBox::addRow(const std::string &row, const bool atTop)
{
std::string tmp = row;
std::string newRow;
size_t idx1;
- gcn::Font *font = getFont();
+ const gcn::Font *const font = getFont();
int linksCount = 0;
if (getWidth() < 0)
@@ -208,7 +208,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
}
// Adjust the BrowserBox size
- int w = font->getWidth(plain);
+ const int w = font->getWidth(plain);
if (w > getWidth())
setWidth(w);
}
@@ -217,8 +217,8 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
{
unsigned int y = 0;
unsigned int nextChar;
- const char *hyphen = "~";
- int hyphenWidth = font->getWidth(hyphen);
+ const char *const hyphen = "~";
+ const int hyphenWidth = font->getWidth(hyphen);
unsigned x = 0;
for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end();
@@ -240,7 +240,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
if (nextSpacePos <= 0)
nextSpacePos = static_cast<int>(sz) - 1;
- unsigned nextWordWidth = font->getWidth(
+ const unsigned nextWordWidth = font->getWidth(
tempRow.substr(nextChar,
(nextSpacePos - nextChar)));
@@ -273,7 +273,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
updateHeight();
}
-void BrowserBox::addRow(const std::string &cmd, char *text)
+void BrowserBox::addRow(const std::string &cmd, const char *const text)
{
addRow(strprintf("@@%s|%s@@", cmd.c_str(), text));
}
@@ -301,10 +301,11 @@ void BrowserBox::clearRows()
struct MouseOverLink
{
- MouseOverLink(int x, int y) : mX(x), mY(y)
+ MouseOverLink(const int x, const int y) :
+ mX(x), mY(y)
{ }
- bool operator() (BROWSER_LINK &link) const
+ bool operator() (const BROWSER_LINK &link) const
{
return (mX >= link.x1 && mX < link.x2 &&
mY >= link.y1 && mY < link.y2);
@@ -317,7 +318,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event)
if (!mLinkHandler)
return;
- LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
+ const LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
MouseOverLink(event.getX(), event.getY()));
if (i != mLinks.end())
@@ -326,7 +327,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event)
void BrowserBox::mouseMoved(gcn::MouseEvent &event)
{
- LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
+ const LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
MouseOverLink(event.getX(), event.getY()));
mSelectedLink = (i != mLinks.end())
@@ -335,10 +336,10 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event)
void BrowserBox::draw(gcn::Graphics *graphics)
{
- gcn::ClipRectangle cr = graphics->getCurrentClipArea();
- Graphics *graphics2 = static_cast<Graphics*>(graphics);
+ const gcn::ClipRectangle cr = graphics->getCurrentClipArea();
+ Graphics *const graphics2 = static_cast<Graphics *const>(graphics);
mYStart = cr.y - cr.yOffset;
- int yEnd = mYStart + cr.height;
+ const int yEnd = mYStart + cr.height;
if (mYStart < 0)
mYStart = 0;
@@ -376,7 +377,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
}
- gcn::Font *font = getFont();
+ gcn::Font *const font = getFont();
for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end();
i != i_end; ++i)
@@ -415,16 +416,16 @@ int BrowserBox::calcHeight()
if (getWidth() < 0)
return 1;
- gcn::Font *font = getFont();
+ const gcn::Font *const font = getFont();
- int fontHeight = font->getHeight();
- int fontWidthMinus = font->getWidth("-");
- char const *hyphen = "~";
- int hyphenWidth = font->getWidth(hyphen);
+ const int fontHeight = font->getHeight();
+ const int fontWidthMinus = font->getWidth("-");
+ char const *const hyphen = "~";
+ const int hyphenWidth = font->getWidth(hyphen);
gcn::Color selColor = getForegroundColor();
const gcn::Color textColor = getForegroundColor();
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
mLineParts.clear();
@@ -453,7 +454,7 @@ int BrowserBox::calcHeight()
std::string str = row.substr(3);
if (str.size() > 2 && str.substr(str.size() - 1) == "~")
str = str.substr(0, str.size() - 1);
- Image *img = resman->getImage(str);
+ Image *const img = resman->getImage(str);
if (img)
{
img->incRef();
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index c19256afa..ed7208031 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -46,13 +46,15 @@ struct BROWSER_LINK
class LinePart
{
public:
- LinePart(int x, int y, gcn::Color color, std::string text, bool bold) :
+ LinePart(const int x, const int y, const gcn::Color color,
+ const std::string &text, const bool bold) :
mX(x), mY(y), mColor(color), mText(text), mType(0),
mImage(nullptr), mBold(bold)
{
}
- LinePart(int x, int y, gcn::Color color, Image *image) :
+ LinePart(const int x, const int y, const gcn::Color color,
+ Image *const image) :
mX(x), mY(y), mColor(color), mText(""), mType(1),
mImage(image), mBold(false)
{
@@ -79,7 +81,8 @@ class BrowserBox : public gcn::Widget,
/**
* Constructor.
*/
- BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true);
+ BrowserBox(const unsigned int mode = AUTO_SIZE,
+ const bool opaque = true);
/**
* Destructor.
@@ -99,7 +102,7 @@ class BrowserBox : public gcn::Widget,
/**
* Sets the Highlight mode for links.
*/
- void setHighlightMode(unsigned int highMode);
+ void setHighlightMode(const unsigned int highMode);
/**
* Sets the maximum numbers of rows in the browser box. 0 = no limit.
@@ -116,12 +119,12 @@ class BrowserBox : public gcn::Widget,
/**
* Adds a text row to the browser.
*/
- void addRow(const std::string &row, bool atTop = false);
+ void addRow(const std::string &row, const bool atTop = false);
/**
* Adds a menu line to the browser.
*/
- void addRow(const std::string &cmd, char *text);
+ void addRow(const std::string &cmd, const char *const text);
void addImage(const std::string &path);
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index d464940ec..2f475db88 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -82,7 +82,7 @@ Button::Button() :
}
Button::Button(const std::string &caption, const std::string &actionEventId,
- gcn::ActionListener *listener) :
+ gcn::ActionListener *const listener) :
gcn::Button(caption),
mDescription(""),
mClickCount(0),
@@ -108,9 +108,9 @@ Button::Button(const std::string &caption, const std::string &actionEventId,
}
Button::Button(const std::string &caption, const std::string &imageName,
- int imageWidth, int imageHeight,
+ const int imageWidth, const int imageHeight,
const std::string &actionEventId,
- gcn::ActionListener *listener) :
+ gcn::ActionListener *const listener) :
gcn::Button(caption),
mDescription(""),
mClickCount(0),
@@ -136,9 +136,10 @@ Button::Button(const std::string &caption, const std::string &imageName,
addActionListener(listener);
}
-Button::Button(const std::string &imageName, int imageWidth, int imageHeight,
+Button::Button(const std::string &imageName,
+ const int imageWidth, const int imageHeight,
const std::string &actionEventId,
- gcn::ActionListener *listener) :
+ gcn::ActionListener *const listener) :
gcn::Button(""),
mDescription(""),
mClickCount(0),
@@ -195,7 +196,7 @@ Button::~Button()
if (mInstances == 0 && Theme::instance())
{
- Theme *theme = Theme::instance();
+ Theme *const theme = Theme::instance();
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unloadRect(button[mode]);
}
@@ -230,7 +231,7 @@ void Button::loadImage(const std::string &imageName)
mImages[0] = nullptr;
for (int f = 0; f < BUTTON_COUNT; f ++)
{
- Image *img = mImageSet->get(f);
+ Image *const img = mImageSet->get(f);
if (img)
mImages[f] = img;
else
@@ -240,7 +241,7 @@ void Button::loadImage(const std::string &imageName)
void Button::updateAlpha()
{
- float alpha = std::max(Client::getGuiAlpha(),
+ const float alpha = std::max(Client::getGuiAlpha(),
Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
@@ -275,7 +276,7 @@ void Button::draw(gcn::Graphics *graphics)
updateAlpha();
- Graphics *g2 = static_cast<Graphics*>(graphics);
+ Graphics *const g2 = static_cast<Graphics *const>(graphics);
bool recalc = false;
if (mRedraw)
@@ -321,7 +322,7 @@ void Button::draw(gcn::Graphics *graphics)
graphics->setColor(mEnabledColor);
int textX = 0;
- int textY = getHeight() / 2 - getFont()->getHeight() / 2;
+ const int textY = getHeight() / 2 - getFont()->getHeight() / 2;
int imageX = 0;
int imageY = 0;
if (mImages)
@@ -346,7 +347,8 @@ void Button::draw(gcn::Graphics *graphics)
case gcn::Graphics::CENTER:
if (mImages)
{
- int width = getFont()->getWidth(mCaption) + mImageWidth + 2;
+ const int width = getFont()->getWidth(mCaption)
+ + mImageWidth + 2;
imageX = getWidth() / 2 - width / 2;
textX = imageX + mImageWidth + 2;
}
@@ -434,7 +436,7 @@ void Button::setCaption(const std::string& caption)
void Button::keyPressed(gcn::KeyEvent& keyEvent)
{
- int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
if (action == Input::KEY_GUI_SELECT)
{
@@ -445,7 +447,7 @@ void Button::keyPressed(gcn::KeyEvent& keyEvent)
void Button::keyReleased(gcn::KeyEvent& keyEvent)
{
- int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
if (action == Input::KEY_GUI_SELECT && mKeyPressed)
{
@@ -458,7 +460,7 @@ void Button::keyReleased(gcn::KeyEvent& keyEvent)
}
-bool Button::isPressed2()
+bool Button::isPressed2() const
{
return (mPressed || isPressed());
}
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index c2d8b0b52..e3ff82f0f 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -52,24 +52,25 @@ class Button : public gcn::Button, public gcn::WidgetListener
* adds the given action listener.
*/
Button(const std::string &caption, const std::string &actionEventId,
- gcn::ActionListener *listener);
+ gcn::ActionListener *const listener);
/**
* Constructor, sets the caption of the button to the given string and
* adds the given action listener.
*/
Button(const std::string &caption, const std::string &imageName,
- int imageWidth, int imageHeight,
+ const int imageWidth, const int imageHeight,
const std::string &actionEventId,
- gcn::ActionListener *listener);
+ gcn::ActionListener *const listener);
/**
* Constructor, sets the caption of the button to the given string and
* adds the given action listener.
*/
- Button(const std::string &imageName, int imageWidth, int imageHeight,
+ Button(const std::string &imageName,
+ const int imageWidth, const int imageHeight,
const std::string &actionEventId,
- gcn::ActionListener *listener);
+ gcn::ActionListener *const listener);
/**
* Destructor.
@@ -123,7 +124,7 @@ class Button : public gcn::Button, public gcn::WidgetListener
void keyReleased(gcn::KeyEvent &keyEvent);
- bool isPressed2();
+ bool isPressed2() const;
private:
void init();
diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp
index f362cc28c..b9ea96650 100644
--- a/src/gui/widgets/channeltab.cpp
+++ b/src/gui/widgets/channeltab.cpp
@@ -31,7 +31,7 @@
#include "debug.h"
-ChannelTab::ChannelTab(Channel *channel) :
+ChannelTab::ChannelTab(Channel *const channel) :
ChatTab(channel->getName()),
mChannel(channel)
{
diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h
index 39702a696..d78027b67 100644
--- a/src/gui/widgets/channeltab.h
+++ b/src/gui/widgets/channeltab.h
@@ -48,7 +48,7 @@ class ChannelTab : public ChatTab
/**
* Constructor.
*/
- ChannelTab(Channel *channel);
+ ChannelTab(Channel *const channel);
/**
* Destructor.
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 0c1bab71a..a78d1f636 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -86,7 +86,7 @@ ChatTab::~ChatTab()
}
void ChatTab::chatLog(std::string line, Own own,
- bool ignoreRecord, bool tryRemoveColors)
+ const bool ignoreRecord, const bool tryRemoveColors)
{
// Trim whitespace
trim(line);
@@ -102,7 +102,7 @@ void ChatTab::chatLog(std::string line, Own own,
return;
}
- unsigned lineLim = config.getIntValue("chatMaxCharLimit");
+ const unsigned lineLim = config.getIntValue("chatMaxCharLimit");
if (lineLim > 0 && line.length() > lineLim)
line = line.substr(0, lineLim);
@@ -220,7 +220,7 @@ void ChatTab::chatLog(std::string line, Own own,
if (config.getBoolValue("useLocalTime"))
{
- struct tm *timeInfo;
+ const struct tm *timeInfo;
timeInfo = localtime(&t);
if (timeInfo)
{
@@ -326,7 +326,7 @@ void ChatTab::chatLog(std::string line, Own own,
void ChatTab::chatLog(const std::string &nick, std::string msg)
{
- Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER);
+ const Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER);
if (byWho == BY_OTHER && config.getBoolValue("removeColors"))
msg = removeColors(msg);
chatLog(nick + " : " + msg, byWho, false, false);
@@ -395,9 +395,9 @@ void ChatTab::chatInput(const std::string &message)
}
}
-void ChatTab::scroll(int amount)
+void ChatTab::scroll(const int amount)
{
- int range = mScrollArea->getHeight() / 8 * amount;
+ const int range = mScrollArea->getHeight() / 8 * amount;
gcn::Rectangle scr;
scr.y = mScrollArea->getVerticalScrollAmount() + range;
scr.height = abs(range);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 27149a9f1..0b4a287d0 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -67,7 +67,8 @@ class ChatTab : public Tab
* @param removeColors try remove color if configured
*/
void chatLog(std::string line, Own own = BY_SERVER,
- bool ignoreRecord = false, bool tryRemoveColors = true);
+ const bool ignoreRecord = false,
+ const bool tryRemoveColors = true);
/**
* Adds the text to the message list
@@ -92,7 +93,7 @@ class ChatTab : public Tab
* up, positive numbers scroll down. The absolute amount indicates the
* amount of 1/8ths of chat window real estate that should be scrolled.
*/
- void scroll(int amount);
+ void scroll(const int amount);
/**
* Clears the text from the tab
@@ -145,19 +146,19 @@ class ChatTab : public Tab
bool getAllowHighlight() const
{ return mAllowHightlight; }
- void setAllowHighlight(bool n)
+ void setAllowHighlight(const bool n)
{ mAllowHightlight = n; }
bool getRemoveNames() const
{ return mRemoveNames; }
- void setRemoveNames(bool n)
+ void setRemoveNames(const bool n)
{ mRemoveNames = n; }
bool getNoAway() const
{ return mNoAway; }
- void setNoAway(bool n)
+ void setNoAway(const bool n)
{ mNoAway = n; }
void addNewRow(std::string &line);
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 72ca9eb8d..759ca9015 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -46,8 +46,9 @@ Image *CheckBox::checkBoxDisabledChecked;
Image *CheckBox::checkBoxNormalHi;
Image *CheckBox::checkBoxCheckedHi;
-CheckBox::CheckBox(const std::string &caption, bool selected,
- gcn::ActionListener* listener, std::string eventId):
+CheckBox::CheckBox(const std::string &caption, const bool selected,
+ gcn::ActionListener *const listener,
+ const std::string &eventId) :
gcn::CheckBox(caption, selected),
mHasMouse(false)
{
@@ -152,7 +153,7 @@ void CheckBox::draw(gcn::Graphics* graphics)
void CheckBox::updateAlpha()
{
- float alpha = std::max(Client::getGuiAlpha(),
+ const float alpha = std::max(Client::getGuiAlpha(),
Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
@@ -173,9 +174,9 @@ void CheckBox::updateAlpha()
}
}
-void CheckBox::drawBox(gcn::Graphics* graphics)
+void CheckBox::drawBox(gcn::Graphics *const graphics)
{
- Image *box;
+ const Image *box;
if (isEnabled())
{
@@ -220,7 +221,7 @@ void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED)
void CheckBox::keyPressed(gcn::KeyEvent& keyEvent)
{
- int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
if (action == Input::KEY_GUI_SELECT)
{
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
index e86e4b214..ff1c2d56c 100644
--- a/src/gui/widgets/checkbox.h
+++ b/src/gui/widgets/checkbox.h
@@ -41,8 +41,8 @@ class CheckBox : public gcn::CheckBox
* Constructor.
*/
CheckBox(const std::string &caption, bool selected = false,
- gcn::ActionListener* listener = nullptr,
- std::string eventId = "");
+ gcn::ActionListener *const listener = nullptr,
+ const std::string &eventId = "");
/**
* Destructor.
@@ -52,7 +52,7 @@ class CheckBox : public gcn::CheckBox
/**
* Draws the caption, then calls drawBox to draw the check box.
*/
- void draw(gcn::Graphics* graphics);
+ void draw(gcn::Graphics *const graphics);
/**
* Update the alpha value to the checkbox components.
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e085d609f..2a15c3044 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -35,7 +35,7 @@ Container::~Container()
delete mWidgets.front();
}
-bool Container::safeRemove(gcn::Widget* widget)
+bool Container::safeRemove(gcn::Widget *const widget)
{
for (WidgetListConstIterator iter = mWidgets.begin();
iter != mWidgets.end(); ++iter)
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index d927f5379..26706722b 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -46,7 +46,7 @@ class Container : public gcn::Container
~Container();
- bool safeRemove(gcn::Widget* widget);
+ bool safeRemove(gcn::Widget *const widget);
};
#endif
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index b6bd62fa7..01002640a 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -86,7 +86,7 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED)
void Desktop::draw(gcn::Graphics *graphics)
{
- Graphics *g = static_cast<Graphics *>(graphics);
+ Graphics *const g = static_cast<Graphics *const>(graphics);
if (!mWallpaper || (getWidth() > mWallpaper->getWidth() ||
getHeight() > mWallpaper->getHeight()))
@@ -126,7 +126,7 @@ void Desktop::setBestFittingWallpaper()
const std::string wallpaperName =
Wallpaper::getWallpaper(getWidth(), getHeight());
- Image *nWallPaper = Theme::getImageFromTheme(wallpaperName);
+ Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName);
if (nWallPaper)
{
@@ -138,8 +138,8 @@ void Desktop::setBestFittingWallpaper()
|| nWallPaper->getHeight() != getHeight()))
{
// We rescale to obtain a fullscreen wallpaper...
- Image *newRsclWlPpr = ResourceManager::getInstance()->getRescaled(
- nWallPaper, getWidth(), getHeight());
+ Image *const newRsclWlPpr = ResourceManager::getInstance()
+ ->getRescaled(nWallPaper, getWidth(), getHeight());
// We replace the resource in the resource manager
nWallPaper->decRef();
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 3012c5553..bb18ff2dd 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -54,8 +54,9 @@ static std::string const dropdownFiles[2] =
"dropdown_pressed.xml"
};
-DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
- std::string eventId):
+DropDown::DropDown(gcn::ListModel *const listModel,
+ gcn::ActionListener *const listener,
+ const std::string &eventId):
gcn::DropDown::DropDown(listModel,
new ScrollArea, new ListBox(listModel)),
mShadowColor(Theme::getThemeColor(Theme::DROPDOWN_SHADOW)),
@@ -69,7 +70,7 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
// Load the background skin
for (int i = 0; i < 2; i ++)
{
- Skin *skin = Theme::instance()->load(
+ Skin *const skin = Theme::instance()->load(
dropdownFiles[i], "dropdown.xml");
if (skin)
{
@@ -217,7 +218,7 @@ void DropDown::drawFrame(gcn::Graphics *graphics)
void DropDown::drawButton(gcn::Graphics *graphics)
{
- int height = mDroppedDown ? mFoldedUpHeight : getHeight();
+ const int height = mDroppedDown ? mFoldedUpHeight : getHeight();
if (buttons[mDroppedDown][mPushed])
{
@@ -233,7 +234,7 @@ void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
if (keyEvent.isConsumed())
return;
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
switch (actionId)
{
@@ -305,7 +306,7 @@ void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
void DropDown::setSelectedString(std::string str)
{
- gcn::ListModel *listModel = mListBox->getListModel();
+ gcn::ListModel *const listModel = mListBox->getListModel();
if (!listModel)
return;
@@ -321,7 +322,7 @@ void DropDown::setSelectedString(std::string str)
std::string DropDown::getSelectedString() const
{
- gcn::ListModel *listModel = mListBox->getListModel();
+ gcn::ListModel *const listModel = mListBox->getListModel();
if (!listModel)
return "";
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index c044e8a16..c01466c03 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -48,9 +48,9 @@ class DropDown : public gcn::DropDown
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
- DropDown(gcn::ListModel *listModel = nullptr,
- gcn::ActionListener* listener = nullptr,
- std::string eventId = "");
+ DropDown(gcn::ListModel *const listModel = nullptr,
+ gcn::ActionListener *const listener = nullptr,
+ const std::string &eventId = "");
~DropDown();
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index af95ffa82..5adc4e343 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -93,7 +93,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
mBackgroundImg->setAlpha(mAlpha);
}
- Graphics *g = static_cast<Graphics*>(graphics);
+ Graphics *const g = static_cast<Graphics*>(graphics);
graphics->setFont(getFont());
@@ -106,7 +106,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
}
}
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
@@ -118,13 +118,13 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
if (dropShortcut->getItem(i) < 0)
continue;
- Item *item = inv->findItem(dropShortcut->getItem(i),
+ const Item *const item = inv->findItem(dropShortcut->getItem(i),
dropShortcut->getItemColor(i));
if (item)
{
// Draw item icon.
- Image* image = item->getImage();
+ Image *const image = item->getImage();
if (image)
{
@@ -149,7 +149,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
if (mItemMoved)
{
// Draw the item image being dragged by the cursor.
- Image* image = mItemMoved->getImage();
+ const Image *const image = mItemMoved->getImage();
if (image)
{
const int tPosX = mCursorPosX - (image->mBounds.w / 2);
@@ -183,11 +183,11 @@ void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (itemId < 0)
return;
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
- Item *item = inv->findItem(itemId, itemColor);
+ Item *const item = inv->findItem(itemId, itemColor);
if (item)
{
@@ -229,11 +229,11 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
- Item *item = inv->findItem(dropShortcut->getItem(index),
+ Item *const item = inv->findItem(dropShortcut->getItem(index),
dropShortcut->getItemColor(index));
if (viewport)
@@ -286,11 +286,11 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event)
if (itemId < 0)
return;
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
- Item *item = inv->findItem(itemId, itemColor);
+ const Item *const item = inv->findItem(itemId, itemColor);
if (item && viewport)
{
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index cfbfad31d..905a3229b 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -63,7 +63,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
- const EmoteSprite* sprite = EmoteDB::getSprite(i, true);
+ const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
if (sprite && sprite->sprite)
mEmoteImg.push_back(sprite);
}
@@ -104,7 +104,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
if (Client::getGuiAlpha() != mAlpha && mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
- Graphics *g = static_cast<Graphics*>(graphics);
+ Graphics *const g = static_cast<Graphics *const>(graphics);
graphics->setFont(getFont());
@@ -129,7 +129,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
graphics->setColor(getForegroundColor());
g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
}
- unsigned sz = static_cast<unsigned>(mEmoteImg.size());
+ const unsigned sz = static_cast<unsigned>(mEmoteImg.size());
for (unsigned i = 0; i < mMaxItems; i++)
{
if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite)
@@ -143,10 +143,10 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
&& mEmoteMoved > 0)
{
// Draw the emote image being dragged by the cursor.
- const EmoteSprite* sprite = mEmoteImg[mEmoteMoved - 1];
+ const EmoteSprite *const sprite = mEmoteImg[mEmoteMoved - 1];
if (sprite && sprite->sprite)
{
- const AnimatedSprite *spr = sprite->sprite;
+ const AnimatedSprite *const spr = sprite->sprite;
const int tPosX = mCursorPosX - (spr->getWidth() / 2);
const int tPosY = mCursorPosY - (spr->getHeight() / 2);
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 8421c22df..c7d42338c 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -38,7 +38,7 @@
#include "debug.h"
-ExtendedListBox::ExtendedListBox(gcn::ListModel *listModel):
+ExtendedListBox::ExtendedListBox(gcn::ListModel *const listModel):
ListBox(listModel),
mRowHeight(13)
{
@@ -53,8 +53,9 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
if (!mListModel)
return;
- ExtendedListModel *model = static_cast<ExtendedListModel*>(mListModel);
- Graphics *g = static_cast<Graphics*>(graphics);
+ ExtendedListModel *const model = static_cast<ExtendedListModel* const>(
+ mListModel);
+ Graphics *const g = static_cast<Graphics *const>(graphics);
updateAlpha();
graphics->setFont(getFont());
@@ -78,7 +79,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
- const Image *image = model->getImageAt(i);
+ const Image *const image = model->getImageAt(i);
if (!image)
{
graphics->drawText(mListModel->getElementAt(i), 1, y + textPos);
diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h
index c6f3278fc..44e160da3 100644
--- a/src/gui/widgets/extendedlistbox.h
+++ b/src/gui/widgets/extendedlistbox.h
@@ -29,7 +29,7 @@ class ExtendedListBox : public ListBox
/**
* Constructor.
*/
- ExtendedListBox(gcn::ListModel *listModel);
+ ExtendedListBox(gcn::ListModel *const listModel);
~ExtendedListBox();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index be7e3136d..7302a039b 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -23,7 +23,7 @@
#include "debug.h"
-FlowContainer::FlowContainer(int boxWidth, int boxHeight):
+FlowContainer::FlowContainer(const int boxWidth, const int boxHeight) :
mBoxWidth(boxWidth), mBoxHeight(boxHeight),
mGridWidth(1), mGridHeight(1)
{
@@ -42,7 +42,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
return;
}
- int itemCount = static_cast<int>(mWidgets.size());
+ const int itemCount = static_cast<int>(mWidgets.size());
if (!mBoxWidth)
mGridWidth = getWidth();
@@ -70,7 +70,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
for (WidgetList::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
- int x = i % mGridWidth * mBoxWidth;
+ const int x = i % mGridWidth * mBoxWidth;
(*it)->setPosition(x, height);
i++;
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index e5eeebdcb..c58a8f121 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -38,7 +38,7 @@ class FlowContainer : public Container,
/**
* Constructor. Initializes the shortcut container.
*/
- FlowContainer(int boxWidth, int boxHeight);
+ FlowContainer(const int boxWidth, const int boxHeight);
/**
* Destructor.
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 63ea96db0..0101ed974 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -89,7 +89,7 @@ void GuiTableActionListener::action(const gcn::ActionEvent
}
-GuiTable::GuiTable(TableModel *initial_model, bool opacity) :
+GuiTable::GuiTable(TableModel *const initial_model, const bool opacity) :
mLinewiseMode(false),
mWrappingEnabled(false),
mOpaque(opacity),
@@ -119,7 +119,7 @@ TableModel *GuiTable::getModel() const
return mModel;
}
-void GuiTable::setModel(TableModel *new_model)
+void GuiTable::setModel(TableModel *const new_model)
{
if (mModel)
{
@@ -142,8 +142,8 @@ void GuiTable::recomputeDimensions()
if (!mModel)
return;
- int rows_nr = mModel->getRows();
- int columns_nr = mModel->getColumns();
+ const int rows_nr = mModel->getRows();
+ const int columns_nr = mModel->getColumns();
int width = 0;
int height = 0;
@@ -178,7 +178,7 @@ int GuiTable::getSelectedColumn() const
return mSelectedColumn;
}
-void GuiTable::setLinewiseSelection(bool linewise)
+void GuiTable::setLinewiseSelection(const bool linewise)
{
mLinewiseMode = linewise;
}
@@ -263,14 +263,14 @@ void GuiTable::installActionListeners()
if (!mModel)
return;
- int rows = mModel->getRows();
- int columns = mModel->getColumns();
+ const int rows = mModel->getRows();
+ const int columns = mModel->getColumns();
for (int row = 0; row < rows; ++row)
{
for (int column = 0; column < columns; ++column)
{
- gcn::Widget *widget = mModel->getElementAt(row, column);
+ gcn::Widget *const widget = mModel->getElementAt(row, column);
if (widget)
{
mActionListeners.push_back(new GuiTableActionListener(
@@ -317,11 +317,11 @@ void GuiTable::draw(gcn::Graphics* graphics)
// Now determine the first and last column
// Take the easy way out; these are usually bounded and all visible.
- unsigned first_column = 0;
- unsigned last_column1 = mModel->getColumns();
+ const unsigned first_column = 0;
+ const unsigned last_column1 = mModel->getColumns();
// Set up everything for drawing
- int height = getRowHeight();
+ const int height = getRowHeight();
int y_offset = first_row * height;
for (unsigned r = first_row; r < first_row + rows_nr; ++r)
@@ -330,8 +330,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
for (unsigned c = first_column; c + 1 <= last_column1; ++c)
{
- gcn::Widget *widget = mModel->getElementAt(r, c);
- int width = getColumnWidth(c);
+ gcn::Widget *const widget = mModel->getElementAt(r, c);
+ const int width = getColumnWidth(c);
if (widget)
{
gcn::Rectangle bounds(x_offset, y_offset, width, height);
@@ -376,7 +376,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mTopWidget)
{
- gcn::Rectangle bounds = mTopWidget->getDimension();
+ const gcn::Rectangle bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
mTopWidget->draw(graphics);
graphics->popClipArea();
@@ -404,7 +404,7 @@ gcn::Rectangle GuiTable::getChildrenArea()
// -- KeyListener notifications
void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
- int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
if (action == Input::KEY_GUI_SELECT)
{
@@ -453,8 +453,8 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
{
- int row = getRowForY(mouseEvent.getY());
- int column = getColumnForX(mouseEvent.getX());
+ const int row = getRowForY(mouseEvent.getY());
+ const int column = getColumnForX(mouseEvent.getX());
if (row > -1 && column > -1 &&
row < mModel->getRows() && column < mModel->getColumns())
@@ -521,15 +521,15 @@ void GuiTable::modelUpdated(bool completed)
gcn::Widget *GuiTable::getWidgetAt(int x, int y)
{
- int row = getRowForY(y);
- int column = getColumnForX(x);
+ const int row = getRowForY(y);
+ const int column = getColumnForX(x);
if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
return mTopWidget;
if (mModel && row > -1 && column > -1)
{
- gcn::Widget *w = mModel->getElementAt(row, column);
+ gcn::Widget *const w = mModel->getElementAt(row, column);
if (w && w->isFocusable())
return w;
else
@@ -588,7 +588,7 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
{
for (int c = 0; c < mModel->getColumns(); ++c)
{
- gcn::Widget *w = mModel->getElementAt(r, c);
+ gcn::Widget *const w = mModel->getElementAt(r, c);
if (w)
w->_setFocusHandler(focusHandler);
}
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index d5810fcbf..f00a3cbf3 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -53,8 +53,8 @@ class GuiTable : public gcn::Widget,
friend class GuiTableActionListener;
public:
- GuiTable(TableModel * initial_model = nullptr,
- bool opacity = true);
+ GuiTable(TableModel *const initial_model = nullptr,
+ const bool opacity = true);
virtual ~GuiTable();
@@ -71,7 +71,7 @@ public:
* the widget have been triggered. To be notified after such an update, add
* an action listener to the table instead.
*/
- void setModel(TableModel *m);
+ void setModel(TableModel *const m);
void setSelected(int row, int column);
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index 5bf81c5d8..91632bf55 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -23,10 +23,10 @@
#include "debug.h"
-HorizontContainer::HorizontContainer(int height, int spacing):
- mSpacing(spacing),
- mCount(0),
- mLastX(spacing)
+HorizontContainer::HorizontContainer(const int height, const int spacing) :
+ mSpacing(spacing),
+ mCount(0),
+ mLastX(spacing)
{
setHeight(height);
addWidgetListener(this);
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 8e1d082ac..b41370ac1 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -34,7 +34,7 @@
class HorizontContainer : public Container, public gcn::WidgetListener
{
public:
- HorizontContainer(int height, int spacing);
+ HorizontContainer(const int height, const int spacing);
virtual void add(gcn::Widget *widget);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 9cb42a9f7..e7404ad93 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -36,14 +36,14 @@ Icon::Icon(const std::string &file)
setSize(mImage->mBounds.w, mImage->mBounds.h);
}
-Icon::Icon(Image *image)
+Icon::Icon(Image *const image)
: mImage(image)
{
if (mImage)
setSize(mImage->mBounds.w, mImage->mBounds.h);
}
-void Icon::setImage(Image *image)
+void Icon::setImage(Image *const image)
{
mImage = image;
if (mImage)
@@ -54,7 +54,7 @@ void Icon::draw(gcn::Graphics *g)
{
if (mImage)
{
- Graphics *graphics = static_cast<Graphics*>(g);
+ Graphics *const graphics = static_cast<Graphics*>(g);
const int x = (getWidth() - mImage->mBounds.w) / 2;
const int y = (getHeight() - mImage->mBounds.h) / 2;
graphics->drawImage(mImage, x, y);
diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h
index 98fee314a..150f34576 100644
--- a/src/gui/widgets/icon.h
+++ b/src/gui/widgets/icon.h
@@ -43,7 +43,7 @@ class Icon : public gcn::Widget
/**
* Constructor, uses an existing Image.
*/
- Icon(Image *image);
+ Icon(Image *const image);
/**
* Gets the current Image.
@@ -54,7 +54,7 @@ class Icon : public gcn::Widget
/**
* Sets the image to display.
*/
- void setImage(Image *image);
+ void setImage(Image *const image);
/**
* Draws the Icon.
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index fbc51ee3d..bb7de3a13 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -31,8 +31,8 @@
#include "debug.h"
-IntTextField::IntTextField(int def, int min, int max,
- bool enabled, int width):
+IntTextField::IntTextField(const int def, const int min, const int max,
+ const bool enabled, const int width) :
TextField(toString(def)),
mDefault(def),
mValue(def)
@@ -47,7 +47,7 @@ IntTextField::IntTextField(int def, int min, int max,
void IntTextField::keyPressed(gcn::KeyEvent &event)
{
- int action = static_cast<KeyEvent*>(&event)->getActionId();
+ const int action = static_cast<KeyEvent*>(&event)->getActionId();
if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE)
{
@@ -71,7 +71,7 @@ void IntTextField::keyPressed(gcn::KeyEvent &event)
distributeActionEvent();
}
-void IntTextField::setRange(int min, int max)
+void IntTextField::setRange(const int min, const int max)
{
mMin = min;
mMax = max;
@@ -87,12 +87,12 @@ void IntTextField::setRange(int min, int max)
mDefault = mMax;
}
-int IntTextField::getValue()
+int IntTextField::getValue() const
{
return getText().empty() ? mMin : mValue;
}
-void IntTextField::setValue(int i)
+void IntTextField::setValue(const int i)
{
if (i < mMin)
mValue = mMin;
@@ -106,7 +106,7 @@ void IntTextField::setValue(int i)
setCaretPosition(static_cast<unsigned>(valStr.length()) + 1);
}
-void IntTextField::setDefaultValue(int value)
+void IntTextField::setDefaultValue(const int value)
{
if (value < mMin)
mDefault = mMin;
diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h
index 7284c9d03..0f92692f3 100644
--- a/src/gui/widgets/inttextfield.h
+++ b/src/gui/widgets/inttextfield.h
@@ -34,18 +34,18 @@ class IntTextField : public TextField
/**
* Constructor, sets default value.
*/
- IntTextField(int def = 0, int min = 0, int max = 0,
- bool enabled = true, int width = 0);
+ IntTextField(const int def = 0, const int min = 0, const int max = 0,
+ const bool enabled = true, const int width = 0);
/**
* Sets the minimum and maximum values of the text box.
*/
- void setRange(int minimum, int maximum);
+ void setRange(const int minimum, const int maximum);
/**
* Returns the value in the text box.
*/
- int getValue();
+ int getValue() const;
/**
* Reset the field to the default value.
@@ -55,12 +55,12 @@ class IntTextField : public TextField
/**
* Set the value of the text box to the specified value.
*/
- void setValue(int value);
+ void setValue(const int value);
/**
* Set the default value of the text box to the specified value.
*/
- void setDefaultValue(int value);
+ void setDefaultValue(const int value);
/**
* Responds to key presses.
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ba359118f..d0331fb37 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 43;
class ItemIdPair
{
public:
- ItemIdPair(int id, Item* item) :
+ ItemIdPair(const int id, Item *const item) :
mId(id), mItem(item)
{
}
@@ -70,7 +70,8 @@ class ItemIdPair
class SortItemAlphaFunctor
{
public:
- bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ bool operator() (const ItemIdPair *const pair1,
+ const ItemIdPair *const pair2) const
{
if (!pair1 || !pair2)
return false;
@@ -83,7 +84,8 @@ class SortItemAlphaFunctor
class SortItemIdFunctor
{
public:
- bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ bool operator() (const ItemIdPair *const pair1,
+ const ItemIdPair *const pair2) const
{
if (!pair1 || !pair2)
return false;
@@ -95,7 +97,8 @@ class SortItemIdFunctor
class SortItemWeightFunctor
{
public:
- bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ bool operator() (const ItemIdPair *const pair1,
+ const ItemIdPair *const pair2) const
{
if (!pair1 || !pair2)
return false;
@@ -114,7 +117,8 @@ class SortItemWeightFunctor
class SortItemAmountFunctor
{
public:
- bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ bool operator() (const ItemIdPair *const pair1,
+ const ItemIdPair *const pair2) const
{
if (!pair1 || !pair2)
return false;
@@ -133,7 +137,8 @@ class SortItemAmountFunctor
class SortItemTypeFunctor
{
public:
- bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ bool operator() (const ItemIdPair *const pair1,
+ const ItemIdPair *const pair2) const
{
if (!pair1 || !pair2)
return false;
@@ -149,7 +154,8 @@ class SortItemTypeFunctor
}
} itemTypeSorter;
-ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
+ItemContainer::ItemContainer(Inventory *const inventory,
+ const bool forceQuantity) :
mInventory(inventory),
mGridColumns(1),
mGridRows(1),
@@ -208,7 +214,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
if (!mInventory || !mShowMatrix)
return;
- Graphics *g = static_cast<Graphics*>(graphics);
+ Graphics *const g = static_cast<Graphics *const>(graphics);
g->setFont(getFont());
@@ -218,16 +224,17 @@ void ItemContainer::draw(gcn::Graphics *graphics)
{
int itemX = i * BOX_WIDTH;
int itemY = j * BOX_HEIGHT;
- int itemIndex = j * mGridColumns + i;
+ const int itemIndex = j * mGridColumns + i;
if (mShowMatrix[itemIndex] < 0)
continue;
- Item *item = mInventory->getItem(mShowMatrix[itemIndex]);
+ const Item *const item = mInventory->getItem(
+ mShowMatrix[itemIndex]);
if (!item || item->getId() == 0)
continue;
- Image *image = item->getImage();
+ Image *const image = item->getImage();
if (image)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
@@ -289,7 +296,7 @@ void ItemContainer::selectNone()
// skillDialog->setItemSelected(-1);
}
-void ItemContainer::setSelectedIndex(int newIndex)
+void ItemContainer::setSelectedIndex(const int newIndex)
{
if (mSelectedIndex != newIndex)
{
@@ -348,7 +355,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
if (index == Inventory::NO_SLOT_INDEX)
return;
- Item *item = mInventory->getItem(index);
+ Item *const item = mInventory->getItem(index);
// put item name into chat window
if (item && mDescItems && chatWindow)
@@ -363,7 +370,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
- int num = itemShortcutWindow->getTabIndex();
+ const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS))
{
if (itemShortcut[num])
@@ -415,7 +422,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
return;
};
- int index = getSlotIndex(event.getX(), event.getY());
+ const int index = getSlotIndex(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
@@ -431,7 +438,8 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event)
if (!mInventory)
return;
- Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY()));
+ const Item *const item = mInventory->getItem(
+ getSlotIndex(event.getX(), event.getY()));
if (item && viewport)
{
@@ -487,7 +495,7 @@ void ItemContainer::updateMatrix()
for (unsigned idx = 0; idx < mInventory->getSize(); idx ++)
{
- Item *item = mInventory->getItem(idx);
+ Item *const item = mInventory->getItem(idx);
if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
continue;
@@ -551,14 +559,14 @@ void ItemContainer::updateMatrix()
delete sortedItems[idx];
}
-int ItemContainer::getSlotIndex(int x, int y) const
+int ItemContainer::getSlotIndex(const int x, const int y) const
{
if (!mShowMatrix)
return Inventory::NO_SLOT_INDEX;
if (x < getWidth() && y < getHeight())
{
- int idx = (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH);
+ const int idx = (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH);
if (idx < mGridRows * mGridColumns && mShowMatrix[idx] >= 0)
return mShowMatrix[idx];
}
@@ -599,7 +607,7 @@ void ItemContainer::keyAction()
}
}
-void ItemContainer::moveHighlight(Direction direction)
+void ItemContainer::moveHighlight(const Direction direction)
{
if (mHighlightedIndex == -1)
{
@@ -645,13 +653,13 @@ void ItemContainer::moveHighlight(Direction direction)
}
}
-void ItemContainer::setFilter (int tag)
+void ItemContainer::setFilter(const int tag)
{
mTag = tag;
updateMatrix();
}
-void ItemContainer::setSortType (int sortType)
+void ItemContainer::setSortType(const int sortType)
{
mSortType = sortType;
updateMatrix();
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 0ad95fd1b..f39af8d7e 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -60,7 +60,8 @@ class ItemContainer : public gcn::Widget,
* @param gridRows Amount of rows in grid.
* @param offset Index offset
*/
- ItemContainer(Inventory *inventory, bool forceQuantity = false);
+ ItemContainer(Inventory *const inventory,
+ const bool forceQuantity = false);
/**
* Destructor.
@@ -117,9 +118,9 @@ class ItemContainer : public gcn::Widget,
void removeSelectionListener(gcn::SelectionListener *listener)
{ mSelectionListeners.remove(listener); }
- void setFilter (int tag);
+ void setFilter(const int tag);
- void setSortType (int sortType);
+ void setSortType(const int sortType);
void setName(std::string str)
{ mName = str; }
@@ -157,12 +158,12 @@ class ItemContainer : public gcn::Widget,
*
* @param direction The move direction of the highlighter.
*/
- void moveHighlight(Direction direction);
+ void moveHighlight(const Direction direction);
/**
* Sets the currently selected item.
*/
- void setSelectedIndex(int index);
+ void setSelectedIndex(const int index);
/**
* Determine and set the height of the container.
@@ -181,7 +182,7 @@ class ItemContainer : public gcn::Widget,
* @param y The Y coordinate position.
* @return The slot index on success, -1 on failure.
*/
- int getSlotIndex(int x, int y) const;
+ int getSlotIndex(const int x, const int y) const;
Inventory *mInventory;