]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/ImageEditor.py
DocView and ActiveGrid IDE updates from Morgan Hua:
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / ImageEditor.py
index 669123616983788be4be4112724df46cb7a7ae80..2e666d400d1679d662ae4a9d842efa576ef0f458 100644 (file)
@@ -11,6 +11,7 @@
 #----------------------------------------------------------------------------
 import wx
 import wx.lib.docview
+import sys
 _ = wx.GetTranslation
 
 
@@ -36,18 +37,25 @@ class ImageView(wx.lib.docview.View):
                                 _("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()))
+        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(bitmap.GetSize())
+        panel.SetClientSize(self._bitmap.GetSize())
         frame.SetClientSize(panel.GetSize())
         self.Activate()
         return True
@@ -69,6 +77,13 @@ class ImageView(wx.lib.docview.View):
         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
 #----------------------------------------------------------------------------
@@ -78,15 +93,21 @@ import cStringIO
 
 def getImageData():
     return \
-'\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' 
+'\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():