1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Defines the default implementation of the ILayout interface."""
17
18 from muntjac.ui.layout import ILayout, IMarginHandler, MarginInfo
19 from muntjac.ui.abstract_component_container import AbstractComponentContainer
20 from muntjac.terminal.gwt.client.mouse_event_details import MouseEventDetails
21 from muntjac.terminal.gwt.client.event_id import EventId
22 from muntjac.event.layout_events import ILayoutClickNotifier, LayoutClickEvent
23
24
25 -class AbstractLayout(AbstractComponentContainer, ILayout, IMarginHandler):
26 """An abstract class that defines default implementation for the
27 L{ILayout} interface.
28
29 @author: Vaadin Ltd.
30 @author: Richard Lincoln
31 @version: 1.1.2
32 """
33
34 _CLICK_EVENT = EventId.LAYOUT_CLICK
35
40
41
43 nargs = len(args)
44 if nargs == 1:
45 if isinstance(args[0], MarginInfo):
46 marginInfo, = args
47 self.margins.setMargins(marginInfo)
48 self.requestRepaint()
49 else:
50 enabled, = args
51 self.margins.setMargins(enabled)
52 self.requestRepaint()
53 elif nargs == 4:
54 topEnabled, rightEnabled, bottomEnabled, leftEnabled = args
55 self.margins.setMargins(topEnabled, rightEnabled,
56 bottomEnabled, leftEnabled)
57 self.requestRepaint()
58 else:
59 raise ValueError, 'invalid number of arguments'
60
61
64
65
66 - def paintContent(self, target):
67
68 target.addAttribute('margins', int( self.margins.getBitMask() ))
69
70
77
78
80 """Fire a layout click event.
81
82 Note that this method is only used by the subclasses that
83 implement L{LayoutClickNotifier}, and can be overridden
84 for custom click event firing.
85
86 @param parameters:
87 The parameters received from the client side
88 implementation
89 """
90 mouseDetails = MouseEventDetails.deSerialize(
91 parameters.get('mouseDetails'))
92
93 clickedComponent = parameters.get('component')
94
95 childComponent = clickedComponent
96 while (childComponent is not None
97 and childComponent.getParent() != self):
98 childComponent = childComponent.getParent()
99
100 self.fireEvent(LayoutClickEvent(self, mouseDetails,
101 clickedComponent, childComponent))
102