1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: Mozilla-sample-code 1.0
4 * Copyright (c) 2002 Netscape Communications Corporation and
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this Mozilla sample software and associated documentation files
9 * (the "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to permit
12 * persons to whom the Software is furnished to do so, subject to the
13 * following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
27 * Adam Lock <adamlock@netscape.com>
29 * ***** END LICENSE BLOCK ***** */
33 #include "GeckoWindow.h"
34 #include "nsIWebBrowserFocus.h"
36 IMPLEMENT_DYNAMIC_CLASS(GeckoWindow
, wxPanel
)
38 GeckoWindow::GeckoWindow(void) :
43 GeckoWindow::~GeckoWindow()
45 SetGeckoContainer(NULL
);
48 void GeckoWindow::SetGeckoContainer(GeckoContainer
*aGeckoContainer
)
50 if (aGeckoContainer
!= mGeckoContainer
)
52 NS_IF_RELEASE(mGeckoContainer
);
53 mGeckoContainer
= aGeckoContainer
;
54 NS_IF_ADDREF(mGeckoContainer
);
58 BEGIN_EVENT_TABLE(GeckoWindow
, wxPanel
)
59 EVT_SIZE( GeckoWindow::OnSize
)
60 EVT_SET_FOCUS( GeckoWindow::OnSetFocus
)
61 EVT_KILL_FOCUS(GeckoWindow::OnKillFocus
)
64 void GeckoWindow::OnSize(wxSizeEvent
&event
)
70 // Make sure the browser is visible and sized
71 nsCOMPtr
<nsIWebBrowser
> webBrowser
;
72 mGeckoContainer
->GetWebBrowser(getter_AddRefs(webBrowser
));
73 nsCOMPtr
<nsIBaseWindow
> webBrowserAsWin
= do_QueryInterface(webBrowser
);
76 wxSize size
= GetClientSize();
77 webBrowserAsWin
->SetPositionAndSize(
78 0, 0, size
.GetWidth(), size
.GetHeight(), PR_TRUE
);
79 webBrowserAsWin
->SetVisibility(PR_TRUE
);
83 void GeckoWindow::OnSetFocus(wxFocusEvent
&event
)
87 void GeckoWindow::OnKillFocus(wxFocusEvent
&event
)