WString GetWString(PasteClip& clip) { GuiLock __; if(clip.Accept("wtext")) { String s = ~clip; return WString((const wchar *)~s, wstrlen((const wchar *)~s)); } if(clip.Accept("text")) return (~clip).ToWString(); return Null; }
Image GetImage(PasteClip& clip) { GuiLock __; Image m; if(Accept<Image>(clip)) { LoadFromString(m, ~clip); if(!m.IsEmpty()) return m; } if(clip.Accept("dib")) { String data = ~clip; if((unsigned)data.GetCount() < sizeof(BITMAPINFO)) return Null; BITMAPINFO *lpBI = (BITMAPINFO *)~data; BITMAPINFOHEADER& hdr = lpBI->bmiHeader; byte *bits = (byte *)lpBI + hdr.biSize; if(hdr.biBitCount <= 8) bits += (hdr.biClrUsed ? hdr.biClrUsed : 1 << hdr.biBitCount) * sizeof(RGBQUAD); if(hdr.biBitCount >= 16 || hdr.biBitCount == 32) { if(hdr.biCompression == 3) bits += 12; if(hdr.biClrUsed != 0) bits += hdr.biClrUsed * sizeof(RGBQUAD); } int h = abs((int)hdr.biHeight); ImageDraw iw(hdr.biWidth, h); ::StretchDIBits(iw.GetHandle(), 0, 0, hdr.biWidth, h, 0, 0, hdr.biWidth, h, bits, lpBI, DIB_RGB_COLORS, SRCCOPY); return iw; } return Null; }
void WorkspaceWork::DnDInsert(int line, PasteClip& d) { if(GetActivePackage() == METAPACKAGE) return; if(GetInternalPtr<UppList>(d, "package-file") == &filelist && d.Accept()) DoMove(line < fileindex.GetCount() ? fileindex[line] : actual.file.GetCount(), true); }
bool AcceptFiles(PasteClip& clip) { if(clip.Accept("files")) { clip.SetAction(DND_COPY); return true; } return false; }
String GetString(PasteClip& clip) { GuiLock __; if(clip.Accept("wtext")) { String s = ~clip; return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString(); } if(clip.IsAvailable("text")) return ~clip; return Null; }
void MyApp::DragAndDrop(Point p, PasteClip& clip) { if(clip.Accept("MyAppData")) { String bin = clip; if(bin.GetLength() > sizeof(Color)) { // prudent check pos = p; memcpy(&data.color, ~bin, sizeof(Color)); data.text = bin.Mid(sizeof(Color)); } Refresh(); } if(AcceptText(clip)) { pos = p; data.text = GetString(clip); } dragpos = clip.IsAccepted() ? p : Null; Refresh(); }
bool AcceptImage(PasteClip& clip) { GuiLock __; return clip.Accept(ClipFmtsImage()); }
bool AcceptText(PasteClip& clip) { return clip.Accept(ClipFmtsText()); }