File: mac_window.py

package info (click to toggle)
python-enable 3.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 10,392 kB
  • ctags: 17,135
  • sloc: cpp: 79,151; python: 29,601; makefile: 2,926; sh: 43
file content (59 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
""" Defines the concrete top-level Enable 'Window' class for the wxPython GUI
toolkit, based on the kiva driver for OS X.
"""

# Major library imports.
import wx

# Enthought library imports.
from enthought.kiva.backend_wx import gc_for_dc

# Local imports.
from window import Window


class MacWindow(Window):
    """ An Enable Window for wxPython GUIs on OS X.
    """

    #### 'Window' interface ####################################################

    def __init__(self, parent, wid=-1, pos=wx.DefaultPosition,
        size=wx.DefaultSize, **traits):

        Window.__init__(self, parent, wid=wid, pos=pos, size=size, **traits)

        #self.memDC = wx.MemoryDC()
        return

    def _create_gc(self, size, pix_format="bgra32"):
        self.dc = wx.ClientDC(self.control)
        gc = gc_for_dc(self.dc)
        gc.begin()
        return gc

    def _window_paint(self, event):
        self.dc = None
        self._gc = None  # force a new gc to be created for the next paint()


    #### 'AbstractWindow' interface ############################################
 
    def _paint(self, event=None):
        size = self._get_control_size()
        if (self._size != tuple(size)) or (self._gc is None):
            self._gc = self._create_gc(size)
            self._size = tuple(size)
        gc = self._gc
        gc.begin()
        gc.clear(self.bgcolor_)
        if hasattr(self.component, "do_layout"):
            self.component.do_layout()
        self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
        self._window_paint(event)
        gc.end()
        return
 


#### EOF #######################################################################