OSDN Git Service

Change idx sub dir's time stamp when saving idx.
[fukui-no-namari/dialektos.git] / src / text_view_popup.cxx
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 #include "text_view_popup.hxx"
22
23 #include <gdkmm/rectangle.h>
24 #include <gtkmm/window.h>
25 #include <boost/foreach.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include "text_element_id_map.hxx"
28 #include "text_element_res_num.hxx"
29 #include "text_line.hxx"
30
31
32 namespace dialektos {
33
34
35 namespace text_view {
36
37
38 Popup::Popup(const LineListType& line_list,
39     const LineListType& original_line_list,
40     const text_element::Anchor& element,
41     boost::shared_ptr<text_element::IDMap> id_map,
42     boost::shared_ptr<text_element::ResNumMap> res_num_map):
43       Gtk::Window(Gtk::WINDOW_POPUP),
44   text_view_(original_line_list),
45   scrolled_(text_view_.get_adjustment()),
46   element_origin_(element) {
47
48   text_view_.set_id_map(id_map);
49   text_view_.set_res_num_map(res_num_map);
50
51   scrolled_.add(text_view_);
52   add(scrolled_);
53
54   text_view_.show();
55
56   text_view_.size_allocate(Gdk::Rectangle(0, 0, 300, 200));
57   text_view_.get_adjustment().set_page_size(200);
58
59   BOOST_FOREACH(const TextLine& line, line_list) {
60     text_view_.add_line(new TextLine(line));
61   }
62
63   text_view_.relayout();
64   text_view_.queue_draw();
65
66   text_view_.size_allocate(Gdk::Rectangle(0, 0, 300,
67       std::min(200.0, std::ceil(text_view_.get_adjustment().get_upper()))));
68   set_default_size(300, text_view_.get_height());
69
70 }
71
72 bool Popup::is_same_origin(const text_element::Anchor& rhs) const {
73   return &element_origin_ == &rhs;
74 }
75
76 bool Popup::on_the_child() const {
77   return text_view_.is_pointer_on_the_popup();
78 }
79
80
81 } // namespace text_view
82
83
84 } // namespace dialektos