1 '''
2 Defines L{AccAdapt.Adapter}s for AT-SPI accessibles implementing the List
3 interface for the Gecko toolkit only.
4
5 @author: Scott Haeger
6 @author: Peter Parente
7 @organization: IBM Corporation
8 @copyright: Copyright (c) 2005, 2007 IBM Corporation
9 @license: The BSD License
10
11 All rights reserved. This program and the accompanying materials are made
12 available under the terms of the BSD license which accompanies
13 this distribution, and is available at
14 U{http://www.opensource.org/licenses/bsd-license.php}
15 '''
16 from POR import POR
17 from AEEvent import *
18 from AEInterfaces import *
19 from DefaultEventHandler import DefaultEventHandlerAdapter
20
21 from pyLinAcc import Constants, Interfaces
22 import pyLinAcc, AEConstants
23 from i18n import _
24
25
26
28 '''
29 Overrides L{DefaultEventHandlerAdapter} to fire L{AEEvent.FocusChange}
30 events on focus changes for list controls. Also, fires a
31 L{AEEvent.SelectorChange} event for the first selected list item one
32 is present. Expects the subject to be a L{pyLinAcc.Accessible}.
33 '''
34 provides = [IEventHandler]
35
36 @staticmethod
38 '''
39 Tests if the given subject can be adapted by this class.
40
41 @param subject: Accessible to test
42 @type subject: L{pyLinAcc.Accessible}
43 @return: True when the subject meets the condition named in the docstring
44 for this class, False otherwise
45 @rtype: boolean
46 '''
47 attrs = subject.getAttributes()
48 return ('tag:SELECT' in attrs and \
49 subject.getApplication().toolkitName == 'Gecko')
50
52 '''
53 Creates an L{AEEvent.FocusChange} indicating that the accessible being
54 adapted has gained the focus. Also, creates a L{AEEvent.SelectorChange}
55 for the first selected item.
56
57 @param event: Raw focus change event
58 @type event: L{pyLinAcc.Event.Event}
59 @param kwargs: Parameters to be passed to any created L{AEEvent}
60 @type kwargs: dictionary
61 @return: L{AEEvent.FocusChange} and L{AEEvent.CaretChange}
62 @rtype: tuple of L{AEEvent}
63 '''
64 events = []
65
66 por = POR(self.subject, None, 0)
67 kwargs['focused'] = True
68 events.append(FocusChange(por, True, **kwargs))
69
70 s = Interfaces.ISelection(self.subject)
71 if s.nSelectedChildren > 0:
72 listitem = s.getSelectedChild(0)
73
74 por = POR(listitem, None, 0)
75 listitemtext = IAccessibleInfo(por).getAccItemText()
76 events.append(SelectorChange(por, listitemtext, **kwargs))
77 return events
78