cwidget  0.5.16
text_layout.h
1 // text_layout.h -*-c++-*-
2 //
3 // Copyright (C) 2004-2005, 2007 Daniel Burrows
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; see the file COPYING. If not, write to
17 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 // Boston, MA 02111-1307, USA.
19 
20 
21 #ifndef TEXT_LAYOUT_H
22 #define TEXT_LAYOUT_H
23 
24 #include "widget.h"
25 #include <cwidget/fragment_contents.h>
26 
27 namespace cwidget
28 {
29  class fragment;
30 
31  namespace widgets
32  {
48  class text_layout : public widget
49  {
50  protected:
51  text_layout();
53  public:
56  {
58  rval->decref();
59  return rval;
60  }
61 
68  {
70  rval->decref();
71  return rval;
72  }
73 
77  bool handle_key(const config::key &k);
78 
79  void dispatch_mouse(short id, int x, int y, int z, mmask_t bstate);
80 
82  void set_fragment(fragment *f);
83 
98  void append_fragment(fragment *f);
99 
103  int width_request();
104 
108  int height_request(int w);
109 
111  bool get_cursorvisible();
112 
115 
117  bool focus_me();
118 
120  void paint(const style &st);
121 
123  void line_down();
124 
126  void line_up();
127 
129  void move_to_top();
130 
132  void move_to_bottom();
133 
135  void page_down();
136 
138  void page_up();
139 
144  void search_for(const std::wstring &s,
145  bool search_forwards);
146 
152  void scroll(bool dir);
153 
155  ~text_layout();
156 
160  sigc::signal2<void, int, int> location_changed;
161 
162  static config::keybindings *bindings;
163 
164  static void init_bindings();
165  private:
167  void set_start(unsigned int new_start);
168 
170  void freshen_contents(const style &st);
171 
173  void layout_me();
174 
176  void do_signal();
177 
179  size_t start;
180 
182  fragment *f;
183 
185  fragment_contents contents;
186 
188  bool stale;
189 
191  int lastw;
192 
194  style lastst;
195  };
196 
198  }
199 }
200 
201 #endif