1# -------------------------------------------------------------------------
2#
3#  Copyright (c) 2007-19, Enthought, Inc.
4#  All rights reserved.
5#
6#  This software is provided without warranty under the terms of the BSD
7#  license included in 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
10#
11#  Thanks for using Enthought open source!
12#
13#  Author: David C. Morrill
14#  Date:   07/14/2007
15#
16# -------------------------------------------------------------------------
17
18""" Defines the theme style information for a DockWindow and its components.
19"""
20
21from pyface.ui_traits import Image
22from traits.api import HasPrivateTraits, Bool, Property, cached_property
23
24from .ui_traits import ATheme
25
26
27class DockWindowTheme(HasPrivateTraits):
28    """ Defines the theme style information for a DockWindow and its components.
29    """
30
31    # -- Public Trait Definitions ---------------------------------------------
32
33    #: Use the theme background color as the DockWindow background color?
34    use_theme_color = Bool(True)
35
36    #: Draw notebook tabs at the top (True) or the bottom (False)?
37    tabs_at_top = Bool(True)
38
39    #: Active tab theme:
40    tab_active = ATheme
41
42    #: Inactive tab theme:
43    tab_inactive = ATheme
44
45    #: Optional image to use for right edge of rightmost inactive tab:
46    tab_inactive_edge = Image
47
48    #: Tab hover theme (used for inactive tabs):
49    tab_hover = ATheme
50
51    #: Optional image to use for right edge of rightmost hover tab:
52    tab_hover_edge = Image
53
54    #: Tab background theme:
55    tab_background = ATheme
56
57    #: Tab theme:
58    tab = ATheme
59
60    #: Vertical splitter bar theme:
61    vertical_splitter = ATheme
62
63    #: Horizontal splitter bar theme:
64    horizontal_splitter = ATheme
65
66    #: Vertical drag bar theme:
67    vertical_drag = ATheme
68
69    #: Horizontal drag bar theme:
70    horizontal_drag = ATheme
71
72    #: The bitmap for the 'tab_inactive_edge' image:
73    tab_inactive_edge_bitmap = Property(depends_on="tab_inactive_edge")
74
75    #: The bitmap for the 'tab_hover_edge' image:
76    tab_hover_edge_bitmap = Property(depends_on="tab_hover_edge")
77
78    # -- Property Implementations ---------------------------------------------
79
80    @cached_property
81    def _get_tab_inactive_edge_bitmap(self):
82        image = self.tab_inactive_edge
83        if image is None:
84            return None
85
86        return image.create_bitmap()
87
88    @cached_property
89    def _get_tab_hover_edge_bitmap(self):
90        image = self.tab_hover_edge
91        if image is None:
92            return self.tab_inactive_edge_bitmap
93
94        return image.create_bitmap()
95
96
97# -------------------------------------------------------------------------
98#  Default theme handling
99# -------------------------------------------------------------------------
100
101#: The current default DockWindow theme
102_dock_window_theme = None
103
104
105def dock_window_theme(theme=None):
106    """ Get or set the default DockWindow theme.
107    """
108    global _dock_window_theme
109
110    if _dock_window_theme is None:
111        from .default_dock_window_theme import default_dock_window_theme
112
113        _dock_window_theme = default_dock_window_theme
114
115    old_theme = _dock_window_theme
116    if theme is not None:
117        _dock_window_theme = theme
118
119    return old_theme
120