summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp13
-rw-r--r--src/gui/widgets/avatarlistbox.h1
-rw-r--r--src/gui/widgets/browserbox.cpp37
-rw-r--r--src/gui/widgets/browserbox.h34
-rw-r--r--src/gui/widgets/button.cpp9
-rw-r--r--src/gui/widgets/button.h2
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/container.h4
-rw-r--r--src/gui/widgets/desktop.cpp11
-rw-r--r--src/gui/widgets/desktop.h2
-rw-r--r--src/gui/widgets/dropdown.cpp22
-rw-r--r--src/gui/widgets/dropdown.h3
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/guildchattab.cpp128
-rw-r--r--src/gui/widgets/guildchattab.h52
-rw-r--r--src/gui/widgets/guitable.cpp16
-rw-r--r--src/gui/widgets/guitable.h3
-rw-r--r--src/gui/widgets/itemcontainer.cpp9
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h3
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/layout.cpp7
-rw-r--r--src/gui/widgets/listbox.cpp8
-rw-r--r--src/gui/widgets/listbox.h1
-rw-r--r--src/gui/widgets/radiobutton.cpp1
-rw-r--r--src/gui/widgets/scrollarea.cpp14
-rw-r--r--src/gui/widgets/scrollarea.h3
-rw-r--r--src/gui/widgets/shoplistbox.cpp40
-rw-r--r--src/gui/widgets/shoplistbox.h6
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/tab.cpp8
-rw-r--r--src/gui/widgets/tab.h2
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/window.cpp73
-rw-r--r--src/gui/widgets/window.h15
40 files changed, 432 insertions, 160 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 0d35ad188..d4764cba5 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -66,6 +66,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
config.addListener("showgender", this);
config.addListener("showlevel", this);
+
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
AvatarListBox::~AvatarListBox()
@@ -102,8 +105,8 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
const int fontHeight = getFont()->getHeight();
@@ -113,7 +116,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
const std::string name = player_node->getName();
// Draw the list elements
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
for (int i = 0, y = 0;
i < model->getNumberOfElements();
++i, y += fontHeight)
@@ -206,7 +209,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
if (a->getLevel() > 1)
{
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
int minHp = 40 + ((a->getLevel() - 1) * 5);
if (minHp < 0)
minHp = 40;
@@ -283,7 +286,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
index 2fe1dfe3d..afb4abdf5 100644
--- a/src/gui/widgets/avatarlistbox.h
+++ b/src/gui/widgets/avatarlistbox.h
@@ -62,6 +62,7 @@ public:
private:
bool mShowGender;
bool mShowLevel;
+ gcn::Color mHighlightColor;
static int instances;
static Image *onlineIcon;
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 7df70bd04..65a25363d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -64,6 +64,19 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque):
{
setFocusable(true);
addMouseListener(this);
+
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK);
+ mColors[RED] = Theme::getThemeColor(Theme::RED);
+ mColors[GREEN] = Theme::getThemeColor(Theme::GREEN);
+ mColors[BLUE] = Theme::getThemeColor(Theme::BLUE);
+ mColors[ORANGE] = Theme::getThemeColor(Theme::ORANGE);
+ mColors[YELLOW] = Theme::getThemeColor(Theme::YELLOW);
+ mColors[PINK] = Theme::getThemeColor(Theme::PINK);
+ mColors[PURPLE] = Theme::getThemeColor(Theme::PURPLE);
+ mColors[GRAY] = Theme::getThemeColor(Theme::GRAY);
+ mColors[BROWN] = Theme::getThemeColor(Theme::BROWN);
}
BrowserBox::~BrowserBox()
@@ -310,7 +323,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mOpaque)
{
- graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND));
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -319,7 +332,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
{
if ((mHighMode & BACKGROUND))
{
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT));
+ graphics->setColor(mHighlightColor);
graphics->fillRectangle(gcn::Rectangle(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y1,
@@ -330,7 +343,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & UNDERLINE))
{
- graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK));
+ graphics->setColor(mHyperLinkColor);
graphics->drawLine(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y2,
@@ -474,15 +487,15 @@ int BrowserBox::calcHeight()
switch (c)
{
- case '1': selColor = RED; break;
- case '2': selColor = GREEN; break;
- case '3': selColor = BLUE; break;
- case '4': selColor = ORANGE; break;
- case '5': selColor = YELLOW; break;
- case '6': selColor = PINK; break;
- case '7': selColor = PURPLE; break;
- case '8': selColor = GRAY; break;
- case '9': selColor = BROWN; break;
+ case '1': selColor = mColors[RED]; break;
+ case '2': selColor = mColors[GREEN]; break;
+ case '3': selColor = mColors[BLUE]; break;
+ case '4': selColor = mColors[ORANGE]; break;
+ case '5': selColor = mColors[YELLOW]; break;
+ case '6': selColor = mColors[PINK]; break;
+ case '7': selColor = mColors[PURPLE]; break;
+ case '8': selColor = mColors[GRAY]; break;
+ case '9': selColor = mColors[BROWN]; break;
case '0':
default:
selColor = textColor;
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 6fdb40042..cd69ce56f 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -147,27 +147,18 @@ class BrowserBox : public gcn::Widget,
AUTO_WRAP /**< Maybe it needs a fix or to be redone. */
};
- /**
- * BrowserBox colors.
- *
- * NOTES (by Javila):
- * - color values is "0x" prefix followed by HTML color style.
- * - we can add up to 10 different colors: [0..9].
- * - not all colors will be fine with all backgrounds due transparent
- * windows and widgets. So, I think it's better keep BrowserBox
- * opaque (white background) by default.
- */
enum
{
- RED = 0xff0000, /**< Color 1 */
- GREEN = 0x009000, /**< Color 2 */
- BLUE = 0x0000ff, /**< Color 3 */
- ORANGE = 0xe0980e, /**< Color 4 */
- YELLOW = 0xf1dc27, /**< Color 5 */
- PINK = 0xff00d8, /**< Color 6 */
- PURPLE = 0x8415e2, /**< Color 7 */
- GRAY = 0x919191, /**< Color 8 */
- BROWN = 0x8e4c17 /**< Color 9 */
+ RED = 0,
+ GREEN = 1,
+ BLUE = 2,
+ ORANGE = 3,
+ YELLOW = 4,
+ PINK = 5,
+ PURPLE = 6,
+ GRAY = 7,
+ BROWN = 8,
+ COLORS_MAX = 9
};
/**
@@ -225,6 +216,11 @@ class BrowserBox : public gcn::Widget,
bool mAlwaysUpdate;
bool mProcessVersion;
bool mEnableImages;
+
+ gcn::Color mBackgroundColor;
+ gcn::Color mHighlightColor;
+ gcn::Color mHyperLinkColor;
+ gcn::Color mColors[COLORS_MAX];
};
#endif
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 2d9678a53..7c46ae9df 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -135,6 +135,9 @@ void Button::init()
}
updateAlpha();
}
+ mEnabledColor = Theme::getThemeColor(Theme::BUTTON);
+ mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED);
+
mInstances++;
}
@@ -202,7 +205,7 @@ void Button::draw(gcn::Graphics *graphics)
}
else
{
- // because we dont know where parent windows was moved,
+ // because we don't know where parent windows was moved,
// need recalc vertexes
gcn::ClipRectangle &rect = static_cast<Graphics*>(
graphics)->getTopClip();
@@ -238,9 +241,9 @@ void Button::draw(gcn::Graphics *graphics)
// drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
if (mode == BUTTON_DISABLED)
- graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED));
+ graphics->setColor(mDisabledColor);
else
- graphics->setColor(Theme::getThemeColor(Theme::BUTTON));
+ graphics->setColor(mEnabledColor);
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index 8c43b6ddd..1b62179b3 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -101,6 +101,8 @@ class Button : public gcn::Button, public gcn::WidgetListener
int mMode;
int mXOffset;
int mYOffset;
+ gcn::Color mEnabledColor;
+ gcn::Color mDisabledColor;
};
#endif
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 785bdd6be..81c0d277f 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -283,9 +283,7 @@ void ChatTab::chatLog(std::string line, Own own,
{
if (player_node)
{
- std::string::size_type pos
- = tmp.text.find(player_node->getName());
- if (pos != std::string::npos)
+ if (chatWindow && chatWindow->findHighlight(tmp.text))
setFlash(2);
else
setFlash(1);
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 61e5d9118..65d26e196 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -86,6 +86,8 @@ CheckBox::CheckBox(const std::string &caption, bool selected,
if (listener)
addActionListener(listener);
+
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
CheckBox::~CheckBox()
@@ -114,7 +116,7 @@ void CheckBox::draw(gcn::Graphics* graphics)
drawBox(graphics);
graphics->setFont(getFont());
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
const int h = getHeight() + getHeight() / 2;
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index 96cea7119..558257507 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -37,7 +37,7 @@ Container::~Container()
bool Container::safeRemove(gcn::Widget* widget)
{
- WidgetListIterator iter;
+ WidgetListConstIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if (*iter == widget)
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 1d8872477..c011b8925 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -26,6 +26,10 @@
#include <guichan/widget.hpp>
#include <guichan/widgets/container.hpp>
+#if !defined USE_INTERNALGUICHAN
+typedef std::list<gcn::Widget *>::const_iterator WidgetListConstIterator;
+#endif
+
/**
* A widget container.
*
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index cfb757638..46240f76d 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -53,8 +53,12 @@ Desktop::Desktop() :
mVersionLabel = new Label(strprintf("%s (Mana %s)", appName.c_str(),
FULL_VERSION));
- mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128));
+ mVersionLabel->setBackgroundColor(
+ Theme::getThemeColor(Theme::BACKGROUND, 128));
add(mVersionLabel, 25, 2);
+
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128);
+ mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY);
}
Desktop::~Desktop()
@@ -84,8 +88,7 @@ void Desktop::draw(gcn::Graphics *graphics)
if (!mWallpaper || (getWidth() > mWallpaper->getWidth() ||
getHeight() > mWallpaper->getHeight()))
{
- // TODO: Color from palette
- g->setColor(gcn::Color(64, 64, 64));
+ g->setColor(mBackgroundGrayColor);
g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -106,7 +109,7 @@ void Desktop::draw(gcn::Graphics *graphics)
}
// Draw a thin border under the application version...
- g->setColor(gcn::Color(255, 255, 255, 128));
+ g->setColor(mBackgroundColor);
g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
Container::draw(graphics);
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 962cc3c01..6364ecfe9 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -68,6 +68,8 @@ class Desktop : public Container, gcn::WidgetListener
Image *mWallpaper;
gcn::Label *mVersionLabel;
+ gcn::Color mBackgroundColor;
+ gcn::Color mBackgroundGrayColor;
};
#endif // DESKTOP_H
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 681d7736e..f01d3fb55 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -101,6 +101,10 @@ DropDown::DropDown(gcn::ListModel *listModel):
}
instances++;
+
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
DropDown::~DropDown()
@@ -163,25 +167,20 @@ void DropDown::draw(gcn::Graphics* graphics)
updateAlpha();
const int alpha = static_cast<int>(mAlpha * 255.0f);
- gcn::Color faceColor = getBaseColor();
- faceColor.a = alpha;
- const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT,
- alpha);
- gcn::Color shadowColor = faceColor - 0x303030;
- shadowColor.a = alpha;
+ mHighlightColor.a = alpha;
+ mShadowColor.a = alpha;
if (mListBox->getListModel() && mListBox->getSelected() >= 0)
{
graphics->setFont(getFont());
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->drawText(mListBox->getListModel()->getElementAt(
mListBox->getSelected()), 1, 0);
}
if (isFocused())
{
- if (highlightColor)
- graphics->setColor(*highlightColor);
+ graphics->setColor(mHighlightColor);
graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h));
}
@@ -193,10 +192,9 @@ void DropDown::draw(gcn::Graphics* graphics)
// Draw two lines separating the ListBox with selected
// element view.
- if (highlightColor)
- graphics->setColor(*highlightColor);
+ graphics->setColor(mHighlightColor);
graphics->drawLine(0, h, getWidth(), h);
- graphics->setColor(shadowColor);
+ graphics->setColor(mShadowColor);
graphics->drawLine(0, h + 1, getWidth(), h + 1);
}
}
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index d85c3166c..6a22ba497 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -87,6 +87,9 @@ class DropDown : public gcn::DropDown
*/
void drawButton(gcn::Graphics *graphics);
+ gcn::Color mShadowColor;
+ gcn::Color mHighlightColor;
+
// Add own Images.
static int instances;
static Image *buttons[2][2];
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 92f02c78f..b628cf2d4 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -73,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
@@ -110,12 +112,6 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
if (mBackgroundImg)
g->drawImage(mBackgroundImg, itemX, itemY);
-/* // Draw item keyboard shortcut.
- const char *key = SDL_GetKeyName(
- (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i));
- graphics->setColor(guiPalette->getColor(Palette::TEXT));
- g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
-*/
if (dropShortcut->getItem(i) < 0)
continue;
@@ -142,11 +138,11 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
image->setAlpha(1.0f);
g->drawImage(image, itemX, itemY);
if (item->isEquipped())
- g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED));
+ g->setColor(mEquipedColor);
else
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + mBoxWidth / 2,
- itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
+ itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
}
}
}
diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h
index 723b215cf..b2d63a7dd 100644
--- a/src/gui/widgets/dropshortcutcontainer.h
+++ b/src/gui/widgets/dropshortcutcontainer.h
@@ -84,6 +84,8 @@ class DropShortcutContainer : public ShortcutContainer
Item *mItemMoved;
ItemPopup *mItemPopup;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
#endif
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 5bb972adc..5aced193f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -80,6 +80,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
EmoteShortcutContainer::~EmoteShortcutContainer()
@@ -118,20 +119,9 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
std::string key = keyboard.getKeyValueString(
keyboard.KEY_EMOTE_1 + i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
-/*
- if (emoteShortcut->getEmote(i)
- && static_cast<unsigned>(emoteShortcut->getEmote(i)) - 1
- < mEmoteImg.size()
- && mEmoteImg[emoteShortcut->getEmote(i) - 1])
- {
- mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2,
- emoteY + 10);
- }
-*/
-
if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite)
mEmoteImg[i]->sprite->draw(g, emoteX + 2, emoteY + 10);
}
diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp
new file mode 100644
index 000000000..0353ac23f
--- /dev/null
+++ b/src/gui/widgets/guildchattab.cpp
@@ -0,0 +1,128 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/guildchattab.h"
+
+#include "chatlogger.h"
+#include "commandhandler.h"
+#include "guild.h"
+#include "guildmanager.h"
+#include "localplayer.h"
+
+#include "gui/theme.h"
+
+#include "resources/iteminfo.h"
+#include "resources/itemdb.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+GuildChatTab::GuildChatTab() :
+ ChatTab(_("Guild"))
+{
+ setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB));
+}
+
+GuildChatTab::~GuildChatTab()
+{
+}
+
+bool GuildChatTab::handleCommand(const std::string &type,
+ const std::string &args)
+{
+ if (type == "help")
+ {
+ if (args == "invite")
+ {
+ chatLog(_("Command: /invite <nick>"));
+ chatLog(_("This command invites <nick> to the guild you're in."));
+ chatLog(_("If the <nick> has spaces in it, enclose it in "
+ "double quotes (\")."));
+ }
+ else if (args == "leave")
+ {
+ chatLog(_("Command: /leave"));
+ chatLog(_("This command causes the player to leave the guild."));
+ }
+ else
+ return false;
+ }
+ else if (type == "invite" && guildManager)
+ {
+ guildManager->invite(args);
+ }
+ else if (type == "leave" && guildManager)
+ {
+ guildManager->leave();
+ }
+ else if (type == "kick" && guildManager)
+ {
+ guildManager->kick(args);
+ }
+ else if (type == "notice" && guildManager)
+ {
+ guildManager->notice(args);
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void GuildChatTab::handleInput(const std::string &msg)
+{
+ if (!guildManager)
+ return;
+
+ if (chatWindow)
+ guildManager->chat(chatWindow->doReplace(msg));
+ else
+ guildManager->chat(msg);
+}
+
+void GuildChatTab::showHelp()
+{
+ chatLog(_("/help > Display this help."));
+ chatLog(_("/invite > Invite a player to your guild"));
+ chatLog(_("/leave > Leave the guild you are in"));
+ chatLog(_("/kick > Kick some one from the guild you are in"));
+}
+
+void GuildChatTab::getAutoCompleteList(std::vector<std::string> &names) const
+{
+ if (!guildManager)
+ return;
+
+ guildManager->getNames(names);
+ names.push_back("/notice ");
+}
+
+void GuildChatTab::saveToLogFile(std::string &msg)
+{
+ if (chatLogger)
+ chatLogger->log("#Guild", msg);
+}
diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h
new file mode 100644
index 000000000..4f5ee3a8e
--- /dev/null
+++ b/src/gui/widgets/guildchattab.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_GUILDTAB_H
+#define GUI_GUILDTAB_H
+
+#include "gui/widgets/chattab.h"
+
+/**
+ * A tab for a guild chat channel.
+ */
+class GuildChatTab : public ChatTab
+{
+ public:
+ GuildChatTab();
+
+ ~GuildChatTab();
+
+ bool handleCommand(const std::string &type, const std::string &args);
+
+ void showHelp();
+
+ void saveToLogFile(std::string &msg);
+
+ int getType() const { return ChatTab::TAB_GUILD; }
+
+ protected:
+ void handleInput(const std::string &msg);
+
+ void getAutoCompleteList(std::vector<std::string> &names) const;
+};
+
+#endif
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index e25e0bb8c..e02eda88c 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -88,17 +88,17 @@ void GuiTableActionListener::action(const gcn::ActionEvent
}
-GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
- bool opacity) :
+GuiTable::GuiTable(TableModel *initial_model, bool opacity) :
mLinewiseMode(false),
mWrappingEnabled(false),
mOpaque(opacity),
- mBackgroundColor(background),
mModel(NULL),
mSelectedRow(0),
mSelectedColumn(0),
mTopWidget(NULL)
{
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setModel(initial_model);
setFocusable(true);
@@ -292,8 +292,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mOpaque)
{
- graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND,
- static_cast<int>(mAlpha * 255.0f)));
+ mBackgroundColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -304,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
first_row = 0;
unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate
- // by one.
+ // by one.
unsigned max_rows_nr;
if (mModel->getRows() < first_row)
@@ -343,8 +343,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
widget->setDimension(bounds);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
if (mSelectedRow > 0)
{
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index c4fab6a0d..d248c4820 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -58,7 +58,6 @@ class GuiTable : public gcn::Widget,
public:
GuiTable(TableModel * initial_model = NULL,
- gcn::Color background = 0xffffff,
bool opacity = true);
virtual ~GuiTable();
@@ -190,6 +189,8 @@ private:
/** Vector for compactness; used as a list in practice. */
std::vector<GuiTableActionListener *> mActionListeners;
+
+ gcn::Color mHighlightColor;
};
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index b79f26226..91b674018 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -118,6 +118,9 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
if (!mSelImg)
logger->log1("Error: Unable to load selection.png");
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
+
addKeyListener(this);
addMouseListener(this);
addWidgetListener(this);
@@ -204,15 +207,16 @@ void ItemContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
if (item->isEquipped())
- g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED));
+ g->setColor(mEquipedColor);
else
- g->setColor(gcn::Color(0, 0, 0));
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + BOX_WIDTH / 2,
itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER);
}
}
+/*
// Draw an orange box around the selected item
if (isFocused() && mHighlightedIndex != -1 && mGridColumns)
{
@@ -221,6 +225,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
g->setColor(gcn::Color(255, 128, 0));
g->drawRectangle(gcn::Rectangle(itemX, itemY, BOX_WIDTH, BOX_HEIGHT));
}
+*/
}
void ItemContainer::selectNone()
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 5fd897a29..df7de63ee 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -202,6 +202,8 @@ class ItemContainer : public gcn::Widget,
typedef SelectionListenerList::iterator SelectionListenerIterator;
SelectionListenerList mSelectionListeners;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
#endif
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 328d5ae4d..79685fe45 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -77,6 +77,9 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
ItemShortcutContainer::~ItemShortcutContainer()
@@ -119,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
std::string key = keyboard.getKeyValueString(
keyboard.KEY_SHORTCUT_1 + i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
@@ -154,14 +157,9 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
image->setAlpha(1.0f);
g->drawImage(image, itemX, itemY);
if (item->isEquipped())
- {
- g->setColor(Theme::getThemeColor(
- Theme::ITEM_EQUIPPED));
- }
+ g->setColor(mEquipedColor);
else
- {
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
- }
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + mBoxWidth / 2,
itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
}
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
index 7eac431ec..e6b32c6f8 100644
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ b/src/gui/widgets/itemshortcutcontainer.h
@@ -88,7 +88,8 @@ class ItemShortcutContainer : public ShortcutContainer
ItemPopup *mItemPopup;
SpellPopup *mSpellPopup;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
-//extern SpellManager *spellManager;
#endif
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 16b813dd5..67e8bd12b 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -26,6 +26,7 @@
Label::Label()
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Label::Label(const std::string &caption) :
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 382d169dc..a14b416ce 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -68,7 +68,9 @@ LayoutArray &LayoutCell::getArray()
void LayoutCell::reflow(int nx, int ny, int nw, int nh)
{
- assert(mType != NONE);
+ if (mType == NONE)
+ return;
+
nx += mHPadding;
ny += mVPadding;
nw -= 2 * mHPadding;
@@ -81,7 +83,8 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh)
void LayoutCell::computeSizes()
{
- assert(mType == ARRAY);
+ if (mType != ARRAY)
+ return;
std::vector< std::vector< LayoutCell * > >::iterator
i = mArray->mCells.begin();
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index de8707406..53299ca46 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -41,6 +41,8 @@ float ListBox::mAlpha = 1.0;
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel)
{
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
ListBox::~ListBox()
@@ -63,8 +65,8 @@ void ListBox::draw(gcn::Graphics *graphics)
updateAlpha();
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
const int height = getRowHeight();
@@ -77,7 +79,7 @@ void ListBox::draw(gcn::Graphics *graphics)
}
// Draw the list elements
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 5f8c20059..418b83f58 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -73,6 +73,7 @@ class ListBox : public gcn::ListBox
void mouseDragged(gcn::MouseEvent &event);
protected:
+ gcn::Color mHighlightColor;
static float mAlpha;
};
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index a82ec3e8d..e641be323 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -46,6 +46,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group,
gcn::RadioButton(caption, group, marked),
mHasMouse(false)
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (instances == 0)
{
radioNormal = Theme::getImageFromTheme("radioout.png");
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 08f0b5a70..2796d3ab2 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -73,7 +73,6 @@ ScrollArea::ScrollArea(gcn::Widget *widget):
mDrawWidth(0),
mDrawHeight(0)
{
-// addWidgetListener(this);
init();
}
@@ -219,6 +218,9 @@ void ScrollArea::init()
}
instances++;
+
+ mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32);
+ mBackground = Theme::getThemeColor(Theme::BACKGROUND);
}
void ScrollArea::logic()
@@ -336,7 +338,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
}
else
{
- // because we dont know where parent windows was moved,
+ // because we don't know where parent windows was moved,
// need recalc vertexes
gcn::ClipRectangle &rect = static_cast<Graphics*>(
graphics)->getTopClip();
@@ -439,17 +441,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics)
void ScrollArea::drawVBar(gcn::Graphics *graphics)
{
const gcn::Rectangle dim = getVerticalBarDimension();
- graphics->setColor(gcn::Color(0, 0, 0, 32));
+ graphics->setColor(mGray);
graphics->fillRectangle(dim);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(mBackground);
}
void ScrollArea::drawHBar(gcn::Graphics *graphics)
{
const gcn::Rectangle dim = getHorizontalBarDimension();
- graphics->setColor(gcn::Color(0, 0, 0, 32));
+ graphics->setColor(mGray);
graphics->fillRectangle(dim);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(mBackground);
}
void ScrollArea::drawVMarker(gcn::Graphics *graphics)
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 440fcec15..095010f3c 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -156,6 +156,9 @@ 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/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 2fe28181b..793491808 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel):
mShopItems(0)
{
mRowHeight = getFont()->getHeight();
- mPriceCheck = true;
-
- mItemPopup = new ItemPopup;
+ init();
}
ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
@@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
mShopItems(shopListModel)
{
mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE);
- mPriceCheck = true;
+ init();
+}
+void ShopListBox::init()
+{
+ mPriceCheck = true;
mItemPopup = new ItemPopup;
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
void ShopListBox::setPlayersMoney(int money)
@@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = Client::getGuiAlpha();
int alpha = static_cast<int>(mAlpha * 255.0f);
- const gcn::Color* highlightColor =
- &Theme::getThemeColor(Theme::HIGHLIGHT, alpha);
+ mHighlightColor.a = alpha;
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
++i, y += mRowHeight)
{
gcn::Color temp;
- const gcn::Color* backgroundColor =
- &Theme::getThemeColor(Theme::BACKGROUND, alpha);
+ gcn::Color* backgroundColor = &mBackgroundColor;
+ mBackgroundColor.a = alpha;
if (mShopItems && mShopItems->at(i) &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
{
if (i != mSelected)
{
- backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING,
- alpha);
+ backgroundColor = &mWarningColor;
+ backgroundColor->a = alpha;
}
else
{
- temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha);
- temp.r = (temp.r + highlightColor->r) / 2;
- temp.g = (temp.g + highlightColor->g) / 2;
- temp.b = (temp.g + highlightColor->b) / 2;
+ temp = mWarningColor;
+ temp.r = (temp.r + mHighlightColor.r) / 2;
+ temp.g = (temp.g + mHighlightColor.g) / 2;
+ temp.b = (temp.g + mHighlightColor.b) / 2;
+ temp.a = alpha;
backgroundColor = &temp;
}
}
else if (i == mSelected)
{
- backgroundColor = highlightColor;
+ backgroundColor = &mHighlightColor;
}
graphics->setColor(*backgroundColor);
@@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, 1, y);
}
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5,
- y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
+ y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
}
}
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 917f46729..38e238f20 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -85,6 +85,8 @@ class ShopListBox : public ListBox
void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED);
private:
+ void init();
+
int mPlayerMoney;
/**
@@ -100,6 +102,10 @@ class ShopListBox : public ListBox
static float mAlpha;
bool mPriceCheck;
+
+ gcn::Color mHighlightColor;
+ gcn::Color mBackgroundColor;
+ gcn::Color mWarningColor;
};
#endif // SHOPLISTBOX_H
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 8d5b563bb..8abe727b5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -81,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
SpellShortcutContainer::~SpellShortcutContainer()
@@ -106,11 +107,10 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
Graphics *g = static_cast<Graphics*>(graphics);
- graphics->setColor(gcn::Color(0, 0, 0, 255));
graphics->setFont(getFont());
int selectedId = spellShortcut->getSelectedItem();
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(getForegroundColor());
for (unsigned i = 0; i < mMaxItems; i++)
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index b7d6b4458..530f1ac82 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -77,6 +77,8 @@ Tab::Tab() : gcn::Tab(),
mMode(0)
{
init();
+ mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH);
+ mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH);
}
Tab::~Tab()
@@ -177,12 +179,10 @@ void Tab::draw(gcn::Graphics *graphics)
switch (mFlash)
{
case 1:
- mLabel->setForegroundColor(Theme::getThemeColor(
- Theme::TAB_FLASH));
+ mLabel->setForegroundColor(mFlashColor);
break;
case 2:
- mLabel->setForegroundColor(Theme::getThemeColor(
- Theme::TAB_PLAYER_FLASH));
+ mLabel->setForegroundColor(mPlayerFlashColor);
break;
default:
break;
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 5847bd505..ba51e6c74 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -91,6 +91,8 @@ class Tab : public gcn::Tab, public gcn::WidgetListener
GraphicsVertexes *mVertexes;
bool mRedraw;
int mMode;
+ gcn::Color mFlashColor;
+ gcn::Color mPlayerFlashColor;
};
#endif
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index f80039650..2729e5407 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -59,6 +59,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab,
mLoseFocusOnTab = loseFocusOnTab;
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+
if (instances == 0)
{
// Load the skin
@@ -136,7 +138,7 @@ void TextField::draw(gcn::Graphics *graphics)
mXScroll);
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 9a7c689e6..4435496a7 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -60,6 +60,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
mSaveVisible(false),
mStickyButton(false),
mSticky(false),
+ mStickyButtonLock(false),
mMinWinWidth(100),
mMinWinHeight(40),
mMaxWinWidth(graphics->mWidth),
@@ -95,6 +96,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
addWidgetListener(this);
mCaptionFont = getFont();
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Window::~Window()
@@ -146,15 +148,10 @@ void Window::draw(gcn::Graphics *graphics)
g->drawImageRect2(mVertexes, mSkin->getBorder());
-/*
- g->drawImageRect(0, 0, getWidth(),
- getHeight(), mSkin->getBorder());
-*/
-
// Draw title
if (mShowTitle)
{
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(getForegroundColor());
g->setFont(mCaptionFont);
g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
}
@@ -162,9 +159,9 @@ void Window::draw(gcn::Graphics *graphics)
// Draw Close Button
if (mCloseButton && mSkin->getCloseImage())
{
- g->drawImage(mSkin->getCloseImage(),
- getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(),
- getPadding());
+ Image *button = mSkin->getCloseImage();
+ const int x = getWidth() - button->getWidth() - getPadding();
+ g->drawImage(button, x, getPadding());
}
// Draw Sticky Button
@@ -175,7 +172,7 @@ void Window::draw(gcn::Graphics *graphics)
{
int x = getWidth() - button->getWidth() - getPadding();
if (mCloseButton && mSkin->getCloseImage())
- x -= mSkin->getCloseImage()->getWidth();
+ x -= mSkin->getCloseImage()->getWidth() + getPadding();
g->drawImage(button, x, getPadding());
}
@@ -371,7 +368,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED)
if (gui)
gui->setCursorType(Gui::CURSOR_POINTER);
- WidgetListIterator it;
+ WidgetListConstIterator it;
if (!mFocusHandler)
return;
@@ -403,6 +400,13 @@ void Window::setSticky(bool sticky)
mSticky = sticky;
}
+void Window::setStickyButtonLock(bool lock)
+{
+ mStickyButtonLock = lock;
+ mStickyButton = lock;
+// mMovable = false;
+}
+
void Window::setVisible(bool visible)
{
setVisible(visible, false);
@@ -417,7 +421,10 @@ void Window::setVisible(bool visible, bool forceSticky)
if (visible)
checkIfIsOffScreen();
- gcn::Window::setVisible((!forceSticky && isSticky()) || visible);
+ if (isStickyButtonLock())
+ gcn::Window::setVisible(visible);
+ else
+ gcn::Window::setVisible((!forceSticky && isSticky()) || visible);
}
void Window::scheduleDelete()
@@ -483,7 +490,10 @@ void Window::mousePressed(gcn::MouseEvent &event)
// Handle window resizing
mouseResize = getResizeHandles(event);
- mMoved = !mouseResize;
+ if (canMove())
+ mMoved = !mouseResize;
+ else
+ mMoved = false;
}
}
@@ -545,10 +555,24 @@ void Window::mouseMoved(gcn::MouseEvent &event)
viewport->hideBeingPopup();
}
+bool Window::canMove()
+{
+ return !mStickyButtonLock || !mSticky;
+}
+
void Window::mouseDragged(gcn::MouseEvent &event)
{
- // Let Guichan handle title bar drag
- gcn::Window::mouseDragged(event);
+ if (canMove())
+ {
+ // Let Guichan handle title bar drag
+ gcn::Window::mouseDragged(event);
+ }
+ else
+ {
+ if (!event.isConsumed() && event.getSource() == this)
+ event.consume();
+ return;
+ }
// Keep guichan window inside screen when it may be moved
if (isMovable() && mMoved)
@@ -639,21 +663,22 @@ void Window::setModal(bool modal)
void Window::loadWindowState()
{
const std::string &name = mWindowName;
- assert(!name.empty());
+ if (name.empty())
+ return;
setPosition(config.getValueInt(name + "WinX", mDefaultX),
- config.getValueInt(name + "WinY", mDefaultY));
+ config.getValueInt(name + "WinY", mDefaultY));
if (mSaveVisible)
{
setVisible(config.getValueBool(name
- + "Visible", mDefaultVisible));
+ + "Visible", mDefaultVisible));
}
if (mStickyButton)
{
setSticky(config.getValueBool(name
- + "Sticky", isSticky()));
+ + "Sticky", isSticky()));
}
if (mGrip)
@@ -685,10 +710,10 @@ void Window::loadWindowState()
int width = getWidth();
int height = getHeight();
- if (getX() + width >= viewport->getWidth())
- width = viewport->getWidth() - getX() - 1;
- if (getY() + height >= viewport->getHeight())
- height = viewport->getHeight() - getY() - 1;
+ if (getX() + width > viewport->getWidth())
+ width = viewport->getWidth() - getX();
+ if (getY() + height > viewport->getHeight())
+ height = viewport->getHeight() - getY();
if (width < 0)
width = 0;
if (height < 0)
@@ -815,7 +840,7 @@ void Window::resetToDefaultSize()
int Window::getResizeHandles(gcn::MouseEvent &event)
{
- if (event.getX() < 0 || event.getY() < 0)
+ if ((mStickyButtonLock && mSticky) || event.getX() < 0 || event.getY() < 0)
return 0;
int resizeHandles = 0;
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index d36d6c5ad..b9f65dceb 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -189,6 +189,17 @@ class Window : public gcn::Window, gcn::WidgetListener
{ return mSticky; }
/**
+ * Sets whether the window sticky mean window locked or not.
+ */
+ void setStickyButtonLock(bool sticky);
+
+ /**
+ * Returns whether the window sticky locking window.
+ */
+ bool isStickyButtonLock() const
+ { return mStickyButtonLock; }
+
+ /**
* Overloads window setVisible by Guichan to allow sticky window
* handling.
*/
@@ -387,6 +398,9 @@ class Window : public gcn::Window, gcn::WidgetListener
void setCaptionFont(gcn::Font *font)
{ mCaptionFont = font; }
+ protected:
+ bool canMove();
+
private:
enum ResizeHandles
{
@@ -423,6 +437,7 @@ class Window : public gcn::Window, gcn::WidgetListener
bool mSaveVisible; /**< Window will save visibility */
bool mStickyButton; /**< Window has a sticky button */
bool mSticky; /**< Window resists hiding*/
+ bool mStickyButtonLock; /**< Window locked if sticky enabled*/
int mMinWinWidth; /**< Minimum window width */
int mMinWinHeight; /**< Minimum window height */
int mMaxWinWidth; /**< Maximum window width */