# Path: pyglet_gui/constants.py
# HALIGN_CENTER = 0
# 
# HALIGN_LEFT = -1
# 
# HALIGN_RIGHT = 1
# 
# VALIGN_TOP = 1
# 
# VALIGN_CENTER = 0
# 
# ANCHOR_CENTER = (VALIGN_CENTER, HALIGN_CENTER)
# 
# def GetRelativePoint(parent, parent_anchor, child, child_anchor, offset):
#     valign, halign = parent_anchor or ANCHOR_CENTER
# 
#     if valign == VALIGN_TOP:
#         y = parent.y + parent.height
#     elif valign == VALIGN_CENTER:
#         y = parent.y + parent.height // 2
#     else:  # VALIGN_BOTTOM
#         y = parent.y
# 
#     if halign == HALIGN_LEFT:
#         x = parent.x
#     elif halign == HALIGN_CENTER:
#         x = parent.x + parent.width // 2
#     else:  # HALIGN_RIGHT
#         x = parent.x + parent.width
# 
#     valign, halign = child_anchor or (valign, halign)
#     offset_x, offset_y = offset
# 
#     if valign == VALIGN_TOP:
#         y += offset_y - child.height
#     elif valign == VALIGN_CENTER:
#         y += offset_y - child.height // 2
#     else:  # VALIGN_BOTTOM
#         y += offset_y
# 
#     if halign == HALIGN_LEFT:
#         x += offset_x
#     elif halign == HALIGN_CENTER:
#         x += offset_x - child.width // 2
#     else:  # HALIGN_RIGHT
#         x += offset_x - child.width
# 
#     return x, y
# 
# Path: pyglet_gui/core.py
# class Viewer(Rectangle, Managed):
#     def __init__(self, width=0, height=0):
#         super(Managed, self).__init__()
#         self._parent = None
#         self._is_loaded = False
# 
#         Rectangle.__init__(self, 0, 0, width, height)
# 
#     @property
#     def parent(self):
#         return self._parent
# 
#     @parent.setter
#     def parent(self, widget):
#         self._parent = widget
# 
#     @property
#     def is_loaded(self):
#         return self._is_loaded
# 
#     def is_expandable(self):
#         return False
# 
#     def set_position(self, x, y):
#         super(Viewer, self).set_position(x, y)
#         self.layout()
# 
#     def get_path(self):
#         raise NotImplementedError
# 
#     def load(self):
#         assert not self._is_loaded
#         self._is_loaded = True
#         self.load_graphics()
# 
#     def unload(self):
#         assert self._is_loaded
#         self._is_loaded = False
#         self.unload_graphics()
# 
#     def reload(self):
#         self.unload()
#         self.load()
# 
#     def load_graphics(self):
#         pass
# 
#     def unload_graphics(self):
#         pass
# 
#     def layout(self):
#         pass
# 
#     def compute_size(self):
#         return self.width, self.height
# 
#     def reset_size(self, reset_parent=True):
#         width, height = self.compute_size()
# 
#         # if out size changes
#         if self.width != width or self.height != height:
#             self.width, self.height = width, height
# 
#             # This will eventually call our layout
#             if reset_parent:
#                 self.parent.reset_size(reset_parent)
#         # else, the parent is never affected and thus we layout.
#         else:
#             self.layout()
# 
#     def delete(self):
#         if self.is_loaded:
#             self.unload()
#         self.parent = None
#         Managed.delete(self)
# 
# class Rectangle(object):
#     def __init__(self, x=0, y=0, width=0, height=0):
#         self._x = x
#         self._y = y
#         self.width = width
#         self.height = height
# 
#     @property
#     def x(self):
#         return self._x
# 
#     @property
#     def y(self):
#         return self._y
# 
#     @x.setter
#     def x(self, value):
#         self._x = value
# 
#     @y.setter
#     def y(self, value):
#         self._y = value
# 
#     def set_position(self, x, y):
#         self._x = x
#         self._y = y
# 
#     def is_inside(self, x, y):
#         return self.x <= x < self.x + self.width and self.y <= y < self.y + self.height


from functools import reduce
from pyglet_gui.constants import HALIGN_CENTER, HALIGN_LEFT, HALIGN_RIGHT, \
    VALIGN_TOP, VALIGN_CENTER, ANCHOR_CENTER, GetRelativePoint
from pyglet_gui.core import Viewer, Rectangle
        super(GridContainer, self).delete()
        self._matrix = [[]]


class Wrapper(Container):
    """
    A Viewer that wraps another widget.
    """
    def __init__(self, content, is_expandable=False, anchor=ANCHOR_CENTER, offset=(0, 0)):
        assert isinstance(content, Viewer)
        Container.__init__(self, [content])

        self.expandable = is_expandable
        self._anchor = anchor
        self.content_offset = offset

    @property
    def anchor(self):
        return self._anchor

    @anchor.setter
    def anchor(self, anchor):
        self._anchor = anchor

    @property
    def content(self):
        return self._content[0]

    @content.setter
    def content(self, content):

