OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python -tt | |
2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Display for bmpblock object.""" | |
7 import wx | |
8 | |
9 class MyPanel(wx.Panel): | |
10 | |
11 def __init__(self, parent): | |
12 wx.Panel.__init__(self, parent, wx.ID_ANY) | |
13 self.Bind(wx.EVT_PAINT, self.OnPaint) | |
14 self.parent = parent | |
15 self.imglist = () | |
16 | |
17 def OnPaint(self, evt=None): | |
18 if (evt): | |
19 dc = wx.PaintDC(self) | |
20 else: | |
21 dc = wx.ClientDC(self) | |
22 | |
23 done_first = False | |
Randall Spangler
2011/03/01 17:37:18
Might want to comment that size is taken from the
| |
24 for x, y, filename in self.imglist: | |
25 img = wx.Image(filename, wx.BITMAP_TYPE_ANY) | |
26 if (not done_first): | |
27 size = img.GetSize() | |
28 self.SetMinSize(size) | |
29 self.SetSize(size) | |
30 self.Fit() | |
31 w,h = self.parent.GetBestSize() | |
32 self.parent.SetDimensions(-1, -1, w, h, wx.SIZE_AUTO) | |
33 done_first = True | |
34 bmp = img.ConvertToBitmap() | |
35 dc.DrawBitmap(bmp, x, y) | |
36 | |
37 | |
38 class Frame(wx.Frame): | |
39 | |
40 def __init__(self, bmpblock=None, title=None): | |
41 wx.Frame.__init__(self, None, wx.ID_ANY, title=title) | |
42 self.CreateStatusBar() | |
43 self.SetStatusText(title) | |
44 self.Bind(wx.EVT_CLOSE, self.OnQuit) | |
45 | |
46 # HEY: really? | |
Randall Spangler
2011/03/01 17:37:18
Leftover comment? (line 51 too)
| |
47 self.bmpblock = bmpblock | |
48 if self.bmpblock: | |
49 self.bmpblock.RegisterScreenDisplayObject(self) | |
50 | |
51 # Is this enough? | |
52 self.p = MyPanel(self) | |
53 | |
54 | |
55 def OnQuit(self, event): | |
56 wx.GetApp().ExitMainLoop() | |
57 | |
58 def DisplayScreen(self, name, imglist): | |
59 self.SetStatusText(name) | |
60 self.p.imglist = imglist | |
61 self.p.OnPaint() | |
OLD | NEW |