blob: bea7736b7dc1f3b98ee420e5f31b38ea9c1d8ecb (
plain)
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
|
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <assert.h>
#include "ecore_win32_dnd_drop_source.h"
#include "ecore_win32_private.h"
// structors
// reference count must ALWAYS start at 1
DropSource::DropSource() : ref_count_(1)
{ }
// IUnknown
HRESULT DropSource::QueryInterface(REFIID iid, void **ppvObject)
{
// check to see what interface has been requested
if (iid == IID_IDropSource || iid == IID_IUnknown)
{
AddRef();
*ppvObject = this;
return S_OK;
}
*ppvObject = 0;
return E_NOINTERFACE;
}
ULONG DropSource::AddRef()
{
return InterlockedIncrement(&ref_count_);
}
ULONG DropSource::Release()
{
LONG count = InterlockedDecrement(&ref_count_);
if(count == 0)
{
delete this;
return 0;
}
return count;
}
// IDropSource
HRESULT DropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
{
// if the Escape key has been pressed since the last call, cancel the drop
if(fEscapePressed == TRUE)
return DRAGDROP_S_CANCEL;
// if the LeftMouse button has been released, then do the drop!
if((grfKeyState & MK_LBUTTON) == 0)
return DRAGDROP_S_DROP;
// continue with the drag-drop
return S_OK;
}
HRESULT DropSource::GiveFeedback(DWORD dwEffect __UNUSED__)
{
return DRAGDROP_S_USEDEFAULTCURSORS;
}
// ecore_win32 private functions
void *_ecore_win32_dnd_drop_source_new()
{
IDropSource *object = new DropSource();
assert(object != NULL);
return object;
}
void _ecore_win32_dnd_drop_source_free(void *drop_source)
{
if (!drop_source)
return;
IDropSource *object = (IDropSource *)drop_source;
object->Release();
}
|