<commit_before>#-------------------------------------------------------------------------------
#
#  Copyright (c) 2005, 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: <NAME>
#  Date:   11/04/2005
#
#-------------------------------------------------------------------------------

""" Defines the DockWindowShell class used to house drag and drag DockWindow  
    items that are dropped on the desktop or on the DockWindowShell window.
"""    

#-------------------------------------------------------------------------------
#  Imports:  
#-------------------------------------------------------------------------------

import wx

# Fixme: Hack to force 'image_slice' to be added via Category to Theme class:
import enthought.traits.ui.wx

from enthought.traits.api \
    import HasPrivateTraits, Instance
    
from enthought.traits.ui.api \
    import View, Group
           
from enthought.pyface.image_resource \
    import ImageResource
    
from dock_window \
    import DockWindow
    
from dock_sizer \
    import DockSizer, DockSection, DockRegion, DockControl, DOCK_RIGHT
    
#-------------------------------------------------------------------------------
#  Constants:  
#-------------------------------------------------------------------------------
        
# Color used for background of windows (like dialog background color):
WindowColor = wx.Colour( 236, 233, 216 )

# DockWindowShell frame icon:
FrameIcon = ImageResource( 'shell.ico' )
    
#-------------------------------------------------------------------------------
#  'DockWindowShell' class:  
#-------------------------------------------------------------------------------

class DockWindowShell ( HasPrivateTraits ):
    
    #---------------------------------------------------------------------------
    #  Trait definitions:  
    #---------------------------------------------------------------------------
    
    # The wx.Frame window which is the actual shell:
    control = Instance( wx.Frame )
    
    #---------------------------------------------------------------------------
    #  Initializes the object:  
    #---------------------------------------------------------------------------
        
    def __init__ ( self, dock_control, use_mouse = False, **traits ):
        super( DockWindowShell, self ).__init__( **traits )
        
        old_control = dock_control.control
        parent      = wx.GetTopLevelParent( old_control )
        while True:
            next_parent = parent.GetParent()
            if next_parent is None:
                break
            parent = next_parent
            
        self.control = shell = wx.Frame( parent, -1, dock_control.name, 
                                         style = wx.DEFAULT_FRAME_STYLE   |
                                                 wx.FRAME_FLOAT_ON_PARENT | 
                                                 wx.FRAME_NO_TASKBAR ) 
        shell.SetIcon( FrameIcon.create_icon() )
        shell.SetBackgroundColour( WindowColor )
        wx.EVT_CLOSE( shell, self._on_close )
        
        theme = dock_control.theme
        self._dock_window = dw = DockWindow( shell, auto_close = True,
                                                    theme      = theme ).set(    
                                                    style      = 'tab' )
        sizer = wx.BoxSizer( wx.VERTICAL )
        sizer.Add( dw.control, 1, wx.EXPAND )
        shell.SetSizer( sizer )
        
        if use_mouse:
            x, y = wx.GetMousePosition()
        else:
            x, y = old_control.GetPositionTuple()
            x, y = old_control.GetParent().ClientToScreenXY( x, y )
            
        dx, dy = old_control.GetSize()
        tis    = theme.tab.image_slice
        tc     = theme.tab.content
        tdy    = theme.tab_active.image_slice.dy
        dx    += (tis.xleft + tc.left + tis.xright  + tc.right)
        dy    += (tis.xtop  + tc.top  + tis.xbottom + tc.bottom + tdy)
        
        self.add_control( dock_control )
            <commit_msg>changed to use system bg color<commit_after>#-------------------------------------------------------------------------------
#
#  Copyright (c) 2005, 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: <NAME>
#  Date:   11/04/2005
#
#-------------------------------------------------------------------------------

""" Defines the DockWindowShell class used to house drag and drag DockWindow  
    items that are dropped on the desktop or on the DockWindowShell window.
"""    

#-------------------------------------------------------------------------------
#  Imports:  
#-------------------------------------------------------------------------------

import wx

# Fixme: Hack to force 'image_slice' to be added via Category to Theme class:
import enthought.traits.ui.wx

from enthought.traits.api \
    import HasPrivateTraits, Instance
    
from enthought.traits.ui.api \
    import View, Group

from enthought.pyface.api import SystemMetrics

from enthought.pyface.image_resource \
    import ImageResource
    
from dock_window \
    import DockWindow
    
from dock_sizer \
    import DockSizer, DockSection, DockRegion, DockControl, DOCK_RIGHT
    
#-------------------------------------------------------------------------------
#  Constants:  
#-------------------------------------------------------------------------------
        
# DockWindowShell frame icon:
FrameIcon = ImageResource( 'shell.ico' )
    
#-------------------------------------------------------------------------------
#  'DockWindowShell' class:  
#-------------------------------------------------------------------------------

class DockWindowShell ( HasPrivateTraits ):
    
    #---------------------------------------------------------------------------
    #  Trait definitions:  
    #---------------------------------------------------------------------------
    
    # The wx.Frame window which is the actual shell:
    control = Instance( wx.Frame )
    
    #---------------------------------------------------------------------------
    #  Initializes the object:  
    #---------------------------------------------------------------------------
        
    def __init__ ( self, dock_control, use_mouse = False, **traits ):
        super( DockWindowShell, self ).__init__( **traits )
        
        old_control = dock_control.control
        parent      = wx.GetTopLevelParent( old_control )
        while True:
            next_parent = parent.GetParent()
            if next_parent is None:
                break
            parent = next_parent
            
        self.control = shell = wx.Frame( parent, -1, dock_control.name, 
                                         style = wx.DEFAULT_FRAME_STYLE   |
                                                 wx.FRAME_FLOAT_ON_PARENT | 
                                                 wx.FRAME_NO_TASKBAR ) 
        shell.SetIcon( FrameIcon.create_icon() )
        shell.SetBackgroundColour( SystemMetrics().dialog_background_color )
        wx.EVT_CLOSE( shell, self._on_close )
        
        theme = dock_control.theme
        self._dock_window = dw = DockWindow( shell, auto_close = True,
                                                    theme      = theme ).set(    
                                                    style      = 'tab' )
        sizer = wx.BoxSizer( wx.VERTICAL )
        sizer.Add( dw.control, 1, wx.EXPAND )
        shell.SetSizer( sizer )
        
        if use_mouse:
            x, y = wx.GetMousePosition()
        else:
            x, y = old_control.GetPositionTuple()
            x, y = old_control.GetParent().ClientToScreenXY( x, y )
            
        dx, dy = old_control.GetSize()
        tis    = theme.tab.image_slice
        tc     = theme.tab.content
        tdy    = theme.tab_active.image_slice.dy
        dx    += (tis.xleft + tc.left + tis.xright  + tc.right)
        dy    += (tis.xtop  + tc.top  + tis.xbottom + tc.bottom + tdy)
        
        self.add_control( dock_control )
            
{'fraction_non_alphanumeric': 0.27722432153899, 'fraction_numerical': 0.004236802931409596, 'mean_word_length': 1.0175560175560177, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4543352', 'n_tokens_mistral': 2086, 'n_tokens_neox': 1996, 'n_words': 532}