#----------------------------------------------------------------------------
import wx
import wx.lib.docview
+import sys
_ = wx.GetTranslation
_("New Image File"),
wx.OK | wx.ICON_EXCLAMATION)
return False
+
+ try:
+ self._bitmap = wx.Image(doc.GetFilename()).ConvertToBitmap()
+ except:
+ wx.MessageBox(_("Error loading '%s'. %s") % (doc.GetPrintableName(), sys.exc_value),
+ _("Open Image File"),
+ wx.OK | wx.ICON_EXCLAMATION)
+ return False
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._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\x06\
+\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
+\x00\x017IDAT8\x8dcddbfh\x9f\xb3\xf3?\x03\x0e\xf0\xfc\xc5[\x0c\xb1\xfb\x0f\
+\x9f10000l\x9e]\xc2\xc8\x02\x13,Ot\xc6e\x06V\xe0\x9f1\x81\x81\x81\x81\x81\
+\x81\x05Y\xf0\xdc\x0b\x88C\x1e|\xfc\xc2\xf0\xe3\xf7\x01\x86{\x1fO20000(\xf1\
+\x9b3p\xb0:\xc0\xd5\x05\xa9\xf3\xc2\xd9L\xe8&\xa3kf```8\xfah-\xc3\xb57\x9d\
+\x0c?~\x1f\xc0p\t\x86\x01\xe8\x9aa\xe0\xf9\xc7\'X\xc5Q\x0c\x90\xe1c\xc4P\xf4\
+\xfc\xe3\x13\x14\xb6\x02?\x0f~\x17(\xf1\x9bc\xd5\xcc\xc0\xc0\xc0 \xc9/\x03g_\
+\xbbx\ta\x00,\xaa\xc4\xb8\x18\x18\x8c%\xd5\xb0j\x86\x19n$\xc1\x88"\xc6\x82\
+\xaeH]X\x9d!T#\x96\xe1\xec\xf3[\x0cG\x1f\xade````\xb0\x96\x0bf0\x96TcP\x17V\
+\xc70\x14\xc3\x00\x98!\xea\xc2\xea\x0c\xb7\x1a\x1a\x19\x18\x18\x18\x18\xa2\
+\xd6,\xc0\xa6\x0c\xe1\x05J\x00\x0b\x03\x03"iz,\xd3A\x91|l\xf2\x8a\x81\x81\
+\x81\x81au\x87\x18\x8a\xf8\xd5\x8aW\xc4\xb9@VN\x0c\x9f4v\x03\x94\x05LH2\x04%\
+\x10wD]!h#N\x03`\xb9\x0b\x06`\t\x85\x10\x00\x00\xe4\x0ecz\x94h\xf0\x8e\x00\
+\x00\x00\x00IEND\xaeB`\x82'
def getImageBitmap():
return ImageFromStream(stream)
def getImageIcon():
- icon = EmptyIcon()
- icon.CopyFromBitmap(getImageBitmap())
- return icon
+ return wx.IconFromBitmap(getImageBitmap())