CtrlLib: RichEdit now supports dropping Image files

git-svn-id: svn://ultimatepp.org/upp/trunk@2270 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-03-26 16:53:32 +00:00
parent f8b182b556
commit 36cbf9dcef
4 changed files with 30 additions and 0 deletions

View file

@ -262,6 +262,7 @@ Image GetImage(PasteClip& clip);
String GetImageClip(const Image& m, const String& fmt);
void Append(VectorMap<String, ClipData>& data, const Image& img);
bool IsAvailableFiles(PasteClip& clip);
bool AcceptFiles(PasteClip& clip);
Vector<String> GetFiles(PasteClip& clip);

View file

@ -392,6 +392,10 @@ bool AcceptFiles(PasteClip& clip)
return false;
}
bool IsAvailableFiles(PasteClip& clip)
{
return clip.IsAvailable("files");
}
struct sDROPFILES {
DWORD offset;

View file

@ -342,6 +342,12 @@ bool AcceptFiles(PasteClip& clip)
return clip.Accept("text/uri-list");
}
bool IsAvailableFiles(PasteClip& clip)
{
GuiLock __;
return clip.IsAvailable("text/uri-list");
}
int JustLf(int c)
{
return (byte)c >= 32 || c == '\n' ? c : 0;

View file

@ -42,6 +42,25 @@ bool RichEdit::Accept(PasteClip& d, RichText& clip)
return true;
}
}
if(AcceptFiles(d)) {
Vector<String> s = GetFiles(d);
if(s.GetCount()) {
String fn = s[0];
String ext = ToUpper(GetFileExt(fn));
if(ext == ".PNG" || ext == ".JPG" || ext == ".JPEG" || ext == ".GIF" || ext == ".TIF" || ext == ".TIFF") {
if(d.Accept()) {
if(StreamRaster::LoadFileAny(fn)) {
RichPara p;
p.Cat(CreateRawImageObject(LoadFile(fn)), formatinfo);
clip.Cat(p);
}
return true;
}
return false;
}
}
d.Reject();
}
if(d.Accept("text/QTF"))
clip = ParseQTF(~d, 0, context);
else