2015-08-03 11:47:09 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/nativewin.h
|
|
|
|
// Purpose: wxNativeWindow documentation.
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2015-07-31
|
|
|
|
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxNativeWindow
|
|
|
|
|
2019-01-25 21:14:20 -05:00
|
|
|
Allows embedding a native widget in an application using wxWidgets.
|
2015-08-03 11:47:09 -04:00
|
|
|
|
|
|
|
This class can be used as a bridge between wxWidgets and native GUI
|
|
|
|
toolkit, i.e. standard Windows controls under MSW, GTK+ widgets or Cocoa
|
|
|
|
views. Using it involves writing code specific to each platform, at the
|
2015-11-10 10:09:21 -05:00
|
|
|
very least for creating and destroying the native window, but possibly also
|
|
|
|
to handle its events, but this class takes care of all the generic parts.
|
2015-08-03 11:47:09 -04:00
|
|
|
|
|
|
|
@note Check whether @c wxHAS_NATIVE_WINDOW is defined before using this
|
|
|
|
class as it is not available under all platforms.
|
|
|
|
|
|
|
|
For example, to embed a native GTK+ "light switch" control in a wxWidgets
|
|
|
|
dialog you could do the following:
|
|
|
|
@code
|
|
|
|
#include <wx/nativewin.h>
|
|
|
|
|
2015-11-10 10:09:21 -05:00
|
|
|
GtkWidget* w = gtk_switch_new();
|
|
|
|
wxNativeWindow* switch = new wxNativeWindow(parent, wxID_ANY, w);
|
|
|
|
g_object_unref(w);
|
2015-08-03 11:47:09 -04:00
|
|
|
@endcode
|
|
|
|
and then use @c switch as usual, e.g. add it to a sizer to layout it
|
|
|
|
correctly. Of course, you will still have to use the native GTK+ functions
|
|
|
|
to handle its events and change or retrieve its state.
|
|
|
|
|
2015-11-10 10:09:21 -05:00
|
|
|
Notice that the native window still remains owned by the caller, to allow
|
|
|
|
reusing it later independently of wxWidgets. If you want wxWidgets to
|
|
|
|
delete the native window when the wxNativeWindow itself is destroyed, you
|
|
|
|
need to explicitly call Disown(). Otherwise you need to perform the
|
|
|
|
necessary cleanup in your own code by calling the appropriate
|
|
|
|
platform-specific function: under MSW, this is @c ::DestroyWindow(), under
|
|
|
|
GTK @c g_object_unref() and under Cocoa -- @c -release:.
|
|
|
|
|
|
|
|
See the "native" page of the widgets sample for the examples of using
|
|
|
|
this class under all major platforms.
|
2015-08-03 11:47:09 -04:00
|
|
|
|
|
|
|
@since 3.1.0
|
|
|
|
|
2015-10-31 16:35:30 -04:00
|
|
|
@library{wxcore}
|
2015-08-03 11:47:09 -04:00
|
|
|
@category{ctrl}
|
|
|
|
*/
|
|
|
|
class wxNativeWindow : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default ctor, Create() must be called later to really create the window.
|
|
|
|
*/
|
|
|
|
wxNativeWindow();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create a window from an existing native window handle.
|
|
|
|
|
|
|
|
Notice that this ctor doesn't take the usual @c pos and @c size
|
|
|
|
parameters, they're taken from the window handle itself.
|
|
|
|
|
|
|
|
Use GetHandle() to check if the creation was successful, it will return
|
|
|
|
0 if the handle was invalid.
|
|
|
|
|
|
|
|
See Create() for the detailed parameters documentation.
|
|
|
|
*/
|
2016-03-02 17:32:19 -05:00
|
|
|
wxNativeWindow(wxWindow* parent, wxWindowID winid, wxNativeWindowHandle handle);
|
2015-08-03 11:47:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Really create the window after using the default ctor to create the C++
|
|
|
|
object.
|
|
|
|
|
|
|
|
@param parent A non-NULL parent window. For the platforms where the
|
|
|
|
parent is used for creating the native window (e.g. MSW), this must
|
|
|
|
be the wxWindow corresponding to the parent handle used when
|
|
|
|
creating the native window.
|
|
|
|
@param winid ID for the new window which will be used for the events
|
|
|
|
generated by it and can also be used to FindWindowById().
|
|
|
|
@param handle A valid native window handle, i.e. HWND under MSW.
|
|
|
|
@return @true if the creation was successful or @false if it failed,
|
|
|
|
typically because the supplied parameters are invalid.
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID winid, wxNativeWindowHandle handle);
|
2015-11-10 10:09:21 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Indicate that the user code yields ownership of the native window.
|
|
|
|
|
|
|
|
This method can be called at most once and after calling it, the native
|
|
|
|
window will be destroyed when this wxNativeWindow object is.
|
|
|
|
*/
|
|
|
|
void Disown();
|
2015-08-03 11:47:09 -04:00
|
|
|
};
|