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 typedef unsigned long wxNativeContainerWindowId
;
43 typedef GdkWindow
*wxNativeContainerWindowHandle
;
45 // no support for using native windows under this platform yet
46 #undef wxHAS_NATIVE_CONTAINER_WINDOW
49 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
51 // ----------------------------------------------------------------------------
52 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
53 // ----------------------------------------------------------------------------
55 class WXDLLIMPEXP_CORE wxNativeContainerWindow
: public wxTopLevelWindow
58 // default ctor, call Create() later
59 wxNativeContainerWindow() { }
61 // create a window from an existing native window handle
63 // use GetHandle() to check if the creation was successful, it will return
64 // 0 if the handle was invalid
65 wxNativeContainerWindow(wxNativeContainerWindowHandle handle
)
70 // same as ctor above but with a return code
71 bool Create(wxNativeContainerWindowHandle handle
);
73 #if defined(__WXGTK__)
74 // this is a convenient ctor for wxGTK applications which can also create
75 // the objects of this class from the really native window handles and not
76 // only the GdkWindow objects
78 // wxNativeContainerWindowId is Window (i.e. an XID, i.e. an int) under X11
79 // (when GDK_WINDOWING_X11 is defined) or HWND under Win32
80 wxNativeContainerWindow(wxNativeContainerWindowId winid
) { Create(winid
); }
82 bool Create(wxNativeContainerWindowId winid
);
85 // unlike for the normal windows, dtor will not destroy the native window
86 // as it normally doesn't belong to us
87 virtual ~wxNativeContainerWindow();
90 // provide (trivial) implementation of the base class pure virtuals
91 virtual void SetTitle(const wxString
& WXUNUSED(title
))
93 wxFAIL_MSG( "not implemented for native windows" );
96 virtual wxString
GetTitle() const
98 wxFAIL_MSG( "not implemented for native windows" );
103 virtual void Maximize(bool WXUNUSED(maximize
) = true)
105 wxFAIL_MSG( "not implemented for native windows" );
108 virtual bool IsMaximized() const
110 wxFAIL_MSG( "not implemented for native windows" );
115 virtual void Iconize(bool WXUNUSED(iconize
) = true)
117 wxFAIL_MSG( "not implemented for native windows" );
120 virtual bool IsIconized() const
122 // this is called by wxGTK implementation so don't assert
126 virtual void Restore()
128 wxFAIL_MSG( "not implemented for native windows" );
131 virtual bool ShowFullScreen(bool WXUNUSED(show
),
132 long WXUNUSED(style
) = wxFULLSCREEN_ALL
)
134 wxFAIL_MSG( "not implemented for native windows" );
139 virtual bool IsFullScreen() const
141 wxFAIL_MSG( "not implemented for native windows" );
147 virtual bool IsShown() const;
150 // this is an implementation detail: called when the native window is
151 // destroyed by an outside agency; deletes the C++ object too but can in
152 // principle be overridden to something else (knowing that the window
153 // handle of this object and all of its children is invalid any more)
154 virtual void OnNativeDestroyed();
159 MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
163 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow
);
166 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
168 #endif // _WX_NATIVEWIN_H_