6e7332f6c6390344654bd9c68fa2edc1e217d32d
[platform/core/uifw/at-spi2-atk.git] / pyatspi / hypertext.py
1 #Copyright (C) 2008 Codethink Ltd
2
3 #This library is free software; you can redistribute it and/or
4 #modify it under the terms of the GNU Lesser General Public
5 #License version 2 as published by the Free Software Foundation.
6
7 #This program is distributed in the hope that it will be useful,
8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 #GNU General Public License for more details.
11 #You should have received a copy of the GNU Lesser General Public License
12 #along with this program; if not, write to the Free Software
13 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14
15 from interfaces import *
16 from accessible import Accessible
17 from factory import accessible_factory
18
19 __all__ = [
20            "Hypertext",
21           ]
22
23 #------------------------------------------------------------------------------
24
25 class Hypertext(Accessible):
26         """
27         An interface used for objects which implement linking between
28         multiple resource or content locations, or multiple 'markers'
29         within a single document. A Hypertext instance is associated
30         with one or more Hyperlinks, which are associated with particular
31         offsets within the Hypertext's included content.
32         """
33
34         def getLink(self, index):
35                 """
36                 Get one of the Hyperlinks associated with this Hypertext object,
37                 by index.
38                 @param : linkIndex
39                 an integer from 0 to getNLinks() - 1. 
40                 @return the Hyperlink in this Hypertext object.
41                 """
42                 func = self.get_dbus_method("getLink", dbus_interface=ATSPI_HYPERTEXT)
43                 return self._cache.create_accessible(self._app_name, func(index),
44                                                      interfaces.ATSPI_HYPERTEXT)
45
46         def getLinkIndex(self, character_index):
47                 """
48                 Get the hyperlink index, if any, associated with a particular
49                 character offset in the Hypertext object. For Hypertext implementors
50                 without textual content, all hyperlinks are associated with character
51                 offset '0'.
52                 @return the index of the Hyperlink associated with character
53                 offset characterIndex, or -1 if no Hyperlink is associated with
54                 that character offset.
55                 """
56                 func = self.get_dbus_method("getLinkIndex", dbus_interface=ATSPI_HYPERTEXT)
57                 return func(character_index)
58
59         def getNLinks(self):
60                 """
61                 Query the hypertext object for the number of Hyperlinks it contains.
62                 @return the number of Hyperlinks associated with this Hypertext
63                 object, as a long integer.
64                 """
65                 func = self.get_dbus_method("getNLinks", dbus_interface=ATSPI_HYPERTEXT)
66                 return func()
67
68 # Register the accessible class with the factory.
69 accessible_factory.register_accessible_class(ATSPI_HYPERTEXT, Hypertext)
70
71 #END----------------------------------------------------------------------------