~ubuntu-branches/ubuntu/vivid/python-chaco/vivid-proposed

« back to all changes in this revision

Viewing changes to enthought/chaco/legend.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-02-28 14:05:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100228140525-1eo43ddoakb2j3j9
Tags: 3.3.0-1
* New upstream release
* Switch to source format 3.0 (quilt)
* Bump Standards-Version to 3.8.4
* Remove transition package: python-enthought-chaco2

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
"""
4
4
from numpy import array, zeros_like
5
5
 
6
 
from enthought.enable.api import white_color_trait
 
6
from enthought.enable.api import black_color_trait, white_color_trait
7
7
from enthought.kiva import font_metrics_provider
8
8
from enthought.kiva.traits.kiva_font_trait import KivaFont
9
9
from enthought.traits.api import Any, Dict, Enum, Bool, HasTraits, Int, \
75
75
    # The border is visible (overrides Enable Component).
76
76
    border_visible = True
77
77
 
 
78
    # The color of the text labels
 
79
    color = black_color_trait
 
80
 
78
81
    # The background color of the legend (overrides AbstractOverlay).
79
82
    bgcolor = white_color_trait
80
83
 
202
205
        else:
203
206
            x = component.x
204
207
        self.outer_position = [x, y]
 
208
        
205
209
        if self.clip_to_component:
206
210
            c = self.component
207
211
            gc.save_state()
208
 
            gc.clip_to_rect(c.x, c.y, c.width, c.height)
209
 
        PlotComponent._draw(self, gc, view_bounds, mode)
210
 
        if self.clip_to_component:
211
 
            gc.restore_state()
 
212
            try:
 
213
                gc.clip_to_rect(c.x, c.y, c.width, c.height)
 
214
                PlotComponent._draw(self, gc, view_bounds, mode)
 
215
            finally:
 
216
                gc.restore_state()
 
217
        else:
 
218
            PlotComponent._draw(self, gc, view_bounds, mode)
 
219
            
 
220
            
212
221
        return
213
222
 
214
223
    # The following two methods implement the functionality of the Legend
249
258
 
250
259
        gc.save_state()
251
260
        try:
252
 
            gc.clip_to_rect(self.x, self.y, self.width, self.height)
 
261
            gc.clip_to_rect(int(self.x), int(self.y), 
 
262
                            int(self.width), int(self.height))
253
263
            edge_space = self.border_width + self.border_padding
254
264
            icon_width, icon_height = self.icon_bounds
255
265
 
446
456
        """ Returns a new Label instance for the given text.  Subclasses can
447
457
        override this method to customize the creation of labels.
448
458
        """
449
 
        return Label(text=text, font=self.font, margin=0, bgcolor="transparent",
450
 
                     border_width=0)
 
459
        return Label(text=text, font=self.font, margin=0, color=self.color_,
 
460
                     bgcolor="transparent", border_width=0)
451
461
 
452
462
    def _composite_icon_renderer_default(self):
453
463
        return CompositeIconRenderer()
460
470
                    "position", "position_items", "bounds", "bounds_items",
461
471
                    "label_at_top"):
462
472
            self._layout_needed = True
 
473
        if name == "color":
 
474
            self.get_preferred_size()
463
475
        return
464
476
 
465
477