Back to index

lightning-sunbird  0.9+nobinonly
GeckoWindow.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: Mozilla-sample-code 1.0
00003  *
00004  * Copyright (c) 2002 Netscape Communications Corporation and
00005  * other contributors
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this Mozilla sample software and associated documentation files
00009  * (the "Software"), to deal in the Software without restriction, including
00010  * without limitation the rights to use, copy, modify, merge, publish,
00011  * distribute, sublicense, and/or sell copies of the Software, and to permit
00012  * persons to whom the Software is furnished to do so, subject to the
00013  * following conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be included
00016  * in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00021  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00023  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00024  * DEALINGS IN THE SOFTWARE.
00025  *
00026  * Contributor(s):
00027  *   Adam Lock <adamlock@netscape.com>
00028  *
00029  * ***** END LICENSE BLOCK ***** */
00030 
00031 #include "global.h"
00032 
00033 #include "GeckoWindow.h"
00034 #include "nsIWebBrowserFocus.h"
00035 
00036 IMPLEMENT_DYNAMIC_CLASS(GeckoWindow, wxPanel)
00037 
00038 GeckoWindow::GeckoWindow(void) :
00039     mGeckoContainer(NULL)
00040 {
00041 }
00042 
00043 GeckoWindow::~GeckoWindow()
00044 {
00045     SetGeckoContainer(NULL);
00046 }
00047 
00048 void GeckoWindow::SetGeckoContainer(GeckoContainer *aGeckoContainer)
00049 {
00050     if (aGeckoContainer != mGeckoContainer)
00051     {
00052         NS_IF_RELEASE(mGeckoContainer);
00053         mGeckoContainer = aGeckoContainer;
00054         NS_IF_ADDREF(mGeckoContainer);
00055     }
00056 }
00057 
00058 BEGIN_EVENT_TABLE(GeckoWindow, wxPanel)
00059     EVT_SIZE(      GeckoWindow::OnSize)
00060     EVT_SET_FOCUS( GeckoWindow::OnSetFocus)
00061     EVT_KILL_FOCUS(GeckoWindow::OnKillFocus)
00062 END_EVENT_TABLE()
00063 
00064 void GeckoWindow::OnSize(wxSizeEvent &event)
00065 {
00066     if (!mGeckoContainer)
00067     {
00068         return;
00069     }
00070     // Make sure the browser is visible and sized 
00071     nsCOMPtr<nsIWebBrowser> webBrowser;
00072     mGeckoContainer->GetWebBrowser(getter_AddRefs(webBrowser));
00073     nsCOMPtr<nsIBaseWindow> webBrowserAsWin = do_QueryInterface(webBrowser);
00074     if (webBrowserAsWin)
00075     {
00076         wxSize size = GetClientSize();
00077         webBrowserAsWin->SetPositionAndSize(
00078             0, 0, size.GetWidth(), size.GetHeight(), PR_TRUE);
00079         webBrowserAsWin->SetVisibility(PR_TRUE);
00080     }
00081 }
00082 
00083 void GeckoWindow::OnSetFocus(wxFocusEvent &event)
00084 {
00085 }
00086 
00087 void GeckoWindow::OnKillFocus(wxFocusEvent &event)
00088 {
00089 }