]>
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
70 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\
71 \x00\x00\x00\x90\x91h6\x00\x00\x00\x03sBIT\x08\x08\x08\xdb\xe1O\xe0\x00\x00\
72 \x00\x9aIDAT(\x91\x95\x92\xc1\r\xc50\x08C\xdd\xaa\xeb\xc12\xec\x90\x9b\x97!\
73 \x0b\xb0\x03\x19\xe8\x1fR\xa9U\xf2\xd5\xb4>DH\xf8\t\x13\xb1E\x04\xbe\xe8\x00\
74 @\xf2\x8d\xb5\xd6z\x02\x00\xccl\t\x98\x19\xc9}\xe9#y\x8f\xb0\x00H\xba\xc3\
75 \xfd\x8a\xbd\x9e0\xe8xn\x9b\x99*q[r\x01`\xfa\x8f?\x91\x86-\x07\x8d\x00Iww\
76 \xf7\xce\xcc\xf0>\xbb\x01\xa8j)e\x80G\xa0\xb7[k\x00J)\xfdU\xd5\xd6Z\x87O_D\
77 \x88\x88\x88dff>\x17"r\x02y\xd33\xb3E\xc4\xcb\xe3\xeb\xda\xbe\x9e\xf7\x0f\
78 \xa0B\x86\xd5X\x16\xcc\xea\x00\x00\x00\x00IEND\xaeB`\x82'
82 return BitmapFromImage(getImageImage())
85 stream
= cStringIO
.StringIO(getImageData())
86 return ImageFromStream(stream
)
89 return wx
.IconFromBitmap(getImageBitmap())