OSDN Git Service

Set window title.
[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 <pangomm/attrlist.h>
27 #include <boost/range.hpp>
28 #include <boost/unordered_map.hpp>
29 #include "text_element_plain.hxx"
30
31
32 namespace dialektos {
33
34 namespace text_element {
35
36
37 /*! @brief text element for Anchor. */
38 class Anchor: public Plain {
39 public:
40
41   /*! @brief Constructor.
42    *
43    * @param range is text represented by Boost.Range concepts.
44    * @param bold is whether or not the text is bold.
45    * @param href is href represented by Boost.Range concepts.
46    */
47   template <typename RangeT, typename RangeT2>
48   Anchor(const RangeT& range, bool bold, const RangeT2 href) :
49     Plain(range, bold), href_(boost::begin(href), boost::end(href)) {
50   }
51   virtual ~Anchor() {}
52
53   /*! @brief return a cursor type appropriated to the anchor text element.
54    *
55    * @return the cursor type for the anchor.
56    */
57   virtual Gdk::CursorType get_cursor_type() const;
58
59   /*! @brief return the href.
60    *
61    * @return the href.
62    */
63   Glib::ustring get_href() const { return href_; }
64
65 protected:
66   /*! @brief set attributes for drawing the anchor text element.
67    *
68    * @param list
69    */
70   virtual void set_attributes(Pango::AttrList& list) const;
71
72 private:
73   virtual Anchor* do_clone() const { return new Anchor(*this); }
74
75 protected:
76   /*! @brief hyper reference */
77   const Glib::ustring href_;
78 };
79
80
81 } // namespace text_element
82
83 } // namespace dialektos
84
85
86 #endif