[EFL][WK2] Add an API for getting context menu item's parent 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 WKContextMenuItemTypes.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  */
57 typedef enum {
58     EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION,
59     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW,
60     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK,
61     EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD,
62     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW,
63     EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK,
64     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD,
65     EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_URL_TO_CLIPBOARD,
66     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW,
67     EWK_CONTEXT_MENU_ITEM_TAG_COPY,
68     EWK_CONTEXT_MENU_ITEM_TAG_GO_BACK,
69     EWK_CONTEXT_MENU_ITEM_TAG_GO_FORWARD,
70     EWK_CONTEXT_MENU_ITEM_TAG_STOP,
71     EWK_CONTEXT_MENU_ITEM_TAG_RELOAD,
72     EWK_CONTEXT_MENU_ITEM_TAG_CUT,
73     EWK_CONTEXT_MENU_ITEM_TAG_PASTE,
74     EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL,
75     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_GUESS,
76     EWK_CONTEXT_MENU_ITEM_TAG_NO_GUESSES_FOUND,
77     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING,
78     EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING,
79     EWK_CONTEXT_MENU_ITEM_TAG_OTHER,
80     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_IN_SPOTLIGHT,
81     EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB,
82     EWK_CONTEXT_MENU_ITEM_TAG_LOOK_UP_IN_DICTIONARY,
83     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_WITH_DEFAULT_APPLICATION,
84     EWK_CONTEXT_MENU_ITEM_PDFACTUAL_SIZE,
85     EWK_CONTEXT_MENU_ITEM_PDFZOOM_IN,
86     EWK_CONTEXT_MENU_ITEM_PDFZOOM_OUT,
87     EWK_CONTEXT_MENU_ITEM_PDFAUTO_SIZE,
88     EWK_CONTEXT_MENU_ITEM_PDFSINGLE_PAGE,
89     EWK_CONTEXT_MENU_ITEM_PDFFACING_PAGES,
90     EWK_CONTEXT_MENU_ITEM_PDFCONTINUOUS,
91     EWK_CONTEXT_MENU_ITEM_PDFNEXT_PAGE,
92     EWK_CONTEXT_MENU_ITEM_PDFPREVIOUS_PAGE,
93     EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK = 2000,
94     EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_GRAMMAR,
95     EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, /**< spelling or spelling/grammar sub-menu */
96     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_SPELLING_PANEL,
97     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING,
98     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING,
99     EWK_CONTEXT_MENU_ITEM_TAG_CHECK_GRAMMAR_WITH_SPELLING,
100     EWK_CONTEXT_MENU_ITEM_TAG_FONT_MENU, /**< font sub-menu */
101     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_FONTS,
102     EWK_CONTEXT_MENU_ITEM_TAG_BOLD,
103     EWK_CONTEXT_MENU_ITEM_TAG_ITALIC,
104     EWK_CONTEXT_MENU_ITEM_TAG_UNDERLINE,
105     EWK_CONTEXT_MENU_ITEM_TAG_OUTLINE,
106     EWK_CONTEXT_MENU_ITEM_TAG_STYLES,
107     EWK_CONTEXT_MENU_ITEM_TAG_SHOW_COLORS,
108     EWK_CONTEXT_MENU_ITEM_TAG_SPEECH_MENU, /**< speech sub-menu */
109     EWK_CONTEXT_MENU_ITEM_TAG_START_SPEAKING,
110     EWK_CONTEXT_MENU_ITEM_TAG_STOP_SPEAKING,
111     EWK_CONTEXT_MENU_ITEM_TAG_WRITING_DIRECTION_MENU, /**< writing direction sub-menu */
112     EWK_CONTEXT_MENU_ITEM_TAG_DEFAULT_DIRECTION,
113     EWK_CONTEXT_MENU_ITEM_TAG_LEFT_TO_RIGHT,
114     EWK_CONTEXT_MENU_ITEM_TAG_RIGHT_TO_LEFT,
115     EWK_CONTEXT_MENU_ITEM_TAG_PDFSINGLE_PAGE_SCROLLING,
116     EWK_CONTEXT_MENU_ITEM_TAG_PDFFACING_PAGES_SCROLLING,
117     EWK_CONTEXT_MENU_ITEM_TAG_INSPECT_ELEMENT,
118     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_MENU, /**< text direction sub-menu */
119     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_DEFAULT,
120     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_LEFT_TO_RIGHT,
121     EWK_CONTEXT_MENU_ITEM_TAG_TEXT_DIRECTION_RIGHT_TO_LEFT,
122     EWK_CONTEXT_MENU_ITEM_OPEN_MEDIA_IN_NEW_WINDOW,
123     EWK_CONTEXT_MENU_ITEM_TAG_COPY_MEDIA_LINK_TO_CLIPBOARD,
124     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_CONTROLS,
125     EWK_CONTEXT_MENU_ITEM_TAG_TOGGLE_MEDIA_LOOP,
126     EWK_CONTEXT_MENU_ITEM_TAG_ENTER_VIDEO_FULLSCREEN,
127     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_PLAY_PAUSE,
128     EWK_CONTEXT_MENU_ITEM_TAG_MEDIA_MUTE,
129     EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG = 10000
130 } Ewk_Context_Menu_Item_Action;
131
132 /**
133  * Creates a new item of the context menu.
134  *
135  * @param type specifies a type of the item
136  * @param action specifies a action of the item
137  * @param title specifies a title of the item
138  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
139  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
140  * @return the pointer to the new item
141  *
142  * @see ewk_context_menu_item_new_with_submenu
143  */
144 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);
145
146 /**
147  * Creates a new item of the context menu.
148  *
149  * @param type specifies a type of the item
150  * @param action specifies a action of the item
151  * @param title specifies a title of the item
152  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
153  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
154  * @param submenu specifies a submenu of the item
155  * @return the pointer to the new item
156  *
157  * @see ewk_context_menu_item_new
158  */
159 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);
160
161 /**
162  * Gets type of the item.
163  *
164  * @param o the item to get the type
165  * @return type of the item on success or @c EWK_ACTION_TYPE on failure
166  *
167  * @see ewk_context_menu_item_type_set
168  */
169 EAPI Ewk_Context_Menu_Item_Type ewk_context_menu_item_type_get(const Ewk_Context_Menu_Item *o);
170
171 /**
172  * Sets the type of item.
173  *
174  * @param o the item to set the type
175  * @param type a new type for the item object
176  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
177  *
178  * @see ewk_context_menu_item_type_get
179  */
180 EAPI Eina_Bool ewk_context_menu_item_type_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Item_Type type);
181
182 /**
183  * Gets an action of the item.
184  *
185  * @param o the item to get the action
186  * @return an action of the item on success or @c EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION on failure
187  *
188  * @see ewk_context_menu_item_action_set
189  */
190 EAPI Ewk_Context_Menu_Item_Action ewk_context_menu_item_action_get(const Ewk_Context_Menu_Item *o);
191
192 /**
193  * Sets an action of the item.
194  *
195  * @param o the item to set the action
196  * @param action a new action for the item object
197  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
198  *
199  * @see ewk_context_menu_item_action_get
200  */
201 EAPI Eina_Bool ewk_context_menu_item_action_set(Ewk_Context_Menu_Item *o, Ewk_Context_Menu_Item_Action action);
202
203 /**
204  * Gets a title of the item.
205  *
206  * @param o the item to get the title
207  * @return a title of the item on success, or @c NULL on failure
208  *
209  * @see ewk_context_menu_item_title_set
210  */
211 EAPI const char *ewk_context_menu_item_title_get(const Ewk_Context_Menu_Item *o);
212
213 /**
214  * Sets a title of the item.
215  *
216  * @param o the item to set the title
217  * @param title a new title for the item object
218  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
219  *
220  * @see ewk_context_menu_item_title_get
221  */
222 EAPI Eina_Bool ewk_context_menu_item_title_set(Ewk_Context_Menu_Item *o, const char *title);
223
224 /**
225  * Queries if the item is toggled.
226  *
227  * @param o the item to query if the item is toggled
228  * @return @c EINA_TRUE if the item is toggled or @c EINA_FALSE if not or on failure
229  */
230 EAPI Eina_Bool ewk_context_menu_item_checked_get(const Ewk_Context_Menu_Item *o);
231
232 /**
233  * Sets if the item should be toggled.
234  *
235  * @param o the item to be toggled
236  * @param checked @c EINA_TRUE if the item should be toggled or @c EINA_FALSE if not
237  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
238  */
239 EAPI Eina_Bool ewk_context_menu_item_checked_set(Ewk_Context_Menu_Item *o, Eina_Bool checked);
240
241 /**
242  * Gets if the item is enabled.
243  *
244  * @param o the item to get enabled state
245  * @return @c EINA_TRUE if it's enabled, @c EINA_FALSE if not or on failure
246  *
247  * @see ewk_context_menu_item_enabled_set
248  */
249 EAPI Eina_Bool ewk_context_menu_item_enabled_get(const Ewk_Context_Menu_Item *o);
250
251 /**
252  * Enables/disables the item.
253  *
254  * @param o the item to enable/disable
255  * @param enabled @c EINA_TRUE to enable the item or @c EINA_FALSE to disable
256  * @return @c EINA_TRUE on success, or @c EINA_FALSE on failure
257  *
258  * @see ewk_context_menu_item_enabled_get
259  */
260 EAPI Eina_Bool ewk_context_menu_item_enabled_set(Ewk_Context_Menu_Item *o, Eina_Bool enabled);
261
262 /**
263  * Gets the parent menu for the item.
264  *
265  * @param o item to get the parent
266  *
267  * @return the pointer to parent menu on success or @c NULL on failure
268  */
269 EAPI Ewk_Context_Menu *ewk_context_menu_item_parent_menu_get(const Ewk_Context_Menu_Item *o);
270
271 #ifdef __cplusplus
272 }
273 #endif
274
275 #endif /* ewk_context_menu_item_h */