summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/chattab.cpp13
-rw-r--r--src/gui/widgets/chattab.h7
-rw-r--r--src/gui/widgets/tab.cpp4
-rw-r--r--src/gui/widgets/tab.h5
-rw-r--r--src/gui/widgets/tabbedarea.cpp29
-rw-r--r--src/gui/widgets/tabbedarea.h32
-rw-r--r--src/gui/widgets/whispertab.cpp2
7 files changed, 35 insertions, 57 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 44840423..01d8b62b 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -125,11 +125,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
}
break;
case BY_PLAYER:
- tmp.nick += CAT_NORMAL;
+ tmp.nick += ": ";
lineColor = "##Y";
break;
case BY_OTHER:
- tmp.nick += CAT_NORMAL;
+ tmp.nick += ": ";
lineColor = "##C";
break;
case BY_SERVER:
@@ -148,7 +148,6 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
lineColor = "##W";
break;
case ACT_IS:
- tmp.nick += CAT_IS;
lineColor = "##I";
break;
case BY_LOGGER:
@@ -207,8 +206,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
void ChatTab::chatLog(const std::string &nick, const std::string &msg)
{
- chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ?
- BY_PLAYER : BY_OTHER, false);
+ chatLog(nick + ": " + msg,
+ nick == player_node->getName() ? BY_PLAYER : BY_OTHER,
+ false);
}
void ChatTab::chatInput(std::string &msg)
@@ -270,7 +270,8 @@ void ChatTab::clearText()
mTextOutput->clearRows();
}
-void ChatTab::handleInput(const std::string &msg) {
+void ChatTab::handleInput(const std::string &msg)
+{
Net::getChatHandler()->talk(msg);
}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 27c27480..dc0d3047 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -42,13 +42,6 @@ enum
};
/**
- * gets in between usernick and message text depending on
- * message type
- */
-#define CAT_NORMAL ": "
-#define CAT_IS ""
-
-/**
* A tab for the chat window. This is special to ease chat handling.
*/
class ChatTab : public Tab
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 456735c4..071be06a 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -159,10 +159,8 @@ void Tab::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-void Tab::setTabColor(gcn::Color color)
+void Tab::setTabColor(const gcn::Color &color)
{
- if (color == NULL)
- color = guiPalette->getColor(Palette::TEXT);
mTabColor = color;
}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 271316e4..134d5591 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -28,7 +28,8 @@ class ImageRect;
class TabbedArea;
/**
- * A tab, the same as the guichan tab in 0.8, but extended to allow transparancy
+ * A tab, the same as the Guichan tab in 0.8, but extended to allow
+ * transparency.
*/
class Tab : public gcn::Tab
{
@@ -44,7 +45,7 @@ class Tab : public gcn::Tab
/**
* Set the normal color fo the tab's text.
*/
- void setTabColor(gcn::Color color);
+ void setTabColor(const gcn::Color &color);
/**
* Set tab highlighted
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 86730c51..07f46a94 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -29,14 +29,14 @@ TabbedArea::TabbedArea() : gcn::TabbedArea()
mWidgetContainer->setOpaque(false);
}
-int TabbedArea::getNumberOfTabs()
+int TabbedArea::getNumberOfTabs() const
{
return mTabs.size();
}
-Tab* TabbedArea::getTab(const std::string &name)
+Tab *TabbedArea::getTab(const std::string &name) const
{
- TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end();
+ TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end();
while (itr != itr_end)
{
if ((*itr).first->getCaption() == name)
@@ -55,9 +55,9 @@ void TabbedArea::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-gcn::Widget* TabbedArea::getWidget(const std::string &name)
+gcn::Widget *TabbedArea::getWidget(const std::string &name) const
{
- TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end();
+ TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end();
while (itr != itr_end)
{
if ((*itr).first->getCaption() == name)
@@ -71,28 +71,13 @@ gcn::Widget* TabbedArea::getWidget(const std::string &name)
void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget)
{
- Tab* tab = new Tab;
+ Tab *tab = new Tab;
tab->setCaption(caption);
mTabsToDelete.push_back(tab);
addTab(tab, widget);
}
-void TabbedArea::addTab(Tab *tab, gcn::Widget *widget)
-{
- tab->setTabbedArea(this);
- tab->addActionListener(this);
-
- mTabContainer->add(tab);
- mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget));
-
- if (!mSelectedTab)
- setSelectedTab(tab);
-
- adjustTabPositions();
- adjustSize();
-}
-
void TabbedArea::removeTab(Tab *tab)
{
int tabIndexToBeSelected = -1;
@@ -146,8 +131,8 @@ void TabbedArea::removeTab(Tab *tab)
void TabbedArea::logic()
{
logicChildren();
-
}
+
void TabbedArea::setSelectedTab(gcn::Tab *tab)
{
gcn::TabbedArea::setSelectedTab(tab);
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index b4fc1ded..6aaafe16 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -47,45 +47,45 @@ class TabbedArea : public gcn::TabbedArea
void draw(gcn::Graphics *graphics);
/**
- * Return how many tabs have been created
+ * Return how many tabs have been created.
+ *
+ * @todo Remove this method when upgrading to Guichan 0.9.0
*/
- int getNumberOfTabs();
+ int getNumberOfTabs() const;
/**
- * Return tab with specified name as caption
+ * Return tab with specified name as caption.
*/
- Tab* getTab(const std::string &name);
+ Tab *getTab(const std::string &name) const;
/**
* Returns the widget with the tab that has specified caption
*/
- gcn::Widget* getWidget(const std::string &name);
+ gcn::Widget *getWidget(const std::string &name) const;
+
+ using gcn::TabbedArea::addTab;
/**
- * Add a tab
+ * Add a tab. Overridden since it needs to create an instance of Tab
+ * instead of gcn::Tab.
+ *
* @param caption The Caption to display
* @param widget The widget to show when tab is selected
*/
void addTab(const std::string &caption, gcn::Widget *widget);
/**
- * Add a tab
- * @param tab The tab
- * @param widget The widget to display
- */
- void addTab(Tab *tab, gcn::Widget *widget);
-
- /**
- * Overload the remove tab function as its broken in guichan 0.8
+ * Overload the remove tab function as it's broken in guichan 0.8.
*/
void removeTab(Tab *tab);
/**
- * Overload the logic function since it's broken in guichan 0.8
+ * Overload the logic function since it's broken in guichan 0.8.
*/
void logic();
- int getContainerHeight() { return mWidgetContainer->getHeight(); }
+ int getContainerHeight() const
+ { return mWidgetContainer->getHeight(); }
void setSelectedTab(unsigned int index)
{ gcn::TabbedArea::setSelectedTab(index); }
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 87a88222..0c6503a6 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -45,7 +45,7 @@ WhisperTab::~WhisperTab()
void WhisperTab::handleInput(const std::string &msg)
{
- if (msg.length() == 0) {
+ if (msg.empty()) {
chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
return;
}