示例#1
0
void DockBase::GroupDrop(int parent, int ii, PasteClip& d)
{
	if (parent == 0) return d.Reject();

	TreeCtrl& tree = grouptab.grouptree;
	int p = tree.GetParent(parent);
	if (p != 0)	parent = p;
	
	if(AcceptInternal<TreeCtrl>(d, "DockCtrlGroupTreeDrag")) 
	{
		Vector<int> sel = tree.GetSel();
		for (int i = 0; i < sel.GetCount(); i++) 
		{

			int id = tree.Get(sel[i]);
			String group = (String) tree.GetValue(parent);
			if(group == t_("Default") || FindWidgetinGroup(group, id)) 
				return d.Reject();
			AddWidgettoGroup(group, id);
			tree.Open(parent);
		}
		return;
	}
	tree.SetFocus();
}
示例#2
0
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                       guint time, gpointer user_data, bool paste)
{
	DndTargets(context);
	g_object_ref(context); // make sure these always survive the action...
	g_object_ref(widget);
	dnd_context = context;
	dnd_widget = widget;
	dnd_time = time;
	PasteClip clip;
	clip.type = 1;
	clip.paste = paste;
	clip.accepted = false;
	clip.allowed = DND_MOVE|DND_COPY;
	gint dummy;
	GdkModifierType mod;
	gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod);
	clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE;
	Ctrl *w = DragWnd(user_data);
	if(w) {
		gint mx, my;
		GdkModifierType mod;
		gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod);
		CurrentState = mod;
		CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft();	
		w->DnD(CurrentMousePos, clip);
	}
	gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE
	                                                                          : GDK_ACTION_COPY
	                                           : GdkDragAction(0), time);
	return clip;
}
示例#3
0
void DndTest::DragAndDrop(Point p, PasteClip& d)
{
	if(d.IsAvailable("files")) {
		files = GetClipFiles(d.Get("files"));
		Refresh();
	}
}
示例#4
0
bool AcceptFiles(PasteClip& clip)
{
	if(clip.Accept("files")) {
		clip.SetAction(DND_COPY);
		return true;
	}
	return false;
}
示例#5
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;
}
示例#6
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;
}
示例#7
0
void DnDLoop::DnD(bool paste)
{
	PasteClip d;
	d.paste = paste;
	d.accepted = false;
	d.allowed = (byte)actions;
	d.action = GetCtrl() ? DND_COPY : DND_MOVE;
	d.dnd = true;
	if(target)
		target->DnD(GetMousePos(), d);
	action = d.IsAccepted() ? d.GetAction() : DND_NONE;
}
示例#8
0
gboolean Ctrl::GtkDragDrop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                           guint time, gpointer user_data)
{
	LLOG("GtkDragDrop");

	PasteClip clip = GtkDnd(widget, context, x, y, time, user_data, true);
	gtk_drag_finish(context, clip.IsAccepted(), clip.IsAccepted() && clip.GetAction() == DND_MOVE, time);
	g_object_unref(widget);
	g_object_unref(context);
	DnDLeave();
	return TRUE;
}
示例#9
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;
}
示例#10
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);
}
示例#11
0
void LineEdit::DragAndDrop(Point p, PasteClip& d)
{
	if(IsReadOnly()) return;
	int c = GetMousePos(p);
	if(AcceptText(d)) {
		NextUndo();
		int a = sb.y;
		int sell, selh;
		WString text = GetWString(d);
		if(GetSelection(sell, selh)) {
			if(c >= sell && c < selh) {
				if(!IsReadOnly())
					RemoveSelection();
				if(IsDragAndDropSource())
					d.SetAction(DND_COPY);
				c = sell;
			}
			else
			if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) {
				if(c > sell)
					c -= selh - sell;
				if(!IsReadOnly())
					RemoveSelection();
				d.SetAction(DND_COPY);
			}
		}
		int count = Insert(c, text);
		sb.y = a;
		SetFocus();
		SetSelection(c, c + count);
		Action();
		return;
	}
	if(!d.IsAccepted()) return;
	if(!isdrag) {
		isdrag = true;
		ScrollIntoCursor();
	}
	Point dc = Null;
	if(c >= 0)
		dc = GetColumnLine(c);
	if(dc != dropcaret) {
		RefreshDropCaret();
		dropcaret = dc;
		RefreshDropCaret();
	}
}
示例#12
0
void DocEdit::DragAndDrop(Point p, PasteClip& d)
{
	if(IsReadOnly()) return;
	int c = GetMousePos(p);
	if(AcceptText(d)) {
		NextUndo();
		int a = sb;
		int sell, selh;
		WString txt = GetWString(d);
		if(GetSelection(sell, selh)) {
			if(c >= sell && c < selh) {
				if(!IsReadOnly())
					RemoveSelection();
				if(IsDragAndDropSource())
					d.SetAction(DND_COPY);
				c = sell;
			}
			else
			if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) {
				if(c > sell)
					c -= selh - sell;
				if(!IsReadOnly())
					RemoveSelection();
				d.SetAction(DND_COPY);
			}
		}
		int count = Insert(c, txt);
		sb = a;
		SetFocus();
		SetSelection(c, c + count);
		Action();
		return;
	}
	if(!d.IsAccepted()) return;
	Point dc = Null;
	if(c >= 0) {
		Point cr = GetCaret(c);
		dc = Point(cr.x + 1, cr.y);
	}
	if(dc != dropcaret) {
		RefreshDropCaret();
		dropcaret = dc;
		RefreshDropCaret();
	}
}
示例#13
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();
}
示例#14
0
void Pdb::DropWatch(PasteClip& clip)
{
	String s = StringStream(GetString(clip)).GetLine();
	if(s.GetCount()) {
		watches.Add(s);
		clip.SetAction(DND_COPY);
		Data();
	}
}
示例#15
0
	void DropSum(int ii, PasteClip& d) {
		if(AcceptInternal<ColumnList>(d, "mydrag")) {
			const ColumnList& src = GetInternal<ColumnList>(d);
			int sum = 0;
			for(int i = 0; i < src.GetCount(); i++)
				if(src.IsSel(i))
					sum += atoi(~String(src[i]));
			list.Set(ii, AsString(sum));
			d.SetAction(DND_COPY);
			list.SetCursor(ii);
		}
	}
