added wxNativeContainerWindow and implemented it for wxMSW and wxGTK

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-03-10 15:50:48 +00:00
parent 478c805363
commit dfba244cbf
12 changed files with 466 additions and 1 deletions

74
src/gtk/nativewin.cpp Normal file
View File

@@ -0,0 +1,74 @@
///////////////////////////////////////////////////////////////////////////////
// Name: src/gtk/nativewin.cpp
// Purpose: wxNativeWindow implementation
// Author: Vadim Zeitlin
// Created: 2008-03-05
// RCS-ID: $Id$
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#endif // WX_PRECOMP
#include "wx/nativewin.h"
#include <gtk/gtk.h>
// ============================================================================
// implementation
// ============================================================================
bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle *win)
{
if ( !wxTopLevelWindow::Create(NULL, wxID_ANY, "") )
return false;
// we need to realize the window first before reparenting it
gtk_widget_realize(m_widget);
gdk_window_reparent(m_widget->window, win, 0, 0);
// we should be initially visible as we suppose that the native window we
// wrap is (we could use gdk_window_is_visible() to test for this but this
// doesn't make much sense unless we also react to visibility changes, so
// just suppose it's always shown for now)
Show();
}
bool wxNativeContainerWindow::Create(wxNativeContainerWindowId anid)
{
bool rc;
GdkWindow * const win = gdk_window_foreign_new(anid);
if ( win )
{
rc = Create(win);
g_object_unref(win);
}
else // invalid native window id
{
rc = false;
}
return rc;
}
wxNativeContainerWindow::~wxNativeContainerWindow()
{
// there doesn't seem to be anything to do here, GTK+ seems to handle
// everything correctly due to its use of reference counting
}