"""Subclass of Breakpoints, which is generated by wxFormBuilder."""
import wx
from activity.files.ui import ui as ui


# Implementing Breakpoints
class Breakpoints(ui.Breakpoints):
    """Pane showing breakpoints"""
    def __init__(self, parent, handler):
        """Initialize pane"""
        self._handler = handler
        super(Breakpoints, self).__init__(parent)
        img = wx.ImageList(24, 24, True, 1)
        img.Add(wx.Bitmap(u"app/res/breakpoint.xpm", wx.BITMAP_TYPE_ANY))
        self.m_listBreakpoints.AssignImageList(img, wx.IMAGE_LIST_SMALL)
        sz = self.GetClientSize()
        self.m_listBreakpoints.InsertColumn(0, '', wx.LIST_FORMAT_LEFT, sz.x)

    def UpdateData(self):
        """Update the data"""
        self.m_listBreakpoints.DeleteAllItems()
        breakpoints = self._handler.breakpoints
        keys = breakpoints.keys()
        keys.sort()
        for i in range(0, len(keys)):
            key = keys[i]
            bpi = breakpoints[key]
            text = '#{num} at {file}:{line}'.format(
                num=str(key),
                file=bpi[0],
                line=bpi[1])
            self.m_listBreakpoints.InsertStringItem(i, text, 0)

    # Handlers for Breakpoints events.
    def OnSelectBreakpoint(self, event):
        """Enable/Disable breakpoint"""
        pass

    def OnEditBreakpoint(self, event):
        """Edit breakpoint conditions"""
        # TODO: Implement OnEditBreakpoint
        pass

    def OnBreakpoinMenu(self, event):
        """Show popup menu for breakpoints"""
        # TODO: Implement OnBreakpoinMenu
        pass

    def OnSize(self, event):
        """Resize listctrl"""
        self.m_listBreakpoints.SetColumnWidth(0, event.m_size.x)

