def __init__(self, style=STYLE_DEFAULT, fixed_size=None): View.__init__(self) self._window = self self._first_responder = None self._title = None self._style = style self._resizable = fixed_size is None self._application = Application.shared_application() self._min_size = None self._max_size = None self._zoomed = False self._key_window = False self._main_window = False if fixed_size is None: # normal window self._pyglet = PygletWindow(self, style=style, resizable=True) else: # fixed size window self._pyglet = PygletWindow(self, style=style, resizable=False, width=fixed_size.width, height=fixed_size.height) x, y = self._pyglet.get_location() width, height = self._pyglet.get_size() View.set_frame(self, Rect(x, y, width, height)) self._application._add_window(self)
def on_mouse_release(self, x, y, button, modifiers): origin = Point(x, y) view = self._window.hit_test_with_event(origin, None) Application.shared_application().post_event(MouseReleaseEvent(origin, button, modifiers, view))
def on_mouse_motion(self, x, y, dx, dy): origin = Point(x, y) delta = Point(dx, dy) view = self._window.hit_test_with_event(origin, None) Application.shared_application().post_event(MouseMotionEvent(origin, delta, view))
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): origin = Point(x, y) delta = Point(dx, dy) view = self._window.hit_test_with_event(origin, None) Application.shared_application().post_event(MouseDragEvent(origin, delta, buttons, modifiers, view))
def on_key_release(self, symbol, modifiers): Application.shared_application().post_event(KeyReleaseEvent(symbol, modifiers))
def on_key_press(self, symbol, modifiers): Application.shared_application().post_event(KeyPressEvent(symbol, modifiers))
def on_activate(self): Application.shared_application()._bring_window_to_front(self._window)
def on_text_motion_select(self, motion): Application.shared_application().post_event(TextMotionSelectEvent(motion))
def on_text(self, text): Application.shared_application().post_event(TextEvent(text))
def on_mouse_scroll(self, x, y, scroll_x, scroll_y): origin = Point(x, y) delta = Point(scroll_x, scroll_y) view = self._window.hit_test_with_event(origin, None) Application.shared_application().post_event(MouseScrollEvent(origin, delta, view))