1 | /* $Id: VBoxDnD.h 49947 2013-12-17 08:40:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxDnD.h - Windows-specific bits of the drag'n drop service.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef __VBOXTRAYDND__H
|
---|
19 | #define __VBOXTRAYDND__H
|
---|
20 |
|
---|
21 | #include <iprt/cpp/mtlist.h>
|
---|
22 | #include <iprt/cpp/ministring.h>
|
---|
23 |
|
---|
24 | int VBoxDnDInit (const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread);
|
---|
25 | unsigned __stdcall VBoxDnDThread (void *pInstance);
|
---|
26 | void VBoxDnDStop (const VBOXSERVICEENV *pEnv, void *pInstance);
|
---|
27 | void VBoxDnDDestroy (const VBOXSERVICEENV *pEnv, void *pInstance);
|
---|
28 |
|
---|
29 | class VBoxDnDWnd;
|
---|
30 |
|
---|
31 | class VBoxDnDDataObject : public IDataObject
|
---|
32 | {
|
---|
33 | public:
|
---|
34 |
|
---|
35 | enum Status
|
---|
36 | {
|
---|
37 | Uninitialized = 0,
|
---|
38 | Initialized,
|
---|
39 | Dropping,
|
---|
40 | Dropped,
|
---|
41 | Aborted
|
---|
42 | };
|
---|
43 |
|
---|
44 | public:
|
---|
45 |
|
---|
46 | VBoxDnDDataObject(FORMATETC *pFormatEtc = NULL, STGMEDIUM *pStgMed = NULL, ULONG cFormats = 0);
|
---|
47 | virtual ~VBoxDnDDataObject(void);
|
---|
48 |
|
---|
49 | public:
|
---|
50 |
|
---|
51 | static int CreateDataObject(FORMATETC *pFormatEtc, STGMEDIUM *pStgMeds,
|
---|
52 | ULONG cFormats, IDataObject **ppDataObject);
|
---|
53 | public: /* IUnknown methods. */
|
---|
54 |
|
---|
55 | STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
|
---|
56 | STDMETHOD_(ULONG, AddRef)(void);
|
---|
57 | STDMETHOD_(ULONG, Release)(void);
|
---|
58 |
|
---|
59 | public: /* IDataObject methods. */
|
---|
60 |
|
---|
61 | STDMETHOD(GetData)(FORMATETC *pFormatEtc, STGMEDIUM *pMedium);
|
---|
62 | STDMETHOD(GetDataHere)(FORMATETC *pFormatEtc, STGMEDIUM *pMedium);
|
---|
63 | STDMETHOD(QueryGetData)(FORMATETC *pFormatEtc);
|
---|
64 | STDMETHOD(GetCanonicalFormatEtc)(FORMATETC *pFormatEct, FORMATETC *pFormatEtcOut);
|
---|
65 | STDMETHOD(SetData)(FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease);
|
---|
66 | STDMETHOD(EnumFormatEtc)(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc);
|
---|
67 | STDMETHOD(DAdvise)(FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection);
|
---|
68 | STDMETHOD(DUnadvise)(DWORD dwConnection);
|
---|
69 | STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppEnumAdvise);
|
---|
70 |
|
---|
71 | public:
|
---|
72 |
|
---|
73 | static const char* ClipboardFormatToString(CLIPFORMAT fmt);
|
---|
74 |
|
---|
75 | int Abort(void);
|
---|
76 | void SetStatus(Status status);
|
---|
77 | int Signal(const RTCString &strFormat, const void *pvData, uint32_t cbData);
|
---|
78 |
|
---|
79 | protected:
|
---|
80 |
|
---|
81 | bool LookupFormatEtc(FORMATETC *pFormatEtc, ULONG *puIndex);
|
---|
82 | static HGLOBAL MemDup(HGLOBAL hMemSource);
|
---|
83 | void RegisterFormat(FORMATETC *pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL,
|
---|
84 | LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL);
|
---|
85 |
|
---|
86 | Status mStatus;
|
---|
87 | LONG mRefCount;
|
---|
88 | ULONG mcFormats;
|
---|
89 | FORMATETC *mpFormatEtc;
|
---|
90 | STGMEDIUM *mpStgMedium;
|
---|
91 | RTSEMEVENT mSemEvent;
|
---|
92 | RTCString mstrFormat;
|
---|
93 | void *mpvData;
|
---|
94 | uint32_t mcbData;
|
---|
95 | };
|
---|
96 |
|
---|
97 | class VBoxDnDDropSource : public IDropSource
|
---|
98 | {
|
---|
99 | public:
|
---|
100 |
|
---|
101 | VBoxDnDDropSource(VBoxDnDWnd *pThis);
|
---|
102 | virtual ~VBoxDnDDropSource(void);
|
---|
103 |
|
---|
104 | public:
|
---|
105 |
|
---|
106 | static int CreateDropSource(VBoxDnDWnd *pParent, IDropSource **ppDropSource);
|
---|
107 |
|
---|
108 | public:
|
---|
109 |
|
---|
110 | uint32_t GetCurrentAction(void) { return muCurAction; }
|
---|
111 |
|
---|
112 | public: /* IUnknown methods. */
|
---|
113 |
|
---|
114 | STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
|
---|
115 | STDMETHOD_(ULONG, AddRef)(void);
|
---|
116 | STDMETHOD_(ULONG, Release)(void);
|
---|
117 |
|
---|
118 | public: /* IDropSource methods. */
|
---|
119 |
|
---|
120 | STDMETHOD(QueryContinueDrag)(BOOL fEscapePressed, DWORD dwKeyState);
|
---|
121 | STDMETHOD(GiveFeedback)(DWORD dwEffect);
|
---|
122 |
|
---|
123 | protected:
|
---|
124 |
|
---|
125 | LONG mRefCount;
|
---|
126 | VBoxDnDWnd *mpWndParent;
|
---|
127 | uint32_t mClientID;
|
---|
128 | DWORD mdwCurEffect;
|
---|
129 | uint32_t muCurAction;
|
---|
130 | };
|
---|
131 |
|
---|
132 | class VBoxDnDEnumFormatEtc : public IEnumFORMATETC
|
---|
133 | {
|
---|
134 | public:
|
---|
135 |
|
---|
136 | VBoxDnDEnumFormatEtc(FORMATETC *pFormatEtc, ULONG cFormats);
|
---|
137 | virtual ~VBoxDnDEnumFormatEtc(void);
|
---|
138 |
|
---|
139 | public:
|
---|
140 |
|
---|
141 | STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject);
|
---|
142 | STDMETHOD_(ULONG, AddRef)(void);
|
---|
143 | STDMETHOD_(ULONG, Release)(void);
|
---|
144 |
|
---|
145 | STDMETHOD(Next)(ULONG cFormats, FORMATETC *pFormatEtc, ULONG *pcFetched);
|
---|
146 | STDMETHOD(Skip)(ULONG cFormats);
|
---|
147 | STDMETHOD(Reset)(void);
|
---|
148 | STDMETHOD(Clone)(IEnumFORMATETC ** ppEnumFormatEtc);
|
---|
149 |
|
---|
150 | public:
|
---|
151 |
|
---|
152 | static void CopyFormat(FORMATETC *pFormatDest, FORMATETC *pFormatSource);
|
---|
153 | static HRESULT CreateEnumFormatEtc(UINT cFormats, FORMATETC *pFormatEtc, IEnumFORMATETC **ppEnumFormatEtc);
|
---|
154 |
|
---|
155 | private:
|
---|
156 |
|
---|
157 | LONG m_lRefCount;
|
---|
158 | ULONG m_nIndex;
|
---|
159 | ULONG m_nNumFormats;
|
---|
160 | FORMATETC * m_pFormatEtc;
|
---|
161 | };
|
---|
162 | #endif /* __VBOXTRAYDND__H */
|
---|
163 |
|
---|