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__)
42 // GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32
44 typedef unsigned long wxNativeContainerWindowId
;
46 typedef void *wxNativeContainerWindowId
;
48 typedef GdkWindow
*wxNativeContainerWindowHandle
;
50 // no support for using native windows under this platform yet
51 #undef wxHAS_NATIVE_CONTAINER_WINDOW
54 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
56 // ----------------------------------------------------------------------------
57 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
58 // ----------------------------------------------------------------------------
60 class WXDLLIMPEXP_CORE wxNativeContainerWindow
: public wxTopLevelWindow
63 // default ctor, call Create() later
64 wxNativeContainerWindow() { }
66 // create a window from an existing native window handle
68 // use GetHandle() to check if the creation was successful, it will return
69 // 0 if the handle was invalid
70 wxNativeContainerWindow(wxNativeContainerWindowHandle handle
)
75 // same as ctor above but with a return code
76 bool Create(wxNativeContainerWindowHandle handle
);
78 #if defined(__WXGTK__)
79 // this is a convenient ctor for wxGTK applications which can also create
80 // the objects of this class from the really native window handles and not
81 // only the GdkWindow objects
83 // wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11
84 // (when GDK_WINDOWING_X11 is defined) or HWND under Win32
85 wxNativeContainerWindow(wxNativeContainerWindowId winid
) { Create(winid
); }
87 bool Create(wxNativeContainerWindowId winid
);
90 // unlike for the normal windows, dtor will not destroy the native window
91 // as it normally doesn't belong to us
92 virtual ~wxNativeContainerWindow();
95 // provide (trivial) implementation of the base class pure virtuals
96 virtual void SetTitle(const wxString
& WXUNUSED(title
))
98 wxFAIL_MSG( "not implemented for native windows" );
101 virtual wxString
GetTitle() const
103 wxFAIL_MSG( "not implemented for native windows" );
108 virtual void Maximize(bool WXUNUSED(maximize
) = true)
110 wxFAIL_MSG( "not implemented for native windows" );
113 virtual bool IsMaximized() const
115 wxFAIL_MSG( "not implemented for native windows" );
120 virtual void Iconize(bool WXUNUSED(iconize
) = true)
122 wxFAIL_MSG( "not implemented for native windows" );
125 virtual bool IsIconized() const
127 // this is called by wxGTK implementation so don't assert
131 virtual void Restore()
133 wxFAIL_MSG( "not implemented for native windows" );
136 virtual bool ShowFullScreen(bool WXUNUSED(show
),
137 long WXUNUSED(style
) = wxFULLSCREEN_ALL
)
139 wxFAIL_MSG( "not implemented for native windows" );
144 virtual bool IsFullScreen() const
146 wxFAIL_MSG( "not implemented for native windows" );
152 virtual bool IsShown() const;
155 // this is an implementation detail: called when the native window is
156 // destroyed by an outside agency; deletes the C++ object too but can in
157 // principle be overridden to something else (knowing that the window
158 // handle of this object and all of its children is invalid any more)
159 virtual void OnNativeDestroyed();
164 MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
168 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow
);
171 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
173 #endif // _WX_NATIVEWIN_H_