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