1 /* gobby - A GTKmm driven libobby client 2 * Copyright (C) 2005 0x539 dev group 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public 15 * License along with this program; if not, write to the Free 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */ 18 19 #ifndef _GOBBY_CHAT_HPP_ 20 #define _GOBBY_CHAT_HPP_ 21 22 #include <gtkmm/box.h> 23 #include <gtkmm/scrolledwindow.h> 24 #include <gtkmm/button.h> 25 #include <gtkmm/image.h> 26 #include <obby/user.hpp> 27 #include "preferences.hpp" 28 #include "historyentry.hpp" 29 #include "logview.hpp" 30 #include "buffer_def.hpp" 31 32 namespace Gobby 33 { 34 35 class Chat: public Gtk::VBox 36 { 37 public: 38 Chat(Gtk::Window& parent, 39 const Preferences& preferences); 40 virtual ~Chat(); 41 42 // Calls from the window 43 void obby_start(LocalBuffer& buf); 44 void obby_end(); 45 void obby_user_join(const obby::user& user); 46 void obby_user_part(const obby::user& user); 47 void obby_document_insert(LocalDocumentInfo& document); 48 void obby_document_remove(LocalDocumentInfo& document); 49 50 protected: 51 void on_chat(); 52 53 #ifdef GTKMM_GEQ_28 54 bool on_focus_in(GdkEventFocus* event); 55 bool on_focus_out(GdkEventFocus* event); 56 #endif 57 58 void on_query_failed(const obby::command_query& query); 59 void on_help(const std::string& name, const std::string& desc); 60 61 void on_remove_result(const obby::command_query& query, 62 const obby::command_result& result); 63 64 void on_message(const obby::chat::message& message); 65 void on_user_message(const obby::chat::user_message& message); 66 void on_server_message(const obby::chat::server_message& message); 67 void on_system_message(const obby::chat::system_message& message); 68 69 void send_line(const std::string& line); 70 void recv_user_line(const std::string& line, 71 const obby::chat::user_message& message); 72 void recv_server_line(const std::string& line, 73 const obby::chat::server_message& message); 74 void recv_system_line(const std::string& line, 75 const obby::chat::system_message& message); 76 77 Gtk::Window& m_parent; 78 const Preferences& m_preferences; 79 LocalBuffer* m_buffer; 80 81 Gtk::Image m_img_btn; 82 Gtk::HBox m_box_chat; 83 Gtk::ScrolledWindow m_wnd_chat; 84 LogView m_log_chat; 85 HistoryEntry m_ent_chat; 86 Gtk::Button m_btn_chat; 87 88 bool m_focus; 89 }; 90 91 } 92 93 #endif // _GOBBY_CHAT_HPP_ 94