1 /* gobby - A GTKmm driven libobby client
2  * Copyright (C) 2005, 2006 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_LOGVIEW_HPP_
20 #define _GOBBY_LOGVIEW_HPP_
21 
22 #include <list>
23 #include <gdkmm/cursor.h>
24 #include <gtkmm/textview.h>
25 #include "features.hpp"
26 
27 #if defined(WITH_GNOME) || defined(WIN32) || defined(OSX)
28 # define HAVE_SHOW_URL
29 #endif
30 
31 namespace Gobby
32 {
33 
34 /** A Gtk::TextView-derived widget that easily supports the appending of new
35  * lines in multiple colors and scrolls automatically to the bottom, if a new
36  * line has been inserted. It is not editable by default.
37  */
38 
39 class LogView: public Gtk::TextView
40 {
41 public:
42 	LogView();
43 
44 	void clear();
45 	void log(const Glib::ustring& text,
46 	         const Glib::ustring& color);
47 	void log(const Glib::ustring& text,
48 	         const Glib::ustring& color,
49 		 const std::time_t timestamp);
50 
51 protected:
52 #ifdef HAVE_SHOW_URL
53 	void set_url_tag(const Gtk::TextIter& begin,
54 	                 const Gtk::TextIter& end);
55 
56 	bool on_motion_notify(GdkEventMotion* event);
57 	void on_event_after(GdkEvent* event);
58 #endif
59 
60 	Glib::RefPtr<Gtk::TextMark> m_end_mark;
61 
62 #ifdef HAVE_SHOW_URL
63 	Glib::RefPtr<Gtk::TextTag> m_tag_link;
64 	Gdk::Cursor m_default;
65 	Gdk::Cursor m_hand;
66 	bool m_hovering;
67 #endif
68 };
69 
70 } // namespace Gobby
71 
72 #endif // _GOBBY_LOGVIEW_HPP_
73