예제 #1
0
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;
}
예제 #2
0
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;
}
예제 #3
0
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);
}
예제 #4
0
bool AcceptFiles(PasteClip& clip)
{
	if(clip.Accept("files")) {
		clip.SetAction(DND_COPY);
		return true;
	}
	return false;
}
예제 #5
0
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;
}
예제 #6
0
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();
}
예제 #7
0
bool AcceptImage(PasteClip& clip)
{
	GuiLock __;
	return clip.Accept(ClipFmtsImage());
}
예제 #8
0
bool AcceptText(PasteClip& clip)
{
	return clip.Accept(ClipFmtsText());
}