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:
74
src/gtk/nativewin.cpp
Normal file
74
src/gtk/nativewin.cpp
Normal 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
|
||||
}
|
Reference in New Issue
Block a user