text_layout.h
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
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