CefWindow
Header: cef_window.h
Category: Views Framework
Overview
Browser-process UI toolkit: windows, panels, layouts, buttons, textfields, and their delegates.
CefWindow
Source File: include/views/cef_window.h
Process / Thread Context: Browser Process / UI Thread.
Purpose: A top-level window/widget in the views hierarchy. By default it
Methods
static CefRefPtr<CefWindow> CreateTopLevelWindow(CefRefPtr<CefWindowDelegate> delegate)
Parameters:
delegate: OptionalCefWindowDelegatefor receiving window events.
Return Value: A new top-level window.
Usage Instruction: Static factory. Window is hidden by default — call
Threading Constraint: Browser process UI thread.
virtual void Show() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Display the window.
Threading Constraint: Browser process UI thread.
virtual void ShowAsBrowserModalDialog(CefRefPtr<CefBrowserView> browser_view) = 0
Parameters:
browser_view: The browser view this dialog is modal to. A parent window
Return Value: void. While this window is visible, browser_view is
Usage Instruction: Cross-platform browser-modal dialog. For a fully
Threading Constraint: Browser process UI thread.
virtual void Hide() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Hide the window.
Threading Constraint: Browser process UI thread.
virtual void CenterWindow(const CefSize& size) = 0
Parameters:
size: The new size to apply before centering.
Return Value: void. Window is sized and centered in the current
Usage Instruction: Center a dialog.
Threading Constraint: Browser process UI thread.
virtual void Close() = 0
Parameters:
- none.
Return Value: void. CanClose() will be consulted first.
Usage Instruction: Close the window.
Threading Constraint: Browser process UI thread.
virtual bool IsClosed() = 0
Parameters:
- none.
Return Value: True if the window has been closed.
Usage Instruction: Detect if Close() has completed.
Threading Constraint: Browser process UI thread.
virtual void Activate() = 0
Parameters:
- none.
Return Value: void. Activates the window if it exists and is visible.
Usage Instruction: Bring the window to the foreground focus.
Threading Constraint: Browser process UI thread.
virtual void Deactivate() = 0
Parameters:
- none.
Return Value: void. The next window in Z order becomes active.
Usage Instruction: Programmatically yield focus.
Threading Constraint: Browser process UI thread.
virtual bool IsActive() = 0
Parameters:
- none.
Return Value: True if this window is the currently active window.
Usage Instruction: Combine with CefView::HasFocus to determine
Threading Constraint: Browser process UI thread.
virtual void BringToTop() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Bring this window above siblings in Z order.
Threading Constraint: Browser process UI thread.
virtual void SetAlwaysOnTop(bool on_top) = 0
Parameters:
on_top: True to keep this window above others.
Return Value: void.
Usage Instruction: Floating tool palettes, etc.
Threading Constraint: Browser process UI thread.
virtual bool IsAlwaysOnTop() = 0
Parameters:
- none.
Return Value: True if SetAlwaysOnTop(true) was applied.
Usage Instruction: Query state.
Threading Constraint: Browser process UI thread.
virtual void Maximize() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Maximize the window.
Threading Constraint: Browser process UI thread.
virtual void Minimize() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Minimize the window.
Threading Constraint: Browser process UI thread.
virtual void Restore() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Restore from minimized/maximized state.
Threading Constraint: Browser process UI thread.
virtual void SetFullscreen(bool fullscreen) = 0
Parameters:
fullscreen: True to enter fullscreen, false to exit.
Return Value: void. OnWindowFullscreenTransition is called during the
Usage Instruction: Toggle fullscreen mode.
Threading Constraint: Browser process UI thread.
virtual bool IsMaximized() = 0
Parameters:
- none.
Return Value: True if maximized.
Usage Instruction: State query.
Threading Constraint: Browser process UI thread.
virtual bool IsMinimized() = 0
Parameters:
- none.
Return Value: True if minimized.
Usage Instruction: State query.
Threading Constraint: Browser process UI thread.
virtual bool IsFullscreen() = 0
Parameters:
- none.
Return Value: True if fullscreen.
Usage Instruction: State query.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefView> GetFocusedView() = 0
Parameters:
- none.
Return Value: The currently focused view within this window, or NULL.
Usage Instruction: Save/restore focus state.
Threading Constraint: Browser process UI thread.
virtual void SetTitle(const CefString& title) = 0
Parameters:
title: New window title (may be empty).
Return Value: void.
Usage Instruction: Set the title-bar text.
Threading Constraint: Browser process UI thread.
virtual CefString GetTitle() = 0
Parameters:
- none.
Return Value: Current title.
Usage Instruction: Read the title.
Threading Constraint: Browser process UI thread.
virtual void SetWindowIcon(CefRefPtr<CefImage> image) = 0
Parameters:
image: A 16x16 icon for the title bar.
Return Value: void.
Usage Instruction: Set the small window icon.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefImage> GetWindowIcon() = 0
Parameters:
- none.
Return Value: The current window icon (may be NULL).
Usage Instruction: Read the icon.
Threading Constraint: Browser process UI thread.
virtual void SetWindowAppIcon(CefRefPtr<CefImage> image) = 0
Parameters:
image: A larger icon used by the host environment's app switcher
Return Value: void.
Usage Instruction: Set the OS-level app icon.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefImage> GetWindowAppIcon() = 0
Parameters:
- none.
Return Value: The current app icon (may be NULL).
Usage Instruction: Read the app icon.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefOverlayController> AddOverlayView(CefRefPtr<CefView> view, cef_docking_mode_t docking_mode, bool can_activate) = 0
Parameters:
view: The contents view for the overlay.docking_mode: One ofcef_docking_mode_t(e.g.,CEF_DOCKING_MODE_CUSTOM,can_activate: True if the overlay may receive input focus.
Return Value: A CefOverlayController used to control the overlay.
Usage Instruction: Floating overlays with absolute positioning and high
Threading Constraint: Browser process UI thread.
virtual void ShowMenu(CefRefPtr<CefMenuModel> menu_model, const CefPoint& screen_point, cef_menu_anchor_position_t anchor_position) = 0
Parameters:
menu_model: The menu contents.screen_point: Position in screen coordinates.anchor_position: How the menu anchors relative toscreen_point.
Return Value: void.
Usage Instruction: Show a context / popup menu.
Threading Constraint: Browser process UI thread.
virtual void CancelMenu() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Dismiss a menu currently shown via ShowMenu.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefDisplay> GetDisplay() = 0
Parameters:
- none.
Return Value: The display that most closely intersects this window's
Usage Instruction: Multi-monitor awareness.
Threading Constraint: Browser process UI thread.
virtual CefRect GetClientAreaBoundsInScreen() = 0
Parameters:
- none.
Return Value: Bounds of the window's client area in screen coordinates.
Usage Instruction: Position child popups within the client area.
Threading Constraint: Browser process UI thread.
virtual void SetDraggableRegions(const std::vector<CefDraggableRegion>& regions) = 0
Parameters:
regions: The regions where mouse events should be intercepted for
Return Value: void.
Usage Instruction: Used by frameless windows to allow custom title-bar
Threading Constraint: Browser process UI thread.
virtual CefWindowHandle GetWindowHandle() = 0
Parameters:
- none.
Return Value: Platform-specific native window handle.
Usage Instruction: Interop with native APIs.
Threading Constraint: Browser process UI thread.
virtual void SendKeyPress(int key_code, uint32_t event_flags) = 0
Parameters:
key_code: A VKEY_* value (from Chromium'skeyboard_codes.h, or VK_*event_flags: Bitmask ofEVENTFLAG_SHIFT_DOWN,EVENTFLAG_CONTROL_DOWN,
Return Value: void.
Usage Instruction: Simulated input — primarily for testing.
Threading Constraint: Browser process UI thread.
virtual void SendMouseMove(int screen_x, int screen_y) = 0
Return Value: void.
Usage Instruction: Simulated input — primarily for testing.
Threading Constraint: Browser process UI thread.
virtual void SendMouseEvents(cef_mouse_button_type_t button, bool mouse_down, bool mouse_up) = 0
Parameters:
button: Which mouse button.mouse_down: True to send a down event.mouse_up: True to send an up event. If both true, down then up (a click)
Return Value: void. Uses the current cursor position, so call
Usage Instruction: Simulated input — primarily for testing.
Threading Constraint: Browser process UI thread.
virtual void SetAccelerator(int command_id, int key_code, bool shift_pressed, bool ctrl_pressed, bool alt_pressed, bool high_priority) = 0
Parameters:
command_id: User-defined command id passed back tokey_code: Virtual key or character value.high_priority: If true, when a childCefBrowserViewhas focus the key
Return Value: void.
Usage Instruction: Register keyboard shortcuts.
Threading Constraint: Browser process UI thread.
virtual void RemoveAccelerator(int command_id) = 0
Parameters:
command_id: The id of the accelerator to remove.
Return Value: void.
Usage Instruction: Unregister a previously registered accelerator.
Threading Constraint: Browser process UI thread.
virtual void RemoveAllAccelerators() = 0
Parameters:
- none.
Return Value: void.
Usage Instruction: Clear all accelerators.
Threading Constraint: Browser process UI thread.
virtual void SetThemeColor(int color_id, cef_color_t color) = 0
Parameters:
color_id: A standard id fromcef_color_ids.h, or a custom id >=color: The color to associate with that id.
Return Value: void. The color is available immediately via
Usage Instruction: Either pre-show (call ThemeChanged() afterwards) or
Threading Constraint: Browser process UI thread.
virtual void ThemeChanged() = 0
Parameters:
- none.
Return Value: void. Triggers CefViewDelegate::OnThemeChanged for
Usage Instruction: Manually trigger theme propagation after calling
Threading Constraint: Browser process UI thread. **Do not call from
virtual cef_runtime_style_t GetRuntimeStyle() = 0
Parameters:
- none.
Return Value: The runtime style (ALLOY or CHROME) for this window.
Usage Instruction: Determine which style the window was created with
Threading Constraint: Browser process UI thread.
Usage Example
CefRefPtr<CefWindow> window = CefWindow::CreateTopLevelWindow(new MyWindowDelegate());
window->SetTitle("My App");
window->SetWindowIcon(LoadIcon16());
window->AddChildView(content_panel);
window->SetAccelerator(IDC_QUIT, VKEY_Q, false, true, false, true);
window->Show();