1 // Copyright (c) 2008 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
32 #define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
35 #include "include/internal/cef_types_win.h"
36 #include "include/internal/cef_types_wrappers.h"
41 #define CefCursorHandle cef_cursor_handle_t
42 #define CefEventHandle cef_event_handle_t
43 #define CefWindowHandle cef_window_handle_t
44 #define CefTextInputContext cef_text_input_context_t
46 struct CefMainArgsTraits {
47 typedef cef_main_args_t struct_type;
49 static inline void init(struct_type* s) {}
50 static inline void clear(struct_type* s) {}
52 static inline void set(const struct_type* src, struct_type* target,
54 target->instance = src->instance;
58 // Class representing CefExecuteProcess arguments.
59 class CefMainArgs : public CefStructBase<CefMainArgsTraits> {
61 typedef CefStructBase<CefMainArgsTraits> parent;
63 CefMainArgs() : parent() {}
64 explicit CefMainArgs(const cef_main_args_t& r) : parent(r) {}
65 explicit CefMainArgs(const CefMainArgs& r) : parent(r) {}
66 explicit CefMainArgs(HINSTANCE hInstance) : parent() {
71 struct CefWindowInfoTraits {
72 typedef cef_window_info_t struct_type;
74 static inline void init(struct_type* s) {}
76 static inline void clear(struct_type* s) {
77 cef_string_clear(&s->window_name);
80 static inline void set(const struct_type* src, struct_type* target,
82 target->ex_style = src->ex_style;
83 cef_string_set(src->window_name.str, src->window_name.length,
84 &target->window_name, copy);
85 target->style = src->style;
88 target->width = src->width;
89 target->height = src->height;
90 target->parent_window = src->parent_window;
91 target->menu = src->menu;
92 target->transparent_painting_enabled = src->transparent_painting_enabled;
93 target->windowless_rendering_enabled = src->windowless_rendering_enabled;
94 target->window = src->window;
99 // Class representing window information.
101 class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
103 typedef CefStructBase<CefWindowInfoTraits> parent;
105 CefWindowInfo() : parent() {}
106 explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
107 explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
110 // Create the browser as a child window.
112 void SetAsChild(CefWindowHandle parent, RECT windowRect) {
113 style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
115 parent_window = parent;
118 width = windowRect.right - windowRect.left;
119 height = windowRect.bottom - windowRect.top;
123 // Create the browser as a popup window.
125 void SetAsPopup(CefWindowHandle parent, const CefString& windowName) {
126 style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
128 parent_window = parent;
131 width = CW_USEDEFAULT;
132 height = CW_USEDEFAULT;
134 cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
138 // Create the browser using windowless (off-screen) rendering. No window
139 // will be created for the browser and all rendering will occur via the
140 // CefRenderHandler interface. The |parent| value will be used to identify
141 // monitor info and to act as the parent window for dialogs, context menus,
142 // etc. If |parent| is not provided then the main screen monitor will be used
143 // and some functionality that requires a parent window may not function
144 // correctly. If |transparent| is true a transparent background color will be
145 // used (RGBA=0x00000000). If |transparent| is false the background will be
146 // white and opaque. In order to create windowless browsers the
147 // CefSettings.windowless_rendering_enabled value must be set to true.
149 void SetAsWindowless(CefWindowHandle parent, bool transparent) {
150 windowless_rendering_enabled = TRUE;
151 parent_window = parent;
152 transparent_painting_enabled = transparent;
156 #endif // CEF_INCLUDE_INTERNAL_CEF_WIN_H_