From aaff5572f054045ecd4dd94ccdc2caac71132ad4 Mon Sep 17 00:00:00 2001 From: Mateusz Kaduk Date: Thu, 30 Jun 2005 20:45:43 +0000 Subject: Improved buddylist, added talk --- src/gui/buddywindow.cpp | 12 ++++++++++-- src/gui/chat.cpp | 6 ++++++ src/gui/chat.h | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp index 748ecb97..d2a20ffe 100644 --- a/src/gui/buddywindow.cpp +++ b/src/gui/buddywindow.cpp @@ -24,6 +24,9 @@ #include "buddywindow.h" #include "scrollarea.h" #include "button.h" +#include "chat.h" + +extern ChatWindow *chatWindow; BuddyWindow::BuddyWindow(): Window("Buddy") @@ -35,7 +38,7 @@ BuddyWindow::BuddyWindow(): scrollArea = new ScrollArea(listbox); scrollArea->setDimension(gcn::Rectangle( - 2, 0, 116, 180)); + 2, 0, 114, 176)); add(scrollArea); talk = new Button("Talk"); @@ -68,7 +71,12 @@ BuddyWindow::~BuddyWindow() void BuddyWindow::action(const std::string& eventId) { if (eventId == "Talk") { - // TODO + int selected = listbox->getSelected(); + if ( selected > -1 ) + { + std::string who = getElementAt(selected); + chatWindow->setInputText(who +": "); + } } else if (eventId == "Remove") { int selected = listbox->getSelected(); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8a11969a..c02f5160 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -327,3 +327,9 @@ void ChatWindow::keyPress(const gcn::Key &key) chatInput->setCaretPosition(chatInput->getText().length()); } } + +void ChatWindow::setInputText(std::string input_str) +{ + chatInput->setText(input_str + " "); + requestChatFocus(); +} diff --git a/src/gui/chat.h b/src/gui/chat.h index dfb0ba85..f459b804 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -184,6 +184,9 @@ class ChatWindow : public Window, public gcn::ActionListener, /** Called when key is pressed */ void keyPress(const gcn::Key& key); + /** Called to set current text */ + void setInputText(std::string input_str); + private: std::ofstream chatlog_file; -- cgit v1.2.3-60-g2f50