Merge branch 'master' of git+ssh://git.codethink.co.uk/git/atspi-dbus
[platform/core/uifw/at-spi2-atk.git] / pyatspi / constants.py
1 #Copyright (C) 2008 Codethink Ltd
2 #copyright: Copyright (c) 2005, 2007 IBM Corporation
3
4 #This library is free software; you can redistribute it and/or
5 #modify it under the terms of the GNU Lesser General Public
6 #License version 2 as published by the Free Software Foundation.
7
8 #This program is distributed in the hope that it will be useful,
9 #but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #GNU General Public License for more details.
12 #You should have received a copy of the GNU Lesser General Public License
13 #along with this program; if not, write to the Free Software
14 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
16 #Portions of this code originally licensed and copyright (c) 2005, 2007
17 #IBM Corporation under the BSD license, available at
18 #U{http://www.opensource.org/licenses/bsd-license.php}
19
20 #authors: Peter Parente, Mark Doffman
21
22 # Constants used in the Component interface to get screen coordinates
23 DESKTOP_COORDS = 0
24 WINDOW_COORDS = 1
25
26 # Constants used to synthesize mouse events
27 MOUSE_B1P = 'b1p'
28 MOUSE_B1R = 'b1r'
29 MOUSE_B1C = 'b1c'
30 MOUSE_B1D = 'b1d'
31 MOUSE_B2P = 'b2p'
32 MOUSE_B2R = 'b2r'
33 MOUSE_B2C = 'b2c'
34 MOUSE_B2D = 'b2d'
35 MOUSE_B3P = 'b3p'
36 MOUSE_B3R = 'b3r'
37 MOUSE_B3C = 'b3c'
38 MOUSE_B3D = 'b3d'
39 MOUSE_ABS = 'abs'
40 MOUSE_REL = 'rel'
41
42 # events that clear cached properties
43 CACHE_EVENTS = ['object:property-change:accessible-name',
44                 'object:property-change:accessible-description',
45                 'object:property-change:accessible-role',
46                 'object:property-change:accessible-parent']
47
48 # Dictionary used to correct the bug of not being able to register for all the
49 # subevents given only an AT-SPI event class (i.e. first part of the event
50 # name) keys are event names having subevents and values are the subevents
51 # under the key event; handlers *can* be registered for events not in this tree
52 EVENT_TREE = {
53   'terminal':
54     ['terminal:line-changed',
55      'terminal:columncount-changed',
56      'terminal:linecount-changed',
57      'terminal:application-changed',
58      'terminal:charwidth-changed'
59      ],
60   'document':
61     ['document:load-complete',
62      'document:reload',
63      'document:load-stopped',
64      'document:content-changed',
65      'document:attributes-changed'
66      ],
67   'object': 
68     ['object:property-change',
69      'object:bounds-changed',
70      'object:link-selected',
71      'object:state-changed',
72      'object:children-changed',
73      'object:visible-data-changed',
74      'object:selection-changed',
75      'object:model-changed',
76      'object:active-descendant-changed',
77      'object:row-inserted',
78      'object:row-reordered',
79      'object:row-deleted',
80      'object:column-inserted',
81      'object:column-reordered',
82      'object:column-deleted',
83      'object:text-bounds-changed',
84      'object:text-selection-changed',
85      'object:text-changed',
86      'object:text-attributes-changed',
87      'object:text-caret-moved',  
88      'object:attributes-changed'],
89   'object:text-changed' :
90     ['object:text-changed:insert',
91     'object:text-changed:delete'],
92   'object:property-change' :
93     ['object:property-change:accessible-parent', 
94     'object:property-change:accessible-name',
95     'object:property-change:accessible-description',
96     'object:property-change:accessible-value',
97     'object:property-change:accessible-role',
98     'object:property-change:accessible-table-caption',
99     'object:property-change:accessible-table-column-description',
100     'object:property-change:accessible-table-column-header',
101     'object:property-change:accessible-table-row-description',
102     'object:property-change:accessible-table-row-header',
103     'object:property-change:accessible-table-summary'],
104   'object:children-changed' :
105     ['object:children-changed:add',
106     'object:children-changed:remove'],
107   'object:state-changed' :
108     ['object:state-changed:'],
109   'mouse' :
110     ['mouse:abs',
111     'mouse:rel',
112     'mouse:button'],
113   'mouse:button' :
114     ['mouse:button:1p',
115     'mouse:button:1r',
116     'mouse:button:2p',
117     'mouse:button:2r',
118     'mouse:button:3p',
119     'mouse:button:3r'],
120   'window' :
121     ['window:minimize',
122     'window:maximize',
123     'window:restore',
124     'window:close',
125     'window:create',
126     'window:reparent',
127     'window:desktop-create',
128     'window:desktop-destroy',
129     'window:activate',
130     'window:deactivate',
131     'window:raise',
132     'window:lower',
133     'window:move',
134     'window:resize',
135     'window:shade',
136     'window:unshade',
137     'window:restyle'],
138   'focus' :
139     ['focus:']
140 }
141
142 import other
143
144 # Build a dictionary mapping state values to names based on the prefix of the
145 # enum constants.
146 STATE_VALUE_TO_NAME = dict(((value, name[6:].lower().replace('_', ' ')) 
147                             for name, value 
148                             in vars(other).items()
149                             if name.startswith('STATE_')))
150
151 # Build a dictionary mapping relation values to names based on the prefix of 
152 # the enum constants.
153 RELATION_VALUE_TO_NAME = dict(((value, name[9:].lower().replace('_', ' ')) 
154                                for name, value 
155                                in vars(other).items()
156                                if name.startswith('RELATION_')))
157
158 del other