My favorites
▼
|
Sign in
upp-mirror
U++ is the C++ development platform
Project Home
Downloads
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
reference
/
Framebuffer
/
DnD.cpp
r5017
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "Fb.h"
#ifdef GUI_FB
NAMESPACE_UPP
#define LLOG(x) // DLOG(x)
// --------------------------------------------------------------------------------------------
Ptr<Ctrl> sDnDSource;
Ctrl * Ctrl::GetDragAndDropSource()
{
return sDnDSource;
}
struct DnDLoop : LocalLoop {
const VectorMap<String, ClipData> *data;
Vector<String> fmts;
Image move, copy, reject;
Ptr<Ctrl> target;
int action;
byte actions;
void Sync();
String GetData(const String& f);
void DnD(bool paste);
virtual void LeftUp(Point, dword);
virtual bool Key(dword, int);
virtual void MouseMove(Point p, dword);
virtual Image CursorImage(Point, dword);
};
Ptr<DnDLoop> dndloop;
bool PasteClip::IsAvailable(const char *fmt) const
{
GuiLock __;
return dnd ? dndloop && FindIndex(dndloop->fmts, fmt) >= 0
: IsClipboardAvailable(fmt);
}
String DnDLoop::GetData(const String& f)
{
GuiLock __;
int i = data->Find(f);
String d;
if(i >= 0)
d = (*data)[i].Render();
else
if(sDnDSource)
d = sDnDSource->GetDropData(f);
return d;
}
String PasteClip::Get(const char *fmt) const
{
return dnd ? dndloop ? dndloop->GetData(fmt) : String() : ReadClipboard(fmt);
}
void PasteClip::GuiPlatformConstruct()
{
dnd = false;
}
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;
}
void DnDLoop::Sync()
{
GuiLock __;
Ptr<Ctrl> t = FindMouseTopCtrl();
if(t != target)
if(target)
target->DnDLeave();
target = t;
DnD(false);
}
void DnDLoop::LeftUp(Point, dword)
{
GuiLock __;
LLOG("DnDLoop::LeftUp");
DnD(true);
EndLoop();
}
void DnDLoop::MouseMove(Point p, dword)
{
GuiLock __;
LLOG("DnDLoop::MouseMove");
Sync();
}
bool DnDLoop::Key(dword, int)
{
GuiLock __;
LLOG("DnDLoop::Key");
Sync();
return false;
}
Image DnDLoop::CursorImage(Point, dword)
{
GuiLock __;
return action == DND_MOVE ? move : action == DND_COPY ? copy : reject;
}
int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
const VectorMap<String, ClipData>& data)
{
GuiLock __;
DnDLoop d;
d.actions = (byte)actions;
d.reject = actions & DND_EXACTIMAGE ? CtrlCoreImg::DndNone() : MakeDragImage(CtrlCoreImg::DndNone(), sample);
if(actions & DND_COPY)
d.copy = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndCopy(), sample);
if(actions & DND_MOVE)
d.move = actions & DND_EXACTIMAGE ? sample : MakeDragImage(CtrlCoreImg::DndMoveX11(), sample);
d.SetMaster(*this);
d.data = &data;
d.action = DND_NONE;
d.fmts = Split(fmts, ';');
dndloop = &d;
sDnDSource = this;
d.Run();
sDnDSource = NULL;
SyncCaret();
LLOG("DoDragAndDrop finished");
return d.action;
}
void Ctrl::SetSelectionSource(const char *fmts) {}
END_UPP_NAMESPACE
#endif
Show details
Hide details
Change log
r4176
by cxl on Nov 16, 2011
Diff
.reference: Rainbow example (RM #158)
Go to:
/trunk/reference/Framebuffer
...nk/reference/Framebuffer/After.h
...erence/Framebuffer/ChSysInit.cpp
...k/reference/Framebuffer/Clip.cpp
...k/reference/Framebuffer/Ctrl.cpp
/trunk/reference/Framebuffer/Ctrl.h
...nk/reference/Framebuffer/DnD.cpp
...k/reference/Framebuffer/Draw.cpp
.../reference/Framebuffer/Event.cpp
/trunk/reference/Framebuffer/FB.iml
/trunk/reference/Framebuffer/Fb.h
...erence/Framebuffer/Framebuffer.h
...ence/Framebuffer/Framebuffer.upp
/trunk/reference/Framebuffer/Gui.h
.../reference/Framebuffer/Image.cpp
...nk/reference/Framebuffer/Top.cpp
/trunk/reference/Framebuffer/Top.h
...ference/Framebuffer/TopFrame.cpp
...k/reference/Framebuffer/Util.cpp
...nk/reference/Framebuffer/Wnd.cpp
/trunk/reference/Framebuffer/init
/trunk/reference/LinuxFb
/trunk/reference/LinuxFb/Keys.h
/trunk/reference/LinuxFb/LinuxFb.h
...nk/reference/LinuxFb/LinuxFb.upp
...reference/LinuxFb/LinuxFbLocal.h
/trunk/reference/LinuxFb/Local.h
/trunk/reference/LinuxFb/Proc.cpp
/trunk/reference/LinuxFb/Win.cpp
/trunk/reference/LinuxFb/init
/trunk/reference/LinuxFb/keymap.cpp
.../reference/LinuxFb/vgakeyboard.h
/trunk/reference/UWord_FB
/trunk/reference/UWord_FB/UWord.cpp
/trunk/reference/UWord_FB/UWord.iml
.../reference/UWord_FB/UWord_FB.upp
/trunk/reference/UWord_FB/icon.ico
/trunk/reference/UWord_FB/init
/trunk/reference/WinFb
/trunk/reference/WinFb/Keys.h
/trunk/reference/WinFb/Local.h
/trunk/reference/WinFb/Proc.cpp
/trunk/reference/WinFb/Win.cpp
/trunk/reference/WinFb/WinFb.h
/trunk/reference/WinFb/WinFb.upp
/trunk/reference/WinFb/init
/trunk/reference/guiplatform.h
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 3100 bytes, 150 lines
View raw file
Powered by
Google Project Hosting