[EFL][WK2] Support Context Menu
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / efl / ewk_context_menu_item.h
1 /*
2  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 /**
27  * @file    ewk_context_menu_item.h
28  * @brief   Describes the Ewk Context Menu Item API.
29  */
30
31 #ifndef ewk_context_menu_item_h
32 #define ewk_context_menu_item_h
33
34 #include "ewk_defines.h"
35 #include <Eina.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /**
42  * \enum    Ewk_Context_Menu_Item_Type
43  * @brief   Defines the types of the items for the context menu.
44  * @info    Keep this in sync with ContextMenuItem.h
45  */
46 typedef enum {
47     EWK_ACTION_TYPE,
48     EWK_CHECKABLE_ACTION_TYPE,
49     EWK_SEPARATOR_TYPE,
50     EWK_SUBMENU_TYPE
51 } Ewk_Context_Menu_Item_Type;
52
53 /**
54  * \enum    Ewk_Context_Menu_Action
55  * @brief   Provides the actions of items for the context menu.
56  * @info    Keep this in sync with ContextMenuItem.h
57  */
58 typedef enum {
59     EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION,
60     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW,
61     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK,
62     EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD,
63     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW,
64     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK,
65     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD,
66     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_URL_TO_CLIPBOARD,
67     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW,
68     EWK_CONTEXT_MENU_ITEM_TAG_COPY,
69     EWK_CONTEXT_MENU_ITEM_TAG_GO_BACK,
70     EWK_CONTEXT_MENU_ITEM_TAG_GO_FORWARD,
71     EWK_CONTEXT_MENU_ITEM_TAG_STOP,
72     EWK_CONTEXT_MENU_ITEM_TAG_RELOAD,
73     EWK_CONTEXT_MENU_ITEM_TAG_CUT,
74     EWK_CONTEXT_MENU_ITEM_TAG_PASTE,
75     EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL,
76     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_GUESS,
77     EWK_CONTEXT_MENU_ITEM_TAG_NO_GUESSES_FOUND,
78     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING,
79     EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING,
80     EWK_CONTEXT_MENU_ITEM_TAG_OTHER,
81     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_IN_SPOTLIGHT,
82     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB,
83     EWK_CONTEXT_MENU_ITEM_TAG_LOOK_UP_IN_DICTIONARY,
84     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_WITH_DEFAULT_APPLICATION,
85     EWK_CONTEXT_MENU_ITEM_PDFACTUAL_SIZE,
86     EWK_CONTEXT_MENU_ITEM_PDFZOOM_IN,
87     EWK_CONTEXT_MENU_ITEM_PDFZOOM_OUT,
88     EWK_CONTEXT_MENU_ITEM_PDFAUTO_SIZE,
89     EWK_CONTEXT_MENU_ITEM_PDFSINGLE_PAGE,
90     EWK_CONTEXT_MENU_ITEM_PDFFACING_PAGES,
91     EWK_CONTEXT_MENU_ITEM_PDFCONTINUOUS,
92     EWK_CONTEXT_MENU_ITEM_PDFNEXT_PAGE,
93     EWK_CONTEXT_MENU_ITEM_PDFPREVIOUS_PAGE,
94     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK = 2000,
95     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_GRAMMAR,
96     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, /**< spelling or spelling/grammar sub-menu */
97     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_SPELLING_PANEL,
98     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING,
99     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING,
100     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_GRAMMAR_WITH_SPELLING,
101     EWK_CONTEXT_MENU_ITEM_TAG_FONT_MENU, /**< font sub-menu */
102     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_FONTS,
103     EWK_CONTEXT_MENU_ITEM_TAG_BOLD,
104     EWK_CONTEXT_MENU_ITEM_TAG_ITALIC,
105     EWK_CONTEXT_MENU_ITEM_TAG_UNDERLINE,
106     EWK_CONTEXT_MENU_ITEM_TAG_OUTLINE,
107     EWK_CONTEXT_MENU_ITEM_TAG_STYLES,
108     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_COLORS,
109     EWK_CONTEXT_MENU_ITEM_TAG_SPEECH_MENU, /**< speech sub-menu */
110     EWK_CONTEXT_MENU_ITEM_TAG_START_SPEAKING,
111     EWK_CONTEXT_MENU_ITEM_TAG_STOP_SPEAKING,
112     EWK_CONTEXT_MENU_ITEM_TAG_WRITING_DIRECTION_MENU, /**< writing direction sub-menu */
113     EWK_CONTEXT_MENU_ITEM_TAG_DEFAULT_DIRECTION,
114     EWK_CONTEXT_MENU_ITEM_TAG_LEFT_TO_RIGHT,
115     EWK_CONTEXT_MENU_ITEM_TAG_RIGHT_TO_LEFT,
116     EWK_CONTEXT_MENU_ITEM_TAG_PDFSINGLE_PAGE_SCROLLING,
117     EWK_CONTEXT_MENU_ITEM_TAG_PDFFACING_PAGES_SCROLLING,
118     EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT,
119     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_MENU, /**< text direction sub-menu */
120     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_DEFAULT,
121     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_LEFT_TO_RIGHT,
122     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_RIGHT_TO_LEFT,
123     EWK_CONTEXT_MENU_ITEM_OPEN_MEDIA_IN_NEW_WINDOW,
124     EWK_CONTEXT_MENU_ITEM_TAG_COPY_MEDIA_LINK_TO_CLIPBOARD,
125     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_CONTROLS,
126     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_LOOP,
127     EWK_CONTEXT_MENU_ITEM_TAG_ENTER_VIDEO_FULLSCREEN,
128     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_PLAY_PAUSE,
129     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_MUTE,
130     EWK_CONTEXT_MENU_ITEM_BASE_CUSTOM_TAG = 5000,
131     EWK_CONTEXT_MENU_ITEM_CUSTOM_TAG_NO_ACTION = 5998,
132     EWK_CONTEXT_MENU_ITEM_LAST_CUSTOM_TAG = 5999,
133     EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG = 10000
134 } Ewk_Context_Menu_Item_Action;
135
136 /**
137  * Creates a new item of the context menu.
138  *
139  * @param type specifies a type of the item
140  * @param action specifies a action of the item
141  * @param title specifies a title of the item
142  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
143  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
144  * @return the pointer to the new item
145  *
146  * @see ewk_context_menu_item_new_with_submenu
147  */
148 EAPI Ewk_Context_Menu_Item *ewk_context_menu_item_new(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char *title, Eina_Bool checked, Eina_Bool enabled);
149
150 /**
151  * Creates a new item of the context menu.
152  *
153  * @param type specifies a type of the item
154  * @param action specifies a action of the item
155  * @param title specifies a title of the item
156  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
157  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
158  * @param submenu specifies a submenu of the item
159  * @return the pointer to the new item
160  *
161  * @see ewk_context_menu_item_new
162  */
163 EAPI Ewk_Context_Menu_Item *ewk_context_menu_item_new_with_submenu(Ewk_Context_Menu_Item_Type type, Ewk_Context_Menu_Item_Action action, const char *title, Eina_Bool checked, Eina_Bool enabled, Ewk_Context_Menu *submenu);
164
165 /**
166  * Gets type of the item.
167  *
168  * @param o the item to get the type
169  * @return type of the item on success or @c EWK_ACTION_TYPE on failure
170  *
171  * @see ewk_context_menu_item_type_set
172  */
173 EAPI Ewk_Context_Menu_Item_Type ewk_context_menu_item_type_get(const Ewk_Context_Menu_Item *o);
174
175 /**
176  * Sets the type of item.
177  *
178  * @param o the item to set the type
179  * @param type a new type for the item object
180  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
181  *
182  * @see ewk_context_menu_item_type_get
183  */
184 EAPI Eina_Bool ewk_context_menu_item_type_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Item_Type type);
185
186 /**
187  * Gets an action of the item.
188  *
189  * @param o the item to get the action
190  * @return an action of the item on success or @c EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION on failure
191  *
192  * @see ewk_context_menu_item_action_set
193  */
194 EAPI Ewk_Context_Menu_Item_Action ewk_context_menu_item_action_get(const Ewk_Context_Menu_Item *o);
195
196 /**
197  * Sets an action of the item.
198  *
199  * @param o the item to set the action
200  * @param action a new action for the item object
201  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
202  *
203  * @see ewk_context_menu_item_action_get
204  */
205 EAPI Eina_Bool ewk_context_menu_item_action_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Item_Action action);
206
207 /**
208  * Gets a title of the item.
209  *
210  * @param o the item to get the title
211  * @return a title of the item on success, or @c NULL on failure
212  *
213  * @see ewk_context_menu_item_title_set
214  */
215 EAPI const char *ewk_context_menu_item_title_get(const Ewk_Context_Menu_Item *o);
216
217 /**
218  * Sets a title of the item.
219  *
220  * @param o the item to set the title
221  * @param title a new title for the item object
222  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
223  *
224  * @see ewk_context_menu_item_title_get
225  */
226 EAPI Eina_Bool ewk_context_menu_item_title_set(Ewk_Context_Menu_Item *o, const char *title);
227
228 /**
229  * Queries if the item is toggled.
230  *
231  * @param o the item to query if the item is toggled
232  * @return @c EINA_TRUE if the item is toggled or @c EINA_FALSE if not or on failure
233  */
234 EAPI Eina_Bool ewk_context_menu_item_checked_get(const Ewk_Context_Menu_Item *o);
235
236 /**
237  * Sets if the item should be toggled.
238  *
239  * @param o the item to be toggled
240  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
241  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
242  */
243 EAPI Eina_Bool ewk_context_menu_item_checked_set(Ewk_Context_Menu_Item *o, Eina_Bool checked);
244
245 /**
246  * Gets if the item is enabled.
247  *
248  * @param o the item to get enabled state
249  * @return @c EINA_TRUE if it's enabled, @c EINA_FALSE if not or on failure
250  *
251  * @see ewk_context_menu_item_enabled_set
252  */
253 EAPI Eina_Bool ewk_context_menu_item_enabled_get(const Ewk_Context_Menu_Item *o);
254
255 /**
256  * Enables/disables the item.
257  *
258  * @param o the item to enable/disable
259  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
260  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
261  *
262  * @see ewk_context_menu_item_enabled_get
263  */
264 EAPI Eina_Bool ewk_context_menu_item_enabled_set(Ewk_Context_Menu_Item *o, Eina_Bool enabled);
265
266 #ifdef __cplusplus
267 }
268 #endif
269
270 #endif /* ewk_context_menu_item_h */