示例#16
0
void UDropTarget::DnD(POINTL pl, bool drop, DWORD *effect, DWORD keys)
{
    GuiLock __;
    LLOG("DnD effect: " << *effect);
    dword e = *effect;
    *effect = DROPEFFECT_NONE;
    if(!ctrl)
        return;
    PasteClip d;
    d.dt = this;
    d.paste = drop;
    d.accepted = false;
    d.allowed = 0;
    d.action = 0;
    if(e & DROPEFFECT_COPY) {
        LLOG("DnD DROPEFFECT_COPY");
        d.allowed = DND_COPY;
        d.action = DND_COPY;
    }
    if(e & DROPEFFECT_MOVE) {
        LLOG("DnD DROPEFFECT_MOVE");
        d.allowed |= DND_MOVE;
        if(Ctrl::GetDragAndDropSource())
            d.action = DND_MOVE;
    }
    LLOG("DnD keys & MK_CONTROL:" << (keys & MK_CONTROL));
    if((keys & MK_CONTROL) && (d.allowed & DND_COPY))
        d.action = DND_COPY;
    if((keys & (MK_ALT|MK_SHIFT)) && (d.allowed & DND_MOVE))
        d.action = DND_MOVE;
    ctrl->DnD(Point(pl.x, pl.y), d);
    if(d.IsAccepted()) {
        LLOG("DnD accepted, action: " << (int)d.action);
        if(d.action == DND_MOVE)
            *effect = DROPEFFECT_MOVE;
        if(d.action == DND_COPY)
            *effect = DROPEFFECT_COPY;
    }
}
示例#17
0
bool AcceptText(PasteClip& clip)
{
	return clip.Accept(ClipFmtsText());
}
示例#18
0
Vector<String> GetFiles(PasteClip& clip)
{
	GuiLock __;
	Vector<String> f;
	return GetClipFiles(clip.Get("files"));
}
示例#19
0
bool IsAvailableFiles(PasteClip& clip)
{
	return clip.IsAvailable("files");
}
示例#20
0
bool AcceptImage(PasteClip& clip)
{
	GuiLock __;
	return clip.Accept(ClipFmtsImage());
}