2008-03-10 11:50:48 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/nativewin.h
|
|
|
|
// Purpose: classes allowing to wrap a native window handle
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2008-03-05
|
|
|
|
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_NATIVEWIN_H_
|
|
|
|
#define _WX_NATIVEWIN_H_
|
|
|
|
|
|
|
|
#include "wx/toplevel.h"
|
|
|
|
|
2015-08-03 11:47:09 -04:00
|
|
|
// These symbols can be tested in the user code to see if the current wx port
|
|
|
|
// has support for creating wxNativeContainerWindow and wxNativeWindow from
|
|
|
|
// native windows.
|
2008-03-10 11:50:48 -04:00
|
|
|
//
|
2015-08-03 11:47:09 -04:00
|
|
|
// Be optimistic by default, we undefine them below if necessary.
|
2008-03-10 11:50:48 -04:00
|
|
|
#define wxHAS_NATIVE_CONTAINER_WINDOW
|
2015-08-03 11:47:09 -04:00
|
|
|
#define wxHAS_NATIVE_WINDOW
|
2008-03-10 11:50:48 -04:00
|
|
|
|
|
|
|
// we define the following typedefs for each of the platform supporting native
|
|
|
|
// windows wrapping:
|
|
|
|
//
|
|
|
|
// - wxNativeContainerWindowHandle is the toolkit-level handle of the native
|
|
|
|
// window, i.e. HWND/GdkWindow*/NSWindow
|
|
|
|
//
|
|
|
|
// - wxNativeContainerWindowId is the lowest level identifier of the native
|
|
|
|
// window, i.e. HWND/GdkNativeWindow/NSWindow (so it's the same as above for
|
|
|
|
// all platforms except GTK where we also can work with Window/XID)
|
|
|
|
//
|
2015-08-03 11:47:09 -04:00
|
|
|
// - wxNativeWindowHandle for child windows, i.e. HWND/GtkWidget*/NSControl
|
2008-03-10 11:50:48 -04:00
|
|
|
#if defined(__WXMSW__)
|
|
|
|
#include "wx/msw/wrapwin.h"
|
|
|
|
|
|
|
|
typedef HWND wxNativeContainerWindowId;
|
|
|
|
typedef HWND wxNativeContainerWindowHandle;
|
2015-08-03 11:47:09 -04:00
|
|
|
typedef HWND wxNativeWindowHandle;
|
2008-03-10 11:50:48 -04:00
|
|
|
#elif defined(__WXGTK__)
|
2015-08-03 11:47:09 -04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-07-10 19:52:14 -04:00
|
|
|
// GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32
|
|
|
|
#ifdef __UNIX__
|
|
|
|
typedef unsigned long wxNativeContainerWindowId;
|
|
|
|
#else
|
|
|
|
typedef void *wxNativeContainerWindowId;
|
|
|
|
#endif
|
2008-03-10 11:50:48 -04:00
|
|
|
typedef GdkWindow *wxNativeContainerWindowHandle;
|
2015-08-03 11:47:09 -04:00
|
|
|
typedef GtkWidget *wxNativeWindowHandle;
|
|
|
|
#elif defined(__WXOSX_COCOA__)
|
|
|
|
typedef NSView *wxNativeWindowHandle;
|
|
|
|
|
|
|
|
// no support for using native TLWs yet
|
|
|
|
#undef wxHAS_NATIVE_CONTAINER_WINDOW
|
2008-03-10 11:50:48 -04:00
|
|
|
#else
|
|
|
|
// no support for using native windows under this platform yet
|
|
|
|
#undef wxHAS_NATIVE_CONTAINER_WINDOW
|
2015-08-03 11:47:09 -04:00
|
|
|
#undef wxHAS_NATIVE_WINDOW
|
2008-03-10 11:50:48 -04:00
|
|
|
#endif
|
|
|
|
|
2015-08-03 11:47:09 -04:00
|
|
|
#ifdef wxHAS_NATIVE_WINDOW
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxNativeWindow: for using native windows inside wxWidgets windows
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxNativeWindow : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Default ctor, Create() must be called later to really create the window.
|
|
|
|
wxNativeWindow() { }
|
|
|
|
|
|
|
|
// Create a window from an existing native window handle.
|
|
|
|
//
|
|
|
|
// Notice that this ctor doesn't take the usual pos and size parameters,
|
|
|
|
// they're taken from the window handle itself.
|
|
|
|
//
|
|
|
|
// Use GetHandle() to check if the creation was successful, it will return
|
|
|
|
// 0 if the handle was invalid.
|
|
|
|
wxNativeWindow(wxWindow* parent, wxWindowID winid, wxNativeWindowHandle handle)
|
|
|
|
{
|
|
|
|
Create(parent, winid, handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Same as non-default ctor, but with a return code.
|
|
|
|
bool Create(wxWindow* parent, wxWindowID winid, wxNativeWindowHandle handle);
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxNativeWindow);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxHAS_NATIVE_WINDOW
|
|
|
|
|
2008-03-10 11:50:48 -04:00
|
|
|
#ifdef wxHAS_NATIVE_CONTAINER_WINDOW
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxNativeContainerWindow: can be used for creating other wxWindows inside it
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxNativeContainerWindow : public wxTopLevelWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// default ctor, call Create() later
|
|
|
|
wxNativeContainerWindow() { }
|
|
|
|
|
|
|
|
// create a window from an existing native window handle
|
|
|
|
//
|
|
|
|
// use GetHandle() to check if the creation was successful, it will return
|
|
|
|
// 0 if the handle was invalid
|
|
|
|
wxNativeContainerWindow(wxNativeContainerWindowHandle handle)
|
|
|
|
{
|
|
|
|
Create(handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
// same as ctor above but with a return code
|
|
|
|
bool Create(wxNativeContainerWindowHandle handle);
|
|
|
|
|
|
|
|
#if defined(__WXGTK__)
|
|
|
|
// this is a convenient ctor for wxGTK applications which can also create
|
|
|
|
// the objects of this class from the really native window handles and not
|
|
|
|
// only the GdkWindow objects
|
|
|
|
//
|
|
|
|
// wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11
|
|
|
|
// (when GDK_WINDOWING_X11 is defined) or HWND under Win32
|
|
|
|
wxNativeContainerWindow(wxNativeContainerWindowId winid) { Create(winid); }
|
|
|
|
|
|
|
|
bool Create(wxNativeContainerWindowId winid);
|
|
|
|
#endif // wxGTK
|
|
|
|
|
|
|
|
// unlike for the normal windows, dtor will not destroy the native window
|
|
|
|
// as it normally doesn't belong to us
|
|
|
|
virtual ~wxNativeContainerWindow();
|
|
|
|
|
|
|
|
|
|
|
|
// provide (trivial) implementation of the base class pure virtuals
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void SetTitle(const wxString& WXUNUSED(title)) wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxString GetTitle() const wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
|
|
|
|
return wxString();
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Maximize(bool WXUNUSED(maximize) = true) wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsMaximized() const wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Iconize(bool WXUNUSED(iconize) = true) wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsIconized() const wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
// this is called by wxGTK implementation so don't assert
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual void Restore() wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool ShowFullScreen(bool WXUNUSED(show),
|
2014-03-29 20:02:23 -04:00
|
|
|
long WXUNUSED(style) = wxFULLSCREEN_ALL) wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool IsFullScreen() const wxOVERRIDE
|
2008-03-10 11:50:48 -04:00
|
|
|
{
|
|
|
|
wxFAIL_MSG( "not implemented for native windows" );
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-05 12:31:07 -05:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
virtual bool IsShown() const;
|
|
|
|
#endif // __WXMSW__
|
2008-03-10 20:03:46 -04:00
|
|
|
|
|
|
|
// this is an implementation detail: called when the native window is
|
|
|
|
// destroyed by an outside agency; deletes the C++ object too but can in
|
|
|
|
// principle be overridden to something else (knowing that the window
|
|
|
|
// handle of this object and all of its children is invalid any more)
|
|
|
|
virtual void OnNativeDestroyed();
|
|
|
|
|
2008-03-14 23:36:15 -04:00
|
|
|
protected:
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
virtual WXLRESULT
|
|
|
|
MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
|
|
|
#endif // __WXMSW__
|
|
|
|
|
2008-03-10 11:50:48 -04:00
|
|
|
private:
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow);
|
2008-03-10 11:50:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxHAS_NATIVE_CONTAINER_WINDOW
|
|
|
|
|
|
|
|
#endif // _WX_NATIVEWIN_H_
|
|
|
|
|