1 // Copyright (c) 2016 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_VIEWS_CEF_WINDOW_H_ 38 #define CEF_INCLUDE_VIEWS_CEF_WINDOW_H_ 39 #pragma once 40 41 #include "include/cef_image.h" 42 #include "include/cef_menu_model.h" 43 #include "include/views/cef_display.h" 44 #include "include/views/cef_panel.h" 45 #include "include/views/cef_window_delegate.h" 46 47 /// 48 // A Window is a top-level Window/widget in the Views hierarchy. By default it 49 // will have a non-client area with title bar, icon and buttons that supports 50 // moving and resizing. All size and position values are in density independent 51 // pixels (DIP) unless otherwise indicated. Methods must be called on the 52 // browser process UI thread unless otherwise indicated. 53 /// 54 /*--cef(source=library)--*/ 55 class CefWindow : public CefPanel { 56 public: 57 /// 58 // Create a new Window. 59 /// 60 /*--cef(optional_param=delegate)--*/ 61 static CefRefPtr<CefWindow> CreateTopLevelWindow( 62 CefRefPtr<CefWindowDelegate> delegate); 63 64 /// 65 // Show the Window. 66 /// 67 /*--cef()--*/ 68 virtual void Show() = 0; 69 70 /// 71 // Hide the Window. 72 /// 73 /*--cef()--*/ 74 virtual void Hide() = 0; 75 76 /// 77 // Sizes the Window to |size| and centers it in the current display. 78 /// 79 /*--cef()--*/ 80 virtual void CenterWindow(const CefSize& size) = 0; 81 82 /// 83 // Close the Window. 84 /// 85 /*--cef()--*/ 86 virtual void Close() = 0; 87 88 /// 89 // Returns true if the Window has been closed. 90 /// 91 /*--cef()--*/ 92 virtual bool IsClosed() = 0; 93 94 /// 95 // Activate the Window, assuming it already exists and is visible. 96 /// 97 /*--cef()--*/ 98 virtual void Activate() = 0; 99 100 /// 101 // Deactivate the Window, making the next Window in the Z order the active 102 // Window. 103 /// 104 /*--cef()--*/ 105 virtual void Deactivate() = 0; 106 107 /// 108 // Returns whether the Window is the currently active Window. 109 /// 110 /*--cef()--*/ 111 virtual bool IsActive() = 0; 112 113 /// 114 // Bring this Window to the top of other Windows in the Windowing system. 115 /// 116 /*--cef()--*/ 117 virtual void BringToTop() = 0; 118 119 /// 120 // Set the Window to be on top of other Windows in the Windowing system. 121 /// 122 /*--cef()--*/ 123 virtual void SetAlwaysOnTop(bool on_top) = 0; 124 125 /// 126 // Returns whether the Window has been set to be on top of other Windows in 127 // the Windowing system. 128 /// 129 /*--cef()--*/ 130 virtual bool IsAlwaysOnTop() = 0; 131 132 /// 133 // Maximize the Window. 134 /// 135 /*--cef()--*/ 136 virtual void Maximize() = 0; 137 138 /// 139 // Minimize the Window. 140 /// 141 /*--cef()--*/ 142 virtual void Minimize() = 0; 143 144 /// 145 // Restore the Window. 146 /// 147 /*--cef()--*/ 148 virtual void Restore() = 0; 149 150 /// 151 // Set fullscreen Window state. 152 /// 153 /*--cef()--*/ 154 virtual void SetFullscreen(bool fullscreen) = 0; 155 156 /// 157 // Returns true if the Window is maximized. 158 /// 159 /*--cef()--*/ 160 virtual bool IsMaximized() = 0; 161 162 /// 163 // Returns true if the Window is minimized. 164 /// 165 /*--cef()--*/ 166 virtual bool IsMinimized() = 0; 167 168 /// 169 // Returns true if the Window is fullscreen. 170 /// 171 /*--cef()--*/ 172 virtual bool IsFullscreen() = 0; 173 174 /// 175 // Set the Window title. 176 /// 177 /*--cef(optional_param=title)--*/ 178 virtual void SetTitle(const CefString& title) = 0; 179 180 /// 181 // Get the Window title. 182 /// 183 /*--cef()--*/ 184 virtual CefString GetTitle() = 0; 185 186 /// 187 // Set the Window icon. This should be a 16x16 icon suitable for use in the 188 // Windows's title bar. 189 /// 190 /*--cef()--*/ 191 virtual void SetWindowIcon(CefRefPtr<CefImage> image) = 0; 192 193 /// 194 // Get the Window icon. 195 /// 196 /*--cef()--*/ 197 virtual CefRefPtr<CefImage> GetWindowIcon() = 0; 198 199 /// 200 // Set the Window App icon. This should be a larger icon for use in the host 201 // environment app switching UI. On Windows, this is the ICON_BIG used in 202 // Alt-Tab list and Windows taskbar. The Window icon will be used by default 203 // if no Window App icon is specified. 204 /// 205 /*--cef()--*/ 206 virtual void SetWindowAppIcon(CefRefPtr<CefImage> image) = 0; 207 208 /// 209 // Get the Window App icon. 210 /// 211 /*--cef()--*/ 212 virtual CefRefPtr<CefImage> GetWindowAppIcon() = 0; 213 214 /// 215 // Show a menu with contents |menu_model|. |screen_point| specifies the menu 216 // position in screen coordinates. |anchor_position| specifies how the menu 217 // will be anchored relative to |screen_point|. 218 /// 219 /*--cef()--*/ 220 virtual void ShowMenu(CefRefPtr<CefMenuModel> menu_model, 221 const CefPoint& screen_point, 222 cef_menu_anchor_position_t anchor_position) = 0; 223 224 /// 225 // Cancel the menu that is currently showing, if any. 226 /// 227 /*--cef()--*/ 228 virtual void CancelMenu() = 0; 229 230 /// 231 // Returns the Display that most closely intersects the bounds of this Window. 232 // May return NULL if this Window is not currently displayed. 233 /// 234 /*--cef()--*/ 235 virtual CefRefPtr<CefDisplay> GetDisplay() = 0; 236 237 /// 238 // Returns the bounds (size and position) of this Window's client area. 239 // Position is in screen coordinates. 240 /// 241 /*--cef()--*/ 242 virtual CefRect GetClientAreaBoundsInScreen() = 0; 243 244 /// 245 // Set the regions where mouse events will be intercepted by this Window to 246 // support drag operations. Call this method with an empty vector to clear the 247 // draggable regions. The draggable region bounds should be in window 248 // coordinates. 249 /// 250 /*--cef(optional_param=regions)--*/ 251 virtual void SetDraggableRegions( 252 const std::vector<CefDraggableRegion>& regions) = 0; 253 254 /// 255 // Retrieve the platform window handle for this Window. 256 /// 257 /*--cef()--*/ 258 virtual CefWindowHandle GetWindowHandle() = 0; 259 260 /// 261 // Simulate a key press. |key_code| is the VKEY_* value from Chromium's 262 // ui/events/keycodes/keyboard_codes.h header (VK_* values on Windows). 263 // |event_flags| is some combination of EVENTFLAG_SHIFT_DOWN, 264 // EVENTFLAG_CONTROL_DOWN and/or EVENTFLAG_ALT_DOWN. This method is exposed 265 // primarily for testing purposes. 266 /// 267 /*--cef()--*/ 268 virtual void SendKeyPress(int key_code, uint32 event_flags) = 0; 269 270 /// 271 // Simulate a mouse move. The mouse cursor will be moved to the specified 272 // (screen_x, screen_y) position. This method is exposed primarily for testing 273 // purposes. 274 /// 275 /*--cef()--*/ 276 virtual void SendMouseMove(int screen_x, int screen_y) = 0; 277 278 /// 279 // Simulate mouse down and/or mouse up events. |button| is the mouse button 280 // type. If |mouse_down| is true a mouse down event will be sent. If 281 // |mouse_up| is true a mouse up event will be sent. If both are true a mouse 282 // down event will be sent followed by a mouse up event (equivalent to 283 // clicking the mouse button). The events will be sent using the current 284 // cursor position so make sure to call SendMouseMove() first to position the 285 // mouse. This method is exposed primarily for testing purposes. 286 /// 287 /*--cef()--*/ 288 virtual void SendMouseEvents(cef_mouse_button_type_t button, 289 bool mouse_down, 290 bool mouse_up) = 0; 291 /// 292 // Set the keyboard accelerator for the specified |command_id|. |key_code| can 293 // be any virtual key or character value. CefWindowDelegate::OnAccelerator 294 // will be called if the keyboard combination is triggered while this window 295 // has focus. 296 /// 297 /*--cef()--*/ 298 virtual void SetAccelerator(int command_id, 299 int key_code, 300 bool shift_pressed, 301 bool ctrl_pressed, 302 bool alt_pressed) = 0; 303 304 /// 305 // Remove the keyboard accelerator for the specified |command_id|. 306 /// 307 /*--cef()--*/ 308 virtual void RemoveAccelerator(int command_id) = 0; 309 310 /// 311 // Remove all keyboard accelerators. 312 /// 313 /*--cef()--*/ 314 virtual void RemoveAllAccelerators() = 0; 315 }; 316 317 #endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_H_ 318