text_layout.h

00001 // text_layout.h                     -*-c++-*-
00002 //
00003 //   Copyright (C) 2004-2005, 2007 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 
00079       void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);
00080 
00082       void set_fragment(fragment *f);
00083 
00098       void append_fragment(fragment *f);
00099 
00103       int width_request();
00104 
00108       int height_request(int w);
00109 
00111       bool get_cursorvisible();
00112 
00114       point get_cursorloc();
00115 
00117       bool focus_me();
00118 
00120       void paint(const style &st);
00121 
00123       void line_down();
00124 
00126       void line_up();
00127 
00129       void move_to_top();
00130 
00132       void move_to_bottom();
00133 
00135       void page_down();
00136 
00138       void page_up();
00139 
00144       void search_for(const std::wstring &s,
00145                       bool search_forwards);
00146 
00152       void scroll(bool dir);
00153 
00155       ~text_layout();
00156 
00160       sigc::signal2<void, int, int> location_changed;
00161 
00162       static config::keybindings *bindings;
00163 
00164       static void init_bindings();
00165     private:
00167       void set_start(unsigned int new_start);
00168 
00170       void freshen_contents(const style &st);
00171 
00173       void layout_me();
00174 
00176       void do_signal();
00177 
00179       size_t start;
00180 
00182       fragment *f;
00183 
00185       fragment_contents contents;
00186 
00188       bool stale;
00189 
00191       int lastw;
00192 
00194       style lastst;
00195     };
00196 
00197     typedef util::ref_ptr<text_layout> text_layout_ref;
00198   }
00199 }
00200 
00201 #endif

Generated on Wed Jan 28 07:23:52 2009 for cwidget by  doxygen 1.5.6