]> git.saurik.com Git - wxWidgets.git/blob - include/wx/nativewin.h
Allow to customize wxGrid column auto-sizing.
[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 // GdkNativeWindow is guint32 under GDK/X11 and gpointer under GDK/WIN32
43 #ifdef __UNIX__
44 typedef unsigned long wxNativeContainerWindowId;
45 #else
46 typedef void *wxNativeContainerWindowId;
47 #endif
48 typedef GdkWindow *wxNativeContainerWindowHandle;
49 #else
50 // no support for using native windows under this platform yet
51 #undef wxHAS_NATIVE_CONTAINER_WINDOW
52 #endif
53
54 #ifdef wxHAS_NATIVE_CONTAINER_WINDOW
55
56 // ----------------------------------------------------------------------------
57 // wxNativeContainerWindow: can be used for creating other wxWindows inside it
58 // ----------------------------------------------------------------------------
59
60 class WXDLLIMPEXP_CORE wxNativeContainerWindow : public wxTopLevelWindow
61 {
62 public:
63 // default ctor, call Create() later
64 wxNativeContainerWindow() { }
65
66 // create a window from an existing native window handle
67 //
68 // use GetHandle() to check if the creation was successful, it will return
69 // 0 if the handle was invalid
70 wxNativeContainerWindow(wxNativeContainerWindowHandle handle)
71 {
72 Create(handle);
73 }
74
75 // same as ctor above but with a return code
76 bool Create(wxNativeContainerWindowHandle handle);
77
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
82 //
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); }
86
87 bool Create(wxNativeContainerWindowId winid);
88 #endif // wxGTK
89
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();
93
94
95 // provide (trivial) implementation of the base class pure virtuals
96 virtual void SetTitle(const wxString& WXUNUSED(title))
97 {
98 wxFAIL_MSG( "not implemented for native windows" );
99 }
100
101 virtual wxString GetTitle() const
102 {
103 wxFAIL_MSG( "not implemented for native windows" );
104
105 return wxString();
106 }
107
108 virtual void Maximize(bool WXUNUSED(maximize) = true)
109 {
110 wxFAIL_MSG( "not implemented for native windows" );
111 }
112
113 virtual bool IsMaximized() const
114 {
115 wxFAIL_MSG( "not implemented for native windows" );
116
117 return false;
118 }
119
120 virtual void Iconize(bool WXUNUSED(iconize) = true)
121 {
122 wxFAIL_MSG( "not implemented for native windows" );
123 }
124
125 virtual bool IsIconized() const
126 {
127 // this is called by wxGTK implementation so don't assert
128 return false;
129 }
130
131 virtual void Restore()
132 {
133 wxFAIL_MSG( "not implemented for native windows" );
134 }
135
136 virtual bool ShowFullScreen(bool WXUNUSED(show),
137 long WXUNUSED(style) = wxFULLSCREEN_ALL)
138 {
139 wxFAIL_MSG( "not implemented for native windows" );
140
141 return false;
142 }
143
144 virtual bool IsFullScreen() const
145 {
146 wxFAIL_MSG( "not implemented for native windows" );
147
148 return false;
149 }
150
151 #ifdef __WXMSW__
152 virtual bool IsShown() const;
153 #endif // __WXMSW__
154
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();
160
161 protected:
162 #ifdef __WXMSW__
163 virtual WXLRESULT
164 MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
165 #endif // __WXMSW__
166
167 private:
168 wxDECLARE_NO_COPY_CLASS(wxNativeContainerWindow);
169 };
170
171 #endif // wxHAS_NATIVE_CONTAINER_WINDOW
172
173 #endif // _WX_NATIVEWIN_H_
174