-
-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathCefMenuModel.java
More file actions
338 lines (281 loc) · 10.3 KB
/
CefMenuModel.java
File metadata and controls
338 lines (281 loc) · 10.3 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package org.cef.callback;
import org.cef.misc.BoolRef;
import org.cef.misc.IntRef;
/**
* Supports creation and modification of menus. See cef_menu_id_t for the
* command ids that have default implementations. All user-defined command ids
* should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The methods of
* this class can only be accessed on the browser process the UI thread.
*/
public interface CefMenuModel {
public static final class MenuId {
public static final int MENU_ID_BACK = 100;
public static final int MENU_ID_FORWARD = 101;
public static final int MENU_ID_RELOAD = 102;
public static final int MENU_ID_RELOAD_NOCACHE = 103;
public static final int MENU_ID_STOPLOAD = 104;
// Editing.
public static final int MENU_ID_UNDO = 110;
public static final int MENU_ID_REDO = 111;
public static final int MENU_ID_CUT = 112;
public static final int MENU_ID_COPY = 113;
public static final int MENU_ID_PASTE = 114;
public static final int MENU_ID_DELETE = 115;
public static final int MENU_ID_SELECT_ALL = 116;
// Miscellaneous.
public static final int MENU_ID_FIND = 130;
public static final int MENU_ID_PRINT = 131;
public static final int MENU_ID_VIEW_SOURCE = 132;
// Spell checking word correction suggestions.
public static final int MENU_ID_SPELLCHECK_SUGGESTION_0 = 200;
public static final int MENU_ID_SPELLCHECK_SUGGESTION_1 = 201;
public static final int MENU_ID_SPELLCHECK_SUGGESTION_2 = 202;
public static final int MENU_ID_SPELLCHECK_SUGGESTION_3 = 203;
public static final int MENU_ID_SPELLCHECK_SUGGESTION_4 = 204;
public static final int MENU_ID_SPELLCHECK_SUGGESTION_LAST = 204;
public static final int MENU_ID_NO_SPELLING_SUGGESTIONS = 205;
// All user-defined menu IDs should come between MENU_ID_USER_FIRST and
// MENU_ID_USER_LAST to avoid overlapping the Chromium and CEF ID ranges
// defined in the tools/gritsettings/resource_ids file.
public static final int MENU_ID_USER_FIRST = 26500;
public static final int MENU_ID_USER_LAST = 28500;
}
/**
* Supported menu item types.
*/
public enum MenuItemType {
MENUITEMTYPE_NONE,
MENUITEMTYPE_COMMAND,
MENUITEMTYPE_CHECK,
MENUITEMTYPE_RADIO,
MENUITEMTYPE_SEPARATOR,
MENUITEMTYPE_SUBMENU,
}
/**
* Clears the menu. Returns true on success.
*/
boolean clear();
/**
* Returns the number of items in this menu.
*/
int getCount();
/**
* Add a separator to the menu. Returns true on success.
*/
boolean addSeparator();
/**
* Add an item to the menu. Returns true on success.
*/
boolean addItem(int command_id, String label);
/**
* Add a check item to the menu. Returns true on success.
*/
boolean addCheckItem(int command_id, String label);
/**
* Add a radio item to the menu. Only a single item with the specified
* |group_id| can be checked at a time. Returns true on success.
*/
boolean addRadioItem(int command_id, String label, int group_id);
/**
* Add a sub-menu to the menu. The new sub-menu is returned.
*/
CefMenuModel addSubMenu(int command_id, String label);
/**
* Insert a separator in the menu at the specified |index|. Returns true on
* success.
*/
boolean insertSeparatorAt(int index);
/**
* Insert an item in the menu at the specified |index|. Returns true on
* success.
*/
boolean insertItemAt(int index, int command_id, String label);
/**
* Insert a check item in the menu at the specified |index|. Returns true on
* success.
*/
boolean insertCheckItemAt(int index, int command_id, String label);
/**
* Insert a radio item in the menu at the specified |index|. Only a single
* item with the specified |group_id| can be checked at a time. Returns true
* on success.
*/
boolean insertRadioItemAt(int index, int command_id, String label, int group_id);
/**
* Insert a sub-menu in the menu at the specified |index|. The new sub-menu
* is returned.
*/
CefMenuModel insertSubMenuAt(int index, int command_id, String label);
/**
* Removes the item with the specified |command_id|. Returns true on success.
*/
boolean remove(int command_id);
/**
* Removes the item at the specified |index|. Returns true on success.
*/
boolean removeAt(int index);
/**
* Returns the index associated with the specified |command_id| or -1 if not
* found due to the command id not existing in the menu.
*/
int getIndexOf(int command_id);
/**
* Returns the command id at the specified |index| or -1 if not found due to
* invalid range or the index being a separator.
*/
int getCommandIdAt(int index);
/**
* Sets the command id at the specified |index|. Returns true on success.
*/
boolean setCommandIdAt(int index, int command_id);
/**
* Returns the label for the specified |command_id| or empty if not found.
*/
String getLabel(int command_id);
/**
* Returns the label at the specified |index| or empty if not found due to
* invalid range or the index being a separator.
*/
String getLabelAt(int index);
/**
* Sets the label for the specified |command_id|. Returns true on success.
*/
boolean setLabel(int command_id, String label);
/**
* Set the label at the specified |index|. Returns true on success.
*/
boolean setLabelAt(int index, String label);
/**
* Returns the item type for the specified |command_id|.
*/
MenuItemType getType(int command_id);
/**
* Returns the item type at the specified |index|.
*/
MenuItemType getTypeAt(int index);
/**
* Returns the group id for the specified |command_id| or -1 if invalid.
*/
int getGroupId(int command_id);
/**
* Returns the group id at the specified |index| or -1 if invalid.
*/
int getGroupIdAt(int index);
/**
* Sets the group id for the specified |command_id|. Returns true on success.
*/
boolean setGroupId(int command_id, int group_id);
/**
* Sets the group id at the specified |index|. Returns true on success.
*/
boolean setGroupIdAt(int index, int group_id);
/**
* Returns the submenu for the specified |command_id| or empty if invalid.
*/
CefMenuModel getSubMenu(int command_id);
/**
* Returns the submenu at the specified |index| or empty if invalid.
*/
CefMenuModel getSubMenuAt(int index);
/**
* Returns true if the specified |command_id| is visible.
*/
boolean isVisible(int command_id);
/**
* Returns true if the specified |index| is visible.
*/
boolean isVisibleAt(int index);
/**
* Change the visibility of the specified |command_id|. Returns true on
* success.
*/
boolean setVisible(int command_id, boolean visible);
/**
* Change the visibility at the specified |index|. Returns true on success.
*/
boolean setVisibleAt(int index, boolean visible);
/**
* Returns true if the specified |command_id| is enabled.
*/
boolean isEnabled(int command_id);
/**
* Returns true if the specified |index| is enabled.
*/
boolean isEnabledAt(int index);
/**
* Change the enabled status of the specified |command_id|. Returns true on
* success.
*/
boolean setEnabled(int command_id, boolean enabled);
/**
* Change the enabled status at the specified |index|. Returns true on
* success.
*/
boolean setEnabledAt(int index, boolean enabled);
/**
* Returns true if the specified |command_id| is checked. Only applies to
* check and radio items.
*/
boolean isChecked(int command_id);
/**
* Returns true if the specified |index| is checked. Only applies to check
* and radio items.
*/
boolean isCheckedAt(int index);
/**
* Check the specified |command_id|. Only applies to check and radio items.
* Returns true on success.
*/
boolean setChecked(int command_id, boolean checked);
/**
* Check the specified |index|. Only applies to check and radio items. Returns
* true on success.
*/
boolean setCheckedAt(int index, boolean checked);
/**
* Returns true if the specified |command_id| has a keyboard accelerator
* assigned.
*/
boolean hasAccelerator(int command_id);
/**
* Returns true if the specified |index| has a keyboard accelerator assigned.
*/
boolean hasAcceleratorAt(int index);
/**
* Set the keyboard accelerator for the specified |command_id|. |key_code| can
* be any key or character value. Returns true on success.
*/
boolean setAccelerator(int command_id, int key_code, boolean shift_pressed,
boolean ctrl_pressed, boolean alt_pressed);
/**
* Set the keyboard accelerator at the specified |index|. |key_code| can be
* any key or character value. Returns true on success.
*/
boolean setAcceleratorAt(int index, int key_code, boolean shift_pressed, boolean ctrl_pressed,
boolean alt_pressed);
/**
* Remove the keyboard accelerator for the specified |command_id|. Returns
* true on success.
*/
boolean removeAccelerator(int command_id);
/**
* Remove the keyboard accelerator at the specified |index|. Returns true on
* success.
*/
boolean removeAcceleratorAt(int index);
/**
* Retrieves the keyboard accelerator for the specified |command_id|. Returns
* true on success.
*/
boolean getAccelerator(int command_id, IntRef key_code, BoolRef shift_pressed,
BoolRef ctrl_pressed, BoolRef alt_pressed);
/**
* Retrieves the keyboard accelerator for the specified |index|. Returns true
* on success.
*/
boolean getAcceleratorAt(int index, IntRef key_code, BoolRef shift_pressed,
BoolRef ctrl_pressed, BoolRef alt_pressed);
}