/* * Copyright (C) 2002-2004 Morten Brix Pedersen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifndef TEXTWIDGET_H #define TEXTWIDGET_H #include #include #include #include #include #include #include class TextWidget : public Gtk::ScrolledWindow { struct TextProperties; public: TextWidget(Pango::FontDescription font); TextWidget& operator<<(const char * str); TextWidget& operator<<(const Glib::ustring& str); void clearText(); void setFont(const Pango::FontDescription& font); void setHighlightMark(); void scrollToHighlightMark(); void scrollUpPage(); void scrollDownPage(); void scrollToBottom(); void scrollToTop(); private: void insertText(const TextProperties& tp, const Glib::ustring& str); void populateMenu(Gtk::Menu*); void setStyle(); void onResize(Gtk::Allocation& alloc); void onScroll(); void removeTopBuffer(); void initializeColorMap(); Gtk::TextView _textview; Glib::RefPtr pos; std::vector > highlight_marks; std::vector >::reverse_iterator highlight_mark_pos; struct TextProperties { bool fgcolor; bool bgcolor; bool bold; bool underline; int numbercount; Glib::ustring fgnumber; Glib::ustring bgnumber; void clear() { bgcolor = false; fgcolor = false; bold = false; underline = false; numbercount = 0; fgnumber.clear(); bgnumber.clear(); } }; }; #endif