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

import wx
import app
from ctx import localcontext as context


# Implementing FullScreen
class FullScreen(app.FullScreen):
    """Implements fullscreen pane"""

    def __init__(self, pane):
        """Initialize pane"""
        super(FullScreen, self).__init__(None)
        self._frame = context.frame
        #context.SetFrame(self)
        self._pane = pane
        self._index = pane._notebook.GetPageIndex(pane)
        pane._notebook.RemovePage(self._index)
        sizer = wx.FlexGridSizer(1, 1, 0, 0)
        sizer.AddGrowableCol(0)
        sizer.AddGrowableRow(0)
        sizer.SetFlexibleDirection(wx.BOTH)
        sizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
        pane.Reparent(self)
        sizer.Add(pane, 1, wx.EXPAND | wx.ALL, 0)
        self.SetSizer(sizer)
        self.Layout()
        self.Centre(wx.BOTH)
        self._frame.Hide()
        self.ShowFullScreen(True)
        wx.GetApp().SetTopWindow(self)

    # Handlers for FullScreen events.
    def LeaveFullScreen(self):
        """Toggle fullscreen"""
        self._pane.Reparent(None)
        obj = self._pane._object
        text = obj.tab_label
        self._pane._notebook.InsertPage(self._index, self._pane, text, True, obj.bitmap_index)
        #self._pane._notebook.SetPageBitmap(self._index, obj.bitmap_index)
        #context.SetFrame(self._frame)
        self._frame.Show()
        wx.GetApp().SetTopWindow(context.frame)
