1 '''
2 Defines the base class for all L{Task}s.
3
4 @author: Peter Parente
5 @organization: IBM Corporation
6 @copyright: Copyright (c) 2005, 2007 IBM Corporation
7 @license: The BSD License
8
9 All rights reserved. This program and the accompanying materials are made
10 available under the terms of the BSD license which accompanies
11 this distribution, and is available at
12 U{http://www.opensource.org/licenses/bsd-license.php}
13 '''
14 import Base
15
17 '''
18 Base class for all L{Task}s that execute in response to L{AEEvent}s.
19
20 The focus, tier, and background parameters specify on which layer
21 the L{Task} will handle events. If focus is True, the L{Task} will be
22 executed in response to an event from a focused control within this L{Tier}.
23 If tier is True, the L{Task} will be executed in response to an event from an
24 unfocused control within this L{Tier}. If background is True, the L{Task}
25 will be executed in response to an event from any control within the tier
26 when the L{Tier} is not active.
27
28 The three layers are mutually exclusive. You may set any combination of
29 focus, tier, and background to True to register the given L{Task} on each
30 selected layer in one call. If all three parameters are False, the
31 registration defaults to the focus layer.
32
33 @ivar layers: Execute on focused events, unfocused events when the L{Tier}
34 is active, and/or events when the L{Tier} is inactive?
35 @type layers: 3-tuple of boolean
36 '''
37 - def __init__(self, ident, focus=False, tier=False, background=False,
38 all=False):
39 '''
40 Stores layer information.
41
42 @param ident: Programmatic identifier
43 @type ident: string
44 @param focus: Execute for events in focus?
45 @type focus: boolean
46 @param tier: Execute for unfocused events when the L{Tier} is active?
47 @type tier: boolean
48 @param background: Execute for events when the L{Tier} is inactive?
49 @type background: boolean
50 '''
51 Base.Task.__init__(self, ident)
52 if all:
53 self.layers = (True, True, True)
54 else:
55 self.layers = (focus, tier, background)
56
58 '''
59 @return: Type of event this L{Task} wants to handle
60 @rtype: L{AEEvent} class
61 @raise NotImplementedError: When a subclass does not define the type of
62 L{AEEvent} it wants to handle
63 '''
64 raise NotImplementedError
65
67 '''
68 @return: Event layer information
69 @rtype: 3-tuple of boolean
70 '''
71 return self.layers
72