Audacity 3.2.0
NativeWindow.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 NativeWindow.h
6
7 Audacity(R) is copyright (c) 1999-2008 Audacity Team.
8 License: GPL v2 or later. See License.txt.
9
10 NOTE: Mostly copied from wxWidgets 3.1.1
11
12*********************************************************************/
13
14#ifndef NATIVEWINDOW_H
15#define NATIVEWINDOW_H
16
17#if defined(__WXMSW__)
18#include <wx/msw/private.h>
19#elif defined(__WXMAC__)
20#include <wx/osx/core/private.h>
21#include <wx/osx/cocoa/private.h>
22#elif defined(__WXGTK__)
23#include <gtk/gtk.h>
24#endif
25
26class NativeWindow : public wxWindow
27{
28public:
30 {
31 }
32
33#if defined(__WXMSW__)
34
35 virtual ~NativeWindow()
36 {
37 UnsubclassWin();
38 }
39
40 bool Create(wxWindow* parent, WXWidget hwnd)
41 {
42 const wxRect r = wxRectFromRECT(wxGetWindowRect((HWND)hwnd));
43
44 // Skip wxWindow::Create() which would try to create a new HWND, we don't
45 // want this as we already have one.
46 if (!CreateBase(parent,
47 wxID_ANY,
48 r.GetPosition(),
49 r.GetSize(),
50 0,
51 wxDefaultValidator,
52 wxS("nativewindow")))
53 {
54 return false;
55 }
56
57 parent->AddChild(this);
58
59 SubclassWin(hwnd);
60
61
62 InheritAttributes();
63
64 return true;
65 }
66
67#elif defined(__WXMAC__)
68
69 virtual ~NativeWindow()
70 {
71 GetPeer()->RemoveFromParent();
72 SetPeer( nullptr );
73 }
74
75 bool Create(wxWindow* parent, WXWidget view)
76 {
77 DontCreatePeer();
78
79 if (!wxWindow::Create(parent, wxID_ANY))
80 {
81 return false;
82 }
83
84 SetPeer(new wxWidgetCocoaImpl(this, view));
85
86 return true;
87 }
88
89#elif defined(__WXGTK__)
90
91 virtual ~NativeWindow()
92 {
93 }
94
95 bool Create(wxWindow* parent, WXWidget widget)
96 {
97 if (!CreateBase(parent, wxID_ANY))
98 {
99 return false;
100 }
101
102 m_widget = widget;
103 g_object_ref(m_widget);
104
105 parent->DoAddChild(this);
106
107 PostCreation();
108
109 // Ensure that the best (and minimal) size is set to fully display the
110 // widget.
111 GtkRequisition req;
112 gtk_widget_size_request(widget, &req);
113 SetInitialSize(wxSize(req.width, req.height));
114
115 return true;
116 }
117#endif
118};
119
120#endif
121
bool Create(wxWindow *parent, WXWidget hwnd)
Definition: NativeWindow.h:40
virtual ~NativeWindow()
Definition: NativeWindow.h:35