Add wxNativeWindow allowing to easily embed native widgets in wx.
Implement the class for wxMSW, wxGTK and wxOSX/Cocoa, show it in the widgets sample and add documentation for it.
This commit is contained in:
@@ -32,6 +32,57 @@
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNativeWindow
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
wxNativeWindow::Create(wxWindow* parent,
|
||||
wxWindowID winid,
|
||||
wxNativeWindowHandle hwnd)
|
||||
{
|
||||
wxCHECK_MSG( hwnd, false, wxS("Invalid null HWND") );
|
||||
wxCHECK_MSG( parent, false, wxS("Must have a valid parent") );
|
||||
wxASSERT_MSG( ::GetParent(hwnd) == GetHwndOf(parent),
|
||||
wxS("The native window has incorrect parent") );
|
||||
|
||||
const wxRect r = wxRectFromRECT(wxGetWindowRect(hwnd));
|
||||
|
||||
// Skip wxWindow::Create() which would try to create a new HWND, we don't
|
||||
// want this as we already have one.
|
||||
if ( !CreateBase(parent, winid,
|
||||
r.GetPosition(), r.GetSize(),
|
||||
0, wxDefaultValidator, wxS("nativewindow")) )
|
||||
return false;
|
||||
|
||||
parent->AddChild(this);
|
||||
|
||||
SubclassWin(hwnd);
|
||||
|
||||
if ( winid == wxID_ANY )
|
||||
{
|
||||
// We allocated a new ID to the control, use it at Windows level as
|
||||
// well because we assume that our and MSW IDs are the same in many
|
||||
// places and it seems prudent to avoid breaking this assumption.
|
||||
SetId(GetId());
|
||||
}
|
||||
else // We used a fixed ID.
|
||||
{
|
||||
// For the same reason as above, check that it's the same as the one
|
||||
// used by the native HWND.
|
||||
wxASSERT_MSG( ::GetWindowLong(hwnd, GWL_ID) == winid,
|
||||
wxS("Mismatch between wx and native IDs") );
|
||||
}
|
||||
|
||||
InheritAttributes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxNativeContainerWindow
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle hwnd)
|
||||
{
|
||||
if ( !::IsWindow(hwnd) )
|
||||
|
||||
Reference in New Issue
Block a user