summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-15 23:05:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-15 23:05:16 +0300
commitb162094c7609fa37f2eef6be3fed0e26830bc506 (patch)
tree072b83f0ce6b7f871acd9a2d2c6c49b8dac7dc64 /src
parent4031a5068859fb99f604dfecceb2fb1c954e166f (diff)
downloadmv-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.gz
mv-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.bz2
mv-b162094c7609fa37f2eef6be3fed0e26830bc506.tar.xz
mv-b162094c7609fa37f2eef6be3fed0e26830bc506.zip
Improve a bit widgets speed.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp8
-rw-r--r--src/gui/widgets/browserbox.cpp6
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/extendedlistbox.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/label.cpp4
-rw-r--r--src/gui/widgets/listbox.cpp4
-rw-r--r--src/gui/widgets/radiobutton.cpp4
-rw-r--r--src/gui/widgets/scrollarea.cpp76
-rw-r--r--src/gui/widgets/scrollarea.h3
-rw-r--r--src/gui/widgets/setupitem.cpp5
-rw-r--r--src/gui/widgets/setuptabscroll.cpp18
-rw-r--r--src/gui/widgets/setuptabscroll.h2
-rw-r--r--src/gui/widgets/shopitems.cpp10
-rw-r--r--src/gui/widgets/shopitems.h6
-rw-r--r--src/gui/widgets/shoplistbox.cpp15
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/sliderlist.cpp8
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/tab.cpp8
-rw-r--r--src/gui/widgets/tabbedarea.cpp28
-rw-r--r--src/gui/widgets/textbox.h2
-rw-r--r--src/gui/widgets/textfield.cpp12
-rw-r--r--src/gui/widgets/textpreview.cpp12
-rw-r--r--src/gui/widgets/vertcontainer.cpp4
-rw-r--r--src/gui/widgets/window.cpp143
-rw-r--r--src/guichan/widgets/label.cpp2
-rw-r--r--src/guichan/widgets/textbox.cpp6
-rw-r--r--src/guichan/widgets/textfield.cpp2
31 files changed, 205 insertions, 207 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 8de202120..1301d4a2e 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -64,7 +64,7 @@ AvatarListBox::AvatarListBox(AvatarListModel *const model) :
config.addListener("showgender", this);
config.addListener("showlevel", this);
- setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mForegroundColor = Theme::getThemeColor(Theme::TEXT);
}
AvatarListBox::~AvatarListBox()
@@ -112,7 +112,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
const std::string name = player_node->getName();
// Draw the list elements
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
for (int i = 0, y = 0;
i < model->getNumberOfElements();
++i, y += fontHeight)
@@ -186,7 +186,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
if (a->getLevel() > 1)
{
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
int minHp = 40 + ((a->getLevel() - 1) * 5);
if (minHp < 0)
minHp = 40;
@@ -263,7 +263,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 9c281de86..c657d1e0e 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -78,7 +78,7 @@ BrowserBox::BrowserBox(const unsigned int mode, const bool opaque) :
mColors[PURPLE] = Theme::getThemeColor(Theme::PURPLE);
mColors[GRAY] = Theme::getThemeColor(Theme::GRAY);
mColors[BROWN] = Theme::getThemeColor(Theme::BROWN);
- setForegroundColor(Theme::getThemeColor(Theme::BROWSERBOX));
+ mForegroundColor = Theme::getThemeColor(Theme::BROWSERBOX);
}
BrowserBox::~BrowserBox()
@@ -424,8 +424,8 @@ int BrowserBox::calcHeight()
char const *const hyphen = "~";
const int hyphenWidth = font->getWidth(hyphen);
- gcn::Color selColor = getForegroundColor();
- const gcn::Color textColor = getForegroundColor();
+ gcn::Color selColor = mForegroundColor;
+ const gcn::Color &textColor = mForegroundColor;
ResourceManager *const resman = ResourceManager::getInstance();
mLineParts.clear();
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 344b99eb0..44d504d2c 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -97,7 +97,7 @@ CheckBox::CheckBox(const std::string &caption, const bool selected,
if (listener)
addActionListener(listener);
- setForegroundColor(Theme::getThemeColor(Theme::CHECKBOX));
+ mForegroundColor = Theme::getThemeColor(Theme::CHECKBOX);
}
CheckBox::~CheckBox()
@@ -144,7 +144,7 @@ void CheckBox::draw(gcn::Graphics* graphics)
drawBox(graphics);
graphics->setFont(getFont());
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
const int h = getHeight() + getHeight() / 2;
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 0aab1f165..5cb624772 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -181,7 +181,7 @@ void DropDown::draw(gcn::Graphics* graphics)
if (mListBox->getListModel() && mListBox->getSelected() >= 0)
{
graphics->setFont(getFont());
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawText(mListBox->getListModel()->getElementAt(
mListBox->getSelected()), 1, 0);
}
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 784587708..a7bb46433 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -81,7 +81,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
- setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mForegroundColor = Theme::getThemeColor(Theme::TEXT);
}
EmoteShortcutContainer::~EmoteShortcutContainer()
@@ -126,7 +126,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
const std::string key = inputManager.getKeyValueString(
Input::KEY_EMOTE_1 + i);
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
}
const unsigned sz = static_cast<unsigned>(mEmoteImg.size());
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index a2c9c0691..610b4360c 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -75,7 +75,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
}
// Draw the list elements
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 8ebad55ed..c0cd7e410 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -76,7 +76,7 @@ ItemShortcutContainer::ItemShortcutContainer(const unsigned number) :
mBoxHeight = 1;
mBoxWidth = 1;
}
- setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mForegroundColor = Theme::getThemeColor(Theme::TEXT);
}
ItemShortcutContainer::~ItemShortcutContainer()
@@ -130,7 +130,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
std::string key = inputManager.getKeyValueString(
Input::KEY_SHORTCUT_1 + i);
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 2e17b7d80..e6f603fb2 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -28,13 +28,13 @@
Label::Label() :
gcn::Label()
{
- setForegroundColor(Theme::getThemeColor(Theme::LABEL));
+ mForegroundColor = Theme::getThemeColor(Theme::LABEL);
}
Label::Label(const std::string &caption) :
gcn::Label(caption)
{
- setForegroundColor(Theme::getThemeColor(Theme::LABEL));
+ mForegroundColor = Theme::getThemeColor(Theme::LABEL);
}
void Label::draw(gcn::Graphics *graphics)
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index dcd27e671..e588f2a66 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -45,7 +45,7 @@ ListBox::ListBox(gcn::ListModel *const listModel):
mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
mDistributeMousePressed(true)
{
- setForegroundColor(Theme::getThemeColor(Theme::LISTBOX));
+ mForegroundColor = Theme::getThemeColor(Theme::LISTBOX);
}
ListBox::~ListBox()
@@ -82,7 +82,7 @@ void ListBox::draw(gcn::Graphics *graphics)
}
// Draw the list elements
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 1daea1d1a..a88a89201 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -48,7 +48,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group,
gcn::RadioButton(caption, group, marked),
mHasMouse(false)
{
- setForegroundColor(Theme::getThemeColor(Theme::RADIOBUTTON));
+ mForegroundColor = Theme::getThemeColor(Theme::RADIOBUTTON);
if (instances == 0)
{
if (Theme::instance())
@@ -151,7 +151,7 @@ void RadioButton::draw(gcn::Graphics* graphics)
drawBox(graphics);
graphics->setFont(getFont());
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawText(getCaption(), 16, 0);
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 9d8be9717..d7042579f 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -177,9 +177,6 @@ void ScrollArea::init(std::string skinName)
}
instances++;
-
- mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32);
- mBackground = Theme::getThemeColor(Theme::BACKGROUND);
}
void ScrollArea::logic()
@@ -194,38 +191,27 @@ void ScrollArea::logic()
// the content dimension exactly.
if (content)
{
- if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
+ const unsigned int frameSize = 2 * content->getFrameSize();
+ if (mHPolicy == gcn::ScrollArea::SHOW_NEVER)
{
- content->setWidth(getChildrenArea().width -
- 2 * content->getFrameSize());
+ content->setWidth((mVBarVisible ? (mDimension.width
+ - mScrollbarWidth) : mDimension.width) - frameSize);
}
- if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
+ if (mVPolicy == gcn::ScrollArea::SHOW_NEVER)
{
- content->setHeight(getChildrenArea().height -
- 2 * content->getFrameSize());
+ content->setHeight((mHBarVisible ? (mDimension.height
+ - mScrollbarWidth) : mDimension.height) - frameSize);
}
}
if (mUpButtonPressed)
- {
- setVerticalScrollAmount(getVerticalScrollAmount() -
- mUpButtonScrollAmount);
- }
+ setVerticalScrollAmount(mVScroll - mUpButtonScrollAmount);
else if (mDownButtonPressed)
- {
- setVerticalScrollAmount(getVerticalScrollAmount() +
- mDownButtonScrollAmount);
- }
+ setVerticalScrollAmount(mVScroll + mDownButtonScrollAmount);
else if (mLeftButtonPressed)
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount() -
- mLeftButtonScrollAmount);
- }
+ setHorizontalScrollAmount(mHScroll - mLeftButtonScrollAmount);
else if (mRightButtonPressed)
- {
- setHorizontalScrollAmount(getHorizontalScrollAmount() +
- mRightButtonScrollAmount);
- }
+ setHorizontalScrollAmount(mHScroll + mRightButtonScrollAmount);
}
void ScrollArea::updateAlpha()
@@ -291,7 +277,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
{
// because we don't know where parent windows was moved,
// need recalc vertexes
- gcn::ClipRectangle &rect = static_cast<Graphics*>(
+ const gcn::ClipRectangle &rect = static_cast<Graphics*>(
graphics)->getTopClip();
if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
{
@@ -393,7 +379,7 @@ void ScrollArea::drawRightButton(gcn::Graphics *const graphics)
void ScrollArea::drawVBar(gcn::Graphics *const graphics)
{
- const gcn::Rectangle dim = getVerticalBarDimension();
+ const gcn::Rectangle &dim = getVerticalBarDimension();
Graphics *const g = static_cast<Graphics*>(graphics);
if (vBackground.grid[4])
@@ -416,7 +402,7 @@ void ScrollArea::drawVBar(gcn::Graphics *const graphics)
void ScrollArea::drawHBar(gcn::Graphics *const graphics)
{
- const gcn::Rectangle dim = getHorizontalBarDimension();
+ const gcn::Rectangle &dim = getHorizontalBarDimension();
Graphics *const g = static_cast<Graphics*>(graphics);
if (hBackground.grid[4])
@@ -441,9 +427,9 @@ void ScrollArea::drawHBar(gcn::Graphics *const graphics)
void ScrollArea::drawVMarker(gcn::Graphics *const graphics)
{
- const gcn::Rectangle dim = getVerticalMarkerDimension();
+ const gcn::Rectangle &dim = getVerticalMarkerDimension();
- if ((mHasMouse) && (mX > (getWidth() - getScrollbarWidth())))
+ if ((mHasMouse) && (mX > (getWidth() - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->
drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -459,7 +445,7 @@ void ScrollArea::drawHMarker(gcn::Graphics *const graphics)
{
const gcn::Rectangle dim = getHorizontalMarkerDimension();
- if ((mHasMouse) && (mY > (getHeight() - getScrollbarWidth())))
+ if ((mHasMouse) && (mY > (getHeight() - mScrollbarWidth)))
{
static_cast<Graphics*>(graphics)->
drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi);
@@ -490,8 +476,8 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED)
void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED)
{
mRedraw = true;
- getContent()->setSize(getWidth() - 2 * getFrameSize(),
- getHeight() - 2 * getFrameSize());
+ const unsigned int frameSize = 2 * getFrameSize();
+ getContent()->setSize(getWidth() - frameSize, getHeight() - frameSize);
}
void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED)
@@ -526,21 +512,33 @@ void ScrollArea::mouseReleased(gcn::MouseEvent& event)
if (dx)
{
- int s = getHorizontalScrollAmount() + dx;
+ int s = mHScroll + dx;
if (s < 0)
+ {
s = 0;
- else if (s > getHorizontalMaxScroll())
- s = getHorizontalMaxScroll();
+ }
+ else
+ {
+ const int maxH = getHorizontalMaxScroll();
+ if (s > maxH)
+ s = maxH;
+ }
setHorizontalScrollAmount(s);
}
if (dy)
{
- int s = getVerticalScrollAmount() + dy;
+ int s = mVScroll + dy;
if (s < 0)
+ {
s = 0;
- else if (s > getVerticalMaxScroll())
- s = getVerticalMaxScroll();
+ }
+ else
+ {
+ const int maxV = getVerticalMaxScroll();
+ if (s > maxV)
+ s = maxV;
+ }
setVerticalScrollAmount(s);
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 4abff1398..870c0eaff 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -160,9 +160,6 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
int mYOffset;
int mDrawWidth;
int mDrawHeight;
-
- gcn::Color mGray;
- gcn::Color mBackground;
};
#endif
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 618011dee..82d5132a3 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -174,8 +174,9 @@ void SetupItem::externalUpdated(std::string eventName A_UNUSED)
void SetupItem::fixFirstItemSize(gcn::Widget *const widget)
{
- if (widget->getWidth() < mParent->getPreferredFirstItemSize())
- widget->setWidth(mParent->getPreferredFirstItemSize());
+ const int maxSize = mParent->getPreferredFirstItemSize();
+ if (widget->getWidth() < maxSize)
+ widget->setWidth(maxSize);
}
SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index c668308c5..554ee5f62 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -66,12 +66,13 @@ void SetupTabScroll::addControl(SetupItem *const widget)
delete (*iter).second;
mItems.erase(iter);
}
- mItems[widget->getActionEventId()] = widget;
+ mItems[actionId] = widget;
}
mAllItems.insert(widget);
}
-void SetupTabScroll::addControl(SetupItem *const widget, std::string event)
+void SetupTabScroll::addControl(SetupItem *const widget,
+ const std::string &event)
{
const std::map<std::string, SetupItem*>::iterator iter
= mItems.find(event);
@@ -87,7 +88,8 @@ void SetupTabScroll::addControl(SetupItem *const widget, std::string event)
void SetupTabScroll::apply()
{
for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ iter = mItems.begin(), iter_end = mItems.end();
+ iter != iter_end; ++ iter)
{
if ((*iter).second)
(*iter).second->apply((*iter).first);
@@ -97,7 +99,8 @@ void SetupTabScroll::apply()
void SetupTabScroll::cancel()
{
for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ iter = mItems.begin(), iter_end = mItems.end();
+ iter != iter_end; ++ iter)
{
if ((*iter).second)
(*iter).second->cancel((*iter).first);
@@ -107,10 +110,11 @@ void SetupTabScroll::cancel()
void SetupTabScroll::externalUpdated()
{
for (std::map<std::string, SetupItem*>::const_iterator
- iter = mItems.begin(); iter != mItems.end(); ++ iter)
+ iter = mItems.begin(), iter_end = mItems.end();
+ iter != iter_end; ++ iter)
{
- const SetupItem *const widget = (*iter).second;
+ SetupItem *const widget = (*iter).second;
if (widget && !widget->isMainConfig())
- (*iter).second->externalUpdated((*iter).first);
+ widget->externalUpdated((*iter).first);
}
}
diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h
index 2bd723434..77103323a 100644
--- a/src/gui/widgets/setuptabscroll.h
+++ b/src/gui/widgets/setuptabscroll.h
@@ -41,7 +41,7 @@ class SetupTabScroll : public SetupTab
void addControl(SetupItem *const widget);
- void addControl(SetupItem *const widget, std::string event);
+ void addControl(SetupItem *const widget, const std::string &event);
VertContainer *getContainer() const
{ return mContainer; }
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index d91e25304..7aa8f40b4 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -38,16 +38,6 @@ ShopItems::~ShopItems()
clear();
}
-int ShopItems::getNumberOfElements()
-{
- return static_cast<int>(mShopItems.size());
-}
-
-bool ShopItems::empty() const
-{
- return mShopItems.empty();
-}
-
std::string ShopItems::getElementAt(int i)
{
if (i < 0 || static_cast<unsigned>(i) >= mShopItems.size()
diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h
index ff1b0ca7a..038c10093 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/widgets/shopitems.h
@@ -77,9 +77,11 @@ class ShopItems : public gcn::ListModel
/**
* Returns the number of items in the shop.
*/
- int getNumberOfElements();
+ int getNumberOfElements()
+ { return static_cast<int>(mShopItems.size()); }
- bool empty() const;
+ bool empty() const
+ { return mShopItems.empty(); }
/**
* Returns the name of item number i in the shop.
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 0bd126482..480f220ea 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -55,7 +55,7 @@ ShopListBox::ShopListBox(gcn::ListModel *const listModel) :
mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)),
mWarningColor(Theme::getThemeColor(Theme::SHOP_WARNING))
{
- setForegroundColor(Theme::getThemeColor(Theme::LISTBOX));
+ mForegroundColor = Theme::getThemeColor(Theme::LISTBOX);
}
ShopListBox::ShopListBox(gcn::ListModel *const listModel,
@@ -70,7 +70,7 @@ ShopListBox::ShopListBox(gcn::ListModel *const listModel,
mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)),
mWarningColor(Theme::getThemeColor(Theme::SHOP_WARNING))
{
- setForegroundColor(Theme::getThemeColor(Theme::LISTBOX));
+ mForegroundColor = Theme::getThemeColor(Theme::LISTBOX);
}
void ShopListBox::init()
@@ -91,12 +91,11 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = Client::getGuiAlpha();
const int alpha = static_cast<int>(mAlpha * 255.0f);
- mHighlightColor.a = alpha;
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
graphics->setFont(getFont());
- graphics->setColor(getForegroundColor());
+// graphics->setColor(mForegroundColor);
// Draw the list elements
for (int i = 0, y = 0;
@@ -106,7 +105,6 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
bool needDraw(false);
gcn::Color temp;
gcn::Color* backgroundColor = &mBackgroundColor;
- mBackgroundColor.a = alpha;
if (mShopItems && mShopItems->at(i) &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
@@ -129,9 +127,14 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
}
else if (i == mSelected)
{
+ mHighlightColor.a = alpha;
backgroundColor = &mHighlightColor;
needDraw = true;
}
+ else
+ {
+ mBackgroundColor.a = alpha;
+ }
if (needDraw)
{
@@ -149,7 +152,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, 1, y);
}
}
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5,
y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
}
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 97c4d1b7d..13c20790a 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -63,8 +63,8 @@ void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED)
int ShortcutContainer::getIndexFromGrid(const int pointX,
const int pointY) const
{
- const gcn::Rectangle tRect = gcn::Rectangle(0, 0, mGridWidth * mBoxWidth,
- mGridHeight * mBoxHeight);
+ const gcn::Rectangle tRect = gcn::Rectangle(0, 0,
+ mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth;
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index ad7fde18f..bd10988fa 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -188,10 +188,11 @@ void SliderList::setSelected(int idx)
return;
mSelectedIndex = idx;
- if (mSelectedIndex >= mListModel->getNumberOfElements())
+ const int num = mListModel->getNumberOfElements();
+ if (mSelectedIndex >= num)
mSelectedIndex = 0;
if (mSelectedIndex < 0)
- mSelectedIndex = mListModel->getNumberOfElements() - 1;
+ mSelectedIndex = num - 1;
updateLabel();
}
@@ -209,7 +210,8 @@ int SliderList::getMaxLabelWidth()
int maxWidth = 0;
const SDLFont *const font = gui->getFont();
- for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
+ const int num = mListModel->getNumberOfElements();
+ for (int f = 0; f < num; f ++)
{
const int w = font->getWidth(mListModel->getElementAt(f));
if (w > maxWidth)
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 7b02b3281..78d112908 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -74,7 +74,7 @@ SpellShortcutContainer::SpellShortcutContainer(const unsigned number) :
mBoxHeight = 1;
mBoxWidth = 1;
}
- setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mForegroundColor = Theme::getThemeColor(Theme::TEXT);
}
SpellShortcutContainer::~SpellShortcutContainer()
@@ -103,7 +103,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
graphics->setFont(getFont());
const int selectedId = spellShortcut->getSelectedItem();
- g->setColor(getForegroundColor());
+ g->setColor(mForegroundColor);
if (mBackgroundImg)
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 124579fab..e002c03fe 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -100,13 +100,11 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- if (Theme::instance())
+ Theme *const theme = Theme::instance();
+ if (theme)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
- {
- Theme::instance()->loadRect(tabImg[mode],
- data[mode], "tab.xml");
- }
+ theme->loadRect(tabImg[mode], data[mode], "tab.xml");
}
updateAlpha();
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 06af8a83a..1cc990f21 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -139,10 +139,9 @@ void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget)
gcn::TabbedArea::addTab(tab, widget);
- const int width = getWidth() - 2 * getFrameSize();
- const int height = getHeight() - 2 * getFrameSize()
- - mTabContainer->getHeight();
- widget->setSize(width, height);
+ const int frameSize = 2 * getFrameSize();
+ widget->setSize(getWidth() - frameSize,
+ getHeight() - frameSize - mTabContainer->getHeight());
updateTabsWidth();
updateArrowEnableState();
@@ -193,8 +192,9 @@ void TabbedArea::removeTab(gcn::Tab *tab)
}
}
- if (tabIndexToBeSelected >= static_cast<signed>(mTabs.size()))
- tabIndexToBeSelected = static_cast<int>(mTabs.size()) - 1;
+ const int tabsSize = static_cast<int>(mTabs.size());
+ if (tabIndexToBeSelected >= tabsSize)
+ tabIndexToBeSelected = tabsSize - 1;
if (tabIndexToBeSelected < -1)
tabIndexToBeSelected = -1;
@@ -269,10 +269,11 @@ void TabbedArea::setSelectedTabByPos(int tab)
void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
{
- const int width = getWidth() - 2 * getFrameSize()
- - 2 * mWidgetContainer->getFrameSize();
- const int height = getHeight() - 2 * getFrameSize()
- - mWidgetContainer->getY() - 2 * mWidgetContainer->getFrameSize();
+ const int frameSize = 2 * getFrameSize();
+ const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize();
+ const int width = getWidth() - frameSize - widgetFrameSize;
+ const int height = getHeight() - frameSize
+ - mWidgetContainer->getY() - widgetFrameSize;
mWidgetContainer->setSize(width, height);
gcn::Widget *const w = getCurrentWidget();
@@ -356,11 +357,12 @@ void TabbedArea::updateVisibleTabsWidth()
void TabbedArea::adjustTabPositions()
{
int maxTabHeight = 0;
- size_t sz = mTabs.size();
+ const size_t sz = mTabs.size();
for (size_t i = 0; i < sz; ++i)
{
- if (mTabs[i].first && mTabs[i].first->getHeight() > maxTabHeight)
- maxTabHeight = mTabs[i].first->getHeight();
+ const gcn::Tab *const tab = mTabs[i].first;
+ if (tab && tab->getHeight() > maxTabHeight)
+ maxTabHeight = tab->getHeight();
}
int x = mArrowButton[0]->isVisible() ? mArrowButton[0]->getWidth() : 0;
diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h
index aafd79627..dcd289a60 100644
--- a/src/gui/widgets/textbox.h
+++ b/src/gui/widgets/textbox.h
@@ -60,7 +60,7 @@ class TextBox : public gcn::TextBox
inline void draw(gcn::Graphics *graphics)
{
if (mTextColor)
- setForegroundColor(*mTextColor);
+ mForegroundColor = *mTextColor;
gcn::TextBox::draw(graphics);
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index c2189e74a..eb4e2f7cb 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -60,7 +60,7 @@ TextField::TextField(const std::string &text, const bool loseFocusOnTab,
{
setFrameSize(2);
- setForegroundColor(Theme::getThemeColor(Theme::TEXTFIELD));
+ mForegroundColor = Theme::getThemeColor(Theme::TEXTFIELD);
if (instances == 0)
{
@@ -111,7 +111,7 @@ void TextField::draw(gcn::Graphics *graphics)
mXScroll);
}
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
}
@@ -120,10 +120,10 @@ void TextField::drawFrame(gcn::Graphics *graphics)
{
//updateAlpha(); -> Not useful...
- int w, h, bs;
- bs = getFrameSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ int w, h;
+ const int bs = 2 * getFrameSize();
+ w = getWidth() + bs;
+ h = getHeight() + bs;
static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
}
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 43b81b2ce..ab5a8ce28 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -54,10 +54,7 @@ void TextPreview::draw(gcn::Graphics* graphics)
if (Client::getGuiAlpha() != mAlpha)
mAlpha = Client::getGuiAlpha();
- int alpha = static_cast<int>(mAlpha * 255.0f);
-
- if (!mTextAlpha)
- alpha = 255;
+ const int alpha = mTextAlpha ? static_cast<int>(mAlpha * 255.0f) : 255;
if (mOpaque)
{
@@ -82,8 +79,7 @@ void TextPreview::draw(gcn::Graphics* graphics)
graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
}
- TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT,
- gcn::Color(mTextColor->r, mTextColor->g,
- mTextColor->b, alpha),
- mFont, mOutline, mShadow);
+ TextRenderer::renderText(graphics, mText, 2, 2, gcn::Graphics::LEFT,
+ gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha),
+ mFont, mOutline, mShadow);
}
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index a6a4748f3..026a2f6f9 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -79,8 +79,8 @@ void VertContainer::clear()
void VertContainer::widgetResized(const gcn::Event &event A_UNUSED)
{
for (std::vector<gcn::Widget*>::const_iterator
- it = mResizableWidgets.begin();
- it != mResizableWidgets.end(); ++ it)
+ it = mResizableWidgets.begin(), it_end = mResizableWidgets.end();
+ it != it_end; ++ it)
{
(*it)->setWidth(getWidth());
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 39e09ef4a..8c520342a 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -132,7 +132,7 @@ Window::Window(const std::string &caption, const bool modal,
setVisible(false);
addWidgetListener(this);
- setForegroundColor(Theme::getThemeColor(Theme::WINDOW));
+ mForegroundColor = Theme::getThemeColor(Theme::WINDOW);
}
Window::~Window()
@@ -180,8 +180,8 @@ void Window::draw(gcn::Graphics *graphics)
{
mRedraw = false;
update = true;
- g->calcWindow(mVertexes, 0, 0, getWidth(),
- getHeight(), mSkin->getBorder());
+ g->calcWindow(mVertexes, 0, 0, mDimension.width,
+ mDimension.height, mSkin->getBorder());
}
g->drawImageRect2(mVertexes, mSkin->getBorder());
@@ -189,7 +189,7 @@ void Window::draw(gcn::Graphics *graphics)
// Draw title
if (mShowTitle)
{
- g->setColor(getForegroundColor());
+ g->setColor(mForegroundColor);
g->setFont(mCaptionFont);
g->drawText(getCaption(), mCaptionOffsetX, mCaptionOffsetY,
static_cast<gcn::Graphics::Alignment>(mCaptionAlign));
@@ -225,8 +225,8 @@ void Window::draw(gcn::Graphics *graphics)
void Window::setContentSize(int width, int height)
{
- width = width + 2 * getPadding();
- height = height + getPadding() + getTitleBarHeight();
+ width = width + 2 * mPadding;
+ height = height + mPadding + getTitleBarHeight();
if (getMinWidth() > width)
width = getMinWidth();
@@ -251,8 +251,10 @@ void Window::setLocationRelativeTo(const gcn::Widget *const widget)
widget->getAbsolutePosition(wx, wy);
getAbsolutePosition(x, y);
- setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x),
- getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y));
+ setPosition(mDimension.x + (wx + (widget->getWidth()
+ - mDimension.width) / 2 - x),
+ mDimension.y + (wy + (widget->getHeight()
+ - mDimension.height) / 2 - y));
}
void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget)
@@ -266,7 +268,8 @@ void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget)
widget->getAbsolutePosition(wx, wy);
getAbsolutePosition(x, y);
- setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), 0);
+ setPosition(mDimension.x + (wx + (widget->getWidth()
+ - mDimension.width) / 2 - x), 0);
}
void Window::setLocationRelativeTo(const ImageRect::ImagePosition position,
@@ -277,39 +280,39 @@ void Window::setLocationRelativeTo(const ImageRect::ImagePosition position,
}
else if (position == ImageRect::UPPER_CENTER)
{
- offsetX += (mainGraphics->mWidth - getWidth()) / 2;
+ offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
}
else if (position == ImageRect::UPPER_RIGHT)
{
- offsetX += mainGraphics->mWidth - getWidth();
+ offsetX += mainGraphics->mWidth - mDimension.width;
}
else if (position == ImageRect::LEFT)
{
- offsetY += (mainGraphics->mHeight - getHeight()) / 2;
+ offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
}
else if (position == ImageRect::CENTER)
{
- offsetX += (mainGraphics->mWidth - getWidth()) / 2;
- offsetY += (mainGraphics->mHeight - getHeight()) / 2;
+ offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
+ offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
}
else if (position == ImageRect::RIGHT)
{
- offsetX += mainGraphics->mWidth - getWidth();
- offsetY += (mainGraphics->mHeight - getHeight()) / 2;
+ offsetX += mainGraphics->mWidth - mDimension.width;
+ offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
}
else if (position == ImageRect::LOWER_LEFT)
{
- offsetY += mainGraphics->mHeight - getHeight();
+ offsetY += mainGraphics->mHeight - mDimension.height;
}
else if (position == ImageRect::LOWER_CENTER)
{
- offsetX += (mainGraphics->mWidth - getWidth()) / 2;
- offsetY += mainGraphics->mHeight - getHeight();
+ offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
+ offsetY += mainGraphics->mHeight - mDimension.height;
}
else if (position == ImageRect::LOWER_RIGHT)
{
- offsetX += mainGraphics->mWidth - getWidth();
- offsetY += mainGraphics->mHeight - getHeight();
+ offsetX += mainGraphics->mWidth - mDimension.width;
+ offsetY += mainGraphics->mHeight - mDimension.height;
}
setPosition(offsetX, offsetY);
@@ -364,8 +367,10 @@ void Window::setResizable(const bool r)
delete mGrip;
}
mGrip = new ResizeGrip;
- mGrip->setX(getWidth() - mGrip->getWidth() - getChildrenArea().x);
- mGrip->setY(getHeight() - mGrip->getHeight() - getChildrenArea().y);
+ mGrip->setX(mDimension.width - mGrip->getWidth()
+ - getChildrenArea().x);
+ mGrip->setY(mDimension.height - mGrip->getHeight()
+ - getChildrenArea().y);
add(mGrip);
}
else
@@ -382,8 +387,8 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
if (mGrip)
{
- mGrip->setPosition(getWidth() - mGrip->getWidth() - area.x,
- getHeight() - mGrip->getHeight() - area.y);
+ mGrip->setPosition(mDimension.width - mGrip->getWidth() - area.x,
+ mDimension.height - mGrip->getHeight() - area.y);
}
if (mLayout)
@@ -397,7 +402,7 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
if (showClose)
{
const Image *const button = mSkin->getCloseImage(false);
- const int x = getWidth() - button->getWidth() - closePadding;
+ const int x = mDimension.width - button->getWidth() - closePadding;
mCloseRect.x = x;
mCloseRect.y = closePadding;
mCloseRect.width = button->getWidth();
@@ -408,7 +413,7 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
const Image *const button = mSkin->getStickyImage(mSticky);
if (button)
{
- int x = getWidth() - button->getWidth() - closePadding;
+ int x = mDimension.width - button->getWidth() - closePadding;
if (showClose)
x -= mSkin->getCloseImage(false)->getWidth() + closePadding;
@@ -612,11 +617,10 @@ void Window::mouseDragged(gcn::MouseEvent &event)
// Keep guichan window inside screen when it may be moved
if (isMovable() && mMoved)
{
- int newX = std::max(0, getX());
- int newY = std::max(0, getY());
- newX = std::min(mainGraphics->mWidth - getWidth(), newX);
- newY = std::min(mainGraphics->mHeight - getHeight(), newY);
- setPosition(newX, newY);
+ setPosition(std::min(mainGraphics->mWidth - mDimension.width,
+ std::max(0, mDimension.x)),
+ std::min(mainGraphics->mHeight - mDimension.height,
+ std::max(0, mDimension.y)));
}
if (mouseResize && !mMoved)
@@ -644,7 +648,7 @@ void Window::mouseDragged(gcn::MouseEvent &event)
std::max(mMinWinWidth, newWidth));
if (mouseResize & LEFT)
- newDim.x -= newDim.width - getWidth();
+ newDim.x -= newDim.width - mDimension.width;
}
// Keep guichan window inside screen (supports resizing any side)
@@ -665,10 +669,10 @@ void Window::mouseDragged(gcn::MouseEvent &event)
// Update mouse offset when dragging bottom or right border
if (mouseResize & BOTTOM)
- mDragOffsetY += newDim.height - getHeight();
+ mDragOffsetY += newDim.height - mDimension.height;
if (mouseResize & RIGHT)
- mDragOffsetX += newDim.width - getWidth();
+ mDragOffsetX += newDim.width - mDimension.width;
// Set the new window and content dimensions
setDimension(newDim);
@@ -740,13 +744,13 @@ void Window::loadWindowState()
if (viewport)
{
- int width = getWidth();
- int height = getHeight();
+ int width = mDimension.width;
+ int height = mDimension.height;
- if (getX() + width > viewport->getWidth())
- width = viewport->getWidth() - getX();
- if (getY() + height > viewport->getHeight())
- height = viewport->getHeight() - getY();
+ if (mDimension.x + width > viewport->getWidth())
+ width = viewport->getWidth() - mDimension.x;
+ if (mDimension.y + height > viewport->getHeight())
+ height = viewport->getHeight() - mDimension.y;
if (width < 0)
width = 0;
if (height < 0)
@@ -760,8 +764,8 @@ void Window::saveWindowState()
// Saving X, Y and Width and Height for resizables in the config
if (!mWindowName.empty() && mWindowName != "window")
{
- config.setValue(mWindowName + "WinX", getX());
- config.setValue(mWindowName + "WinY", getY());
+ config.setValue(mWindowName + "WinX", mDimension.x);
+ config.setValue(mWindowName + "WinY", mDimension.y);
if (mSaveVisible)
config.setValue(mWindowName + "Visible", isVisible());
@@ -771,17 +775,17 @@ void Window::saveWindowState()
if (mGrip)
{
- if (getMinWidth() > getWidth())
+ if (getMinWidth() > mDimension.width)
setWidth(getMinWidth());
- else if (getMaxWidth() < getWidth())
+ else if (getMaxWidth() < mDimension.width)
setWidth(getMaxWidth());
- if (getMinHeight() > getHeight())
+ if (getMinHeight() > mDimension.height)
setHeight(getMinHeight());
- else if (getMaxHeight() < getHeight())
+ else if (getMaxHeight() < mDimension.height)
setHeight(getMaxHeight());
- config.setValue(mWindowName + "WinWidth", getWidth());
- config.setValue(mWindowName + "WinHeight", getHeight());
+ config.setValue(mWindowName + "WinWidth", mDimension.width);
+ config.setValue(mWindowName + "WinHeight", mDimension.height);
}
}
}
@@ -806,10 +810,10 @@ void Window::setDefaultSize(int defaultX, int defaultY,
void Window::setDefaultSize()
{
- mDefaultX = getX();
- mDefaultY = getY();
- mDefaultWidth = getWidth();
- mDefaultHeight = getHeight();
+ mDefaultX = mDimension.x;
+ mDefaultY = mDimension.y;
+ mDefaultWidth = mDimension.width;
+ mDefaultHeight = mDimension.height;
}
void Window::setDefaultSize(int defaultWidth, int defaultHeight,
@@ -877,12 +881,13 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth,
gcn::Rectangle dimension = getDimension();
// If window was aligned to the right or bottom, keep it there
- const int rightMargin = oldScreenWidth - (getX() + getWidth());
- const int bottomMargin = oldScreenHeight - (getY() + getHeight());
- if (getX() > 0 && getX() > rightMargin)
- dimension.x = mainGraphics->mWidth - rightMargin - getWidth();
- if (getY() > 0 && getY() > bottomMargin)
- dimension.y = mainGraphics->mHeight - bottomMargin - getHeight();
+ const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
+ const int bottomMargin = oldScreenHeight
+ - (mDimension.y + mDimension.height);
+ if (mDimension.x > 0 && mDimension.x > rightMargin)
+ dimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
+ if (mDimension.y > 0 && mDimension.y > bottomMargin)
+ dimension.y = mainGraphics->mHeight - bottomMargin - mDimension.height;
setDimension(dimension);
ensureOnScreen();
@@ -901,15 +906,15 @@ int Window::getResizeHandles(const gcn::MouseEvent &event)
if (!mStickyButtonLock || !mSticky)
{
- if (mGrip && (y > mTitleBarHeight || (y < getPadding()
- && mTitleBarHeight > getPadding())))
+ if (mGrip && (y > mTitleBarHeight || (y < mPadding
+ && mTitleBarHeight > mPadding)))
{
if (!getWindowArea().isPointInRect(x, y)
&& event.getSource() == this)
{
- resizeHandles |= (x > getWidth() - resizeBorderWidth)
+ resizeHandles |= (x > mDimension.width - resizeBorderWidth)
? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
- resizeHandles |= (y > getHeight() - resizeBorderWidth)
+ resizeHandles |= (y > mDimension.height - resizeBorderWidth)
? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
}
@@ -930,7 +935,7 @@ bool Window::isResizeAllowed(const gcn::MouseEvent &event) const
const int y = event.getY();
if (mGrip && (y > static_cast<int>(mTitleBarHeight)
- || y < static_cast<int>(getPadding())))
+ || y < static_cast<int>(mPadding)))
{
const int x = event.getX();
@@ -1021,7 +1026,7 @@ void Window::centerHorisontally()
void Window::ensureOnScreen()
{
// Skip when a window hasn't got any size initialized yet
- if (getWidth() == 0 && getHeight() == 0)
+ if (mDimension.width == 0 && mDimension.height == 0)
return;
gcn::Rectangle dimension = getDimension();
@@ -1043,10 +1048,10 @@ void Window::ensureOnScreen()
gcn::Rectangle Window::getWindowArea() const
{
- return gcn::Rectangle(getPadding(),
- getPadding(),
- getWidth() - getPadding() * 2,
- getHeight() - getPadding() * 2);
+ return gcn::Rectangle(mPadding,
+ mPadding,
+ mDimension.width - mPadding * 2,
+ mDimension.height - mPadding * 2);
}
int Window::getOption(const std::string &name, const int def) const
diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp
index aebbd0472..cfd62630a 100644
--- a/src/guichan/widgets/label.cpp
+++ b/src/guichan/widgets/label.cpp
@@ -112,7 +112,7 @@ namespace gcn
}
graphics->setFont(getFont());
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawText(getCaption(), textX, textY, getAlignment());
}
diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp
index ad5338069..1f56ed322 100644
--- a/src/guichan/widgets/textbox.cpp
+++ b/src/guichan/widgets/textbox.cpp
@@ -122,7 +122,7 @@ namespace gcn
{
if (mOpaque)
{
- graphics->setColor(getBackgroundColor());
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -133,7 +133,7 @@ namespace gcn
mCaretRow * getFont()->getHeight());
}
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->setFont(getFont());
for (size_t i = 0, sz = mTextRows.size(); i < sz; i++)
@@ -146,7 +146,7 @@ namespace gcn
void TextBox::drawCaret(Graphics* graphics, int x, int y)
{
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawLine(x, getFont()->getHeight() + y, x, y);
}
diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp
index 5434d341c..7a2bde46e 100644
--- a/src/guichan/widgets/textfield.cpp
+++ b/src/guichan/widgets/textfield.cpp
@@ -102,7 +102,7 @@ namespace gcn
// drawn a border).
const Rectangle clipArea = graphics->getCurrentClipArea();
- graphics->setColor(getForegroundColor());
+ graphics->setColor(mForegroundColor);
graphics->drawLine(x, clipArea.height - 2, x, 1);
}