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.Hyperlink; 26 27 private import atk.ActionIF; 28 private import atk.ActionT; 29 private import atk.ObjectAtk; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtkc.atk; 34 public import gtkc.atktypes; 35 public import gtkc.gdktypes; 36 37 38 /** 39 * An ATK object which encapsulates a link or set of links (for 40 * instance in the case of client-side image maps) in a hypertext 41 * document. It may implement the AtkAction interface. AtkHyperlink 42 * may also be used to refer to inline embedded content, since it 43 * allows specification of a start and end offset within the host 44 * AtkHypertext object. 45 */ 46 public class Hyperlink : ObjectG, ActionIF 47 { 48 /** the main Gtk struct */ 49 protected AtkHyperlink* atkHyperlink; 50 51 /** Get the main Gtk struct */ 52 public AtkHyperlink* getHyperlinkStruct() 53 { 54 return atkHyperlink; 55 } 56 57 /** the main Gtk struct as a void* */ 58 protected override void* getStruct() 59 { 60 return cast(void*)atkHyperlink; 61 } 62 63 protected override void setStruct(GObject* obj) 64 { 65 atkHyperlink = cast(AtkHyperlink*)obj; 66 super.setStruct(obj); 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (AtkHyperlink* atkHyperlink, bool ownedRef = false) 73 { 74 this.atkHyperlink = atkHyperlink; 75 super(cast(GObject*)atkHyperlink, ownedRef); 76 } 77 78 // add the Action capabilities 79 mixin ActionT!(AtkHyperlink); 80 81 82 /** */ 83 public static GType getType() 84 { 85 return atk_hyperlink_get_type(); 86 } 87 88 /** 89 * Gets the index with the hypertext document at which this link ends. 90 * 91 * Return: the index with the hypertext document at which this link ends 92 */ 93 public int getEndIndex() 94 { 95 return atk_hyperlink_get_end_index(atkHyperlink); 96 } 97 98 /** 99 * Gets the number of anchors associated with this hyperlink. 100 * 101 * Return: the number of anchors associated with this hyperlink 102 */ 103 public int getNAnchors() 104 { 105 return atk_hyperlink_get_n_anchors(atkHyperlink); 106 } 107 108 /** 109 * Returns the item associated with this hyperlinks nth anchor. 110 * For instance, the returned #AtkObject will implement #AtkText 111 * if @link_ is a text hyperlink, #AtkImage if @link_ is an image 112 * hyperlink etc. 113 * 114 * Multiple anchors are primarily used by client-side image maps. 115 * 116 * Params: 117 * i = a (zero-index) integer specifying the desired anchor 118 * 119 * Return: an #AtkObject associated with this hyperlinks 120 * i-th anchor 121 */ 122 public ObjectAtk getObject(int i) 123 { 124 auto p = atk_hyperlink_get_object(atkHyperlink, i); 125 126 if(p is null) 127 { 128 return null; 129 } 130 131 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 132 } 133 134 /** 135 * Gets the index with the hypertext document at which this link begins. 136 * 137 * Return: the index with the hypertext document at which this link begins 138 */ 139 public int getStartIndex() 140 { 141 return atk_hyperlink_get_start_index(atkHyperlink); 142 } 143 144 /** 145 * Get a the URI associated with the anchor specified 146 * by @i of @link_. 147 * 148 * Multiple anchors are primarily used by client-side image maps. 149 * 150 * Params: 151 * i = a (zero-index) integer specifying the desired anchor 152 * 153 * Return: a string specifying the URI 154 */ 155 public string getUri(int i) 156 { 157 auto retStr = atk_hyperlink_get_uri(atkHyperlink, i); 158 159 scope(exit) Str.freeString(retStr); 160 return Str.toString(retStr); 161 } 162 163 /** 164 * Indicates whether the link currently displays some or all of its 165 * content inline. Ordinary HTML links will usually return 166 * %FALSE, but an inline <src> HTML element will return 167 * %TRUE. 168 * 169 * Return: whether or not this link displays its content inline. 170 */ 171 public bool isInline() 172 { 173 return atk_hyperlink_is_inline(atkHyperlink) != 0; 174 } 175 176 /** 177 * Determines whether this AtkHyperlink is selected 178 * 179 * Deprecated: Please use ATK_STATE_FOCUSABLE for all links, 180 * and ATK_STATE_FOCUSED for focused links. 181 * 182 * Return: True if the AtkHyperlink is selected, False otherwise 183 * 184 * Since: 1.4 185 */ 186 public bool isSelectedLink() 187 { 188 return atk_hyperlink_is_selected_link(atkHyperlink) != 0; 189 } 190 191 /** 192 * Since the document that a link is associated with may have changed 193 * this method returns %TRUE if the link is still valid (with 194 * respect to the document it references) and %FALSE otherwise. 195 * 196 * Return: whether or not this link is still valid 197 */ 198 public bool isValid() 199 { 200 return atk_hyperlink_is_valid(atkHyperlink) != 0; 201 } 202 203 int[string] connectedSignals; 204 205 void delegate(Hyperlink)[] onLinkActivatedListeners; 206 /** 207 * The signal link-activated is emitted when a link is activated. 208 */ 209 void addOnLinkActivated(void delegate(Hyperlink) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 210 { 211 if ( "link-activated" !in connectedSignals ) 212 { 213 Signals.connectData( 214 this, 215 "link-activated", 216 cast(GCallback)&callBackLinkActivated, 217 cast(void*)this, 218 null, 219 connectFlags); 220 connectedSignals["link-activated"] = 1; 221 } 222 onLinkActivatedListeners ~= dlg; 223 } 224 extern(C) static void callBackLinkActivated(AtkHyperlink* hyperlinkStruct, Hyperlink _hyperlink) 225 { 226 foreach ( void delegate(Hyperlink) dlg; _hyperlink.onLinkActivatedListeners ) 227 { 228 dlg(_hyperlink); 229 } 230 } 231 }