summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatarlistbox.cpp65
-rw-r--r--src/gui/widgets/avatarlistbox.h1
-rw-r--r--src/gui/widgets/battletab.cpp4
-rw-r--r--src/gui/widgets/browserbox.cpp12
-rw-r--r--src/gui/widgets/browserbox.h4
-rw-r--r--src/gui/widgets/button.cpp11
-rw-r--r--src/gui/widgets/button.h2
-rw-r--r--src/gui/widgets/chattab.cpp11
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/desktop.cpp13
-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.cpp19
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h7
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp16
-rw-r--r--src/gui/widgets/guitable.cpp (renamed from src/gui/widgets/table.cpp)18
-rw-r--r--src/gui/widgets/guitable.h (renamed from src/gui/widgets/table.h)3
-rw-r--r--src/gui/widgets/horizontcontainer.h3
-rw-r--r--src/gui/widgets/inventoryfilter.cpp6
-rw-r--r--src/gui/widgets/inventoryfilter.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp11
-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.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp8
-rw-r--r--src/gui/widgets/listbox.h1
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/radiobutton.cpp1
-rw-r--r--src/gui/widgets/scrollarea.cpp16
-rw-r--r--src/gui/widgets/scrollarea.h3
-rw-r--r--src/gui/widgets/setupitem.cpp591
-rw-r--r--src/gui/widgets/setupitem.h273
-rw-r--r--src/gui/widgets/setuptabscroll.cpp3
-rw-r--r--src/gui/widgets/shopitems.cpp5
-rw-r--r--src/gui/widgets/shopitems.h2
-rw-r--r--src/gui/widgets/shoplistbox.cpp40
-rw-r--r--src/gui/widgets/shoplistbox.h6
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp11
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h5
-rw-r--r--src/gui/widgets/tab.cpp10
-rw-r--r--src/gui/widgets/tab.h2
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp6
-rw-r--r--src/gui/widgets/tradetab.cpp4
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/gui/widgets/whispertab.cpp4
-rw-r--r--src/gui/widgets/window.cpp10
50 files changed, 1105 insertions, 165 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 748e038e2..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;
@@ -242,28 +245,48 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- if (mShowGender)
+ if (graphics->getSecure())
{
- switch (a->getGender())
+ if (mShowGender)
{
- case GENDER_FEMALE:
- text += strprintf(" \u2640 %s",
- a->getAdditionString().c_str());
- break;
- case GENDER_MALE:
- text += strprintf(" \u2642 %s",
- a->getAdditionString().c_str());
- break;
- default:
- break;
+ switch (a->getGender())
+ {
+ case GENDER_FEMALE:
+ text += strprintf(" \u2640 ");
+ break;
+ case GENDER_MALE:
+ text += strprintf(" \u2642 ");
+ break;
+ default:
+ break;
+ }
}
}
else
{
- text += a->getAdditionString();
+ if (mShowGender)
+ {
+ switch (a->getGender())
+ {
+ case GENDER_FEMALE:
+ text += strprintf(" \u2640 %s",
+ a->getAdditionString().c_str());
+ break;
+ case GENDER_MALE:
+ text += strprintf(" \u2642 %s",
+ a->getAdditionString().c_str());
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ text += a->getAdditionString();
+ }
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
@@ -366,8 +389,10 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
{
- chatWindow->addWhisperTab(model->getAvatarAt(selected)
- ->getName(), true);
+ ChatTab *tab = chatWindow->addWhisperTab(
+ model->getAvatarAt(selected)->getName(), true);
+ if (chatWindow && tab)
+ chatWindow->saveState();
}
}
}
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/battletab.cpp b/src/gui/widgets/battletab.cpp
index e72c78ee0..c5500e801 100644
--- a/src/gui/widgets/battletab.cpp
+++ b/src/gui/widgets/battletab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/battletab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 140a72770..bb83c1159 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "utils/stringutils.h"
@@ -64,6 +64,10 @@ 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);
}
BrowserBox::~BrowserBox()
@@ -310,7 +314,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 +323,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 +334,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,
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 6fdb40042..9969bfd3b 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -225,6 +225,10 @@ class BrowserBox : public gcn::Widget,
bool mAlwaysUpdate;
bool mProcessVersion;
bool mEnableImages;
+
+ gcn::Color mBackgroundColor;
+ gcn::Color mHighlightColor;
+ gcn::Color mHyperLinkColor;
};
#endif
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 0570630c3..7c46ae9df 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -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 42a39a20f..81c0d277f 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -23,11 +23,11 @@
#include "gui/widgets/chattab.h"
#include "actorspritemanager.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "configuration.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "sound.h"
#include "gui/widgets/browserbox.h"
@@ -249,12 +249,13 @@ void ChatTab::chatLog(std::string line, Own own,
// We look if the Vertical Scroll Bar is set at the max before
// adding a row, otherwise the max will always be a row higher
// at comparison.
- if (mScrollArea->getVerticalScrollAmount() >=
+ if (mScrollArea->getVerticalScrollAmount() + 2 >=
mScrollArea->getVerticalMaxScroll())
{
addRow(line);
mScrollArea->setVerticalScrollAmount(
mScrollArea->getVerticalMaxScroll());
+
}
else
{
@@ -282,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/desktop.cpp b/src/gui/widgets/desktop.cpp
index 3ade3b37f..46240f76d 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -22,7 +22,7 @@
#include "configuration.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/palette.h"
@@ -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 257f4837c..b628cf2d4 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * 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
@@ -72,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
@@ -109,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;
@@ -141,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 77de914ea..b2d63a7dd 100644
--- a/src/gui/widgets/dropshortcutcontainer.h
+++ b/src/gui/widgets/dropshortcutcontainer.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * 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
@@ -83,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 bb5af4b1c..5aced193f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -29,7 +29,7 @@
#include "itemshortcut.h"
#include "keyboardconfig.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/textpopup.h"
@@ -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/table.cpp b/src/gui/widgets/guitable.cpp
index 04ae41ad7..e02eda88c 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/table.h"
+#include "gui/widgets/guitable.h"
#include "client.h"
#include "configuration.h"
@@ -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/table.h b/src/gui/widgets/guitable.h
index c4fab6a0d..d248c4820 100644
--- a/src/gui/widgets/table.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/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 4a959190e..80014c171 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -41,8 +41,11 @@ class HorizontContainer : public Container, public gcn::WidgetListener
{
public:
HorizontContainer(int height, int spacing);
+
virtual void add(gcn::Widget *widget);
+
virtual void clear();
+
void widgetResized(const gcn::Event &event);
protected:
diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp
index a220fdb98..795f0d31e 100644
--- a/src/gui/widgets/inventoryfilter.cpp
+++ b/src/gui/widgets/inventoryfilter.cpp
@@ -1,8 +1,8 @@
/*
- * The Mana Client
+ * The ManaPlus Client
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana Client.
+ * 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
@@ -23,7 +23,7 @@
#include "gui/widgets/horizontcontainer.h"
#include "gui/widgets/radiobutton.h"
-#include "log.h"
+#include "logger.h"
#include "debug.h"
diff --git a/src/gui/widgets/inventoryfilter.h b/src/gui/widgets/inventoryfilter.h
index da7b7af1e..be69489a8 100644
--- a/src/gui/widgets/inventoryfilter.h
+++ b/src/gui/widgets/inventoryfilter.h
@@ -1,9 +1,9 @@
/*
- * The Mana Client
+ * The ManaPlus Client
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana Client.
+ * 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
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 7818432f8..91b674018 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -27,7 +27,7 @@
#include "item.h"
#include "itemshortcut.h"
#include "dropshortcut.h"
-#include "log.h"
+#include "logger.h"
#include "gui/chatwindow.h"
#include "gui/itempopup.h"
@@ -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 274c17d61..382d169dc 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -22,7 +22,7 @@
#include "gui/widgets/layout.h"
-#include "log.h"
+#include "logger.h"
#include <cassert>
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/popup.cpp b/src/gui/widgets/popup.cpp
index ea51c146a..38088770b 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
#include "gui/viewport.h"
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 df39854da..2796d3ab2 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
@@ -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/setupitem.cpp b/src/gui/widgets/setupitem.cpp
new file mode 100644
index 000000000..698e133dd
--- /dev/null
+++ b/src/gui/widgets/setupitem.cpp
@@ -0,0 +1,591 @@
+/*
+ * The ManaPlus Client
+ * 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/setupitem.h"
+
+#include "configuration.h"
+#include "main.h"
+#include "logger.h"
+
+#include "gui/editdialog.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/checkbox.h"
+#include "gui/widgets/dropdown.h"
+#include "gui/widgets/horizontcontainer.h"
+#include "gui/widgets/inttextfield.h"
+#include "gui/widgets/label.h"
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/tabbedarea.h"
+#include "gui/widgets/textfield.h"
+#include "gui/widgets/vertcontainer.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+
+
+SetupItem::SetupItem(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, bool mainConfig) :
+ mText(text),
+ mDescription(description),
+ mKeyName(keyName),
+ mParent(parent),
+ mEventName(eventName),
+ mMainConfig(mainConfig),
+ mUseDefault(false),
+ mValue(""),
+ mDefault(""),
+ mWidget(0),
+ mValueType(VBOOL)
+{
+}
+
+SetupItem::SetupItem(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, std::string def, bool mainConfig) :
+ mText(text),
+ mDescription(description),
+ mKeyName(keyName),
+ mParent(parent),
+ mEventName(eventName),
+ mMainConfig(mainConfig),
+ mUseDefault(true),
+ mValue(""),
+ mDefault(def),
+ mWidget(0),
+ mValueType(VBOOL)
+{
+}
+
+SetupItem::~SetupItem()
+{
+
+}
+
+Configuration *SetupItem::getConfig()
+{
+ if (mMainConfig)
+ return &config;
+ else
+ return &serverConfig;
+}
+
+void SetupItem::load()
+{
+ Configuration *cfg = getConfig();
+ if (mUseDefault)
+ {
+ mValue = cfg->getValue(mKeyName, mDefault);
+ }
+ else
+ {
+ switch (mValueType)
+ {
+ case VBOOL:
+ if (cfg->getBoolValue(mKeyName))
+ mValue = "1";
+ else
+ mValue = "0";
+ break;
+ case VSTR:
+ default:
+ mValue = cfg->getStringValue(mKeyName);
+ break;
+ case VINT:
+ mValue = toString(cfg->getIntValue(mKeyName));
+ break;
+ case VNONE:
+ break;
+ }
+ }
+}
+
+void SetupItem::save()
+{
+ Configuration *cfg = getConfig();
+ cfg->setValue(mKeyName, mValue);
+}
+
+std::string SetupItem::getActionEventId()
+{
+ if (!mWidget)
+ return "";
+
+ return mWidget->getActionEventId();
+}
+
+void SetupItem::action(const gcn::ActionEvent &event)
+{
+ if (!mWidget)
+ return;
+
+ if (event.getId() == mWidget->getActionEventId())
+ action();
+}
+
+void SetupItem::action()
+{
+ fromWidget();
+}
+
+void SetupItem::apply(std::string eventName A_UNUSED)
+{
+ save();
+}
+
+void SetupItem::cancel(std::string eventName A_UNUSED)
+{
+ load();
+ toWidget();
+}
+
+void SetupItem::externalUpdated(std::string eventName A_UNUSED)
+{
+ load();
+ toWidget();
+}
+
+SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig)
+{
+ createControls();
+}
+
+SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName, std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig)
+{
+ createControls();
+}
+
+SetupItemCheckBox::~SetupItemCheckBox()
+{
+ mWidget = 0;
+}
+
+void SetupItemCheckBox::createControls()
+{
+ load();
+ mCheckBox = new CheckBox(mText, mValue != "0", mParent, mEventName);
+ mWidget = mCheckBox;
+ mParent->getContainer()->add(mWidget);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemCheckBox::fromWidget()
+{
+ if (!mCheckBox)
+ return;
+
+ if (mCheckBox->isSelected())
+ mValue = "1";
+ else
+ mValue = "0";
+}
+
+void SetupItemCheckBox::toWidget()
+{
+ if (!mCheckBox)
+ return;
+
+ mCheckBox->setSelected(mValue != "0");
+}
+
+
+SetupItemTextField::SetupItemTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mEditDialog(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemTextField::SetupItemTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName, std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mEditDialog(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemTextField::~SetupItemTextField()
+{
+ mHorizont = 0;
+ mWidget = 0;
+ mTextField = 0;
+ mLabel = 0;
+ mButton = 0;
+}
+
+void SetupItemTextField::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mTextField = new TextField(mValue, true, mParent, mEventName);
+ mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent);
+ mWidget = mTextField;
+ mTextField->setWidth(200);
+ mHorizont->add(mLabel);
+ mHorizont->add(mTextField);
+ mHorizont->add(mButton);
+
+ mParent->getContainer()->add(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addControl(this, mEventName + "_EDIT");
+ mParent->addControl(this, mEventName + "_EDIT_OK");
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+ mButton->addActionListener(this);
+}
+
+void SetupItemTextField::fromWidget()
+{
+ if (!mTextField)
+ return;
+
+ mValue = mTextField->getText();
+}
+
+void SetupItemTextField::toWidget()
+{
+ if (!mTextField)
+ return;
+
+ mTextField->setText(mValue);
+}
+
+void SetupItemTextField::action(const gcn::ActionEvent &event)
+{
+ if (!mTextField)
+ return;
+
+ if (event.getId() == mWidget->getActionEventId())
+ {
+ fromWidget();
+ }
+ else if (event.getId() == mEventName + "_EDIT")
+ {
+ mEditDialog = new EditDialog(mText, mTextField->getText(),
+ mEventName + "_EDIT_OK");
+ mEditDialog->addActionListener(this);
+ }
+ else if (event.getId() == mEventName + "_EDIT_OK")
+ {
+ mTextField->setText(mEditDialog->getMsg());
+ mEditDialog = 0;
+ }
+}
+
+void SetupItemTextField::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
+
+SetupItemIntTextField::SetupItemIntTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ int min, int max,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mMin(min),
+ mMax(max),
+ mEditDialog(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemIntTextField::SetupItemIntTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ int min, int max,
+ std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mMin(min),
+ mMax(max),
+ mEditDialog(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemIntTextField::~SetupItemIntTextField()
+{
+ mHorizont = 0;
+ mWidget = 0;
+ mTextField = 0;
+ mLabel = 0;
+ mButton = 0;
+}
+
+void SetupItemIntTextField::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mTextField = new IntTextField(atoi(mValue.c_str()), mMin, mMax, true, 30);
+ mTextField->setActionEventId(mEventName);
+ mTextField->addActionListener(mParent);
+
+ mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent);
+ mWidget = mTextField;
+ mTextField->setWidth(50);
+ mHorizont->add(mLabel);
+ mHorizont->add(mTextField);
+ mHorizont->add(mButton);
+
+ mParent->getContainer()->add(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addControl(this, mEventName + "_EDIT");
+ mParent->addControl(this, mEventName + "_EDIT_OK");
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+ mButton->addActionListener(this);
+}
+
+void SetupItemIntTextField::fromWidget()
+{
+ if (!mTextField)
+ return;
+
+ mValue = mTextField->getText();
+}
+
+void SetupItemIntTextField::toWidget()
+{
+ if (!mTextField)
+ return;
+
+ mTextField->setText(mValue);
+}
+
+void SetupItemIntTextField::action(const gcn::ActionEvent &event)
+{
+ if (!mTextField)
+ return;
+
+ if (event.getId() == mWidget->getActionEventId())
+ {
+ fromWidget();
+ }
+ else if (event.getId() == mEventName + "_EDIT")
+ {
+ mEditDialog = new EditDialog(mText, mTextField->getText(),
+ mEventName + "_EDIT_OK");
+ mEditDialog->addActionListener(this);
+ }
+ else if (event.getId() == mEventName + "_EDIT_OK")
+ {
+ mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
+ mEditDialog = 0;
+ }
+}
+
+void SetupItemIntTextField::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
+
+
+
+SetupItemLabel::SetupItemLabel(std::string text, std::string description,
+ SetupTabScroll *parent, bool separator) :
+ SetupItem(text, description, "", parent, "", "", true),
+ mLabel(0),
+ mIsSeparator(separator)
+{
+ mValueType = VNONE;
+ createControls();
+}
+
+SetupItemLabel::~SetupItemLabel()
+{
+ mWidget = 0;
+ mLabel = 0;
+}
+
+void SetupItemLabel::createControls()
+{
+ if (mIsSeparator)
+ {
+ const std::string str = " \342\200\225\342\200\225\342\200\225"
+ "\342\200\225\342\200\225 ";
+ mLabel = new Label(str + mText + str);
+ }
+ else
+ {
+ mLabel = new Label(mText);
+ }
+
+ mWidget = mLabel;
+ mParent->getContainer()->add(mWidget);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemLabel::fromWidget()
+{
+}
+
+void SetupItemLabel::toWidget()
+{
+}
+
+void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED)
+{
+}
+
+void SetupItemLabel::apply(std::string eventName A_UNUSED)
+{
+}
+
+
+SetupItemDropDown::SetupItemDropDown(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mModel(model),
+ mDropDown(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemDropDown::SetupItemDropDown(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mModel(model),
+ mDropDown(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemDropDown::~SetupItemDropDown()
+{
+ mHorizont = 0;
+ mWidget = 0;
+ mModel = 0;
+ mDropDown = 0;
+ mLabel = 0;
+}
+
+void SetupItemDropDown::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mDropDown = new DropDown(mModel);
+ mDropDown->setActionEventId(mEventName);
+ mDropDown->addActionListener(mParent);
+
+ mWidget = mDropDown;
+// mTextField->setWidth(50);
+ mHorizont->add(mLabel);
+ mHorizont->add(mDropDown);
+
+ mParent->getContainer()->add(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemDropDown::fromWidget()
+{
+ if (!mDropDown)
+ return;
+
+ mValue = mDropDown->getSelectedString();
+}
+
+void SetupItemDropDown::toWidget()
+{
+ if (!mDropDown)
+ return;
+
+ mDropDown->setSelectedString(mValue);
+}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
new file mode 100644
index 000000000..15d2d41ea
--- /dev/null
+++ b/src/gui/widgets/setupitem.h
@@ -0,0 +1,273 @@
+/*
+ * The ManaPlus Client
+ * 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 SETUPITEM_H
+#define SETUPITEM_H
+
+#include "gui/widgets/tabbedarea.h"
+
+#include "guichanfwd.h"
+
+#include "gui/widgets/setuptabscroll.h"
+#include "gui/widgets/window.h"
+
+#include <guichan/actionlistener.hpp>
+#include <guichan/widget.hpp>
+
+#include <list>
+
+#ifdef __GNUC__
+#define A_UNUSED __attribute__ ((unused))
+#else
+#define A_UNUSED
+#endif
+
+class CheckBox;
+class Configuration;
+class ContainerPlacer;
+class DropDown;
+class EditDialog;
+class HorizontContainer;
+class IntTextField;
+class Label;
+class TextField;
+
+class SetupItem : public gcn::ActionListener
+{
+ public:
+ enum
+ {
+ VBOOL = 0,
+ VSTR,
+ VINT,
+ VNONE
+ };
+
+ SetupItem(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, bool mainConfig);
+
+ SetupItem(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, std::string def, bool mainConfig);
+
+ ~SetupItem();
+
+ void load();
+
+ void save();
+
+ virtual void fromWidget() = 0;
+
+ virtual void toWidget() = 0;
+
+ void setWidget(gcn::Widget *widget)
+ { mWidget = widget; }
+
+ gcn::Widget *getWidget()
+ { return mWidget; }
+
+ Configuration *getConfig();
+
+ virtual std::string getActionEventId();
+
+ virtual void action(const gcn::ActionEvent &event);
+
+ virtual void action();
+
+ virtual void apply(std::string eventName);
+
+ virtual void cancel(std::string eventName);
+
+ virtual void externalUpdated(std::string eventName);
+// virtual int add(ContainerPlacer &place, int x, int y, int width);
+
+ bool isMainConfig()
+ { return mMainConfig; }
+
+ protected:
+ std::string mText;
+
+ std::string mDescription;
+
+ std::string mKeyName;
+
+ SetupTabScroll *mParent;
+
+ std::string mEventName;
+
+ bool mMainConfig;
+
+ bool mUseDefault;
+
+ std::string mValue;
+
+ std::string mDefault;
+
+ gcn::Widget *mWidget;
+
+ std::list<gcn::Widget*> mTempWidgets;
+
+ int mValueType;
+};
+
+class SetupItemCheckBox : public SetupItem
+{
+ public:
+ SetupItemCheckBox(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, bool mainConfig = true);
+
+ SetupItemCheckBox(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, std::string def,
+ bool mainConfig = true);
+
+ ~SetupItemCheckBox();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ protected:
+ CheckBox *mCheckBox;
+};
+
+class SetupItemTextField : public SetupItem
+{
+ public:
+ SetupItemTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, bool mainConfig = true);
+
+ SetupItemTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, std::string def,
+ bool mainConfig = true);
+
+ ~SetupItemTextField();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ TextField *mTextField;
+ Button *mButton;
+ EditDialog *mEditDialog;
+};
+
+class SetupItemIntTextField : public SetupItem
+{
+ public:
+ SetupItemIntTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ bool mainConfig = true);
+
+ SetupItemIntTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemIntTextField();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ IntTextField *mTextField;
+ Button *mButton;
+ int mMin;
+ int mMax;
+ EditDialog *mEditDialog;
+};
+
+class SetupItemLabel : public SetupItem
+{
+ public:
+ SetupItemLabel(std::string text, std::string description,
+ SetupTabScroll *parent, bool separator = true);
+
+ ~SetupItemLabel();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ protected:
+ Label *mLabel;
+ bool mIsSeparator;
+};
+
+class SetupItemDropDown : public SetupItem
+{
+ public:
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ bool mainConfig = true);
+
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemDropDown();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ gcn::ListModel *mModel;
+ DropDown *mDropDown;
+};
+
+#endif
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index 805c0c8c7..30bb66469 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -20,10 +20,9 @@
#include "gui/widgets/setuptabscroll.h"
-#include "gui/setupitem.h"
-
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
#include "gui/widgets/vertcontainer.h"
#include "debug.h"
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index c5bcd88c4..e15445b77 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -43,6 +43,11 @@ int ShopItems::getNumberOfElements()
return static_cast<int>(mShopItems.size());
}
+bool ShopItems::empty()
+{
+ 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 abfcffb71..29d24cb64 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/widgets/shopitems.h
@@ -76,6 +76,8 @@ class ShopItems : public gcn::ListModel
*/
int getNumberOfElements();
+ bool 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 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 0f4814429..8abe727b5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * 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
@@ -39,7 +40,7 @@
#include "keyboardconfig.h"
#include "localplayer.h"
#include "spellmanager.h"
-#include "log.h"
+#include "logger.h"
#include "resources/image.h"
#include "textcommand.h"
@@ -80,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
SpellShortcutContainer::~SpellShortcutContainer()
@@ -105,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/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 28016cbad..2155e2a8b 100644
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ b/src/gui/widgets/spellshortcutcontainer.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * 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
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 1b548a6a3..530f1ac82 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -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/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index d3539a115..940dad12a 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -25,7 +25,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tab.h"
-#include "log.h"
+#include "logger.h"
#include <guichan/widgets/container.hpp>
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index d3108a77f..2729e5407 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
@@ -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/tradetab.cpp b/src/gui/widgets/tradetab.cpp
index 99a145d86..deec2aea6 100644
--- a/src/gui/widgets/tradetab.cpp
+++ b/src/gui/widgets/tradetab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/tradetab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index d65274f20..ea6b4d520 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -49,7 +49,7 @@ void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing)
widget->setPosition(mLeftSpacing, mNextY);
if (resizable)
{
- widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize);
+ widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize * 5);
mResizableWidgets.push_back(widget);
}
else if (widget->getHeight() > mVerticalItemSize)
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index bee30b969..c99c4e0c5 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/whispertab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 14448ea86..cdb9d3d55 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/gui.h"
#include "gui/palette.h"
@@ -95,6 +95,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
addWidgetListener(this);
mCaptionFont = getFont();
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Window::~Window()
@@ -146,15 +147,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);
}