]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/cef_menu_model.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / cef_menu_model.h
1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36
37 #ifndef CEF_INCLUDE_CEF_MENU_MODEL_H_
38 #define CEF_INCLUDE_CEF_MENU_MODEL_H_
39 #pragma once
40
41 #include "include/cef_base.h"
42
43 ///
44 // Supports creation and modification of menus. See cef_menu_id_t for the
45 // command ids that have default implementations. All user-defined command ids
46 // should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The methods of
47 // this class can only be accessed on the browser process the UI thread.
48 ///
49 /*--cef(source=library)--*/
50 class CefMenuModel : public virtual CefBase {
51  public:
52   typedef cef_menu_item_type_t MenuItemType;
53
54   ///
55   // Clears the menu. Returns true on success.
56   ///
57   /*--cef()--*/
58   virtual bool Clear() =0;
59
60   ///
61   // Returns the number of items in this menu.
62   ///
63   /*--cef()--*/
64   virtual int GetCount() =0;
65
66   //
67   // Add a separator to the menu. Returns true on success.
68   ///
69   /*--cef()--*/
70   virtual bool AddSeparator() =0;
71
72   //
73   // Add an item to the menu. Returns true on success.
74   ///
75   /*--cef()--*/
76   virtual bool AddItem(int command_id,
77                        const CefString& label) =0;
78
79   //
80   // Add a check item to the menu. Returns true on success.
81   ///
82   /*--cef()--*/
83   virtual bool AddCheckItem(int command_id,
84                             const CefString& label) =0;
85   //
86   // Add a radio item to the menu. Only a single item with the specified
87   // |group_id| can be checked at a time. Returns true on success.
88   ///
89   /*--cef()--*/
90   virtual bool AddRadioItem(int command_id,
91                             const CefString& label,
92                             int group_id) =0;
93
94   //
95   // Add a sub-menu to the menu. The new sub-menu is returned.
96   ///
97   /*--cef()--*/
98   virtual CefRefPtr<CefMenuModel> AddSubMenu(int command_id,
99                                              const CefString& label) =0;
100
101   //
102   // Insert a separator in the menu at the specified |index|. Returns true on
103   // success.
104   ///
105   /*--cef()--*/
106   virtual bool InsertSeparatorAt(int index) =0;
107
108   //
109   // Insert an item in the menu at the specified |index|. Returns true on
110   // success.
111   ///
112   /*--cef()--*/
113   virtual bool InsertItemAt(int index,
114                             int command_id,
115                             const CefString& label) =0;
116
117   //
118   // Insert a check item in the menu at the specified |index|. Returns true on
119   // success.
120   ///
121   /*--cef()--*/
122   virtual bool InsertCheckItemAt(int index,
123                                  int command_id,
124                                  const CefString& label) =0;
125
126   //
127   // Insert a radio item in the menu at the specified |index|. Only a single
128   // item with the specified |group_id| can be checked at a time. Returns true
129   // on success.
130   ///
131   /*--cef()--*/
132   virtual bool InsertRadioItemAt(int index,
133                                  int command_id,
134                                  const CefString& label,
135                                  int group_id) =0;
136
137   //
138   // Insert a sub-menu in the menu at the specified |index|. The new sub-menu
139   // is returned.
140   ///
141   /*--cef()--*/
142   virtual CefRefPtr<CefMenuModel> InsertSubMenuAt(int index,
143                                                   int command_id,
144                                                   const CefString& label) =0;
145
146   ///
147   // Removes the item with the specified |command_id|. Returns true on success.
148   ///
149   /*--cef()--*/
150   virtual bool Remove(int command_id) =0;
151
152   ///
153   // Removes the item at the specified |index|. Returns true on success.
154   ///
155   /*--cef()--*/
156   virtual bool RemoveAt(int index) =0;
157
158   ///
159   // Returns the index associated with the specified |command_id| or -1 if not
160   // found due to the command id not existing in the menu.
161   ///
162   /*--cef()--*/
163   virtual int GetIndexOf(int command_id) =0;
164
165   ///
166   // Returns the command id at the specified |index| or -1 if not found due to
167   // invalid range or the index being a separator.
168   ///
169   /*--cef()--*/
170   virtual int GetCommandIdAt(int index) =0;
171
172   ///
173   // Sets the command id at the specified |index|. Returns true on success.
174   ///
175   /*--cef()--*/
176   virtual bool SetCommandIdAt(int index, int command_id) =0;
177
178   ///
179   // Returns the label for the specified |command_id| or empty if not found.
180   ///
181   /*--cef()--*/
182   virtual CefString GetLabel(int command_id) =0;
183
184   ///
185   // Returns the label at the specified |index| or empty if not found due to
186   // invalid range or the index being a separator.
187   ///
188   /*--cef()--*/
189   virtual CefString GetLabelAt(int index) =0;
190
191   ///
192   // Sets the label for the specified |command_id|. Returns true on success.
193   ///
194   /*--cef()--*/
195   virtual bool SetLabel(int command_id, const CefString& label) =0;
196
197   ///
198   // Set the label at the specified |index|. Returns true on success.
199   ///
200   /*--cef()--*/
201   virtual bool SetLabelAt(int index, const CefString& label) =0;
202
203   ///
204   // Returns the item type for the specified |command_id|.
205   ///
206   /*--cef(default_retval=MENUITEMTYPE_NONE)--*/
207   virtual MenuItemType GetType(int command_id) =0;
208
209   ///
210   // Returns the item type at the specified |index|.
211   ///
212   /*--cef(default_retval=MENUITEMTYPE_NONE)--*/
213   virtual MenuItemType GetTypeAt(int index) =0;
214
215   ///
216   // Returns the group id for the specified |command_id| or -1 if invalid.
217   ///
218   /*--cef()--*/
219   virtual int GetGroupId(int command_id) =0;
220
221   ///
222   // Returns the group id at the specified |index| or -1 if invalid.
223   ///
224   /*--cef()--*/
225   virtual int GetGroupIdAt(int index) =0;
226
227   ///
228   // Sets the group id for the specified |command_id|. Returns true on success.
229   ///
230   /*--cef()--*/
231   virtual bool SetGroupId(int command_id, int group_id) =0;
232
233   ///
234   // Sets the group id at the specified |index|. Returns true on success.
235   ///
236   /*--cef()--*/
237   virtual bool SetGroupIdAt(int index, int group_id) =0;
238
239   ///
240   // Returns the submenu for the specified |command_id| or empty if invalid.
241   ///
242   /*--cef()--*/
243   virtual CefRefPtr<CefMenuModel> GetSubMenu(int command_id) =0;
244
245   ///
246   // Returns the submenu at the specified |index| or empty if invalid.
247   ///
248   /*--cef()--*/
249   virtual CefRefPtr<CefMenuModel> GetSubMenuAt(int index) =0;
250
251   //
252   // Returns true if the specified |command_id| is visible.
253   ///
254   /*--cef()--*/
255   virtual bool IsVisible(int command_id) =0;
256
257   //
258   // Returns true if the specified |index| is visible.
259   ///
260   /*--cef()--*/
261   virtual bool IsVisibleAt(int index) =0;
262
263   //
264   // Change the visibility of the specified |command_id|. Returns true on
265   // success.
266   ///
267   /*--cef()--*/
268   virtual bool SetVisible(int command_id, bool visible) =0;
269
270   //
271   // Change the visibility at the specified |index|. Returns true on success.
272   ///
273   /*--cef()--*/
274   virtual bool SetVisibleAt(int index, bool visible) =0;
275
276   //
277   // Returns true if the specified |command_id| is enabled.
278   ///
279   /*--cef()--*/
280   virtual bool IsEnabled(int command_id) =0;
281
282   //
283   // Returns true if the specified |index| is enabled.
284   ///
285   /*--cef()--*/
286   virtual bool IsEnabledAt(int index) =0;
287
288   //
289   // Change the enabled status of the specified |command_id|. Returns true on
290   // success.
291   ///
292   /*--cef()--*/
293   virtual bool SetEnabled(int command_id, bool enabled) =0;
294
295   //
296   // Change the enabled status at the specified |index|. Returns true on
297   // success.
298   ///
299   /*--cef()--*/
300   virtual bool SetEnabledAt(int index, bool enabled) =0;
301
302   //
303   // Returns true if the specified |command_id| is checked. Only applies to
304   // check and radio items.
305   ///
306   /*--cef()--*/
307   virtual bool IsChecked(int command_id) =0;
308
309   //
310   // Returns true if the specified |index| is checked. Only applies to check
311   // and radio items.
312   ///
313   /*--cef()--*/
314   virtual bool IsCheckedAt(int index) =0;
315
316   //
317   // Check the specified |command_id|. Only applies to check and radio items.
318   // Returns true on success.
319   ///
320   /*--cef()--*/
321   virtual bool SetChecked(int command_id, bool checked) =0;
322
323   //
324   // Check the specified |index|. Only applies to check and radio items. Returns
325   // true on success.
326   ///
327   /*--cef()--*/
328   virtual bool SetCheckedAt(int index, bool checked) =0;
329
330   //
331   // Returns true if the specified |command_id| has a keyboard accelerator
332   // assigned.
333   ///
334   /*--cef()--*/
335   virtual bool HasAccelerator(int command_id) =0;
336
337   //
338   // Returns true if the specified |index| has a keyboard accelerator assigned.
339   ///
340   /*--cef()--*/
341   virtual bool HasAcceleratorAt(int index) =0;
342
343   //
344   // Set the keyboard accelerator for the specified |command_id|. |key_code| can
345   // be any virtual key or character value. Returns true on success.
346   ///
347   /*--cef()--*/
348   virtual bool SetAccelerator(int command_id,
349                               int key_code,
350                               bool shift_pressed,
351                               bool ctrl_pressed,
352                               bool alt_pressed) =0;
353
354   //
355   // Set the keyboard accelerator at the specified |index|. |key_code| can be
356   // any virtual key or character value. Returns true on success.
357   ///
358   /*--cef()--*/
359   virtual bool SetAcceleratorAt(int index,
360                                 int key_code,
361                                 bool shift_pressed,
362                                 bool ctrl_pressed,
363                                 bool alt_pressed) =0;
364
365   //
366   // Remove the keyboard accelerator for the specified |command_id|. Returns
367   // true on success.
368   ///
369   /*--cef()--*/
370   virtual bool RemoveAccelerator(int command_id) =0;
371
372   //
373   // Remove the keyboard accelerator at the specified |index|. Returns true on
374   // success.
375   ///
376   /*--cef()--*/
377   virtual bool RemoveAcceleratorAt(int index) =0;
378
379   //
380   // Retrieves the keyboard accelerator for the specified |command_id|. Returns
381   // true on success.
382   ///
383   /*--cef()--*/
384   virtual bool GetAccelerator(int command_id,
385                               int& key_code,
386                               bool& shift_pressed,
387                               bool& ctrl_pressed,
388                               bool& alt_pressed) =0;
389
390   //
391   // Retrieves the keyboard accelerator for the specified |index|. Returns true
392   // on success.
393   ///
394   /*--cef()--*/
395   virtual bool GetAcceleratorAt(int index,
396                                 int& key_code,
397                                 bool& shift_pressed,
398                                 bool& ctrl_pressed,
399                                 bool& alt_pressed) =0;
400 };
401
402 #endif  // CEF_INCLUDE_CEF_MENU_MODEL_H_