• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2022 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 // This file was generated by the CEF translator tool and should not edited
33 // by hand. See the translator.README.txt file in the tools directory for
34 // more information.
35 //
36 // $hash=1785245d89e84d5a27ce062208bc19a4031ce97f$
37 //
38 
39 #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
40 #define CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
41 #pragma once
42 
43 #include "include/capi/cef_image_capi.h"
44 #include "include/capi/cef_menu_model_capi.h"
45 #include "include/capi/views/cef_display_capi.h"
46 #include "include/capi/views/cef_overlay_controller_capi.h"
47 #include "include/capi/views/cef_panel_capi.h"
48 #include "include/capi/views/cef_window_delegate_capi.h"
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 ///
55 // A Window is a top-level Window/widget in the Views hierarchy. By default it
56 // will have a non-client area with title bar, icon and buttons that supports
57 // moving and resizing. All size and position values are in density independent
58 // pixels (DIP) unless otherwise indicated. Methods must be called on the
59 // browser process UI thread unless otherwise indicated.
60 ///
61 typedef struct _cef_window_t {
62   ///
63   // Base structure.
64   ///
65   cef_panel_t base;
66 
67   ///
68   // Show the Window.
69   ///
70   void(CEF_CALLBACK* show)(struct _cef_window_t* self);
71 
72   ///
73   // Hide the Window.
74   ///
75   void(CEF_CALLBACK* hide)(struct _cef_window_t* self);
76 
77   ///
78   // Sizes the Window to |size| and centers it in the current display.
79   ///
80   void(CEF_CALLBACK* center_window)(struct _cef_window_t* self,
81                                     const cef_size_t* size);
82 
83   ///
84   // Close the Window.
85   ///
86   void(CEF_CALLBACK* close)(struct _cef_window_t* self);
87 
88   ///
89   // Returns true (1) if the Window has been closed.
90   ///
91   int(CEF_CALLBACK* is_closed)(struct _cef_window_t* self);
92 
93   ///
94   // Activate the Window, assuming it already exists and is visible.
95   ///
96   void(CEF_CALLBACK* activate)(struct _cef_window_t* self);
97 
98   ///
99   // Deactivate the Window, making the next Window in the Z order the active
100   // Window.
101   ///
102   void(CEF_CALLBACK* deactivate)(struct _cef_window_t* self);
103 
104   ///
105   // Returns whether the Window is the currently active Window.
106   ///
107   int(CEF_CALLBACK* is_active)(struct _cef_window_t* self);
108 
109   ///
110   // Bring this Window to the top of other Windows in the Windowing system.
111   ///
112   void(CEF_CALLBACK* bring_to_top)(struct _cef_window_t* self);
113 
114   ///
115   // Set the Window to be on top of other Windows in the Windowing system.
116   ///
117   void(CEF_CALLBACK* set_always_on_top)(struct _cef_window_t* self, int on_top);
118 
119   ///
120   // Returns whether the Window has been set to be on top of other Windows in
121   // the Windowing system.
122   ///
123   int(CEF_CALLBACK* is_always_on_top)(struct _cef_window_t* self);
124 
125   ///
126   // Maximize the Window.
127   ///
128   void(CEF_CALLBACK* maximize)(struct _cef_window_t* self);
129 
130   ///
131   // Minimize the Window.
132   ///
133   void(CEF_CALLBACK* minimize)(struct _cef_window_t* self);
134 
135   ///
136   // Restore the Window.
137   ///
138   void(CEF_CALLBACK* restore)(struct _cef_window_t* self);
139 
140   ///
141   // Set fullscreen Window state.
142   ///
143   void(CEF_CALLBACK* set_fullscreen)(struct _cef_window_t* self,
144                                      int fullscreen);
145 
146   ///
147   // Returns true (1) if the Window is maximized.
148   ///
149   int(CEF_CALLBACK* is_maximized)(struct _cef_window_t* self);
150 
151   ///
152   // Returns true (1) if the Window is minimized.
153   ///
154   int(CEF_CALLBACK* is_minimized)(struct _cef_window_t* self);
155 
156   ///
157   // Returns true (1) if the Window is fullscreen.
158   ///
159   int(CEF_CALLBACK* is_fullscreen)(struct _cef_window_t* self);
160 
161   ///
162   // Set the Window title.
163   ///
164   void(CEF_CALLBACK* set_title)(struct _cef_window_t* self,
165                                 const cef_string_t* title);
166 
167   ///
168   // Get the Window title.
169   ///
170   // The resulting string must be freed by calling cef_string_userfree_free().
171   cef_string_userfree_t(CEF_CALLBACK* get_title)(struct _cef_window_t* self);
172 
173   ///
174   // Set the Window icon. This should be a 16x16 icon suitable for use in the
175   // Windows's title bar.
176   ///
177   void(CEF_CALLBACK* set_window_icon)(struct _cef_window_t* self,
178                                       struct _cef_image_t* image);
179 
180   ///
181   // Get the Window icon.
182   ///
183   struct _cef_image_t*(CEF_CALLBACK* get_window_icon)(
184       struct _cef_window_t* self);
185 
186   ///
187   // Set the Window App icon. This should be a larger icon for use in the host
188   // environment app switching UI. On Windows, this is the ICON_BIG used in Alt-
189   // Tab list and Windows taskbar. The Window icon will be used by default if no
190   // Window App icon is specified.
191   ///
192   void(CEF_CALLBACK* set_window_app_icon)(struct _cef_window_t* self,
193                                           struct _cef_image_t* image);
194 
195   ///
196   // Get the Window App icon.
197   ///
198   struct _cef_image_t*(CEF_CALLBACK* get_window_app_icon)(
199       struct _cef_window_t* self);
200 
201   ///
202   // Add a View that will be overlayed on the Window contents with absolute
203   // positioning and high z-order. Positioning is controlled by |docking_mode|
204   // as described below. The returned cef_overlay_controller_t object is used to
205   // control the overlay. Overlays are hidden by default.
206   //
207   // With CEF_DOCKING_MODE_CUSTOM:
208   //   1. The overlay is initially hidden, sized to |view|'s preferred size, and
209   //      positioned in the top-left corner.
210   //   2. Optionally change the overlay position and/or size by calling
211   //      CefOverlayController methods.
212   //   3. Call CefOverlayController::SetVisible(true) to show the overlay.
213   //   4. The overlay will be automatically re-sized if |view|'s layout changes.
214   //      Optionally change the overlay position and/or size when
215   //      OnLayoutChanged is called on the Window's delegate to indicate a
216   //      change in Window bounds.
217   //
218   // With other docking modes:
219   //   1. The overlay is initially hidden, sized to |view|'s preferred size, and
220   //      positioned based on |docking_mode|.
221   //   2. Call CefOverlayController::SetVisible(true) to show the overlay.
222   //   3. The overlay will be automatically re-sized if |view|'s layout changes
223   //      and re-positioned as appropriate when the Window resizes.
224   //
225   // Overlays created by this function will receive a higher z-order then any
226   // child Views added previously. It is therefore recommended to call this
227   // function last after all other child Views have been added so that the
228   // overlay displays as the top-most child of the Window.
229   ///
230   struct _cef_overlay_controller_t*(CEF_CALLBACK* add_overlay_view)(
231       struct _cef_window_t* self,
232       struct _cef_view_t* view,
233       cef_docking_mode_t docking_mode);
234 
235   ///
236   // Show a menu with contents |menu_model|. |screen_point| specifies the menu
237   // position in screen coordinates. |anchor_position| specifies how the menu
238   // will be anchored relative to |screen_point|.
239   ///
240   void(CEF_CALLBACK* show_menu)(struct _cef_window_t* self,
241                                 struct _cef_menu_model_t* menu_model,
242                                 const cef_point_t* screen_point,
243                                 cef_menu_anchor_position_t anchor_position);
244 
245   ///
246   // Cancel the menu that is currently showing, if any.
247   ///
248   void(CEF_CALLBACK* cancel_menu)(struct _cef_window_t* self);
249 
250   ///
251   // Returns the Display that most closely intersects the bounds of this Window.
252   // May return NULL if this Window is not currently displayed.
253   ///
254   struct _cef_display_t*(CEF_CALLBACK* get_display)(struct _cef_window_t* self);
255 
256   ///
257   // Returns the bounds (size and position) of this Window's client area.
258   // Position is in screen coordinates.
259   ///
260   cef_rect_t(CEF_CALLBACK* get_client_area_bounds_in_screen)(
261       struct _cef_window_t* self);
262 
263   ///
264   // Set the regions where mouse events will be intercepted by this Window to
265   // support drag operations. Call this function with an NULL vector to clear
266   // the draggable regions. The draggable region bounds should be in window
267   // coordinates.
268   ///
269   void(CEF_CALLBACK* set_draggable_regions)(
270       struct _cef_window_t* self,
271       size_t regionsCount,
272       cef_draggable_region_t const* regions);
273 
274   ///
275   // Retrieve the platform window handle for this Window.
276   ///
277   cef_window_handle_t(CEF_CALLBACK* get_window_handle)(
278       struct _cef_window_t* self);
279 
280   ///
281   // Simulate a key press. |key_code| is the VKEY_* value from Chromium's
282   // ui/events/keycodes/keyboard_codes.h header (VK_* values on Windows).
283   // |event_flags| is some combination of EVENTFLAG_SHIFT_DOWN,
284   // EVENTFLAG_CONTROL_DOWN and/or EVENTFLAG_ALT_DOWN. This function is exposed
285   // primarily for testing purposes.
286   ///
287   void(CEF_CALLBACK* send_key_press)(struct _cef_window_t* self,
288                                      int key_code,
289                                      uint32 event_flags);
290 
291   ///
292   // Simulate a mouse move. The mouse cursor will be moved to the specified
293   // (screen_x, screen_y) position. This function is exposed primarily for
294   // testing purposes.
295   ///
296   void(CEF_CALLBACK* send_mouse_move)(struct _cef_window_t* self,
297                                       int screen_x,
298                                       int screen_y);
299 
300   ///
301   // Simulate mouse down and/or mouse up events. |button| is the mouse button
302   // type. If |mouse_down| is true (1) a mouse down event will be sent. If
303   // |mouse_up| is true (1) a mouse up event will be sent. If both are true (1)
304   // a mouse down event will be sent followed by a mouse up event (equivalent to
305   // clicking the mouse button). The events will be sent using the current
306   // cursor position so make sure to call send_mouse_move() first to position
307   // the mouse. This function is exposed primarily for testing purposes.
308   ///
309   void(CEF_CALLBACK* send_mouse_events)(struct _cef_window_t* self,
310                                         cef_mouse_button_type_t button,
311                                         int mouse_down,
312                                         int mouse_up);
313 
314   ///
315   // Set the keyboard accelerator for the specified |command_id|. |key_code| can
316   // be any virtual key or character value. cef_window_delegate_t::OnAccelerator
317   // will be called if the keyboard combination is triggered while this window
318   // has focus.
319   ///
320   void(CEF_CALLBACK* set_accelerator)(struct _cef_window_t* self,
321                                       int command_id,
322                                       int key_code,
323                                       int shift_pressed,
324                                       int ctrl_pressed,
325                                       int alt_pressed);
326 
327   ///
328   // Remove the keyboard accelerator for the specified |command_id|.
329   ///
330   void(CEF_CALLBACK* remove_accelerator)(struct _cef_window_t* self,
331                                          int command_id);
332 
333   ///
334   // Remove all keyboard accelerators.
335   ///
336   void(CEF_CALLBACK* remove_all_accelerators)(struct _cef_window_t* self);
337 } cef_window_t;
338 
339 ///
340 // Create a new Window.
341 ///
342 CEF_EXPORT cef_window_t* cef_window_create_top_level(
343     struct _cef_window_delegate_t* delegate);
344 
345 #ifdef __cplusplus
346 }
347 #endif
348 
349 #endif  // CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_
350