summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp27
-rw-r--r--src/gui/chat.h19
2 files changed, 36 insertions, 10 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 8b53ef98..5e3aaf60 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -411,6 +411,19 @@ ChatWindow::const_msg(CHATSKILL act)
}
void
+ChatWindow::scroll(int amount)
+{
+ if (!isVisible())
+ return;
+
+ int range = mScrollArea->getHeight() / 8 * amount;
+ gcn::Rectangle scr;
+ scr.y = mScrollArea->getVerticalScrollAmount() + range;
+ scr.height = abs(range);
+ mTextOutput->showPart(scr);
+}
+
+void
ChatWindow::keyPressed(gcn::KeyEvent &event)
{
if (event.getKey().getValue() == gcn::Key::DOWN &&
@@ -446,11 +459,13 @@ ChatWindow::setInputText(std::string input_str)
void
ChatWindow::setVisible(bool isVisible)
{
- Window::setVisible(isVisible);
+ Window::setVisible(isVisible);
- /*
- * For whatever reason, if setVisible is called, the mTmpVisible effect
- * should be disabled.
- */
- mTmpVisible = false;
+ /*
+ * For whatever reason, if setVisible is called, the mTmpVisible effect
+ * should be disabled.
+ */
+
+ mTmpVisible = false;
}
+
diff --git a/src/gui/chat.h b/src/gui/chat.h
index f2e018a6..0bdc76f1 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -44,7 +44,7 @@ class ScrollArea;
#define BY_SERVER 3
#define ACT_WHISPER 4 // getting whispered at
-#define ACT_IS 5 // equivalent to "/me" in irc
+#define ACT_IS 5 // equivalent to "/me" on IRC
#define BY_LOGGER 6
@@ -99,7 +99,9 @@ class ScrollArea;
#define RFAIL_GENERIC 0x0a
/** should always be zero if failed */
-#define SKILL_FAILED 0x00
+#define SKILL_FAILED 0x00
+
+#define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'.
struct CHATSKILL
{
@@ -157,7 +159,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
*/
bool isInputFocused();
- /*
+ /**
* Determines whether to send a command or an ordinary message, then
* contructs packets & sends them.
*
@@ -196,6 +198,16 @@ class ChatWindow : public Window, public gcn::ActionListener,
void
setVisible(bool visible);
+ /**
+ * Scrolls the chat window
+ *
+ * @param amount direction and amount to scroll. Negative numbers scroll
+ * up, positive numbers scroll down. The absolute amount indicates the
+ * amount of 1/8ths of chat window real estate that should be scrolled.
+ */
+ void
+ scroll(int amount);
+
private:
Network *mNetwork;
bool mTmpVisible;
@@ -224,4 +236,3 @@ class ChatWindow : public Window, public gcn::ActionListener,
extern ChatWindow *chatWindow;
#endif
-