OSDN Git Service

Initial commit. Text view widget is implemented.
[fukui-no-namari/dialektos.git] / src / text_line.hxx
1 /*
2  * Copyright (C) 2009 by Aiwota Programmer
3  * aiwotaprog@tetteke.tk
4  *
5  * This file is part of Dialektos.
6  *
7  * Dialektos is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Dialektos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Dialektos.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef TEXT_LINE_HXX
22 #define TEXT_LINE_HXX
23
24 #include <boost/ptr_container/ptr_vector.hpp>
25
26
27 namespace dialektos {
28
29
30 namespace text_view {
31   class DrawingSet;
32   class LayoutSet;
33 }
34
35 namespace text_element {
36   class Plain;
37 };
38
39 class TextLine {
40   typedef boost::ptr_vector<text_element::Plain> ElementListType;
41 public:
42   explicit TextLine(int res_num, int left_margin);
43   explicit TextLine(const TextLine& rhs);
44   ~TextLine();
45   void add_element(text_element::Plain* element);
46   void trim_right();
47   bool empty() const;
48   void layout(text_view::LayoutSet&);
49   void draw(text_view::DrawingSet&) const;
50   double get_height() const { return height_; }
51   /* return y position on the adjustment. */
52   double get_y() const { return y_; }
53   double get_btm_y() const { return y_ + height_; }
54   const text_element::Plain* get_text_element(double x, double y) const;
55   const text_element::Plain* get_nearest_text_element(
56       double& x, double& y) const;
57   int get_res_num() const { return res_num_; }
58 private:
59   const int res_num_;
60   ElementListType element_list_;
61   double height_;
62   double y_;  // y on the adjustment.
63   int width_;
64   int left_margin_;
65   int right_margin_;
66 };
67
68
69 } // namespace dialektos
70
71 #endif