Mozilla/mozilla/embedding/minimo/wince/WindowCreator.cpp
dougt%meer.net db37daf1ac Better idle event handling. removal of unneeded files. NPODB
git-svn-id: svn://10.0.0.236/trunk@175199 18797224-902f-48f8-a5cc-f745e15eee43
2005-06-28 04:11:13 +00:00

111 lines
3.4 KiB
C++
Executable File

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#include "WindowCreator.h"
#include "MinimoPrivate.h"
WindowCreator::WindowCreator()
{
}
WindowCreator::~WindowCreator()
{
}
NS_IMPL_ISUPPORTS1(WindowCreator, nsIWindowCreator)
nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome)
{
if (!chrome)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIEmbeddingSiteWindow> embeddingSite = do_QueryInterface(chrome);
HWND hWnd;
embeddingSite->GetSiteWindow((void **) & hWnd);
if (!hWnd)
return NS_ERROR_NULL_POINTER;
RECT rect;
GetClientRect(hWnd, &rect);
// Make sure the browser is visible and sized
nsCOMPtr<nsIWebBrowser> webBrowser;
chrome->GetWebBrowser(getter_AddRefs(webBrowser));
nsCOMPtr<nsIBaseWindow> webBrowserAsWin = do_QueryInterface(webBrowser);
if (webBrowserAsWin)
{
webBrowserAsWin->SetPositionAndSize(rect.left,
rect.top,
rect.right - rect.left,
rect.bottom - rect.top,
PR_TRUE);
webBrowserAsWin->SetVisibility(PR_TRUE);
}
return NS_OK;
}
NS_IMETHODIMP
WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
PRUint32 aChromeFlags,
nsIWebBrowserChrome **aNewWindow)
{
NS_ENSURE_ARG_POINTER(aNewWindow);
WebBrowserChrome * chrome = new WebBrowserChrome();
if (!chrome)
return NS_ERROR_FAILURE;
// now an extra addref; the window owns itself (to be released by
// WebBrowserChromeUI::Destroy)
NS_ADDREF(chrome);
chrome->SetChromeFlags(aChromeFlags);
// Insert the browser
nsCOMPtr<nsIWebBrowser> newBrowser;
chrome->CreateBrowser(-1, -1, -1, -1, getter_AddRefs(newBrowser));
if (!newBrowser)
{
NS_RELEASE(chrome);
return NS_ERROR_FAILURE;
}
// and an addref on the way out.
NS_ADDREF(chrome);
*aNewWindow = NS_STATIC_CAST(nsIWebBrowserChrome*, chrome);
ResizeEmbedding(chrome);
return NS_OK;
}