]> git.saurik.com Git - wxWidgets.git/blob - include/wx/nativewin.h
Partial fix for #15196: wxRichTextCell caret issues (dghart)
[wxWidgets.git] / include / wx / nativewin.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/nativewin.h
3 // Purpose: classes allowing to wrap a native window handle
4 // Author: Vadim Zeitlin
5 // Created: 2008-03-05
6 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_NATIVEWIN_H_
11 #define _WX_NATIVEWIN_H_
12
13 #include "wx/toplevel.h"
14
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
17 //
18 // be optimistic by default, we undefine it below if we don't have it finally
19 #define wxHAS_NATIVE_CONTAINER_WINDOW
20
21 // we define the following typedefs for each of the platform supporting native
22 // windows wrapping:
23 //
24 // - wxNativeContainerWindowHandle is the toolkit-level handle of the native
25 // window, i.e. HWND/GdkWindow*/NSWindow
26 //
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)
30 //
31 // later we'll also have
32 //
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"
37
38 typedef HWND wxNativeContainerWindowId;
39 typedef HWND wxNativeContainerWindowHandle;
40 #elif defined(__WXGTK__)
41 // GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32
42 #ifdef __UNIX__
43 typedef unsigned long wxNativeContainerWindowId;
44 #else
45 typedef void *wxNativeContainerWindowId;
46 #endif
47 typedef GdkWindow *wxNativeContainerWindowHandle;
48 #else
49 // no support for using native windows under this platform yet
50 #undef wxHAS_NATIVE_CONTAINER_WINDOW
51 #endif
52
53 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
54
55 // ----------------------------------------------------------------------------
56 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
57 // ----------------------------------------------------------------------------
58
59 class WXDLLIMPEXP_CORE wxNativeContainerWindow : public wxTopLevelWindow
60 {
61 public:
62 // default ctor, call Create() later
63 wxNativeContainerWindow() { }
64
65 // create a window from an existing native window handle
66 //
67 // use GetHandle() to check if the creation was successful, it will return
68 // 0 if the handle was invalid
69 wxNativeContainerWindow(wxNativeContainerWindowHandle handle)
70 {
71 Create(handle);
72 }
73
74 // same as ctor above but with a return code
75 bool Create(wxNativeContainerWindowHandle handle);
76
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
81 //
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); }
85
86 bool Create(wxNativeContainerWindowId winid);
87 #endif // wxGTK
88
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();
92
93
94 // provide (trivial) implementation of the base class pure virtuals
95 virtual void SetTitle(const wxString& WXUNUSED(title))
96 {
97 wxFAIL_MSG( "not implemented for native windows" );
98 }
99
100 virtual wxString GetTitle() const
101 {
102 wxFAIL_MSG( "not implemented for native windows" );
103
104 return wxString();
105 }
106
107 virtual void Maximize(bool WXUNUSED(maximize) = true)
108 {
109 wxFAIL_MSG( "not implemented for native windows" );
110 }
111
112 virtual bool IsMaximized() const
113 {
114 wxFAIL_MSG( "not implemented for native windows" );
115
116 return false;
117 }
118
119 virtual void Iconize(bool WXUNUSED(iconize) = true)
120 {
121 wxFAIL_MSG( "not implemented for native windows" );
122 }
123
124 virtual bool IsIconized() const
125 {
126 // this is called by wxGTK implementation so don't assert
127 return false;
128 }
129
130 virtual void Restore()
131 {
132 wxFAIL_MSG( "not implemented for native windows" );
133 }
134
135 virtual bool ShowFullScreen(bool WXUNUSED(show),
136 long WXUNUSED(style) = wxFULLSCREEN_ALL)
137 {
138 wxFAIL_MSG( "not implemented for native windows" );
139
140 return false;
141 }
142
143 virtual bool IsFullScreen() const
144 {
145 wxFAIL_MSG( "not implemented for native windows" );
146
147 return false;
148 }
149
150 #ifdef __WXMSW__
151 virtual bool IsShown() const;
152 #endif // __WXMSW__
153
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();
159
160 protected:
161 #ifdef __WXMSW__
162 virtual WXLRESULT
163 MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
164 #endif // __WXMSW__
165
166 private:
167 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow);
168 };
169
170 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
171
172 #endif // _WX_NATIVEWIN_H_
173