"""Subclass of UserSections, which is generated by wxFormBuilder."""
import wxx
from activity.models.ui import ui as ui


# Implementing UserSections
class UserSectionsDialog(ui.UserSections):
    """
    This dialog allows to edit user sections and put
    custom code inside generated code.
    """
    @wxx.SetInfo(__doc__)
    def __init__(self, parent, container):
        """initialization"""
        super(UserSectionsDialog, self).__init__(parent)
        self.container = container

    # Handlers for UserSections events.
    def OnLeaveFocus(self, event):
        event.Skip()

    def OnGetFocus(self, event):
        event.Skip()

    def CopyAttributes(self, cls):
        """Copy attributes to class"""
        cls.user_code_h1 = self.m_h1.GetText()
        cls.user_code_h2 = self.m_h2.GetText()
        cls.user_code_h3 = self.m_h3.GetText()
        cls.user_code_s1 = self.m_s1.GetText()
        cls.user_code_s2 = self.m_s2.GetText()
        cls.user_code_s3 = self.m_s3.GetText()

    def SetAttributes(self, cls):
        """Setup attributes for editing already class"""
        self.m_h1.SetText(cls.user_code_h1)
        self.m_h2.SetText(cls.user_code_h2)
        self.m_h3.SetText(cls.user_code_h3)
        self.m_s1.SetText(cls.user_code_s1)
        self.m_s2.SetText(cls.user_code_s2)
        self.m_s3.SetText(cls.user_code_s3)
