1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/nativewin.h
3 // Purpose: classes allowing to wrap a native window handle
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_NATIVEWIN_H_
12 #define _WX_NATIVEWIN_H_
14 #include "wx/toplevel.h"
16 // this symbol can be tested in the user code to see if the current wx port has
17 // support for creating wxNativeContainerWindow from native windows
19 // be optimistic by default, we undefine it below if we don't have it finally
20 #define wxHAS_NATIVE_CONTAINER_WINDOW
22 // we define the following typedefs for each of the platform supporting native
25 // - wxNativeContainerWindowHandle is the toolkit-level handle of the native
26 // window, i.e. HWND/GdkWindow*/NSWindow
28 // - wxNativeContainerWindowId is the lowest level identifier of the native
29 // window, i.e. HWND/GdkNativeWindow/NSWindow (so it's the same as above for
30 // all platforms except GTK where we also can work with Window/XID)
32 // later we'll also have
34 // - wxNativeWindowHandle for child windows (which will be wrapped by
35 // wxNativeWindow<T> class), it is HWND/GtkWidget*/ControlRef
36 #if defined(__WXMSW__)
37 #include "wx/msw/wrapwin.h"
39 typedef HWND wxNativeContainerWindowId
;
40 typedef HWND wxNativeContainerWindowHandle
;
41 #elif defined(__WXGTK__)
44 typedef GdkNativeWindow wxNativeContainerWindowId
;
45 typedef GdkWindow
*wxNativeContainerWindowHandle
;
47 // no support for using native windows under this platform yet
48 #undef wxHAS_NATIVE_CONTAINER_WINDOW
51 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
53 // ----------------------------------------------------------------------------
54 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
55 // ----------------------------------------------------------------------------
57 class WXDLLIMPEXP_CORE wxNativeContainerWindow
: public wxTopLevelWindow
60 // default ctor, call Create() later
61 wxNativeContainerWindow() { }
63 // create a window from an existing native window handle
65 // use GetHandle() to check if the creation was successful, it will return
66 // 0 if the handle was invalid
67 wxNativeContainerWindow(wxNativeContainerWindowHandle handle
)
72 // same as ctor above but with a return code
73 bool Create(wxNativeContainerWindowHandle handle
);
75 #if defined(__WXGTK__)
76 // this is a convenient ctor for wxGTK applications which can also create
77 // the objects of this class from the really native window handles and not
78 // only the GdkWindow objects
80 // wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11
81 // (when GDK_WINDOWING_X11 is defined) or HWND under Win32
82 wxNativeContainerWindow(wxNativeContainerWindowId winid
) { Create(winid
); }
84 bool Create(wxNativeContainerWindowId winid
);
87 // unlike for the normal windows, dtor will not destroy the native window
88 // as it normally doesn't belong to us
89 virtual ~wxNativeContainerWindow();
92 // provide (trivial) implementation of the base class pure virtuals
93 virtual void SetTitle(const wxString
& WXUNUSED(title
))
95 wxFAIL_MSG( "not implemented for native windows" );
98 virtual wxString
GetTitle() const
100 wxFAIL_MSG( "not implemented for native windows" );
105 virtual void Maximize(bool WXUNUSED(maximize
) = true)
107 wxFAIL_MSG( "not implemented for native windows" );
110 virtual bool IsMaximized() const
112 wxFAIL_MSG( "not implemented for native windows" );
117 virtual void Iconize(bool WXUNUSED(iconize
) = true)
119 wxFAIL_MSG( "not implemented for native windows" );
122 virtual bool IsIconized() const
124 // this is called by wxGTK implementation so don't assert
128 virtual void Restore()
130 wxFAIL_MSG( "not implemented for native windows" );
133 virtual bool ShowFullScreen(bool WXUNUSED(show
),
134 long WXUNUSED(style
) = wxFULLSCREEN_ALL
)
136 wxFAIL_MSG( "not implemented for native windows" );
141 virtual bool IsFullScreen() const
143 wxFAIL_MSG( "not implemented for native windows" );
149 // this is an implementation detail: called when the native window is
150 // destroyed by an outside agency; deletes the C++ object too but can in
151 // principle be overridden to something else (knowing that the window
152 // handle of this object and all of its children is invalid any more)
153 virtual void OnNativeDestroyed();
158 MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
162 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow
);
165 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
167 #endif // _WX_NATIVEWIN_H_