gfx/native_embed.h
A platform control inside a component tree: HWNDComponent, NSViewComponent, XEmbedComponent and ActiveXControlComponent.
#include <sonore/gfx/native_embed.h>- 4types
- Guides: The native editor
On this page
Design notes
The other direction from the peers
The window_*.h peers put a component tree inside somebody else's window. These put somebody else's window inside a component tree: a component that owns a rectangle and keeps a native child window -- a foreign HWND, an NSView, an X client, an ActiveX control -- in that rectangle, shown while the component is showing.
Following the component
The tree has no "moved" notification (setBounds is not virtual and an ancestor's move tells nobody), so the native window is brought into line at three moments: when the component is resized, when it is painted (which a move always causes, at the old place and the new), and on every tick of the TopLevelWindow it is in -- which is what catches an ancestor hidden, since a hidden subtree is not painted. Each check costs a comparison; the native call is made only for a change.
The host window is the peer's own window inside the TopLevelWindow the component is in (TopLevelWindow::getContentHandle). Anywhere else -- a plugin editor -- setParentWindow() names it (NativeEditor::handle()), and the caller ticks updateBounds() from its own clock.
What is here, and what is not
HWNDComponent Windows. RUN: parented, moved, sized, hidden and
released, read back from the window manager.
ActiveXControlComponent Windows: a control by CLSID, in-place activated
in a site window through IOleObject, with this
file's IOleClientSite/IOleInPlaceSite/
IOleInPlaceFrame. RUN with the WebBrowser
control, and the failure path with a CLSID that
names nothing.
NSViewComponent macOS: an NSView added to the peer's (flipped)
view. Compiled only.
XEmbedComponent X11: the XEmbed protocol, as embedder -- a
client window reparented into a socket window,
told XEMBED_EMBEDDED_NOTIFY, kept to the socket's
size, given focus and activation messages; or a
socket whose id another process embeds into.
Compiled only.
UIViewComponent and AndroidViewComponent are not here: this SDK has no
iOS or Android target to put them in.Types 4
class HWNDComponent : public Component, private detail::embed::Embedded
A foreign HWND inside the tree. It is not owned: the caller made it and destroys it. While set it is made a child (WS_CHILD) of the host window and kept at this component's place; on release it is hidden and handed back to the desktop with its old style.
class ActiveXControlComponent : public Component, private detail::embed::Embedded
An ActiveX control by CLSID, in-place active in this component's rectangle. COM must be (or become) single-threaded on this thread: createControl calls OleInitialize, and fails on a thread already in the multi-threaded apartment.
class NSViewComponent : public Component, private detail::embed::Embedded
An NSView inside the tree, added to the peer's view (which is flipped, so a frame's origin is its top-left as in the tree). Retained while set. NSViewComponentWithParent -- the reverse, a tree inside a host's view -- is a different class elsewhere.
class XEmbedComponent : public Component, private detail::embed::Embedded
The XEmbed protocol, embedder side.
A SOCKET window is made as a child of the peer's window, on a connection of this component's own, and kept at the component's place. A client is either handed over by id (the constructor taking one) and reparented into the socket, or arrives by reparenting itself into getHostWindowID() -- the id a socket gives another process. Either way it is told XEMBED_EMBEDDED_NOTIFY, mapped when its _XEMBED_INFO says so, kept to the socket's size, and told of activation and focus.