frame = wx.GetApp().CreateDocumentFrame(self, doc, flags)
panel = wx.Panel(frame, -1)
- bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap()
- self._ctrl = wx.StaticBitmap(panel, -1, bitmap, (0,0), (bitmap.GetWidth(), bitmap.GetHeight()))
- panel.SetClientSize(bitmap.GetSize())
+ self._bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap()
+ self._ctrl = wx.StaticBitmap(panel, -1, self._bitmap, (0,0), (self._bitmap.GetWidth(), self._bitmap.GetHeight()))
+ wx.EVT_LEFT_DOWN(self._ctrl, self.OnFocus)
+ wx.EVT_LEFT_DCLICK(self._ctrl, self.OnFocus)
+ wx.EVT_RIGHT_DOWN(self._ctrl, self.OnFocus)
+ wx.EVT_RIGHT_DCLICK(self._ctrl, self.OnFocus)
+ wx.EVT_MIDDLE_DOWN(self._ctrl, self.OnFocus)
+ wx.EVT_MIDDLE_DCLICK(self._ctrl, self.OnFocus)
+ panel.SetClientSize(self._bitmap.GetSize())
frame.SetClientSize(panel.GetSize())
self.Activate()
return True
+ def OnFocus(self, event):
+ self._ctrl.SetFocus()
+ event.Skip()
+
+
def OnClose(self, deleteWindow = True):
statusC = wx.GetApp().CloseChildDocuments(self.GetDocument())
statusP = wx.lib.docview.View.OnClose(self, deleteWindow = deleteWindow)
return True
+ def OnDraw(self, dc):
+ """ for Print Preview and Print """
+ dc.BeginDrawing()
+ dc.DrawBitmap(self._bitmap, 10, 10, True)
+ dc.EndDrawing()
+
+
#----------------------------------------------------------------------------
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
-from wx import EmptyIcon
import cStringIO
def getImageData():
return \
-'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0f\x00\x00\x00\x0e\x08\x06\
-\x00\x00\x00\xf0\x8aF\xef\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
-\x00\x00\x97IDAT(\x91\x9d\x93Q\n\xc4 \x0cD\'\xda\xd3\xa9\xe9ac\xdb\x8bx\xa0\
-\xf4C"\xd6mAw@\x0c1/\t\x03\x123+\x16\x95s\x06\x00l\x00p\x9c\x17\xad\xc0\xe4<\
-R\x0c\xeaf\x81\x14\x83\xa6\x18\x1e[N\xc1)\x06\x15\x01Dj\xbc\x04\x7fi\x9b):\
-\xce\x8b\xf6\xbdN\xec\xfd\x99\x82G\xc8\xf4\xba\xf6\x9b9o\xfa\x81\xab9\x02\
-\x11i\xe6|6cf%\xe7A\xce\x83\x99\xd5\xc4\xccZJ\xd11\xd7\xd76\xd8\x8aJ)\xed\
-\xb6c\x8d,~\xc0\xe3\xe3L\xdc\xe0~\xcaJ\x03\xfa\xe7c\x98n\x01\x88\xc6k\xb1\
-\x83\x04\x87\x00\x00\x00\x00IEND\xaeB`\x82'
+'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\
+\x00\x00\x00\x90\x91h6\x00\x00\x00\x03sBIT\x08\x08\x08\xdb\xe1O\xe0\x00\x00\
+\x00\x9aIDAT(\x91\x95\x92\xc1\r\xc50\x08C\xdd\xaa\xeb\xc12\xec\x90\x9b\x97!\
+\x0b\xb0\x03\x19\xe8\x1fR\xa9U\xf2\xd5\xb4>DH\xf8\t\x13\xb1E\x04\xbe\xe8\x00\
+@\xf2\x8d\xb5\xd6z\x02\x00\xccl\t\x98\x19\xc9}\xe9#y\x8f\xb0\x00H\xba\xc3\
+\xfd\x8a\xbd\x9e0\xe8xn\x9b\x99*q[r\x01`\xfa\x8f?\x91\x86-\x07\x8d\x00Iww\
+\xf7\xce\xcc\xf0>\xbb\x01\xa8j)e\x80G\xa0\xb7[k\x00J)\xfdU\xd5\xd6Z\x87O_D\
+\x88\x88\x88dff>\x17"r\x02y\xd33\xb3E\xc4\xcb\xe3\xeb\xda\xbe\x9e\xf7\x0f\
+\xa0B\x86\xd5X\x16\xcc\xea\x00\x00\x00\x00IEND\xaeB`\x82'
def getImageBitmap():
return ImageFromStream(stream)
def getImageIcon():
- icon = EmptyIcon()
- icon.CopyFromBitmap(getImageBitmap())
- return icon
+ return wx.IconFromBitmap(getImageBitmap())