1
#------------------------------------------------------------------------------
2
# Copyright (c) 2011, Enthought, Inc.
5
# This software is provided without warranty under the terms of the BSD
6
# license included in enthought/LICENSE.txt and may be redistributed only
7
# under the conditions described in the aforementioned license. The license
8
# is also available online at http://www.enthought.com/licenses/BSD.txt
9
# Thanks for using Enthought open source!
10
#------------------------------------------------------------------------------
13
pyglet.options['shadow_window'] = False
15
from enthought.traits.api import Bool, Instance
16
from enthought.kiva.gl import CompiledPath, GraphicsContext
18
from base_window import BaseGLWindow
19
from scrollbar import NativeScrollBar
21
class Window(BaseGLWindow):
22
def _create_gc(self, size, pix_format=None):
23
""" Create a GraphicsContext instance.
25
from pyglet.gl import Context
27
gc = GraphicsContext((size[0]+1, size[1]+1))
28
self._pyglet_gl_context = Context()
30
gc.translate_ctm(0.5, 0.5)
34
""" Gives the GC a chance to initialize itself before components perform layout
35
and draw. This is called every time through the paint loop.
37
self._pyglet_gl_context.set_current()
38
self.control.makeCurrent()
39
super(Window, self)._init_gc()
41
def _paint(self, event=None):
42
""" Paint the contents of the window.
44
if self.control is None:
47
size = self._get_control_size()
48
self._size = tuple(size)
49
self._gc = self._create_gc(size)
51
if hasattr(self.component, "do_layout"):
52
self.component.do_layout()
53
self._gc.clear(self.bgcolor_)
54
self.component.draw(self._gc, view_bounds=(0, 0, size[0], size[1]))
55
self._update_region = []
57
def font_metrics_provider():
58
from enthought.kiva.fonttools import Font
59
gc = GraphicsContext((1, 1))