1
#------------------------------------------------------------------------------
3
# Copyright (c) 2006, Enthought, Inc.
6
# This software is provided without warranty under the terms of the BSD
7
# license included in enthought/LICENSE.txt and may be redistributed only
8
# under the conditions described in the aforementioned license. The license
9
# is also available online at http://www.enthought.com/licenses/BSD.txt
11
# Thanks for using Enthought open source!
16
#------------------------------------------------------------------------------
18
""" Defines the table column descriptor used for toggleable columns.
21
#-------------------------------------------------------------------------------
23
#-------------------------------------------------------------------------------
25
from __future__ import absolute_import
27
from traits.etsconfig.api import ETSConfig
29
from ..table_column import ObjectColumn
31
if ETSConfig.toolkit == 'wx':
32
from pyface.ui.wx.grid.checkbox_renderer import CheckboxRenderer
33
elif ETSConfig.toolkit == 'qt4':
34
from ..qt4.extra.checkbox_renderer import CheckboxRenderer
36
raise NotImplementedError, "No checkbox renderer for backend"
38
#-------------------------------------------------------------------------------
39
# 'CheckboxColumn' class:
40
#-------------------------------------------------------------------------------
42
class CheckboxColumn ( ObjectColumn ):
44
#---------------------------------------------------------------------------
45
# Initializes the object:
46
#---------------------------------------------------------------------------
48
def __init__ ( self, **traits ):
49
""" Initializes the object.
51
super( CheckboxColumn, self ).__init__( **traits )
53
# force the renderer to be a checkbox renderer
54
self.renderer = CheckboxRenderer()
56
#---------------------------------------------------------------------------
57
# Returns the cell background color for the column for a specified object:
58
#---------------------------------------------------------------------------
60
def get_cell_color ( self, object ):
61
""" Returns the cell background color for the column for a specified
65
# Override the parent class to ALWAYS provide the standard color:
66
return self.cell_color_
68
#---------------------------------------------------------------------------
69
# Returns whether the column is editable for a specified object:
70
#---------------------------------------------------------------------------
72
def is_editable ( self, object ):
73
""" Returns whether the column is editable for a specified object.
76
# Although a checkbox column is always editable, we return this
77
# to keep a standard editor from appearing. The editing is handled
78
# in the renderer's handlers.