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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#------------------------------------------------------------------------------
#
# Copyright (c) 2008, Enthought, Inc.
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in enthought/LICENSE.txt and may be redistributed only
# under the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
#
# Author: David C. Morrill
# Date: 10/21/2004
#
#------------------------------------------------------------------------------
""" Defines the instance editor factory for all traits user interface
toolkits.
"""
#-------------------------------------------------------------------------------
# Imports:
#-------------------------------------------------------------------------------
from __future__ import absolute_import
from traits.api import Str, List, Enum, Unicode, Type, Bool
from ..view import View, AKind
from ..ui_traits import AView
from ..instance_choice import InstanceChoice, InstanceChoiceItem
from ..editor_factory import EditorFactory
#-------------------------------------------------------------------------------
# 'ToolkitEditorFactory' class:
#-------------------------------------------------------------------------------
class ToolkitEditorFactory ( EditorFactory ):
""" Editor factory for instance editors.
"""
#---------------------------------------------------------------------------
# Trait definitions:
#---------------------------------------------------------------------------
# List of items describing the types of selectable or editable instances
values = List( InstanceChoiceItem )
# Extended name of the context object trait containing the list of types of
# selectable or editable instances
name = Str
# Is the current value of the object trait editable (vs. merely selectable)?
editable = Bool(True)
# Should the object trait value be selectable from a list of objects (a
# value of True forces a selection list to be displayed, while a value of
# False displays a selection list only if at least one object in the list
# of possible object values is selectable):
selectable = Bool( False )
# Should the editor support drag and drop of objects to set the trait value
# (a value of True forces the editor to allow drag and drop, while a value
# of False only supports drag and drop if at least one item in the list of
# possible objects supports drag and drop):
droppable = Bool( False )
# Should factory-created objects be cached?
cachable = Bool(True)
# Optional label for button
label = Unicode
# Optional instance view to use
view = AView
# Extended name of the context object trait containing the view, or name of
# the view, to use
view_name = Str
# The ID to use with the view
id = Str
# Kind of pop-up editor (live, modal, nonmodal, wizard)
kind = AKind
# The orientation of the instance editor relative to the instance selector
orientation = Enum( 'default', 'horizontal', 'vertical' )
# The default adapter class used to create InstanceChoice compatible
# adapters for instance objects:
adapter = Type( InstanceChoice, allow_none = False )
#---------------------------------------------------------------------------
# Traits view definitions:
#---------------------------------------------------------------------------
traits_view = View( [ [ 'label{Button label}',
'view{View name}', '|[]' ],
[ 'kind@', '|[Pop-up editor style]<>' ] ] )
# Define the InstanceEditor class.
InstanceEditor = ToolkitEditorFactory
### EOF #######################################################################
|