1.2.1
by Varun Hiremath
Import upstream version 3.4.1 |
1 |
#------------------------------------------------------------------------------
|
2 |
# Copyright (c) 2011, Enthought, Inc.
|
|
3 |
# All rights reserved.
|
|
4 |
#
|
|
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 |
#------------------------------------------------------------------------------
|
|
11 |
||
12 |
from enthought.qt import QtCore, QtGui |
|
13 |
from enthought.kiva.cairo import CompiledPath, GraphicsContext, font_metrics_provider |
|
14 |
||
15 |
from base_window import BaseWindow |
|
16 |
from scrollbar import NativeScrollBar |
|
17 |
||
18 |
class Window(BaseWindow): |
|
19 |
def _create_gc(self, size, pix_format="bgra32"): |
|
20 |
gc = GraphicsContext((size[0]+1, size[1]+1)) |
|
21 |
gc.translate_ctm(0.5, 0.5) |
|
22 |
||
23 |
return gc |
|
24 |
||
25 |
def _window_paint(self, event): |
|
26 |
if self.control is None: |
|
27 |
return
|
|
28 |
||
29 |
# self._gc is an image context
|
|
30 |
w = self._gc.width() |
|
31 |
h = self._gc.height() |
|
32 |
data = self._gc.pixel_map.convert_to_argbarray() |
|
33 |
||
34 |
image = QtGui.QImage(data, w, h, QtGui.QImage.Format_ARGB32) |
|
35 |
||
36 |
rect = QtCore.QRect(0,0,w,h) |
|
37 |
painter = QtGui.QPainter(self.control) |
|
38 |
painter.drawImage(rect, image) |
|
39 |
||
40 |
||
41 |
||
42 |
# EOF
|