~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to enthought/enable/qt4/cairo.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-05 21:54:28 UTC
  • mfrom: (1.1.5 upstream)
  • mto: (8.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110405215428-1x2wtubz3ok2kxaq
Tags: upstream-3.4.1
ImportĀ upstreamĀ versionĀ 3.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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