<commit_before>
import xml.etree.cElementTree as etree
import wx

from enthought.traits.api import Str, Range, Enum, Instance, Event, Int
from enthought.traits.ui.api import View
from enthought.traits.ui.ui_traits import AView
from enthought.traits.ui.wx.editor import Editor
from enthought.traits.ui.wx.basic_editor_factory import BasicEditorFactory

from enthought.pyface.widget import Widget

from enthought.savage.svg.document import SVGDocument
from enthought.savage.svg.backends.wx.renderer import Renderer
from wx_render_panel import RenderPanel


class ButtonRenderPanel(RenderPanel):
    def __init__(self, parent, button):
        self.button = button
        self.document = button.document
        
        super(ButtonRenderPanel, self).__init__(parent, document=self.document)
    
    def OnLeftDown(self, evt):
        print "left down!"
        evt.Skip()

    def OnLeftUp(self, evt):
        print "left up!"
        evt.Skip()


class _SVGButtonControl(Widget):
    
    document = Instance(SVGDocument)
    
    # The (optional) label:
    label = Str
    
    # Extra padding to add to both the left and right sides:
    width_padding = Range( 0, 31, 7 )
    
    # Extra padding to add to both the top and bottom sides:
    height_padding = Range( 0, 31, 5 )<commit_msg>added dimming of button when clicking on it. This resembles what Traits does, though it may not look right in apps still<commit_after>
import xml.etree.cElementTree as etree
import wx

from enthought.traits.api import Str, Range, Enum, Instance, Event, Int
from enthought.traits.ui.api import View
from enthought.traits.ui.ui_traits import AView
from enthought.traits.ui.wx.editor import Editor
from enthought.traits.ui.wx.basic_editor_factory import BasicEditorFactory

from enthought.pyface.widget import Widget

from enthought.savage.svg.document import SVGDocument
from enthought.savage.svg.backends.wx.renderer import Renderer
from wx_render_panel import RenderPanel


class ButtonRenderPanel(RenderPanel):
    def __init__(self, parent, button):
        self.button = button
        self.document = button.document
        self.state = 'up'
        
        super(ButtonRenderPanel, self).__init__(parent, document=self.document)
        
    def GetBackgroundColour(self):
        bgcolor = super(ButtonRenderPanel, self).GetBackgroundColour()
        if self.state == 'down':
            red, green, blue = bgcolor.Get()
            red -= 50
            green -= 50
            blue -= 50
            bgcolor.Set(red, green, blue, 255)
        return bgcolor
    
    def OnLeftDown(self, evt):
        print "left down!"
        self.state = 'down'
        evt.Skip()
        self.Refresh()

    def OnLeftUp(self, evt):
        print "left up!"
        self.state = 'up'
        evt.Skip()
        self.Refresh()


class _SVGButtonControl(Widget):
    
    document = Instance(SVGDocument)
    
    # The (optional) label:
    label = Str
    
    # Extra padding to add to both the left and right sides:
    width_padding = Range( 0, 31, 7 )
    
    # Extra padding to add to both the top and bottom sides:
    height_padding = Range( 0, 31, 5 )
{'fraction_non_alphanumeric': 0.08251348778165661, 'fraction_numerical': 0.007933989209774674, 'mean_word_length': 2.8865598027127004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '409207', 'n_tokens_mistral': 968, 'n_tokens_neox': 934, 'n_words': 285}