2 * Copyright (C) 2009 by Aiwota Programmer
3 * aiwotaprog@tetteke.tk
5 * This file is part of Dialektos.
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.
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.
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/>.
21 #ifndef TEXT_ELEMENT_ANCHOR_HXX
22 #define TEXT_ELEMENT_ANCHOR_HXX
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"
35 namespace text_element {
38 /*! @brief text element for Anchor. */
39 class Anchor: public Plain {
42 /*! @brief Constructor.
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.
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)) {
54 /*! @brief return a cursor type appropriated to the anchor text element.
56 * @return the cursor type for the anchor.
58 virtual Gdk::CursorType get_cursor_type() const;
60 /*! @brief return the href.
64 Glib::ustring get_href() const { return href_; }
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;
71 void do_draw_underline(text_view::DrawingSet&,
72 const Glib::RefPtr<const Gdk::GC>&, double width, double x, double y) const;
75 virtual Anchor* do_clone() const { return new Anchor(*this); }
78 /*! @brief hyper reference */
79 const Glib::ustring href_;
83 } // namespace text_element
85 } // namespace dialektos