1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.HypertextT;
26 
27 public  import atk.Hyperlink;
28 public  import gobject.ObjectG;
29 public  import gobject.Signals;
30 public  import gtkc.atk;
31 public  import gtkc.atktypes;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * An interface used for objects which implement linking between
37  * multiple resource or content locations, or multiple 'markers'
38  * within a single document.  A Hypertext instance is associated with
39  * one or more Hyperlinks, which are associated with particular
40  * offsets within the Hypertext's included content.  While this
41  * interface is derived from Text, there is no requirement that
42  * Hypertext instances have textual content; they may implement Image
43  * as well, and Hyperlinks need not have non-zero text offsets.
44  */
45 public template HypertextT(TStruct)
46 {
47 	/** Get the main Gtk struct */
48 	public AtkHypertext* getHypertextStruct()
49 	{
50 		return cast(AtkHypertext*)getStruct();
51 	}
52 
53 
54 	/**
55 	 * Gets the link in this hypertext document at index
56 	 * @link_index
57 	 *
58 	 * Params:
59 	 *     linkIndex = an integer specifying the desired link
60 	 *
61 	 * Return: the link in this hypertext document at
62 	 *     index @link_index
63 	 */
64 	public Hyperlink getLink(int linkIndex)
65 	{
66 		auto p = atk_hypertext_get_link(getHypertextStruct(), linkIndex);
67 		
68 		if(p is null)
69 		{
70 			return null;
71 		}
72 		
73 		return ObjectG.getDObject!(Hyperlink)(cast(AtkHyperlink*) p);
74 	}
75 
76 	/**
77 	 * Gets the index into the array of hyperlinks that is associated with
78 	 * the character specified by @char_index.
79 	 *
80 	 * Params:
81 	 *     charIndex = a character index
82 	 *
83 	 * Return: an index into the array of hyperlinks in @hypertext,
84 	 *     or -1 if there is no hyperlink associated with this character.
85 	 */
86 	public int getLinkIndex(int charIndex)
87 	{
88 		return atk_hypertext_get_link_index(getHypertextStruct(), charIndex);
89 	}
90 
91 	/**
92 	 * Gets the number of links within this hypertext document.
93 	 *
94 	 * Return: the number of links within this hypertext document
95 	 */
96 	public int getNLinks()
97 	{
98 		return atk_hypertext_get_n_links(getHypertextStruct());
99 	}
100 
101 	int[string] connectedSignals;
102 
103 	void delegate(int, HypertextIF)[] _onLinkSelectedListeners;
104 	@property void delegate(int, HypertextIF)[] onLinkSelectedListeners()
105 	{
106 		return _onLinkSelectedListeners;
107 	}
108 	/**
109 	 * The "link-selected" signal is emitted by an AtkHyperText
110 	 * object when one of the hyperlinks associated with the object
111 	 * is selected.
112 	 *
113 	 * Params:
114 	 *     arg1 = the index of the hyperlink which is selected
115 	 */
116 	void addOnLinkSelected(void delegate(int, HypertextIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
117 	{
118 		if ( "link-selected" !in connectedSignals )
119 		{
120 			Signals.connectData(
121 				this,
122 				"link-selected",
123 				cast(GCallback)&callBackLinkSelected,
124 				cast(void*)cast(HypertextIF)this,
125 				null,
126 				connectFlags);
127 			connectedSignals["link-selected"] = 1;
128 		}
129 		_onLinkSelectedListeners ~= dlg;
130 	}
131 	extern(C) static void callBackLinkSelected(AtkHypertext* hypertextStruct, int arg1, HypertextIF _hypertext)
132 	{
133 		foreach ( void delegate(int, HypertextIF) dlg; _hypertext.onLinkSelectedListeners )
134 		{
135 			dlg(arg1, _hypertext);
136 		}
137 	}
138 }