00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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