OSDN Git Service

Add a menu item 'Close'.
[fukui-no-namari/dialektos.git] / src / text_element_anchor.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_ELEMENT_ANCHOR_HXX
22 #define TEXT_ELEMENT_ANCHOR_HXX
23
24 #include <glibmm/ustring.h>
25 #include <gdkmm/cursor.h>
26 #include <boost/range.hpp>
27 #include <pangomm/item.h>
28 #include <pangomm/glyphstring.h>
29 #include <boost/unordered_map.hpp>
30 #include "text_element_plain.hxx"
31
32
33 namespace dialektos {
34
35 namespace text_element {
36
37
38 /*! @brief text element for Anchor. */
39 class Anchor: public Plain {
40 public:
41
42   /*! @brief Constructor.
43    *
44    * @param range is text represented by Boost.Range concepts.
45    * @param bold is whether or not the text is bold.
46    * @param href is href represented by Boost.Range concepts.
47    */
48   template <typename RangeT, typename RangeT2>
49   Anchor(const RangeT& range, bool bold, const RangeT2 href) :
50     Plain(range, bold), href_(boost::begin(href), boost::end(href)) {
51   }
52   virtual ~Anchor() {}
53
54   /*! @brief return a cursor type appropriated to the anchor text element.
55    *
56    * @return the cursor type for the anchor.
57    */
58   virtual Gdk::CursorType get_cursor_type() const;
59
60   /*! @brief return the href.
61    *
62    * @return the href.
63    */
64   Glib::ustring get_href() const { return href_; }
65
66 protected:
67   virtual void do_draw_glyphs(text_view::DrawingSet&, const Pango::Item&,
68       const Pango::GlyphString&, double x, double y,
69       bool in_selection) const;
70
71   void do_draw_underline(text_view::DrawingSet&,
72       const Glib::RefPtr<const Gdk::GC>&, double width, double x, double y) const;
73
74 private:
75   virtual Anchor* do_clone() const { return new Anchor(*this); }
76
77 protected:
78   /*! @brief hyper reference */
79   const Glib::ustring href_;
80 };
81
82
83 } // namespace text_element
84
85 } // namespace dialektos
86
87
88 #endif