text_layout.h

00001 // text_layout.h                     -*-c++-*-
00002 //
00003 //   Copyright (C) 2004-2005 Daniel Burrows
00004 //
00005 //   This program is free software; you can redistribute it and/or
00006 //   modify it under the terms of the GNU General Public License as
00007 //   published by the Free Software Foundation; either version 2 of
00008 //   the License, or (at your option) any later version.
00009 //
00010 //   This program is distributed in the hope that it will be useful,
00011 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 //   General Public License for more details.
00014 //
00015 //   You should have received a copy of the GNU General Public License
00016 //   along with this program; see the file COPYING.  If not, write to
00017 //   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018 //   Boston, MA 02111-1307, USA.
00019 
00020 
00021 #ifndef TEXT_LAYOUT_H
00022 #define TEXT_LAYOUT_H
00023 
00024 #include "widget.h"
00025 #include <cwidget/fragment_contents.h>
00026 
00027 namespace cwidget
00028 {
00029   class fragment;
00030 
00031   namespace widgets
00032   {
00048     class text_layout : public widget
00049     {
00050     protected:
00051       text_layout();
00052       text_layout(fragment *f);
00053     public:
00055       static util::ref_ptr<text_layout> create()
00056       {
00057         util::ref_ptr<text_layout> rval(new text_layout);
00058         rval->decref();
00059         return rval;
00060       }
00061 
00067       static util::ref_ptr<text_layout> create(fragment *f)
00068       {
00069         util::ref_ptr<text_layout> rval(new text_layout(f));
00070         rval->decref();
00071         return rval;
00072       }
00073 
00077       bool handle_key(const config::key &k);
00078 
00080       void set_fragment(fragment *f);
00081 
00096       void append_fragment(fragment *f);
00097 
00101       int width_request();
00102 
00106       int height_request(int w);
00107 
00109       bool get_cursorvisible();
00110 
00112       point get_cursorloc();
00113 
00115       bool focus_me();
00116 
00118       void paint(const style &st);
00119 
00121       void line_down();
00122 
00124       void line_up();
00125 
00127       void move_to_top();
00128 
00130       void move_to_bottom();
00131 
00133       void page_down();
00134 
00136       void page_up();
00137 
00142       void search_for(const std::wstring &s,
00143                       bool search_forwards);
00144 
00150       void scroll(bool dir);
00151 
00153       ~text_layout();
00154 
00158       sigc::signal2<void, int, int> location_changed;
00159 
00160       static config::keybindings *bindings;
00161 
00162       static void init_bindings();
00163     private:
00165       void set_start(unsigned int new_start);
00166 
00168       void freshen_contents(const style &st);
00169 
00171       void layout_me();
00172 
00174       void do_signal();
00175 
00177       size_t start;
00178 
00180       fragment *f;
00181 
00183       fragment_contents contents;
00184 
00186       bool stale;
00187 
00189       int lastw;
00190 
00192       style lastst;
00193     };
00194 
00195     typedef util::ref_ptr<text_layout> text_layout_ref;
00196   }
00197 }
00198 
00199 #endif

Generated on Fri Nov 16 03:33:05 2007 for cwidget by  doxygen 1.5.1