2 Copyright (C) 1999 Paul Barton-Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm2ext/textviewer.h>
26 using namespace Gtkmm2ext;
29 TextViewer::TextViewer (size_t xsize, size_t ysize) :
30 Gtk::Window (Gtk::WINDOW_TOPLEVEL),
31 Transmitter (Transmitter::Info), /* channel arg is irrelevant */
34 set_size_request (xsize, ysize);
36 set_title ("Text Viewer");
37 set_name ("TextViewer");
41 vbox1.set_homogeneous (false);
42 vbox1.set_spacing (0);
46 vbox2.set_homogeneous (false);
47 vbox2.set_spacing (10);
48 //vbox2.set_border_width (10);
50 vbox1.pack_start (vbox2, true, true, 0);
53 vbox2.pack_start (scrollwin, TRUE, TRUE, 0);
54 scrollwin.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
57 etext.set_editable (false);
58 etext.set_wrap_mode (Gtk::WRAP_WORD);
59 scrollwin.add (etext);
62 vbox1.pack_start (dismiss, false, false, 0);
65 dismiss.signal_clicked().connect(mem_fun (*this, &TextViewer::signal_released_handler));
69 TextViewer::signal_released_handler()
75 TextViewer::scroll_to_bottom ()
80 adj = scrollwin.get_vadjustment();
81 adj->set_value (MAX(0,(adj->get_upper() - adj->get_page_size())));
85 TextViewer::deliver ()
89 Glib::RefPtr<Gtk::TextBuffer> tb (etext.get_buffer());
92 read (buf, sizeof (buf));
95 tb->insert (tb->end(), foo);