1# (C) Copyright 2005-2020 Enthought, Inc., Austin, TX 2# All rights reserved. 3# 4# This software is provided without warranty under the terms of the BSD 5# license included in LICENSE.txt and may be redistributed only under 6# the conditions described in the aforementioned license. The license 7# is also available online at http://www.enthought.com/licenses/BSD.txt 8# 9# Thanks for using Enthought open source! 10 11""" The 'null' backend specific implementation of the tool bar manager. 12""" 13 14 15from traits.api import Bool, Enum, Instance, Tuple 16 17 18from pyface.image_cache import ImageCache 19from pyface.action.action_manager import ActionManager 20 21 22class ToolBarManager(ActionManager): 23 """ A tool bar manager realizes itself in errr, a tool bar control. """ 24 25 # 'ToolBarManager' interface ------------------------------------------- 26 27 # The size of tool images (width, height). 28 image_size = Tuple((16, 16)) 29 30 # The orientation of the toolbar. 31 orientation = Enum("horizontal", "vertical") 32 33 # Should we display the name of each tool bar tool under its image? 34 show_tool_names = Bool(True) 35 36 # Should we display the horizontal divider? 37 show_divider = Bool(True) 38 39 # Private interface ---------------------------------------------------- 40 41 # Cache of tool images (scaled to the appropriate size). 42 _image_cache = Instance(ImageCache) 43 44 # ------------------------------------------------------------------------ 45 # 'object' interface. 46 # ------------------------------------------------------------------------ 47 48 def __init__(self, *args, **traits): 49 """ Creates a new tool bar manager. """ 50 51 # Base class contructor. 52 super(ToolBarManager, self).__init__(*args, **traits) 53 54 # An image cache to make sure that we only load each image used in the 55 # tool bar exactly once. 56 self._image_cache = ImageCache(self.image_size[0], self.image_size[1]) 57 58 return 59 60 # ------------------------------------------------------------------------ 61 # 'ToolBarManager' interface. 62 # ------------------------------------------------------------------------ 63 64 def create_tool_bar(self, parent, controller=None): 65 """ Creates a tool bar. """ 66 67 # If a controller is required it can either be set as a trait on the 68 # tool bar manager (the trait is part of the 'ActionManager' API), or 69 # passed in here (if one is passed in here it takes precedence over the 70 # trait). 71 if controller is None: 72 controller = self.controller 73 74 return None 75