1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/nativewin.h
3 // Purpose: classes allowing to wrap a native window handle
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_NATIVEWIN_H_
11 #define _WX_NATIVEWIN_H_
13 #include "wx/toplevel.h"
15 // this symbol can be tested in the user code to see if the current wx port has
16 // support for creating wxNativeContainerWindow from native windows
18 // be optimistic by default, we undefine it below if we don't have it finally
19 #define wxHAS_NATIVE_CONTAINER_WINDOW
21 // we define the following typedefs for each of the platform supporting native
24 // - wxNativeContainerWindowHandle is the toolkit-level handle of the native
25 // window, i.e. HWND/GdkWindow*/NSWindow
27 // - wxNativeContainerWindowId is the lowest level identifier of the native
28 // window, i.e. HWND/GdkNativeWindow/NSWindow (so it's the same as above for
29 // all platforms except GTK where we also can work with Window/XID)
31 // later we'll also have
33 // - wxNativeWindowHandle for child windows (which will be wrapped by
34 // wxNativeWindow<T> class), it is HWND/GtkWidget*/ControlRef
35 #if defined(__WXMSW__)
36 #include "wx/msw/wrapwin.h"
38 typedef HWND wxNativeContainerWindowId
;
39 typedef HWND wxNativeContainerWindowHandle
;
40 #elif defined(__WXGTK__)
41 // GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32
43 typedef unsigned long wxNativeContainerWindowId
;
45 typedef void *wxNativeContainerWindowId
;
47 typedef GdkWindow
*wxNativeContainerWindowHandle
;
49 // no support for using native windows under this platform yet
50 #undef wxHAS_NATIVE_CONTAINER_WINDOW
53 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
55 // ----------------------------------------------------------------------------
56 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
57 // ----------------------------------------------------------------------------
59 class WXDLLIMPEXP_CORE wxNativeContainerWindow
: public wxTopLevelWindow
62 // default ctor, call Create() later
63 wxNativeContainerWindow() { }
65 // create a window from an existing native window handle
67 // use GetHandle() to check if the creation was successful, it will return
68 // 0 if the handle was invalid
69 wxNativeContainerWindow(wxNativeContainerWindowHandle handle
)
74 // same as ctor above but with a return code
75 bool Create(wxNativeContainerWindowHandle handle
);
77 #if defined(__WXGTK__)
78 // this is a convenient ctor for wxGTK applications which can also create
79 // the objects of this class from the really native window handles and not
80 // only the GdkWindow objects
82 // wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11
83 // (when GDK_WINDOWING_X11 is defined) or HWND under Win32
84 wxNativeContainerWindow(wxNativeContainerWindowId winid
) { Create(winid
); }
86 bool Create(wxNativeContainerWindowId winid
);
89 // unlike for the normal windows, dtor will not destroy the native window
90 // as it normally doesn't belong to us
91 virtual ~wxNativeContainerWindow();
94 // provide (trivial) implementation of the base class pure virtuals
95 virtual void SetTitle(const wxString
& WXUNUSED(title
))
97 wxFAIL_MSG( "not implemented for native windows" );
100 virtual wxString
GetTitle() const
102 wxFAIL_MSG( "not implemented for native windows" );
107 virtual void Maximize(bool WXUNUSED(maximize
) = true)
109 wxFAIL_MSG( "not implemented for native windows" );
112 virtual bool IsMaximized() const
114 wxFAIL_MSG( "not implemented for native windows" );
119 virtual void Iconize(bool WXUNUSED(iconize
) = true)
121 wxFAIL_MSG( "not implemented for native windows" );
124 virtual bool IsIconized() const
126 // this is called by wxGTK implementation so don't assert
130 virtual void Restore()
132 wxFAIL_MSG( "not implemented for native windows" );
135 virtual bool ShowFullScreen(bool WXUNUSED(show
),
136 long WXUNUSED(style
) = wxFULLSCREEN_ALL
)
138 wxFAIL_MSG( "not implemented for native windows" );
143 virtual bool IsFullScreen() const
145 wxFAIL_MSG( "not implemented for native windows" );
151 virtual bool IsShown() const;
154 // this is an implementation detail: called when the native window is
155 // destroyed by an outside agency; deletes the C++ object too but can in
156 // principle be overridden to something else (knowing that the window
157 // handle of this object and all of its children is invalid any more)
158 virtual void OnNativeDestroyed();
163 MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
167 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow
);
170 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
172 #endif // _WX_NATIVEWIN_H_