]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/internal/cef_win.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / internal / cef_win.h
1 // Copyright (c) 2008 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 #ifndef CEF_INCLUDE_INTERNAL_CEF_WIN_H_
32 #define CEF_INCLUDE_INTERNAL_CEF_WIN_H_
33 #pragma once
34
35 #include "include/internal/cef_types_win.h"
36 #include "include/internal/cef_types_wrappers.h"
37
38 ///
39 // Handle types.
40 ///
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
45
46 struct CefMainArgsTraits {
47   typedef cef_main_args_t struct_type;
48
49   static inline void init(struct_type* s) {}
50   static inline void clear(struct_type* s) {}
51
52   static inline void set(const struct_type* src, struct_type* target,
53       bool copy) {
54     target->instance = src->instance;
55   }
56 };
57
58 // Class representing CefExecuteProcess arguments.
59 class CefMainArgs : public CefStructBase<CefMainArgsTraits> {
60  public:
61   typedef CefStructBase<CefMainArgsTraits> parent;
62
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() {
67     instance = hInstance;
68   }
69 };
70
71 struct CefWindowInfoTraits {
72   typedef cef_window_info_t struct_type;
73
74   static inline void init(struct_type* s) {}
75
76   static inline void clear(struct_type* s) {
77     cef_string_clear(&s->window_name);
78   }
79
80   static inline void set(const struct_type* src, struct_type* target,
81       bool copy) {
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;
86     target->x = src->x;
87     target->y = src->y;
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;
95   }
96 };
97
98 ///
99 // Class representing window information.
100 ///
101 class CefWindowInfo : public CefStructBase<CefWindowInfoTraits> {
102  public:
103   typedef CefStructBase<CefWindowInfoTraits> parent;
104
105   CefWindowInfo() : parent() {}
106   explicit CefWindowInfo(const cef_window_info_t& r) : parent(r) {}
107   explicit CefWindowInfo(const CefWindowInfo& r) : parent(r) {}
108
109   ///
110   // Create the browser as a child window.
111   ///
112   void SetAsChild(CefWindowHandle parent, RECT windowRect) {
113     style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |
114             WS_VISIBLE;
115     parent_window = parent;
116     x = windowRect.left;
117     y = windowRect.top;
118     width = windowRect.right - windowRect.left;
119     height = windowRect.bottom - windowRect.top;
120   }
121
122   ///
123   // Create the browser as a popup window.
124   ///
125   void SetAsPopup(CefWindowHandle parent, const CefString& windowName) {
126     style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
127             WS_VISIBLE;
128     parent_window = parent;
129     x = CW_USEDEFAULT;
130     y = CW_USEDEFAULT;
131     width = CW_USEDEFAULT;
132     height = CW_USEDEFAULT;
133
134     cef_string_copy(windowName.c_str(), windowName.length(), &window_name);
135   }
136
137   ///
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.
148   ///
149   void SetAsWindowless(CefWindowHandle parent, bool transparent) {
150     windowless_rendering_enabled = TRUE;
151     parent_window = parent;
152     transparent_painting_enabled = transparent;
153   }
154 };
155
156 #endif  // CEF_INCLUDE_INTERNAL_CEF_WIN_H_