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

import copy
import wx
import app
import app.resources as rc
import model


# Implementing codeNavigator
class CodeNavigator(app.codeNavigator):
    """Dialog for code insertion"""
    def __init__(self, parent, method):
        """Initialice dialog"""
        self.method = method
        super(CodeNavigator, self).__init__(parent)

    def add_root(self, name, _type):
        """Add element to tree"""
        # we need to find all visible methods
        self.m_treeCtrl3.AppendItem(self.root, name, data=wx.TreeItemData(_type))

    def ShowModal(self):
        """Initialize dialog and go"""
        # add root
        self.root = self.m_treeCtrl3.AddRoot(wx.EmptyString)
        # insert methods for variables
        t = model.cc.typeinst(type=self.method.inner_class, ptr=True, constptr=True)
        self.add_root('this', t)

        super(wx.Dialog, self).Show()  # skip dialog modeless handling but show window
        return super(CodeNavigator, self).ShowModal()

    def OnKeyDown(self, event):
        if event.GetKeyCode() == wx.WXK_ESCAPE:
            self.EndModal(wx.ID_CANCEL)

    # Handlers for codeNavigator events.
    def OnSelectedItem(self, event):
        """Handle select item"""
        # TODO: Implement OnSelectedItem
        pass

    def OnExpandItem(self, event):
        # TODO: Implement OnExpandItem
        """Handle select item"""
        pass


