File: container_overlay.py

package info (click to toggle)
python-chaco 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,144 kB
  • sloc: python: 35,936; ansic: 1,211; cpp: 241; makefile: 124; sh: 5
file content (41 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Plot overlay which is an Enable Container

This module provides an Enable Container subclass which renders itself
into the overlay of a plot.  This allows the easy use of standard Enable
components in plot overlays.
"""

from traits.api import Instance
from enable.api import Container, Component
from chaco.api import PlotComponent


class ContainerOverlay(Container, PlotComponent):
    """ Container which is also a Chaco plot overlay

    Since this is an Enable container, any Components that it contains will
    be rendered into the overlay layer of the plot.
    """
    # XXX this works, but I'm not sure that it's quite right.

    # The component that this object overlays. This can be None. By default, if
    # this object is called to draw(), it tries to render onto this component.
    component = Instance(Component)

    draw_layer = "overlay"

    # The background color (overrides PlotComponent).
    # Typically, an overlay does not render a background.
    bgcolor = "transparent"

    unified_draw = True

    auto_size = True

    def overlay(self, other, gc, view_bounds, mode):
        self.draw(gc, view_bounds, mode)

    def _request_redraw(self):
        if self.component is not None:
            self.component.request_redraw()
        super(ContainerOverlay, self)._request_redraw()