Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GHOST_DropTargetX11.h « intern « ghost « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0254139bcd820c615033c878702ae5033c22a30d (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
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
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2012 by the Blender Foundation.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): Sergey Sharybin.
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file ghost/intern/GHOST_DropTargetWin32.h
 *  \ingroup GHOST
 */

#ifndef __GHOST_DROPTARGETX11_H__
#define __GHOST_DROPTARGETX11_H__

#include <GHOST_Types.h>
#include "GHOST_WindowX11.h"
#include "GHOST_SystemX11.h"

#include "xdnd.h"

class GHOST_DropTargetX11
{
public:
	/**
	 * Constructor
	 *
	 * \param window	The window to register as drop target.
	 * \param system	The associated system.
	 */
	GHOST_DropTargetX11(GHOST_WindowX11 *window, GHOST_SystemX11 *system);

	/**
	 * Destructor
	 */
	~GHOST_DropTargetX11();

	/**
	 * Handler of ClientMessage X11 event
	 */
	bool GHOST_HandleClientMessage(XEvent *event);

	/**
	 * Get data to pass in event.
	 * It checks the type and calls specific functions for each type.
	 * \param dropType - type of dropped entity.
	 * \param dropBuffer - buffer returned from source application
	 * \param dropBufferSize - size of returned buffer
	 * \return Pointer to data.
	 */
	void *getGhostData(Atom dropType, unsigned char *dropBuffer, int dropBufferSize);

private:
	/* Internal helper functions */

	/**
	 * Initiailize XDND and all related X atoms
	 */
	void Initialize(void);

	/**
	 * Uninitiailize XDND and all related X atoms
	 */
	void Uninitialize(void);

	/**
	 * Get data to be passed to event from text/uri-list mime type
	 * \param dropBuffer - buffer returned from source application
	 * \param dropBufferSize - size of dropped buffer
	 * \return pointer to newly created GHOST data
	 */
	void *getURIListGhostData(unsigned char *dropBuffer, int dropBufferSize);

	/**
	 * Decode URL (i.e. converts "file:///a%20b/test" to "file:///a b/test")
	 * \param decodedOut - buffer for decoded URL
	 * \param bufferSize - size of output buffer
	 * \param encodedIn - input encoded buffer to be decoded
	 */
	void UrlDecode(char *decodedOut, int bufferSize, const char *encodedIn);

	/**
	 * Fully decode file URL (i.e. converts "file:///a%20b/test" to "/a b/test")
	 * \param fileUrl - file path URL to be fully decoded
	 * \return decoded file path (resutl shold be free-d)
	 */
	char *FileUrlDecode(char *fileUrl);

	/* The associated GHOST_WindowWin32. */
	GHOST_WindowX11 *m_window;
	/* The System. */
	GHOST_SystemX11 *m_system;

	/* Data type of the dragged object */
	GHOST_TDragnDropTypes m_draggedObjectType;

	/* is dnd stuff initialzied */
	static bool m_xdndInitialized;

	/* class holding internal stiff of xdnd library */
	static DndClass m_dndClass;

	/* list of supported types to eb draggeg into */
	static Atom *m_dndTypes;

	/* list of supported dran'n'drop actions */
	static Atom *m_dndActions;

	/* List of supported MIME types to be dragged into */
	static const char *m_dndMimeTypes[];

	/* counter of references to global XDND structures */
	static int m_refCounter;

#ifdef WITH_CXX_GUARDEDALLOC
	MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DropTargetX11")
#endif
};

#endif  // __GHOST_DROPTARGETX11_H__