# Path: pyglet_gui/constants.py
# HALIGN_CENTER = 0
# 
# HALIGN_LEFT = -1
# 
# HALIGN_RIGHT = 1
# 
# VALIGN_TOP = 1
# 
# VALIGN_CENTER = 0
# 
# ANCHOR_CENTER = (VALIGN_CENTER, HALIGN_CENTER)
# 
# def GetRelativePoint(parent, parent_anchor, child, child_anchor, offset):
#     valign, halign = parent_anchor or ANCHOR_CENTER
# 
#     if valign == VALIGN_TOP:
#         y = parent.y + parent.height
#     elif valign == VALIGN_CENTER:
#         y = parent.y + parent.height // 2
#     else:  # VALIGN_BOTTOM
#         y = parent.y
# 
#     if halign == HALIGN_LEFT:
#         x = parent.x
#     elif halign == HALIGN_CENTER:
#         x = parent.x + parent.width // 2
#     else:  # HALIGN_RIGHT
#         x = parent.x + parent.width
# 
#     valign, halign = child_anchor or (valign, halign)
#     offset_x, offset_y = offset
# 
#     if valign == VALIGN_TOP:
#         y += offset_y - child.height
#     elif valign == VALIGN_CENTER:
#         y += offset_y - child.height // 2
#     else:  # VALIGN_BOTTOM
#         y += offset_y
# 
#     if halign == HALIGN_LEFT:
#         x += offset_x
#     elif halign == HALIGN_CENTER:
#         x += offset_x - child.width // 2
#     else:  # HALIGN_RIGHT
#         x += offset_x - child.width
# 
#     return x, y
# 
# Path: pyglet_gui/core.py
# class Viewer(Rectangle, Managed):
#     def __init__(self, width=0, height=0):
#         super(Managed, self).__init__()
#         self._parent = None
#         self._is_loaded = False
# 
#         Rectangle.__init__(self, 0, 0, width, height)
# 
#     @property
#     def parent(self):
#         return self._parent
# 
#     @parent.setter
#     def parent(self, widget):
#         self._parent = widget
# 
#     @property
#     def is_loaded(self):
#         return self._is_loaded
# 
#     def is_expandable(self):
#         return False
# 
#     def set_position(self, x, y):
#         super(Viewer, self).set_position(x, y)
#         self.layout()
# 
#     def get_path(self):
#         raise NotImplementedError
# 
#     def load(self):
#         assert not self._is_loaded
#         self._is_loaded = True
#         self.load_graphics()
# 
#     def unload(self):
#         assert self._is_loaded
#         self._is_loaded = False
#         self.unload_graphics()
# 
#     def reload(self):
#         self.unload()
#         self.load()
# 
#     def load_graphics(self):
#         pass
# 
#     def unload_graphics(self):
#         pass
# 
#     def layout(self):
#         pass
# 
#     def compute_size(self):
#         return self.width, self.height
# 
#     def reset_size(self, reset_parent=True):
#         width, height = self.compute_size()
# 
#         # if out size changes
#         if self.width != width or self.height != height:
#             self.width, self.height = width, height
# 
#             # This will eventually call our layout
#             if reset_parent:
#                 self.parent.reset_size(reset_parent)
#         # else, the parent is never affected and thus we layout.
#         else:
#             self.layout()
# 
#     def delete(self):
#         if self.is_loaded:
#             self.unload()
#         self.parent = None
#         Managed.delete(self)
# 
# class Rectangle(object):
#     def __init__(self, x=0, y=0, width=0, height=0):
#         self._x = x
#         self._y = y
#         self.width = width
#         self.height = height
# 
#     @property
#     def x(self):
#         return self._x
# 
#     @property
#     def y(self):
#         return self._y
# 
#     @x.setter
#     def x(self, value):
#         self._x = value
# 
#     @y.setter
#     def y(self, value):
#         self._y = value
# 
#     def set_position(self, x, y):
#         self._x = x
#         self._y = y
# 
#     def is_inside(self, x, y):
#         return self.x <= x < self.x + self.width and self.y <= y < self.y + self.height


# Path: pyglet_gui/containers.py
from functools import reduce
from pyglet_gui.constants import HALIGN_CENTER, HALIGN_LEFT, HALIGN_RIGHT, \
    VALIGN_TOP, VALIGN_CENTER, ANCHOR_CENTER, GetRelativePoint
from pyglet_gui.core import Viewer, Rectangle

        super(GridContainer, self).delete()
        self._matrix = [[]]


class Wrapper(Container):
    """
    A Viewer that wraps another widget.
    """
    def __init__(self, content, is_expandable=False, anchor=ANCHOR_CENTER, offset=(0, 0)):
        assert isinstance(content, Viewer)
        Container.__init__(self, [content])

        self.expandable = is_expandable
        self._anchor = anchor
        self.content_offset = offset

    @property
    def anchor(self):
        return self._anchor

    @anchor.setter
    def anchor(self, anchor):
        self._anchor = anchor

    @property
    def content(self):
        return self._content[0]

    @content.setter
    def content(self, content):

        assert isinstance(content, Viewer)