| Trees | Indices | Help |
|---|
|
|
1 '''
2 Defines an abstract base class for all input devices that serve double duty as
3 sources of input for LSR and for the rest of the operating system.
4
5 @author: Peter Parente
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
8 @license: The BSD License
9
10 All rights reserved. This program and the accompanying materials are made
11 available under the terms of the BSD license which accompanies
12 this distribution, and is available at
13 U{http://www.opensource.org/licenses/bsd-license.php}
14 '''
15 import Base, AEConstants
16
18 '''
19 Abstract base class for input devices that are used by both LSR and the OS.
20 Provides an interface for registering modifier actions that can be used to
21 indicate the start of commands intended for LSR. Also provides an interface
22 for registering filtered L{GestureList}s that indicate which combination of
23 L{Gesture}s should not be passed to other applications. The definition of what
24 constitues a valid L{Gesture} and L{GestureList} is left to a subclass. The
25 decision as to when registered L{Gesture}s are filtered or not is determined
26 by a mode managed in this class via L{getFilterMode} and L{setFilterMode}.
27
28 This class is abstract as some of the methods inherited from
29 L{Base.AEInput} are not overridden and raise NotImplementedError.
30
31 @ivar modifiers: Dictionary of action codes that are considered modifiers
32 @type modifiers: dictionary
33 @ivar filter_mode: Mode that determines which L{Gesture}s are filtered
34 @type filter_mode: integer
35 '''
37 '''
38 Initializes the filters to an empty list, the modifiers to an empty
39 dictionary, and the filtering mode to none.
40 '''
41 Base.AEInput.__init__(self)
42 self.modifiers = {}
43 self.filter_mode = AEConstants.FILTER_NONE
44
46 '''
47 @return: 'system input' as the only capability of this device.
48 @rtype: list of string
49 '''
50 return ['system input']
51
53 '''
54 Gets the current filter mode.
55
56 @return: Current filter mode
57 @rtype: integer
58 '''
59 return self.filter_mode
60
62 '''
63 Stores the current filter mode.
64
65 @param mode: Current filter mode
66 @type mode: integer
67 '''
68 self.filter_mode = mode
69
71 '''
72 Adds an action code to the modifiers dictionary to identify it as a modifier
73 for other actions.
74
75 @param code: Action code to register as a modifier
76 @type code: integer
77 '''
78 try:
79 self.modifiers[code] += 1
80 except KeyError:
81 self.modifiers[code] = 1
82
84 '''
85 Removes an action code from the modifiers dictionary if it is no longer
86 in use. Otherwise, it decrements the reference count.
87
88 @param code: Action code to unregister as a modifier
89 @type code: integer
90 '''
91 try:
92 self.modifiers[code] -= 1
93 if self.modifiers[code] <= 0:
94 del self.modifiers[code]
95 except KeyError:
96 pass
97
99 '''
100 Removes all modifiers by destroying the modifiers dictionary and recreating
101 it.
102 '''
103 self.modifiers = {}
104
106 '''
107 Abstact method. Adds a L{GestureList} as a filter to this device. A filter
108 typically indicates input that should be consumed and prevented from
109 reaching other applications. Exactly how the filter is stored and used is
110 determined by a subclass.
111
112 @param gestures: L{Gesture}s to possibly filter
113 @type gestures: L{GestureList}
114 @raise NotImplementedError: When this method is not overridden by a
115 subclass
116 '''
117 raise NotImplementedError
118
120 '''
121 Abstract method. Removes a L{GestureList} as a filter from this device.
122 A filter typically indicates input that should be consumed and prevented
123 from reaching other applications. How the filter is removed is determined
124 by a subclass.
125
126 @param gestures: L{Gesture}s to no longer filter
127 @type gestures: L{GestureList}
128 @raise NotImplementedError: When this method is not overridden by a
129 subclass
130 '''
131 raise NotImplementedError
132
134 '''
135 Abstract method. Removes all L{GestureList} filters from the device. How
136 the filters are removed is determined by a subclass. A filter typically
137 indicates input that should be consumed and prevented from reaching other
138 applications. Exactly How the filter is removed is determined by a
139 subclass.
140
141 @raise NotImplementedError: When this method is not overridden by a
142 subclass
143 '''
144 raise NotImplementedError
145
153
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Mon Jun 4 15:33:30 2007 | http://epydoc.sourceforge.net |