| Trees | Indices | Help |
|
|---|
|
|
1 '''
2 Defines an L{AEEvent} indicating the view has been updated by the
3 L{AEViewManager}.
4
5 @author: Peter Parente
6 @author: Pete Brunet
7 @organization: IBM Corporation
8 @copyright: Copyright (c) 2005, 2007 IBM Corporation
9 @license: The BSD License
10
11 @author: Frank Zenker
12 @author: Ramona Bunk
13 @organization: IT Science Center Ruegen gGmbH, Germany
14 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
15 @license: The BSD License
16
17 All rights reserved. This program and the accompanying materials are made
18 available under the terms of the BSD license which accompanies
19 this distribution, and is available at
20 U{http://www.opensource.org/licenses/bsd-license.php}
21 '''
22
23 import AccessEngine
24 import Base
25 from AccessEngine import AEConstants
26 from AccessEngine.AEAccInterfaces import *
27
29 '''
30 Event that fires when the L{AEViewManager} is creating or updating its view.
31
32 This class registers its name and whether it should be monitored by default
33 in an L{AEMonitor} using the L{Base.registerEventType} function when
34 this module is first imported. An L{AEMonitor} can use this information to
35 build its menus.
36
37 @ivar gained: Type of view change
38 @type gained: boolean
39 @ivar title: Name of the root element of the new view (e.g. title of the
40 foreground window)
41 @type title: string
42 '''
43 Base.registerEventType('ViewChange', True)
45 '''
46 Stores the type of view change and intializes the title attribute to
47 an empty string.
48
49 @param por: Point-of-regard to the accessible at the root of the new view
50 @type por: L{AEPor <AEPor.AEPor>}
51 @param gained: Type of view change
52 @type gained: integer
53 '''
54 focused = gained in (AEConstants.EVENT_VIEW_GAINED,
55 AEConstants.EVENT_VIEW_FIRST_GAINED)
56 Base.AEEvent.__init__(self, focused=focused, **kwargs)
57 self.por = por
58 self.gained = gained
59 self.title = ''
60
62 '''
63 Returns a human readable representation of this event including its name,
64 its L{AEPor <AEPor.AEPor>}, its type, and the title of the new view.
65
66 @return: Information about this event
67 @rtype: string
68 '''
69 name = Base.AEEvent.__str__(self)
70 if self.gained == AEConstants.EVENT_VIEW_GAINED:
71 action = 'gained'
72 elif self.gained == AEConstants.EVENT_VIEW_LOST:
73 action = 'lost'
74 elif self.gained == AEConstants.EVENT_VIEW_FIRST_GAINED:
75 action = 'first gained'
76 elif self.gained == AEConstants.EVENT_VIEW_STARTUP:
77 action = 'startup'
78 return '%s:\n\tPOR: %s\n\ttitle: %s\n\taction: %s' % (name, self.por,
79 self.title, action)
80
82 '''
83 Stores the name of the root element of the new view in the title
84 attribute. Calls L{AETierManager._AETierManager}.switchAETier to switch to
85 the appropriate L{AETier} for this view. Calls
86 L{AETierManager._AETierManager}.manageEvent to allow it to dispatch this
87 L{AEEvent} to the active L{AETier} and its registered
88 L{AEScript <AEScript.AEScript>}.
89
90 @return: True to indicate the event executed properly
91 @rtype: boolean
92 '''
93 # get the accessible name of the root element
94 ai = IAccessibleInfo(self.por)
95 try:
96 self.title = ai.getAccName()
97 except LookupError:
98 # view is dead
99 return True
100 if self.gained in (AEConstants.EVENT_VIEW_GAINED,
101 AEConstants.EVENT_VIEW_FIRST_GAINED):
102 # get information about the accessible's application
103 try:
104 aid = ai.getAccAppID()
105 aname = ai.getAccAppName()
106 except LookupError:
107 # view is dead
108 return True
109 # inform the view manager of the AE view change
110 AccessEngine.AEViewManager.setAEView(self.por)
111 # ask the tier manager to switch tiers first
112 AccessEngine.AETierManager.switchAETier(aname, aid, self.por)
113 elif self.gained == AEConstants.EVENT_VIEW_LOST:
114 if self.por == AccessEngine.AEViewManager.getAEView():
115 # only unset if the view being deactivated is still the active view
116 AccessEngine.AEViewManager.setAEView(None)
117 # then process the view change event
118 AccessEngine.AETierManager.manageEvent(self)
119 return True
120
122 '''
123 Fetches data out of this L{ViewChange} for use by a
124 L{AEScript.EventScript.onViewChange}-Task.
125
126 @return: Dictionary of parameters to be passed to a
127 L{AEScript.EventScript.onViewChange}-Task as follows:
128 - por: Point of regard to the top of the new view
129 - title: String containing the window title of the view which changed
130 - gained: The type of view change, indicated by one of the integer
131 class variables
132 @rtype: dictionary
133 '''
134 return {'title':self.title, 'gained':self.gained, 'por':self.getPOR()}
135
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Mon Jun 30 13:06:04 2008 | http://epydoc.sourceforge.net |