33f2613c15bf04f0a8d39d8f9c49533c4884709c
[platform/upstream/enlightenment.git] / src / bin / e_dnd.h
1 #ifdef E_TYPEDEFS
2
3 typedef enum _E_Drag_Type
4 {
5    E_DRAG_NONE,
6    E_DRAG_INTERNAL,
7    E_DRAG_XDND
8 } E_Drag_Type;
9
10 typedef struct _E_Drag            E_Drag;
11 typedef struct _E_Drop_Handler    E_Drop_Handler;
12 typedef struct _E_Event_Dnd_Enter E_Event_Dnd_Enter;
13 typedef struct _E_Event_Dnd_Move  E_Event_Dnd_Move;
14 typedef struct _E_Event_Dnd_Leave E_Event_Dnd_Leave;
15 typedef struct _E_Event_Dnd_Drop  E_Event_Dnd_Drop;
16 typedef struct E_Dnd_X_Moz_Url    E_Dnd_X_Moz_Url;
17
18 #else
19 #ifndef E_DND_H
20 #define E_DND_H
21
22 #define E_DRAG_TYPE 0xE0b0100f
23
24 struct _E_Drag
25 {
26    E_Object           e_obj_inherit;
27
28    void              *data;
29    int                data_size;
30
31    E_Drag_Type        type;
32
33    struct
34    {
35       void *(*convert)(E_Drag * drag, const char *type);
36       void  (*finished)(E_Drag *drag, int dropped);
37       void  (*key_down)(E_Drag *drag, Ecore_Event_Key *e);
38       void  (*key_up)(E_Drag *drag, Ecore_Event_Key *e);
39    } cb;
40
41    E_Comp           *comp;
42    Evas              *evas;
43    Evas_Object       *comp_object;
44    Evas_Object       *object;
45
46    int                x, y, w, h;
47    int                dx, dy;
48
49    E_Layer            layer;
50    unsigned char      visible : 1;
51
52    unsigned int       num_types;
53    const char        *types[];
54 };
55
56 struct _E_Drop_Handler
57 {
58    struct
59    {
60       void  (*enter)(void *data, const char *type, void *event);
61       void  (*move)(void *data, const char *type, void *event);
62       void  (*leave)(void *data, const char *type, void *event);
63       void  (*drop)(void *data, const char *type, void *event);
64       Eina_Bool (*xds)(void *data, const char *type);
65       void *data;
66    } cb;
67
68    E_Object     *obj;
69    Evas_Object *base;
70    int           x, y, w, h;
71
72    const char   *active_type;
73    Eina_Bool active : 1;
74    Eina_Bool entered : 1;
75    Eina_Bool hidden : 1;
76    unsigned int  num_types;
77    Eina_Stringshare *types[];
78 };
79
80 struct _E_Event_Dnd_Enter
81 {
82    void        *data;
83    int          x, y;
84    Ecore_X_Atom action;
85 };
86
87 struct _E_Event_Dnd_Move
88 {
89    int          x, y;
90    Ecore_X_Atom action;
91 };
92
93 struct _E_Event_Dnd_Leave
94 {
95    int x, y;
96 };
97
98 struct _E_Event_Dnd_Drop
99 {
100    void *data;
101    int   x, y;
102 };
103
104 struct E_Dnd_X_Moz_Url
105 {
106    Eina_Inarray *links;
107    Eina_Inarray *link_names;
108 };
109
110 EINTERN int          e_dnd_init(void);
111 EINTERN int          e_dnd_shutdown(void);
112
113 EAPI int             e_dnd_active(void);
114
115 /* x and y are the top left coords of the object that is to be dragged */
116 EAPI E_Drag         *e_drag_new(E_Comp *comp, int x, int y,
117                                 const char **types, unsigned int num_types,
118                                 void *data, int size,
119                                 void *(*convert_cb)(E_Drag * drag, const char *type),
120                                 void (*finished_cb)(E_Drag *drag, int dropped));
121 EAPI Evas           *e_drag_evas_get(const E_Drag *drag);
122 EAPI void            e_drag_object_set(E_Drag *drag, Evas_Object *object);
123 EAPI void            e_drag_move(E_Drag *drag, int x, int y);
124 EAPI void            e_drag_resize(E_Drag *drag, int w, int h);
125 EAPI void            e_drag_key_down_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e));
126 EAPI void            e_drag_key_up_cb_set(E_Drag *drag, void (*func)(E_Drag *drag, Ecore_Event_Key *e));
127
128 /* x and y are the coords where the mouse is when dragging starts */
129 EAPI int             e_drag_start(E_Drag *drag, int x, int y);
130 EAPI int             e_drag_xdnd_start(E_Drag *drag, int x, int y);
131
132 EAPI void e_drop_xds_update(Eina_Bool enable, const char *value);
133 EAPI void e_drop_handler_xds_set(E_Drop_Handler *handler, Eina_Bool (*cb)(void *data, const char *type));
134 EAPI E_Drop_Handler *e_drop_handler_add(E_Object *obj,
135                                         void *data,
136                                         void (*enter_cb)(void *data, const char *type, void *event),
137                                         void (*move_cb)(void *data, const char *type, void *event),
138                                         void (*leave_cb)(void *data, const char *type, void *event),
139                                         void (*drop_cb)(void *data, const char *type, void *event),
140                                         const char **types, unsigned int num_types,
141                                         int x, int y, int w, int h);
142 EAPI void         e_drop_handler_geometry_set(E_Drop_Handler *handler, int x, int y, int w, int h);
143 EAPI int          e_drop_inside(const E_Drop_Handler *handler, int x, int y);
144 EAPI void         e_drop_handler_del(E_Drop_Handler *handler);
145 EAPI int          e_drop_xdnd_register_set(Ecore_X_Window win, int reg);
146 EAPI void         e_drop_handler_responsive_set(E_Drop_Handler *handler);
147 EAPI int          e_drop_handler_responsive_get(const E_Drop_Handler *handler);
148 EAPI void         e_drop_handler_action_set(Ecore_X_Atom action);
149 EAPI Ecore_X_Atom e_drop_handler_action_get(void);
150 EAPI Eina_List *e_dnd_util_text_uri_list_convert(char *data, int size);
151
152
153 static inline void
154 e_drag_show(E_Drag *drag)
155 {
156    drag->visible = 1;
157 }
158
159 static inline void
160 e_drag_hide(E_Drag *drag)
161 {
162    drag->visible = 0;
163 }
164
165 #endif
166 #endif