2008-12-17 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / pyatspi / image.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 import dbus
16 from interfaces import *
17 from accessible import Accessible
18 from factory import accessible_factory
19 from accessible import BoundingBox
20
21 __all__ = [
22            "Image",
23           ]
24
25 #------------------------------------------------------------------------------
26
27 class Image(Accessible):
28         """
29         An interface implemented by objects which render image data or
30         pictorial information to the screen. When onscreen components
31         include graphical information that is not purely intended to
32         enhance "3d effect" or visual layout, but which conveys some
33         semantic or informational content to the sighted user, they should
34         implement Image, and that semantic content should be conveyed
35         textually to the extent possible via the image description, as
36         well as the Accessible::name and Accessible::description properties.
37         """
38
39         def getImageExtents(self, coordType):
40                 """
41                 Obtain a bounding box which entirely contains the image contents,
42                 as displayed on screen. The bounds returned do not account for
43                 any viewport clipping or the fact that the image may be partially
44                 or wholly obscured by other onscreen content. 
45                 @param : coordType
46                 If 0, the returned bounding box position is returned relative
47                 to the screen; if 1, the bounding box position is returned relative
48                 to the containing window. 
49                 @return a BoundingBox enclosing the image's onscreen representation.
50                 """
51                 func = self.get_dbus_method("getImageExtents", dbus_interface=ATSPI_IMAGE)
52                 return BoundingBox(*func(dbus.Int16(coordType)))
53
54         def getImagePosition(self, *args, **kwargs):
55                 """
56                 Get the coordinates of the current image position on screen.
57                 @param : x
58                 Back-filled with the x coordinate of the onscreen image (i.e.
59                 the minimum x coordinate) 
60                 @param : y
61                 Back-filled with the y coordinate of the onscreen image (i.e.
62                 the minimum y coordinate) 
63                 @param : coordType
64                 If 0, the returned x and y coordinates are returned relative
65                 to the screen; if 1, they are returned relative to the containing
66                 window.
67                 """
68                 func = self.get_dbus_method("getImagePosition", dbus_interface=ATSPI_IMAGE)
69                 return func(*args, **kwargs)
70
71         def getImageSize(self, *args, **kwargs):
72                 """
73                 Obtain the width and height of the current onscreen view of the
74                 image. The extents returned do not account for any viewport clipping
75                 or the fact that the image may be partially or wholly obscured
76                 by other onscreen content. 
77                 @param : width
78                 Back-filled with the x extents of the onscreen image (i.e. the
79                 image width in pixels) 
80                 @param : height
81                 Back-filled with the y extents of the onscreen image (i.e. the
82                 image height in pixels)
83                 """
84                 func = self.get_dbus_method("getImageSize", dbus_interface=ATSPI_IMAGE)
85                 return func(*args, **kwargs)
86
87         def get_imageDescription(self):
88                 return self._pgetter(self._dbus_interface, "imageDescription")
89         def set_imageDescription(self, value):
90                 self._psetter(self._dbus_interface, "imageDescription", value)
91         _imageDescriptionDoc = \
92                 """
93                 A UTF-8 string providing a textual description of what is visually
94                 depicted in the image.
95                 """
96         imageDescription = property(fget=get_imageDescription, fset=set_imageDescription, doc=_imageDescriptionDoc)
97
98         def get_imageLocale(self):
99                 return self._pgetter(self._dbus_interface, "imageLocale")
100         def set_imageLocale(self, value):
101                 self._psetter(self._dbus_interface, "imageLocale", value)
102         _imageLocaleDoc = \
103                 """
104                 A string corresponding to the POSIX LC_MESSAGES locale used by
105                 the imageDescription.
106                 """
107         imageLocale = property(fget=get_imageLocale, fset=set_imageLocale, doc=_imageLocaleDoc)
108
109 # Register the accessible class with the factory.
110 accessible_factory.register_accessible_class(ATSPI_IMAGE, Image)
111
112 #END----------------------------------------------------------------------------