Merge remote-tracking branch 'remotes/origin/upstream'
[framework/uifw/elementary.git] / src / lib / elm_cnp.h
1 /**
2 <<<<<<< HEAD
3  * @addtogroup CopyPaste
4  * @{
5  */
6
7 typedef struct _Elm_Selection_Data Elm_Selection_Data;
8 typedef Eina_Bool                (*Elm_Drop_Cb)(void *d, Evas_Object *o, Elm_Selection_Data *data);
9
10 typedef enum
11 {
12    ELM_SEL_TYPE_PRIMARY,
13    ELM_SEL_TYPE_SECONDARY,
14    ELM_SEL_TYPE_CLIPBOARD,
15    ELM_SEL_TYPE_XDND,
16
17    ELM_SEL_TYPE_MAX,
18 } Elm_Sel_Type;
19
20 typedef enum
21 {
22    /** Targets: for matching every atom requesting */
23    ELM_SEL_FORMAT_TARGETS = -1,
24    /** they come from outside of elm */
25    ELM_SEL_FORMAT_NONE = 0x0,
26    /** Plain unformated text: Used for things that don't want rich markup */
27    ELM_SEL_FORMAT_TEXT = 0x01,
28    /** Edje textblock markup, including inline images */
29    ELM_SEL_FORMAT_MARKUP = 0x02,
30    /** Images */
31    ELM_SEL_FORMAT_IMAGE = 0x04,
32    /** Vcards */
33    ELM_SEL_FORMAT_VCARD = 0x08,
34    /** Raw HTMLish things for widgets that want that stuff (hello webkit!) */
35    ELM_SEL_FORMAT_HTML = 0x10,
36
37    ELM_SEL_FORMAT_MAX
38 } Elm_Sel_Format;
39
40 struct _Elm_Selection_Data
41 {
42    int            x, y;
43 =======
44  * @defgroup CopyPaste CopyPaste
45  *
46  * Implements the following functionality
47  *    a. select, copy/cut and paste
48  *    b. clipboard
49  *    c. drag and drop
50  * in order to share data across application windows.
51  *
52  * Contains functions to select text or a portion of data,
53  * send it to a buffer, and paste the data into a target.
54  *
55  * elm_cnp provides a generic copy and paste facility based on its windowing system.
56  * It is not necessary to know the details of each windowing system,
57  * but some terms and behavior are common.
58  * Currently the X11 window system is widely used, and only X11 functionality is implemented.
59  *
60  * In X11R6 window system, CopyPaste works like a peer-to-peer communication.
61  * Copying is an operation on an object in an X server.
62  * X11 calls those objects 'selections' which have names.
63  * Generally, two selection types are needed for copy and paste:
64  * The Primary selection and the Clipboard selection.
65  * Primary selection is for selecting text (that means highlighted text).
66  * Clipboard selection is for explicit copying behavior
67  * (such as ctrl+c, or 'copy' in a menu).
68  * Thus, in applications most cases only use the clipboard selection.
69  * As stated before, taking ownership of a selection doesn't move any actual data.
70  * Copying and Pasting is described as follows:
71  *  1. Copy text in Program A : Program A takes ownership of the selection
72  *  2. Paste text in Program B : Program B notes that Program A owns the selection
73  *  3. Program B asks A for the text
74  *  4. Program A responds and sends the text to program B
75  *  5. Program B pastes the response
76  * More information is on
77  *  - http://www.jwz.org/doc/x-cut-and-paste.html
78  *  - X11R6 Inter-Client Communication Conventions Manual, section 2
79  *
80  * TODO: add for other window system.
81  *
82  * @{
83  */
84
85 /**
86  * Defines the types of selection property names.
87  * @see http://www.x.org/docs/X11/xlib.pdf
88  * for more details.
89  */
90 typedef enum
91 {
92    ELM_SEL_TYPE_PRIMARY, /**< Primary text selection (highlighted or selected text) */
93    ELM_SEL_TYPE_SECONDARY, /**< Used when primary selection is in use */
94    ELM_SEL_TYPE_XDND, /**< Drag 'n' Drop */
95    ELM_SEL_TYPE_CLIPBOARD, /**< Clipboard selection (ctrl+C) */
96 } Elm_Sel_Type;
97
98 /**
99  * Defines the types of content.
100  */
101 typedef enum
102 {
103    /** For matching every possible atom */
104    ELM_SEL_FORMAT_TARGETS =   -1,
105    /** Content is from outside of Elementary */
106    ELM_SEL_FORMAT_NONE    =  0x0,
107    /** Plain unformatted text: Used for things that don't want rich markup */
108    ELM_SEL_FORMAT_TEXT    = 0x01,
109    /** Edje textblock markup, including inline images */
110    ELM_SEL_FORMAT_MARKUP  = 0x02,
111    /** Images */
112    ELM_SEL_FORMAT_IMAGE   = 0x04,
113    /** Vcards */
114    ELM_SEL_FORMAT_VCARD   = 0x08,
115    /** Raw HTML-like data (eg. webkit) */
116    ELM_SEL_FORMAT_HTML    = 0x10,
117 } Elm_Sel_Format;
118
119 /**
120  * Structure holding the info about selected data.
121  */
122 struct _Elm_Selection_Data
123 {
124    Evas_Coord     x, y;
125 >>>>>>> remotes/origin/upstream
126    Elm_Sel_Format format;
127    void          *data;
128    size_t         len;
129 };
130 <<<<<<< HEAD
131
132 /**
133  * @brief Set a data of a widget to copy and paste.
134  *
135  * Append the given callback to the list. This functions will be called
136  * called.
137  *
138  * @param selection selection type for copying and pasting
139  * @param widget The source widget pointer
140  * @param format Type of selection format
141  * @param buf The pointer of data source
142  * @return If EINA_TRUE, setting data is success.
143 =======
144 typedef struct _Elm_Selection_Data Elm_Selection_Data;
145
146 /**
147  * Callback invoked in when the selected data is 'dropped' at its destination.
148  *
149  * @param data Application specific data
150  * @param obj The evas object where selected data is 'dropped'.
151  * @param ev struct holding information about selected data
152  * FIXME: this should probably be a smart callback
153  */
154 typedef Eina_Bool (*Elm_Drop_Cb)(void *data, Evas_Object *obj, Elm_Selection_Data *ev);
155
156
157 /**
158  * @brief Set copy data for a widget.
159  *
160  * Set copy data and take ownership of selection. Format is used for specifying the selection type,
161  * and this is used during pasting.
162  *
163  * @param selection Selection type for copying and pasting
164  * @param obj The source widget pointer
165  * @param format Selection format
166  * @param buf The data selected
167  * @param buflen The size of @p buf
168  * @return If EINA_TRUE, setting data was successful.
169 >>>>>>> remotes/origin/upstream
170  *
171  * @ingroup CopyPaste
172  *
173  */
174 <<<<<<< HEAD
175
176 EAPI Eina_Bool elm_cnp_selection_set(Elm_Sel_Type selection, Evas_Object *widget, Elm_Sel_Format format, const void *buf, size_t buflen);
177
178 /**
179  * @brief Retrive the data from the widget which is set for copying and pasting.
180  *
181  * Getting the data from the widget which is set for copying and pasting.
182  * Mainly the widget is elm_entry. If then @p datacb and @p udata are
183  * can be NULL. If not, @p datacb and @p udata are used for retriving data.
184  *
185  * @see also elm_cnp_selection_set()
186  *
187  * @param selection selection type for copying and pasting
188  * @param widget The source widget pointer
189  * @param datacb The user data callback if the target widget isn't elm_entry
190  * @param udata The user data pointer for @p datacb
191  * @return If EINA_TRUE, getting data is success.
192  *
193  * @ingroup CopyPaste
194  *
195  */
196
197 EAPI Eina_Bool elm_cnp_selection_get(Elm_Sel_Type selection, Elm_Sel_Format format, Evas_Object *widget, Elm_Drop_Cb datacb, void *udata);
198
199 /**
200  * @brief Clear the data in the widget which is set for copying and pasting.
201  *
202  * Clear the data in the widget. Normally this function isn't need to call.
203  *
204  * @see also elm_cnp_selection_set()
205  *
206  * @param selection selection type for copying and pasting
207  * @param widget The source widget pointer
208  * @return If EINA_TRUE, clearing data is success.
209 =======
210 EAPI Eina_Bool elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
211                                      Elm_Sel_Format format,
212                                      const void *buf, size_t buflen);
213
214 /**
215  * @brief Retrieve data from a widget that has a selection.
216  *
217  * Gets the current selection data from a widget.
218  * The widget input here will usually be elm_entry,
219  * in which case @p datacb and @p udata can be NULL.
220  * If a different widget is passed, @p datacb and @p udata are used for retrieving data.
221  *
222  * @see also elm_cnp_selection_set()
223  *
224  * @param selection Selection type for copying and pasting
225  * @param format Selection format
226  * @param obj The source widget
227  * @param datacb The user data callback if the target widget isn't elm_entry
228  * @param udata The user data pointer for @p datacb
229  * @return If EINA_TRUE, getting selection data was successful.
230  *
231  * @ingroup CopyPaste
232  */
233 EAPI Eina_Bool elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection,
234                                      Elm_Sel_Format format,
235                                      Elm_Drop_Cb datacb, void *udata);
236
237 /**
238  * @brief Clear the selection data of a widget.
239  *
240  * Clear all data from the selection which is owned by a widget.
241  *
242  * @see also elm_cnp_selection_set()
243  *
244  * @param obj The source widget
245  * @param selection Selection type for copying and pasting
246  * @return If EINA_TRUE, clearing data was successful.
247 >>>>>>> remotes/origin/upstream
248  *
249  * @ingroup CopyPaste
250  *
251  */
252 <<<<<<< HEAD
253
254 EAPI Eina_Bool elm_cnp_selection_clear(Elm_Sel_Type selection, Evas_Object *widget);
255 =======
256 EAPI Eina_Bool elm_object_cnp_selection_clear(Evas_Object *obj,
257                                               Elm_Sel_Type selection);
258 >>>>>>> remotes/origin/upstream
259
260 /**
261  * @}
262  */