]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/tool/ImageEditor.py
   1 #---------------------------------------------------------------------------- 
   3 # Purpose:      Image Editor for pydocview 
   8 # Copyright:    (c) 2004-2005 ActiveGrid, Inc. 
  10 # License:      wxWindows License 
  11 #---------------------------------------------------------------------------- 
  17 class ImageDocument(wx
.lib
.docview
.Document
): 
  21 class ImageView(wx
.lib
.docview
.View
): 
  24     #---------------------------------------------------------------------------- 
  26     #---------------------------------------------------------------------------- 
  29         wx
.lib
.docview
.View
.__init
__(self
) 
  33     def OnCreate(self
, doc
, flags
): 
  34         if len(doc
.GetFilename()) == 0: 
  35             wx
.MessageBox(_("Cannot create a new image file.\n%s has no paint capability.") % wx
.GetApp().GetAppName(), 
  37                                 wx
.OK | wx
.ICON_EXCLAMATION
) 
  40         frame 
= wx
.GetApp().CreateDocumentFrame(self
, doc
, flags
) 
  41         panel 
= wx
.Panel(frame
, -1)             
  42         bitmap 
= wx
.Image(doc
.GetFilename()).ConvertToBitmap() 
  43         self
._ctrl 
= wx
.StaticBitmap(panel
, -1, bitmap
, (0,0), (bitmap
.GetWidth(), bitmap
.GetHeight())) 
  44         panel
.SetClientSize(bitmap
.GetSize()) 
  45         frame
.SetClientSize(panel
.GetSize()) 
  50     def OnClose(self
, deleteWindow 
= True): 
  51         statusC 
= wx
.GetApp().CloseChildDocuments(self
.GetDocument()) 
  52         statusP 
= wx
.lib
.docview
.View
.OnClose(self
, deleteWindow 
= deleteWindow
) 
  53         if not (statusC 
and statusP
): 
  57             self
.GetFrame().Destroy() 
  61 #---------------------------------------------------------------------------- 
  62 # Icon Bitmaps - generated by encode_bitmaps.py 
  63 #---------------------------------------------------------------------------- 
  64 from wx 
import ImageFromStream
, BitmapFromImage
 
  65 from wx 
import EmptyIcon
 
  71 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0f\x00\x00\x00\x0e\x08\x06\ 
  72 \x00\x00\x00\xf0\x8aF\xef\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ 
  73 \x00\x00\x97IDAT(\x91\x9d\x93Q\n\xc4 \x0cD\'\xda\xd3\xa9\xe9ac\xdb\x8bx\xa0\ 
  74 \xf4C"\xd6mAw@\x0c1/\t\x03\x123+\x16\x95s\x06\x00l\x00p\x9c\x17\xad\xc0\xe4<\ 
  75 R\x0c\xeaf\x81\x14\x83\xa6\x18\x1e[N\xc1)\x06\x15\x01Dj\xbc\x04\x7fi\x9b):\ 
  76 \xce\x8b\xf6\xbdN\xec\xfd\x99\x82G\xc8\xf4\xba\xf6\x9b9o\xfa\x81\xab9\x02\ 
  77 \x11i\xe6|6cf%\xe7A\xce\x83\x99\xd5\xc4\xccZJ\xd11\xd7\xd76\xd8\x8aJ)\xed\ 
  78 \xb6c\x8d,~\xc0\xe3\xe3L\xdc\xe0~\xcaJ\x03\xfa\xe7c\x98n\x01\x88\xc6k\xb1\ 
  79 \x83\x04\x87\x00\x00\x00\x00IEND\xaeB`\x82'  
  83     return BitmapFromImage(getImageImage()) 
  86     stream 
= cStringIO
.StringIO(getImageData()) 
  87     return ImageFromStream(stream
) 
  91     icon
.CopyFromBitmap(getImageBitmap())