summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-08-10 20:53:07 -0600
committerJared Adams <jaxad0127@gmail.com>2009-08-10 20:53:07 -0600
commit3a23f6a771142b6dc3df361b88621eec31d4e40f (patch)
tree7364a138e37b96ced7363a1be010fea70b280e3e /src
parent843fbb7fac79d1e0340fe489e8e78e4a41b3da43 (diff)
downloadmana-3a23f6a771142b6dc3df361b88621eec31d4e40f.tar.gz
mana-3a23f6a771142b6dc3df361b88621eec31d4e40f.tar.bz2
mana-3a23f6a771142b6dc3df361b88621eec31d4e40f.tar.xz
mana-3a23f6a771142b6dc3df361b88621eec31d4e40f.zip
Remove layout code from ChatWindow
Diffstat (limited to 'src')
-rw-r--r--src/gui/chat.cpp48
-rw-r--r--src/gui/chat.h8
-rw-r--r--src/gui/widgets/tabbedarea.cpp8
-rw-r--r--src/gui/widgets/tabbedarea.h8
4 files changed, 20 insertions, 52 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index be302dc3..4cabf92e 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -98,10 +98,10 @@ ChatWindow::ChatWindow():
mChatTabs = new TabbedArea;
- //place(0, 0, mChatTabs, 3, 3);
- //place(0, 3, mChatInput, 3);
- add(mChatTabs);
- add(mChatInput);
+ place(0, 0, mChatTabs, 3, 3);
+ place(0, 3, mChatInput, 3);
+ //add(mChatTabs);
+ //add(mChatInput);
loadWindowState();
@@ -128,41 +128,6 @@ void ChatWindow::resetToDefaultSize()
Window::resetToDefaultSize();
}
-void ChatWindow::adjustTabSize()
-{
- //return;
- const gcn::Rectangle area = getChildrenArea();
-
- mChatInput->setPosition(mChatInput->getFrameSize(),
- area.height - mChatInput->getHeight() -
- mChatInput->getFrameSize());
- mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize());
-
- mChatTabs->setWidth(area.width - 2 * mChatTabs->getFrameSize());
- mChatTabs->setHeight(area.height - 2 * mChatTabs->getFrameSize() -
- (mChatInput->getHeight() + mChatInput->getFrameSize() * 2));
-
- ChatTab *tab = getFocused();
- if (tab) {
- gcn::Widget *content = tab->mScrollArea;
- bool scrollLock = false;
- if(tab->mScrollArea->getVerticalMaxScroll() == tab->mScrollArea->getVerticalScrollAmount())
- scrollLock = true;
- content->setSize(mChatTabs->getWidth() - 2 * content->getFrameSize(),
- mChatTabs->getContainerHeight() - 2 * content->getFrameSize());
- content->logic();
- if(scrollLock)
- tab->mScrollArea->setVerticalScrollAmount(tab->mScrollArea->getVerticalMaxScroll());
- }
-}
-
-void ChatWindow::widgetResized(const gcn::Event &event)
-{
- Window::widgetResized(event);
-
- adjustTabSize();
-}
-
void ChatWindow::logic()
{
Window::logic();
@@ -170,7 +135,6 @@ void ChatWindow::logic()
Tab *tab = getFocused();
if (tab != mCurrentTab) {
mCurrentTab = tab;
- adjustTabSize();
}
}
@@ -294,10 +258,6 @@ void ChatWindow::addTab(ChatTab *tab)
mChatTabs->addTab(tab, tab->mScrollArea);
- // Fix for layout issues when adding the first tab
- if (tab == localChatTab)
- adjustTabSize();
-
// Update UI
logic();
}
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 2de3a634..af5f760b 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -74,12 +74,6 @@ class ChatWindow : public Window,
*/
~ChatWindow();
- /**
- * Called when the widget changes size. Used for adapting the size of
- * the tabbed area.
- */
- void widgetResized(const gcn::Event &event);
-
void logic();
/**
@@ -193,8 +187,6 @@ class ChatWindow : public Window,
void removeWhisper(const std::string &nick);
- void adjustTabSize();
-
/** Used for showing item popup on clicking links **/
ItemLinkHandler *mItemLinkHandler;
Recorder *mRecorder;
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 2de812ed..681f99ec 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -80,6 +80,14 @@ gcn::Widget *TabbedArea::getCurrentWidget()
return NULL;
}
+void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget)
+{
+ int width = getWidth() - 2 * getFrameSize();
+ int height = getHeight() - 2 * getFrameSize() - mTabContainer->getHeight();
+ widget->setSize(width, height);
+ gcn::TabbedArea::addTab(tab, widget);
+}
+
void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget)
{
Tab *tab = new Tab;
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 1b61b102..a64d855f 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -72,6 +72,14 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
using gcn::TabbedArea::addTab;
/**
+ * Add a tab. Overridden since it needs to size the widget.
+ *
+ * @param tab The tab widget for the tab.
+ * @param widget The widget to view when the tab is selected.
+ */
+ void addTab(gcn::Tab* tab, gcn::Widget* widget);
+
+ /**
* Add a tab. Overridden since it needs to create an instance of Tab
* instead of gcn::Tab.
*