OSDN Git Service

Session load and save.
[fukui-no-namari/dialektos.git] / src / text_view_layoutable.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_VIEW_LAYOUTABLE_HXX
22 #define TEXT_VIEW_LAYOUTABLE_HXX
23
24 #include <glibmm/refptr.h>
25 #include <pangomm/layout.h>
26 #include <boost/ptr_container/ptr_vector.hpp>
27 #include <boost/shared_ptr.hpp>
28 #include "text_view_scrollable.hxx"
29
30
31 namespace dialektos {
32
33 class TextLine;
34
35 namespace text_element {
36   class Plain;
37   class IDMap;
38   class ResNumMap;
39 }
40
41 namespace text_view {
42
43
44 class Layoutable: public Scrollable {
45 public:
46   typedef boost::ptr_vector<TextLine> LineListType;
47   typedef boost::shared_ptr<text_element::IDMap> IDMapPtrType;
48 //  typedef boost::shared_ptr<const text_element::IDMap> ConstIDMapPtrType;
49   typedef boost::shared_ptr<text_element::ResNumMap> ResNumMapPtrType;
50 //  typedef boost::shared_ptr<const text_element::ResNumMap> ConstResNumMapPtrType;
51
52   Layoutable();
53   virtual ~Layoutable();
54   void relayout();
55   void add_line(TextLine*);
56   void set_id_map(IDMapPtrType map) { id_map_ = map; }
57   void set_res_num_map(ResNumMapPtrType map) { res_num_map_ = map; }
58   IDMapPtrType get_id_map() const { return id_map_; }
59   ResNumMapPtrType get_res_num_map() const { return res_num_map_; }
60   void set_res_num(int res_num) { res_num_ = res_num; }
61   int get_res_num() const { return res_num_; }
62 protected:
63   //virtual bool on_expose_event(GdkEventExpose*);
64   virtual bool on_configure_event(GdkEventConfigure*);
65
66   const TextLine* get_text_line(gdouble y) const;
67   const TextLine* get_nearest_text_line(gdouble& y) const;
68   const text_element::Plain* get_text_element(gdouble x, gdouble y) const;
69   const text_element::Plain* get_nearest_text_element(gdouble& x, gdouble& y) const;
70
71   Glib::RefPtr<Pango::Layout> pango_layout_;
72   LineListType line_list_;
73   boost::shared_ptr<text_element::IDMap> id_map_;
74   boost::shared_ptr<text_element::ResNumMap> res_num_map_;
75   int res_num_;
76   /* cached */
77   gint width_;
78 };
79
80
81 } // namespace text_view
82
83
84 } // namespace dialektos
85
86
87 #endif