"""Subclass of Threads, which is generated by wxFormBuilder."""

import wx
from activity.files.ui import ui as ui


# Implementing Threads
class Threads(ui.Threads):
    """Pane showing current threads"""

    def __init__(self, parent, handler):
        """Initialize pane"""
        self._handler = handler
        super(Threads, self).__init__(parent)

    # Update data
    def UpdateData(self):
        """Update the threads info"""
        self.Freeze()
        self.m_listThreads.Clear()
        threads = self._handler.threads
        current = None
        # update thread list
        for k in threads:
            thread = threads[k]
            i = self.m_listThreads.Append('{name}:{classname}={id} {status}'.format(
                    name=thread.name, classname=thread.classname, id=thread.id, status=thread.status))
            self.m_listThreads.SetClientData(i, thread)
            if thread.is_current:
                current = thread
                self.m_listThreads.SetItemBackgroundColour(i, wx.Colour(127, 255, 255))
        self.Thaw()
        if current:
            self._handler.m_stack.UpdateData(current)

    # Handlers for Threads events.
    def OnSelectThread(self, event):
        """Select thread"""
        # TODO: Implement OnSelectThread
        pass

    def OnActivateThread(self, event):
        """Activate thread"""
        # TODO: Implement OnActivateThread
        pass

    def OnSelectStackFrame(self, event):
        """Select frame"""
        # TODO: Implement OnSelectStackFrame
        pass

    def OnActivateStackFrame(self, event):
        """Activate stack frame"""
        # TODO: Implement OnActivateStackFrame
        pass

