libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
wrapinfo.h
1 /* Copyright (C) 2011-2012 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_WRAPINFO_H
15 #define T3_WIDGET_WRAPINFO_H
16 
17 #include <vector>
18 
19 #include <t3widget/util.h>
20 #include <t3widget/textbuffer.h>
21 
22 namespace t3_widget {
23 
24 typedef std::vector<int> wrap_points_t;
25 typedef std::vector<wrap_points_t *> wrap_data_t;
26 
35 class T3_WIDGET_LOCAL wrap_info_t {
36  private:
37  wrap_data_t wrap_data;
38  text_buffer_t *text;
39  int size,
40  tabsize,
41  wrap_width;
42  sigc::connection rewrap_connection;
43 
44  void delete_lines(int first, int last);
45  void insert_lines(int first, int last);
46  void rewrap_line(int line, int pos, bool force);
47  void rewrap_all(void);
48  void rewrap(rewrap_type_t type, int a, int b);
49 
50  public:
51  wrap_info_t(int width, int tabsize = 8);
52  ~wrap_info_t(void);
53  int get_size(void) const;
54 
55  void set_wrap_width(int width);
56  void set_tabsize(int _tabsize);
57  void set_text_buffer(text_buffer_t *_text);
58 
59  bool add_lines(text_coordinate_t &coord, int count) const;
60  bool sub_lines(text_coordinate_t &coord, int count) const;
61  int get_line_count(int line) const;
62  text_coordinate_t get_end(void) const;
63  int find_line(text_coordinate_t coord) const;
64  int calculate_screen_pos(void) const;
65  int calculate_screen_pos(const text_coordinate_t *where) const;
66  int calculate_line_pos(int line, int pos, int subline) const;
67  void paint_line(t3_window_t *win, text_coordinate_t line, text_line_t::paint_info_t *info) const;
68 };
69 
70 }; // namespace
71 #endif