From 95cc240945e765a0eb01e83d088e95243d4fc2a1 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Fri, 13 Apr 2007 17:22:43 +0000 Subject: [PATCH] Bug 377410 - remove mfcembed, r=dougt git-svn-id: svn://10.0.0.236/trunk@224494 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/embedding/tests/Makefile.in | 11 - .../tests/mfcembed/BrowserFrameGlue.cpp | 508 ------ .../embedding/tests/mfcembed/BrowserFrm.cpp | 402 ----- mozilla/embedding/tests/mfcembed/BrowserFrm.h | 230 --- .../embedding/tests/mfcembed/BrowserImpl.cpp | 411 ----- .../embedding/tests/mfcembed/BrowserImpl.h | 71 - .../mfcembed/BrowserImplCtxMenuLstnr.cpp | 48 - .../tests/mfcembed/BrowserImplPrompt.cpp | 158 -- .../mfcembed/BrowserImplWebPrgrsLstnr.cpp | 155 -- .../tests/mfcembed/BrowserToolTip.cpp | 147 -- .../embedding/tests/mfcembed/BrowserToolTip.h | 87 - .../embedding/tests/mfcembed/BrowserView.cpp | 1333 ---------------- .../embedding/tests/mfcembed/BrowserView.h | 205 --- .../tests/mfcembed/CCustomPromptDialog.cpp | 43 - .../tests/mfcembed/CCustomPromptDialog.h | 77 - .../tests/mfcembed/CFormatOptionTab.cpp | 281 ---- .../tests/mfcembed/CFormatOptionTab.h | 100 -- .../tests/mfcembed/CMarginHeaderFooter.cpp | 172 -- .../tests/mfcembed/CMarginHeaderFooter.h | 99 -- .../tests/mfcembed/CPageSetupPropSheet.cpp | 229 --- .../tests/mfcembed/CPageSetupPropSheet.h | 91 -- mozilla/embedding/tests/mfcembed/Dialogs.cpp | 153 -- mozilla/embedding/tests/mfcembed/Dialogs.h | 80 - .../embedding/tests/mfcembed/EditorFrm.cpp | 674 -------- mozilla/embedding/tests/mfcembed/EditorFrm.h | 124 -- .../tests/mfcembed/IBrowserFrameGlue.h | 112 -- mozilla/embedding/tests/mfcembed/Makefile.in | 208 --- mozilla/embedding/tests/mfcembed/MfcEmbed.cpp | 922 ----------- mozilla/embedding/tests/mfcembed/MfcEmbed.h | 136 -- mozilla/embedding/tests/mfcembed/MfcEmbed.rc | 786 --------- .../tests/mfcembed/MostRecentUrls.cpp | 147 -- .../embedding/tests/mfcembed/MostRecentUrls.h | 49 - .../embedding/tests/mfcembed/Preferences.cpp | 107 -- .../embedding/tests/mfcembed/Preferences.h | 119 -- .../embedding/tests/mfcembed/ProfileMgr.cpp | 203 --- mozilla/embedding/tests/mfcembed/ProfileMgr.h | 63 - .../embedding/tests/mfcembed/ProfilesDlg.cpp | 333 ---- .../embedding/tests/mfcembed/ProfilesDlg.h | 150 -- mozilla/embedding/tests/mfcembed/README.TXT | 151 -- mozilla/embedding/tests/mfcembed/StdAfx.cpp | 39 - mozilla/embedding/tests/mfcembed/StdAfx.h | 133 -- .../tests/mfcembed/components/Dialogs.cpp | 430 ----- .../tests/mfcembed/components/Dialogs.h | 190 --- .../tests/mfcembed/components/Dialogs.rc | 214 --- .../mfcembed/components/HelperAppDlg.cpp | 606 ------- .../tests/mfcembed/components/HelperAppDlg.h | 151 -- .../mfcembed/components/HelperAppService.h | 54 - .../tests/mfcembed/components/Makefile.in | 91 -- .../components/PrintProgressDialog.cpp | 275 ---- .../mfcembed/components/PrintProgressDialog.h | 74 - .../components/PrintingPromptService.cpp | 365 ----- .../components/PrintingPromptService.h | 53 - .../mfcembed/components/PromptService.cpp | 468 ------ .../tests/mfcembed/components/PromptService.h | 53 - .../mfcembed/components/nsPrintDialogUtil.cpp | 1412 ----------------- .../mfcembed/components/nsPrintDialogUtil.h | 37 - .../components/nsPrintProgressParams.cpp | 75 - .../components/nsPrintProgressParams.h | 52 - .../tests/mfcembed/components/resource.h | 51 - .../tests/mfcembed/components/stdafx.h | 70 - mozilla/embedding/tests/mfcembed/mfcembed.dsp | 389 ----- mozilla/embedding/tests/mfcembed/mfcembed.dsw | 29 - mozilla/embedding/tests/mfcembed/mfcembed.htm | 58 - mozilla/embedding/tests/mfcembed/mfcembed.pkg | 4 - .../embedding/tests/mfcembed/res/Toolbar.bmp | Bin 1198 -> 0 bytes .../embedding/tests/mfcembed/res/broken.ico | Bin 2126 -> 0 bytes .../embedding/tests/mfcembed/res/mainfram.bmp | Bin 2854 -> 0 bytes .../embedding/tests/mfcembed/res/mfcembed.ico | Bin 1078 -> 0 bytes .../embedding/tests/mfcembed/res/mfcembed.rc2 | 13 - .../embedding/tests/mfcembed/res/sinsecur.ico | Bin 2126 -> 0 bytes .../embedding/tests/mfcembed/res/ssecur.ico | Bin 1366 -> 0 bytes mozilla/embedding/tests/mfcembed/resource.h | 153 -- .../mfcembed/winEmbedFileLocProvider.cpp | 288 ---- .../tests/mfcembed/winEmbedFileLocProvider.h | 63 - 74 files changed, 15265 deletions(-) delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserFrm.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserFrm.h delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserImpl.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserImpl.h delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserImplWebPrgrsLstnr.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserToolTip.h delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserView.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/BrowserView.h delete mode 100644 mozilla/embedding/tests/mfcembed/CCustomPromptDialog.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/CCustomPromptDialog.h delete mode 100644 mozilla/embedding/tests/mfcembed/CFormatOptionTab.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/CFormatOptionTab.h delete mode 100644 mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.h delete mode 100644 mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.h delete mode 100644 mozilla/embedding/tests/mfcembed/Dialogs.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/Dialogs.h delete mode 100644 mozilla/embedding/tests/mfcembed/EditorFrm.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/EditorFrm.h delete mode 100644 mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h delete mode 100644 mozilla/embedding/tests/mfcembed/Makefile.in delete mode 100644 mozilla/embedding/tests/mfcembed/MfcEmbed.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/MfcEmbed.h delete mode 100644 mozilla/embedding/tests/mfcembed/MfcEmbed.rc delete mode 100644 mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/MostRecentUrls.h delete mode 100644 mozilla/embedding/tests/mfcembed/Preferences.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/Preferences.h delete mode 100644 mozilla/embedding/tests/mfcembed/ProfileMgr.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/ProfileMgr.h delete mode 100644 mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/ProfilesDlg.h delete mode 100644 mozilla/embedding/tests/mfcembed/README.TXT delete mode 100644 mozilla/embedding/tests/mfcembed/StdAfx.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/StdAfx.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/Dialogs.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/Dialogs.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/Dialogs.rc delete mode 100644 mozilla/embedding/tests/mfcembed/components/HelperAppDlg.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/HelperAppDlg.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/HelperAppService.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/Makefile.in delete mode 100644 mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/PrintingPromptService.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/PromptService.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/PromptService.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/resource.h delete mode 100644 mozilla/embedding/tests/mfcembed/components/stdafx.h delete mode 100644 mozilla/embedding/tests/mfcembed/mfcembed.dsp delete mode 100644 mozilla/embedding/tests/mfcembed/mfcembed.dsw delete mode 100644 mozilla/embedding/tests/mfcembed/mfcembed.htm delete mode 100644 mozilla/embedding/tests/mfcembed/mfcembed.pkg delete mode 100644 mozilla/embedding/tests/mfcembed/res/Toolbar.bmp delete mode 100644 mozilla/embedding/tests/mfcembed/res/broken.ico delete mode 100644 mozilla/embedding/tests/mfcembed/res/mainfram.bmp delete mode 100644 mozilla/embedding/tests/mfcembed/res/mfcembed.ico delete mode 100644 mozilla/embedding/tests/mfcembed/res/mfcembed.rc2 delete mode 100644 mozilla/embedding/tests/mfcembed/res/sinsecur.ico delete mode 100644 mozilla/embedding/tests/mfcembed/res/ssecur.ico delete mode 100644 mozilla/embedding/tests/mfcembed/resource.h delete mode 100644 mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.cpp delete mode 100644 mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h diff --git a/mozilla/embedding/tests/Makefile.in b/mozilla/embedding/tests/Makefile.in index ef298d8ed65..55db97b048f 100644 --- a/mozilla/embedding/tests/Makefile.in +++ b/mozilla/embedding/tests/Makefile.in @@ -47,17 +47,6 @@ DIRS = winEmbed endif endif -# disable mfcembed in static builds -ifndef BUILD_STATIC_LIBS -ifndef GNU_CC -ifndef NO_MFC -ifndef MOZ_NO_XPCOM_OBSOLETE -DIRS += mfcembed/components mfcembed -endif -endif -endif -endif - endif include $(topsrcdir)/config/rules.mk diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp deleted file mode 100644 index 11620b7738e..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// File Overview.... -// -// This file has the IBrowserFrameGlueObj implementation -// This frame glue object is nested inside of the BrowserFrame -// object(See BrowserFrm.h for more info) -// -// This is the place where all the platform specific interaction -// with the browser frame window takes place in response to -// callbacks from Gecko interface methods -// -// The main purpose of this interface is to separate the cross -// platform code in BrowserImpl*.cpp from the platform specific -// code(which is in this file) -// -// You'll also notice the use of a macro named "METHOD_PROLOGUE" -// through out this file. This macro essentially makes the pointer -// to a "containing" class available inside of the class which is -// being contained via a var named "pThis". In our case, the -// BrowserFrameGlue object is contained inside of the BrowserFrame -// object so "pThis" will be a pointer to a BrowserFrame object -// Refer to MFC docs for more info on METHOD_PROLOGUE macro - - -#include "stdafx.h" -#include "MfcEmbed.h" -#include "BrowserFrm.h" -#include "Dialogs.h" - -///////////////////////////////////////////////////////////////////////////// -// IBrowserFrameGlue implementation - -void CBrowserFrame::BrowserFrameGlueObj::UpdateStatusBarText(const PRUnichar *aMessage) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - USES_CONVERSION; - pThis->m_wndStatusBar.SetPaneText(0, aMessage ? W2CT(aMessage) : _T("")); -} - -void CBrowserFrame::BrowserFrameGlueObj::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->m_wndProgressBar.SetRange32(0, aMax); - pThis->m_wndProgressBar.SetPos(aCurrent); -} - -void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - // Just notify the view of the busy state - // There's code in there which will take care of - // updating the STOP toolbar btn. etc - - pThis->m_wndBrowserView.UpdateBusyState(aBusy); -} - -// Called from the OnLocationChange() method in the nsIWebProgressListener -// interface implementation in CBrowserImpl to update the current URI -// Will get called after a URI is successfully loaded in the browser -// We use this info to update the URL bar's edit box -// -void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - if(aLocation) - { - USES_CONVERSION; - nsEmbedCString uriString; - aLocation->GetSpec(uriString); - pThis->m_wndUrlBar.SetCurrentURL(A2CT(uriString.get())); - } -} - -void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - CString title; - pThis->GetWindowText(title); - - if(!title.IsEmpty()) - { - USES_CONVERSION; - nsEmbedString nsTitle; - nsTitle.Assign(T2CW(title.GetBuffer(0))); - *aTitle = NS_StringCloneData(nsTitle); - } -} - -void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameTitle(const PRUnichar *aTitle) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - CString title; - if (aTitle) - { - USES_CONVERSION; - title = W2CT(aTitle); - } - else - { - // Use the AppName i.e. mfcembed as the title if we - // do not get one from GetBrowserWindowTitle() - // - title.LoadString(AFX_IDS_APP_TITLE); - } - pThis->SetWindowText(title); -} - -void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->SetWindowPos(NULL, 0, 0, aCX, aCY, - SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER - ); -} - -void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - RECT wndRect; - pThis->GetWindowRect(&wndRect); - - if (aCX) - *aCX = wndRect.right - wndRect.left; - - if (aCY) - *aCY = wndRect.bottom - wndRect.top; -} - -void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePosition(PRInt32 aX, PRInt32 aY) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->SetWindowPos(NULL, aX, aY, 0, 0, - SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - RECT wndRect; - pThis->GetWindowRect(&wndRect); - - if (aX) - *aX = wndRect.left; - - if (aY) - *aY = wndRect.top; -} - -void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - RECT wndRect; - pThis->GetWindowRect(&wndRect); - - if (aX) - *aX = wndRect.left; - - if (aY) - *aY = wndRect.top; - - if (aCX) - *aCX = wndRect.right - wndRect.left; - - if (aCY) - *aCY = wndRect.bottom - wndRect.top; -} - -void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->SetWindowPos(NULL, aX, aY, aCX, aCY, - SWP_NOACTIVATE | SWP_NOZORDER); -} - -void CBrowserFrame::BrowserFrameGlueObj::SetFocus() -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->SetFocus(); -} - -void CBrowserFrame::BrowserFrameGlueObj::FocusAvailable(PRBool *aFocusAvail) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - HWND focusWnd = GetFocus()->m_hWnd; - - if ((focusWnd == pThis->m_hWnd) || ::IsChild(pThis->m_hWnd, focusWnd)) - *aFocusAvail = PR_TRUE; - else - *aFocusAvail = PR_FALSE; -} - -void CBrowserFrame::BrowserFrameGlueObj::ShowBrowserFrame(PRBool aShow) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - if(aShow) - { - pThis->ShowWindow(SW_SHOW); - pThis->SetActiveWindow(); - pThis->UpdateWindow(); - } - else - { - pThis->ShowWindow(SW_HIDE); - } -} - -void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameVisibility(PRBool *aVisible) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - // Is the current BrowserFrame the active one? - if (GetActiveWindow()->m_hWnd != pThis->m_hWnd) - { - *aVisible = PR_FALSE; - return; - } - - // We're the active one - //Return FALSE if we're minimized - WINDOWPLACEMENT wpl; - pThis->GetWindowPlacement(&wpl); - - if ((wpl.showCmd == SW_RESTORE) || (wpl.showCmd == SW_MAXIMIZE)) - *aVisible = PR_TRUE; - else - *aVisible = PR_FALSE; -} - -PRBool CBrowserFrame::BrowserFrameGlueObj::CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - nsIWebBrowser** aWebBrowser) -{ - NS_ENSURE_ARG_POINTER(aWebBrowser); - - *aWebBrowser = nsnull; - - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - if(!pApp) - return PR_FALSE; - - // Note that we're calling with the last param set to "false" i.e. - // this instructs not to show the frame window - // This is mainly needed when the window size is specified in the window.open() - // JS call. In those cases Gecko calls us to create the browser with a default - // size (all are -1) and then it calls the SizeBrowserTo() method to set - // the proper window size. If this window were to be visible then you'll see - // the window size changes on the screen causing an unappealing flicker - // - - CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_FALSE); - if(!pFrm) - return PR_FALSE; - - // At this stage we have a new CBrowserFrame and a new CBrowserView - // objects. The CBrowserView also would have an embedded browser - // object created. Get the mWebBrowser member from the CBrowserView - // and return it. (See CBrowserView's CreateBrowser() on how the - // embedded browser gets created and how it's mWebBrowser member - // gets initialized) - - NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser); - - return PR_TRUE; -} - -void CBrowserFrame::BrowserFrameGlueObj::DestroyBrowserFrame() -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->PostMessage(WM_CLOSE); -} - -#define GOTO_BUILD_CTX_MENU { bContentHasFrames = FALSE; goto BUILD_CTX_MENU; } - -void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - BOOL bContentHasFrames = FALSE; - UINT nIDResource = IDR_CTXMENU_DOCUMENT; - - // Reset the values from the last invocation - // Clear image src & link url - nsEmbedString empty; - pThis->m_wndBrowserView.SetCtxMenuImageSrc(empty); - pThis->m_wndBrowserView.SetCtxMenuLinkUrl(empty); - pThis->m_wndBrowserView.SetCurrentFrameURL(empty); - - // Display the Editor context menu if the we're inside - // an EditorFrm which is hosting an editing session - // - if(pThis->GetEditable()) - { - nIDResource = IDR_CTXMENU_EDITOR; - - GOTO_BUILD_CTX_MENU; - } - - if(aContextFlags & nsIContextMenuListener2::CONTEXT_DOCUMENT) - { - nIDResource = IDR_CTXMENU_DOCUMENT; - - // Background image? - if (aContextFlags & nsIContextMenuListener2::CONTEXT_BACKGROUND_IMAGE) - { - // Get the IMG SRC - nsCOMPtr imgURI; - aInfo->GetBackgroundImageSrc(getter_AddRefs(imgURI)); - if (!imgURI) - return; - nsEmbedCString uri; - imgURI->GetSpec(uri); - - nsEmbedString uri2; - NS_CStringToUTF16(uri, NS_CSTRING_ENCODING_UTF8, uri2); - - pThis->m_wndBrowserView.SetCtxMenuImageSrc(uri2); // Set the new Img Src - } - } - else if(aContextFlags & nsIContextMenuListener2::CONTEXT_TEXT) - nIDResource = IDR_CTXMENU_TEXT; - else if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK) - { - nIDResource = IDR_CTXMENU_LINK; - - // Since we handle all the browser menu/toolbar commands - // in the View, we basically setup the Link's URL in the - // BrowserView object. When a menu selection in the context - // menu is made, the appropriate command handler in the - // BrowserView will be invoked and the value of the URL - // will be accesible in the view - - nsEmbedString strUrlUcs2; - nsresult rv = aInfo->GetAssociatedLink(strUrlUcs2); - if(NS_FAILED(rv)) - return; - - // Update the view with the new LinkUrl - // Note that this string is in UCS2 format - pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2); - - // Test if there is an image URL as well - nsCOMPtr imgURI; - aInfo->GetImageSrc(getter_AddRefs(imgURI)); - if(imgURI) - { - nsEmbedCString strImgSrcUtf8; - imgURI->GetSpec(strImgSrcUtf8); - if(strImgSrcUtf8.Length() != 0) - { - // Set the new Img Src - nsEmbedString strImgSrc; - NS_CStringToUTF16(strImgSrcUtf8, NS_CSTRING_ENCODING_UTF8, strImgSrc); - pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrc); - } - } - } - else if(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE) - { - nIDResource = IDR_CTXMENU_IMAGE; - - // Get the IMG SRC - nsCOMPtr imgURI; - aInfo->GetImageSrc(getter_AddRefs(imgURI)); - if(!imgURI) - return; - nsEmbedCString strImgSrcUtf8; - imgURI->GetSpec(strImgSrcUtf8); - if(strImgSrcUtf8.Length() == 0) - return; - - // Set the new Img Src - nsEmbedString strImgSrc; - NS_CStringToUTF16(strImgSrcUtf8, NS_CSTRING_ENCODING_UTF8, strImgSrc); - pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrc); - } - - // Determine if we need to add the Frame related context menu items - // such as "View Frame Source" etc. - // - if(pThis->m_wndBrowserView.ViewContentContainsFrames()) - { - bContentHasFrames = TRUE; - - //Determine the current Frame URL - // - nsresult rv = NS_OK; - nsCOMPtr node; - aInfo->GetTargetNode(getter_AddRefs(node)); - if(!node) - GOTO_BUILD_CTX_MENU; - - nsCOMPtr domDoc; - rv = node->GetOwnerDocument(getter_AddRefs(domDoc)); - if(NS_FAILED(rv)) - GOTO_BUILD_CTX_MENU; - - nsCOMPtr htmlDoc(do_QueryInterface(domDoc, &rv)); - if(NS_FAILED(rv)) - GOTO_BUILD_CTX_MENU; - - nsEmbedString strFrameURL; - rv = htmlDoc->GetURL(strFrameURL); - if(NS_FAILED(rv)) - GOTO_BUILD_CTX_MENU; - - pThis->m_wndBrowserView.SetCurrentFrameURL(strFrameURL); //Set it to the new URL - } - -BUILD_CTX_MENU: - - CMenu ctxMenu; - if(ctxMenu.LoadMenu(nIDResource)) - { - //Append the Frame related menu items if content has frames - if(bContentHasFrames) - { - CMenu* pCtxMenu = ctxMenu.GetSubMenu(0); - if(pCtxMenu) - { - pCtxMenu->AppendMenu(MF_SEPARATOR); - - CString strMenuItem; - strMenuItem.LoadString(IDS_VIEW_FRAME_SOURCE); - pCtxMenu->AppendMenu(MF_STRING, ID_VIEW_FRAME_SOURCE, strMenuItem); - - strMenuItem.LoadString(IDS_OPEN_FRAME_IN_NEW_WINDOW); - pCtxMenu->AppendMenu(MF_STRING, ID_OPEN_FRAME_IN_NEW_WINDOW, strMenuItem); - } - } - - POINT cursorPos; - GetCursorPos(&cursorPos); - - (ctxMenu.GetSubMenu(0))->TrackPopupMenu(TPM_LEFTALIGN, cursorPos.x, cursorPos.y, pThis); - } -} - -HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd() -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - return pThis->m_hWnd; -} - -void CBrowserFrame::BrowserFrameGlueObj::UpdateSecurityStatus(PRInt32 aState) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - - pThis->UpdateSecurityStatus(aState); -} - -void CBrowserFrame::BrowserFrameGlueObj::ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - pThis->m_wndTooltip.SetTipText(CString(aTipText)); - pThis->m_wndTooltip.Show(&pThis->m_wndBrowserView, aXCoords, aYCoords); -} - -void CBrowserFrame::BrowserFrameGlueObj::HideTooltip() -{ - METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj) - pThis->m_wndTooltip.Hide(); -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp deleted file mode 100644 index d19bd04b591..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserFrm.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// File Overview.... -// -// The typical MFC View, toolbar, statusbar creation done -// in CBrowserFrame::OnCreate() -// -// Code to update the Status/Tool bars in response to the -// Web page loading progress(called from methods in CBrowserImpl) -// -// SetupFrameChrome() determines what, if any, UI elements this Frame -// will sport based on the current "chromeMask" -// -// Also take a look at OnClose() which gets used when you close a browser -// window. This needs to be overrided mainly to handle supporting multiple -// browser frame windows via the "New Browser Window" menu item -// Without this being overridden the MFC framework handles the OnClose and -// shutsdown the complete application when a frame window is closed. -// In our case, we want the app to shutdown when the File/Exit menu is chosen -// -// Another key functionality this object implements is the IBrowserFrameGlue -// interface - that's the interface the Gecko embedding interfaces call -// upong to update the status bar etc. -// (Take a look at IBrowserFrameGlue.h for the interface definition and -// the BrowserFrm.h to see how we implement this interface - as a nested -// class) -// We pass this Glue object pointer to the CBrowserView object via the -// SetBrowserFrameGlue() method. The CBrowserView passes this on to the -// embedding interface implementaion -// -// Please note the use of the macro METHOD_PROLOGUE in the implementation -// of the nested BrowserFrameGlue object. Essentially what this macro does -// is to get you access to the outer (or the object which is containing the -// nested object) object via the pThis pointer. -// Refer to the AFXDISP.H file in VC++ include dirs -// -// Next suggested file to look at : BrowserView.cpp - -#include "stdafx.h" -#include "MfcEmbed.h" -#include "BrowserFrm.h" -#include "EditorFrm.h" -#include "BrowserImpl.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CBrowserFrame - -IMPLEMENT_DYNAMIC(CBrowserFrame, CFrameWnd) - -BEGIN_MESSAGE_MAP(CBrowserFrame, CFrameWnd) - //{{AFX_MSG_MAP(CBrowserFrame) - ON_WM_CREATE() - ON_WM_SETFOCUS() - ON_WM_SIZE() - ON_WM_CLOSE() - ON_WM_ACTIVATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // For the Status line - ID_SEPARATOR, // For the Progress Bar - ID_SEPARATOR, // For the padlock image -}; - -///////////////////////////////////////////////////////////////////////////// -// CBrowserFrame construction/destruction - -CBrowserFrame::CBrowserFrame() -{ - mIsEditor = FALSE; -} - -CBrowserFrame::CBrowserFrame(PRUint32 chromeMask) -{ - // Save the chromeMask off. It'll be used - // later to determine whether this browser frame - // will have menubar, toolbar, statusbar etc. - - m_chromeMask = chromeMask; - mIsEditor = FALSE; -} - -CBrowserFrame::~CBrowserFrame() -{ -} - -void CBrowserFrame::OnClose() -{ - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - pApp->RemoveFrameFromList(this); - - DestroyWindow(); -} - -// This is where the UrlBar, ToolBar, StatusBar, ProgressBar -// get created -// -int CBrowserFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // Pass "this" to the View for later callbacks - // and/or access to any public data members, if needed - // - m_wndBrowserView.SetBrowserFrame(this); - - // Pass on the BrowserFrameGlue also to the View which - // it will use during the Init() process after creation - // of the BrowserImpl obj. Essentially, the View object - // hooks up the Embedded browser's callbacks to the BrowserFrame - // via this BrowserFrameGlue object - m_wndBrowserView.SetBrowserFrameGlue((PBROWSERFRAMEGLUE)&m_xBrowserFrameGlueObj); - - // create a view to occupy the client area of the frame - // This will be the view in which the embedded browser will - // be displayed in - // - if (!m_wndBrowserView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, - CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) - { - TRACE0("Failed to create view window\n"); - return -1; - } - - // create the URL bar (essentially a ComboBoxEx object) - if (!m_wndUrlBar.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 150), this, ID_URL_BAR)) - { - TRACE0("Failed to create URL Bar\n"); - return -1; // fail to create - } - - // Load the Most Recently Used(MRU) Urls into the UrlBar - m_wndUrlBar.LoadMRUList(); - - UINT resID = mIsEditor ? IDR_EDITOR : IDR_MAINFRAME; - - // Create the toolbar with Back, Fwd, Stop, etc. buttons.. - // or - // Create a toolbar with the Editor toolbar buttons - Bold, Italic etc. - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || - !m_wndToolBar.LoadToolBar(resID)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - // Create a ReBar window to which the toolbar and UrlBar - // will be added - if (!m_wndReBar.Create(this)) - { - TRACE0("Failed to create ReBar\n"); - return -1; // fail to create - } - - //Add the ToolBar and UrlBar windows to the rebar - m_wndReBar.AddBar(&m_wndToolBar); - - if (!mIsEditor) - m_wndReBar.AddBar(&m_wndUrlBar, _T("Enter URL:")); - - // Create the status bar with two panes - one pane for actual status - // text msgs. and the other for the progress control - if (!m_wndStatusBar.CreateEx(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // Create the progress bar as a child of the status bar. - // Note that the ItemRect which we'll get at this stage - // is bogus since the status bar panes are not fully - // positioned yet i.e. we'll be passing in an invalid rect - // to the Create function below - // The actual positioning of the progress bar will be done - // in response to OnSize() - RECT rc; - m_wndStatusBar.GetItemRect (1, &rc); - if (!m_wndProgressBar.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, rc, &m_wndStatusBar, ID_PROG_BAR)) - { - TRACE0("Failed to create progress bar\n"); - return -1; // fail to create - } - - // The third pane(i.e. at index 2) of the status bar will have - // the security lock icon displayed in it. Set up it's size(16) - // and style(no border)so that the padlock icons can be properly drawn - m_wndStatusBar.SetPaneInfo(2, -1, SBPS_NORMAL|SBPS_NOBORDERS, 16); - - // Create a tooltip window. (the MFC tooltip is not really suitable) - m_wndTooltip.Create(CWnd::GetDesktopWindow()); - - // Also, set the padlock icon to be the insecure icon to begin with - UpdateSecurityStatus(nsIWebProgressListener::STATE_IS_INSECURE); - - // Based on the "chromeMask" we were supplied during construction - // hide any requested UI elements - statusbar, menubar etc... - // Note that the window styles (WM_RESIZE etc) are set inside - // of PreCreateWindow() - - SetupFrameChrome(); - - return 0; -} - -void CBrowserFrame::SetupFrameChrome() -{ - if(m_chromeMask == nsIWebBrowserChrome::CHROME_ALL) - return; - - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_MENUBAR) ) - SetMenu(NULL); // Hide the MenuBar - - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR) ) - m_wndReBar.ShowWindow(SW_HIDE); // Hide the ToolBar - - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) ) - m_wndStatusBar.ShowWindow(SW_HIDE); // Hide the StatusBar -} - -BOOL CBrowserFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - - cs.dwExStyle &= ~WS_EX_CLIENTEDGE; - - // Change window style based on the chromeMask - - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR) ) - cs.style &= ~WS_CAPTION; // No caption - - if(! (m_chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) ) - { - // Can't resize this window - cs.style &= ~WS_SIZEBOX; - cs.style &= ~WS_THICKFRAME; - cs.style &= ~WS_MINIMIZEBOX; - cs.style &= ~WS_MAXIMIZEBOX; - } - - cs.lpszClass = AfxRegisterWndClass(0); - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CBrowserFrame message handlers -void CBrowserFrame::OnSetFocus(CWnd* pOldWnd) -{ - // forward focus to the view window - m_wndBrowserView.SetFocus(); -} - -BOOL CBrowserFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) -{ - // let the view have first crack at the command - if (m_wndBrowserView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) - return TRUE; - - // otherwise, do default handling - return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); -} - -// Needed to properly position/resize the progress bar -// -void CBrowserFrame::OnSize(UINT nType, int cx, int cy) -{ - CFrameWnd::OnSize(nType, cx, cy); - - // Get the ItemRect of the status bar's Pane 1 - // That's where the progress bar will be located - RECT rc; - m_wndStatusBar.GetItemRect(1, &rc); - - // Move the progress bar into it's correct location - // - m_wndProgressBar.MoveWindow(&rc); -} - -#ifdef _DEBUG -void CBrowserFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CBrowserFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //_DEBUG - - -void CBrowserFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - CFrameWnd::OnActivate(nState, pWndOther, bMinimized); - - m_wndBrowserView.Activate(nState, pWndOther, bMinimized); -} - -#define IS_SECURE(state) ((state & 0xFFFF) == nsIWebProgressListener::STATE_IS_SECURE) -void CBrowserFrame::UpdateSecurityStatus(PRInt32 aState) -{ - int iResID = nsIWebProgressListener::STATE_IS_INSECURE; - - if(IS_SECURE(aState)){ - iResID = IDR_SECURITY_LOCK; - m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_SECURE; - } - else if(aState == nsIWebProgressListener::STATE_IS_INSECURE) { - iResID = IDR_SECURITY_UNLOCK; - m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_INSECURE; - } - else if(aState == nsIWebProgressListener::STATE_IS_BROKEN) { - iResID = IDR_SECURITY_BROKEN; - m_wndBrowserView.m_SecurityState = CBrowserView::SECURITY_STATE_BROKEN; - } - - CStatusBarCtrl& sb = m_wndStatusBar.GetStatusBarCtrl(); - sb.SetIcon(2, //2 is the pane index of the status bar where the lock icon will be shown - (HICON)::LoadImage(AfxGetResourceHandle(), - MAKEINTRESOURCE(iResID), IMAGE_ICON, 16,16,0)); -} - -void CBrowserFrame::ShowSecurityInfo() -{ - m_wndBrowserView.ShowSecurityInfo(); -} - -// CMyStatusBar Class -CMyStatusBar::CMyStatusBar() -{ -} - -CMyStatusBar::~CMyStatusBar() -{ -} - -BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar) - //{{AFX_MSG_MAP(CMyStatusBar) - ON_WM_LBUTTONDOWN() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void CMyStatusBar::OnLButtonDown(UINT nFlags, CPoint point) -{ - // Check to see if the mouse click was within the - // padlock icon pane(at pane index 2) of the status bar... - - RECT rc; - GetItemRect(2, &rc ); - - if(PtInRect(&rc, point)) - { - CBrowserFrame *pFrame = (CBrowserFrame *)GetParent(); - if(pFrame != NULL) - pFrame->ShowSecurityInfo(); - } - - CStatusBar::OnLButtonDown(nFlags, point); -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrm.h b/mozilla/embedding/tests/mfcembed/BrowserFrm.h deleted file mode 100644 index 5f2c993f530..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserFrm.h +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// BrowserFrm.h : interface of the CBrowserFrame class -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef _IBROWSERFRM_H -#define _IBROWSERFRM_H - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "BrowserView.h" -#include "BrowserToolTip.h" -#include "IBrowserFrameGlue.h" -#include "MostRecentUrls.h" - -// A simple UrlBar class... -class CUrlBar : public CComboBoxEx -{ -public: - inline void GetEnteredURL(CString& url) { - GetEditCtrl()->GetWindowText(url); - } - inline void GetSelectedURL(CString& url) { - GetLBText(GetCurSel(), url); - } - inline void SetCurrentURL(LPCTSTR pUrl) { - SetWindowText(pUrl); - } - inline void AddURLToList(CString& url, bool bAddToMRUList = true) { - USES_CONVERSION; - COMBOBOXEXITEM ci; - ci.mask = CBEIF_TEXT; ci.iItem = -1; - ci.pszText = const_cast((LPCTSTR)url); - InsertItem(&ci); - - if(bAddToMRUList) - m_MRUList.AddURL(T2CA(url)); - } - inline void LoadMRUList() { - for (int i=0;im_hWnd == CWnd::GetFocus()->m_hWnd); - } - inline BOOL EditCtrlHasSelection() { - int nStartChar = 0, nEndChar = 0; - if(EditCtrlHasFocus()) - GetEditCtrl()->GetSel(nStartChar, nEndChar); - return (nEndChar > nStartChar) ? TRUE : FALSE; - } - inline BOOL CanCutToClipboard() { - return EditCtrlHasSelection(); - } - inline void CutToClipboard() { - GetEditCtrl()->Cut(); - } - inline BOOL CanCopyToClipboard() { - return EditCtrlHasSelection(); - } - inline void CopyToClipboard() { - GetEditCtrl()->Copy(); - } - inline BOOL CanPasteFromClipboard() { - return EditCtrlHasFocus(); - } - inline void PasteFromClipboard() { - GetEditCtrl()->Paste(); - } - inline BOOL CanUndoEditOp() { - return EditCtrlHasFocus() ? GetEditCtrl()->CanUndo() : FALSE; - } - inline void UndoEditOp() { - if(EditCtrlHasFocus()) - GetEditCtrl()->Undo(); - } - -protected: - CMostRecentUrls m_MRUList; -}; - -// CMyStatusBar class -class CMyStatusBar : public CStatusBar -{ -public: - CMyStatusBar(); - virtual ~CMyStatusBar(); - -protected: - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - - DECLARE_MESSAGE_MAP() -}; - -class CBrowserFrame : public CFrameWnd -{ -public: - CBrowserFrame(); - CBrowserFrame(PRUint32 chromeMask); - -protected: - DECLARE_DYNAMIC(CBrowserFrame) - -public: - inline CBrowserImpl *GetBrowserImpl() { return m_wndBrowserView.mpBrowserImpl; } - - CToolBar m_wndToolBar; - CMyStatusBar m_wndStatusBar; - CProgressCtrl m_wndProgressBar; - CUrlBar m_wndUrlBar; - CReBar m_wndReBar; - CBrowserToolTip m_wndTooltip; - - // The view inside which the embedded browser will - // be displayed in - CBrowserView m_wndBrowserView; - - void UpdateSecurityStatus(PRInt32 aState); - void ShowSecurityInfo(); - - // Wrapper functions for UrlBar clipboard operations - inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); } - inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); } - inline BOOL CanCopyUrlBarSelection() { return m_wndUrlBar.CanCopyToClipboard(); } - inline void CopyUrlBarSelToClipboard() { m_wndUrlBar.CopyToClipboard(); } - inline BOOL CanPasteToUrlBar() { return m_wndUrlBar.CanPasteFromClipboard(); } - inline void PasteFromClipboardToUrlBar() { m_wndUrlBar.PasteFromClipboard(); } - inline BOOL CanUndoUrlBarEditOp() { return m_wndUrlBar.CanUndoEditOp(); } - inline void UndoUrlBarEditOp() { m_wndUrlBar.UndoEditOp(); } - - // This specifies what UI elements this frame will sport - // w.r.t. toolbar, statusbar, urlbar etc. - PRUint32 m_chromeMask; - -protected: - // - // This nested class implements the IBrowserFramGlue interface - // The Gecko embedding interfaces call on this interface - // to update the status bars etc. - // - class BrowserFrameGlueObj : public IBrowserFrameGlue - { - // - // NS_DECL_BROWSERFRAMEGLUE below is a macro which expands - // to the function prototypes of methods in IBrowserFrameGlue - // Take a look at IBrowserFrameGlue.h for this macro define - // - - NS_DECL_BROWSERFRAMEGLUE - - } m_xBrowserFrameGlueObj; - friend class BrowserFrameGlueObj; - -public: - void SetupFrameChrome(); - void SetEditable(BOOL isEditor) { mIsEditor = isEditor; } - BOOL GetEditable() { return mIsEditor; } - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBrowserFrame) - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CBrowserFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -// Generated message map functions -protected: - //{{AFX_MSG(CBrowserFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSetFocus(CWnd *pOldWnd); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnClose(); - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - BOOL mIsEditor; -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif //_IBROWSERFRM_H diff --git a/mozilla/embedding/tests/mfcembed/BrowserImpl.cpp b/mozilla/embedding/tests/mfcembed/BrowserImpl.cpp deleted file mode 100644 index e1edbf84afb..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserImpl.cpp +++ /dev/null @@ -1,411 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// File Overview.... -// This is the class which implements all the interfaces -// required(and optional) by the mozilla embeddable browser engine -// -// Note that this obj gets passed in the IBrowserFrameGlue* using the -// Init() method. Many of the interface implementations use this -// to get the actual task done. Ex: to update the status bar -// -// Look at the INTERFACE_MAP_ENTRY's below for the list of -// the currently implemented interfaces -// -// This file currently has the implementation for all the interfaces -// which are required of an app embedding Gecko -// Implementation of other optional interfaces are in separate files -// to avoid cluttering this one and to demonstrate other embedding -// principles. For example, nsIPrompt is implemented in a separate DLL. -// -// nsIWebBrowserChrome - This is a required interface to be implemented -// by embeddors -// -// nsIEmbeddingSiteWindow - This is a required interface to be implemented -// by embedders -// - SetTitle() gets called after a document -// load giving us the chance to update our -// titlebar -// -// Some points to note... -// -// nsIWebBrowserChrome interface's SetStatus() gets called when a user -// mouses over the links on a page -// -// nsIWebProgressListener interface's OnStatusChange() gets called -// to indicate progress when a page is being loaded -// -// Next suggested file(s) to look at : -// Any of the BrowserImpl*.cpp files for other interface -// implementation details -// - -#ifdef _WINDOWS - #include "stdafx.h" -#endif - -#include "nsIDOMWindow.h" -#include "BrowserImpl.h" - -CBrowserImpl::CBrowserImpl() -{ - m_pBrowserFrameGlue = NULL; - mWebBrowser = nsnull; -} - - -CBrowserImpl::~CBrowserImpl() -{ -} - -// It's very important that the creator of this CBrowserImpl object -// Call on this Init() method with proper values after creation -// -NS_METHOD CBrowserImpl::Init(PBROWSERFRAMEGLUE pBrowserFrameGlue, - nsIWebBrowser* aWebBrowser) -{ - m_pBrowserFrameGlue = pBrowserFrameGlue; - - SetWebBrowser(aWebBrowser); - - return NS_OK; -} - -//***************************************************************************** -// CBrowserImpl::nsISupports -//***************************************************************************** - -NS_IMPL_ADDREF(CBrowserImpl) -NS_IMPL_RELEASE(CBrowserImpl) - -NS_INTERFACE_MAP_BEGIN(CBrowserImpl) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome) - NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) - NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) - NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus) - NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow) - NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow2) - NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) - NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener2) - NS_INTERFACE_MAP_ENTRY(nsITooltipListener) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) -NS_INTERFACE_MAP_END - -//***************************************************************************** -// CBrowserImpl::nsIInterfaceRequestor -//***************************************************************************** - -NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr) -{ - if(aIID.Equals(NS_GET_IID(nsIDOMWindow))) - { - if (mWebBrowser) - return mWebBrowser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr); - return NS_ERROR_NOT_INITIALIZED; - } - - return QueryInterface(aIID, aInstancePtr); -} - -//***************************************************************************** -// CBrowserImpl::nsIWebBrowserChrome -//***************************************************************************** - -//Gets called when you mouseover links etc. in a web page -// -NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->UpdateStatusBarText(aStatus); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser) -{ - NS_ENSURE_ARG_POINTER(aWebBrowser); - - *aWebBrowser = mWebBrowser; - - NS_IF_ADDREF(*aWebBrowser); - - return NS_OK; -} - -// Currently called from Init(). I'm not sure who else -// calls this -// -NS_IMETHODIMP CBrowserImpl::SetWebBrowser(nsIWebBrowser* aWebBrowser) -{ - NS_ENSURE_ARG_POINTER(aWebBrowser); - - mWebBrowser = aWebBrowser; - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -// Will get called in response to JavaScript window.close() -// -NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow() -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->DestroyBrowserFrame(); - - return NS_OK; -} - -// Gets called in response to set the size of a window -// Ex: In response to a JavaScript Window.Open() call of -// the form -// -// window.open("http://www.mozilla.org", "theWin", "width=200, height=400"); -// -// First the CreateBrowserWindow() call will be made followed by a -// call to this method to resize the window -// -NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd(); - - CRect rcNewFrame(CPoint(0, 0), CSize(aCX, aCY)); - CRect rcFrame; - CRect rcClient; - - // Adjust for 3D edge on client area - AdjustWindowRectEx(&rcNewFrame, WS_VISIBLE, FALSE, WS_EX_CLIENTEDGE); - - GetClientRect(w, &rcClient); - GetWindowRect(w, &rcFrame); - - rcNewFrame.right += rcFrame.Width() - rcClient.Width(); - rcNewFrame.bottom += rcFrame.Height() - rcClient.Height(); - - m_pBrowserFrameGlue->SetBrowserFrameSize(rcNewFrame.Width(), rcNewFrame.Height()); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::ShowAsModal(void) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval) -{ - // We're not modal - *retval = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus) -{ - return NS_OK; -} - -//***************************************************************************** -// CBrowserImpl::nsIWebBrowserChromeFocus -//***************************************************************************** - -NS_IMETHODIMP CBrowserImpl::FocusNextElement() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CBrowserImpl::FocusPrevElement() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -//***************************************************************************** -// CBrowserImpl::nsIEmbeddingSiteWindow -//***************************************************************************** - -NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && - (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || - aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) - { - m_pBrowserFrameGlue->SetBrowserFramePositionAndSize(x, y, cx, cy, PR_TRUE); - } - else - { - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) - { - m_pBrowserFrameGlue->SetBrowserFramePosition(x, y); - } - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || - aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) - { - m_pBrowserFrameGlue->SetBrowserFrameSize(cx, cy); - } - } - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) - { - m_pBrowserFrameGlue->GetBrowserFramePosition(x, y); - } - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || - aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) - { - m_pBrowserFrameGlue->GetBrowserFrameSize(cx, cy); - } - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow) -{ - if (!aSiteWindow) - return NS_ERROR_NULL_POINTER; - - *aSiteWindow = 0; - if (m_pBrowserFrameGlue) { - HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd(); - *aSiteWindow = NS_REINTERPRET_CAST(void *, w); - } - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::SetFocus() -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->SetFocus(); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->GetBrowserFrameTitle(aTitle); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->SetBrowserFrameTitle(aTitle); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->GetBrowserFrameVisibility(aVisibility); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->ShowBrowserFrame(aVisibility); - - return NS_OK; -} - -//***************************************************************************** -// CBrowserImpl::nsIEmbeddingSiteWindow2 -//***************************************************************************** - -NS_IMETHODIMP CBrowserImpl::Blur() -{ - return NS_OK; -} - - -//***************************************************************************** -// CBrowserImpl::nsITooltipListener -//***************************************************************************** - -/* void onShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */ -NS_IMETHODIMP CBrowserImpl::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->ShowTooltip(aXCoords, aYCoords, aTipText); - - return NS_OK; -} - -/* void onHideTooltip (); */ -NS_IMETHODIMP CBrowserImpl::OnHideTooltip() -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->HideTooltip(); - - return NS_OK; -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserImpl.h b/mozilla/embedding/tests/mfcembed/BrowserImpl.h deleted file mode 100644 index ccf93b87f87..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserImpl.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _BROWSERIMPL_H -#define _BROWSERIMPL_H - -#include "IBrowserFrameGlue.h" -#include "nsIWebBrowserChromeFocus.h" -#include "nsICommandParams.h" - -class CBrowserImpl : public nsIInterfaceRequestor, - public nsIWebBrowserChrome, - public nsIWebBrowserChromeFocus, - public nsIEmbeddingSiteWindow2, - public nsIWebProgressListener, - public nsIContextMenuListener2, - public nsITooltipListener, - public nsSupportsWeakReference -{ -public: - CBrowserImpl(); - ~CBrowserImpl(); - NS_METHOD Init(PBROWSERFRAMEGLUE pBrowserFrameGlue, - nsIWebBrowser* aWebBrowser); - - NS_DECL_ISUPPORTS - NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSIWEBBROWSERCHROME - NS_DECL_NSIWEBBROWSERCHROMEFOCUS - NS_DECL_NSIEMBEDDINGSITEWINDOW - NS_DECL_NSIEMBEDDINGSITEWINDOW2 - NS_DECL_NSIWEBPROGRESSLISTENER - NS_DECL_NSICONTEXTMENULISTENER2 - NS_DECL_NSITOOLTIPLISTENER - -protected: - - PBROWSERFRAMEGLUE m_pBrowserFrameGlue; - - nsCOMPtr mWebBrowser; -}; - -#endif //_BROWSERIMPL_H diff --git a/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp b/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp deleted file mode 100644 index 5aa3b559c12..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserImplCtxMenuLstnr.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifdef _WINDOWS - #include "stdafx.h" -#endif -#include "BrowserImpl.h" -#include "IBrowserFrameGlue.h" - -//***************************************************************************** -// CBrowserImpl::nsIContextMenuListener2 -//***************************************************************************** - -NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) -{ - if(m_pBrowserFrameGlue) - m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aInfo); - - return NS_OK; -} \ No newline at end of file diff --git a/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp b/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp deleted file mode 100644 index 67f75aa4c7a..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserImplPrompt.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// File overview..... -// -// The nsIPrompt interface is mainly used to convey/get information -// from a user via Alerts, Prompts etc. -// - -#ifdef _WINDOWS - #include "stdafx.h" -#endif -#include "BrowserImpl.h" -#include "IBrowserFrameGlue.h" - -//***************************************************************************** -// CBrowserImpl::nsIPrompt Implementation -//***************************************************************************** - - -// Needed for JavaScript and other cases where a msg needs to be -// shown to the user. For ex, when a page has some JS such as -// "Alert("Hello")" this method will be invoked -NS_IMETHODIMP -CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->Alert(dialogTitle, text); - - return NS_OK; -} - -// Invoked in the case of a JS confirm() method invocation -NS_IMETHODIMP -CBrowserImpl::Confirm(const PRUnichar *dialogTitle, - const PRUnichar *text, PRBool *retval) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->Confirm(dialogTitle, text, retval); - - return NS_OK; -} - -NS_IMETHODIMP -CBrowserImpl::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, - PRUnichar **promptText, - const PRUnichar *checkMsg, PRBool *checkValue, - PRBool *_retval) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval); - - return NS_OK; -} - -NS_IMETHODIMP -CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, - PRUnichar **password, - const PRUnichar *checkMsg, PRBool *checkValue, - PRBool *_retval) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password, - checkMsg, checkValue, _retval); - - return NS_OK; -} - -NS_IMETHODIMP -CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text, - PRUnichar **username, PRUnichar **password, - const PRUnichar *checkMsg, PRBool *checkValue, - PRBool *_retval) -{ - if(! m_pBrowserFrameGlue) - return NS_ERROR_FAILURE; - - m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text, - username, password, - checkMsg, checkValue, - _retval); - - return NS_OK; -} - -NS_IMETHODIMP -CBrowserImpl::AlertCheck(const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -CBrowserImpl::ConfirmCheck(const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkMsg, - PRBool *checkValue, PRBool *retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -CBrowserImpl::ConfirmEx(const PRUnichar *dialogTitle, const PRUnichar *text, - PRUint32 buttonFlags, const PRUnichar *button0Title, - const PRUnichar *button1Title, const PRUnichar *button2Title, - const PRUnichar *checkMsg, PRBool *checkValue, - PRInt32 *buttonPressed) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -CBrowserImpl::Select(const PRUnichar *dialogTitle, - const PRUnichar *text, PRUint32 count, - const PRUnichar **selectList, - PRInt32 *outSelection, PRBool *retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - diff --git a/mozilla/embedding/tests/mfcembed/BrowserImplWebPrgrsLstnr.cpp b/mozilla/embedding/tests/mfcembed/BrowserImplWebPrgrsLstnr.cpp deleted file mode 100644 index ed820b28618..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserImplWebPrgrsLstnr.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifdef _WINDOWS - #include "stdafx.h" -#endif -#include "BrowserImpl.h" -#include "IBrowserFrameGlue.h" - -//***************************************************************************** -// CBrowserImpl::nsIWebProgressListener Implementation -//***************************************************************************** -// -// - Implements browser progress update functionality -// while loading a page into the embedded browser -// -// - Calls methods via the IBrowserFrameGlue interace -// (available thru' the m_pBrowserFrameGlue member var) -// to do the actual statusbar/progress bar updates. -// - -NS_IMETHODIMP CBrowserImpl::OnProgressChange(nsIWebProgress *progress, - nsIRequest *request, - PRInt32 curSelfProgress, - PRInt32 maxSelfProgress, - PRInt32 curTotalProgress, - PRInt32 maxTotalProgress) -{ - if(! m_pBrowserFrameGlue) { - // always return NS_OK - return NS_OK; - } - - PRInt32 nProgress = curTotalProgress; - PRInt32 nProgressMax = maxTotalProgress; - - if (nProgressMax == 0) - nProgressMax = LONG_MAX; - - if (nProgress > nProgressMax) - nProgress = nProgressMax; // Progress complete - - m_pBrowserFrameGlue->UpdateProgress(nProgress, nProgressMax); - - return NS_OK; -} - -NS_IMETHODIMP CBrowserImpl::OnStateChange(nsIWebProgress *progress, - nsIRequest *request, - PRUint32 progressStateFlags, - nsresult status) -{ - if(! m_pBrowserFrameGlue) { - // always return NS_OK - return NS_OK; - } - - if ((progressStateFlags & STATE_START) && (progressStateFlags & STATE_IS_DOCUMENT)) - { - // Navigation has begun - m_pBrowserFrameGlue->UpdateBusyState(PR_TRUE); - } - - if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_DOCUMENT)) - { - // We've completed the navigation - - m_pBrowserFrameGlue->UpdateBusyState(PR_FALSE); - m_pBrowserFrameGlue->UpdateProgress(0, 100); // Clear the prog bar - m_pBrowserFrameGlue->UpdateStatusBarText(nsnull); // Clear the status bar - } - - return NS_OK; -} - - -NS_IMETHODIMP CBrowserImpl::OnLocationChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsIURI *location) -{ - if(! m_pBrowserFrameGlue) { - // always return NS_OK - return NS_OK; - } - - PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load - if (aWebProgress) { - nsCOMPtr domWindow; - nsCOMPtr topDomWindow; - aWebProgress->GetDOMWindow(getter_AddRefs(domWindow)); - if (domWindow) { // Get root domWindow - domWindow->GetTop(getter_AddRefs(topDomWindow)); - } - if (domWindow != topDomWindow) - isSubFrameLoad = PR_TRUE; - - } - - if (!isSubFrameLoad) // Update urlbar only if it is not a subframe load - m_pBrowserFrameGlue->UpdateCurrentURI(location); - - return NS_OK; -} - -NS_IMETHODIMP -CBrowserImpl::OnStatusChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsresult aStatus, - const PRUnichar* aMessage) -{ - if(m_pBrowserFrameGlue) - m_pBrowserFrameGlue->UpdateStatusBarText(aMessage); - - return NS_OK; -} - - - -NS_IMETHODIMP -CBrowserImpl::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 state) -{ - m_pBrowserFrameGlue->UpdateSecurityStatus(state); - - return NS_OK; -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp b/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp deleted file mode 100644 index 19716573308..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserToolTip.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- 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): - * Adam Lock - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" - -#include "BrowserToolTip.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CBrowserToolTip - -CBrowserToolTip::CBrowserToolTip() -{ -} - -CBrowserToolTip::~CBrowserToolTip() -{ -} - - -BEGIN_MESSAGE_MAP(CBrowserToolTip, CWnd) - //{{AFX_MSG_MAP(CBrowserToolTip) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -BOOL CBrowserToolTip::Create(CWnd *pParentWnd) -{ - return CWnd::CreateEx(WS_EX_TOOLWINDOW, - AfxRegisterWndClass(CS_SAVEBITS, NULL, GetSysColorBrush(COLOR_INFOBK), NULL), - _T("ToolTip"), WS_POPUP | WS_BORDER, 0, 0, 1, 1, pParentWnd->GetSafeHwnd(), NULL); -} - -///////////////////////////////////////////////////////////////////////////// -// CBrowserToolTip message handlers - -void CBrowserToolTip::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect rcClient; - GetClientRect(&rcClient); - - // Draw tip text - int oldBkMode = dc.SetBkMode(TRANSPARENT); - COLORREF oldTextColor = dc.SetTextColor(GetSysColor(COLOR_INFOTEXT)); - HGDIOBJ oldFont = dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT)); - - dc.DrawText(m_szTipText, -1, rcClient, DT_SINGLELINE | DT_VCENTER | DT_CENTER); - - dc.SetBkMode(oldBkMode); - dc.SetTextColor(oldTextColor); - dc.SelectObject(oldFont); -} - -BOOL CBrowserToolTip::PreCreateWindow(CREATESTRUCT& cs) -{ - return CWnd::PreCreateWindow(cs); -} - -void CBrowserToolTip::SetTipText(const CString &szTipText) -{ - m_szTipText = szTipText; -} - -void CBrowserToolTip::Show(CWnd *pOverWnd, long left, long top) -{ - // Calculate the client window size - CRect rcNewClient(0,0,0,0); - CDC *pdc = GetDC(); - HGDIOBJ oldFont = pdc->SelectObject(GetStockObject(DEFAULT_GUI_FONT)); - rcNewClient.bottom = pdc->DrawText(m_szTipText, -1, rcNewClient, - DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT); - pdc->SelectObject(oldFont); - ReleaseDC(pdc); - rcNewClient.right += 8; - rcNewClient.bottom += 8; - - // Adjust the tooltip to new size - AdjustWindowRectEx(rcNewClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE)); - - // Adjust the left, top position of the tooltip - CPoint ptTip(left, top); - pOverWnd->ClientToScreen(&ptTip); - - // Make sure tip is below cursor - POINT ptCursor; - GetCursorPos(&ptCursor); - long cyCursor = GetSystemMetrics(SM_CYCURSOR); - if (ptTip.y < ptCursor.y + cyCursor) - ptTip.y = ptCursor.y + cyCursor; - - // Make sure tip is fully visible - RECT rcScreen; - GetDesktopWindow()->GetClientRect(&rcScreen); - if (ptTip.x < 0) - ptTip.x = 0; - else if (ptTip.x + rcNewClient.Width() > rcScreen.right) - ptTip.x = rcScreen.right - rcNewClient.Width(); - if (ptTip.y < 0) - ptTip.y = 0; - else if (ptTip.y + rcNewClient.Height() > rcScreen.bottom) - ptTip.y = rcScreen.bottom - rcNewClient.Height(); - - // Position and show the tip - SetWindowPos(&CWnd::wndTop, ptTip.x, ptTip.y, rcNewClient.Width(), rcNewClient.Height(), - SWP_NOACTIVATE | SWP_SHOWWINDOW); -} - -void CBrowserToolTip::Hide() -{ - ShowWindow(SW_HIDE); -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserToolTip.h b/mozilla/embedding/tests/mfcembed/BrowserToolTip.h deleted file mode 100644 index 96483e649c1..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserToolTip.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- 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): - * Adam Lock - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_) -#define AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// BrowserToolTip.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CBrowserToolTip window - -class CBrowserToolTip : public CWnd -{ -// Construction -public: - CBrowserToolTip(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBrowserToolTip) - protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL - - CString m_szTipText; -// Implementation -public: - virtual ~CBrowserToolTip(); - - BOOL Create(CWnd *pParentWnd); - void SetTipText(const CString &szTipText); - void Show(CWnd *pOverWnd, long left, long top); - void Hide(); - - - // Generated message map functions -protected: - //{{AFX_MSG(CBrowserToolTip) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BROWSERTOOLTIP_H__13240069_1816_403C_A79D_306FD710B75A__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.cpp b/mozilla/embedding/tests/mfcembed/BrowserView.cpp deleted file mode 100644 index 9e80f25aed9..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserView.cpp +++ /dev/null @@ -1,1333 +0,0 @@ -/* -*- 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): - * Chak Nanga - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -// File Overview.... -// -// When the CBrowserFrm creates this View: -// - CreateBrowser() is called in OnCreate() to create the -// mozilla embeddable browser -// -// OnSize() method handles the window resizes and calls the approriate -// interface method to resize the embedded browser properly -// -// Command handlers to handle browser navigation - OnNavBack(), -// OnNavForward() etc -// -// DestroyBrowser() called for cleaning up during object destruction -// -// Some important coding notes.... -// -// 1. Make sure we do not have the CS_HREDRAW|CS_VREDRAW in the call -// to AfxRegisterWndClass() inside of PreCreateWindow() below -// If these flags are present then you'll see screen flicker when -// you resize the frame window -// -// Next suggested file to look at : BrowserImpl.cpp -// - -#include "stdafx.h" -#include "MfcEmbed.h" -#include "BrowserView.h" -#include "BrowserImpl.h" -#include "BrowserFrm.h" -#include "Dialogs.h" -#include "CPageSetupPropSheet.h" - -// Mozilla Includes -#include "nsIIOService.h" -#include "nsIWidget.h" -#include "nsServiceManagerUtils.h" -#include "nsComponentManagerUtils.h" -#include "nsMemory.h" -#include "nsXPCOM.h" - -static nsresult -NewURI(nsIURI **result, const nsAString &spec) -{ - nsEmbedCString specUtf8; - NS_UTF16ToCString(spec, NS_CSTRING_ENCODING_UTF8, specUtf8); - - nsCOMPtr ios = do_GetService("@mozilla.org/network/io-service;1"); - NS_ENSURE_TRUE(ios, NS_ERROR_UNEXPECTED); - - return ios->NewURI(specUtf8, nsnull, nsnull, result); -} - -static void -ReplaceChar(nsAString &str, char oldChar, char newChar) -{ - // XXX this could be much more efficient - - PRUnichar *data = NS_StringCloneData(str); - PRUnichar *datastring = data; - for (; *data; ++data) - { - if ((char ) *data == oldChar) - *data = (PRUnichar) newChar; - } - NS_StringSetData(str, datastring); - nsMemory::Free(datastring); -} - -static void -StripChars(nsAString &str, const char *chars) -{ - // XXX this could be much more efficient - - PRUint32 len = str.Length(); - - PRUnichar *data = NS_StringCloneData(str); - PRUnichar *datastring = data; - PRUnichar *dataEnd = data + len; - for (; *data; ++data) - { - if (strchr(chars, (char ) *data)) - { - // include trailing null terminator in the memmove - memmove(data, data + 1, (dataEnd - data) * sizeof(PRUnichar)); - --dataEnd; - } - } - NS_StringSetData(str, datastring); - nsMemory::Free(datastring); -} - -static void -StripChars(nsACString &str, const char *chars) -{ - // XXX this could be much more efficient - - PRUint32 len = str.Length(); - - char *data = NS_CStringCloneData(str); - char *datastring = data; - char *dataEnd = data + len; - for (; *data; ++data) - { - if (strchr(chars, *data)) - { - // include trailing null terminator in the memmove - memmove(data, data + 1, dataEnd - data); - --dataEnd; - } - } - NS_CStringSetData(str, datastring); - nsMemory::Free(datastring); -} - -static const char* kWhitespace="\b\t\r\n "; - -static void -CompressWhitespace(nsAString &str) -{ - const PRUnichar *p; - PRInt32 i, len = (PRInt32) NS_StringGetData(str, &p); - - // trim leading whitespace - - for (i=0; i0) - { - NS_StringCutData(str, 0, i); - len = (PRInt32) NS_StringGetData(str, &p); - } - - // trim trailing whitespace - - for (i=len-1; i>=0; --i) - { - if (!strchr(kWhitespace, (char) p[i])) - break; - } - - if (++i < len) - NS_StringCutData(str, i, len - i); -} - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -// Register message for FindDialog communication -static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING); - -BEGIN_MESSAGE_MAP(CBrowserView, CWnd) - //{{AFX_MSG_MAP(CBrowserView) - ON_WM_CREATE() - ON_WM_DESTROY() - ON_WM_SIZE() - - // UrlBar command handlers - ON_COMMAND(IDOK, OnNewUrlEnteredInUrlBar) - ON_CBN_SELENDOK(ID_URL_BAR, OnUrlSelectedInUrlBar) - - // Menu/Toolbar command handlers - ON_COMMAND(ID_FILE_OPEN, OnFileOpen) - ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs) - ON_COMMAND(ID_VIEW_SOURCE, OnViewSource) - ON_COMMAND(ID_VIEW_INFO, OnViewInfo) - ON_COMMAND(ID_NAV_BACK, OnNavBack) - ON_COMMAND(ID_NAV_FORWARD, OnNavForward) - ON_COMMAND(ID_NAV_HOME, OnNavHome) - ON_COMMAND(ID_NAV_RELOAD, OnNavReload) - ON_COMMAND(ID_NAV_STOP, OnNavStop) - ON_COMMAND(ID_EDIT_CUT, OnCut) - ON_COMMAND(ID_EDIT_COPY, OnCopy) - ON_COMMAND(ID_EDIT_PASTE, OnPaste) - ON_COMMAND(ID_EDIT_UNDO, OnUndoUrlBarEditOp) - ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll) - ON_COMMAND(ID_EDIT_SELECT_NONE, OnSelectNone) - ON_COMMAND(ID_OPEN_LINK_IN_NEW_WINDOW, OnOpenLinkInNewWindow) - ON_COMMAND(ID_VIEW_IMAGE, OnViewImageInNewWindow) - ON_COMMAND(ID_COPY_LINK_LOCATION, OnCopyLinkLocation) - ON_COMMAND(ID_SAVE_LINK_AS, OnSaveLinkAs) - ON_COMMAND(ID_SAVE_IMAGE_AS, OnSaveImageAs) - ON_COMMAND(ID_EDIT_FIND, OnShowFindDlg) - ON_COMMAND(ID_FILE_PRINT, OnFilePrint) - ON_COMMAND(ID_FILE_PRINTPREVIEW, OnFilePrintPreview) - ON_COMMAND(ID_FILE_PRINTSETUP, OnFilePrintSetup) - ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) - ON_COMMAND(ID_VIEW_FRAME_SOURCE, OnViewFrameSource) - ON_COMMAND(ID_OPEN_FRAME_IN_NEW_WINDOW, OnOpenFrameInNewWindow) - - // Menu/Toolbar UI update handlers - ON_UPDATE_COMMAND_UI(ID_NAV_BACK, OnUpdateNavBack) - ON_UPDATE_COMMAND_UI(ID_NAV_FORWARD, OnUpdateNavForward) - ON_UPDATE_COMMAND_UI(ID_NAV_STOP, OnUpdateNavStop) - ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateCut) - ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateCopy) - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdatePaste) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint) - ON_UPDATE_COMMAND_UI(ID_FILE_PRINTSETUP, OnUpdatePrintSetup) - ON_UPDATE_COMMAND_UI(ID_VIEW_IMAGE, OnUpdateViewImage) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -CBrowserView::CBrowserView() -{ - mWebBrowser = nsnull; - mBaseWindow = nsnull; - mWebNav = nsnull; - - mpBrowserImpl = nsnull; - mpBrowserFrame = nsnull; - mpBrowserFrameGlue = nsnull; - - mbDocumentLoading = PR_FALSE; - - m_pFindDlg = NULL; - m_bUrlBarClipOp = FALSE; - m_bCurrentlyPrinting = FALSE; - - m_SecurityState = SECURITY_STATE_INSECURE; - - m_InPrintPreview = FALSE; -} - -CBrowserView::~CBrowserView() -{ -} - -// This is a good place to create the embeddable browser -// instance -// -int CBrowserView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - CreateBrowser(); - - return 0; -} - -void CBrowserView::OnDestroy() -{ - DestroyBrowser(); -} - -// Create an instance of the Mozilla embeddable browser -// -HRESULT CBrowserView::CreateBrowser() -{ - // Create web shell - nsresult rv; - mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); - if(NS_FAILED(rv)) - return rv; - - // Save off the nsIWebNavigation interface pointer - // in the mWebNav member variable which we'll use - // later for web page navigation - // - rv = NS_OK; - mWebNav = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; - - // Create the CBrowserImpl object - this is the object - // which implements the interfaces which are required - // by an app embedding mozilla i.e. these are the interfaces - // thru' which the *embedded* browser communicates with the - // *embedding* app - // - // The CBrowserImpl object will be passed in to the - // SetContainerWindow() call below - // - // Also note that we're passing the BrowserFrameGlue pointer - // and also the mWebBrowser interface pointer via CBrowserImpl::Init() - // of CBrowserImpl object. - // These pointers will be saved by the CBrowserImpl object. - // The CBrowserImpl object uses the BrowserFrameGlue pointer to - // call the methods on that interface to update the status/progress bars - // etc. - mpBrowserImpl = new CBrowserImpl(); - if(mpBrowserImpl == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - - // Pass along the mpBrowserFrameGlue pointer to the BrowserImpl object - // This is the interface thru' which the XP BrowserImpl code communicates - // with the platform specific code to update status bars etc. - mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser); - mpBrowserImpl->AddRef(); - - mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, mpBrowserImpl)); - - rv = NS_OK; - nsCOMPtr dsti = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; - - // If the browser window hosting chrome or content? - dsti->SetItemType(((CMfcEmbedApp *)AfxGetApp())->m_bChrome ? - nsIDocShellTreeItem::typeChromeWrapper : - nsIDocShellTreeItem::typeContentWrapper); - - // Create the real webbrowser window - - // Note that we're passing the m_hWnd in the call below to InitWindow() - // (CBrowserView inherits the m_hWnd from CWnd) - // This m_hWnd will be used as the parent window by the embeddable browser - // - rv = NS_OK; - mBaseWindow = do_QueryInterface(mWebBrowser, &rv); - if(NS_FAILED(rv)) - return rv; - - // Get the view's ClientRect which to be passed in to the InitWindow() - // call below - RECT rcLocation; - GetClientRect(&rcLocation); - if(IsRectEmpty(&rcLocation)) - { - rcLocation.bottom++; - rcLocation.top++; - } - - rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd), nsnull, - 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top); - rv = mBaseWindow->Create(); - - // Register the BrowserImpl object to receive progress messages - // These callbacks will be used to update the status/progress bars - nsWeakPtr weakling( - do_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, mpBrowserImpl))); - (void)mWebBrowser->AddWebBrowserListener(weakling, - NS_GET_IID(nsIWebProgressListener)); - - // Finally, show the web browser window - mBaseWindow->SetVisibility(PR_TRUE); - - return S_OK; -} - -HRESULT CBrowserView::DestroyBrowser() -{ - if(mBaseWindow) - { - mBaseWindow->Destroy(); - mBaseWindow = nsnull; - } - - if(mpBrowserImpl) - { - mpBrowserImpl->Release(); - mpBrowserImpl = nsnull; - } - - return NS_OK; -} - -BOOL CBrowserView::PreCreateWindow(CREATESTRUCT& cs) -{ - if (!CWnd::PreCreateWindow(cs)) - return FALSE; - - cs.dwExStyle |= WS_EX_CLIENTEDGE; - cs.style &= ~WS_BORDER; - cs.style |= WS_CLIPCHILDREN; - cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS, - ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); - - return TRUE; -} - -// Adjust the size of the embedded browser -// in response to any container size changes -// -void CBrowserView::OnSize( UINT nType, int cx, int cy) -{ - mBaseWindow->SetPositionAndSize(0, 0, cx, cy, PR_TRUE); -} - -// Called by this object's creator i.e. the CBrowserFrame object -// to pass it's pointer to us -// -void CBrowserView::SetBrowserFrame(CBrowserFrame* pBrowserFrame) -{ - mpBrowserFrame = pBrowserFrame; -} - -void CBrowserView::SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue) -{ - mpBrowserFrameGlue = pBrowserFrameGlue; -} - -// A new URL was entered in the URL bar -// Get the URL's text from the Urlbar's (ComboBox's) EditControl -// and navigate to that URL -// -void CBrowserView::OnNewUrlEnteredInUrlBar() -{ - // Get the currently entered URL - CString strUrl; - mpBrowserFrame->m_wndUrlBar.GetEnteredURL(strUrl); - - if(IsViewSourceUrl(strUrl)) - OpenViewSourceWindow(strUrl.GetBuffer(0)); - else - // Navigate to that URL - OpenURL(strUrl.GetBuffer(0)); - - // Add what was just entered into the UrlBar - mpBrowserFrame->m_wndUrlBar.AddURLToList(strUrl); -} - -// A URL has been selected from the UrlBar's dropdown list -// -void CBrowserView::OnUrlSelectedInUrlBar() -{ - CString strUrl; - - mpBrowserFrame->m_wndUrlBar.GetSelectedURL(strUrl); - - if(IsViewSourceUrl(strUrl)) - OpenViewSourceWindow(strUrl.GetBuffer(0)); - else - OpenURL(strUrl.GetBuffer(0)); -} - -BOOL CBrowserView::IsViewSourceUrl(CString& strUrl) -{ - return (strUrl.Find(_T("view-source:"), 0) != -1) ? TRUE : FALSE; -} - -BOOL CBrowserView::OpenViewSourceWindow(const char* pUrl) -{ - nsEmbedString str; - NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_ASCII, str); - return OpenViewSourceWindow(str.get()); -} - -BOOL CBrowserView::OpenViewSourceWindow(const PRUnichar* pUrl) -{ - // Create a new browser frame in which we'll show the document source - // Note that we're getting rid of the toolbars etc. by specifying - // the appropriate chromeFlags - PRUint32 chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS | - nsIWebBrowserChrome::CHROME_TITLEBAR | - nsIWebBrowserChrome::CHROME_WINDOW_RESIZE; - CBrowserFrame* pFrm = CreateNewBrowserFrame(chromeFlags); - if(!pFrm) - return FALSE; - - // Finally, load this URI into the newly created frame - pFrm->m_wndBrowserView.OpenURL(pUrl); - - pFrm->BringWindowToTop(); - - return TRUE; -} - -void CBrowserView::OnViewSource() -{ - if(! mWebNav) - return; - - // Get the URI object whose source we want to view. - nsresult rv = NS_OK; - nsCOMPtr currentURI; - rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI)); - if(NS_FAILED(rv) || !currentURI) - return; - - // Get the uri string associated with the nsIURI object - nsEmbedCString uriString; - rv = currentURI->GetSpec(uriString); - if(NS_FAILED(rv)) - return; - - // Build the view-source: url - nsEmbedCString viewSrcUrl("view-source:"); - viewSrcUrl.Append(uriString); - - OpenViewSourceWindow(viewSrcUrl.get()); -} - -void CBrowserView::OnViewInfo() -{ - AfxMessageBox(_T("To Be Done...")); -} - -void CBrowserView::OnNavBack() -{ - if(mWebNav) - mWebNav->GoBack(); -} - -void CBrowserView::OnUpdateNavBack(CCmdUI* pCmdUI) -{ - PRBool canGoBack = PR_FALSE; - - if (mWebNav) - mWebNav->GetCanGoBack(&canGoBack); - - pCmdUI->Enable(canGoBack); -} - -void CBrowserView::OnNavForward() -{ - if(mWebNav) - mWebNav->GoForward(); -} - -void CBrowserView::OnUpdateNavForward(CCmdUI* pCmdUI) -{ - PRBool canGoFwd = PR_FALSE; - - if (mWebNav) - mWebNav->GetCanGoForward(&canGoFwd); - - pCmdUI->Enable(canGoFwd); -} - -void CBrowserView::OnNavHome() -{ - // Get the currently configured HomePage URL - CString strHomeURL; - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - if(pApp) - pApp->GetHomePage(strHomeURL); - - if(strHomeURL.GetLength() > 0) - OpenURL(strHomeURL); -} - -void CBrowserView::OnNavReload() -{ - PRUint32 loadFlags = nsIWebNavigation::LOAD_FLAGS_NONE; - if (GetKeyState(VK_SHIFT)) - loadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE; - if (mWebNav) - mWebNav->Reload(loadFlags); -} - -void CBrowserView::OnNavStop() -{ - if(mWebNav) - mWebNav->Stop(nsIWebNavigation::STOP_ALL); -} - -void CBrowserView::OnUpdateNavStop(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(mbDocumentLoading); -} - -void CBrowserView::OnCut() -{ - if(m_bUrlBarClipOp) - { - // We need to operate on the URLBar selection - mpBrowserFrame->CutUrlBarSelToClipboard(); - m_bUrlBarClipOp = FALSE; - } - else - { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - - if(clipCmds) - clipCmds->CutSelection(); - } -} - -void CBrowserView::OnUpdateCut(CCmdUI* pCmdUI) -{ - PRBool canCutSelection = PR_FALSE; - - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if (clipCmds) - clipCmds->CanCutSelection(&canCutSelection); - - if(!canCutSelection) - { - // Check to see if the Cut cmd is to cut the URL - // selection in the UrlBar - if(mpBrowserFrame->CanCutUrlBarSelection()) - { - canCutSelection = TRUE; - m_bUrlBarClipOp = TRUE; - } - } - - pCmdUI->Enable(canCutSelection); -} - -void CBrowserView::OnCopy() -{ - if(m_bUrlBarClipOp) - { - // We need to operate on the URLBar selection - mpBrowserFrame->CopyUrlBarSelToClipboard(); - m_bUrlBarClipOp = FALSE; - } - else - { - // We need to operate on the web page content - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - - if(clipCmds) - clipCmds->CopySelection(); - } -} - -void CBrowserView::OnUpdateCopy(CCmdUI* pCmdUI) -{ - PRBool canCopySelection = PR_FALSE; - - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if (clipCmds) - clipCmds->CanCopySelection(&canCopySelection); - - if(!canCopySelection) - { - // Check to see if the Copy cmd is to copy the URL - // selection in the UrlBar - if(mpBrowserFrame->CanCopyUrlBarSelection()) - { - canCopySelection = TRUE; - m_bUrlBarClipOp = TRUE; - } - } - - pCmdUI->Enable(canCopySelection); -} - -void CBrowserView::OnPaste() -{ - if(m_bUrlBarClipOp) - { - mpBrowserFrame->PasteFromClipboardToUrlBar(); - m_bUrlBarClipOp = FALSE; - } - else - { - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - - if(clipCmds) - clipCmds->Paste(); - } -} - -void CBrowserView::OnUndoUrlBarEditOp() -{ - if(mpBrowserFrame->CanUndoUrlBarEditOp()) - mpBrowserFrame->UndoUrlBarEditOp(); -} - -void CBrowserView::OnUpdatePaste(CCmdUI* pCmdUI) -{ - PRBool canPaste = PR_FALSE; - - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - if (clipCmds) - clipCmds->CanPaste(&canPaste); - - if(!canPaste) - { - if(mpBrowserFrame->CanPasteToUrlBar()) - { - canPaste = TRUE; - m_bUrlBarClipOp = TRUE; - } - } - - pCmdUI->Enable(canPaste); -} - -void CBrowserView::OnSelectAll() -{ - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - - if(clipCmds) - clipCmds->SelectAll(); -} - -void CBrowserView::OnSelectNone() -{ - nsCOMPtr clipCmds = do_GetInterface(mWebBrowser); - - if(clipCmds) - clipCmds->SelectNone(); -} - -void CBrowserView::OnFileOpen() -{ - TCHAR *lpszFilter = - _T("HTML Files Only (*.htm;*.html)|*.htm;*.html|") - _T("All Files (*.*)|*.*||"); - - CFileDialog cf(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - CString strFullPath = cf.GetPathName(); // Will be like: c:\tmp\junk.htm - OpenURL(strFullPath); - } -} - -void CBrowserView::GetBrowserWindowTitle(nsAString& title) -{ - PRUnichar *idlStrTitle = nsnull; - if(mBaseWindow) - mBaseWindow->GetTitle(&idlStrTitle); - - title = idlStrTitle; - nsMemory::Free(idlStrTitle); -} - -void CBrowserView::OnFileSaveAs() -{ - nsEmbedString fileName; - - GetBrowserWindowTitle(fileName); // Suggest the window title as the filename - - // Sanitize the file name of all illegal characters - - USES_CONVERSION; - CompressWhitespace(fileName); // Remove whitespace from the ends - StripChars(fileName, "\\*|:\"> persist(do_QueryInterface(mWebBrowser)); - if(persist) - { - nsEmbedCString fullPath(T2CA(pStrFullPath)); - nsCOMPtr file; - NS_NewNativeLocalFile(fullPath, TRUE, getter_AddRefs(file)); - - nsCOMPtr data; - if (pStrDataPath) - { - nsEmbedCString dataPath(T2CA(pStrDataPath)); - NS_NewNativeLocalFile(dataPath, TRUE, getter_AddRefs(data)); - } - - if(bSaveAll) - persist->SaveDocument(nsnull, file, data, nsnull, 0, 0); - else - persist->SaveURI(nsnull, nsnull, nsnull, nsnull, nsnull, file); - } - } -} - -void CBrowserView::OpenURL(const char* pUrl) -{ - nsEmbedString str; - NS_CStringToUTF16(nsEmbedCString(pUrl), NS_CSTRING_ENCODING_ASCII, str); - OpenURL(str.get()); -} - -void CBrowserView::OpenURL(const PRUnichar* pUrl) -{ - if(mWebNav) - mWebNav->LoadURI(pUrl, // URI string - nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags - nsnull, // Referring URI - nsnull, // Post data - nsnull); // Extra headers -} - -CBrowserFrame* CBrowserView::CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - PRBool bShowWindow) -{ - CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp(); - if(!pApp) - return NULL; - - return pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, bShowWindow); -} - -void CBrowserView::OpenURLInNewWindow(const PRUnichar* pUrl) -{ - if(!pUrl) - return; - - CBrowserFrame* pFrm = CreateNewBrowserFrame(); - if(!pFrm) - return; - - // Load the URL into it... - - // Note that OpenURL() is overloaded - one takes a "char *" - // and the other a "PRUniChar *". We're using the "PRUnichar *" - // version here - - pFrm->m_wndBrowserView.OpenURL(pUrl); -} - -void CBrowserView::LoadHomePage() -{ - OnNavHome(); -} - -void CBrowserView::OnCopyLinkLocation() -{ - if(! mCtxMenuLinkUrl.Length()) - return; - - if (! OpenClipboard()) - return; - - PRUint32 size = mCtxMenuLinkUrl.Length() + 1; - - HGLOBAL hClipData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); - if(! hClipData) - return; - - char *pszClipData = (char*)::GlobalLock(hClipData); - if(!pszClipData) - return; - - memcpy(pszClipData, mCtxMenuLinkUrl.get(), size); - - GlobalUnlock(hClipData); - - EmptyClipboard(); - SetClipboardData(CF_TEXT, hClipData); - CloseClipboard(); -} - -void CBrowserView::OnOpenLinkInNewWindow() -{ - if(mCtxMenuLinkUrl.Length()) - OpenURLInNewWindow(mCtxMenuLinkUrl.get()); -} - -void CBrowserView::OnViewImageInNewWindow() -{ - if(mCtxMenuImgSrc.Length()) - OpenURLInNewWindow(mCtxMenuImgSrc.get()); -} - -void CBrowserView::OnUpdateViewImage(CCmdUI *pCmdUI) -{ - pCmdUI->Enable(mCtxMenuImgSrc.Length() > 0); -} - -void CBrowserView::OnSaveLinkAs() -{ - if(! mCtxMenuLinkUrl.Length()) - return; - - // Try to get the file name part from the URL - // To do that we first construct an obj which supports - // nsIRUI interface. Makes it easy to extract portions - // of a URL like the filename, scheme etc. + We'll also - // use it while saving this link to a file - nsresult rv = NS_OK; - nsCOMPtr linkURI; - rv = NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl); - if (NS_FAILED(rv)) - return; - - // Get the "path" portion (see nsIURI.h for more info - // on various parts of a URI) - nsEmbedCString fileName; - linkURI->GetPath(fileName); - - // The path may have the "/" char in it - strip those - StripChars(fileName, "\\/"); - - // Now, use this file name in a File Save As dlg... - - TCHAR *lpszFilter = - _T("HTML Files (*.htm;*.html)|*.htm;*.html|") - _T("Text Files (*.txt)|*.txt|") - _T("All Files (*.*)|*.*||"); - - CString strFilename = fileName.get(); - - CFileDialog cf(FALSE, _T("htm"), strFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - USES_CONVERSION; - nsEmbedCString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); - nsCOMPtr persist(do_QueryInterface(mWebBrowser)); - if(persist) - { - nsCOMPtr file; - NS_NewNativeLocalFile(fullPath, TRUE, getter_AddRefs(file)); - persist->SaveURI(linkURI, nsnull, nsnull, nsnull, nsnull, file); - } - } -} - -void CBrowserView::OnSaveImageAs() -{ - if(! mCtxMenuImgSrc.Length()) - return; - - // Try to get the file name part from the URL - // To do that we first construct an obj which supports - // nsIRUI interface. Makes it easy to extract portions - // of a URL like the filename, scheme etc. + We'll also - // use it while saving this link to a file - nsresult rv = NS_OK; - nsCOMPtr linkURI; - rv = NewURI(getter_AddRefs(linkURI), mCtxMenuImgSrc); - if (NS_FAILED(rv)) - return; - - // Get the "path" portion (see nsIURI.h for more info - // on various parts of a URI) - nsEmbedCString path; - linkURI->GetPath(path); - - // The path may have the "/" char in it - strip those - nsEmbedCString fileName(path); - StripChars(fileName, "\\/"); - - // Now, use this file name in a File Save As dlg... - - TCHAR *lpszFilter = _T("All Files (*.*)|*.*||"); - CString strFilename = fileName.get(); - - CFileDialog cf(FALSE, NULL, strFilename, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - USES_CONVERSION; - nsEmbedCString fullPath; fullPath.Assign(T2CA(cf.GetPathName())); - - nsCOMPtr persist(do_QueryInterface(mWebBrowser)); - if(persist) - { - nsCOMPtr file; - NS_NewNativeLocalFile(fullPath, TRUE, getter_AddRefs(file)); - persist->SaveURI(linkURI, nsnull, nsnull, nsnull, nsnull, file); - } - } -} - -void CBrowserView::OnShowFindDlg() -{ - // When the the user chooses the Find menu item - // and if a Find dlg. is already being shown - // just set focus to the existing dlg instead of - // creating a new one - if(m_pFindDlg) - { - m_pFindDlg->SetFocus(); - return; - } - - CString csSearchStr; - PRBool bMatchCase = PR_FALSE; - PRBool bMatchWholeWord = PR_FALSE; - PRBool bWrapAround = PR_FALSE; - PRBool bSearchBackwards = PR_FALSE; - - // See if we can get and initialize the dlg box with - // the values/settings the user specified in the previous search - nsCOMPtr finder(do_GetInterface(mWebBrowser)); - if(finder) - { - PRUnichar *stringBuf = nsnull; - finder->GetSearchString(&stringBuf); - csSearchStr = stringBuf; - nsMemory::Free(stringBuf); - - finder->GetMatchCase(&bMatchCase); - finder->GetEntireWord(&bMatchWholeWord); - finder->GetWrapFind(&bWrapAround); - finder->GetFindBackwards(&bSearchBackwards); - } - - m_pFindDlg = new CFindDialog(csSearchStr, bMatchCase, bMatchWholeWord, - bWrapAround, bSearchBackwards, this); - m_pFindDlg->Create(TRUE, NULL, NULL, 0, this); -} - -// This will be called whenever the user pushes the Find -// button in the Find dialog box -// This method gets bound to the WM_FINDMSG windows msg via the -// -// ON_REGISTERED_MESSAGE(WM_FINDMSG, OnFindMsg) -// -// message map entry. -// -// WM_FINDMSG (which is registered towards the beginning of this file) -// is the message via which the FindDialog communicates with this view -// -LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) -{ - nsCOMPtr finder(do_GetInterface(mWebBrowser)); - if(!finder) - return NULL; - - // Get the pointer to the current Find dialog box - CFindDialog* dlg = (CFindDialog *) CFindReplaceDialog::GetNotifier(lParam); - if(!dlg) - return NULL; - - // Has the user decided to terminate the dialog box? - if(dlg->IsTerminating()) - return NULL; - - if(dlg->FindNext()) - { - USES_CONVERSION; - finder->SetSearchString(T2W(dlg->GetFindString().GetBuffer(0))); - finder->SetMatchCase(dlg->MatchCase() ? PR_TRUE : PR_FALSE); - finder->SetEntireWord(dlg->MatchWholeWord() ? PR_TRUE : PR_FALSE); - finder->SetWrapFind(dlg->WrapAround() ? PR_TRUE : PR_FALSE); - finder->SetFindBackwards(dlg->SearchBackwards() ? PR_TRUE : PR_FALSE); - - PRBool didFind; - nsresult rv = finder->FindNext(&didFind); - - if(!didFind) - { - AfxMessageBox(IDS_SRCH_STR_NOT_FOUND); - dlg->SetFocus(); - } - - return (NS_SUCCEEDED(rv) && didFind); - } - - return 0; -} - -void CBrowserView::OnFilePrint() -{ - nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { - if (!m_PrintSettings) - { - if (NS_FAILED(print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)))) { - return; - } - } - nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { - print->Print(m_PrintSettings, nsnull); - } - - } -} - -void CBrowserView::OnFilePrintPreview() -{ - nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { - if (!m_PrintSettings) - { - if (NS_FAILED(print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)))) { - return; - } - } - if (!m_InPrintPreview) - { - if (NS_SUCCEEDED(print->PrintPreview(m_PrintSettings, nsnull, nsnull))) - { - m_InPrintPreview = TRUE; - - CMenu* menu = mpBrowserFrame->GetMenu(); - if (menu) - { - menu->CheckMenuItem( ID_FILE_PRINTPREVIEW, MF_CHECKED ); - } - } - } - else - { - if (NS_SUCCEEDED(print->ExitPrintPreview())) - { - m_InPrintPreview = FALSE; - CMenu* menu = mpBrowserFrame->GetMenu(); - if (menu) - { - menu->CheckMenuItem( ID_FILE_PRINTPREVIEW, MF_UNCHECKED ); - } - } - } - } -} - -void CBrowserView::OnFilePrintSetup() -{ - nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { - if (!m_PrintSettings) - { - if (NS_FAILED(print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)))) { - return; - } - } - CPageSetupPropSheet propSheet(_T("Page Setup"), this); - - propSheet.SetPrintSettingsValues(m_PrintSettings); - - int status = propSheet.DoModal(); - if (status == IDOK) - { - propSheet.GetPrintSettingsValues(m_PrintSettings); - } - } -} - -///////////////////////////////////////////////////////////////////////////// -void CBrowserView::OnUpdateFilePrint(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_bCurrentlyPrinting); -} - -///////////////////////////////////////////////////////////////////////////// -void CBrowserView::OnUpdatePrintSetup(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(!m_bCurrentlyPrinting && !m_InPrintPreview); -} - - - -// Called from the busy state related methods in the -// BrowserFrameGlue object -// -// When aBusy is TRUE it means that browser is busy loading a URL -// When aBusy is FALSE, it's done loading -// We use this to update our STOP tool bar button -// -// We basically note this state into a member variable -// The actual toolbar state will be updated in response to the -// ON_UPDATE_COMMAND_UI method - OnUpdateNavStop() being called -// -void CBrowserView::UpdateBusyState(PRBool aBusy) -{ - if (mbDocumentLoading && !aBusy && m_InPrintPreview) - { - nsCOMPtr print(do_GetInterface(mWebBrowser)); - if(print) - { - PRBool isDoingPP; - print->GetDoingPrintPreview(&isDoingPP); - if (!isDoingPP) - { - m_InPrintPreview = FALSE; - CMenu* menu = mpBrowserFrame->GetMenu(); - if (menu) - { - menu->CheckMenuItem( ID_FILE_PRINTPREVIEW, MF_UNCHECKED ); - } - } - } - } - mbDocumentLoading = aBusy; -} - -void CBrowserView::SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl) -{ - mCtxMenuLinkUrl = strLinkUrl; -} - -void CBrowserView::SetCtxMenuImageSrc(nsEmbedString& strImgSrc) -{ - mCtxMenuImgSrc = strImgSrc; -} - -void CBrowserView::SetCurrentFrameURL(nsEmbedString& strCurrentFrameURL) -{ - mCtxMenuCurrentFrameURL = strCurrentFrameURL; -} - -void CBrowserView::Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized) -{ - if(bMinimized) // This isn't an activate event that Gecko cares about - return; - - nsCOMPtr focus(do_GetInterface(mWebBrowser)); - if(!focus) - return; - - switch(nState) { - case WA_ACTIVE: - case WA_CLICKACTIVE: - focus->Activate(); - break; - case WA_INACTIVE: - focus->Deactivate(); - break; - default: - break; - } -} - -void CBrowserView::ShowSecurityInfo() -{ - HWND hParent = mpBrowserFrame->m_hWnd; - - if(m_SecurityState == SECURITY_STATE_INSECURE) { - CString csMsg; - csMsg.LoadString(IDS_NOSECURITY_INFO); - ::MessageBox(hParent, csMsg, _T("MfcEmbed"), MB_OK); - return; - } - - ::MessageBox(hParent, _T("To Be Done.........."), _T("MfcEmbed"), MB_OK); -} - -// Determintes if the currently loaded document -// contains frames -// -BOOL CBrowserView::ViewContentContainsFrames() -{ - nsresult rv = NS_OK; - - // Get nsIDOMDocument from nsIWebNavigation - nsCOMPtr domDoc; - rv = mWebNav->GetDocument(getter_AddRefs(domDoc)); - if(NS_FAILED(rv)) - return FALSE; - - // QI nsIDOMDocument for nsIDOMHTMLDocument - nsCOMPtr htmlDoc = do_QueryInterface(domDoc); - if (!htmlDoc) - return FALSE; - - // Get the element of the doc - nsCOMPtr body; - rv = htmlDoc->GetBody(getter_AddRefs(body)); - if(NS_FAILED(rv)) - return FALSE; - - // Is it of type nsIDOMHTMLFrameSetElement? - nsCOMPtr frameset = do_QueryInterface(body); - - return (frameset != nsnull); -} - -void CBrowserView::OnViewFrameSource() -{ - // Build the view-source: url - // - nsEmbedString viewSrcUrl; - viewSrcUrl.Append(L"view-source:"); - viewSrcUrl.Append(mCtxMenuCurrentFrameURL); - - OpenViewSourceWindow(viewSrcUrl.get()); -} - -void CBrowserView::OnOpenFrameInNewWindow() -{ - if(mCtxMenuCurrentFrameURL.Length()) - OpenURLInNewWindow(mCtxMenuCurrentFrameURL.get()); -} diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.h b/mozilla/embedding/tests/mfcembed/BrowserView.h deleted file mode 100644 index 03bfd6d203b..00000000000 --- a/mozilla/embedding/tests/mfcembed/BrowserView.h +++ /dev/null @@ -1,205 +0,0 @@ -/* -*- 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): - * Chak Nanga - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -// BrowserView.h : interface of the CBrowserView class -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef _BROWSERVIEW_H -#define _BROWSERVIEW_H - -#if _MSC_VER > 1000 - #pragma once -#endif - -#include "IBrowserFrameGlue.h" -#include "nsIPrintSettings.h" - -///////////////////////////////////////////////////////////////////////////// -// CBrowserView window - -class CBrowserFrame; -class CBrowserImpl; -class CFindDialog; -class CPrintProgressDialog; - -class CBrowserView : public CWnd -{ -public: - CBrowserView(); - virtual ~CBrowserView(); - - // Some helper methods - HRESULT CreateBrowser(); - HRESULT DestroyBrowser(); - void OpenURL(const char* pUrl); - void OpenURL(const PRUnichar* pUrl); - CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, - PRInt32 x = -1, PRInt32 y = -1, - PRInt32 cx = -1, PRInt32 cy = -1, - PRBool bShowWindow = PR_TRUE); - void OpenURLInNewWindow(const PRUnichar* pUrl); - void LoadHomePage(); - - void GetBrowserWindowTitle(nsAString& title); - - // Called by the CBrowserFrame after it creates the view - // Essentially a back pointer to the BrowserFrame - void SetBrowserFrame(CBrowserFrame* pBrowserFrame); - CBrowserFrame* mpBrowserFrame; - - // Called by the CBrowserFrame after it creates the view - // The view passes this on to the embedded Browser's Impl - // obj - void SetBrowserFrameGlue(PBROWSERFRAMEGLUE pBrowserFrameGlue); - PBROWSERFRAMEGLUE mpBrowserFrameGlue; - - // Pointer to the object which implements - // the inerfaces required by Mozilla embedders - // - CBrowserImpl* mpBrowserImpl; - - // Mozilla interfaces - // - nsCOMPtr mWebBrowser; - nsCOMPtr mBaseWindow; - nsCOMPtr mWebNav; - - void UpdateBusyState(PRBool aBusy); - PRBool mbDocumentLoading; - - void SetCtxMenuLinkUrl(nsEmbedString& strLinkUrl); - nsEmbedString mCtxMenuLinkUrl; - - void SetCtxMenuImageSrc(nsEmbedString& strImgSrc); - nsEmbedString mCtxMenuImgSrc; - - void SetCurrentFrameURL(nsEmbedString& strCurrentFrameURL); - nsEmbedString mCtxMenuCurrentFrameURL; - - inline void ClearFindDialog() { m_pFindDlg = NULL; } - CFindDialog* m_pFindDlg; - CPrintProgressDialog* m_pPrintProgressDlg; - // When set to TRUE... - // indicates that the clipboard operation needs to be - // performed on the UrlBar rather than on - // the web page content - // - BOOL m_bUrlBarClipOp; - - // indicates whether we are currently printing - BOOL m_bCurrentlyPrinting; - - void Activate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - - BOOL OpenViewSourceWindow(const PRUnichar* pUrl); - BOOL OpenViewSourceWindow(const char* pUrl); - BOOL IsViewSourceUrl(CString& strUrl); - - enum _securityState { - SECURITY_STATE_SECURE, - SECURITY_STATE_INSECURE, - SECURITY_STATE_BROKEN - }; - int m_SecurityState; - void ShowSecurityInfo(); - - BOOL ViewContentContainsFrames(); - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBrowserView) - protected: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL - - - // Generated message map functions -protected: - nsCOMPtr m_PrintSettings; - BOOL m_InPrintPreview; - - //{{AFX_MSG(CBrowserView) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnDestroy(); - afx_msg void OnSize( UINT, int, int ); - // UrlBar command handlers - // - afx_msg void OnUrlSelectedInUrlBar(); - afx_msg void OnNewUrlEnteredInUrlBar(); - - // ToolBar/Menu command handlers - // - afx_msg void OnFileOpen(); - afx_msg void OnFileSaveAs(); - afx_msg void OnViewSource(); - afx_msg void OnViewInfo(); - afx_msg void OnNavBack(); - afx_msg void OnNavForward(); - afx_msg void OnNavHome(); - afx_msg void OnNavReload(); - afx_msg void OnNavStop(); - afx_msg void OnCut(); - afx_msg void OnCopy(); - afx_msg void OnPaste(); - afx_msg void OnUndoUrlBarEditOp(); - afx_msg void OnSelectAll(); - afx_msg void OnSelectNone(); - afx_msg void OnCopyLinkLocation(); - afx_msg void OnOpenLinkInNewWindow(); - afx_msg void OnViewImageInNewWindow(); - afx_msg void OnSaveLinkAs(); - afx_msg void OnSaveImageAs(); - afx_msg void OnShowFindDlg(); - afx_msg void OnFilePrint(); - afx_msg void OnFilePrintPreview(); - afx_msg void OnFilePrintSetup(); - afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI); - afx_msg void OnUpdatePrintSetup(CCmdUI* pCmdUI); - afx_msg LRESULT OnFindMsg(WPARAM wParam, LPARAM lParam); - afx_msg void OnViewFrameSource(); - afx_msg void OnOpenFrameInNewWindow(); - - // Handlers to keep the toolbar/menu items up to date - // - afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI); - afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI); - afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI); - afx_msg void OnUpdateCut(CCmdUI* pCmdUI); - afx_msg void OnUpdateCopy(CCmdUI* pCmdUI); - afx_msg void OnUpdatePaste(CCmdUI* pCmdUI); - afx_msg void OnUpdateViewImage(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#endif //_BROWSERVIEW_H diff --git a/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.cpp b/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.cpp deleted file mode 100644 index 13a783812bf..00000000000 --- a/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// CustomPromptDialog.cpp : implementation file -// - -#include "stdafx.h" -#include "mfcembed.h" -#include "CCustomPromptDialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCustomPromptDialog dialog - - -CCustomPromptDialog::CCustomPromptDialog(CWnd* pParent /*=NULL*/) - : CDialog(CCustomPromptDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(CCustomPromptDialog) - m_CustomText = _T(""); - //}}AFX_DATA_INIT -} - - -void CCustomPromptDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CCustomPromptDialog) - DDX_Text(pDX, IDC_PROMPT_TEXT, m_CustomText); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CCustomPromptDialog, CDialog) - //{{AFX_MSG_MAP(CCustomPromptDialog) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomPromptDialog message handlers diff --git a/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.h b/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.h deleted file mode 100644 index b8dd32908f4..00000000000 --- a/mozilla/embedding/tests/mfcembed/CCustomPromptDialog.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined(AFX_CCUSTOMPROMPTDIALOG_H__6C159F14_88A7_465F_993B_76B03D670DE5__INCLUDED_) -#define AFX_CCUSTOMPROMPTDIALOG_H__6C159F14_88A7_465F_993B_76B03D670DE5__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// CCustomPromptDialog.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CCustomPromptDialog dialog - -class CCustomPromptDialog : public CDialog -{ -// Construction -public: - CCustomPromptDialog(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CCustomPromptDialog) - enum { IDD = IDD_CUSTOM_PROMPT_DIALOG }; - CString m_CustomText; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CCustomPromptDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CCustomPromptDialog) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CUSTOMPROMPTDIALOG_H__6C159F14_88A7_465F_993B_76B03D670DE5__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/CFormatOptionTab.cpp b/mozilla/embedding/tests/mfcembed/CFormatOptionTab.cpp deleted file mode 100644 index 9c155a20ced..00000000000 --- a/mozilla/embedding/tests/mfcembed/CFormatOptionTab.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// FormatOptionTab.cpp : implementation file -// - -#include "stdafx.h" -#include "mfcembed.h" -#include "CFormatOptionTab.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -const int kMinScaleRange = 30; - -///////////////////////////////////////////////////////////////////////////// -typedef struct { - TCHAR* mDesc; - short mUnit; - double mWidth; - double mHeight; - BOOL mIsUserDefined; -} PaperSizes; - -static const PaperSizes gPaperSize[] = { - {_T("Letter (8.5 x 11.0)"), nsIPrintSettings::kPaperSizeInches, 8.5, 11.0, FALSE}, - {_T("Legal (8.5 x 14.0)"), nsIPrintSettings::kPaperSizeInches, 8.5, 14.0, FALSE}, - {_T("A4 (210 x 297mm)"), nsIPrintSettings::kPaperSizeMillimeters, 210.0, 297.0, FALSE}, - {_T("User Defined"), nsIPrintSettings::kPaperSizeInches, 8.5, 11.0, TRUE} -}; -static const int gNumPaperSizes = 4; - - -///////////////////////////////////////////////////////////////////////////// -// CFormatOptionTab property page - -IMPLEMENT_DYNCREATE(CFormatOptionTab, CPropertyPage) - -CFormatOptionTab::CFormatOptionTab() : CPropertyPage(CFormatOptionTab::IDD) -{ - //{{AFX_DATA_INIT(CFormatOptionTab) - m_PaperSize = -1; - m_BGColors = FALSE; - m_Scaling = 0; - m_ScalingText = _T(""); - m_PaperHeight = 0.0; - m_PaperWidth = 0.0; - m_DoInches = -1; - m_BGImages = FALSE; - m_IsLandScape = FALSE; - //}}AFX_DATA_INIT -} - -CFormatOptionTab::~CFormatOptionTab() -{ -} - -void CFormatOptionTab::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CFormatOptionTab) - DDX_CBIndex(pDX, IDC_PAPER_SIZE_CBX, m_PaperSize); - DDX_Check(pDX, IDC_PRT_BGCOLORS, m_BGColors); - DDX_Slider(pDX, IDC_SCALE, m_Scaling); - DDX_Text(pDX, IDC_SCALE_TXT, m_ScalingText); - DDX_Text(pDX, IDC_UD_PAPER_HGT, m_PaperHeight); - DDX_Text(pDX, IDC_UD_PAPER_WDTH, m_PaperWidth); - DDX_Radio(pDX, IDC_INCHES_RD, m_DoInches); - DDX_Check(pDX, IDC_PRT_BGIMAGES, m_BGImages); - DDX_Radio(pDX, IDC_PRT_PORTRAIT_RD, m_IsLandScape); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CFormatOptionTab, CPropertyPage) - //{{AFX_MSG_MAP(CFormatOptionTab) - ON_NOTIFY(NM_CUSTOMDRAW, IDC_SCALE, OnCustomdrawScale) - ON_EN_KILLFOCUS(IDC_SCALE_TXT, OnKillfocusScaleTxt) - ON_CBN_SELCHANGE(IDC_PAPER_SIZE_CBX, OnSelchangePaperSizeCbx) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFormatOptionTab message handlers - -BOOL CFormatOptionTab::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CSliderCtrl* scale = (CSliderCtrl*)GetDlgItem(IDC_SCALE); - CWnd* scaleTxt = GetDlgItem(IDC_SCALE_TXT); - if (scale != NULL) - { - scale->SetRange(kMinScaleRange, 100); - scale->SetBuddy(scaleTxt, FALSE); - scale->SetTicFreq(10); - } - - CComboBox* cbx = (CComboBox*)GetDlgItem(IDC_PAPER_SIZE_CBX); - if (cbx != NULL) - { - // First Initialize the Combobox - for (int i=0;iAddString(gPaperSize[i].mDesc); - } - short unit; - double paperWidth = 0.0; - double paperHeight = 0.0; - m_PrintSettings->GetPaperSizeType(&unit); - m_PrintSettings->GetPaperWidth(&paperWidth); - m_PrintSettings->GetPaperHeight(&paperHeight); - - m_PaperSizeInx = GetPaperSizeIndexFromData(unit, paperWidth, paperHeight); - if (m_PaperSizeInx == -1) - { // couldn't find a match - m_PaperSizeInx = 0; - unit = gPaperSize[m_PaperSizeInx].mUnit; - paperWidth = gPaperSize[m_PaperSizeInx].mWidth; - paperHeight = gPaperSize[m_PaperSizeInx].mHeight; - } - - cbx->SetCurSel(m_PaperSizeInx); - - EnableUserDefineControls(gPaperSize[m_PaperSizeInx].mIsUserDefined); - - if (gPaperSize[m_PaperSizeInx].mIsUserDefined) - { - CString wStr; - CString hStr; - if (unit == nsIPrintSettings::kPaperSizeInches) - { - wStr.Format(_T("%6.2f"), paperWidth); - hStr.Format(_T("%6.2f"), paperHeight); - CheckRadioButton(IDC_INCHES_RD, IDC_MILLI_RD, IDC_INCHES_RD); - } - else - { - wStr.Format(_T("%d"), int(paperWidth)); - hStr.Format(_T("%d"), int(paperHeight)); - CheckRadioButton(IDC_INCHES_RD, IDC_MILLI_RD, IDC_MILLI_RD); - } - CWnd* widthTxt = GetDlgItem(IDC_UD_PAPER_WDTH); - CWnd* heightTxt = GetDlgItem(IDC_UD_PAPER_HGT); - widthTxt->SetWindowText(wStr); - heightTxt->SetWindowText(hStr); - } - else - { - CheckRadioButton(IDC_INCHES_RD, IDC_MILLI_RD, IDC_INCHES_RD); - } - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CFormatOptionTab::OnCustomdrawScale(NMHDR* pNMHDR, LRESULT* pResult) -{ - CSliderCtrl* scale = (CSliderCtrl*)GetDlgItem(IDC_SCALE); - CWnd* scaleTxt = GetDlgItem(IDC_SCALE_TXT); - if (scale != NULL && scaleTxt != NULL) - { - CString str; - str.Format(_T("%d"), scale->GetPos()); - scaleTxt->SetWindowText(str); - } - - *pResult = 0; -} - -static int GetIntFromStr(const TCHAR * aStr, int aMinVal = kMinScaleRange, int aMaxVal = 100) -{ - int val = aMinVal; - _stscanf(aStr, _T("%d"), &val); - if (val < aMinVal) - { - return aMinVal; - } - else if (val > aMaxVal) - { - return aMaxVal; - } - return val; -} - -void CFormatOptionTab::OnKillfocusScaleTxt() -{ - CSliderCtrl* scale = (CSliderCtrl*)GetDlgItem(IDC_SCALE); - CWnd* scaleTxt = GetDlgItem(IDC_SCALE_TXT); - if (scale != NULL && scaleTxt != NULL) - { - CString str; - scaleTxt->GetWindowText(str); - scale->SetPos(GetIntFromStr(str)); - } -} - - -void CFormatOptionTab::EnableUserDefineControls(BOOL aEnable) -{ - CWnd* cntrl = GetDlgItem(IDC_UD_WIDTH_LBL); - cntrl->EnableWindow(aEnable); - cntrl = GetDlgItem(IDC_UD_HEIGHT_LBL); - cntrl->EnableWindow(aEnable); - cntrl = GetDlgItem(IDC_UD_PAPER_WDTH); - cntrl->EnableWindow(aEnable); - cntrl = GetDlgItem(IDC_UD_PAPER_HGT); - cntrl->EnableWindow(aEnable); - cntrl = GetDlgItem(IDC_INCHES_RD); - cntrl->EnableWindow(aEnable); - cntrl = GetDlgItem(IDC_MILLI_RD); - cntrl->EnableWindow(aEnable); -} - -void CFormatOptionTab::OnSelchangePaperSizeCbx() -{ - CComboBox* cbx = (CComboBox*)GetDlgItem(IDC_PAPER_SIZE_CBX); - if (cbx) - { - CString text; - cbx->GetWindowText(text); - m_PaperSizeInx = GetPaperSizeIndex(text); - EnableUserDefineControls(gPaperSize[m_PaperSizeInx].mIsUserDefined); - } -} - -void CFormatOptionTab::GetPaperSizeInfo(short& aUnit, double& aWidth, double& aHeight) -{ - if (gPaperSize[m_PaperSizeInx].mIsUserDefined) - { - aUnit = m_DoInches == 0?nsIPrintSettings::kPaperSizeInches:nsIPrintSettings::kPaperSizeMillimeters; - aWidth = m_PaperWidth; - aHeight = m_PaperHeight; - } - else - { - aUnit = gPaperSize[m_PaperSizeInx].mUnit; - aWidth = gPaperSize[m_PaperSizeInx].mWidth; - aHeight = gPaperSize[m_PaperSizeInx].mHeight; - } -} - -// Search for Sizes in Pape Size Data -int CFormatOptionTab::GetPaperSizeIndexFromData(short aUnit, double aW, double aH) -{ - int i; - for (i=0;i - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined(AFX_CFORMATOPTIONTAB_H__F7BDB355_9202_440A_8478_165AD3FC2F41__INCLUDED_) -#define AFX_CFORMATOPTIONTAB_H__F7BDB355_9202_440A_8478_165AD3FC2F41__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// CFormatOptionTab.h : header file -// - -#include "nsIPrintSettings.h" - -///////////////////////////////////////////////////////////////////////////// -// CFormatOptionTab dialog - -class CFormatOptionTab : public CPropertyPage -{ - DECLARE_DYNCREATE(CFormatOptionTab) - -// Construction -public: - CFormatOptionTab(); - ~CFormatOptionTab(); - void GetPaperSizeInfo(short& aType, double& aWidth, double& aHeight); - -// Dialog Data - //{{AFX_DATA(CFormatOptionTab) - enum { IDD = IDD_FORMAT_OPTIONS_TAB }; - int m_PaperSize; - BOOL m_BGColors; - int m_Scaling; - CString m_ScalingText; - int m_DoInches; - BOOL m_BGImages; - double m_PaperHeight; - double m_PaperWidth; - BOOL m_IsLandScape; - //}}AFX_DATA - - nsCOMPtr m_PrintSettings; - int m_PaperSizeInx; - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(CFormatOptionTab) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void EnableUserDefineControls(BOOL aEnable); - int GetPaperSizeIndexFromData(short aType, double aW, double aH); - int GetPaperSizeIndex(const CString& aStr); - - // Generated message map functions - //{{AFX_MSG(CFormatOptionTab) - virtual BOOL OnInitDialog(); - afx_msg void OnCustomdrawScale(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnKillfocusScaleTxt(); - afx_msg void OnSelchangePaperSizeCbx(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CFORMATOPTIONTAB_H__F7BDB355_9202_440A_8478_165AD3FC2F41__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.cpp b/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.cpp deleted file mode 100644 index 3d0e418e8c3..00000000000 --- a/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// MarginHeaderFooter.cpp : implementation file -// - -#include "stdafx.h" -#include "mfcembed.h" -#include "CMarginHeaderFooter.h" -#include "CCustomPromptDialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -static TCHAR* sCBXTitles[] = { - _T("--Blank--"), _T("Title"), _T("URL"), _T("Date/Time"), _T("Page #"), - _T("Page # of #"), _T("Custom..."), NULL}; -static TCHAR* sCBXValues[] = { - _T(""), _T("&T"), _T("&U"), _T("&D"), _T("&P"), _T("&PT"), _T(""), NULL}; - -///////////////////////////////////////////////////////////////////////////// -// CMarginHeaderFooter property page - -IMPLEMENT_DYNCREATE(CMarginHeaderFooter, CPropertyPage) - -CMarginHeaderFooter::CMarginHeaderFooter() : CPropertyPage(CMarginHeaderFooter::IDD) -{ - //{{AFX_DATA_INIT(CMarginHeaderFooter) - m_BottomMarginText = _T(""); - m_LeftMarginText = _T(""); - m_RightMarginText = _T(""); - m_TopMarginText = _T(""); - //}}AFX_DATA_INIT - - m_FooterLeftText = _T(""); - m_FooterCenterText = _T(""); - m_FooterRightText = _T(""); - m_HeaderLeftText = _T(""); - m_HeaderCenterText = _T(""); - m_HeaderRightText = _T(""); -} - -CMarginHeaderFooter::~CMarginHeaderFooter() -{ -} - -void CMarginHeaderFooter::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CMarginHeaderFooter) - DDX_Text(pDX, IDC_BOTTOM_MARGIN_TXT, m_BottomMarginText); - DDX_Text(pDX, IDC_LEFT_MARGIN_TXT, m_LeftMarginText); - DDX_Text(pDX, IDC_RIGHT_MARGIN_TXT, m_RightMarginText); - DDX_Text(pDX, IDC_TOP_MARGIN_TXT, m_TopMarginText); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CMarginHeaderFooter, CPropertyPage) - //{{AFX_MSG_MAP(CMarginHeaderFooter) - ON_CBN_SELCHANGE(IDC_FTR_LEFT_CMBX, OnEditchangeFTRLeft) - ON_CBN_SELCHANGE(IDC_FTR_CENTER_CMBX, OnEditchangeFTRCenter) - ON_CBN_SELCHANGE(IDC_FTR_RIGHT_CMBX, OnEditchangeFTRRight) - ON_CBN_SELCHANGE(IDC_HDR_LEFT_CMBX, OnEditchangeHDRLeft) - ON_CBN_SELCHANGE(IDC_HDR_CENTER_CMBX, OnEditchangeHDRCenter) - ON_CBN_SELCHANGE(IDC_HDR_RIGHT_CMBX, OnEditchangeHDRRight) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMarginHeaderFooter message handlers - -void CMarginHeaderFooter::SetComboboxValue(int aId, const TCHAR *aItem) -{ - CComboBox* cbx = (CComboBox*)GetDlgItem(aId); - if (cbx) - { - int inx = 0; - while (sCBXValues[inx] != NULL) - { - if (!_tcscmp(sCBXValues[inx], aItem)) - { - cbx->SetCurSel(inx); - return; - } - inx++; - } - cbx->SetCurSel(inx-1); - } -} - -void CMarginHeaderFooter::AddCBXItem(int aId, const TCHAR * aItem) -{ - CComboBox* cbx = (CComboBox*)GetDlgItem(aId); - if (cbx) - { - cbx->AddString(aItem); - } -} - -BOOL CMarginHeaderFooter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - int inx = 0; - while (sCBXTitles[inx] != NULL) - { - AddCBXItem(IDC_HDR_LEFT_CMBX, sCBXTitles[inx]); - AddCBXItem(IDC_HDR_CENTER_CMBX, sCBXTitles[inx]); - AddCBXItem(IDC_HDR_RIGHT_CMBX, sCBXTitles[inx]); - AddCBXItem(IDC_FTR_LEFT_CMBX, sCBXTitles[inx]); - AddCBXItem(IDC_FTR_CENTER_CMBX, sCBXTitles[inx]); - AddCBXItem(IDC_FTR_RIGHT_CMBX, sCBXTitles[inx]); - inx++; - } - SetComboboxValue(IDC_HDR_LEFT_CMBX, m_HeaderLeftText); - SetComboboxValue(IDC_HDR_CENTER_CMBX, m_HeaderCenterText); - SetComboboxValue(IDC_HDR_RIGHT_CMBX, m_HeaderRightText); - SetComboboxValue(IDC_FTR_LEFT_CMBX, m_FooterLeftText); - SetComboboxValue(IDC_FTR_CENTER_CMBX, m_FooterCenterText); - SetComboboxValue(IDC_FTR_RIGHT_CMBX, m_FooterRightText); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CMarginHeaderFooter::SetCombobox(int aId, CString& aText) -{ - CComboBox* cbx = (CComboBox*)GetDlgItem(aId); - int inx = cbx->GetCurSel(); - if (inx == 6) - { - CCustomPromptDialog prompt(this); - prompt.m_CustomText = aText; - if(prompt.DoModal() == IDOK) - { - aText = prompt.m_CustomText; - } - } else { - aText = sCBXValues[inx]; - } -} - -void CMarginHeaderFooter::OnEditchangeFTRLeft() -{ - SetCombobox(IDC_FTR_LEFT_CMBX, m_FooterLeftText); -} - -void CMarginHeaderFooter::OnEditchangeFTRCenter() -{ - SetCombobox(IDC_FTR_CENTER_CMBX, m_FooterCenterText); -} - -void CMarginHeaderFooter::OnEditchangeFTRRight() -{ - SetCombobox(IDC_FTR_CENTER_CMBX, m_FooterCenterText); -} - -void CMarginHeaderFooter::OnEditchangeHDRLeft() -{ - SetCombobox(IDC_HDR_LEFT_CMBX, m_HeaderLeftText); -} - -void CMarginHeaderFooter::OnEditchangeHDRCenter() -{ - SetCombobox(IDC_HDR_CENTER_CMBX, m_HeaderCenterText); -} - -void CMarginHeaderFooter::OnEditchangeHDRRight() -{ - SetCombobox(IDC_HDR_CENTER_CMBX, m_HeaderCenterText); -} diff --git a/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.h b/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.h deleted file mode 100644 index e55cc8bdfe7..00000000000 --- a/mozilla/embedding/tests/mfcembed/CMarginHeaderFooter.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined(AFX_CMARGINHEADERFOOTER_H__A95A9A17_692E_425B_8B70_419C24DDE6BC__INCLUDED_) -#define AFX_CMARGINHEADERFOOTER_H__A95A9A17_692E_425B_8B70_419C24DDE6BC__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// CMarginHeaderFooter.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CMarginHeaderFooter dialog - -class CMarginHeaderFooter : public CPropertyPage -{ - DECLARE_DYNCREATE(CMarginHeaderFooter) - -// Construction -public: - CMarginHeaderFooter(); - ~CMarginHeaderFooter(); - -// Dialog Data - //{{AFX_DATA(CMarginHeaderFooter) - enum { IDD = IDD_HEADERFOOTER_TAB }; - CString m_BottomMarginText; - CString m_LeftMarginText; - CString m_RightMarginText; - CString m_TopMarginText; - //}}AFX_DATA - - CString m_FooterLeftText; - CString m_FooterCenterText; - CString m_FooterRightText; - CString m_HeaderLeftText; - CString m_HeaderCenterText; - CString m_HeaderRightText; - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(CMarginHeaderFooter) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void SetCombobox(int aId, CString& aText); - void SetComboboxValue(int aId, const TCHAR * aValue); - void AddCBXItem(int aId, const TCHAR * aItem); - - // Generated message map functions - //{{AFX_MSG(CMarginHeaderFooter) - virtual BOOL OnInitDialog(); - afx_msg void OnEditchangeFTRLeft(); - afx_msg void OnEditchangeFTRCenter(); - afx_msg void OnEditchangeFTRRight(); - afx_msg void OnEditchangeHDRLeft(); - afx_msg void OnEditchangeHDRCenter(); - afx_msg void OnEditchangeHDRRight(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MARGINHEADERFOOTER_H__A95A9A17_692E_425B_8B70_419C24DDE6BC__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp b/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp deleted file mode 100644 index 684d90cc13c..00000000000 --- a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -// CPageSetupPropSheet.cpp : implementation file -// - -#include "stdafx.h" -#include "resource.h" -#include "CPageSetupPropSheet.h" -#include "nsMemory.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupPropSheet - -IMPLEMENT_DYNAMIC(CPageSetupPropSheet, CPropertySheet) - -CPageSetupPropSheet::CPageSetupPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) - :CPropertySheet(nIDCaption, pParentWnd, iSelectPage) -{ - AddControlPages(); -} - -CPageSetupPropSheet::CPageSetupPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) - :CPropertySheet(pszCaption, pParentWnd, iSelectPage) -{ - AddControlPages(); -} - -CPageSetupPropSheet::~CPageSetupPropSheet() -{ -} - - -BEGIN_MESSAGE_MAP(CPageSetupPropSheet, CPropertySheet) - //{{AFX_MSG_MAP(CPageSetupPropSheet) - // NOTE - the ClassWizard will add and remove mapping macros here. - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupPropSheet message handlers - -///////////////////////////////////////////////////////////////////////////// -void CPageSetupPropSheet::AddControlPages() -{ - m_psh.dwFlags &= ~PSH_HASHELP; // Lose the Help button - AddPage(&m_FormatOptionTab); - AddPage(&m_MarginHeaderFooterTab); -} - -///////////////////////////////////////////////////////////////////////////// -static float GetFloatFromStr(const TCHAR * aStr, float aMaxVal = 1.0) -{ - float val; - _stscanf(aStr, _T("%f"), &val); - if (val <= aMaxVal) - { - return val; - } - else - { - return 0.5; - } -} - -///////////////////////////////////////////////////////////////////////////// -static PRUnichar* GetUnicodeFromCString(const CString& aStr) -{ -#ifdef _UNICODE - nsEmbedString str(aStr); -#else - nsEmbedString str; - NS_CStringToUTF16(nsEmbedCString(aStr), NS_CSTRING_ENCODING_ASCII, str); -#endif - return NS_StringCloneData(str); -} - -///////////////////////////////////////////////////////////////////////////// -void CPageSetupPropSheet::SetPrintSettingsValues(nsIPrintSettings* aPrintSettings) -{ - m_FormatOptionTab.m_PrintSettings = aPrintSettings; - - if (aPrintSettings != NULL) - { - double top, left, right, bottom; - aPrintSettings->GetMarginTop(&top); - aPrintSettings->GetMarginLeft(&left); - aPrintSettings->GetMarginRight(&right); - aPrintSettings->GetMarginBottom(&bottom); - - char buf[16]; - sprintf(buf, "%5.2f", top); - m_MarginHeaderFooterTab.m_TopMarginText = buf; - sprintf(buf, "%5.2f", left); - m_MarginHeaderFooterTab.m_LeftMarginText = buf; - sprintf(buf, "%5.2f", right); - m_MarginHeaderFooterTab.m_RightMarginText = buf; - sprintf(buf, "%5.2f", bottom); - m_MarginHeaderFooterTab.m_BottomMarginText = buf; - - PRInt32 orientation; - aPrintSettings->GetOrientation(&orientation); - m_FormatOptionTab.m_IsLandScape = orientation != nsIPrintSettings::kPortraitOrientation; - - double scaling; - aPrintSettings->GetScaling(&scaling); - m_FormatOptionTab.m_Scaling = int(scaling * 100.0); - - PRBool boolVal; - aPrintSettings->GetPrintBGColors(&boolVal); - m_FormatOptionTab.m_BGColors = boolVal == PR_TRUE; - aPrintSettings->GetPrintBGImages(&boolVal); - m_FormatOptionTab.m_BGImages = boolVal == PR_TRUE; - - PRUnichar* uStr; - aPrintSettings->GetHeaderStrLeft(&uStr); - m_MarginHeaderFooterTab.m_HeaderLeftText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - - aPrintSettings->GetHeaderStrCenter(&uStr); - m_MarginHeaderFooterTab.m_HeaderCenterText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - - aPrintSettings->GetHeaderStrRight(&uStr); - m_MarginHeaderFooterTab.m_HeaderRightText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - - aPrintSettings->GetFooterStrLeft(&uStr); - m_MarginHeaderFooterTab.m_FooterLeftText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - - aPrintSettings->GetFooterStrCenter(&uStr); - m_MarginHeaderFooterTab.m_FooterCenterText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - - aPrintSettings->GetFooterStrRight(&uStr); - m_MarginHeaderFooterTab.m_FooterRightText = uStr; - if (uStr != nsnull) nsMemory::Free(uStr); - } -} - -///////////////////////////////////////////////////////////////////////////// -void CPageSetupPropSheet::GetPrintSettingsValues(nsIPrintSettings* aPrintSettings) -{ - - if (!aPrintSettings) return; - - aPrintSettings->SetScaling(double(m_FormatOptionTab.m_Scaling) / 100.0); - aPrintSettings->SetPrintBGColors(m_FormatOptionTab.m_BGColors); - aPrintSettings->SetPrintBGImages(m_FormatOptionTab.m_BGImages); - - PRInt32 orientation = m_FormatOptionTab.m_IsLandScape? - nsIPrintSettings::kLandscapeOrientation:nsIPrintSettings::kPortraitOrientation; - aPrintSettings->SetOrientation(orientation); - - short type; - double width; - double height; - m_FormatOptionTab.GetPaperSizeInfo(type, width, height); - aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeDefined); - aPrintSettings->SetPaperSizeUnit(type); - aPrintSettings->SetPaperWidth(width); - aPrintSettings->SetPaperHeight(height); - - aPrintSettings->SetMarginTop(GetFloatFromStr(m_MarginHeaderFooterTab.m_TopMarginText)); - aPrintSettings->SetMarginLeft(GetFloatFromStr(m_MarginHeaderFooterTab.m_LeftMarginText)); - aPrintSettings->SetMarginRight(GetFloatFromStr(m_MarginHeaderFooterTab.m_RightMarginText)); - aPrintSettings->SetMarginBottom(GetFloatFromStr(m_MarginHeaderFooterTab.m_BottomMarginText)); - - PRUnichar* uStr; - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_HeaderLeftText); - aPrintSettings->SetHeaderStrLeft(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); - - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_HeaderCenterText); - aPrintSettings->SetHeaderStrCenter(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); - - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_HeaderRightText); - aPrintSettings->SetHeaderStrRight(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); - - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_FooterLeftText); - aPrintSettings->SetFooterStrLeft(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); - - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_FooterCenterText); - aPrintSettings->SetFooterStrCenter(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); - - uStr = GetUnicodeFromCString(m_MarginHeaderFooterTab.m_FooterRightText); - aPrintSettings->SetFooterStrRight(uStr); - if (uStr != nsnull) nsMemory::Free(uStr); -} - diff --git a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.h b/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.h deleted file mode 100644 index 25dc3162428..00000000000 --- a/mozilla/embedding/tests/mfcembed/CPageSetupPropSheet.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -#if !defined(AFX_CPAGESETUPPROPSHEET_H__E8A6D703_7EAD_4729_8FBA_9E0515AB9822__INCLUDED_) -#define AFX_CPAGESETUPPROPSHEET_H__E8A6D703_7EAD_4729_8FBA_9E0515AB9822__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// CPageSetupPropSheet.h : header file -// -#include "CFormatOptionTab.h" -#include "CMarginHeaderFooter.h" - -///////////////////////////////////////////////////////////////////////////// -// CPageSetupPropSheet - -class CPageSetupPropSheet : public CPropertySheet -{ - DECLARE_DYNAMIC(CPageSetupPropSheet) - -// Construction -public: - CPageSetupPropSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - CPageSetupPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - - void SetPrintSettingsValues(nsIPrintSettings* aPrintSettings); - void GetPrintSettingsValues(nsIPrintSettings* aPrintSettings); - -protected: - void AddControlPages(void); - -// Attributes -public: - CFormatOptionTab m_FormatOptionTab; - CMarginHeaderFooter m_MarginHeaderFooterTab; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPageSetupPropSheet) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CPageSetupPropSheet(); - - // Generated message map functions -protected: - //{{AFX_MSG(CPageSetupPropSheet) - // NOTE - the ClassWizard will add and remove member functions here. - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CPAGESETUPPROPSHEET_H__E8A6D703_7EAD_4729_8FBA_9E0515AB9822__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/Dialogs.cpp b/mozilla/embedding/tests/mfcembed/Dialogs.cpp deleted file mode 100644 index 696a9b205af..00000000000 --- a/mozilla/embedding/tests/mfcembed/Dialogs.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" -#include "Dialogs.h" -#include "BrowserView.h" - -// File overview.... -// -// contains Find dialog box code -// - -//--------------------------------------------------------------------------// -// CFindDialog Stuff -//--------------------------------------------------------------------------// - -CFindDialog::CFindDialog(CString& csSearchStr, PRBool bMatchCase, - PRBool bMatchWholeWord, PRBool bWrapAround, - PRBool bSearchBackwards, CBrowserView* pOwner) - : CFindReplaceDialog() -{ - // Save these initial settings off in member vars - // We'll use these to initialize the controls - // in InitDialog() - m_csSearchStr = csSearchStr; - m_bMatchCase = bMatchCase; - m_bMatchWholeWord = bMatchWholeWord; - m_bWrapAround = bWrapAround; - m_bSearchBackwards = bSearchBackwards; - m_pOwner = pOwner; - - // Set up to load our customized Find dialog template - // rather than the default one MFC provides - m_fr.Flags |= FR_ENABLETEMPLATE; - m_fr.hInstance = AfxGetInstanceHandle(); - m_fr.lpTemplateName = MAKEINTRESOURCE(IDD_FINDDLG); -} - -BOOL CFindDialog::OnInitDialog() -{ - CFindReplaceDialog::OnInitDialog(); - - CEdit* pEdit = (CEdit *)GetDlgItem(IDC_FIND_EDIT); - if(pEdit) - pEdit->SetWindowText(m_csSearchStr); - - CButton* pChk = (CButton *)GetDlgItem(IDC_MATCH_CASE); - if(pChk) - pChk->SetCheck(m_bMatchCase); - - pChk = (CButton *)GetDlgItem(IDC_MATCH_WHOLE_WORD); - if(pChk) - pChk->SetCheck(m_bMatchWholeWord); - - pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); - if(pChk) - pChk->SetCheck(m_bWrapAround); - - pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); - if(pChk) - pChk->SetCheck(m_bSearchBackwards); - - return TRUE; -} - -void CFindDialog::PostNcDestroy() -{ - // Let the owner know we're gone - if(m_pOwner != NULL) - m_pOwner->ClearFindDialog(); - - CFindReplaceDialog::PostNcDestroy(); -} - -BOOL CFindDialog::WrapAround() -{ - CButton* pChk = (CButton *)GetDlgItem(IDC_WRAP_AROUND); - - return pChk ? pChk->GetCheck() : FALSE; -} - -BOOL CFindDialog::SearchBackwards() -{ - CButton* pChk = (CButton *)GetDlgItem(IDC_SEARCH_BACKWARDS); - - return pChk ? pChk->GetCheck() : FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// CLinkPropertiesDlg dialog -CLinkPropertiesDlg::CLinkPropertiesDlg(CWnd* pParent /*=NULL*/) - : CDialog(CLinkPropertiesDlg::IDD, pParent) -{ - m_LinkText = _T(""); - m_LinkLocation = _T(""); -} - -void CLinkPropertiesDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Text(pDX, IDC_EDIT_LINK_TEXT, m_LinkText); - DDX_Text(pDX, IDC_EDIT_LINK_LOCATION, m_LinkLocation); -} - - -BEGIN_MESSAGE_MAP(CLinkPropertiesDlg, CDialog) -END_MESSAGE_MAP() - -void CLinkPropertiesDlg::OnOK() -{ - UpdateData(TRUE); - - if (m_LinkLocation.IsEmpty() || (m_LinkText.IsEmpty() && m_LinkLocation.IsEmpty())) - { - MessageBox(_T("Please enter a Link Location")); - return; - } - - if (m_LinkText.IsEmpty()) - { - m_LinkText = m_LinkLocation; - } - - EndDialog(IDOK); -} diff --git a/mozilla/embedding/tests/mfcembed/Dialogs.h b/mozilla/embedding/tests/mfcembed/Dialogs.h deleted file mode 100644 index 2176d7f5953..00000000000 --- a/mozilla/embedding/tests/mfcembed/Dialogs.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _DIALOGS_H_ -#define _DIALOGS_H_ - -#include "resource.h" - -class CBrowserView; - -class CFindDialog : public CFindReplaceDialog -{ -public: - CFindDialog(CString& csSearchStr, PRBool bMatchCase, - PRBool bMatchWholeWord, PRBool bWrapAround, - PRBool bSearchBackwards, CBrowserView* pOwner); - BOOL WrapAround(); - BOOL SearchBackwards(); - -private: - CString m_csSearchStr; - PRBool m_bMatchCase; - PRBool m_bMatchWholeWord; - PRBool m_bWrapAround; - PRBool m_bSearchBackwards; - CBrowserView* m_pOwner; - -protected: - virtual BOOL OnInitDialog(); - virtual void PostNcDestroy(); -}; - -///////////////////////////////////////////////////////////////////////////// -// CLinkPropertiesDlg dialog - -class CLinkPropertiesDlg : public CDialog -{ -public: - CLinkPropertiesDlg(CWnd* pParent = NULL); - - enum { IDD = IDD_DIALOG_LINK_PROPERTIES }; - CString m_LinkText; - CString m_LinkLocation; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); - virtual void OnOK(); - - DECLARE_MESSAGE_MAP() -}; - -#endif //_DIALOG_H_ diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp b/mozilla/embedding/tests/mfcembed/EditorFrm.cpp deleted file mode 100644 index 5561173d836..00000000000 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.cpp +++ /dev/null @@ -1,674 +0,0 @@ -/* -*- 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): - * Mike Judge - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" -#include "MfcEmbed.h" -#include "BrowserFrm.h" -#include "EditorFrm.h" -#include "Dialogs.h" -#include "nsComponentManagerUtils.h" -#include "nsMemory.h" -#include "nsIEditor.h" -#include "nsIHTMLEditor.h" - -//------------------------------------------------------------ -// Editor Command/Parameter Names -//------------------------------------------------------------ -#define BOLD_COMMAND "cmd_bold" -#define ITALIC_COMMAND "cmd_italic" -#define UNDERLINE_COMMAND "cmd_underline" -#define INDENT_COMMAND "cmd_indent" -#define OUTDENT_COMMAND "cmd_outdent" -#define FONTCOLOR_COMMAND "cmd_fontColor" -#define BACKGROUNDCOLOR_COMMAND "cmd_backgroundColor" -#define COMMAND_NAME "cmd_name" -#define INCREASEFONT_COMMAND "cmd_increaseFont" -#define DECREASEFONT_COMMAND "cmd_decreaseFont" -#define FONTFACE_COMMAND "cmd_fontFace" -#define ALIGN_COMMAND "cmd_align" -#define UNDO_COMMAND "cmd_undo" -#define REDO_COMMAND "cmd_redo" - - -//states -#define STATE_ALL "state_all" -#define STATE_MIXED "state_mixed" -#define STATE_ATTRIBUTE "state_attribute" -#define STATE_ENABLED "state_enabled" - -//colors -#define COLOR_RED "#FF0000" -#define COLOR_BLACK "#000000" - -//fonts -#define FONT_ARIAL "Helvetica, Arial, sans-serif" -#define FONT_TIMES "Times New Roman, Times, serif" -#define FONT_COURIER "Courier New, Courier, monospace" - -//align -#define ALIGN_LEFT "left" -#define ALIGN_RIGHT "right" -#define ALIGN_CENTER "center" - - -//value -#define STATE_EMPTY "" - -IMPLEMENT_DYNAMIC(CEditorFrame, CBrowserFrame) - -BEGIN_MESSAGE_MAP(CEditorFrame, CBrowserFrame) - //{{AFX_MSG_MAP(CEditorFrame) - ON_COMMAND(ID_BOLD, OnBold) - ON_UPDATE_COMMAND_UI(ID_BOLD, OnUpdateBold) - ON_COMMAND(ID_ITALICS, OnItalics) - ON_UPDATE_COMMAND_UI(ID_ITALICS, OnUpdateItalics) - ON_COMMAND(ID_UNDERLINE, OnUnderline) - ON_UPDATE_COMMAND_UI(ID_UNDERLINE, OnUpdateUnderline) - ON_COMMAND(ID_INDENT, OnIndent) - ON_UPDATE_COMMAND_UI(ID_INDENT, OnUpdateIndent) - ON_COMMAND(ID_OUTDENT, OnOutdent) - ON_UPDATE_COMMAND_UI(ID_OUTDENT, OnUpdateOutdent) - ON_COMMAND(ID_FONTRED, OnFontred) - ON_UPDATE_COMMAND_UI(ID_FONTRED, OnUpdateFontred) - ON_COMMAND(ID_FONTBLACK, OnFontblack) - ON_UPDATE_COMMAND_UI(ID_FONTBLACK, OnUpdateFontblack) - ON_COMMAND(ID_BGCOLOR, OnBgcolor) - ON_UPDATE_COMMAND_UI(ID_BGCOLOR, OnUpdateBgcolor) - ON_COMMAND(ID_NOBGCOLOR, OnNobgcolor) - ON_UPDATE_COMMAND_UI(ID_NOBGCOLOR, OnUpdateNobgcolor) - ON_COMMAND(ID_FONTSIZEINCREASE, OnFontsizeincrease) - ON_COMMAND(ID_FONTSIZEDECREASE, OnFontsizedecrease) - ON_COMMAND(ID_ARIAL, OnArial) - ON_COMMAND(ID_TIMES, OnTimes) - ON_COMMAND(ID_COURIER, OnCourier) - ON_COMMAND(ID_ALIGNLEFT, OnAlignleft) - ON_UPDATE_COMMAND_UI(ID_ALIGNLEFT, OnUpdateAlignleft) - ON_COMMAND(ID_ALIGNRIGHT, OnAlignright) - ON_UPDATE_COMMAND_UI(ID_ALIGNRIGHT, OnUpdateAlignright) - ON_COMMAND(ID_ALIGNCENTER, OnAligncenter) - ON_UPDATE_COMMAND_UI(ID_ALIGNCENTER, OnUpdateAligncenter) - ON_COMMAND(ID_INSERTLINK, OnInsertlink) - ON_COMMAND(ID_EDITOR_UNDO, OnEditUndo) - ON_COMMAND(ID_EDITOR_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDITOR_REDO, OnUpdateEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDITOR_UNDO, OnUpdateEditUndo) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -CEditorFrame::CEditorFrame(PRUint32 chromeMask) -{ - m_chromeMask = chromeMask; - - mCommandManager = nsnull; -} - -CEditorFrame::~CEditorFrame() -{ -} - -BOOL CEditorFrame::InitEditor() -{ - // Get and save off nsICommandManager for later use - // - nsresult rv; - mCommandManager = do_GetInterface(m_wndBrowserView.mWebBrowser, &rv); - - rv = MakeEditable(); - - return (NS_SUCCEEDED(rv)); -} - -void CEditorFrame::OnBold() -{ - ExecuteStyleCommand(BOLD_COMMAND); -} - -void CEditorFrame::OnUpdateBold(CCmdUI* pCmdUI) -{ - UpdateStyleToolBarBtn(BOLD_COMMAND, pCmdUI); -} - -void CEditorFrame::OnItalics() -{ - ExecuteStyleCommand(ITALIC_COMMAND); -} - -void CEditorFrame::OnUpdateItalics(CCmdUI* pCmdUI) -{ - UpdateStyleToolBarBtn(ITALIC_COMMAND, pCmdUI); -} - -void CEditorFrame::OnUnderline() -{ - ExecuteStyleCommand(UNDERLINE_COMMAND); -} - -void CEditorFrame::OnUpdateUnderline(CCmdUI* pCmdUI) -{ - UpdateStyleToolBarBtn(UNDERLINE_COMMAND, pCmdUI); -} - - -//Called to make a nsICommandParams with the 1 value pair of command name -NS_METHOD -CEditorFrame::MakeCommandParams(const char *aCommand,nsICommandParams **aParams) -{ - nsresult rv; - nsCOMPtr params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); - if (NS_FAILED(rv)) - return rv; - if (!params) - return NS_ERROR_FAILURE; - *aParams = params; - NS_ADDREF(*aParams); - return rv; -} - - -// Called in response to the ON_COMMAND messages generated -// when style related toolbar buttons(bold, italic etc) -// are clicked -// -NS_METHOD -CEditorFrame::ExecuteStyleCommand(const char *aCommand) -{ - return DoCommand(aCommand,0); -} - -// Called in response to the UPDATE_COMMAND_UI messages for -// style related toolbar buttons(bold, italic etc.) -// to update their current state -// -void CEditorFrame::UpdateStyleToolBarBtn(const char *aCommand, CCmdUI* pCmdUI) -{ - nsCOMPtr params; - nsresult rv; - rv = MakeCommandParams(aCommand,getter_AddRefs(params)); - if (NS_FAILED(rv) || !params) - return; - rv = GetCommandState(aCommand,params); - if (NS_SUCCEEDED(rv)) - { - // Does our current selection span mixed styles? - // If so, set the toolbar button to an indeterminate - // state - // - PRBool bMixedStyle = PR_FALSE; - rv = params->GetBooleanValue(STATE_MIXED, &bMixedStyle); - if (NS_SUCCEEDED(rv)) - { - if(bMixedStyle) - { - pCmdUI->SetCheck(2); - return; - } - } - - // We're not in STATE_MIXED. Enable/Disable the - // toolbar button based on it's current state - // - PRBool bCmdEnabled = PR_FALSE; - rv = params->GetBooleanValue(STATE_ALL, &bCmdEnabled); - if (NS_SUCCEEDED(rv)) - { - bCmdEnabled ? pCmdUI->SetCheck(1) : pCmdUI->SetCheck(0); - } - } -} - -NS_METHOD -CEditorFrame::MakeEditable() -{ - nsresult rv; - - m_wndBrowserView.mWebBrowser->GetContentDOMWindow(getter_AddRefs(mDOMWindow)); - if (!mDOMWindow) - return NS_ERROR_FAILURE; - - mEditingSession = do_GetInterface(m_wndBrowserView.mWebBrowser); - if (!mEditingSession) - return NS_ERROR_FAILURE; - - rv= mEditingSession->MakeWindowEditable(mDOMWindow, NULL, PR_TRUE); - - return rv; -} - -NS_METHOD -CEditorFrame::DoCommand(const char *aCommand, nsICommandParams *aCommandParams) -{ - nsCOMPtr domWindow; - m_wndBrowserView.mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); - return mCommandManager ? mCommandManager->DoCommand(aCommand, aCommandParams, domWindow) : NS_ERROR_FAILURE; -} - -NS_METHOD -CEditorFrame::IsCommandEnabled(const char *aCommand, PRBool *retval) -{ - nsCOMPtr domWindow; - m_wndBrowserView.mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); - return mCommandManager ? mCommandManager->IsCommandEnabled(aCommand, domWindow, retval) : NS_ERROR_FAILURE; -} - - -NS_METHOD -CEditorFrame::GetCommandState(const char *aCommand, nsICommandParams *aCommandParams) -{ - nsCOMPtr domWindow; - m_wndBrowserView.mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); - return mCommandManager ? mCommandManager->GetCommandState(aCommand, domWindow, aCommandParams) : NS_ERROR_FAILURE; -} - -NS_METHOD -CEditorFrame::ExecuteNoParam(const char *aCommand) -{ - return DoCommand(aCommand,0); -} - -void CEditorFrame::OnIndent() -{ - ExecuteNoParam(INDENT_COMMAND); -} - -void CEditorFrame::OnUpdateIndent(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -void CEditorFrame::OnOutdent() -{ - ExecuteNoParam(OUTDENT_COMMAND); -} - -void CEditorFrame::OnUpdateOutdent(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -NS_METHOD -CEditorFrame::ExecuteAttribParam(const char *aCommand, const char *aAttribute) -{ - nsresult rv; - nsCOMPtr params; - rv = MakeCommandParams(aCommand,getter_AddRefs(params)); - if (NS_FAILED(rv)) - return rv; - if (!params) - return NS_ERROR_FAILURE; - params->SetCStringValue(STATE_ATTRIBUTE, aAttribute); - return DoCommand(aCommand,params); -} - -NS_METHOD -CEditorFrame::GetAttributeParamValue(const char *aCommand, nsEmbedCString &aValue) -{ - nsresult rv; - nsCOMPtr params; - rv = MakeCommandParams(aCommand,getter_AddRefs(params)); - if (NS_FAILED(rv)) - return rv; - if (!params) - return NS_ERROR_FAILURE; - rv = GetCommandState(aCommand, params); - if (NS_SUCCEEDED(rv)) - { - char *tchar; - rv = params->GetCStringValue(STATE_ATTRIBUTE,&tchar); - aValue.Assign(tchar); - nsMemory::Free(tchar); - return rv; - } - return rv; -} - - -void CEditorFrame::OnFontred() -{ - ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_RED); -} - -void CEditorFrame::OnUpdateFontred(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -void CEditorFrame::OnFontblack() -{ - ExecuteAttribParam(FONTCOLOR_COMMAND,COLOR_BLACK); -} - -void CEditorFrame::OnUpdateFontblack(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -void CEditorFrame::OnBgcolor() -{ - ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,COLOR_RED); -} - -void CEditorFrame::OnUpdateBgcolor(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -void CEditorFrame::OnNobgcolor() -{ - ExecuteAttribParam(BACKGROUNDCOLOR_COMMAND,STATE_EMPTY); -} - -void CEditorFrame::OnUpdateNobgcolor(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here -} - -void CEditorFrame::OnFontsizeincrease() -{ - ExecuteNoParam(INCREASEFONT_COMMAND); -} - -void CEditorFrame::OnFontsizedecrease() -{ - ExecuteNoParam(DECREASEFONT_COMMAND); -} - -void CEditorFrame::OnArial() -{ - ExecuteAttribParam(FONTFACE_COMMAND,FONT_ARIAL); -} - -void CEditorFrame::OnTimes() -{ - ExecuteAttribParam(FONTFACE_COMMAND,FONT_TIMES); -} - -void CEditorFrame::OnCourier() -{ - ExecuteAttribParam(FONTFACE_COMMAND,FONT_COURIER); -} - -void CEditorFrame::OnAlignleft() -{ - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_LEFT); -} - - -void CEditorFrame::OnUpdateAlignleft(CCmdUI* pCmdUI) -{ - nsEmbedCString tValue; - - nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); - if (NS_SUCCEEDED(rv)) - { - if (strcmp(tValue.get(), ALIGN_LEFT) == 0) - pCmdUI->SetCheck(1); - else - pCmdUI->SetCheck(0); - } -} - -void CEditorFrame::OnAlignright() -{ - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_RIGHT); -} - -void CEditorFrame::OnUpdateAlignright(CCmdUI* pCmdUI) -{ - nsEmbedCString tValue; - nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); - if (NS_SUCCEEDED(rv)) - { - if (strcmp(tValue.get(), ALIGN_RIGHT) == 0) - pCmdUI->SetCheck(1); - else - pCmdUI->SetCheck(0); - } -} - -void CEditorFrame::OnAligncenter() -{ - ExecuteAttribParam(ALIGN_COMMAND,ALIGN_CENTER); -} - -void CEditorFrame::OnUpdateAligncenter(CCmdUI* pCmdUI) -{ - nsEmbedCString tValue; - nsresult rv = GetAttributeParamValue(ALIGN_COMMAND,tValue); - if (NS_SUCCEEDED(rv)) - { - if (strcmp(tValue.get(), ALIGN_CENTER) == 0) - pCmdUI->SetCheck(1); - else - pCmdUI->SetCheck(0); - } -} - -void CEditorFrame::OnInsertlink() -{ - if (InLink()) - ShowEditLinkDlg(); - else - ShowInsertLinkDlg(); -} - -void CEditorFrame::ShowInsertLinkDlg() -{ - CLinkPropertiesDlg dlg; - - if(dlg.DoModal() == IDOK) - { - InsertLink(dlg.m_LinkText, dlg.m_LinkLocation); - } -} - -void CEditorFrame::InsertLink(CString& linkText, CString& linkLocation) -{ - CString html = "  " + linkText + "  "; - - InsertHTML(html); -} - -void CEditorFrame::InsertHTML(CString& str) -{ - nsEmbedString htmlToInsert; -#ifdef _UNICODE - htmlToInsert.Assign(str.GetBuffer(0)); -#else - NS_CStringToUTF16(nsEmbedCString(str.GetBuffer(0)), - NS_CSTRING_ENCODING_ASCII, - htmlToInsert); -#endif - - nsCOMPtr htmlEditor; - GetHTMLEditor(getter_AddRefs(htmlEditor)); - if (htmlEditor) - htmlEditor->InsertHTML(htmlToInsert); -} - -void CEditorFrame::ShowEditLinkDlg() -{ - nsCOMPtr anchorElement; - CLinkPropertiesDlg dlg; - - if (GetCurrentLinkInfo(dlg.m_LinkText, dlg.m_LinkLocation, getter_AddRefs(anchorElement))) - { - if(dlg.DoModal() == IDOK) - { - //Select the link being edited and then insert the - //new link into it's place i.e. essentially a replace operation - nsCOMPtr htmlEditor; - GetHTMLEditor(getter_AddRefs(htmlEditor)); - if (htmlEditor) - htmlEditor->SelectElement(anchorElement); - - InsertLink(dlg.m_LinkText, dlg.m_LinkLocation); - } - } -} - -BOOL CEditorFrame::GetCurrentLinkInfo(CString& strLinkText, CString& strLinkLocation, nsIDOMHTMLAnchorElement** anchorElement) -{ - USES_CONVERSION; - - nsCOMPtr htmlEditor; - - GetHTMLEditor(getter_AddRefs(htmlEditor)); - if (!htmlEditor) - return FALSE; - - nsCOMPtr domElement; - htmlEditor->GetElementOrParentByTagName(nsEmbedString(L"href"), - nsnull, - getter_AddRefs(domElement)); - if (!domElement) - return FALSE; - - nsEmbedString linkLocation, linkText; - nsresult rv = NS_ERROR_FAILURE; - - // Determine linkLocation - nsCOMPtr linkElement(do_QueryInterface(domElement, &rv)); - if (NS_SUCCEEDED(rv)) - rv = linkElement->GetHref(linkLocation); - if (NS_FAILED(rv)) - return FALSE; - - // Determine linkText - nsCOMPtr firstChild; - rv = linkElement->GetFirstChild(getter_AddRefs(firstChild)); - if (NS_FAILED(rv)) - return FALSE; - firstChild->GetNodeValue(linkText); - if (NS_FAILED(rv)) - return FALSE; - - strLinkText = W2CT(linkText.get()); - strLinkLocation = W2CT(linkLocation.get()); - - *anchorElement = linkElement; - NS_ADDREF(*anchorElement); - - return TRUE; -} - -void CEditorFrame::OnEditUndo() -{ - ExecuteNoParam(UNDO_COMMAND); -} - -void CEditorFrame::OnEditRedo() -{ - ExecuteNoParam(REDO_COMMAND); -} - -void CEditorFrame::OnUpdateEditRedo(CCmdUI* pCmdUI) -{ - nsresult rv; - nsCOMPtr params; - rv = MakeCommandParams(REDO_COMMAND,getter_AddRefs(params)); - if (NS_FAILED(rv)) - return; - if (!params) - return; - rv = GetCommandState(REDO_COMMAND, params); - if (NS_SUCCEEDED(rv)) - { - PRBool tValue; - params->GetBooleanValue(STATE_ENABLED,&tValue); - if (tValue) - { - pCmdUI->Enable(TRUE); - return; - } - } - pCmdUI->Enable(FALSE); -} - -void CEditorFrame::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - nsresult rv; - nsCOMPtr params; - rv = MakeCommandParams(UNDO_COMMAND,getter_AddRefs(params)); - if (NS_FAILED(rv)) - return; - if (!params) - return; - rv = GetCommandState(UNDO_COMMAND, params); - if (NS_SUCCEEDED(rv)) - { - PRBool tValue; - params->GetBooleanValue(STATE_ENABLED,&tValue); - if (tValue) - { - pCmdUI->Enable(TRUE); - return; - } - } - pCmdUI->Enable(FALSE); -} - -void CEditorFrame::GetEditor(nsIEditor** editor) -{ - mEditingSession->GetEditorForWindow(mDOMWindow, editor); -} - -void CEditorFrame::GetHTMLEditor(nsIHTMLEditor** htmlEditor) -{ - *htmlEditor = 0; - - nsCOMPtr editor; - GetEditor(getter_AddRefs(editor)); - if (!editor) - { - return; - } - - editor->QueryInterface(NS_GET_IID(nsIHTMLEditor), (void**)htmlEditor); -} - -BOOL CEditorFrame::InLink() -{ - nsCOMPtr htmlEditor; - - GetHTMLEditor(getter_AddRefs(htmlEditor)); - - if (htmlEditor) - { - nsCOMPtr domElememt; - htmlEditor->GetElementOrParentByTagName(nsEmbedString(L"href"), - nsnull, - getter_AddRefs(domElememt)); - return domElememt ? TRUE : FALSE; - } - - return false; -} diff --git a/mozilla/embedding/tests/mfcembed/EditorFrm.h b/mozilla/embedding/tests/mfcembed/EditorFrm.h deleted file mode 100644 index af39f8f1e13..00000000000 --- a/mozilla/embedding/tests/mfcembed/EditorFrm.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- 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): - * Mike Judge - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _EDITORFRM_H_ -#define _EDITORFRM_H_ - -class nsICommandParams; -class nsIEditor; -class nsIHTMLEditor; - -#include "nsIEditingSession.h" -#include "nsICommandManager.h" - -class CEditorFrame : public CBrowserFrame -{ -public: - CEditorFrame(PRUint32 chromeMask); - virtual ~CEditorFrame(); - -protected: - DECLARE_DYNAMIC(CEditorFrame) - -public: - BOOL InitEditor(); - NS_METHOD MakeEditable(); - NS_METHOD DoCommand(const char *aCommand, nsICommandParams *aCommandParams); - NS_METHOD IsCommandEnabled(const char *aCommand, PRBool *retval); - NS_METHOD GetCommandState(const char *aCommand, nsICommandParams *aCommandParams); - - void GetEditor(nsIEditor** editor); - void GetHTMLEditor(nsIHTMLEditor** htmlEditor); - BOOL InLink(); - void ShowInsertLinkDlg(); - void ShowEditLinkDlg(); - BOOL GetCurrentLinkInfo(CString& strLinkText, CString& strLinkLocation, nsIDOMHTMLAnchorElement** anchorElement); - void InsertLink(CString& linkText, CString& linkLocation); - void InsertHTML(CString& str); - -// Generated message map functions -protected: - //{{AFX_MSG(CEditorFrame) - afx_msg void OnBold(); - afx_msg void OnUpdateBold(CCmdUI* pCmdUI); - afx_msg void OnItalics(); - afx_msg void OnUpdateItalics(CCmdUI* pCmdUI); - afx_msg void OnUnderline(); - afx_msg void OnUpdateUnderline(CCmdUI* pCmdUI); - afx_msg void OnIndent(); - afx_msg void OnUpdateIndent(CCmdUI* pCmdUI); - afx_msg void OnOutdent(); - afx_msg void OnUpdateOutdent(CCmdUI* pCmdUI); - afx_msg void OnFontred(); - afx_msg void OnUpdateFontred(CCmdUI* pCmdUI); - afx_msg void OnFontblack(); - afx_msg void OnUpdateFontblack(CCmdUI* pCmdUI); - afx_msg void OnBgcolor(); - afx_msg void OnUpdateBgcolor(CCmdUI* pCmdUI); - afx_msg void OnNobgcolor(); - afx_msg void OnUpdateNobgcolor(CCmdUI* pCmdUI); - afx_msg void OnFontsizeincrease(); - afx_msg void OnFontsizedecrease(); - afx_msg void OnArial(); - afx_msg void OnTimes(); - afx_msg void OnCourier(); - afx_msg void OnAlignleft(); - afx_msg void OnUpdateAlignleft(CCmdUI* pCmdUI); - afx_msg void OnAlignright(); - afx_msg void OnUpdateAlignright(CCmdUI* pCmdUI); - afx_msg void OnAligncenter(); - afx_msg void OnUpdateAligncenter(CCmdUI* pCmdUI); - afx_msg void OnInsertlink(); - afx_msg void OnEditUndo(); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - -private: - NS_METHOD ExecuteStyleCommand(const char *aCommand); - NS_METHOD ExecuteNoParam(const char *aCommand); - NS_METHOD MakeCommandParams(const char *aCommand,nsICommandParams **aParams); - NS_METHOD ExecuteAttribParam(const char *aCommand, const char *aAttribute); - NS_METHOD GetAttributeParamValue(const char *aCommand, nsEmbedCString &aValue); - - void UpdateStyleToolBarBtn(const char *aCommand, CCmdUI* pCmdUI); - -private: - nsCOMPtr mCommandManager; - nsCOMPtr mDOMWindow; - nsCOMPtr mEditingSession; -}; - -#endif //_EDITORFRM_H_ diff --git a/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h b/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h deleted file mode 100644 index 6de25d80c05..00000000000 --- a/mozilla/embedding/tests/mfcembed/IBrowserFrameGlue.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// This interface acts as a glue between the required/optional -// Gecko embedding interfaces and the actual platform specific -// way of doing things - such as updating a statusbar etc. -// -// For ex, in the mfcembed sample the required interfaces such as -// IWebBrowserChrome etc. are implemented in a XP way in the -// BrowserImp*.cpp files. However, when they get called to update the -// statusbar etc. they call on this interface to get the actual job -// done. During the BrowserFrame creation some object must implement -// this interface and pass the pointer to it via the Init() member of -// the CBrowserImpl class - -#ifndef _IBROWSERFRAMEGLUE_H -#define _IBROWSERFRAMEGLUE_H - -struct IBrowserFrameGlue { - // Progress Related Methods - virtual void UpdateStatusBarText(const PRUnichar *aMessage) = 0; - virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax) = 0; - virtual void UpdateBusyState(PRBool aBusy) = 0; - virtual void UpdateCurrentURI(nsIURI *aLocation) = 0; - virtual void UpdateSecurityStatus(PRInt32 aState) = 0; - - // BrowserFrame Related Methods - virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - nsIWebBrowser ** aWebBrowser) = 0; - virtual void DestroyBrowserFrame() = 0; - virtual void GetBrowserFrameTitle(PRUnichar **aTitle) = 0; - virtual void SetBrowserFrameTitle(const PRUnichar *aTitle) = 0; - virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY) = 0; - virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY) = 0; - virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY) = 0; - virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY) = 0; - virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) = 0; - virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint) = 0; - virtual void ShowBrowserFrame(PRBool aShow) = 0; - virtual void SetFocus() = 0; - virtual void FocusAvailable(PRBool *aFocusAvail) = 0; - virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0; - - // ContextMenu Related Methods - virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) = 0; - - // Tooltip methods - virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) = 0; - virtual void HideTooltip() = 0; - - virtual HWND GetBrowserFrameNativeWnd() = 0; -}; - -#define NS_DECL_BROWSERFRAMEGLUE \ - public: \ - virtual void UpdateStatusBarText(const PRUnichar *aMessage); \ - virtual void UpdateProgress(PRInt32 aCurrent, PRInt32 aMax); \ - virtual void UpdateBusyState(PRBool aBusy); \ - virtual void UpdateCurrentURI(nsIURI *aLocation); \ - virtual void UpdateSecurityStatus(PRInt32 aState); \ - virtual PRBool CreateNewBrowserFrame(PRUint32 chromeMask, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, nsIWebBrowser** aWebBrowser); \ - virtual void DestroyBrowserFrame(); \ - virtual void GetBrowserFrameTitle(PRUnichar **aTitle); \ - virtual void SetBrowserFrameTitle(const PRUnichar *aTitle); \ - virtual void GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY); \ - virtual void SetBrowserFramePosition(PRInt32 aX, PRInt32 aY); \ - virtual void GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY); \ - virtual void SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY); \ - virtual void GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY); \ - virtual void SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint); \ - virtual void ShowBrowserFrame(PRBool aShow); \ - virtual void SetFocus(); \ - virtual void FocusAvailable(PRBool *aFocusAvail); \ - virtual void GetBrowserFrameVisibility(PRBool *aVisible); \ - virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo); \ - virtual void ShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText); \ - virtual void HideTooltip(); \ - virtual HWND GetBrowserFrameNativeWnd(); - -typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE; - -#endif //_IBROWSERFRAMEGLUE_H diff --git a/mozilla/embedding/tests/mfcembed/Makefile.in b/mozilla/embedding/tests/mfcembed/Makefile.in deleted file mode 100644 index b103417a526..00000000000 --- a/mozilla/embedding/tests/mfcembed/Makefile.in +++ /dev/null @@ -1,208 +0,0 @@ -# ***** 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 ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -PROGRAM = mfcembed$(BIN_SUFFIX) -RESFILE = MfcEmbed.res - -MODULE = mfcEmbed -PACKAGE_FILE = mfcembed.pkg - -# comment this out if for some reason you want to link against xpcom -# directly instead of using the standalone glue -ifndef BUILD_STATIC_LIBS -GRE_BUILD = 1 -endif - -ifdef GRE_BUILD -DEFINES += -DXPCOM_GLUE -DMOZILLA_STRICT_API -endif - -REQUIRES = \ - xpcom_obsolete \ - xpcom \ - string \ - necko \ - webbrwsr \ - widget \ - docshell \ - dom \ - uriloader \ - embed_base \ - webshell \ - shistory \ - pref \ - profile \ - profdirserviceprovider \ - find \ - gfx \ - windowwatcher \ - layout \ - webbrowserpersist \ - composer \ - commandhandler \ - imglib2 \ - webbrwsr \ - editor \ - $(NULL) - -ifdef NS_TRACE_MALLOC -REQUIRES += tracemalloc -endif - -ifdef MOZ_PROFILESHARING -REQUIRES += profilesharingsetup -endif - -CPPSRCS = \ - CCustomPromptDialog.cpp \ - CMarginHeaderFooter.cpp \ - CFormatOptionTab.cpp \ - CPageSetupPropSheet.cpp \ - MfcEmbed.cpp \ - BrowserFrm.cpp \ - EditorFrm.cpp \ - BrowserFrameGlue.cpp \ - BrowserView.cpp \ - BrowserImpl.cpp \ - BrowserImplWebPrgrsLstnr.cpp \ - BrowserImplCtxMenuLstnr.cpp \ - BrowserToolTip.cpp \ - Dialogs.cpp \ - ProfileMgr.cpp \ - ProfilesDlg.cpp \ - winEmbedFileLocProvider.cpp \ - MostRecentUrls.cpp \ - Preferences.cpp \ - StdAfx.cpp \ - $(NULL) - -LIBS = \ - $(DEPTH)/profile/dirserviceprovider/standalone/$(LIB_PREFIX)profdirserviceprovidersa_s.$(LIB_SUFFIX) \ - $(NULL) - -ifdef NS_TRACE_MALLOC -LIBS += $(DIST)/lib/$(LIB_PREFIX)tracemalloc.$(LIB_SUFFIX) -endif - -LIBS += \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(NULL) - -ifdef GRE_BUILD -LIBS += \ - $(DEPTH)/embedding/base/standalone/$(LIB_PREFIX)embed_base_standalone.$(LIB_SUFFIX) \ - $(XPCOM_STANDALONE_GLUE_LDOPTS) \ - $(NULL) -else -LIBS += \ - $(DEPTH)/embedding/base/$(LIB_PREFIX)embed_base_s.$(LIB_SUFFIX) \ - $(XPCOM_LIBS) \ - $(NULL) -ifdef BUILD_STATIC_LIBS -LIBS += $(MOZ_JS_LIBS) -endif -endif - -LIBS += $(NSPR_LIBS) - -OS_LIBS += \ - ole32.lib \ - comdlg32.lib \ - shell32.lib \ - version.lib \ - $(NULL) - -LOCAL_INCLUDES = -I$(srcdir)/components - -# -# Control the default heap size. -# This is the heap returned by GetProcessHeap(). -# As we use the CRT heap, the default size is too large and wastes VM. -# -# The default heap size is 1MB on Win32. -# The heap will grow if need be. -# -# Set it to 256k. See bug 127069. -# -LDFLAGS += -HEAP:0x40000 - - -include $(topsrcdir)/config/config.mk - -# Force applications to be built non-statically -# when building the mozcomps meta component -ifneq (,$(filter mozcomps,$(MOZ_META_COMPONENTS))) -BUILD_STATIC_LIBS= -endif - -ifdef BUILD_STATIC_LIBS - -include $(topsrcdir)/config/static-config.mk - -EXTRA_DEPS += $(STATIC_EXTRA_DEPS) -EXTRA_DSO_LIBS += $(STATIC_EXTRA_DSO_LIBS) -ifneq ($(OS_ARCH),WINNT) -EXTRA_LIBS += -L$(DEPTH)/dist/lib/components -endif # !WINNT -EXTRA_LIBS += $(EXTRA_DSO_LIBS) $(STATIC_EXTRA_LIBS) -DEFINES += $(STATIC_DEFINES) -CPPSRCS += $(STATIC_CPPSRCS) - -endif # BUILD_STATIC_LIBS - - -include $(topsrcdir)/config/rules.mk - - -ifdef BUILD_STATIC_LIBS -include $(topsrcdir)/config/static-rules.mk -endif # BUILD_STATIC_LIBS - -# UNICODE -ifdef BUILD_UNICODE_MFCEMBED -CXXFLAGS += -D "_UNICODE" -LDFLAGS += -ENTRY:wWinMainCRTStartup -endif - -CXXFLAGS += -D "_AFXDLL" -D "USE_SINGLE_SIGN_ON" -DMOZILLA_VERSION=\"$(MOZILLA_VERSION)\" -LDFLAGS += -SUBSYSTEM:windows - -libs:: mfcembed.htm - $(INSTALL) $^ $(DIST)/bin - -install:: mfcembed.htm - $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir) - diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp b/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp deleted file mode 100644 index d5e67609b59..00000000000 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.cpp +++ /dev/null @@ -1,922 +0,0 @@ -/* -*- 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): - * Chak Nanga - * Conrad Carlen - * - * ***** END LICENSE BLOCK ***** */ - -// File Overview.... -// -// The typical MFC app, frame creation code + AboutDlg handling -// -// NS_InitEmbedding() is called in InitInstance() -// -// NS_TermEmbedding() is called in ExitInstance() -// ExitInstance() also takes care of cleaning up of -// multiple browser frame windows on app exit -// -// Code to handle the creation of a new browser window - -// Next suggested file to look at : BrowserFrm.cpp - -// Local Includes -#include "stdafx.h" -#include "MfcEmbed.h" -#include "nsXPCOM.h" -#include "nsXPCOMGlue.h" -#include "nsMemory.h" -#include "nsIComponentRegistrar.h" -#include "nsIFactory.h" -#include "nsServiceManagerUtils.h" -#include "BrowserFrm.h" -#include "EditorFrm.h" -#include "winEmbedFileLocProvider.h" -#include "BrowserImpl.h" -#include "nsIWindowWatcher.h" -#include "plstr.h" -#include "Preferences.h" -#include -#include - -#ifdef USE_PROFILES -#include "ProfileMgr.h" -#else -#include "nsProfileDirServiceProvider.h" -#endif - -#ifdef MOZ_PROFILESHARING -#include "nsIProfileSharingSetup.h" -#endif - -#ifdef _BUILD_STATIC_BIN -#include "nsStaticComponent.h" -nsresult PR_CALLBACK -app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count); -#endif - - -#ifdef NS_TRACE_MALLOC -#include "nsTraceMalloc.h" -#endif - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -// this is for overriding the Mozilla default PromptService component -#include "PromptService.h" -#define kComponentsLibname _T("mfcEmbedComponents.dll") -#define NS_PROMPTSERVICE_CID \ - {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}} -static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID); - -// this is for overriding the Mozilla default PrintingPromptService component -#include "PrintingPromptService.h" -#define NS_PRINTINGPROMPTSERVICE_CID \ - {0xe042570c, 0x62de, 0x4bb6, { 0xa6, 0xe0, 0x79, 0x8e, 0x3c, 0x7, 0xb4, 0xdf}} -static NS_DEFINE_CID(kPrintingPromptServiceCID, NS_PRINTINGPROMPTSERVICE_CID); - -// this is for overriding the Mozilla default HelperAppLauncherDialog -#include "HelperAppService.h" -#define NS_HELPERAPPLAUNCHERDIALOG_CID \ - {0xf68578eb, 0x6ec2, 0x4169, {0xae, 0x19, 0x8c, 0x62, 0x43, 0xf0, 0xab, 0xe1}} -static NS_DEFINE_CID(kHelperAppLauncherDialogCID, NS_HELPERAPPLAUNCHERDIALOG_CID); - -class CMfcEmbedCommandLine : public CCommandLineInfo -{ -public: - - CMfcEmbedCommandLine(CMfcEmbedApp& app) : CCommandLineInfo(), - mApp(app) - { - } - - // generic parser which bundles up flags and their parameters, to - // pass to HandleFlag() or HandleNakedParameter() - // if you're adding new parameters, please don't touch this - // function and instead add your own handler below - virtual void ParseParam(LPCTSTR szParam, BOOL bFlag, BOOL bLast) - { - CCommandLineInfo::ParseParam(szParam, bFlag, bLast); - if (bFlag) { - // advance past extra stuff like --foo - while (*szParam && *szParam == '-') - szParam++; - - // previous argument was a flag too, so process that first - if (mLastFlag.Length() != 0) - HandleFlag(mLastFlag); - - mLastFlag = szParam; - - // oops, no more arguments coming, so handle this now - if (bLast) - HandleFlag(mLastFlag); - - } else { - if (mLastFlag.Length() != 0) - HandleFlag(mLastFlag, szParam); - - mLastFlag.Cut(0, PR_UINT32_MAX); - } - } - - // handle flag-based parameters -#ifdef _UNICODE - void HandleFlag(const nsAString& flag, const TCHAR * param = nsnull) -#else - void HandleFlag(const nsACString& flag, const TCHAR * param = nsnull) -#endif - { - if (_tcscmp(flag.BeginReading(), _T("console")) == 0) - DoConsole(); - else if (_tcscmp(flag.BeginReading(), _T("chrome")) == 0) - DoChrome(); -#ifdef NS_TRACE_MALLOC - else if (_tcscmp(flag.BeginReading(), _T("trace-malloc")) == 0) - { - USES_CONVERSION; - DoTraceMalloc(flag, T2CA(param)); - } -#endif - // add new flag handlers here (please add a DoFoo() method below!) - } - - void HandleNakedParameter(const char* flag) { - // handle non-flag arguments here - } - - // add your specific handlers here - void DoConsole() { - mApp.ShowDebugConsole(); - } - - void DoChrome() { - mApp.m_bChrome = TRUE; - } - -#ifdef NS_TRACE_MALLOC - void DoTraceMalloc(const nsACString& flag, const char* param) - { - if (!param) { - NS_WARNING("--trace-malloc needs a filename as a parameter"); - return; - } - - // build up fake argv/argc arguments for tracemalloc stuff - char* argv[] = { "mfcembed", "--trace-malloc", - NS_CONST_CAST(char*, param) }; - - NS_TraceMallocStartupArgs(3, argv); - } -#endif - -private: - // autostring is fine, this is a stack based object anyway -#ifdef _UNICODE - nsEmbedString mLastFlag; -#else - nsEmbedCString mLastFlag; -#endif - - CMfcEmbedApp& mApp; -}; - - -BEGIN_MESSAGE_MAP(CMfcEmbedApp, CWinApp) - //{{AFX_MSG_MAP(CMfcEmbedApp) - ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser) - ON_COMMAND(ID_NEW_EDITORWINDOW, OnNewEditor) -#ifdef USE_PROFILES - ON_COMMAND(ID_MANAGE_PROFILES, OnManageProfiles) -#endif - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_EDIT_PREFERENCES, OnEditPreferences) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -CMfcEmbedApp::CMfcEmbedApp() -{ - mRefCnt = 1; // Start at one - nothing is going to addref this object - -#ifdef USE_PROFILES - m_ProfileMgr = NULL; -#endif - - m_strHomePage = ""; - - m_iStartupPage = 0; - - m_bChrome = FALSE; -} - -CMfcEmbedApp theApp; - -/* Some Gecko interfaces are implemented as components, automatically - registered at application initialization. nsIPrompt is an example: - the default implementation uses XUL, not native windows. Embedding - apps can override the default implementation by implementing the - nsIPromptService interface and registering a factory for it with - the same CID and Contract ID as the default's. - - Note that this example implements the service in a separate DLL, - replacing the default if the override DLL is present. This could - also have been done in the same module, without a separate DLL. - See the PowerPlant example for, well, an example. -*/ -nsresult CMfcEmbedApp::OverrideComponents() -{ - nsCOMPtr compReg; - nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(compReg)); - NS_ENSURE_SUCCESS(rv, rv); - - // replace Mozilla's default PromptService with our own, if the - // expected override DLL is present - HMODULE overlib = ::LoadLibrary(kComponentsLibname); - if (overlib) { - InitPromptServiceType InitLib; - MakeFactoryType MakeFactory; - InitLib = reinterpret_cast(::GetProcAddress(overlib, kPromptServiceInitFuncName)); - MakeFactory = reinterpret_cast(::GetProcAddress(overlib, kPromptServiceFactoryFuncName)); - - if (InitLib && MakeFactory) { - InitLib(overlib); - - nsCOMPtr promptFactory; - rv = MakeFactory(getter_AddRefs(promptFactory)); - if (NS_SUCCEEDED(rv)) { - compReg->RegisterFactory(kPromptServiceCID, - "Prompt Service", - "@mozilla.org/embedcomp/prompt-service;1", - promptFactory); - } - } else - ::FreeLibrary(overlib); - } - - // Replace Mozilla's helper app launcher dialog with our own - overlib = ::LoadLibrary(kComponentsLibname); - if (overlib) { - InitHelperAppDlgType InitLib; - MakeFactoryType MakeFactory; - InitLib = reinterpret_cast(::GetProcAddress(overlib, kHelperAppDlgInitFuncName)); - MakeFactory = reinterpret_cast(::GetProcAddress(overlib, kHelperAppDlgFactoryFuncName)); - - if (InitLib && MakeFactory) { - InitLib(overlib); - - nsCOMPtr helperAppDlgFactory; - rv = MakeFactory(getter_AddRefs(helperAppDlgFactory)); - if (NS_SUCCEEDED(rv)) - compReg->RegisterFactory(kHelperAppLauncherDialogCID, - "Helper App Launcher Dialog", - "@mozilla.org/helperapplauncherdialog;1", - helperAppDlgFactory); - } else - ::FreeLibrary(overlib); - } - - // replace Mozilla's default PrintingPromptService with our own, if the - // expected override DLL is present - overlib = ::LoadLibrary(kComponentsLibname); - if (overlib) { - InitPrintingPromptServiceType InitLib; - MakeFactoryType MakeFactory; - InitLib = reinterpret_cast(::GetProcAddress(overlib, kPrintingPromptServiceInitFuncName)); - MakeFactory = reinterpret_cast(::GetProcAddress(overlib, kPrintingPromptServiceFactoryFuncName)); - - if (InitLib && MakeFactory) { - InitLib(overlib); - - nsCOMPtr printingPromptFactory; - rv = MakeFactory(getter_AddRefs(printingPromptFactory)); - if (NS_SUCCEEDED(rv)) - compReg->RegisterFactory(kPrintingPromptServiceCID, - "Printing Prompt Service", - "@mozilla.org/embedcomp/printingprompt-service;1", - printingPromptFactory); - } else - ::FreeLibrary(overlib); - } - return rv; -} - -void CMfcEmbedApp::ShowDebugConsole() -{ -#ifdef _DEBUG - // Show console only in debug mode - - if(! AllocConsole()) - return; - - // Redirect stdout to the console - int hCrtOut = _open_osfhandle( - (long) GetStdHandle(STD_OUTPUT_HANDLE), - _O_TEXT); - if(hCrtOut == -1) - return; - - FILE *hfOut = _fdopen(hCrtOut, "w"); - if(hfOut != NULL) - { - // Setup for unbuffered I/O so the console - // output shows up right away - *stdout = *hfOut; - setvbuf(stdout, NULL, _IONBF, 0); - } - - // Redirect stderr to the console - int hCrtErr = _open_osfhandle( - (long) GetStdHandle(STD_ERROR_HANDLE), - _O_TEXT); - if(hCrtErr == -1) - return; - - FILE *hfErr = _fdopen(hCrtErr, "w"); - if(hfErr != NULL) - { - // Setup for unbuffered I/O so the console - // output shows up right away - *stderr = *hfErr; - setvbuf(stderr, NULL, _IONBF, 0); - } -#endif -} - - -// Initialize our MFC application and also init -// the Gecko embedding APIs -// Note that we're also init'ng the profile switching -// code here -// Then, create a new BrowserFrame and load our -// default homepage -// -BOOL CMfcEmbedApp::InitInstance() -{ -#ifdef _BUILD_STATIC_BIN - // Initialize XPCOM's module info table - NSGetStaticModuleInfo = app_getModuleInfo; -#endif - -#ifdef XPCOM_GLUE - if (NS_FAILED(XPCOMGlueStartup(GRE_GetXPCOMPath()))) { - MessageBox(NULL, "Could not initialize XPCOM. Perhaps the GRE\nis not installed or could not be found?", "MFCEmbed", MB_OK | MB_ICONERROR); - return FALSE; - } -#endif - - CMfcEmbedCommandLine cmdLine(*this); - ParseCommandLine(cmdLine); - - Enable3dControls(); - - // - // 1. Determine the name of the dir from which the GRE based app is being run - // from [It's OK to do this even if you're not running in an GRE env] - // - // 2. Create an nsILocalFile out of it which will passed in to NS_InitEmbedding() - // - // Please see http://www.mozilla.org/projects/embedding/GRE.html - // for more info. on GRE - - TCHAR path[_MAX_PATH+1]; - ::GetModuleFileName(0, path, _MAX_PATH); - TCHAR* lastSlash = _tcsrchr(path, _T('\\')); - if (!lastSlash) { - NS_ERROR("No slash in module file name... something is wrong."); - return FALSE; - } - *lastSlash = _T('\0'); - - USES_CONVERSION; - nsresult rv; - nsCOMPtr mreAppDir; - rv = NS_NewNativeLocalFile(nsEmbedCString(T2A(path)), TRUE, getter_AddRefs(mreAppDir)); - NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create mreAppDir localfile"); - - // Take a look at - // http://www.mozilla.org/projects/xpcom/file_locations.html - // for more info on File Locations - - CString strRes; - strRes.LoadString(IDS_PROFILES_FOLDER_NAME); - winEmbedFileLocProvider *provider = new winEmbedFileLocProvider(nsEmbedCString(strRes)); - if(!provider) - { - ASSERT(FALSE); - return FALSE; - } - - rv = NS_InitEmbedding(mreAppDir, provider); - if(NS_FAILED(rv)) - { - ASSERT(FALSE); - return FALSE; - } - - rv = OverrideComponents(); - if(NS_FAILED(rv)) - { - ASSERT(FALSE); - return FALSE; - } - - - rv = InitializeWindowCreator(); - if (NS_FAILED(rv)) - { - ASSERT(FALSE); - return FALSE; - } - - if(!InitializeProfiles()) - { - ASSERT(FALSE); - NS_TermEmbedding(); - return FALSE; - } - - - if(!CreateHiddenWindow()) - { - ASSERT(FALSE); - NS_TermEmbedding(); - return FALSE; - } - - // Create the first browser frame window - OnNewBrowser(); - - return TRUE; -} - -CBrowserFrame* CMfcEmbedApp::CreateNewBrowserFrame(PRUint32 chromeMask, - PRInt32 x, PRInt32 y, - PRInt32 cx, PRInt32 cy, - PRBool bShowWindow, - PRBool bIsEditor - ) -{ - UINT resId = bIsEditor ? IDR_EDITOR : IDR_MAINFRAME; - - // Setup a CRect with the requested window dimensions - CRect winSize(x, y, cx, cy); - - // Use the Windows default if all are specified as -1 - if(x == -1 && y == -1 && cx == -1 && cy == -1) - winSize = CFrameWnd::rectDefault; - - // Load the window title from the string resource table - CString strTitle; - strTitle.LoadString(IDR_MAINFRAME); - - // Now, create the browser frame - CBrowserFrame* pFrame = bIsEditor ? ( new CEditorFrame(chromeMask) ) : - ( new CBrowserFrame(chromeMask) ); - pFrame->SetEditable(bIsEditor); - - if (!pFrame->Create(NULL, strTitle, WS_OVERLAPPEDWINDOW, - winSize, NULL, MAKEINTRESOURCE(resId), 0L, NULL)) - { - return NULL; - } - - // load accelerator resource - pFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MAINFRAME)); - - // Show the window... - if(bShowWindow) - { - pFrame->ShowWindow(SW_SHOW); - pFrame->UpdateWindow(); - } - - // Add to the list of BrowserFrame windows - m_FrameWndLst.AddHead(pFrame); - - return pFrame; -} - -void CMfcEmbedApp::OnNewBrowser() -{ - CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(); - - //Load the HomePage into the browser view - if(pBrowserFrame && (GetStartupPageMode() == 1)) - pBrowserFrame->m_wndBrowserView.LoadHomePage(); -} - -void CMfcEmbedApp::OnNewEditor() -{ - CEditorFrame *pEditorFrame = (CEditorFrame *)CreateNewBrowserFrame(nsIWebBrowserChrome::CHROME_ALL, - -1, -1, -1, -1, - PR_TRUE,PR_TRUE); - if (pEditorFrame) - { - pEditorFrame->InitEditor(); - pEditorFrame->m_wndBrowserView.OpenURL("about:blank"); - } -} - -// This gets called anytime a BrowserFrameWindow is -// closed i.e. by choosing the "close" menu item from -// a window's system menu or by dbl clicking on the -// system menu box -// -// Sends a WM_QUIT to the hidden window which results -// in ExitInstance() being called and the app is -// properly cleaned up and shutdown -// -void CMfcEmbedApp::RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame/*= TRUE*/) -{ - POSITION pos = m_FrameWndLst.Find(pFrm); - m_FrameWndLst.RemoveAt(pos); - - // Send a WM_QUIT msg. to the hidden window if we've - // just closed the last browserframe window and - // if the bCloseAppOnLastFrame is TRUE. This be FALSE - // only in the case we're switching profiles - // Without this the hidden window will stick around - // i.e. the app will never die even after all the - // visible windows are gone. - if(m_FrameWndLst.GetCount() == 0 && bCloseAppOnLastFrame) - m_pMainWnd->PostMessage(WM_QUIT); -} - -int CMfcEmbedApp::ExitInstance() -{ - // When File/Exit is chosen and if the user - // has opened multiple browser windows shut all - // of them down properly before exiting the app - - CBrowserFrame* pBrowserFrame = NULL; - - POSITION pos = m_FrameWndLst.GetHeadPosition(); - while( pos != NULL ) - { - pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); - if(pBrowserFrame) - { - pBrowserFrame->ShowWindow(false); - pBrowserFrame->DestroyWindow(); - } - } - m_FrameWndLst.RemoveAll(); - - if (m_pMainWnd) - m_pMainWnd->DestroyWindow(); - -#ifdef USE_PROFILES - delete m_ProfileMgr; -#else - if (m_ProfileDirServiceProvider) - { - m_ProfileDirServiceProvider->Shutdown(); - NS_RELEASE(m_ProfileDirServiceProvider); - } -#endif - - NS_TermEmbedding(); - -#ifdef XPCOM_GLUE - XPCOMGlueShutdown(); -#endif - - return 1; -} - -BOOL CMfcEmbedApp::OnIdle(LONG lCount) -{ - CWinApp::OnIdle(lCount); - - return FALSE; -} - -void CMfcEmbedApp::OnManageProfiles() -{ -#ifdef USE_PROFILES - m_ProfileMgr->DoManageProfilesDialog(PR_FALSE); -#endif -} - -void CMfcEmbedApp::OnEditPreferences() -{ - CPreferences prefs(_T("Preferences")); - - prefs.m_startupPage.m_iStartupPage = m_iStartupPage; - prefs.m_startupPage.m_strHomePage = m_strHomePage; - - if(prefs.DoModal() == IDOK) - { - // Update our member vars with these new pref values - m_iStartupPage = prefs.m_startupPage.m_iStartupPage; - m_strHomePage = prefs.m_startupPage.m_strHomePage; - - // Save these changes to disk now - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) - { - USES_CONVERSION; - prefs->SetIntPref("browser.startup.page", m_iStartupPage); - rv = prefs->SetCharPref("browser.startup.homepage", T2CA(m_strHomePage)); - if (NS_SUCCEEDED(rv)) - rv = prefs->SavePrefFile(nsnull); - } - else - NS_ASSERTION(PR_FALSE, "Could not get preferences service"); - } -} - -BOOL CMfcEmbedApp::InitializeProfiles() -{ - -#ifdef MOZ_PROFILESHARING - // If we are using profile sharing, get the sharing setup service - nsCOMPtr sharingSetup = - do_GetService("@mozilla.org/embedcomp/profile-sharing-setup;1"); - if (sharingSetup) - { - USES_CONVERSION; - CString strRes; - strRes.LoadString(IDS_PROFILES_NONSHARED_NAME); - nsEmbedString nonSharedName(T2W(strRes)); - sharingSetup->EnableSharing(nonSharedName); - } -#endif - - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1"); - if (!observerService) - return FALSE; - - // Both the profile mgr and standalone nsProfileDirServiceProvider - // send this notification. - observerService->AddObserver(this, "profile-after-change", PR_TRUE); - -#ifdef USE_PROFILES - m_ProfileMgr = new CProfileMgr; - if (!m_ProfileMgr) - return FALSE; - - observerService->AddObserver(this, "profile-approve-change", PR_TRUE); - observerService->AddObserver(this, "profile-change-teardown", PR_TRUE); - - m_ProfileMgr->StartUp(); -#else - nsresult rv; - nsCOMPtr appDataDir; - NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, - getter_AddRefs(appDataDir)); - if (!appDataDir) - return FALSE; - nsCOMPtr profProvider; - NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(profProvider)); - if (!profProvider) - return FALSE; - profProvider->Register(); - nsCOMPtr localAppDataDir(do_QueryInterface(appDataDir)); - rv = profProvider->SetProfileDir(localAppDataDir); - if (NS_FAILED(rv)) - return FALSE; - NS_ADDREF(m_ProfileDirServiceProvider = profProvider); -#endif - - return TRUE; -} - -// When the profile switch happens, all open browser windows need to be -// closed. -// In order for that not to kill off the app, we just make the MFC app's -// mainframe be an invisible window which doesn't get closed on profile -// switches -BOOL CMfcEmbedApp::CreateHiddenWindow() -{ - CFrameWnd *hiddenWnd = new CFrameWnd; - if(!hiddenWnd) - return FALSE; - - RECT bounds = { -10010, -10010, -10000, -10000 }; - hiddenWnd->Create(NULL, _T("main"), WS_DISABLED, bounds, NULL, NULL, 0, NULL); - m_pMainWnd = hiddenWnd; - - return TRUE; -} - -nsresult CMfcEmbedApp::InitializePrefs() -{ - nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) { - - // We are using the default prefs from mozilla. If you were - // disributing your own, this would be done simply by editing - // the default pref files. - - PRBool inited; - rv = prefs->GetBoolPref("mfcbrowser.prefs_inited", &inited); - if (NS_FAILED(rv) || !inited) - { - USES_CONVERSION; - m_iStartupPage = 1; - m_strHomePage = "http://www.mozilla.org/projects/embedding"; - - prefs->SetIntPref("browser.startup.page", m_iStartupPage); - prefs->SetCharPref("browser.startup.homepage", T2CA(m_strHomePage)); - prefs->SetIntPref("font.size.variable.x-western", 16); - prefs->SetIntPref("font.size.fixed.x-western", 13); - rv = prefs->SetBoolPref("mfcbrowser.prefs_inited", PR_TRUE); - if (NS_SUCCEEDED(rv)) - rv = prefs->SavePrefFile(nsnull); - } - else - { - // The prefs are present, read them in - - prefs->GetIntPref("browser.startup.page", &m_iStartupPage); - - char* str = nsnull; - prefs->GetCharPref("browser.startup.homepage", &str); - if (str) - { - USES_CONVERSION; - m_strHomePage = A2CT(str); - } - else - { - m_strHomePage.Empty(); - } - nsMemory::Free(str); - } - } - else - NS_ASSERTION(PR_FALSE, "Could not get preferences service"); - - return rv; -} - - -/* InitializeWindowCreator creates and hands off an object with a callback - to a window creation function. This will be used by Gecko C++ code - (never JS) to create new windows when no previous window is handy - to begin with. This is done in a few exceptional cases, like PSM code. - Failure to set this callback will only disable the ability to create - new windows under these circumstances. */ -nsresult CMfcEmbedApp::InitializeWindowCreator() -{ - // give an nsIWindowCreator to the WindowWatcher service - nsCOMPtr windowCreator(NS_STATIC_CAST(nsIWindowCreator *, this)); - if (windowCreator) { - nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); - if (wwatch) { - wwatch->SetWindowCreator(windowCreator); - return NS_OK; - } - } - return NS_ERROR_FAILURE; -} - -// --------------------------------------------------------------------------- -// CMfcEmbedApp : nsISupports -// --------------------------------------------------------------------------- - -NS_IMPL_ISUPPORTS3(CMfcEmbedApp, nsIObserver, nsIWindowCreator, nsISupportsWeakReference) - -// --------------------------------------------------------------------------- -// CMfcEmbedApp : nsIObserver -// --------------------------------------------------------------------------- - -// Mainly needed to support "on the fly" profile switching - -NS_IMETHODIMP CMfcEmbedApp::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) -{ - nsresult rv = NS_OK; - - if (strcmp(aTopic, "profile-approve-change") == 0) - { - // Ask the user if they want to - int result = MessageBox(NULL, - _T("Do you want to close all windows in order to switch the profile?"), - _T("Confirm"), MB_YESNO | MB_ICONQUESTION); - if (result != IDYES) - { - nsCOMPtr status = do_QueryInterface(aSubject); - NS_ENSURE_TRUE(status, NS_ERROR_FAILURE); - status->VetoChange(); - } - } - else if (strcmp(aTopic, "profile-change-teardown") == 0) - { - // Close all open windows. Alternatively, we could just call CBrowserWindow::Stop() - // on each. Either way, we have to stop all network activity on this phase. - - POSITION pos = m_FrameWndLst.GetHeadPosition(); - while( pos != NULL ) - { - CBrowserFrame *pBrowserFrame = (CBrowserFrame *) m_FrameWndLst.GetNext(pos); - if(pBrowserFrame) - { - pBrowserFrame->ShowWindow(false); - - // Passing in FALSE below so that we do not - // kill the main app during a profile switch - RemoveFrameFromList(pBrowserFrame, FALSE); - - pBrowserFrame->DestroyWindow(); - } - } - } - else if (strcmp(aTopic, "profile-after-change") == 0) - { - InitializePrefs(); // In case we have just switched to a newly created profile. - - // Only make a new browser window on a switch. This also gets - // called at start up and we already make a window then. - if (!wcscmp(someData, L"switch")) - OnNewBrowser(); - } - return rv; -} - -// --------------------------------------------------------------------------- -// CMfcEmbedApp : nsIWindowCreator -// --------------------------------------------------------------------------- -NS_IMETHODIMP CMfcEmbedApp::CreateChromeWindow(nsIWebBrowserChrome *parent, - PRUint32 chromeFlags, - nsIWebBrowserChrome **_retval) -{ - // XXX we're ignoring the "parent" parameter - NS_ENSURE_ARG_POINTER(_retval); - *_retval = 0; - - CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(chromeFlags); - if(pBrowserFrame) { - *_retval = NS_STATIC_CAST(nsIWebBrowserChrome *, pBrowserFrame->GetBrowserImpl()); - NS_ADDREF(*_retval); - } - return NS_OK; -} - -// AboutDlg Stuff - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - - enum { IDD = IDD_ABOUTBOX }; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - -protected: - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) -END_MESSAGE_MAP() - -// Show the AboutDlg -void CMfcEmbedApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.h b/mozilla/embedding/tests/mfcembed/MfcEmbed.h deleted file mode 100644 index bc773ef5dfd..00000000000 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// mozembed.h : main header file for the MOZEMBED application -// - -#ifndef _MFCEMBED_H -#define _MFCEMBED_H - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CMfcEmbedApp: -// See mozembed.cpp for the implementation of this class -// - -class CBrowserFrame; -class CProfileMgr; -class nsProfileDirServiceProvider; - -class CMfcEmbedApp : public CWinApp, - public nsIObserver, - public nsIWindowCreator, - public nsSupportsWeakReference -{ -public: - CMfcEmbedApp(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - NS_DECL_NSIWINDOWCREATOR - - CBrowserFrame* CreateNewBrowserFrame(PRUint32 chromeMask = nsIWebBrowserChrome::CHROME_ALL, - PRInt32 x = -1, PRInt32 y = -1, - PRInt32 cx = -1, PRInt32 cy = -1, PRBool bShowWindow = PR_TRUE, - PRBool bIsEditor=PR_FALSE); - void RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame = TRUE); - - void ShowDebugConsole(); - nsresult OverrideComponents(); - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMfcEmbedApp) - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - virtual BOOL OnIdle(LONG lCount); - //}}AFX_VIRTUAL - - CObList m_FrameWndLst; - - BOOL m_bChrome; - CString m_strHomePage; - inline BOOL GetHomePage(CString& strHomePage) { - strHomePage = m_strHomePage; - return TRUE; - } - - int m_iStartupPage; //0 = BlankPage, 1 = HomePage - inline int GetStartupPageMode() { - return m_iStartupPage; - } - -// Implementation - -public: - //{{AFX_MSG(CMfcEmbedApp) - afx_msg void OnAppAbout(); - afx_msg void OnNewBrowser(); - afx_msg void OnNewEditor(); - afx_msg void OnManageProfiles(); - afx_msg void OnEditPreferences(); - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - BOOL InitializeProfiles(); - BOOL CreateHiddenWindow(); - nsresult InitializePrefs(); - nsresult InitializeWindowCreator(); - -private: - -#ifdef USE_PROFILES - CProfileMgr *m_ProfileMgr; -#else - nsProfileDirServiceProvider *m_ProfileDirServiceProvider; -#endif -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // _MFCEMBED_H diff --git a/mozilla/embedding/tests/mfcembed/MfcEmbed.rc b/mozilla/embedding/tests/mfcembed/MfcEmbed.rc deleted file mode 100644 index 442e87a9c19..00000000000 --- a/mozilla/embedding/tests/mfcembed/MfcEmbed.rc +++ /dev/null @@ -1,786 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\mfcembed.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\mfcembed.ico" -IDR_SECURITY_LOCK ICON DISCARDABLE "res\\ssecur.ico" -IDR_SECURITY_UNLOCK ICON DISCARDABLE "res\\sinsecur.ico" -IDR_SECURITY_BROKEN ICON DISCARDABLE "res\\broken.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp" -IDR_EDITOR BITMAP MOVEABLE PURE "res\\mainfram.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_MAINFRAME TOOLBAR DISCARDABLE 20, 18 -BEGIN - BUTTON ID_NAV_BACK - BUTTON ID_NAV_FORWARD - SEPARATOR - BUTTON ID_NAV_RELOAD - BUTTON ID_NAV_STOP - SEPARATOR - BUTTON ID_NAV_HOME - SEPARATOR - BUTTON ID_APP_ABOUT -END - -IDR_EDITOR TOOLBAR DISCARDABLE 20, 18 -BEGIN - BUTTON ID_BOLD - BUTTON ID_ITALICS - BUTTON ID_UNDERLINE - SEPARATOR - BUTTON ID_INDENT - BUTTON ID_OUTDENT - SEPARATOR - BUTTON ID_FONTBLACK - BUTTON ID_FONTRED - BUTTON ID_BGCOLOR - BUTTON ID_NOBGCOLOR - SEPARATOR - BUTTON ID_FONTSIZEINCREASE - BUTTON ID_FONTSIZEDECREASE - SEPARATOR - BUTTON ID_ALIGNLEFT - BUTTON ID_ALIGNCENTER - BUTTON ID_ALIGNRIGHT - SEPARATOR - BUTTON ID_INSERTLINK -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINFRAME MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New Browser Window\tCtrl+N", ID_NEW_BROWSER - MENUITEM "New &Editor Window", ID_NEW_EDITORWINDOW - MENUITEM SEPARATOR - MENUITEM "&Open File...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save Page As...\tCtrl+S", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "Page Set&up...", ID_FILE_PRINTSETUP - MENUITEM "&Print...\tCtrl-P", ID_FILE_PRINT - MENUITEM "Print Pre&view", ID_FILE_PRINTPREVIEW - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM "Select &None", ID_EDIT_SELECT_NONE - MENUITEM SEPARATOR - MENUITEM "&Find in This Page...\tCtrl+F", ID_EDIT_FIND - MENUITEM SEPARATOR - MENUITEM "Profiles...", ID_MANAGE_PROFILES - MENUITEM SEPARATOR - MENUITEM "Preferences...", ID_EDIT_PREFERENCES - END - POPUP "&View" - BEGIN - MENUITEM "Page S&ource", ID_VIEW_SOURCE - MENUITEM "Page &Info", ID_VIEW_INFO - MENUITEM SEPARATOR - MENUITEM "&Toolbar", ID_VIEW_TOOLBAR - MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR - END - POPUP "&Go" - BEGIN - MENUITEM "&Back", ID_NAV_BACK - MENUITEM "&Forward", ID_NAV_FORWARD - MENUITEM "&Home", ID_NAV_HOME - END - POPUP "&Help" - BEGIN - MENUITEM "&About MfcEmbed...", ID_APP_ABOUT - END -END - -IDR_CTXMENU_DOCUMENT MENU DISCARDABLE -BEGIN - POPUP "Document Context Menu" - BEGIN - MENUITEM "&Back", ID_NAV_BACK - MENUITEM "&Forward", ID_NAV_FORWARD - MENUITEM "&Reload", ID_NAV_RELOAD - MENUITEM "&Stop", ID_NAV_STOP - MENUITEM SEPARATOR - MENUITEM "&View Page Source", ID_VIEW_SOURCE - MENUITEM "View Page &Info", ID_VIEW_INFO - MENUITEM "View Background &Image", ID_VIEW_IMAGE - MENUITEM SEPARATOR - MENUITEM "Save &Page As...", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM "Select &None", ID_EDIT_SELECT_NONE - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - END -END - -IDR_CTXMENU_IMAGE MENU DISCARDABLE -BEGIN - POPUP "Image Context Menu" - BEGIN - MENUITEM "&Back", ID_NAV_BACK - MENUITEM "&Forward", ID_NAV_FORWARD - MENUITEM "&Reload", ID_NAV_RELOAD - MENUITEM "&Stop", ID_NAV_STOP - MENUITEM SEPARATOR - MENUITEM "&View Page Source", ID_VIEW_SOURCE - MENUITEM "View &Image", ID_VIEW_IMAGE - MENUITEM SEPARATOR - MENUITEM "Save Image As...", ID_SAVE_IMAGE_AS - MENUITEM "Save &Page As...", ID_FILE_SAVE_AS - END -END - -IDR_CTXMENU_LINK MENU DISCARDABLE -BEGIN - POPUP "Link Context Menu" - BEGIN - MENUITEM "Open Link In New Window", ID_OPEN_LINK_IN_NEW_WINDOW - MENUITEM SEPARATOR - MENUITEM "&Back", ID_NAV_BACK - MENUITEM "&Forward", ID_NAV_FORWARD - MENUITEM "&Reload", ID_NAV_RELOAD - MENUITEM "&Stop", ID_NAV_STOP - MENUITEM SEPARATOR - MENUITEM "&View Page Source", ID_VIEW_SOURCE - MENUITEM SEPARATOR - MENUITEM "View &Image", ID_VIEW_IMAGE - MENUITEM SEPARATOR - MENUITEM "Save &Page As...", ID_FILE_SAVE_AS - MENUITEM "Save &Link As...", ID_SAVE_LINK_AS - MENUITEM "&Copy Link Location", ID_COPY_LINK_LOCATION - END -END - -IDR_CTXMENU_TEXT MENU DISCARDABLE -BEGIN - POPUP "Selection Context Menu" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - END -END - -IDR_CTXMENU_EDITOR MENU DISCARDABLE -BEGIN - POPUP "Editor Context Menu" - BEGIN - MENUITEM "Cu&t", ID_EDIT_CUT - MENUITEM "&Copy", ID_EDIT_COPY - MENUITEM "&Paste", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM "Select &None", ID_EDIT_SELECT_NONE - END -END - -IDR_EDITOR MENU PRELOAD DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&New Browser Window\tCtrl+N", ID_NEW_BROWSER - MENUITEM "New &Editor Window", ID_NEW_EDITORWINDOW - MENUITEM SEPARATOR - MENUITEM "&Open File...\tCtrl+O", ID_FILE_OPEN - MENUITEM "&Save Page As...\tCtrl+S", ID_FILE_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Print...\tCtrl-P", ID_FILE_PRINT - MENUITEM SEPARATOR - MENUITEM "E&xit\tCtrl+Q", ID_APP_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "Undo\tCtrl+Z", ID_EDITOR_UNDO - MENUITEM "Redo\tCtrl+Shift+Z", ID_EDITOR_REDO - MENUITEM SEPARATOR - MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT - MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY - MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE - MENUITEM SEPARATOR - MENUITEM "Select &All", ID_EDIT_SELECT_ALL - MENUITEM "Select &None", ID_EDIT_SELECT_NONE - MENUITEM SEPARATOR - MENUITEM "&Find in This Page...\tCtrl+F", ID_EDIT_FIND - END - POPUP "F& ormat" - BEGIN - POPUP "Font" - BEGIN - MENUITEM "Arial", ID_ARIAL - MENUITEM "Times New Roman", ID_TIMES - MENUITEM "Courier", ID_COURIER - END - END - POPUP "&Help" - BEGIN - MENUITEM "&About MfcEmbed...", ID_APP_ABOUT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE -BEGIN - "C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - "F", ID_EDIT_FIND, VIRTKEY, CONTROL, NOINVERT - "N", ID_NEW_BROWSER, VIRTKEY, CONTROL, NOINVERT - "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT - "S", ID_FILE_SAVE_AS, VIRTKEY, CONTROL, NOINVERT - "V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT - VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT - VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT - VK_ESCAPE, ID_NAV_STOP, VIRTKEY, NOINVERT - VK_F6, ID_NEXT_PANE, VIRTKEY, NOINVERT - VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT, NOINVERT - VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT - VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT, NOINVERT - "X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDITOR_UNDO, VIRTKEY, CONTROL, NOINVERT - "Z", ID_EDIT_REDO, VIRTKEY, SHIFT, CONTROL, - NOINVERT - "Z", ID_EDITOR_REDO, VIRTKEY, SHIFT, CONTROL, - NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About MfcEmbed" -FONT 8, "MS Sans Serif" -BEGIN - ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 - LTEXT "Mozilla MfcEmbed Version 1.0",IDC_STATIC,40,10,119,8, - SS_NOPREFIX - LTEXT "Copyright (C) 2001",IDC_STATIC,40,25,119,8 - DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP -END - -IDD_PROFILES DIALOG DISCARDABLE 0, 0, 193, 110 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Manage Profiles" -FONT 8, "MS Sans Serif" -BEGIN - LISTBOX IDC_LIST1,7,7,117,56,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | - WS_TABSTOP - PUSHBUTTON "New...",IDC_PROF_NEW,133,7,50,14 - PUSHBUTTON "Rename...",IDC_PROF_RENAME,133,27,50,14 - PUSHBUTTON "Delete",IDC_PROF_DELETE,133,48,50,14 - CONTROL "Ask At Startup",IDC_CHECK_ASK_AT_START,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,71,61,10 - DEFPUSHBUTTON "OK",IDOK,77,89,50,14 - PUSHBUTTON "Cancel",IDCANCEL,133,89,50,14 -END - -IDD_PROFILE_NEW DIALOG DISCARDABLE 0, 0, 177, 79 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "New Profile" -FONT 8, "MS Sans Serif" -BEGIN - RTEXT "Name:",IDC_STATIC,13,18,22,8 - EDITTEXT IDC_NEW_PROF_NAME,39,16,122,14,ES_AUTOHSCROLL - RTEXT "Locale:",IDC_STATIC,11,37,24,8 - COMBOBOX IDC_LOCALE_COMBO,39,35,67,30,CBS_DROPDOWNLIST | CBS_SORT | - WS_DISABLED | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK",IDOK,64,58,50,14 - PUSHBUTTON "Cancel",IDCANCEL,120,58,50,14 -END - -IDD_PROFILE_RENAME DIALOG DISCARDABLE 0, 0, 177, 71 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Rename Profile" -FONT 8, "MS Sans Serif" -BEGIN - RTEXT "New Name:",IDC_STATIC,7,18,38,8 - EDITTEXT IDC_NEW_NAME,50,16,113,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,60,48,50,14 - PUSHBUTTON "Cancel",IDCANCEL,115,48,50,14 -END - -IDD_FINDDLG DIALOG DISCARDABLE 30, 73, 239, 83 -STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Find" -FONT 8, "MS Shell Dlg" -BEGIN - LTEXT "Fi&nd what:",-1,4,8,42,8 - EDITTEXT IDC_FIND_EDIT,47,7,128,12,ES_AUTOHSCROLL | WS_GROUP - CONTROL "Wra&p around",IDC_WRAP_AROUND,"Button",BS_AUTOCHECKBOX | - WS_GROUP | WS_TABSTOP,47,45,65,12 - CONTROL "Match &case",IDC_MATCH_CASE,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,47,29,64,12 - CONTROL "Search &backwards",IDC_SEARCH_BACKWARDS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,47,62,75,12 - DEFPUSHBUTTON "&Find Next",IDOK,182,5,50,14,WS_GROUP - PUSHBUTTON "Cancel",IDCANCEL,182,23,50,14 -END - -IDD_PREFS_START_PAGE DIALOG DISCARDABLE 0, 0, 284, 150 -STYLE WS_CHILD | WS_DISABLED | WS_CAPTION -CAPTION "Startup" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "MfcEmbed starts with",IDC_STATIC,6,10,271,49 - CONTROL "Bla&nk Page",IDC_RADIO_BLANK_PAGE,"Button", - BS_AUTORADIOBUTTON | WS_GROUP,16,24,53,10 - CONTROL "&Home Page",IDC_RADIO_HOME_PAGE,"Button", - BS_AUTORADIOBUTTON,16,40,53,10 - GROUPBOX "Home Page",IDC_STATIC,6,67,271,51 - LTEXT "Clicking the Home button will take you to this page", - IDC_STATIC,17,80,234,8 - LTEXT "Loc&ation:",IDC_STATIC,17,98,31,8 - EDITTEXT IDC_EDIT_HOMEPAGE,53,95,211,14,ES_AUTOHSCROLL -END - -IDD_PRINTSETUP_DIALOG DIALOG DISCARDABLE 0, 0, 328, 175 -STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Page Setup" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,7,154,50,14 - PUSHBUTTON "Cancel",IDCANCEL,271,154,50,14 - CONTROL "Tab1",IDC_PRINTSETUP_TAB_CTRL,"SysTabControl32",0x0,7,7, - 314,125 -END - -IDD_HEADERFOOTER_TAB DIALOG DISCARDABLE 0, 0, 319, 106 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Margins && Headers/Footers" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX "Headers && Footers",IDC_STATIC,7,38,229,56 - RTEXT "Left",IDC_STATIC,30,65,13,8 - RTEXT "Center",IDC_STATIC,104,65,22,8 - RTEXT "Right",IDC_STATIC,187,65,18,8 - EDITTEXT IDC_TOP_MARGIN_TXT,39,15,40,14,ES_AUTOHSCROLL - EDITTEXT IDC_LEFT_MARGIN_TXT,112,15,40,14,ES_AUTOHSCROLL - EDITTEXT IDC_BOTTOM_MARGIN_TXT,185,15,40,14,ES_AUTOHSCROLL - EDITTEXT IDC_RIGHT_MARGIN_TXT,258,15,40,14,ES_AUTOHSCROLL - GROUPBOX "Margins",IDC_STATIC,7,7,302,26 - LTEXT "Left:",IDC_STATIC,95,17,15,8 - LTEXT "Top:",IDC_STATIC,22,17,16,8 - LTEXT "Right:",IDC_STATIC,236,17,20,8 - LTEXT "Bottom:",IDC_STATIC,158,17,25,8 - COMBOBOX IDC_FTR_LEFT_CMBX,13,76,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_FTR_CENTER_CMBX,92,76,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_FTR_RIGHT_CMBX,171,76,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_HDR_LEFT_CMBX,13,49,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_HDR_CENTER_CMBX,92,50,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_HDR_RIGHT_CMBX,171,50,57,70,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP -END - -IDD_FORMAT_OPTIONS_TAB DIALOG DISCARDABLE 0, 0, 321, 126 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Format && Options" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "&Portait",IDC_PRT_PORTRAIT_RD,"Button", - BS_AUTORADIOBUTTON | WS_GROUP,14,16,36,10 - CONTROL "&Landscape",IDC_PRT_LANDSCAPE_RD,"Button", - BS_AUTORADIOBUTTON,56,16,51,10 - COMBOBOX IDC_PAPER_SIZE_CBX,26,40,81,67,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_GROUP | WS_TABSTOP - EDITTEXT IDC_UD_PAPER_WDTH,33,57,40,14,ES_AUTOHSCROLL | - WS_DISABLED - EDITTEXT IDC_UD_PAPER_HGT,106,57,40,14,ES_AUTOHSCROLL | - WS_DISABLED - CONTROL "Inches",IDC_INCHES_RD,"Button",BS_AUTORADIOBUTTON | - WS_DISABLED | WS_GROUP,13,76,37,10 - CONTROL "Millimeters",IDC_MILLI_RD,"Button",BS_AUTORADIOBUTTON | - WS_DISABLED,53,76,48,10 - CONTROL "Slider1",IDC_SCALE,"msctls_trackbar32",TBS_AUTOTICKS | - TBS_BOTH | WS_TABSTOP,163,42,100,19 - EDITTEXT IDC_SCALE_TXT,264,47,19,14,ES_AUTOHSCROLL - CONTROL "Print Background C&olors",IDC_PRT_BGCOLORS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,10,100,92,10 - CONTROL "Print Background &Images",IDC_PRT_BGIMAGES,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,124,100,95,10 - GROUPBOX "Scaling",IDC_STATIC,161,31,148,34 - LTEXT "Size:",IDC_STATIC,10,41,16,8 - GROUPBOX "Format",IDC_STATIC,7,31,147,57 - LTEXT "Width:",IDC_UD_WIDTH_LBL,10,60,22,8,WS_DISABLED - LTEXT "Height:",IDC_UD_HEIGHT_LBL,81,60,24,8,WS_DISABLED - GROUPBOX "Options",IDC_STATIC,7,90,213,25 - GROUPBOX "Orientation",IDC_STATIC,7,7,104,22 -END - -IDD_CUSTOM_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 232, 49 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Custom" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_PROMPT_TEXT,35,7,135,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,175,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,175,24,50,14 - LTEXT "Custom:",IDC_STATIC,7,8,26,8 -END - -IDD_DIALOG_LINK_PROPERTIES DIALOG DISCARDABLE 0, 0, 262, 162 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Link Properties" -FONT 8, "MS Sans Serif" -BEGIN - GROUPBOX " Link Text ",IDC_STATIC,7,7,248,52 - GROUPBOX " Link Location ",IDC_STATIC,7,73,248,52 - LTEXT "Enter &text to display for the link:",IDC_STATIC,16,20, - 223,8 - EDITTEXT IDC_EDIT_LINK_TEXT,16,34,232,14,ES_AUTOHSCROLL - LTEXT "Enter a web page &location:",IDC_STATIC,16,88,223,8 - EDITTEXT IDC_EDIT_LINK_LOCATION,16,103,232,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,69,140,50,14 - PUSHBUTTON "Cancel",IDCANCEL,128,140,50,14 -END - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "MfcEmbed MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "MfcEmbed\0" - VALUE "LegalCopyright", "Copyright (C) 2001\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "MfcEmbed.EXE\0" - VALUE "ProductName", "MfcEmbed Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 228 - TOPMARGIN, 7 - BOTTOMMARGIN, 48 - END - - IDD_PROFILES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 189 - TOPMARGIN, 7 - BOTTOMMARGIN, 88 - END - - IDD_PROFILE_NEW, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 170 - TOPMARGIN, 7 - BOTTOMMARGIN, 72 - END - - IDD_PROFILE_RENAME, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 170 - TOPMARGIN, 7 - BOTTOMMARGIN, 69 - END - - IDD_PRINTSETUP_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 321 - TOPMARGIN, 7 - BOTTOMMARGIN, 168 - END - - IDD_HEADERFOOTER_TAB, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 312 - TOPMARGIN, 7 - BOTTOMMARGIN, 99 - END - - IDD_FORMAT_OPTIONS_TAB, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 314 - TOPMARGIN, 7 - BOTTOMMARGIN, 119 - END - - IDD_CUSTOM_PROMPT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 225 - TOPMARGIN, 7 - BOTTOMMARGIN, 42 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDR_MAINFRAME "mfcembed" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - IDS_NOSECURITY_INFO "This page has no security information or was not encrypted.\nThis means it was possible for other people to view this page when it was loaded." - IDS_ENCRYPTION_HIGH_GRADE "High-grade Encryption (%1% %2!d! bit)" - IDS_ENCRYPTION_LOW_GRADE "Low-grade Encryption (%1% %2!d! bit)" - IDS_ENCRYPTION_NONE "Connection Not Encrypted" - IDS_SRCH_STR_NOT_FOUND "The text you entered was not found" - IDS_VIEW_FRAME_SOURCE "View Frame Source" - IDS_OPEN_FRAME_IN_NEW_WINDOW "Open Frame in New Window" -END - -STRINGTABLE PRELOAD DISCARDABLE -BEGIN - AFX_IDS_APP_TITLE "mfcembed" - AFX_IDS_IDLEMESSAGE "Ready" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_APP_ABOUT "Display program information, version number and copyright\nAbout" - ID_APP_EXIT "Quit the application; prompts to save documents\nExit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_NEXT_PANE "Switch to the next window pane\nNext Pane" - ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_WINDOW_SPLIT "Split the active window into panes\nSplit" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_CLEAR "Erase the selection\nErase" - ID_EDIT_CLEAR_ALL "Erase everything\nErase All" - ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" - ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" - ID_EDIT_FIND "Find the specified text\nFind" - ID_EDIT_PASTE "Insert Clipboard contents\nPaste" - ID_EDIT_REPEAT "Repeat the last action\nRepeat" - ID_EDIT_REPLACE "Replace specific text with different text\nReplace" - ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" - ID_EDIT_UNDO "Undo the last action\nUndo" - ID_EDIT_REDO "Redo the previously undone action\nRedo" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" - ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCSIZE "Change the window size" - AFX_IDS_SCMOVE "Change the window position" - AFX_IDS_SCMINIMIZE "Reduce the window to an icon" - AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" - AFX_IDS_SCNEXTWINDOW "Switch to the next document window" - AFX_IDS_SCPREVWINDOW "Switch to the previous document window" - AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" -END - -STRINGTABLE DISCARDABLE -BEGIN - AFX_IDS_SCRESTORE "Restore the window to normal size" - AFX_IDS_SCTASKLIST "Activate Task List" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_SELECT_NONE "Select nothing in the document\nSelect None" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FILE_PRINTPREVIEW "Print Preview" - ID_FILE_PRINTSETUP "Page Setup Dialog" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_ARIAL "Arial" - ID_TIMES "Times New Roman" -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_PROFILES_FOLDER_NAME "MfcEmbed" - IDS_PROFILES_NONSHARED_NAME "Browser" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\mfcembed.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp b/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp deleted file mode 100644 index eb2a1074d19..00000000000 --- a/mozilla/embedding/tests/mfcembed/MostRecentUrls.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -// -// CMostRecentUrls object is responsible for keeping track of the -// 16 most recently used URLs. It stores this list in a file named -// "urls.txt" on a per profile basis in the user's profile directory -// -// The constructor loads the URL list -// The destructor saves the URL list -// - -#include "StdAfx.h" -#include "nsIFile.h" -#include "nsILocalFile.h" -#include "nsServiceManagerUtils.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsDirectoryServiceUtils.h" -#include "MostRecentUrls.h" - -//-------------------------------------------------------- -//-- CMostRecentUrls -//-------------------------------------------------------- -CMostRecentUrls::CMostRecentUrls() : - mNumURLs(0) -{ - for (int i=0;i 1) { - line[strlen(line)-1] = 0; - mURLs[mNumURLs++] = _strdup(line); - } - } - fclose(fd); - } - -} - -FILE * CMostRecentUrls::GetFD(const char * aMode) -{ - FILE * fd = nsnull; - nsCOMPtr file; - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file)); - if (NS_SUCCEEDED(rv)) { - nsCOMPtr local_file(do_QueryInterface(file)); - local_file->AppendNative(nsEmbedCString("urls.txt")); - local_file->OpenANSIFileDesc(aMode, &fd); - } - - return fd; -} - -CMostRecentUrls::~CMostRecentUrls() -{ - FILE * fd = GetFD("w"); - if (fd) { - for (int i=0;i0; i--) - { - if(mURLs[i]) - free(mURLs[i]); - - if(mURLs[i-1]) - mURLs[i] = _strdup(mURLs[i-1]); - } - - // place this url at the top - if(mURLs[0]) - free(mURLs[0]); - mURLs[0] = _strdup(szTemp); -} diff --git a/mozilla/embedding/tests/mfcembed/MostRecentUrls.h b/mozilla/embedding/tests/mfcembed/MostRecentUrls.h deleted file mode 100644 index 4cd84fc9c77..00000000000 --- a/mozilla/embedding/tests/mfcembed/MostRecentUrls.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -class CMostRecentUrls { -public: - enum _maxUrls { - MAX_URLS = 16 - }; - - CMostRecentUrls(); - virtual ~CMostRecentUrls(); - - char * GetURL(int aInx); - void AddURL(const char * aURL); - inline int GetNumURLs() { return mNumURLs; } - FILE * CMostRecentUrls::GetFD(const char * aMode); - -protected: - char * mURLs[MAX_URLS]; - int mNumURLs; -}; diff --git a/mozilla/embedding/tests/mfcembed/Preferences.cpp b/mozilla/embedding/tests/mfcembed/Preferences.cpp deleted file mode 100644 index d29433f0130..00000000000 --- a/mozilla/embedding/tests/mfcembed/Preferences.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" -#include "Preferences.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////// -// CPreferences - -IMPLEMENT_DYNAMIC(CPreferences, CPropertySheet) - -CPreferences::CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) - :CPropertySheet(pszCaption, pParentWnd, iSelectPage) -{ - AddPage(&m_startupPage); -} - -CPreferences::~CPreferences() -{ -} - -BEGIN_MESSAGE_MAP(CPreferences, CPropertySheet) - //{{AFX_MSG_MAP(CPreferences) - // NOTE - the ClassWizard will add and remove mapping macros here. - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -BOOL CPreferences::OnInitDialog() -{ - BOOL bResult = CPropertySheet::OnInitDialog(); - - // Hide the Apply button - CWnd* pApplyButton = GetDlgItem(ID_APPLY_NOW); - ASSERT(pApplyButton); - pApplyButton->ShowWindow(SW_HIDE); - - return bResult; -} - - -///////////////////////////////////////////////////////////////// -// CStartupPrefsPage property page - -IMPLEMENT_DYNCREATE(CStartupPrefsPage, CPropertyPage) - -CStartupPrefsPage::CStartupPrefsPage() : CPropertyPage(CStartupPrefsPage::IDD) -{ - //{{AFX_DATA_INIT(CStartupPrefsPage) - m_strHomePage = _T(""); - m_iStartupPage = -1; - //}}AFX_DATA_INIT -} - -CStartupPrefsPage::~CStartupPrefsPage() -{ -} - -void CStartupPrefsPage::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CStartupPrefsPage) - DDX_Control(pDX, IDC_EDIT_HOMEPAGE, m_HomePage); - DDX_Text(pDX, IDC_EDIT_HOMEPAGE, m_strHomePage); - DDX_Radio(pDX, IDC_RADIO_BLANK_PAGE, m_iStartupPage); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CStartupPrefsPage, CPropertyPage) - //{{AFX_MSG_MAP(CStartupPrefsPage) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() diff --git a/mozilla/embedding/tests/mfcembed/Preferences.h b/mozilla/embedding/tests/mfcembed/Preferences.h deleted file mode 100644 index 293ba9f76fd..00000000000 --- a/mozilla/embedding/tests/mfcembed/Preferences.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - - -#ifndef _PREFERENCES_H_ -#define _PREFERENCES_H_ - -#include "resource.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CStartupPrefsPage dialog - -class CStartupPrefsPage : public CPropertyPage -{ - DECLARE_DYNCREATE(CStartupPrefsPage) - -// Construction -public: - CStartupPrefsPage(); - ~CStartupPrefsPage(); - -// Dialog Data - //{{AFX_DATA(CStartupPrefsPage) - enum { IDD = IDD_PREFS_START_PAGE }; - CEdit m_HomePage; - CString m_strHomePage; - int m_iStartupPage; - //}}AFX_DATA - - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(CStartupPrefsPage) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - // Generated message map functions - //{{AFX_MSG(CStartupPrefsPage) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -///////////////////////////////////////////////////////////////////////////// -// CPreferences - -class CPreferences : public CPropertySheet -{ - DECLARE_DYNAMIC(CPreferences) - -// Construction -public: - CPreferences(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - -// Attributes -public: - CStartupPrefsPage m_startupPage; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPreferences) - public: - virtual BOOL OnInitDialog(); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CPreferences(); - - // Generated message map functions -protected: - //{{AFX_MSG(CPreferences) - // NOTE - the ClassWizard will add and remove member functions here. - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // _PREFERENCES_H_ diff --git a/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp b/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp deleted file mode 100644 index f2fe8d4e611..00000000000 --- a/mozilla/embedding/tests/mfcembed/ProfileMgr.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ***** 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): - * Conrad Carlen - * - * ***** END LICENSE BLOCK ***** */ - -// Local Includes -#include "stdafx.h" -#include "mfcembed.h" -#include "ProfileMgr.h" -#include "ProfilesDlg.h" - -// Mozilla Includes -#include "nsEmbedString.h" -#include "nsIRegistry.h" -#include "nsIProfile.h" -#include "nsServiceManagerUtils.h" -#include "nsComponentManagerUtils.h" -#include "nsCOMPtr.h" -#include "nsMemory.h" - -// Constants -#define kRegistryGlobalPrefsSubtreeString (nsEmbedString(L"global-prefs")) -#define kRegistryShowProfilesAtStartup "start-show-dialog" - -//***************************************************************************** -//*** CProfileMgr: Object Management -//***************************************************************************** - -CProfileMgr::CProfileMgr() -{ -} - -CProfileMgr::~CProfileMgr() -{ -} - - -//***************************************************************************** -//*** CProfileMgr: Public Methods -//***************************************************************************** - -nsresult CProfileMgr::StartUp() -{ - nsresult rv; - - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; - - PRInt32 profileCount; - rv = profileService->GetProfileCount(&profileCount); - if (NS_FAILED(rv)) return rv; - if (profileCount == 0) - { - // Make a new default profile - nsEmbedString newProfileName(L"default"); - - rv = profileService->CreateNewProfile(newProfileName.get(), nsnull, nsnull, PR_FALSE); - if (NS_FAILED(rv)) return rv; - rv = profileService->SetCurrentProfile(newProfileName.get()); - if (NS_FAILED(rv)) return rv; - } - else - { - // Use our flag here to check for whether to show profile mgr UI. If the flag - // says don't show it, just start with the last used profile. - - PRBool showIt; - rv = GetShowDialogOnStart(&showIt); - - if (NS_FAILED(rv) || (profileCount > 1 && showIt)) - { - DoManageProfilesDialog(TRUE); - } - else - { - // GetCurrentProfile returns the profile which was last used but is not nescesarily - // active. Call SetCurrentProfile to make it installed and active. - - PRUnichar *currProfileName = nsnull; - rv = profileService->GetCurrentProfile(&currProfileName); - if (NS_FAILED(rv)) return rv; - rv = profileService->SetCurrentProfile(currProfileName); - nsMemory::Free(currProfileName); - if (NS_FAILED(rv)) return rv; - } - } - - return NS_OK; -} - -nsresult CProfileMgr::DoManageProfilesDialog(PRBool bAtStartUp) -{ - CProfilesDlg dialog; - nsresult rv; - PRBool showIt; - - rv = GetShowDialogOnStart(&showIt); - dialog.m_bAtStartUp = bAtStartUp; - dialog.m_bAskAtStartUp = NS_SUCCEEDED(rv) ? showIt : TRUE; - - if (dialog.DoModal() == IDOK) - { - SetShowDialogOnStart(dialog.m_bAskAtStartUp); - - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) - rv = profileService->SetCurrentProfile(dialog.m_SelectedProfile.get()); - } - return NS_OK; -} - - -//***************************************************************************** -//*** CProfileMgr: Protected Methods -//***************************************************************************** - -nsresult CProfileMgr::GetShowDialogOnStart(PRBool* showIt) -{ - nsresult rv = NS_OK; - - *showIt = PR_TRUE; - - nsCOMPtr registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv)); - rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry); - if (NS_FAILED(rv)) return rv; - - nsRegistryKey profilesTreeKey; - - rv = registry->GetKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString.get(), - &profilesTreeKey); - - if (NS_SUCCEEDED(rv)) - { - PRInt32 flagValue; - rv = registry->GetInt(profilesTreeKey, - kRegistryShowProfilesAtStartup, - &flagValue); - - if (NS_SUCCEEDED(rv)) - *showIt = (flagValue != 0); - } - return rv; -} - -nsresult CProfileMgr::SetShowDialogOnStart(PRBool showIt) -{ - nsresult rv = NS_OK; - - nsCOMPtr registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv)); - rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry); - if (NS_FAILED(rv)) return rv; - - nsRegistryKey profilesTreeKey; - - rv = registry->GetKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString.get(), - &profilesTreeKey); - - if (NS_FAILED(rv)) - { - rv = registry->AddKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString.get(), - &profilesTreeKey); - } - if (NS_SUCCEEDED(rv)) - { - - rv = registry->SetInt(profilesTreeKey, - kRegistryShowProfilesAtStartup, - showIt); - } - - return rv; -} - diff --git a/mozilla/embedding/tests/mfcembed/ProfileMgr.h b/mozilla/embedding/tests/mfcembed/ProfileMgr.h deleted file mode 100644 index 5636610b0d6..00000000000 --- a/mozilla/embedding/tests/mfcembed/ProfileMgr.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ***** 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): - * Conrad Carlen - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __ProfileMgr__ -#define __ProfileMgr__ - -// Mozilla Includes -#include "nsError.h" - -// Forward Declarations -class nsIRegistry; - -//***************************************************************************** -//*** CProfileMgr -//***************************************************************************** - -class CProfileMgr -{ - public: - CProfileMgr(); - virtual ~CProfileMgr(); - - virtual nsresult StartUp(); - virtual nsresult DoManageProfilesDialog(PRBool bAtStartUp); - // If bAtStartUp is TRUE, a profile must be selected. - - protected: - - nsresult GetShowDialogOnStart(PRBool* showIt); - nsresult SetShowDialogOnStart(PRBool showIt); -}; - - - - -#endif diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp b/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp deleted file mode 100644 index cd0243322f1..00000000000 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/* ***** 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 ***** */ - -// ProfilesDlg.cpp : implementation file -// - -#include "stdafx.h" -#include -#include "mfcembed.h" -#include "ProfilesDlg.h" - -// Mozilla -#include "nsIProfile.h" -#include "nsIServiceManager.h" -#include "nsServiceManagerUtils.h" -#include "nsMemory.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -// Static Routines -static void ValidateProfileName(const CString& profileName, CDataExchange* pDX) -{ - USES_CONVERSION; - - nsresult rv; - PRBool exists = FALSE; - - { - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - rv = profileService->ProfileExists(T2CW(profileName), &exists); - } - - if (NS_SUCCEEDED(rv) && exists) - { - CString errMsg; - errMsg.Format(_T("Error: A profile named \"%s\" already exists."), profileName); - AfxMessageBox( errMsg, MB_ICONEXCLAMATION ); - errMsg.Empty(); - pDX->Fail(); - } - - if (profileName.FindOneOf(_T("\\/")) != -1) - { - AfxMessageBox( _T("Error: A profile name cannot contain the characters \"\\\" or \"/\"."), MB_ICONEXCLAMATION ); - pDX->Fail(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CNewProfileDlg dialog - - -CNewProfileDlg::CNewProfileDlg(CWnd* pParent /*=NULL*/) - : CDialog(CNewProfileDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CNewProfileDlg) - m_LocaleIndex = -1; - m_Name = _T(""); - //}}AFX_DATA_INIT -} - - -void CNewProfileDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CNewProfileDlg) - DDX_CBIndex(pDX, IDC_LOCALE_COMBO, m_LocaleIndex); - DDX_Text(pDX, IDC_NEW_PROF_NAME, m_Name); - //}}AFX_DATA_MAP - - pDX->PrepareEditCtrl(IDC_NEW_PROF_NAME); - if (pDX->m_bSaveAndValidate) - { - ValidateProfileName(m_Name, pDX); - } -} - - -BEGIN_MESSAGE_MAP(CNewProfileDlg, CDialog) - //{{AFX_MSG_MAP(CNewProfileDlg) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CNewProfileDlg message handlers - - -///////////////////////////////////////////////////////////////////////////// -// CRenameProfileDlg dialog - - -CRenameProfileDlg::CRenameProfileDlg(CWnd* pParent /*=NULL*/) - : CDialog(CRenameProfileDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CRenameProfileDlg) - m_NewName = _T(""); - //}}AFX_DATA_INIT -} - - -void CRenameProfileDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CRenameProfileDlg) - DDX_Text(pDX, IDC_NEW_NAME, m_NewName); - //}}AFX_DATA_MAP - - pDX->PrepareEditCtrl(IDC_NEW_NAME); - if (pDX->m_bSaveAndValidate) - { - ValidateProfileName(m_NewName, pDX); - } -} - - -BEGIN_MESSAGE_MAP(CRenameProfileDlg, CDialog) - //{{AFX_MSG_MAP(CRenameProfileDlg) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRenameProfileDlg message handlers - - -///////////////////////////////////////////////////////////////////////////// -// CProfilesDlg dialog - - -CProfilesDlg::CProfilesDlg(CWnd* pParent /*=NULL*/) - : CDialog(CProfilesDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CProfilesDlg) - m_bAtStartUp = FALSE; - m_bAskAtStartUp = FALSE; - //}}AFX_DATA_INIT -} - - -void CProfilesDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CProfilesDlg) - DDX_Control(pDX, IDC_LIST1, m_ProfileList); - DDX_Check(pDX, IDC_CHECK_ASK_AT_START, m_bAskAtStartUp); - //}}AFX_DATA_MAP - - if (pDX->m_bSaveAndValidate) - { - USES_CONVERSION; - - int itemIndex = m_ProfileList.GetCurSel(); - if (itemIndex != LB_ERR) - { - CString itemText; - m_ProfileList.GetText(itemIndex, itemText); - m_SelectedProfile.Assign(T2CW(itemText)); - } - } -} - - -BEGIN_MESSAGE_MAP(CProfilesDlg, CDialog) - //{{AFX_MSG_MAP(CProfilesDlg) - ON_BN_CLICKED(IDC_PROF_NEW, OnNewProfile) - ON_BN_CLICKED(IDC_PROF_RENAME, OnRenameProfile) - ON_BN_CLICKED(IDC_PROF_DELETE, OnDeleteProfile) - ON_LBN_DBLCLK(IDC_LIST1, OnDblclkProfile) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CProfilesDlg message handlers - -BOOL CProfilesDlg::OnInitDialog() -{ - USES_CONVERSION; - - CDialog::OnInitDialog(); - - PRUnichar *curProfileName = nsnull; - - // Fill the list of profiles - nsresult rv; - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - profileService->GetCurrentProfile(&curProfileName); - - PRInt32 selectedRow = 0; - PRUint32 listLen; - PRUnichar **profileList; - rv = profileService->GetProfileList(&listLen, &profileList); - - for (PRUint32 index = 0; index < listLen; index++) - { - CString tmpStr(W2T(profileList[index])); - m_ProfileList.AddString(tmpStr); - if (wcscmp(profileList[index], curProfileName) == 0) - selectedRow = index; - } - nsMemory::Free(curProfileName); - - m_ProfileList.SetCurSel(selectedRow); - - if (m_bAtStartUp) - { - GetDlgItem(IDCANCEL)->EnableWindow(FALSE); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CProfilesDlg::OnNewProfile() -{ - CNewProfileDlg dialog; - - if (dialog.DoModal() == IDOK) - { - nsresult rv; - - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - ASSERT(NS_SUCCEEDED(rv)); - if (NS_SUCCEEDED(rv)) - { - USES_CONVERSION; - - rv = profileService->CreateNewProfile(T2CW(dialog.m_Name), nsnull, nsnull, PR_FALSE); - ASSERT(NS_SUCCEEDED(rv)); - if (NS_SUCCEEDED(rv)) - { - int item = m_ProfileList.AddString(dialog.m_Name); - m_ProfileList.SetCurSel(item); - GetDlgItem(IDOK)->EnableWindow(TRUE); - } - } - } -} - -void CProfilesDlg::OnRenameProfile() -{ - CRenameProfileDlg dialog; - - int itemIndex = m_ProfileList.GetCurSel(); - ASSERT(itemIndex != LB_ERR); - if (itemIndex == LB_ERR) - return; - - m_ProfileList.GetText(itemIndex, dialog.m_CurrentName); - - if (dialog.DoModal() == IDOK) - { - USES_CONVERSION; - - nsresult rv; - - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - ASSERT(NS_SUCCEEDED(rv)); - if (NS_SUCCEEDED(rv)) - { - rv = profileService->RenameProfile(T2CW(dialog.m_CurrentName), T2CW(dialog.m_NewName)); - ASSERT(NS_SUCCEEDED(rv)); - } - } -} - -void CProfilesDlg::OnDeleteProfile() -{ - int itemIndex = m_ProfileList.GetCurSel(); - ASSERT(itemIndex != LB_ERR); - if (itemIndex == LB_ERR) - return; - - CString selectedProfile; - m_ProfileList.GetText(itemIndex, selectedProfile); - - nsresult rv; - nsCOMPtr profileService = - do_GetService(NS_PROFILE_CONTRACTID, &rv); - ASSERT(NS_SUCCEEDED(rv)); - if (NS_SUCCEEDED(rv)) - { - USES_CONVERSION; - - rv = profileService->DeleteProfile(T2CW(selectedProfile), PR_TRUE); - ASSERT(NS_SUCCEEDED(rv)); - if (NS_SUCCEEDED(rv)) - { - int itemCount = m_ProfileList.DeleteString(itemIndex); - if (itemCount == 0) - GetDlgItem(IDOK)->EnableWindow(FALSE); - } - } -} - -void CProfilesDlg::OnDblclkProfile() -{ - OnOK(); -} diff --git a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h b/mozilla/embedding/tests/mfcembed/ProfilesDlg.h deleted file mode 100644 index a4fe6fe0547..00000000000 --- a/mozilla/embedding/tests/mfcembed/ProfilesDlg.h +++ /dev/null @@ -1,150 +0,0 @@ -/* ***** 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 ***** */ - -#if !defined(AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_) -#define AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// ProfilesDlg.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CNewProfileDlg dialog - -class CNewProfileDlg : public CDialog -{ -// Construction -public: - CNewProfileDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CNewProfileDlg) - enum { IDD = IDD_PROFILE_NEW }; - int m_LocaleIndex; - CString m_Name; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CNewProfileDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CNewProfileDlg) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// CRenameProfileDlg dialog - -class CRenameProfileDlg : public CDialog -{ -// Construction -public: - CRenameProfileDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CRenameProfileDlg) - enum { IDD = IDD_PROFILE_RENAME }; - CString m_NewName; - //}}AFX_DATA - - CString m_CurrentName; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CRenameProfileDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CRenameProfileDlg) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// CProfilesDlg dialog - -class CProfilesDlg : public CDialog -{ -// Construction -public: - CProfilesDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CProfilesDlg) - enum { IDD = IDD_PROFILES }; - CListBox m_ProfileList; - BOOL m_bAtStartUp; - BOOL m_bAskAtStartUp; - //}}AFX_DATA - - nsEmbedString m_SelectedProfile; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CProfilesDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CProfilesDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnNewProfile(); - afx_msg void OnRenameProfile(); - afx_msg void OnDeleteProfile(); - afx_msg void OnDblclkProfile(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PROFILESDLG_H__48358887_EBFA_11D4_9905_00B0D0235410__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/README.TXT b/mozilla/embedding/tests/mfcembed/README.TXT deleted file mode 100644 index 09fb4ea7f85..00000000000 --- a/mozilla/embedding/tests/mfcembed/README.TXT +++ /dev/null @@ -1,151 +0,0 @@ -***** BEGIN LICENSE BLOCK ***** -Version: MPL 1.1/GPL 2.0/LGPL 2.1 - -The contents of this file are subject to the Mozilla Public License Version -1.1 (the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -for the specific language governing rights and limitations under the -License. - -The Original Code is mozilla.org code. - -The Initial Developer of the Original Code is -Netscape Communications Corporation. -Portions created by the Initial Developer are Copyright (C) 2___ -the Initial Developer. All Rights Reserved. - -Contributor(s): - Chak Nanga - -Alternatively, the contents of this file may be used under the terms of -either the GNU General Public License Version 2 or later (the "GPL"), or -the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -in which case the provisions of the GPL or the LGPL are applicable instead -of those above. If you wish to allow use of your version of this file only -under the terms of either the GPL or the LGPL, and not to allow others to -use your version of this file under the terms of the MPL, indicate your -decision by deleting the provisions above and replace them with the notice -and other provisions required by the GPL or the LGPL. If you do not delete -the provisions above, a recipient may use your version of this file under -the terms of any one of the MPL, the GPL or the LGPL. - -***** END LICENSE BLOCK ***** - -This sample shows how to embed Mozilla from within -an MFC Windows application - -Mainly demonstrates the use of the following interfaces: - - nsIWebBrowserChrome - nsIEmbeddingSiteWindow - nsIWebProgressListener - nsIContextMenuListener - nsIPrompt - nsIWebBrowserFind - -General Overview: ------------------ - -1. The MfcEmbedApp creates BrowserFrames - -2. BrowserFrame creates the toolbar, statusbar, URLbar - BrowserView etc. - BrowserFrames implement the IBrowserFrameGlue interface - using which new BrowserFrames can be created, statusbar - updated etc. - -3. BrowserView creates the embeddable browser instance and - manages user interaction such as URL navigation etc. - BrowserView connects the BrowserImpl with the BrowserFrame - via the IBrowserFrameGlue interface - -4. BrowserImpl implements the set of required/optional Gecko - embedding interfaces - - -Start by first looking at MfcEmbed.cpp - -Files: - -StdAfx.h - - Includes the required Mozilla header files - -MfcEmbed.cpp - - CWinApp derived class - - Creates the browser's main frame window etc - using the CreateNewBrowserFrame() and loads - the HomePage - - Makes the required NS_InitEmbedding() and the - NS_TermEmbedding() calls in the app's InitInstance() - and ExitInstance() functions - - Keeps track of the list of new BrowserFrames created - which it cleans up properly in ExitInstance() - -BrowserFrm.cpp - - This is the browser's Frame window i.e. the one with the - "chrome" - with the toolbar, urlbar etc. - - Creates the toolbar, URLbar, statusbar, progressbar - also the browser's view window. - -BrowserFrameGlue.cpp - - Implements the IBrowserFrameGlue interface. This interface - contains platform specific implementations of functions to - update the statusbar, creating new browser frames etc. Embedded - browser's callbacks use this interface when needed - -BrowserView.cpp - - Creates the embedded browser object and handles most aspects - of the embedded browser interactions - like URL navigation, - clipboard interactions etc - - Also has code to keep the menu/toolbar/statusbar UI items up - to date - - It's the view which conntects the BrowserFrame to the BrowserImpl - (see below) by passing it the pointer to IBrowserFrameGlue - -BrowserImpl*.cpp - - Implements the required and/or optional embedded browser - interfaces - (BrowserImpl.cpp implements the set of interfaces which - are required by Gecko of all embedding apps. The other - interfaces implemented in the BrowserImpl*.cpp files are - optional) - - - Calls on the statusbar/progressbar update functions exposed - via the IBrowserFrameGlue in response to the nsIProgressListener - interface callbacks - -Dialogs.cpp - - Contains dialog box code for displaying Prompts, getting - passwords, getting username/passwords etc - - Contains the CFindDialog class - used for searching text - in a web page - -winEmbedFileLocProvider.cpp, ProfilesDlg.cpp, ProfileMgr.cpp - - Profile management related code (by Conrad Carlen) - -MfcEmbed.htm - - This is a simple test harness for excercising some of the - implemented interfaces . For ex, the nsIWebBrowserChrome. - - Open the file in mfcemed by typing the following in it's - location bar. For ex: - - file:///c:/tmp/mfcembed.htm - - Read/Click on the links on that page more info - - This test page is just a start and will add more test - case to it over time - - -makefile.win - - We define "_AFXDLL" and for the compiler and specify - "-SUBSYSTEM:windows" for the linker using LCFLAGS and - LLFLAGS, respectively - - We also define "USE_SINGLE_SIGN_ON" to enable the - single sign-on support - -mfcembed.dsp and mfcembed.dsw - - These VisualStudio workspace/project files can be used - to open/build this sample inside of the VC++ IDE diff --git a/mozilla/embedding/tests/mfcembed/StdAfx.cpp b/mozilla/embedding/tests/mfcembed/StdAfx.cpp deleted file mode 100644 index 3d72d0e4218..00000000000 --- a/mozilla/embedding/tests/mfcembed/StdAfx.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// stdafx.cpp : source file that includes just the standard includes -// mozembed.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/mozilla/embedding/tests/mfcembed/StdAfx.h b/mozilla/embedding/tests/mfcembed/StdAfx.h deleted file mode 100644 index 798755e3e4e..00000000000 --- a/mozilla/embedding/tests/mfcembed/StdAfx.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef _STDAFX_H -#define _STDAFX_H - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -// -// These headers are very evil, as they will define DEBUG if _DEBUG is -// defined, which is lame and not what we want for things like -// MOZ_TRACE_MALLOC and other tools. -// If we do not detect this, various MOZ/NS debug symbols are undefined -// and we can not build. -// /MDd defines _DEBUG automagically to have the right debug C LIB -// functions get called (so we can get symbols and hook into malloc). -// -#if !defined(DEBUG) -#define THERECANBENODEBUG -#endif - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#include // Needed for MFC MBCS/Unicode Conversion Macros -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#if defined(THERECANBENODEBUG) && defined(DEBUG) -#undef DEBUG -#endif - -#include "nsCOMPtr.h" -#include "nsEmbedString.h" -#include "nsCWebBrowser.h" -#include "nsWidgetsCID.h" -#include "nsIDocShell.h" -#include "nsIWebBrowser.h" -#include "nsIBaseWindow.h" -#include "nsIWebNavigation.h" -#include "nsIWebBrowserChrome.h" -#include "nsIWebProgressListener.h" -#include "nsIWebProgress.h" -#include "nsIWindowCreator.h" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" -#include "nsIDocShellTreeOwner.h" -#include "nsIDocShellTreeItem.h" -#include "nsIClipboardCommands.h" -#include "nsIWebBrowserPersist.h" -#include "nsIContextMenuListener2.h" -#include "nsITooltipListener.h" -#include "nsIDOMNode.h" -#include "nsIDOMHTMLAnchorElement.h" -#include "nsIDOMHTMLImageElement.h" -#include "nsIDOMDocument.h" -#include "nsIDOMHTMLDocument.h" -#include "nsIDOMHTMLFrameSetElement.h" -#include "nsIPrompt.h" -#include "nsEmbedAPI.h" -#include "nsISHistory.h" -#include "nsISHEntry.h" -#include "nsIPref.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsIProfileChangeStatus.h" -#include "nsIObserverService.h" -#include "imgIContainer.h" -#ifdef MOZ_OLD_CACHE -#include "nsINetDataCacheManager.h" -#endif -#include "nsError.h" -#include "nsIObserver.h" -#include "nsWeakReference.h" -#include "nsIEmbeddingSiteWindow2.h" -#include "nsIWebBrowserFind.h" -#include "nsIWebBrowserFocus.h" -#include "nsIURI.h" - -// Printer Includes -#include "nsIWebBrowserPrint.h" -#include "nsIDOMWindow.h" - -// MfcEmbed #defines - -// USE_PROFILES - If defined, nsIProfile will be used which allows for -// multiple profiles. If not defined, a standalone directory service provider -// will be used to provide "profile" locations to one specified directory. -// In the case, the mozilla profile DLL is not needed. - -#define USE_PROFILES 1 - -#endif //_STDAFX_H diff --git a/mozilla/embedding/tests/mfcembed/components/Dialogs.cpp b/mozilla/embedding/tests/mfcembed/components/Dialogs.cpp deleted file mode 100644 index ec263e997b8..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/Dialogs.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" -#include "Dialogs.h" - -// File overview.... -// -// Contains dialog box code to support Alerts, Prompts such as -// password prompt and username/password prompts -// - -//--------------------------------------------------------------------------// -// CPromptDialog Stuff -//--------------------------------------------------------------------------// - -CPromptDialog::CPromptDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitPromptText, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal) - : CDialog(CPromptDialog::IDD, pParent), - m_bHasCheckBox(bHasCheck) -{ - if(pTitle) - m_csDialogTitle = pTitle; - if(pText) - m_csPromptText = pText; - if(pInitPromptText) - m_csPromptAnswer = pInitPromptText; - if(pCheckText) - m_csCheckBoxText = pCheckText; -} - -void CPromptDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPromptDialog) - DDX_Text(pDX, IDC_PROMPT_ANSWER, m_csPromptAnswer); - DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CPromptDialog, CDialog) - //{{AFX_MSG_MAP(CPromptDialog) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -int CPromptDialog::OnInitDialog() -{ - SetWindowText(m_csDialogTitle); - - CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT); - if(pWnd) - pWnd->SetWindowText(m_csPromptText); - - CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD); - if(pChk) - { - if (m_bHasCheckBox) - { - if(!m_csCheckBoxText.IsEmpty()) - pChk->SetWindowText(m_csCheckBoxText); - pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED); - } - else - { - // Hide the check box control if there's no label text - // This will be the case when we're not using single sign-on - pChk->ShowWindow(SW_HIDE); - } - } - - CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PROMPT_ANSWER); - if(pEdit) - { - pEdit->SetWindowText(m_csPromptAnswer); - pEdit->SetFocus(); - pEdit->SetSel(0, -1); - - return 0; // Returning "0" since we're explicitly setting focus - } - - return TRUE; -} - -//--------------------------------------------------------------------------// -// CPromptPasswordDialog Stuff -//--------------------------------------------------------------------------// - -CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitPasswordText, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal) - : CDialog(CPromptPasswordDialog::IDD, pParent), - m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal) -{ - if(pTitle) - m_csDialogTitle = pTitle; - if(pText) - m_csPromptText = pText; - if(pInitPasswordText) - m_csPassword = pInitPasswordText; - if(pCheckText) - m_csCheckBoxText = pCheckText; -} - -void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPromptPasswordDialog) - DDX_Text(pDX, IDC_PASSWORD, m_csPassword); - DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CPromptPasswordDialog, CDialog) - //{{AFX_MSG_MAP(CPromptPasswordDialog) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -int CPromptPasswordDialog::OnInitDialog() -{ - SetWindowText(m_csDialogTitle); - - CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT); - if(pWnd) - pWnd->SetWindowText(m_csPromptText); - - CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD); - if(pChk) - { - if (m_bHasCheckBox) - { - if(!m_csCheckBoxText.IsEmpty()) - pChk->SetWindowText(m_csCheckBoxText); - pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED); - } - else - { - // Hide the check box control if there's no label text - // This will be the case when we're not using single sign-on - pChk->ShowWindow(SW_HIDE); - } - } - - CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD); - if(pEdit) - { - pEdit->SetFocus(); - - return 0; // Returning "0" since we're explicitly setting focus - } - - return TRUE; -} - -//--------------------------------------------------------------------------// -// CPromptUsernamePasswordDialog Stuff -//--------------------------------------------------------------------------// - -CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitUsername, const TCHAR* pInitPassword, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal) - : CDialog(CPromptUsernamePasswordDialog::IDD, pParent), - m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal) -{ - if(pTitle) - m_csDialogTitle = pTitle; - if(pText) - m_csPromptText = pText; - if(pInitUsername) - m_csUserName = pInitUsername; - if(pInitPassword) - m_csPassword = pInitPassword; - if(pCheckText) - m_csCheckBoxText = pCheckText; -} - -void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPromptUsernamePasswordDialog) - DDX_Text(pDX, IDC_USERNAME, m_csUserName); - DDX_Text(pDX, IDC_PASSWORD, m_csPassword); - DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CPromptUsernamePasswordDialog, CDialog) - //{{AFX_MSG_MAP(CPromptUsernamePasswordDialog) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -int CPromptUsernamePasswordDialog::OnInitDialog() -{ - SetWindowText(m_csDialogTitle); - - CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT); - if(pWnd) - pWnd->SetWindowText(m_csPromptText); - - CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD); - if(pChk) - { - if(m_bHasCheckBox) - { - if (!m_csCheckBoxText.IsEmpty()) - pChk->SetWindowText(m_csCheckBoxText); - pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED); - } - else - { - pChk->ShowWindow(SW_HIDE); - } - } - - CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD); - if(pEdit) - { - pEdit->SetWindowText(m_csPassword); - } - - pEdit = (CEdit *)GetDlgItem(IDC_USERNAME); - if(pEdit) - { - pEdit->SetWindowText(m_csUserName); - pEdit->SetSel(0, -1); - - pEdit->SetFocus(); - - return 0; // Returning "0" since we're explicitly setting focus - } - - return TRUE; -} - -//--------------------------------------------------------------------------// -// CAlertCheckDialog Stuff -//--------------------------------------------------------------------------// - -CAlertCheckDialog::CAlertCheckDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pCheckText, int initCheckVal) - : CDialog(CAlertCheckDialog::IDD, pParent) -{ - if(pTitle) - m_csDialogTitle = pTitle; - if(pText) - m_csMsgText = pText; - if(pCheckText) - m_csCheckBoxText = pCheckText; - - m_bCheckBoxValue = initCheckVal; -} - -void CAlertCheckDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAlertCheckDialog) - DDX_Check(pDX, IDC_CHECKBOX, m_bCheckBoxValue); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAlertCheckDialog, CDialog) - //{{AFX_MSG_MAP(CAlertCheckDialog) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -int CAlertCheckDialog::OnInitDialog() -{ - SetWindowText(m_csDialogTitle); - - CWnd *pWnd = GetDlgItem(IDC_MSG_TEXT); - if(pWnd) - pWnd->SetWindowText(m_csMsgText); - - CButton *pChk = (CButton *)GetDlgItem(IDC_CHECKBOX); - if(pChk) - { - pChk->SetWindowText(m_csCheckBoxText); - pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED); - } - - return TRUE; -} - -//--------------------------------------------------------------------------// -// CConfirmCheckDialog Stuff -//--------------------------------------------------------------------------// - -CConfirmCheckDialog::CConfirmCheckDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pCheckText, int initCheckVal, - const TCHAR *pBtn1Text, const TCHAR *pBtn2Text, - const TCHAR *pBtn3Text) - : CDialog(CConfirmCheckDialog::IDD, pParent) -{ - if(pTitle) - m_csDialogTitle = pTitle; - if(pText) - m_csMsgText = pText; - if(pCheckText) - m_csCheckBoxText = pCheckText; - - m_bCheckBoxValue = initCheckVal; - - if(pBtn1Text) - m_csBtn1Text = pBtn1Text; - if(pBtn2Text) - m_csBtn2Text = pBtn2Text; - if(pBtn3Text) - m_csBtn3Text = pBtn3Text; -} - -void CConfirmCheckDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CConfirmCheckDialog) - DDX_Check(pDX, IDC_CHECKBOX, m_bCheckBoxValue); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CConfirmCheckDialog, CDialog) - //{{AFX_MSG_MAP(CConfirmCheckDialog) - ON_BN_CLICKED(IDC_BTN1, OnBtn1Clicked) - ON_BN_CLICKED(IDC_BTN2, OnBtn2Clicked) - ON_BN_CLICKED(IDC_BTN3, OnBtn3Clicked) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -int CConfirmCheckDialog::OnInitDialog() -{ - SetWindowText(m_csDialogTitle); - - CWnd *pWnd = GetDlgItem(IDC_MSG_TEXT); - if(pWnd) - pWnd->SetWindowText(m_csMsgText); - - CButton *pChk = (CButton *)GetDlgItem(IDC_CHECKBOX); - if(pChk) - { - if(m_csCheckBoxText.IsEmpty()) - { - pChk->ShowWindow(SW_HIDE); - } - else - { - pChk->SetWindowText(m_csCheckBoxText); - pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED); - } - } - - CButton *pBtn1 = (CButton *)GetDlgItem(IDC_BTN1); - if(pBtn1) - { - if(m_csBtn1Text.IsEmpty()) - pBtn1->ShowWindow(SW_HIDE); - else - pBtn1->SetWindowText(m_csBtn1Text); - } - - CButton *pBtn2 = (CButton *)GetDlgItem(IDC_BTN2); - if(pBtn2) - { - if(m_csBtn2Text.IsEmpty()) - pBtn2->ShowWindow(SW_HIDE); - else - pBtn2->SetWindowText(m_csBtn2Text); - } - - CButton *pBtn3 = (CButton *)GetDlgItem(IDC_BTN3); - if(pBtn3) - { - if(m_csBtn3Text.IsEmpty()) - pBtn3->ShowWindow(SW_HIDE); - else - pBtn3->SetWindowText(m_csBtn3Text); - } - - return TRUE; -} - -void CConfirmCheckDialog::OnBtn1Clicked() -{ - UpdateData(); - - EndDialog(0); // where 0 indicates that the btn pressed was at index 0 -} - -void CConfirmCheckDialog::OnBtn2Clicked() -{ - UpdateData(); - - EndDialog(1); // where 1 indicates that the btn pressed was at index 1 -} - -void CConfirmCheckDialog::OnBtn3Clicked() -{ - UpdateData(); - - EndDialog(2); // where 2 indicates that the btn pressed was at index 2 -} diff --git a/mozilla/embedding/tests/mfcembed/components/Dialogs.h b/mozilla/embedding/tests/mfcembed/components/Dialogs.h deleted file mode 100644 index 63f8e095ccc..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/Dialogs.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _DIALOGS_H_ -#define _DIALOGS_H_ - -#include "resource.h" - -class CPromptDialog : public CDialog -{ -public: - CPromptDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitPromptText, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal); - - // Dialog Data - enum { IDD = IDD_PROMPT_DIALOG }; - CString m_csPromptAnswer; - - CString m_csDialogTitle; - CString m_csPromptText; - BOOL m_bHasCheckBox; - CString m_csCheckBoxText; - int m_bCheckBoxValue; - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPromptDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); - //}}AFX_VIRTUAL - - //{{AFX_MSG(CPromptDialog) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -class CPromptPasswordDialog : public CDialog -{ -public: - CPromptPasswordDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitPasswordText, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal); - - // Dialog Data - enum { IDD = IDD_PROMPT_PASSWORD_DIALOG }; - - CString m_csDialogTitle; - CString m_csPromptText; - CString m_csPassword; - BOOL m_bHasCheckBox; - CString m_csCheckBoxText; - int m_bCheckBoxValue; - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPromptPasswordDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); - //}}AFX_VIRTUAL - - //{{AFX_MSG(CPromptPasswordDialog) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -class CPromptUsernamePasswordDialog : public CDialog -{ -public: - CPromptUsernamePasswordDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pInitUsername, const TCHAR* pInitPassword, - BOOL bHasCheck, const TCHAR* pCheckText, int initCheckVal); - - // Dialog Data - enum { IDD = IDD_PROMPT_USERPASS_DIALOG }; - - CString m_csDialogTitle; - CString m_csPromptText; - CString m_csUserNameLabel; - CString m_csPasswordLabel; - CString m_csPassword; - CString m_csUserName; - BOOL m_bHasCheckBox; - CString m_csCheckBoxText; - int m_bCheckBoxValue; - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPromptUsernamePasswordDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); - //}}AFX_VIRTUAL - - //{{AFX_MSG(CPromptUsernamePasswordDialog) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -class CAlertCheckDialog : public CDialog -{ -public: - CAlertCheckDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pCheckText, int initCheckVal); - - // Dialog Data - enum { IDD = IDD_ALERT_CHECK_DIALOG }; - - CString m_csDialogTitle; - CString m_csMsgText; - CString m_csCheckBoxText; - int m_bCheckBoxValue; - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAlertCheckDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); - //}}AFX_VIRTUAL - - //{{AFX_MSG(CAlertCheckDialog) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -class CConfirmCheckDialog : public CDialog -{ -public: - CConfirmCheckDialog(CWnd* pParent, const TCHAR* pTitle, const TCHAR* pText, - const TCHAR* pCheckText, int initCheckVal, - const TCHAR *pBtn1Text, const TCHAR *pBtn2Text, - const TCHAR *pBtn3Text); - - // Dialog Data - enum { IDD = IDD_CONFIRM_CHECK_DIALOG }; - - CString m_csDialogTitle; - CString m_csMsgText; - CString m_csCheckBoxText; - int m_bCheckBoxValue; - CString m_csBtn1Text; - CString m_csBtn2Text; - CString m_csBtn3Text; - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CConfirmCheckDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); - //}}AFX_VIRTUAL - - //{{AFX_MSG(CConfirmCheckDialog) - virtual BOOL OnInitDialog(); - afx_msg void OnBtn1Clicked(); - afx_msg void OnBtn2Clicked(); - afx_msg void OnBtn3Clicked(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -#endif //_DIALOG_H_ diff --git a/mozilla/embedding/tests/mfcembed/components/Dialogs.rc b/mozilla/embedding/tests/mfcembed/components/Dialogs.rc deleted file mode 100644 index 20972ea8e4e..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/Dialogs.rc +++ /dev/null @@ -1,214 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\mfcembed.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 92 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Prompt Dialog" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,130,69,50,14 - PUSHBUTTON "Cancel",IDCANCEL,189,69,50,14 - LTEXT "Please enter something....",IDC_PROMPT_TEXT,10,7,229,29 - EDITTEXT IDC_PROMPT_ANSWER,7,39,232,13,ES_AUTOHSCROLL - CONTROL "Save Answer",IDC_CHECK_SAVE_PASSWORD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10 -END - -IDD_PROMPT_PASSWORD_DIALOG DIALOG DISCARDABLE 0, 0, 248, 93 -STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -CAPTION "Password Entry Dialog" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Please enter your password:",IDC_PROMPT_TEXT,5,7,232,20 - DEFPUSHBUTTON "OK",IDOK,129,75,50,14 - PUSHBUTTON "Cancel",IDCANCEL,188,75,50,14 - EDITTEXT IDC_PASSWORD,5,37,233,12,ES_PASSWORD | ES_AUTOHSCROLL - CONTROL "Save Password",IDC_CHECK_SAVE_PASSWORD,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10 -END - -IDD_PROMPT_USERPASS_DIALOG DIALOG DISCARDABLE 0, 0, 214, 123 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Username and Password Required" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "This operation requires authentication. Please enter your user name and password:", - IDC_PROMPT_TEXT,6,9,171,25 - LTEXT "User Name:",IDC_USERNAME_LABEL,6,39,39,9 - EDITTEXT IDC_USERNAME,49,39,153,12,ES_AUTOHSCROLL - LTEXT "Password:",IDC_PASSWORD_LABEL,6,58,36,8 - EDITTEXT IDC_PASSWORD,49,56,153,12,ES_PASSWORD | ES_AUTOHSCROLL - CONTROL "Save User Name and Password",IDC_CHECK_SAVE_PASSWORD, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10 - DEFPUSHBUTTON "OK",IDOK,40,101,50,14 - PUSHBUTTON "Cancel",IDCANCEL,95,101,50,14 -END - -IDD_ALERT_CHECK_DIALOG DIALOG DISCARDABLE 0, 0, 233, 151 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Alert" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,91,127,50,14 - CONTROL "",IDC_CHECKBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10, - 104,215,10 - EDITTEXT IDC_MSG_TEXT,10,10,214,88,ES_MULTILINE | ES_READONLY -END - -IDD_CONFIRM_CHECK_DIALOG DIALOG DISCARDABLE 0, 0, 371, 111 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "ConfirmCheck" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Btn1",IDC_BTN1,104,90,50,14 - CONTROL "",IDC_CHECKBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, - 62,355,10 - LTEXT "",IDC_MSG_TEXT,6,10,354,39 - DEFPUSHBUTTON "Btn2",IDC_BTN2,164,89,50,14 - DEFPUSHBUTTON "Btn3",IDC_BTN3,224,89,50,14 -END - -IDD_PROGRESS_DIALOG DIALOG DISCARDABLE 0, 0, 285, 95 -STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -CAPTION "Saving File" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "Cancel",IDCANCEL,115,73,50,14 - LTEXT "Action:",IDC_STATIC,27,23,26,9 - CONTROL "",IDC_ACTION,"Static",SS_LEFTNOWORDWRAP | - WS_GROUP,59,23,211,8 - LTEXT "Saving From:",IDC_STATIC,7,6,42,8 - LTEXT "",IDC_SAVING_FROM,59,6,213,8 - LTEXT "Progress:",IDC_STATIC,19,41,30,8 - CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | - WS_BORDER,59,41,166,10 - LTEXT "100%",IDC_STATIC,229,42,18,8 -END - -IDD_CHOOSE_ACTION_DIALOG DIALOG DISCARDABLE 0, 0, 285, 114 -STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -CAPTION "Choose An Action" -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "You have chosen to download a file of type: ", - IDC_STATIC,8,9,142,8 - LTEXT "Static",IDC_CONTENT_TYPE,152,10,123,8 - GROUPBOX "What would you like MfcEmbed to do with this file?", - IDC_STATIC,8,24,268,61 - CONTROL "O&pen using",IDC_OPEN_USING,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,19,41,60,10 - CONTROL "&Save this file to disk",IDC_SAVE_TO_DISK,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,19,69,103,10 - LTEXT "Static",IDC_APP_NAME,31,53,186,9,SS_SUNKEN - PUSHBUTTON "&Choose...",IDC_CHOOSE_APP,222,51,50,12 - PUSHBUTTON "Ok",IDOK,94,94,50,14 - PUSHBUTTON "Cancel",IDCANCEL,150,94,50,14 -END - -IDD_PRINT_PROGRESS_DIALOG DIALOG DISCARDABLE 0, 0, 294, 53 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Print Progress" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "Cancel",IDCANCEL,237,36,50,14 - RTEXT "URL:",IDC_PRINT_PROGRESS_URL_LABEL_TXT,7,7,30,8 - LTEXT "...",IDC_PRINT_PROGRESS_URL_TXT,41,7,231,8 - RTEXT "Progress:",IDC_STATIC,7,18,30,8 - CONTROL "Progress1",IDC_PRINT_PROGRESS_PRG,"msctls_progress32", - WS_BORDER,41,18,217,8 - LTEXT "Preparing...",IDC_PRINT_PROGRESS_TXT,41,18,217,8 - LTEXT "",IDC_PRINT_PROGRESS_PERCENT_TXT,264,18,19,8 -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.cpp b/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.cpp deleted file mode 100644 index 8ebbd7d00c5..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.cpp +++ /dev/null @@ -1,606 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#include "stdafx.h" -#include "HelperAppService.h" -#include "HelperAppDlg.h" -#include "nsCOMPtr.h" -#include "nsString.h" -#include "nsILocalFile.h" -#include "nsIURI.h" -#include "nsNetError.h" -#include "nsIMIMEInfo.h" -#include "nsIDOMWindow.h" -#include "nsIEmbeddingSiteWindow.h" -#include "nsIServiceManager.h" -#include "nsIWebBrowserChrome.h" -#include "nsIInterfaceRequestor.h" -#include "nsIInterfaceRequestorUtils.h" - -// This file contains code which overrides the default -// Gecko implementation for helper app dialog handling -// -// General Overview: -// -// We register the factory object for overriding helper app dialogs -// [See OverrideComponents() in mfcembed.cpp] -// -// -// When Gecko encounters content it cannot handle it will: -// 1. Call CHelperAppLauncherDialog::Show() method -// -// 2. If the user chooses SaveToDisk in the dialog presented by -// step 1, then CHelperAppLauncherDialog::PromptForSaveToFile() -// will be called to get the filename to save the content to -// -// If the user chooses OpenUsingAnExternalApp option in the -// dialog box(and subsequnetly specifies the app to use by -// clicking on the "Choose..." button), the specified app -// is run after the content is downloaded -// -// 3. In either case, an instance of nsIProgressDialog will be created -// which is used to display a download progress -// dialog box. This dialog box registers itself as a -// WebProgressListener so that it can receive the progress change -// messages, using which it can update the progress bar -// -// 4. The downloads can be cancelled by clicking on the "Cancel" button -// at anytime during the download. - -static HINSTANCE gInstance; - -//***************************************************************************** -// ResourceState -//***************************************************************************** - -class ResourceState { -public: - ResourceState() { - mPreviousInstance = ::AfxGetResourceHandle(); - ::AfxSetResourceHandle(gInstance); - } - ~ResourceState() { - ::AfxSetResourceHandle(mPreviousInstance); - } -private: - HINSTANCE mPreviousInstance; -}; - -//***************************************************************************** -// CHelperAppLauncherDialogFactory Creation and Init Functions -//***************************************************************************** - -void InitHelperAppDlg(HINSTANCE instance) -{ - gInstance = instance; -} - -nsresult NS_NewHelperAppDlgFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - CHelperAppLauncherDialogFactory *result = new CHelperAppLauncherDialogFactory; - if (!result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} - -//***************************************************************************** -// CHelperAppLauncherDialogFactory -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(CHelperAppLauncherDialogFactory, nsIFactory) - -CHelperAppLauncherDialogFactory::CHelperAppLauncherDialogFactory() -{ -} - -CHelperAppLauncherDialogFactory::~CHelperAppLauncherDialogFactory() { -} - -NS_IMETHODIMP CHelperAppLauncherDialogFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = NULL; - CHelperAppLauncherDialog *inst = new CHelperAppLauncherDialog; - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - if (rv != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } - - return rv; -} - -NS_IMETHODIMP CHelperAppLauncherDialogFactory::LockFactory(PRBool lock) -{ - return NS_OK; -} - -//******************************************************************************* -// CHelperAppLauncherDialog - Implements the nsIHelperAppLauncherDialog interface -//******************************************************************************* - -NS_IMPL_ISUPPORTS1(CHelperAppLauncherDialog, nsIHelperAppLauncherDialog) - -CHelperAppLauncherDialog::CHelperAppLauncherDialog() : - mWWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)) -{ -} - -CHelperAppLauncherDialog::~CHelperAppLauncherDialog() -{ -} - -// Returns a CWnd given aWindowContext - the returned CWnd is mainly used as -// a parent window for the dialog boxes we display -// -CWnd* CHelperAppLauncherDialog::GetParentFromContext(nsISupports *aWindowContext) -{ - nsCOMPtr domWnd(do_GetInterface(aWindowContext)); - if(!domWnd) - return NULL; - - CWnd *retWnd = NULL; - - nsCOMPtr chrome; - if(mWWatch) - { - nsCOMPtr fosterParent; - if (!domWnd) - { // it will be a dependent window. try to find a foster parent. - mWWatch->GetActiveWindow(getter_AddRefs(fosterParent)); - domWnd = fosterParent; - } - mWWatch->GetChromeForWindow(domWnd, getter_AddRefs(chrome)); - } - - if (chrome) - { - nsCOMPtr site(do_QueryInterface(chrome)); - if (site) - { - HWND w; - site->GetSiteWindow(reinterpret_cast(&w)); - retWnd = CWnd::FromHandle(w); - } - } - - return retWnd; -} - -// Displays the "Save To Disk" or "Open Using..." dialog box -// when Gecko encounters a mime type it cannot handle -// -NS_IMETHODIMP CHelperAppLauncherDialog::Show(nsIHelperAppLauncher *aLauncher, - nsISupports *aContext, - PRUint32 aReason) -{ - ResourceState setState; - - NS_ENSURE_ARG_POINTER(aLauncher); - - CChooseActionDlg dlg(aLauncher, GetParentFromContext(aContext)); - if(dlg.DoModal() == IDCANCEL) - { - // User chose Cancel - just cancel the download - - aLauncher->Cancel(NS_BINDING_ABORTED); - - return NS_OK; - } - - // User did not cancel out of the dialog box i.e. OK was chosen - - if(dlg.m_ActionChosen == CONTENT_SAVE_TO_DISK) - { - m_HandleContentOp = CONTENT_SAVE_TO_DISK; - - return aLauncher->SaveToDisk(nsnull, PR_FALSE); - } - else - { - m_HandleContentOp = CONTENT_LAUNCH_WITH_APP; - - m_FileName = dlg.m_OpenWithAppName; - - USES_CONVERSION; - nsCAutoString fileName(T2CA(m_FileName)); - - nsCOMPtr openWith; - nsresult rv = NS_NewNativeLocalFile(fileName, PR_FALSE, getter_AddRefs(openWith)); - if (NS_FAILED(rv)) - return aLauncher->LaunchWithApplication(nsnull, PR_FALSE); - else - return aLauncher->LaunchWithApplication(openWith, PR_FALSE); - } -} - -// User chose the "Save To Disk" option in the dialog before -// We prompt the user for the filename to which the content -// will be saved into -// -NS_IMETHODIMP CHelperAppLauncherDialog::PromptForSaveToFile(nsIHelperAppLauncher* aLauncher, - nsISupports *aWindowContext, - const PRUnichar *aDefaultFile, - const PRUnichar *aSuggestedFileExtension, - nsILocalFile **_retval) -{ - USES_CONVERSION; - - NS_ENSURE_ARG_POINTER(_retval); - - TCHAR *lpszFilter = _T("All Files (*.*)|*.*||"); - CFileDialog cf(FALSE, W2CT(aSuggestedFileExtension), W2CT(aDefaultFile), - OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, GetParentFromContext(aWindowContext)); - if(cf.DoModal() == IDOK) - { - m_FileName = cf.GetPathName(); // Will be like: c:\tmp\junk.exe - USES_CONVERSION; - nsCAutoString fileName(T2CA(m_FileName)); - return NS_NewNativeLocalFile(fileName, PR_FALSE, _retval); - } - else - return NS_ERROR_FAILURE; -} - -//***************************************************************************** -// CChooseActionDlg -//***************************************************************************** - -CChooseActionDlg::CChooseActionDlg(nsIHelperAppLauncher *aLauncher, CWnd* pParent /*=NULL*/) - : CDialog(CChooseActionDlg::IDD, pParent) -{ - m_HelperAppLauncher = aLauncher; -} - -void CChooseActionDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - - DDX_Control(pDX, IDC_CONTENT_TYPE, m_ContentType); -} - -BOOL CChooseActionDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Get the mimeInfo from nsIHelperAppLauncher - // - nsCOMPtr mimeInfo; - if(m_HelperAppLauncher) - m_HelperAppLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo)); - - if(mimeInfo) - { - // Retrieve and set the Mime type of the content we're downloading - // in the content type field of the dialog box - // - nsCAutoString mimeType; - nsresult rv = mimeInfo->GetMIMEType(mimeType); - if(NS_SUCCEEDED(rv)) - { - CStatic *pMimeType = (CStatic *)GetDlgItem(IDC_CONTENT_TYPE); - if(pMimeType) - { - USES_CONVERSION; - pMimeType->SetWindowText(A2CT(mimeType.get())); - } - } - - // See if we can get the preferred action from the mime info - // and init the controls accordingly - // - InitWithPreferredAction(mimeInfo); - } - else - SelectSaveToDiskOption(); - - return FALSE; // return TRUE unless you set the focus to a control -} - -// See if we can determine the default handling action, if any, -// from aMimeInfo -// If not, simply select SaveToDisk as the default -// -void CChooseActionDlg::InitWithPreferredAction(nsIMIMEInfo* aMimeInfo) -{ - // Retrieve and set the specified default action - // - nsMIMEInfoHandleAction prefAction = nsIMIMEInfo::saveToDisk; - aMimeInfo->GetPreferredAction(&prefAction); - if(prefAction == nsIMIMEInfo::saveToDisk) - { - SelectSaveToDiskOption(); - return; - } - - // OpenWithApp is the preferred action - select it - // - SelectOpenUsingAppOption(); - - // See if we can get the appname - // - nsAutoString appDesc; - nsresult rv = aMimeInfo->GetApplicationDescription(appDesc); - if(NS_SUCCEEDED(rv)) - { - USES_CONVERSION; - m_OpenWithAppName = W2CT(appDesc.get()); - - // Update with the app name - // - UpdateAppNameField(m_OpenWithAppName); - } -} - -void CChooseActionDlg::UpdateAppNameField(CString& appName) -{ - CStatic *pAppName = (CStatic *)GetDlgItem(IDC_APP_NAME); - if(pAppName) - pAppName->SetWindowText(appName); -} - -void CChooseActionDlg::SelectSaveToDiskOption() -{ - CButton *pRadioSaveToDisk = (CButton *)GetDlgItem(IDC_SAVE_TO_DISK); - if(pRadioSaveToDisk) - { - pRadioSaveToDisk->SetCheck(1); - - pRadioSaveToDisk->SetFocus(); - - OnSaveToDiskRadioBtnClicked(); - } -} - -void CChooseActionDlg::SelectOpenUsingAppOption() -{ - CButton *pRadioOpenUsing = (CButton *)GetDlgItem(IDC_OPEN_USING); - if(pRadioOpenUsing) - { - pRadioOpenUsing->SetCheck(1); - - pRadioOpenUsing->SetFocus(); - - OnOpenUsingRadioBtnClicked(); - } -} - -void CChooseActionDlg::EnableChooseBtn(BOOL bEnable) -{ - CButton *pChooseBtn = (CButton *)GetDlgItem(IDC_CHOOSE_APP); - if(pChooseBtn) - { - pChooseBtn->EnableWindow(bEnable); - } -} - -void CChooseActionDlg::EnableAppName(BOOL bEnable) -{ - CStatic *pAppName = (CStatic *)GetDlgItem(IDC_APP_NAME); - if(pAppName) - { - pAppName->EnableWindow(bEnable); - } -} - -void CChooseActionDlg::OnOpenUsingRadioBtnClicked() -{ - EnableChooseBtn(TRUE); - EnableAppName(TRUE); -} - -void CChooseActionDlg::OnSaveToDiskRadioBtnClicked() -{ - EnableChooseBtn(FALSE); - EnableAppName(FALSE); -} - -void CChooseActionDlg::OnChooseAppClicked() -{ - TCHAR *lpszFilter = - _T("EXE Files Only (*.exe)|*.exe|") - _T("All Files (*.*)|*.*||"); - - CFileDialog cf(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - lpszFilter, this); - if(cf.DoModal() == IDOK) - { - m_OpenWithAppName = cf.GetPathName(); // Will be like: c:\tmp\junk.exe - - UpdateAppNameField(m_OpenWithAppName); - } -} - -void CChooseActionDlg::OnOK() -{ - CButton *pRadioOpenWithApp = (CButton *)GetDlgItem(IDC_OPEN_USING); - - if(pRadioOpenWithApp->GetCheck()) - { - // Do not allow to leave the dialog if the OpenWithAnApp option - // is selected and the the name of the app is unknown/empty - // - if(m_OpenWithAppName.IsEmpty()) - { - ::MessageBox(this->m_hWnd, - _T("You have chosen to open the content with an external application, but,\nno application has been specified.\n\nPlease click the Choose... button to select an application"), - _T("MfcEmbed"), MB_OK); - return; - } - else - m_ActionChosen = CONTENT_LAUNCH_WITH_APP; - } - else - m_ActionChosen = CONTENT_SAVE_TO_DISK; - - CDialog::OnOK(); -} - -void CChooseActionDlg::OnCancel() -{ - CDialog::OnCancel(); -} - -BEGIN_MESSAGE_MAP(CChooseActionDlg, CDialog) - ON_BN_CLICKED(IDC_CHOOSE_APP, OnChooseAppClicked) - ON_BN_CLICKED(IDC_SAVE_TO_DISK, OnSaveToDiskRadioBtnClicked) - ON_BN_CLICKED(IDC_OPEN_USING, OnOpenUsingRadioBtnClicked) -END_MESSAGE_MAP() - -//***************************************************************************** -// CProgressDlg -//***************************************************************************** - -NS_IMPL_ISUPPORTS2(CProgressDlg, nsIWebProgressListener, nsISupportsWeakReference) - -CProgressDlg::CProgressDlg(nsIHelperAppLauncher *aLauncher, int aHandleContentOp, - CString& aFileName, CWnd* pParent /*=NULL*/) - : CDialog(CProgressDlg::IDD, pParent) -{ - m_HelperAppLauncher = aLauncher; - m_HandleContentOp = aHandleContentOp; - m_FileName = aFileName; -} - -CProgressDlg::~CProgressDlg() -{ -} - -NS_IMETHODIMP CProgressDlg::OnStateChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, PRUint32 aStateFlags, - nsresult aStatus) -{ - if((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_DOCUMENT)) - { - // We've completed the download - close the progress window - - if(m_HelperAppLauncher) - m_HelperAppLauncher->CloseProgressWindow(); - - DestroyWindow(); - } - - return NS_OK; -} - -NS_IMETHODIMP CProgressDlg::OnProgressChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, - PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) -{ - // Update the progress control - - if(::IsWindow(m_ProgressCtrl.m_hWnd)) - { - m_ProgressCtrl.SetRange32(0, aMaxTotalProgress); - m_ProgressCtrl.SetPos(aCurTotalProgress); - } - - return NS_OK; -} - -NS_IMETHODIMP CProgressDlg::OnLocationChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, nsIURI *location) -{ - return NS_OK; -} - -NS_IMETHODIMP CProgressDlg::OnStatusChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, nsresult aStatus, - const PRUnichar *aMessage) -{ - return NS_OK; -} - -NS_IMETHODIMP CProgressDlg::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, PRUint32 state) -{ - return NS_OK; -} - -BOOL CProgressDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Set the "SavingFrom" field - if(m_HelperAppLauncher) - { - nsCOMPtr srcUri; - nsresult rv = m_HelperAppLauncher->GetSource(getter_AddRefs(srcUri)); - if(NS_SUCCEEDED(rv)) - { - nsCAutoString uriString; - srcUri->GetSpec(uriString); - USES_CONVERSION; - m_SavingFrom.SetWindowText(A2CT(uriString.get())); - } - } - - // Set the "Action" field - if(m_HandleContentOp == CONTENT_SAVE_TO_DISK) - m_Action.SetWindowText(_T("[Saving file to:] ") + m_FileName); - else if(m_HandleContentOp == CONTENT_LAUNCH_WITH_APP) - m_Action.SetWindowText(_T("[Opening file with:] ") + m_FileName); - - return TRUE; -} - -void CProgressDlg::OnCancel() -{ - if(m_HelperAppLauncher) - m_HelperAppLauncher->Cancel(NS_BINDING_ABORTED); - - DestroyWindow(); -} - -void CProgressDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - - DDX_Control(pDX, IDC_PROGRESS, m_ProgressCtrl); - DDX_Control(pDX, IDC_SAVING_FROM, m_SavingFrom); - DDX_Control(pDX, IDC_ACTION, m_Action); -} - -BEGIN_MESSAGE_MAP(CProgressDlg, CDialog) -END_MESSAGE_MAP() diff --git a/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.h b/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.h deleted file mode 100644 index 2d151623d14..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/HelperAppDlg.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __HelperAppDlg_h -#define __HelperAppDlg_h - -#include "nsError.h" -#include "resource.h" -#include "nsIFactory.h" -#include "nsIExternalHelperAppService.h" -#include "nsIHelperAppLauncherDialog.h" -#include "nsIWebProgressListener.h" -#include "nsWeakReference.h" -#include "nsIWindowWatcher.h" - -// this component is for an MFC app; it's Windows. make sure this is defined. -#ifndef XP_WIN -#define XP_WIN -#endif - -class CHelperAppLauncherDialogFactory : public nsIFactory { -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - - CHelperAppLauncherDialogFactory(); - virtual ~CHelperAppLauncherDialogFactory(); -}; - -enum { - CONTENT_SAVE_TO_DISK, - CONTENT_LAUNCH_WITH_APP -}; - -// This class implements the nsIHelperAppLauncherDialog interface -// -class CHelperAppLauncherDialog : public nsIHelperAppLauncherDialog { -public: - CHelperAppLauncherDialog(); - virtual ~CHelperAppLauncherDialog(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIHELPERAPPLAUNCHERDIALOG - - int m_HandleContentOp; - CString m_FileName; - -private: - nsCOMPtr mWWatch; - CWnd* GetParentFromContext(nsISupports *aWindowContext); -}; - -// This class implements a download progress dialog -// which displays the progress of a file download -// -class CProgressDlg : public CDialog, - public nsIWebProgressListener, - public nsSupportsWeakReference -{ -public: - enum { IDD = IDD_PROGRESS_DIALOG }; - - CProgressDlg(nsIHelperAppLauncher *aLauncher, int aHandleContentOp, - CString& aFileName, CWnd* pParent = NULL); - virtual ~CProgressDlg(); - - int m_HandleContentOp; - CString m_FileName; - CStatic m_SavingFrom; - CStatic m_Action; - CProgressCtrl m_ProgressCtrl; - - nsCOMPtr m_HelperAppLauncher; - - NS_DECL_ISUPPORTS - NS_DECL_NSIWEBPROGRESSLISTENER - -protected: - virtual void DoDataExchange(CDataExchange* pDX); - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - - DECLARE_MESSAGE_MAP() -}; - -// This class implements a dialog box which gives the user -// a choice of saving the content being downloaded to disk -// or to open with an external application -// -class CChooseActionDlg : public CDialog -{ -public: - CChooseActionDlg(nsIHelperAppLauncher* aLauncher, CWnd* pParent = NULL); - - enum { IDD = IDD_CHOOSE_ACTION_DIALOG }; - CStatic m_ContentType; - - int m_ActionChosen; - CString m_OpenWithAppName; - nsCOMPtr m_HelperAppLauncher; - -protected: - virtual void DoDataExchange(CDataExchange* pDX); - -protected: - virtual BOOL OnInitDialog(); - afx_msg void OnChooseAppClicked(); - virtual void OnOK(); - virtual void OnCancel(); - afx_msg void OnOpenUsingRadioBtnClicked(); - afx_msg void OnSaveToDiskRadioBtnClicked(); - - void EnableAppName(BOOL bEnable); - void EnableChooseBtn(BOOL bEnable); - void InitWithPreferredAction(nsIMIMEInfo* aMimeInfo); - void SelectSaveToDiskOption(); - void SelectOpenUsingAppOption(); - void UpdateAppNameField(CString& appName); - - DECLARE_MESSAGE_MAP() -}; - -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/HelperAppService.h b/mozilla/embedding/tests/mfcembed/components/HelperAppService.h deleted file mode 100644 index 87279f164e1..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/HelperAppService.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __HelperAppService_h -#define __HelperAppService_h - -#include "nsError.h" - -// this component is for an MFC app; it's Windows. make sure this is defined. -#ifndef XP_WIN -#define XP_WIN -#endif - -class nsIFactory; - -// factory creator, in hard and soft link formats -extern "C" NS_EXPORT nsresult NS_NewHelperAppDlgFactory(nsIFactory** aFactory); -typedef nsresult (__cdecl *MakeFactoryType)(nsIFactory **); -#define kHelperAppDlgFactoryFuncName "NS_NewHelperAppDlgFactory" - -// initialization function, in hard and soft link formats -extern "C" NS_EXPORT void InitHelperAppDlg(HINSTANCE instance); -typedef nsresult (__cdecl *InitHelperAppDlgType)(HINSTANCE instance); -#define kHelperAppDlgInitFuncName "InitHelperAppDlg" - -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/Makefile.in b/mozilla/embedding/tests/mfcembed/components/Makefile.in deleted file mode 100644 index cc7f2df10ff..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/Makefile.in +++ /dev/null @@ -1,91 +0,0 @@ -# ***** 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 ***** - -DEPTH = ../../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBRARY_NAME = mfcEmbedComponents -RESFILE = Dialogs.res -MOZILLA_INTERNAL_API = 1 - -REQUIRES = \ - xpcom \ - string \ - dom \ - content \ - layout \ - gfx \ - widget \ - pref \ - intl \ - webbrwsr \ - windowwatcher \ - exthandler \ - uriloader \ - necko \ - mimetype \ - $(NULL) - -CPPSRCS = \ - nsPrintDialogUtil.cpp \ - nsPrintProgressParams.cpp \ - PrintingPromptService.cpp \ - PrintProgressDialog.cpp \ - Dialogs.cpp \ - PromptService.cpp \ - HelperAppDlg.cpp \ - $(NULL) - -EXTRA_DSO_LIBS = gkgfx - -EXTRA_DSO_LDOPTS += \ - $(EXTRA_DSO_LIBS) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(NULL) - -FORCE_SHARED_LIB = 1 - -include $(topsrcdir)/config/rules.mk - -# UNICODE -ifdef BUILD_UNICODE_MFCEMBED -CXXFLAGS += -D "_UNICODE" -endif - -CXXFLAGS += -D "_AFXDLL" -D "USE_SINGLE_SIGN_ON" -D "_WINDLL" -LDFLAGS += -SUBSYSTEM:windows - -Dialogs.res: Dialogs.rc resource.h - diff --git a/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.cpp b/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.cpp deleted file mode 100644 index d86a2d1e05f..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// PrintProgressDialog.cpp : implementation file -// - -#include "stdafx.h" -//#include "mfcembed.h" -#include "PrintProgressDialog.h" -//#include "BrowserView.h" -#include "nsIWebBrowser.h" -#include "nsIWebBrowserPrint.h" -#include "nsIInterfaceRequestorUtils.h" - -#include "nsMemory.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPrintProgressDialog dialog - -class CDlgPrintListener : public nsIWebProgressListener -{ -// Construction -public: - CDlgPrintListener(CPrintProgressDialog* aDlg); - - NS_DECL_ISUPPORTS - NS_DECL_NSIWEBPROGRESSLISTENER - - void ClearDlg() { m_PrintDlg = NULL; } // weak reference - -// Implementation -protected: - CPrintProgressDialog* m_PrintDlg; -}; - -NS_IMPL_ADDREF(CDlgPrintListener) -NS_IMPL_RELEASE(CDlgPrintListener) - -NS_INTERFACE_MAP_BEGIN(CDlgPrintListener) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebProgressListener) - NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) -NS_INTERFACE_MAP_END - - -CDlgPrintListener::CDlgPrintListener(CPrintProgressDialog* aDlg) : - m_PrintDlg(aDlg) -{ -} - -/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */ -NS_IMETHODIMP -CDlgPrintListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) -{ - if (m_PrintDlg) { - if (aStateFlags == (nsIWebProgressListener::STATE_START|nsIWebProgressListener::STATE_IS_DOCUMENT)) { - return m_PrintDlg->OnStartPrinting(); - - } else if (aStateFlags == (nsIWebProgressListener::STATE_STOP|nsIWebProgressListener::STATE_IS_DOCUMENT)) { - return m_PrintDlg->OnEndPrinting(aStatus); - } - } - return NS_OK; -} - -/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */ -NS_IMETHODIMP -CDlgPrintListener::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) -{ - if (m_PrintDlg) { - return m_PrintDlg->OnProgressPrinting(aCurSelfProgress, aMaxSelfProgress); - } - return NS_OK; -} - -/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */ -NS_IMETHODIMP -CDlgPrintListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location) -{ - return NS_OK; -} - -/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */ -NS_IMETHODIMP -CDlgPrintListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage) -{ - return NS_OK; -} - -/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */ -NS_IMETHODIMP -CDlgPrintListener::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state) -{ - return NS_OK; -} - - -///////////////////////////////////////////////////////////////////////////// -// CPrintProgressDialog dialog - - -CPrintProgressDialog::CPrintProgressDialog(CWnd* pParent, - BOOL aIsForPrinting, - nsIPrintProgressParams* aPPParams, - nsIWebBrowserPrint* aWebBrowserPrint, - nsIPrintSettings* aPrintSettings) - : CDialog(CPrintProgressDialog::IDD, pParent), - m_WebBrowserPrint(aWebBrowserPrint), - m_PPParams(aPPParams), - m_PrintListener(nsnull), - m_PrintSettings(aPrintSettings), - m_HasStarted(FALSE), - m_IsForPrinting(aIsForPrinting) -{ - //{{AFX_DATA_INIT(CPrintProgressDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -CPrintProgressDialog::~CPrintProgressDialog() -{ - CDlgPrintListener * pl = (CDlgPrintListener*)m_PrintListener.get(); - if (pl) { - pl->ClearDlg(); - } -} - - -void CPrintProgressDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPrintProgressDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CPrintProgressDialog, CDialog) - //{{AFX_MSG_MAP(CPrintProgressDialog) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPrintProgressDialog message handlers - -BOOL CPrintProgressDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd* cancelBtn = (CWnd*)GetDlgItem(IDCANCEL); - if (cancelBtn) - { - if (m_IsForPrinting) - { - cancelBtn->EnableWindow(FALSE); - } else { - cancelBtn->ShowWindow(SW_HIDE); - SetWindowText(_T("Print Preview")); - } - } - - SetDocAndURL(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -/* void OnStartPrinting (); */ -NS_IMETHODIMP -CPrintProgressDialog::OnStartPrinting() -{ - CProgressCtrl* progressCtrl = (CProgressCtrl *)GetDlgItem(IDC_PRINT_PROGRESS_PRG); - CWnd* progressText = (CWnd*)GetDlgItem(IDC_PRINT_PROGRESS_TXT); - if (!progressCtrl || !progressText) return NS_OK; - - m_HasStarted = TRUE; - progressCtrl->ShowWindow(SW_HIDE); - - SetDocAndURL(); - - return NS_OK; -} - -/* void OnProgressPrinting (in PRUint32 aProgress, in PRUint32 aProgressMax); */ -NS_IMETHODIMP -CPrintProgressDialog::OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax) -{ - CProgressCtrl* progressCtrl = (CProgressCtrl *)GetDlgItem(IDC_PRINT_PROGRESS_PRG); - CWnd* progressText = (CWnd*)GetDlgItem(IDC_PRINT_PROGRESS_TXT); - if (!progressCtrl || !progressText) return NS_OK; - - if (m_HasStarted && aProgress != 100) - { - progressText->ShowWindow(SW_HIDE); - progressCtrl->ShowWindow(SW_SHOW); - progressCtrl->SetRange(0, aProgressMax); - m_HasStarted = FALSE; - progressText->UpdateWindow(); - } - - SetDocAndURL(); - - // Initialize the progress meter we we get the "zero" progress - // which also tells us the max progress - if (aProgress == 0) { - progressCtrl->SetRange(0, aProgressMax); - progressCtrl->SetPos(0); - - } - CWnd* cancelBtn = (CWnd*)GetDlgItem(IDCANCEL); - if (cancelBtn && m_IsForPrinting) - { - cancelBtn->EnableWindow(TRUE); - } - progressCtrl->SetPos(aProgress); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); - - return NS_OK; -} - -/* void OnEndPrinting (in PRUint32 aStatus); */ -NS_IMETHODIMP -CPrintProgressDialog::OnEndPrinting(PRUint32 aStatus) -{ - return NS_OK; -} - -void CPrintProgressDialog::OnCancel() -{ - if (m_WebBrowserPrint) { - m_WebBrowserPrint->Cancel(); - } - - CDialog::OnCancel(); -} - -void CPrintProgressDialog::SetDocAndURL() -{ - USES_CONVERSION; - - if (m_PPParams) - { - PRUnichar* docTitle = nsnull; - PRUnichar* urlStr = nsnull; - m_PPParams->GetDocTitle(&docTitle); - m_PPParams->GetDocURL(&urlStr); - - if (docTitle) - { - if (*docTitle && W2T(docTitle)) - { - SetWindowText(W2T(docTitle)); - } - nsMemory::Free(docTitle); - } - - if (urlStr) - { - if (*urlStr && W2T(urlStr)) - { - CWnd *pWnd = GetDlgItem(IDC_PRINT_PROGRESS_URL_TXT); - if (pWnd) - { - pWnd->SetWindowText(W2T(urlStr)); - } - } - nsMemory::Free(urlStr); - } - } - Invalidate(); - UpdateWindow(); -} diff --git a/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.h b/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.h deleted file mode 100644 index 31db9edc0a8..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PrintProgressDialog.h +++ /dev/null @@ -1,74 +0,0 @@ -#if !defined(AFX_PRINTPROGRESSDIALOG_H__1E3AA1B5_B8BB_4B25_86A5_A90E663D137F__INCLUDED_) -#define AFX_PRINTPROGRESSDIALOG_H__1E3AA1B5_B8BB_4B25_86A5_A90E663D137F__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// PrintProgressDialog.h : header file -// - -#include "resource.h" -#include "nsIWebProgressListener.h" -#include "nsIWebBrowserPrint.h" -#include "nsIPrintSettings.h" -#include "nsIPrintProgressParams.h" -#include "nsCOMPtr.h" - -///////////////////////////////////////////////////////////////////////////// -// CPrintProgressDialog dialog - -class CPrintProgressDialog : public CDialog -{ -// Construction -public: - CPrintProgressDialog(CWnd* pParent, - BOOL aIsForPrinting, - nsIPrintProgressParams* aPPParams, - nsIWebBrowserPrint* aWebBrowserPrint, - nsIPrintSettings* aPrintSettings); - virtual ~CPrintProgressDialog(); - - // Helper - void SetDocAndURL(); - - NS_IMETHOD OnStartPrinting(void); - NS_IMETHOD OnProgressPrinting(PRUint32 aProgress, PRUint32 aProgressMax); - NS_IMETHOD OnEndPrinting(PRUint32 aStatus); - -// Dialog Data - //{{AFX_DATA(CPrintProgressDialog) - enum { IDD = IDD_PRINT_PROGRESS_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPrintProgressDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - CProgressCtrl m_wndProgress; - CString m_URL; - nsCOMPtr m_WebBrowserPrint; - nsCOMPtr m_PPParams; - nsCOMPtr m_PrintListener; - nsCOMPtr m_PrintSettings; - BOOL m_HasStarted; - BOOL m_IsForPrinting; - - // Generated message map functions - //{{AFX_MSG(CPrintProgressDialog) - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PRINTPROGRESSDIALOG_H__1E3AA1B5_B8BB_4B25_86A5_A90E663D137F__INCLUDED_) diff --git a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp b/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp deleted file mode 100644 index 52b06e10464..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.cpp +++ /dev/null @@ -1,365 +0,0 @@ -/* -*- 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 ***** */ - -/* PrintingPromptService is intended to override the default Mozilla PrintingPromptService, - giving nsIPrompt implementations of our own design, rather than using - Mozilla's. Do this by building this into a component and registering the - factory with the same CID/ContractID as Mozilla's (see MfcEmbed.cpp). -*/ - -#include "stdafx.h" -#include "Dialogs.h" -#include "PrintingPromptService.h" -#include "nsCOMPtr.h" -#include "nsMemory.h" -#include "nsString.h" -#include "nsReadableUtils.h" -#include "nsThreadUtils.h" -#include "nsIDOMWindow.h" -#include "nsIEmbeddingSiteWindow.h" -#include "nsIFactory.h" -#include "nsIPrintingPromptService.h" -#include "nsIServiceManager.h" -#include "nsIWebBrowserChrome.h" -#include "nsIWindowWatcher.h" -#include "nsIWebProgressListener.h" -#include "nsPrintProgressParams.h" -#include "nsPrintDialogUtil.h" -#include "PrintProgressDialog.h" - -static HINSTANCE gInstance; - -//***************************************************************************** -// ResourceState -//***************************************************************************** - -class ResourceState { -public: - ResourceState() { - mPreviousInstance = ::AfxGetResourceHandle(); - ::AfxSetResourceHandle(gInstance); - } - ~ResourceState() { - ::AfxSetResourceHandle(mPreviousInstance); - } -private: - HINSTANCE mPreviousInstance; -}; - - -//***************************************************************************** -// CPrintingPromptService -//***************************************************************************** - -class CPrintingPromptService: public nsIPrintingPromptService, - public nsIWebProgressListener { -public: - CPrintingPromptService(); - virtual ~CPrintingPromptService(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIPRINTINGPROMPTSERVICE - NS_DECL_NSIWEBPROGRESSLISTENER - - void NotifyObserver(); - -private: - PRBool FirePauseEvent(); - CWnd *CWndForDOMWindow(nsIDOMWindow *aWindow); - - nsCOMPtr mWWatch; - nsCOMPtr mWebProgressListener; - nsCOMPtr mObserver; - CPrintProgressDialog* m_PPDlg; -}; - -//***************************************************************************** - -NS_IMPL_ISUPPORTS2(CPrintingPromptService, nsIPrintingPromptService, nsIWebProgressListener) - -CPrintingPromptService::CPrintingPromptService() : - mWWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)), - m_PPDlg(NULL) -{ -} - -CPrintingPromptService::~CPrintingPromptService() { -} - -CWnd * -CPrintingPromptService::CWndForDOMWindow(nsIDOMWindow *aWindow) -{ - nsCOMPtr chrome; - CWnd *val = 0; - - if (mWWatch) { - nsCOMPtr fosterParent; - if (!aWindow) { // it will be a dependent window. try to find a foster parent. - mWWatch->GetActiveWindow(getter_AddRefs(fosterParent)); - aWindow = fosterParent; - } - mWWatch->GetChromeForWindow(aWindow, getter_AddRefs(chrome)); - } - - if (chrome) { - nsCOMPtr site(do_QueryInterface(chrome)); - if (site) { - HWND w; - site->GetSiteWindow(reinterpret_cast(&w)); - val = CWnd::FromHandle(w); - } - } - - return val; -} - -/////////////////////////////////////////////////////////////////////////////// -// nsIPrintingPrompt - -//----------------------------------------------------------- -NS_IMETHODIMP -CPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings) -{ - //NS_ENSURE_ARG(parent); - - CWnd* wnd = CWndForDOMWindow(parent); - - NS_ASSERTION(wnd && wnd->m_hWnd, "Couldn't get native window for PRint Dialog!"); - if (wnd && wnd->m_hWnd) { - return NativeShowPrintDialog(wnd->m_hWnd, webBrowserPrint, printSettings); - } else { - return NS_ERROR_FAILURE; - } -} - -//----------------------------------------------------------- -PRBool -CPrintingPromptService::FirePauseEvent() -{ - nsCOMPtr event = - NS_NEW_RUNNABLE_METHOD(CPrintingPromptService, this, NotifyObserver); - return NS_SUCCEEDED(NS_DispatchToCurrentThread(event)); -} - -/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */ -NS_IMETHODIMP -CPrintingPromptService::ShowProgress(nsIDOMWindow* parent, - nsIWebBrowserPrint* webBrowserPrint, // ok to be null - nsIPrintSettings* printSettings, // ok to be null - nsIObserver* openDialogObserver, // ok to be null - PRBool isForPrinting, - nsIWebProgressListener** webProgressListener, - nsIPrintProgressParams** printProgressParams, - PRBool* notifyOnOpen) -{ - NS_ENSURE_ARG(webProgressListener); - NS_ENSURE_ARG(printProgressParams); - NS_ENSURE_ARG(notifyOnOpen); - - ResourceState setState; - nsresult rv; - - nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams(); - rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)printProgressParams); - NS_ENSURE_SUCCESS(rv, rv); - - mObserver = openDialogObserver; - - *notifyOnOpen = PR_FALSE; - if (printProgressParams) - { - CWnd *wnd = CWndForDOMWindow(parent); - m_PPDlg = new CPrintProgressDialog(wnd, isForPrinting, *printProgressParams, webBrowserPrint, printSettings); - m_PPDlg->Create(IDD_PRINT_PROGRESS_DIALOG); - m_PPDlg->ShowWindow(SW_SHOW); - m_PPDlg->UpdateWindow(); - - *notifyOnOpen = FirePauseEvent(); - } - - *webProgressListener = NS_STATIC_CAST(nsIWebProgressListener*, this); - NS_ADDREF(*webProgressListener); - - return rv; -} - -/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings); */ -NS_IMETHODIMP -CPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs) -{ - NS_ENSURE_ARG(printSettings); - - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void showPrinterProperties (in nsIDOMWindow parent, in wstring printerName, in nsIPrintSettings printSettings); */ -NS_IMETHODIMP -CPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const PRUnichar *printerName, nsIPrintSettings *printSettings) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -//------------------------------------------------------------------------ -void CPrintingPromptService::NotifyObserver() -{ - if (mObserver) { - mObserver->Observe(nsnull, nsnull, nsnull); - } -} - -////////////////////////////////////////////////////////////////////// -// nsIWebProgressListener -////////////////////////////////////////////////////////////////////// - -/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in nsresult aStatus); */ -NS_IMETHODIMP -CPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) -{ - if (aStateFlags & STATE_START) - { - if (m_PPDlg) - { - m_PPDlg->OnStartPrinting(); - } - } - - if (aStateFlags & STATE_STOP) - { - if (m_PPDlg) - { - m_PPDlg->OnProgressPrinting(100, 100); - m_PPDlg->DestroyWindow(); - m_PPDlg = NULL; - } - } - return NS_OK; -} - -/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */ -NS_IMETHODIMP -CPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) -{ - if (m_PPDlg) - { - m_PPDlg->OnProgressPrinting(aCurTotalProgress, aMaxTotalProgress); - } - return NS_OK; -} - -/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location); */ -NS_IMETHODIMP -CPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location) -{ - return NS_OK; -} - -/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */ -NS_IMETHODIMP -CPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage) -{ - return NS_OK; -} - -/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */ -NS_IMETHODIMP -CPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 state) -{ - return NS_OK; -} - - - -//***************************************************************************** -// CPrintingPromptServiceFactory -//***************************************************************************** - -class CPrintingPromptServiceFactory : public nsIFactory { -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - - CPrintingPromptServiceFactory(); - virtual ~CPrintingPromptServiceFactory(); -}; - -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(CPrintingPromptServiceFactory, nsIFactory) - -CPrintingPromptServiceFactory::CPrintingPromptServiceFactory() { -} - -CPrintingPromptServiceFactory::~CPrintingPromptServiceFactory() { -} - -NS_IMETHODIMP CPrintingPromptServiceFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = NULL; - CPrintingPromptService *inst = new CPrintingPromptService; - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - if (rv != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } - - return rv; -} - -NS_IMETHODIMP CPrintingPromptServiceFactory::LockFactory(PRBool lock) -{ - return NS_OK; -} - -//***************************************************************************** - -void InitPrintingPromptService(HINSTANCE instance) { - - gInstance = instance; -} - -nsresult NS_NewPrintingPromptServiceFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - CPrintingPromptServiceFactory *result = new CPrintingPromptServiceFactory; - if (!result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.h b/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.h deleted file mode 100644 index a0a603afb6a..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PrintingPromptService.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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 ***** */ - -#ifndef __PrintingPromptService_h -#define __PrintingPromptService_h - -#include "nsError.h" - -// this component is for an MFC app; it's Windows. make sure this is defined. -#ifndef XP_WIN -#define XP_WIN -#endif - -class nsIFactory; - -// factory creator, in hard and soft link formats -extern "C" NS_EXPORT nsresult NS_NewPrintingPromptServiceFactory(nsIFactory** aFactory); -typedef nsresult (__cdecl *MakeFactoryType)(nsIFactory **); -#define kPrintingPromptServiceFactoryFuncName "NS_NewPrintingPromptServiceFactory" - -// initialization function, in hard and soft link formats -extern "C" NS_EXPORT void InitPrintingPromptService(HINSTANCE instance); -typedef nsresult (__cdecl *InitPrintingPromptServiceType)(HINSTANCE instance); -#define kPrintingPromptServiceInitFuncName "InitPrintingPromptService" - -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/PromptService.cpp b/mozilla/embedding/tests/mfcembed/components/PromptService.cpp deleted file mode 100644 index ee52f8cac19..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PromptService.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/* -*- 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 ***** */ - -/* PromptService is intended to override the default Mozilla PromptService, - giving nsIPrompt implementations of our own design, rather than using - Mozilla's. Do this by building this into a component and registering the - factory with the same CID/ContractID as Mozilla's (see MfcEmbed.cpp). -*/ - -#include "stdafx.h" -#include "Dialogs.h" -#include "PromptService.h" -#include "nsCOMPtr.h" -#include "nsMemory.h" -#include "nsString.h" -#include "nsReadableUtils.h" -#include "nsIDOMWindow.h" -#include "nsIEmbeddingSiteWindow.h" -#include "nsIFactory.h" -#include "nsIPromptService.h" -#include "nsIServiceManager.h" -#include "nsIWebBrowserChrome.h" -#include "nsIWindowWatcher.h" - -static HINSTANCE gInstance; - -//***************************************************************************** -// ResourceState -//***************************************************************************** - -class ResourceState { -public: - ResourceState() { - mPreviousInstance = ::AfxGetResourceHandle(); - ::AfxSetResourceHandle(gInstance); - } - ~ResourceState() { - ::AfxSetResourceHandle(mPreviousInstance); - } -private: - HINSTANCE mPreviousInstance; -}; - - -//***************************************************************************** -// CPromptService -//***************************************************************************** - -class CPromptService: public nsIPromptService { -public: - CPromptService(); - virtual ~CPromptService(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIPROMPTSERVICE - -private: - nsCOMPtr mWWatch; - CWnd *CWndForDOMWindow(nsIDOMWindow *aWindow); -}; - -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(CPromptService, nsIPromptService) - -CPromptService::CPromptService() : - mWWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)) -{ -} - -CPromptService::~CPromptService() { -} - -CWnd * -CPromptService::CWndForDOMWindow(nsIDOMWindow *aWindow) -{ - nsCOMPtr chrome; - CWnd *val = 0; - - if (mWWatch) { - nsCOMPtr fosterParent; - if (!aWindow) { // it will be a dependent window. try to find a foster parent. - mWWatch->GetActiveWindow(getter_AddRefs(fosterParent)); - aWindow = fosterParent; - } - mWWatch->GetChromeForWindow(aWindow, getter_AddRefs(chrome)); - } - - if (chrome) { - nsCOMPtr site(do_QueryInterface(chrome)); - if (site) { - HWND w; - site->GetSiteWindow(reinterpret_cast(&w)); - val = CWnd::FromHandle(w); - } - } - - return val; -} - -NS_IMETHODIMP CPromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle, - const PRUnichar *text) -{ - USES_CONVERSION; - CWnd *wnd = CWndForDOMWindow(parent); - if (wnd) - wnd->MessageBox(W2CT(text), W2CT(dialogTitle), MB_OK | MB_ICONEXCLAMATION); - else - ::MessageBox(0, W2CT(text), W2CT(dialogTitle), MB_OK | MB_ICONEXCLAMATION); - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkboxMsg, - PRBool *checkValue) -{ - ResourceState setState; - USES_CONVERSION; - - CWnd *wnd = CWndForDOMWindow(parent); - CAlertCheckDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - W2CT(checkboxMsg), checkValue ? *checkValue : 0); - - dlg.DoModal(); - - *checkValue = dlg.m_bCheckBoxValue; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::Confirm(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRBool *_retval) -{ - USES_CONVERSION; - CWnd *wnd = CWndForDOMWindow(parent); - int choice; - - if (wnd) - choice = wnd->MessageBox(W2CT(text), W2CT(dialogTitle), - MB_YESNO | MB_ICONEXCLAMATION); - else - choice = ::MessageBox(0, W2CT(text), W2CT(dialogTitle), - MB_YESNO | MB_ICONEXCLAMATION); - - *_retval = choice == IDYES ? PR_TRUE : PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - ResourceState setState; - USES_CONVERSION; - - CWnd *wnd = CWndForDOMWindow(parent); - CConfirmCheckDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - W2CT(checkboxMsg), checkValue ? *checkValue : 0, - _T("Yes"), _T("No"), NULL); - - int iBtnClicked = dlg.DoModal(); - - *checkValue = dlg.m_bCheckBoxValue; - - *_retval = iBtnClicked == 0 ? PR_TRUE : PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **value, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - ResourceState setState; - USES_CONVERSION; - - CWnd *wnd = CWndForDOMWindow(parent); - CPromptDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - text && *text ? W2CT(text) : 0, - checkValue != nsnull, W2CT(checkboxMsg), - checkValue ? *checkValue : 0); - if(dlg.DoModal() == IDOK) { - // Get the value entered in the editbox of the PromptDlg - if (value && *value) { - nsMemory::Free(*value); - *value = nsnull; - } - USES_CONVERSION; - nsString csPromptEditValue; - csPromptEditValue.Assign(T2CW(dlg.m_csPromptAnswer.GetBuffer(0))); - - *value = ToNewUnicode(csPromptEditValue); - - *_retval = PR_TRUE; - } else - *_retval = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **username, - PRUnichar **password, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - ResourceState setState; - USES_CONVERSION; - - CWnd *wnd = CWndForDOMWindow(parent); - CPromptUsernamePasswordDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - username && *username ? W2CT(*username) : 0, - password && *password ? W2CT(*password) : 0, - checkValue != nsnull, W2CT(checkboxMsg), - checkValue ? *checkValue : 0); - - if (dlg.DoModal() == IDOK) { - // Get the username entered - if (username && *username) { - nsMemory::Free(*username); - *username = nsnull; - } - USES_CONVERSION; - nsString csUserName; - csUserName.Assign(T2CW(dlg.m_csUserName.GetBuffer(0))); - *username = ToNewUnicode(csUserName); - - // Get the password entered - if (password && *password) { - nsMemory::Free(*password); - *password = nsnull; - } - nsString csPassword; - csPassword.Assign(T2CW(dlg.m_csPassword.GetBuffer(0))); - *password = ToNewUnicode(csPassword); - - if(checkValue) - *checkValue = dlg.m_bCheckBoxValue; - - *_retval = PR_TRUE; - } else - *_retval = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **password, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - ResourceState setState; - USES_CONVERSION; - - CWnd *wnd = CWndForDOMWindow(parent); - CPromptPasswordDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - password && *password ? W2CT(*password) : 0, - checkValue != nsnull, W2CT(checkboxMsg), - checkValue ? *checkValue : 0); - if(dlg.DoModal() == IDOK) { - // Get the password entered - if (password && *password) { - nsMemory::Free(*password); - *password = nsnull; - } - USES_CONVERSION; - nsString csPassword; - csPassword.Assign(T2CW(dlg.m_csPassword.GetBuffer(0))); - *password = ToNewUnicode(csPassword); - - if(checkValue) - *checkValue = dlg.m_bCheckBoxValue; - - *_retval = PR_TRUE; - } else - *_retval = PR_FALSE; - - return NS_OK; -} - -NS_IMETHODIMP CPromptService::Select(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, PRUint32 count, - const PRUnichar **selectList, - PRInt32 *outSelection, - PRBool *_retval) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CPromptService::ConfirmEx(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUint32 buttonFlags, - const PRUnichar *button0Title, - const PRUnichar *button1Title, - const PRUnichar *button2Title, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRInt32 *buttonPressed) -{ - ResourceState setState; - USES_CONVERSION; - - // First, determine the button titles based on buttonFlags - const PRUnichar* buttonStrings[] = { button0Title, button1Title, button2Title }; - CString csBtnTitles[3]; - - for(int i=0; i<3; i++) - { - switch(buttonFlags & 0xff) { - case BUTTON_TITLE_OK: - csBtnTitles[i] = "Ok"; - break; - case BUTTON_TITLE_CANCEL: - csBtnTitles[i] = "Cancel"; - break; - case BUTTON_TITLE_YES: - csBtnTitles[i] = "Yes"; - break; - case BUTTON_TITLE_NO: - csBtnTitles[i] = "No"; - break; - case BUTTON_TITLE_SAVE: - csBtnTitles[i] = "Save"; - break; - case BUTTON_TITLE_DONT_SAVE: - csBtnTitles[i] = "DontSave"; - break; - case BUTTON_TITLE_REVERT: - csBtnTitles[i] = "Revert"; - break; - case BUTTON_TITLE_IS_STRING: - csBtnTitles[i] = W2CT(buttonStrings[i]); - break; - } - - buttonFlags >>= 8; - } - - CWnd *wnd = CWndForDOMWindow(parent); - CConfirmCheckDialog dlg(wnd, W2CT(dialogTitle), W2CT(text), - checkMsg ? W2CT(checkMsg) : NULL, checkValue ? *checkValue : 0, - csBtnTitles[0].IsEmpty() ? NULL : (LPCTSTR)csBtnTitles[0], - csBtnTitles[1].IsEmpty() ? NULL : (LPCTSTR)csBtnTitles[1], - csBtnTitles[2].IsEmpty() ? NULL : (LPCTSTR)csBtnTitles[2]); - - *buttonPressed = dlg.DoModal(); - - if(checkValue) - *checkValue = dlg.m_bCheckBoxValue; - - return NS_OK; -} - -//***************************************************************************** -// CPromptServiceFactory -//***************************************************************************** - -class CPromptServiceFactory : public nsIFactory { -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - - CPromptServiceFactory(); - virtual ~CPromptServiceFactory(); -}; - -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(CPromptServiceFactory, nsIFactory) - -CPromptServiceFactory::CPromptServiceFactory() { -} - -CPromptServiceFactory::~CPromptServiceFactory() { -} - -NS_IMETHODIMP CPromptServiceFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = NULL; - CPromptService *inst = new CPromptService; - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - if (rv != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } - - return rv; -} - -NS_IMETHODIMP CPromptServiceFactory::LockFactory(PRBool lock) -{ - return NS_OK; -} - -//***************************************************************************** - -void InitPromptService(HINSTANCE instance) { - - gInstance = instance; -} - -nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - CPromptServiceFactory *result = new CPromptServiceFactory; - if (!result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/mozilla/embedding/tests/mfcembed/components/PromptService.h b/mozilla/embedding/tests/mfcembed/components/PromptService.h deleted file mode 100644 index 1f496a2de87..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/PromptService.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- 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 ***** */ - -#ifndef __PromptService_h -#define __PromptService_h - -#include "nsError.h" - -// this component is for an MFC app; it's Windows. make sure this is defined. -#ifndef XP_WIN -#define XP_WIN -#endif - -class nsIFactory; - -// factory creator, in hard and soft link formats -extern "C" NS_EXPORT nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory); -typedef nsresult (__cdecl *MakeFactoryType)(nsIFactory **); -#define kPromptServiceFactoryFuncName "NS_NewPromptServiceFactory" - -// initialization function, in hard and soft link formats -extern "C" NS_EXPORT void InitPromptService(HINSTANCE instance); -typedef nsresult (__cdecl *InitPromptServiceType)(HINSTANCE instance); -#define kPromptServiceInitFuncName "InitPromptService" - -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp b/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp deleted file mode 100644 index 0fed45b4460..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.cpp +++ /dev/null @@ -1,1412 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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 ***** */ - -#ifdef MOZ_REQUIRE_CURRENT_SDK -#undef WINVER -#define WINVER 0x0500 -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 -#endif - -/* ------------------------------------------------------------------- -To Build This: - - You need to add this to the the makefile.win in mozilla/content/base/src: - - .\$(OBJDIR)\nsFlyOwnPrintDialog.obj \ - - - And this to the makefile.win in mozilla/content/build: - -WIN_LIBS= \ - winspool.lib \ - comctl32.lib \ - comdlg32.lib - ----------------------------------------------------------------------- */ - -#include "prmem.h" -#include "plstr.h" -#include -#include - -#include -#include - -#include "nsIWebBrowserPrint.h" -#include "nsString.h" -#include "nsIServiceManager.h" -#include "nsReadableUtils.h" -#include "nsIWidget.h" -#include "nsIPrintSettings.h" -#include "nsIPrintSettingsWin.h" -#include "nsUnitConversion.h" -#include "nsIPrintOptions.h" -#include "nsWidgetsCID.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" - -static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); - -#include "nsRect.h" - -#include "nsCRT.h" -#include "prenv.h" /* for PR_GetEnv */ - -#include -#include - -// For Localization -#include "nsIStringBundle.h" - -// This is for extending the dialog -#include - -// For PrintDlgEx -// needed because there are unicode/ansi versions of this routine -// and we need to make sure we get the correct one. -#ifdef UNICODE -#define GetPrintDlgExQuoted "PrintDlgExW" -#else -#define GetPrintDlgExQuoted "PrintDlgExA" -#endif - -// Default labels for the radio buttons -static const char* kAsLaidOutOnScreenStr = "As &laid out on the screen"; -static const char* kTheSelectedFrameStr = "The selected &frame"; -static const char* kEachFrameSeparately = "&Each frame separately"; - - -//----------------------------------------------- -// Global Data -//----------------------------------------------- -// Identifies which new radio btn was cliked on -static UINT gFrameSelectedRadioBtn = 0; - -// Indicates whether the native print dialog was successfully extended -static PRPackedBool gDialogWasExtended = PR_FALSE; - -#define PRINTDLG_PROPERTIES "chrome://global/locale/printdialog.properties" - -static HWND gParentWnd = NULL; - -//****************************************************** -// Define native paper sizes -//****************************************************** -typedef struct { - short mPaperSize; // native enum - double mWidth; - double mHeight; - PRBool mIsInches; -} NativePaperSizes; - -// There are around 40 default print sizes defined by Windows -const NativePaperSizes kPaperSizes[] = { - {DMPAPER_LETTER, 8.5, 11.0, PR_TRUE}, - {DMPAPER_LEGAL, 8.5, 14.0, PR_TRUE}, - {DMPAPER_A4, 210.0, 297.0, PR_FALSE}, - {DMPAPER_TABLOID, 11.0, 17.0, PR_TRUE}, - {DMPAPER_LEDGER, 17.0, 11.0, PR_TRUE}, - {DMPAPER_STATEMENT, 5.5, 8.5, PR_TRUE}, - {DMPAPER_EXECUTIVE, 7.25, 10.5, PR_TRUE}, - {DMPAPER_A3, 297.0, 420.0, PR_FALSE}, - {DMPAPER_A5, 148.0, 210.0, PR_FALSE}, - {DMPAPER_CSHEET, 17.0, 22.0, PR_TRUE}, - {DMPAPER_DSHEET, 22.0, 34.0, PR_TRUE}, - {DMPAPER_ESHEET, 34.0, 44.0, PR_TRUE}, - {DMPAPER_LETTERSMALL, 8.5, 11.0, PR_TRUE}, - {DMPAPER_A4SMALL, 210.0, 297.0, PR_FALSE}, - {DMPAPER_B4, 250.0, 354.0, PR_FALSE}, - {DMPAPER_B5, 182.0, 257.0, PR_FALSE}, - {DMPAPER_FOLIO, 8.5, 13.0, PR_TRUE}, - {DMPAPER_QUARTO, 215.0, 275.0, PR_FALSE}, - {DMPAPER_10X14, 10.0, 14.0, PR_TRUE}, - {DMPAPER_11X17, 11.0, 17.0, PR_TRUE}, - {DMPAPER_NOTE, 8.5, 11.0, PR_TRUE}, - {DMPAPER_ENV_9, 3.875, 8.875, PR_TRUE}, - {DMPAPER_ENV_10, 40.125, 9.5, PR_TRUE}, - {DMPAPER_ENV_11, 4.5, 10.375, PR_TRUE}, - {DMPAPER_ENV_12, 4.75, 11.0, PR_TRUE}, - {DMPAPER_ENV_14, 5.0, 11.5, PR_TRUE}, - {DMPAPER_ENV_DL, 110.0, 220.0, PR_FALSE}, - {DMPAPER_ENV_C5, 162.0, 229.0, PR_FALSE}, - {DMPAPER_ENV_C3, 324.0, 458.0, PR_FALSE}, - {DMPAPER_ENV_C4, 229.0, 324.0, PR_FALSE}, - {DMPAPER_ENV_C6, 114.0, 162.0, PR_FALSE}, - {DMPAPER_ENV_C65, 114.0, 229.0, PR_FALSE}, - {DMPAPER_ENV_B4, 250.0, 353.0, PR_FALSE}, - {DMPAPER_ENV_B5, 176.0, 250.0, PR_FALSE}, - {DMPAPER_ENV_B6, 176.0, 125.0, PR_FALSE}, - {DMPAPER_ENV_ITALY, 110.0, 230.0, PR_FALSE}, - {DMPAPER_ENV_MONARCH, 3.875, 7.5, PR_TRUE}, - {DMPAPER_ENV_PERSONAL, 3.625, 6.5, PR_TRUE}, - {DMPAPER_FANFOLD_US, 14.875, 11.0, PR_TRUE}, - {DMPAPER_FANFOLD_STD_GERMAN, 8.5, 12.0, PR_TRUE}, - {DMPAPER_FANFOLD_LGL_GERMAN, 8.5, 13.0, PR_TRUE}, -}; -const PRInt32 kNumPaperSizes = 41; - -//---------------------------------------------------------------------------------- -static PRBool -CheckForExtendedDialog() -{ -#ifdef MOZ_REQUIRE_CURRENT_SDK - HMODULE lib = GetModuleHandle("comdlg32.dll"); - if ( lib ) { - return GetProcAddress(lib, GetPrintDlgExQuoted); - } -#endif - return PR_FALSE; -} - -//---------------------------------------------------------------------------------- -// Map an incoming size to a Windows Native enum in the DevMode -static void -MapPaperSizeToNativeEnum(LPDEVMODE aDevMode, - PRInt16 aType, - double aW, - double aH) -{ - -#ifdef DEBUG_rods - BOOL doingOrientation = aDevMode->dmFields & DM_ORIENTATION; - BOOL doingPaperSize = aDevMode->dmFields & DM_PAPERSIZE; - BOOL doingPaperLength = aDevMode->dmFields & DM_PAPERLENGTH; - BOOL doingPaperWidth = aDevMode->dmFields & DM_PAPERWIDTH; -#endif - - const double kThreshold = 0.05; - PRBool foundEnum = PR_FALSE; - for (PRInt32 i=0;i width-kThreshold && - aH < height+kThreshold && aH > height-kThreshold) { - aDevMode->dmPaperSize = kPaperSizes[i].mPaperSize; - aDevMode->dmFields &= ~DM_PAPERLENGTH; - aDevMode->dmFields &= ~DM_PAPERWIDTH; - aDevMode->dmFields |= DM_PAPERSIZE; - return; - } - } - - short width = 0; - short height = 0; - if (aType == nsIPrintSettings::kPaperSizeInches) { - width = short(NS_TWIPS_TO_MILLIMETERS(NS_INCHES_TO_TWIPS(float(aW))) / 10); - height = short(NS_TWIPS_TO_MILLIMETERS(NS_INCHES_TO_TWIPS(float(aH))) / 10); - - } else if (aType == nsIPrintSettings::kPaperSizeMillimeters) { - width = short(aW / 10.0); - height = short(aH / 10.0); - } else { - return; // don't set anything - } - - // width and height is in - aDevMode->dmPaperSize = 0; - aDevMode->dmPaperWidth = width; - aDevMode->dmPaperLength = height; - - aDevMode->dmFields |= DM_PAPERSIZE; - aDevMode->dmFields |= DM_PAPERLENGTH; - aDevMode->dmFields |= DM_PAPERWIDTH; -} - -//---------------------------------------------------------------------------------- -// Setup Paper Size & Orientation options into the DevMode -// -static void -SetupDevModeFromSettings(LPDEVMODE aDevMode, nsIPrintSettings* aPrintSettings) -{ - // Setup paper size - if (aPrintSettings) { - PRInt16 type; - aPrintSettings->GetPaperSizeType(&type); - if (type == nsIPrintSettings::kPaperSizeNativeData) { - PRInt16 paperEnum; - aPrintSettings->GetPaperData(&paperEnum); - aDevMode->dmPaperSize = paperEnum; - aDevMode->dmFields &= ~DM_PAPERLENGTH; - aDevMode->dmFields &= ~DM_PAPERWIDTH; - aDevMode->dmFields |= DM_PAPERSIZE; - } else { - PRInt16 unit; - double width, height; - aPrintSettings->GetPaperSizeUnit(&unit); - aPrintSettings->GetPaperWidth(&width); - aPrintSettings->GetPaperHeight(&height); - MapPaperSizeToNativeEnum(aDevMode, unit, width, height); - } - - // Setup Orientation - PRInt32 orientation; - aPrintSettings->GetOrientation(&orientation); - aDevMode->dmOrientation = orientation == nsIPrintSettings::kPortraitOrientation?DMORIENT_PORTRAIT:DMORIENT_LANDSCAPE; - aDevMode->dmFields |= DM_ORIENTATION; - - // Setup Number of Copies - PRInt32 copies; - aPrintSettings->GetNumCopies(&copies); - aDevMode->dmCopies = copies; - aDevMode->dmFields |= DM_COPIES; - - } - -} - -//---------------------------------------------------------------------------------- -// Helper Function - Free and reallocate the string -static nsresult -SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, - LPDEVMODE aDevMode) -{ - if (aPrintSettings == nsnull) { - return NS_ERROR_FAILURE; - } - - if (aDevMode->dmFields & DM_ORIENTATION) { - PRInt32 orientation = aDevMode->dmOrientation == DMORIENT_PORTRAIT? - nsIPrintSettings::kPortraitOrientation:nsIPrintSettings::kLandscapeOrientation; - aPrintSettings->SetOrientation(orientation); - } - - // Setup Number of Copies - if (aDevMode->dmFields & DM_COPIES) { - aPrintSettings->SetNumCopies(PRInt32(aDevMode->dmCopies)); - } - - // Scaling - // Since we do the scaling, grab their value and reset back to 100 - if (aDevMode->dmFields & DM_SCALE) { - double origScale = 1.0; - aPrintSettings->GetScaling(&origScale); - double scale = double(aDevMode->dmScale) / 100.0f; - if (origScale == 1.0 || scale != 1.0) { - aPrintSettings->SetScaling(scale); - } - aDevMode->dmScale = 100; - // To turn this on you must change where the mPrt->mShrinkToFit is being set in the DocumentViewer - //aPrintSettings->SetShrinkToFit(PR_FALSE); - } - - if (aDevMode->dmFields & DM_PAPERSIZE) { - aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeNativeData); - aPrintSettings->SetPaperData(aDevMode->dmPaperSize); - - } else if (aDevMode->dmFields & DM_PAPERLENGTH && aDevMode->dmFields & DM_PAPERWIDTH) { - PRBool found = PR_FALSE; - for (PRInt32 i=0;idmPaperSize) { - aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeDefined); - aPrintSettings->SetPaperWidth(kPaperSizes[i].mWidth); - aPrintSettings->SetPaperHeight(kPaperSizes[i].mHeight); - aPrintSettings->SetPaperSizeUnit(kPaperSizes[i].mIsInches?nsIPrintSettings::kPaperSizeInches:nsIPrintSettings::kPaperSizeInches); - found = PR_TRUE; - break; - } - } - if (!found) { - return NS_ERROR_FAILURE; - } - } else { - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -//---------------------------------------------------------------------------------- -// Return localized bundle for resource strings -static nsresult -GetLocalizedBundle(const char * aPropFileName, nsIStringBundle** aStrBundle) -{ - NS_ENSURE_ARG_POINTER(aPropFileName); - NS_ENSURE_ARG_POINTER(aStrBundle); - - nsresult rv; - nsCOMPtr bundle; - - - // Create bundle - nsCOMPtr stringService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv) && stringService) { - rv = stringService->CreateBundle(aPropFileName, aStrBundle); - } - - return rv; -} - -//-------------------------------------------------------- -// Return localized string -static nsresult -GetLocalizedString(nsIStringBundle* aStrBundle, const char* aKey, nsString& oVal) -{ - NS_ENSURE_ARG_POINTER(aStrBundle); - NS_ENSURE_ARG_POINTER(aKey); - - // Determine default label from string bundle - nsXPIDLString valUni; - nsAutoString key; - key.AssignWithConversion(aKey); - nsresult rv = aStrBundle->GetStringFromName(key.get(), getter_Copies(valUni)); - if (NS_SUCCEEDED(rv) && valUni) { - oVal.Assign(valUni); - } else { - oVal.Truncate(); - } - return rv; -} - -//-------------------------------------------------------- -static char* -GetACPString(const nsAString& aStr) -{ - int acplen = aStr.Length() * 2 + 1; - char * acp = new char[acplen]; - if(acp) - { - int outlen = ::WideCharToMultiByte( CP_ACP, 0, - PromiseFlatString(aStr).get(), aStr.Length(), - acp, acplen, NULL, NULL); - if ( outlen > 0) - acp[outlen] = '\0'; // null terminate - } - return acp; -} - -//-------------------------------------------------------- -// Set a multi-byte string in the control -static void SetTextOnWnd(HWND aControl, const nsString& aStr) -{ - char* pStr = GetACPString(aStr); - if (pStr) { - ::SetWindowText(aControl, pStr); - delete [] pStr; - } -} - -//-------------------------------------------------------- -// Will get the control and localized string by "key" -static void SetText(HWND aParent, - UINT aId, - nsIStringBundle* aStrBundle, - const char* aKey) -{ - HWND wnd = GetDlgItem (aParent, aId); - if (!wnd) { - return; - } - nsAutoString str; - nsresult rv = GetLocalizedString(aStrBundle, aKey, str); - if (NS_SUCCEEDED(rv)) { - SetTextOnWnd(wnd, str); - } -} - -//-------------------------------------------------------- -static void SetRadio(HWND aParent, - UINT aId, - PRBool aIsSet, - PRBool isEnabled = PR_TRUE) -{ - HWND wnd = ::GetDlgItem (aParent, aId); - if (!wnd) { - return; - } - if (!isEnabled) { - ::EnableWindow(wnd, FALSE); - return; - } - ::EnableWindow(wnd, TRUE); - ::SendMessage(wnd, BM_SETCHECK, (WPARAM)aIsSet, (LPARAM)0); -} - -//-------------------------------------------------------- -static void SetRadioOfGroup(HWND aDlg, int aRadId) -{ - int radioIds[] = {rad4, rad5, rad6}; - int numRads = 3; - - for (int i=0;i strBundle; - if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) { - PRInt32 i = 0; - while (gAllPropKeys[i].mKeyStr != NULL) { - SetText(hdlg, gAllPropKeys[i].mKeyId, strBundle, gAllPropKeys[i].mKeyStr); - i++; - } - } - - // Set up radio buttons - if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) { - SetRadio(hdlg, rad4, PR_FALSE); - SetRadio(hdlg, rad5, PR_TRUE); - SetRadio(hdlg, rad6, PR_FALSE); - // set default so user doesn't have to actually press on it - gFrameSelectedRadioBtn = rad5; - - } else if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) { - SetRadio(hdlg, rad4, PR_FALSE); - SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad6, PR_TRUE); - // set default so user doesn't have to actually press on it - gFrameSelectedRadioBtn = rad6; - - - } else { // nsIPrintSettings::kFrameEnableNone - // we are using this function to disabe the group box - SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE); - // now disable radiobuttons - SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE); - } - -} - - -//-------------------------------------------------------- -// Special Hook Procedure for handling the print dialog messages -static UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - - if (uiMsg == WM_COMMAND) { - UINT id = LOWORD(wParam); - if (id == rad4 || id == rad5 || id == rad6) { - gFrameSelectedRadioBtn = id; - SetRadioOfGroup(hdlg, id); - } - - } else if (uiMsg == WM_INITDIALOG) { - PRINTDLG * printDlg = (PRINTDLG *)lParam; - if (printDlg == NULL) return 0L; - - PRInt16 howToEnableFrameUI = (PRInt16)printDlg->lCustData; - - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hdlg, GWL_HINSTANCE); - if (hInst == NULL) return 0L; - - // Start by getting the local rects of several of the controls - // so we can calculate where the new controls are - HWND wnd = ::GetDlgItem(hdlg, grp1); - if (wnd == NULL) return 0L; - RECT dlgRect; - GetLocalRect(wnd, dlgRect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad1); // this is the top control "All" - if (wnd == NULL) return 0L; - RECT rad1Rect; - GetLocalRect(wnd, rad1Rect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad2); // this is the bottom control "Selection" - if (wnd == NULL) return 0L; - RECT rad2Rect; - GetLocalRect(wnd, rad2Rect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad3); // this is the middle control "Pages" - if (wnd == NULL) return 0L; - RECT rad3Rect; - GetLocalRect(wnd, rad3Rect, hdlg); - - HWND okWnd = ::GetDlgItem(hdlg, IDOK); - if (okWnd == NULL) return 0L; - RECT okRect; - GetLocalRect(okWnd, okRect, hdlg); - - wnd = ::GetDlgItem(hdlg, grp4); // this is the "Print range" groupbox - if (wnd == NULL) return 0L; - RECT prtRect; - GetLocalRect(wnd, prtRect, hdlg); - - - // calculate various different "gaps" for layout purposes - - int rbGap = rad3Rect.top - rad1Rect.bottom; // gap between radiobtns - int grpBotGap = dlgRect.bottom - rad2Rect.bottom; // gap from bottom rb to bottom of grpbox - int grpGap = dlgRect.top - prtRect.bottom ; // gap between group boxes - int top = dlgRect.bottom + grpGap; - int radHgt = rad1Rect.bottom - rad1Rect.top + 1; // top of new group box - int y = top+(rad1Rect.top-dlgRect.top); // starting pos of first radio - int rbWidth = dlgRect.right - rad1Rect.left - 5; // measure from rb left to the edge of the groupbox - // (5 is arbitrary) - nsRect rect; - - // Create and position the radio buttons - // - // If any one control cannot be created then - // hide the others and bail out - // - rect.SetRect(rad1Rect.left, y, rbWidth,radHgt); - HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect); - if (rad4Wnd == NULL) return 0L; - y += radHgt + rbGap; - - rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); - HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, kTheSelectedFrameStr, rect); - if (rad5Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - return 0L; - } - y += radHgt + rbGap; - - rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); - HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, kEachFrameSeparately, rect); - if (rad6Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - return 0L; - } - y += radHgt + grpBotGap; - - // Create and position the group box - rect.SetRect (dlgRect.left, top, dlgRect.right-dlgRect.left+1, y-top+1); - HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect); - if (grpBoxWnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - Show(rad6Wnd, FALSE); // hide - return 0L; - } - - // Here we figure out the old height of the dlg - // then figure it's gap from the old grpbx to the bottom - // then size the dlg - RECT pr, cr; - ::GetWindowRect(hdlg, &pr); - ::GetClientRect(hdlg, &cr); - - int dlgHgt = (cr.bottom - cr.top) + 1; - int bottomGap = dlgHgt - okRect.bottom; - pr.bottom += (dlgRect.bottom-dlgRect.top) + grpGap + 1 - (dlgHgt-dlgRect.bottom) + bottomGap; - - ::SetWindowPos(hdlg, NULL, pr.left, pr.top, pr.right-pr.left+1, pr.bottom-pr.top+1, - SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER); - - // figure out the new height of the dialog - ::GetClientRect(hdlg, &cr); - dlgHgt = (cr.bottom - cr.top) + 1; - - // Reposition the OK and Cancel btns - int okHgt = okRect.bottom - okRect.top + 1; - ::SetWindowPos(okWnd, NULL, okRect.left, dlgHgt-bottomGap-okHgt, 0, 0, - SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); - - HWND cancelWnd = ::GetDlgItem(hdlg, IDCANCEL); - if (cancelWnd == NULL) return 0L; - - RECT cancelRect; - GetLocalRect(cancelWnd, cancelRect, hdlg); - int cancelHgt = cancelRect.bottom - cancelRect.top + 1; - ::SetWindowPos(cancelWnd, NULL, cancelRect.left, dlgHgt-bottomGap-cancelHgt, 0, 0, - SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); - - // localize and initialize the groupbox and radiobuttons - InitializeExtendedDialog(hdlg, howToEnableFrameUI); - - // Looks like we were able to extend the dialog - gDialogWasExtended = PR_TRUE; - } - return 0L; -} - -//---------------------------------------------------------------------------------- -// Returns a Global Moveable Memory Handle to a DevMode -// from the Printer byt the name of aPrintName -static HGLOBAL CreateGlobalDevModeAndInit(LPTSTR aPrintName, nsIPrintSettings* aPS) -{ - HGLOBAL hGlobalDevMode = NULL; - - nsresult rv = NS_ERROR_FAILURE; - HANDLE hPrinter = NULL; - BOOL status = ::OpenPrinter(aPrintName, &hPrinter, NULL); - if (status) { - - LPDEVMODE pNewDevMode; - DWORD dwNeeded, dwRet; - - nsString prtName; -#ifdef UNICODE - prtName.AppendWithConversion((PRUnichar *)aPrintName); -#else - prtName.AssignWithConversion((char*)aPrintName); -#endif - - // Allocate a buffer of the correct size. - dwNeeded = ::DocumentProperties(gParentWnd, hPrinter, aPrintName, NULL, NULL, 0); - - pNewDevMode = (LPDEVMODE)malloc(dwNeeded); - if (!pNewDevMode) return NULL; - - hGlobalDevMode = (HGLOBAL)::GlobalAlloc(GHND, dwNeeded); - if (!hGlobalDevMode) { - free(pNewDevMode); - } - - dwRet = ::DocumentProperties(gParentWnd, hPrinter, aPrintName, pNewDevMode, NULL, DM_OUT_BUFFER); - - if (dwRet != IDOK) { - free(pNewDevMode); - ::GlobalFree(hGlobalDevMode); - ::ClosePrinter(hPrinter); - return NULL; - } - - // Lock memory and copy contents from DEVMODE (current printer) - // to Global Memory DEVMODE - LPDEVMODE devMode = (DEVMODE *)::GlobalLock(hGlobalDevMode); - if (devMode) { - memcpy(devMode, pNewDevMode, dwNeeded); - // Initialize values from the PrintSettings - SetupDevModeFromSettings(devMode, aPS); - ::GlobalUnlock(hGlobalDevMode); - } else { - ::GlobalFree(hGlobalDevMode); - hGlobalDevMode = NULL; - } - - free(pNewDevMode); - - ::ClosePrinter(hPrinter); - - } else { - return NULL; - } - - return hGlobalDevMode; -} - -//------------------------------------------------------------------ -// helper -static PRUnichar * GetDefaultPrinterNameFromGlobalPrinters() -{ - nsresult rv; - PRUnichar * printerName = nsnull; - nsCOMPtr prtEnum = do_GetService(kPrinterEnumeratorCID, &rv); - if (prtEnum) { - prtEnum->GetDefaultPrinterName(&printerName); - } - return printerName; -} - -// Determine whether we have a completely native dialog -// or whether we cshould extend it -static PRBool ShouldExtendPrintDialog() -{ - nsresult rv; - nsCOMPtr prefs = - do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, PR_TRUE); - nsCOMPtr prefBranch; - rv = prefs->GetBranch(nsnull, getter_AddRefs(prefBranch)); - NS_ENSURE_SUCCESS(rv, PR_TRUE); - - PRBool result; - rv = prefBranch->GetBoolPref("print.extend_native_print_dialog", &result); - NS_ENSURE_SUCCESS(rv, PR_TRUE); - return result; -} - -//------------------------------------------------------------------ -// Displays the native Print Dialog -static nsresult -ShowNativePrintDialog(HWND aHWnd, - nsIPrintSettings* aPrintSettings) -{ - //NS_ENSURE_ARG_POINTER(aHWnd); - NS_ENSURE_ARG_POINTER(aPrintSettings); - - nsresult rv = NS_ERROR_FAILURE; - gDialogWasExtended = PR_FALSE; - - HGLOBAL hGlobalDevMode = NULL; - HGLOBAL hDevNames = NULL; - - // Get the Print Name to be used - PRUnichar * printerName; - aPrintSettings->GetPrinterName(&printerName); - - // If there is no name then use the default printer - if (!printerName || (printerName && !*printerName)) { - printerName = GetDefaultPrinterNameFromGlobalPrinters(); - } - - NS_ASSERTION(printerName, "We have to have a printer name"); - if (!printerName) return NS_ERROR_FAILURE; - - // Now create a DEVNAMES struct so the the dialog is initialized correctly. - PRUint32 len = nsCRT::strlen(printerName); - hDevNames = (HGLOBAL)::GlobalAlloc(GHND, len+sizeof(DEVNAMES)+1); - DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames); - pDevNames->wDriverOffset = sizeof(DEVNAMES); - pDevNames->wDeviceOffset = sizeof(DEVNAMES); - pDevNames->wOutputOffset = sizeof(DEVNAMES)+len+1; - pDevNames->wDefault = 0; - char* device = &(((char*)pDevNames)[pDevNames->wDeviceOffset]); - strcpy(device, NS_ConvertUTF16toUTF8(printerName).get()); - ::GlobalUnlock(hDevNames); - - // Create a Moveable Memory Object that holds a new DevMode - // from the Printer Name - // The PRINTDLG.hDevMode requires that it be a moveable memory object - // NOTE: We only need to free hGlobalDevMode when the dialog is cancelled - // When the user prints, it comes back in the printdlg struct and - // is used and cleaned up later -#ifdef UNICODE - hGlobalDevMode = CreateGlobalDevModeAndInit(printerName, aPrintSettings); -#else - hGlobalDevMode = CreateGlobalDevModeAndInit(NS_CONST_CAST(char*, NS_ConvertUTF16toUTF8(printerName).get()), aPrintSettings); -#endif - - // Prepare to Display the Print Dialog - PRINTDLG prntdlg; - memset(&prntdlg, 0, sizeof(PRINTDLG)); - - prntdlg.lStructSize = sizeof(prntdlg); - prntdlg.hwndOwner = aHWnd; - prntdlg.hDevMode = hGlobalDevMode; - prntdlg.hDevNames = hDevNames; - prntdlg.hDC = NULL; - prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC | PD_HIDEPRINTTOFILE | PD_USEDEVMODECOPIESANDCOLLATE; - - // if there is a current selection then enable the "Selection" radio button - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - PRBool isOn; - aPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - if (!isOn) { - prntdlg.Flags |= PD_NOSELECTION; - } - aPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); - - prntdlg.nFromPage = 0xFFFF; - prntdlg.nToPage = 0xFFFF; - prntdlg.nMinPage = 1; - prntdlg.nMaxPage = 0xFFFF; - prntdlg.nCopies = 1; - prntdlg.lpfnSetupHook = NULL; - prntdlg.lpSetupTemplateName = NULL; - prntdlg.hPrintTemplate = NULL; - prntdlg.hSetupTemplate = NULL; - - prntdlg.hInstance = NULL; - prntdlg.lpPrintTemplateName = NULL; - - if (!ShouldExtendPrintDialog()) { - prntdlg.lCustData = NULL; - prntdlg.lpfnPrintHook = NULL; - } else { - // Set up print dialog "hook" procedure for extending the dialog - prntdlg.lCustData = (DWORD)howToEnableFrameUI; - prntdlg.lpfnPrintHook = (LPPRINTHOOKPROC)PrintHookProc; - prntdlg.Flags |= PD_ENABLEPRINTHOOK; - } - - BOOL result = ::PrintDlg(&prntdlg); - - if (TRUE == result) { - if (aPrintSettings && prntdlg.hDevMode != NULL) { - // Transfer the settings from the native data to the PrintSettings - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - SetPrintSettingsFromDevMode(aPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - } - DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(prntdlg.hDevNames); - if ( NULL != devnames ) { - - char* device = &(((char *)devnames)[devnames->wDeviceOffset]); - char* driver = &(((char *)devnames)[devnames->wDriverOffset]); - - nsCOMPtr psWin(do_QueryInterface(aPrintSettings)); - // Setup local Data members - psWin->SetDeviceName(device); - psWin->SetDriverName(driver); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - printf("printer: driver %s, device %s flags: %d\n", driver, device, prntdlg.Flags); -#endif - // fill the print options with the info from the dialog - if (aPrintSettings != nsnull) { - nsString printerName; - printerName.AssignWithConversion(device); - - aPrintSettings->SetPrinterName(printerName.get()); - - if (prntdlg.Flags & PD_SELECTION) { - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection); - - } else if (prntdlg.Flags & PD_PAGENUMS) { - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange); - aPrintSettings->SetStartPageRange(prntdlg.nFromPage); - aPrintSettings->SetEndPageRange(prntdlg.nToPage); - - } else { // (prntdlg.Flags & PD_ALLPAGES) - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - if (howToEnableFrameUI != nsIPrintSettings::kFrameEnableNone) { - // make sure the dialog got extended - if (gDialogWasExtended) { - // check to see about the frame radio buttons - switch (gFrameSelectedRadioBtn) { - case rad4: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - break; - case rad5: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - break; - case rad6: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - break; - } // switch - } else { - // if it didn't get extended then have it default to printing - // each frame separately - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - } else { - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kNoFrames); - } - } - ::GlobalUnlock(prntdlg.hDevNames); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - PRBool printSelection = prntdlg.Flags & PD_SELECTION; - PRBool printAllPages = prntdlg.Flags & PD_ALLPAGES; - PRBool printNumPages = prntdlg.Flags & PD_PAGENUMS; - PRInt32 fromPageNum = 0; - PRInt32 toPageNum = 0; - - if (printNumPages) { - fromPageNum = prntdlg.nFromPage; - toPageNum = prntdlg.nToPage; - } - if (printSelection) { - printf("Printing the selection\n"); - - } else if (printAllPages) { - printf("Printing all the pages\n"); - - } else { - printf("Printing from page no. %d to %d\n", fromPageNum, toPageNum); - } -#endif - - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - psWin->SetDevMode(devMode); - SetPrintSettingsFromDevMode(aPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - - } - } else { - aPrintSettings->SetIsCancelled(PR_TRUE); - ::GlobalFree(hGlobalDevMode); - return NS_ERROR_ABORT; - } - - return NS_OK; -} - - -#ifdef MOZ_REQUIRE_CURRENT_SDK -//------------------------------------------------------------------ -// Callback for Property Sheet -static BOOL APIENTRY PropSheetCallBack(HWND hdlg, UINT uiMsg, UINT wParam, LONG lParam) -{ - if (uiMsg == WM_COMMAND) { - UINT id = LOWORD(wParam); - if (id == rad4 || id == rad5 || id == rad6) { - gFrameSelectedRadioBtn = id; - SetRadioOfGroup(hdlg, id); - } - - } else if (uiMsg == WM_INITDIALOG) { - // Create the groupbox and Radiobuttons on the "Options" Property Sheet - - // We temporarily borrowed the global value for initialization - // now clear it before the dialog appears - PRInt16 howToEnableFrameUI = gFrameSelectedRadioBtn; - gFrameSelectedRadioBtn = 0; - - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hdlg, GWL_HINSTANCE); - if (hInst == NULL) return 0L; - - // Get default font for the dialog & then its font metrics - // we need the text height to determine the height of the radio buttons - TEXTMETRIC metrics; - HFONT hFont = (HFONT)::SendMessage(hdlg, WM_GETFONT, (WPARAM)0, (LPARAM)0); - HDC localDC = ::GetDC(hdlg); - ::SelectObject(localDC, (HGDIOBJ)hFont); - ::GetTextMetrics(localDC, &metrics); - ::ReleaseDC(hdlg, localDC); - - // calculate various different "gaps" for layout purposes - RECT dlgr; - ::GetWindowRect(hdlg, &dlgr); - - int horzGap = 5; // generic horz gap - int vertGap = 5; // generic vert gap - int rbGap = metrics.tmHeight / 2; // gap between radiobtns - int top = vertGap*2; // start at the top - int radHgt = metrics.tmHeight; // top of new group box - int y = top; // starting pos of first radio - int x = horzGap*2; - int rbWidth = dlgr.right - dlgr.left - (5*horzGap); - int grpWidth = dlgr.right - dlgr.left - (2*horzGap); - - nsRect rect; - - // Create and position the radio buttons - // - // If any one control cannot be created then - // hide the others and bail out - // - x += horzGap*2; - y += vertGap + metrics.tmHeight; - rect.SetRect(x, y, rbWidth,radHgt); - HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect); - if (rad4Wnd == NULL) return 0L; - y += radHgt + rbGap; - - rect.SetRect(x, y, rbWidth, radHgt); - HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, kTheSelectedFrameStr, rect); - if (rad5Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - return 0L; - } - y += radHgt + rbGap; - - rect.SetRect(x, y, rbWidth, radHgt); - HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, kEachFrameSeparately, rect); - if (rad6Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - return 0L; - } - y += radHgt + (vertGap*2); - - x -= horzGap*2; - // Create and position the group box - rect.SetRect (x, top, grpWidth, y-top+1); - HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect); - if (grpBoxWnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - Show(rad6Wnd, FALSE); // hide - return 0L; - } - - // localize and initialize the groupbox and radiobuttons - InitializeExtendedDialog(hdlg, howToEnableFrameUI); - - // Looks like we were able to extend the dialog - gDialogWasExtended = PR_TRUE; - } - return 0L; -} - -//------------------------------------------------------------------ -// Creates the "Options" Property Sheet -static HPROPSHEETPAGE ExtendPrintDialog(HWND aHWnd, char* aTitle) -{ - // The resource "OPTPROPSHEET" comes out of the widget/build/widget.rc file - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(aHWnd, GWL_HINSTANCE); - PROPSHEETPAGE psp; - memset(&psp, 0, sizeof(PROPSHEETPAGE)); - psp.dwSize = sizeof(PROPSHEETPAGE); - psp.dwFlags = PSP_USETITLE | PSP_PREMATURE; - psp.hInstance = hInst; - psp.pszTemplate = "OPTPROPSHEET"; - psp.pfnDlgProc = PropSheetCallBack; - psp.pszTitle = aTitle?aTitle:"Options"; - - HPROPSHEETPAGE newPropSheet = ::CreatePropertySheetPage(&psp); - return newPropSheet; - -} - -//------------------------------------------------------------------ -// Displays the native Print Dialog -static nsresult -ShowNativePrintDialogEx(HWND aHWnd, - nsIPrintSettings* aPrintSettings) -{ - NS_ENSURE_ARG_POINTER(aHWnd); - NS_ENSURE_ARG_POINTER(aPrintSettings); - - nsresult rv = NS_ERROR_FAILURE; - gDialogWasExtended = PR_FALSE; - - // Create a Moveable Memory Object that holds a new DevMode - // from the Printer Name - // The PRINTDLG.hDevMode requires that it be a moveable memory object - // NOTE: We only need to free hGlobalDevMode when the dialog is cancelled - // When the user prints, it comes back in the printdlg struct and - // is used and cleaned up later - PRUnichar * printerName; - aPrintSettings->GetPrinterName(&printerName); - HGLOBAL hGlobalDevMode = NULL; - if (printerName) { -#ifdef UNICODE - hGlobalDevMode = CreateGlobalDevModeAndInit(printerName, aPrintSettings); -#else - hGlobalDevMode = CreateGlobalDevModeAndInit(NS_CONST_CAST(char*, NS_ConvertUTF16toUTF8(printerName).get()), aPrintSettings); -#endif - } - - // Prepare to Display the Print Dialog - PRINTDLGEX prntdlg; - memset(&prntdlg, 0, sizeof(PRINTDLGEX)); - - prntdlg.lStructSize = sizeof(prntdlg); - prntdlg.hwndOwner = aHWnd; - prntdlg.hDevMode = hGlobalDevMode; - prntdlg.Flags = PD_ALLPAGES | PD_RETURNDC | PD_HIDEPRINTTOFILE | PD_USEDEVMODECOPIESANDCOLLATE | - PD_NOCURRENTPAGE; - prntdlg.nStartPage = START_PAGE_GENERAL; - - // if there is a current selection then enable the "Selection" radio button - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - if (aPrintSettings != nsnull) { - PRBool isOn; - aPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - if (!isOn) { - prntdlg.Flags |= PD_NOSELECTION; - } - aPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); - } - - // At the moment we can only support one page range - // from all the documentation I can find, it appears that this - // will get cleanup automatically when the struct goes away - const int kNumPageRanges = 1; - LPPRINTPAGERANGE pPageRanges = (LPPRINTPAGERANGE) GlobalAlloc(GPTR, kNumPageRanges * sizeof(PRINTPAGERANGE)); - if (!pPageRanges) - return E_OUTOFMEMORY; - - prntdlg.nPageRanges = 0; - prntdlg.nMaxPageRanges = kNumPageRanges; - prntdlg.lpPageRanges = pPageRanges; - prntdlg.nMinPage = 1; - prntdlg.nMaxPage = 0xFFFF; - prntdlg.nCopies = 1; - - if (ShouldExtendPrintDialog()) { - // lLcalize the Property Sheet (Tab) title - char* pTitle = NULL; - nsString optionsStr; - if (NS_SUCCEEDED(GetLocalizedString(strBundle, "options", optionsStr))) { - pTitle = GetACPString(optionsStr); - } - - // Temporarily borrow this variable for setting up the radiobuttons - // if we don't use this, we will need to define a new global var - gFrameSelectedRadioBtn = howToEnableFrameUI; - HPROPSHEETPAGE psp[1]; - psp[0] = ExtendPrintDialog(aHWnd, pTitle); - prntdlg.nPropertyPages = 1; - prntdlg.lphPropertyPages = psp; - } - - HRESULT result = ::PrintDlgEx(&prntdlg); - - if (S_OK == result && (prntdlg.dwResultAction == PD_RESULT_PRINT)) { - if (aPrintSettings && prntdlg.hDevMode != NULL) { - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - SetPrintSettingsFromDevMode(aPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - } - DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(prntdlg.hDevNames); - if ( NULL != devnames ) { - - char* device = &(((char *)devnames)[devnames->wDeviceOffset]); - char* driver = &(((char *)devnames)[devnames->wDriverOffset]); - - nsCOMPtr psWin(do_QueryInterface(aPrintSettings)); - // Setup local Data members - psWin->SetDeviceName(device); - psWin->SetDriverName(driver); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - printf("printer: driver %s, device %s flags: %d\n", driver, device, prntdlg.Flags); -#endif - ::GlobalUnlock(prntdlg.hDevNames); - - // fill the print options with the info from the dialog - if (aPrintSettings != nsnull) { - - if (prntdlg.Flags & PD_SELECTION) { - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection); - - } else if (prntdlg.Flags & PD_PAGENUMS) { - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange); - aPrintSettings->SetStartPageRange(pPageRanges->nFromPage); - aPrintSettings->SetEndPageRange(pPageRanges->nToPage); - - } else { // (prntdlg.Flags & PD_ALLPAGES) - aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - if (howToEnableFrameUI != nsIPrintSettings::kFrameEnableNone) { - // make sure the dialog got extended - if (gDialogWasExtended) { - // check to see about the frame radio buttons - switch (gFrameSelectedRadioBtn) { - case rad4: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - break; - case rad5: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - break; - case rad6: - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - break; - } // switch - } else { - // if it didn't get extended then have it default to printing - // each frame separately - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - } else { - aPrintSettings->SetPrintFrameType(nsIPrintSettings::kNoFrames); - } - } - - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - PRBool printSelection = prntdlg.Flags & PD_SELECTION; - PRBool printAllPages = prntdlg.Flags & PD_ALLPAGES; - PRBool printNumPages = prntdlg.Flags & PD_PAGENUMS; - PRInt32 fromPageNum = 0; - PRInt32 toPageNum = 0; - - if (printNumPages) { - fromPageNum = pPageRanges->nFromPage; - toPageNum = pPageRanges->nToPage; - } - if (printSelection) { - printf("Printing the selection\n"); - - } else if (printAllPages) { - printf("Printing all the pages\n"); - - } else { - printf("Printing from page no. %d to %d\n", fromPageNum, toPageNum); - } -#endif - - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - psWin->SetDevMode(devMode); - SetPrintSettingsFromDevMode(aPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - - } - } else { - if (hGlobalDevMode) ::GlobalFree(hGlobalDevMode); - return NS_ERROR_ABORT; - } - - ::GlobalFree(pPageRanges); - - return NS_OK; -} -#endif // MOZ_REQUIRE_CURRENT_SDK - -//------------------------------------------------------------------ -static void -PrepareForPrintDialog(nsIWebBrowserPrint* aWebBrowserPrint, nsIPrintSettings* aPS) -{ - NS_ASSERTION(aWebBrowserPrint, "Can't be null"); - NS_ASSERTION(aPS, "Can't be null"); - - PRBool isFramesetDocument; - PRBool isFramesetFrameSelected; - PRBool isIFrameSelected; - PRBool isRangeSelection; - - aWebBrowserPrint->GetIsFramesetDocument(&isFramesetDocument); - aWebBrowserPrint->GetIsFramesetFrameSelected(&isFramesetFrameSelected); - aWebBrowserPrint->GetIsIFrameSelected(&isIFrameSelected); - aWebBrowserPrint->GetIsRangeSelection(&isRangeSelection); - - // Setup print options for UI - if (isFramesetDocument) { - if (isFramesetFrameSelected) { - aPS->SetHowToEnableFrameUI(nsIPrintSettings::kFrameEnableAll); - } else { - aPS->SetHowToEnableFrameUI(nsIPrintSettings::kFrameEnableAsIsAndEach); - } - } else { - aPS->SetHowToEnableFrameUI(nsIPrintSettings::kFrameEnableNone); - } - - // Now determine how to set up the Frame print UI - aPS->SetPrintOptions(nsIPrintSettings::kEnableSelectionRB, isRangeSelection || isIFrameSelected); - -} - -//---------------------------------------------------------------------------------- -//-- Show Print Dialog -//---------------------------------------------------------------------------------- -nsresult NativeShowPrintDialog(HWND aHWnd, - nsIWebBrowserPrint* aWebBrowserPrint, - nsIPrintSettings* aPrintSettings) -{ - nsresult rv = NS_ERROR_FAILURE; - - PrepareForPrintDialog(aWebBrowserPrint, aPrintSettings); - -#ifdef MOZ_REQUIRE_CURRENT_SDK - if (CheckForExtendedDialog()) { - rv = ShowNativePrintDialogEx(aHWnd, aPrintSettings); - } else { - rv = ShowNativePrintDialog(aHWnd, aPrintSettings); - } -#else - rv = ShowNativePrintDialog(aHWnd, aPrintSettings); -#endif - - return rv; -} - diff --git a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.h b/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.h deleted file mode 100644 index 58ed7ab113c..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/nsPrintDialogUtil.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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 ***** */ -#ifndef nsFlyOwnDialog_h___ -#define nsFlyOwnDialog_h___ - -nsresult NativeShowPrintDialog(HWND aHWnd, - nsIWebBrowserPrint* aWebBrowserPrint, - nsIPrintSettings* aPrintSettings); - -#endif /* nsFlyOwnDialog_h___ */ diff --git a/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.cpp b/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.cpp deleted file mode 100644 index 1b2a0662213..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsPrintProgressParams.h" -#include "nsReadableUtils.h" - - -NS_IMPL_ISUPPORTS1(nsPrintProgressParams, nsIPrintProgressParams) - -nsPrintProgressParams::nsPrintProgressParams() -{ -} - -nsPrintProgressParams::~nsPrintProgressParams() -{ -} - -/* attribute wstring docTitle; */ -NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(PRUnichar * *aDocTitle) -{ - NS_ENSURE_ARG(aDocTitle); - - *aDocTitle = ToNewUnicode(mDocTitle); - return NS_OK; -} - -NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const PRUnichar * aDocTitle) -{ - mDocTitle = aDocTitle; - return NS_OK; -} - -/* attribute wstring docURL; */ -NS_IMETHODIMP nsPrintProgressParams::GetDocURL(PRUnichar * *aDocURL) -{ - NS_ENSURE_ARG(aDocURL); - - *aDocURL = ToNewUnicode(mDocURL); - return NS_OK; -} - -NS_IMETHODIMP nsPrintProgressParams::SetDocURL(const PRUnichar * aDocURL) -{ - mDocURL = aDocURL; - return NS_OK; -} - diff --git a/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.h b/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.h deleted file mode 100644 index aac5c666c36..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/nsPrintProgressParams.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** 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): - * Rod Spears - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef __nsPrintProgressParams_h -#define __nsPrintProgressParams_h - -#include "nsIPrintProgressParams.h" -#include "nsString.h" - -class nsPrintProgressParams : public nsIPrintProgressParams -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIPRINTPROGRESSPARAMS - - nsPrintProgressParams(); - virtual ~nsPrintProgressParams(); - -private: - nsString mDocTitle; - nsString mDocURL; -}; - -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/resource.h b/mozilla/embedding/tests/mfcembed/components/resource.h deleted file mode 100644 index aa4d285c93b..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/resource.h +++ /dev/null @@ -1,51 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Dialogs.rc -// -#define IDD_PROMPT_DIALOG 128 -#define IDD_PROMPT_PASSWORD_DIALOG 129 -#define IDD_PROMPT_USERPASS_DIALOG 130 -#define IDD_ALERT_CHECK_DIALOG 131 -#define IDD_CONFIRM_CHECK_DIALOG 132 -#define IDD_PROGRESS_DIALOG 133 -#define IDD_CHOOSE_ACTION_DIALOG 134 -#define IDD_PRINT_PROGRESS_DIALOG 143 -#define IDC_PROMPT_ANSWER 1001 -#define IDC_PROMPT_TEXT 1002 -#define IDC_USERNAME 1003 -#define IDC_PASSWORD 1004 -#define IDC_CHECK_SAVE_PASSWORD 1005 -#define IDC_USERNAME_LABEL 1006 -#define IDC_PASSWORD_LABEL 1007 -#define IDC_CHECKBOX 1008 -#define IDC_MSG_TEXT 1009 -#define IDC_BTN1 1010 -#define IDC_BTN2 1011 -#define IDC_BTN3 1012 -#define IDC_ACTION 1013 -#define IDC_SAVING_FROM 1014 -#define IDC_PROGRESS 1015 -#define IDC_CONTENT_TYPE 1016 -#define IDC_SAVE_TO_DISK 1017 -#define IDC_OPEN_USING 1018 -#define IDC_CHOOSE_APP 1019 -#define IDC_APP_NAME 1020 -#define IDC_PRINT_PROGRESS_URL_TXT 1022 -#define IDC_PRINT_PROGRESS_PRG 1023 -#define IDC_PRINT_PROGRESS_PERCENT_TXT 1024 -#define IDC_PRINT_PROGRESS_URL_LABEL_TXT 1025 -#define IDC_PRINT_PROGRESS_TXT 1026 - - - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 144 -#define _APS_NEXT_COMMAND_VALUE 32789 -#define _APS_NEXT_CONTROL_VALUE 1027 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/mozilla/embedding/tests/mfcembed/components/stdafx.h b/mozilla/embedding/tests/mfcembed/components/stdafx.h deleted file mode 100644 index 99209e4f2e9..00000000000 --- a/mozilla/embedding/tests/mfcembed/components/stdafx.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- 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): - * Chak Nanga - * - * ***** END LICENSE BLOCK ***** */ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef _STDAFX_H -#define _STDAFX_H - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -// -// These headers are very evil, as they will define DEBUG if _DEBUG is -// defined, which is lame and not what we want for things like -// MOZ_TRACE_MALLOC and other tools. -// If we do not detect this, various MOZ/NS debug symbols are undefined -// and we can not build. -// /MDd defines _DEBUG automagically to have the right debug C LIB -// functions get called (so we can get symbols and hook into malloc). -// -#if !defined(DEBUG) -#define THERECANBENODEBUG -#endif - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#include // Needed for MFC MBCS/Unicode Conversion Macros -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#if defined(THERECANBENODEBUG) && defined(DEBUG) -#undef DEBUG -#endif - -#endif //_STDAFX_H diff --git a/mozilla/embedding/tests/mfcembed/mfcembed.dsp b/mozilla/embedding/tests/mfcembed/mfcembed.dsp deleted file mode 100644 index f78b52adfd4..00000000000 --- a/mozilla/embedding/tests/mfcembed/mfcembed.dsp +++ /dev/null @@ -1,389 +0,0 @@ -# Microsoft Developer Studio Project File - Name="mfcembed" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) External Target" 0x0106 - -CFG=mfcembed - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "mfcembed.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mfcembed.mak" CFG="mfcembed - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mfcembed - Win32 Release" (based on "Win32 (x86) External Target") -!MESSAGE "mfcembed - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" - -!IF "$(CFG)" == "mfcembed - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Cmd_Line "NMAKE /f mfcembed.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "mfcembed.exe" -# PROP BASE Bsc_Name "mfcembed.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Cmd_Line "nmake /f "makfile.win"" -# PROP Rebuild_Opt "/a" -# PROP Target_File "WIN32_O.OBJ\mfcembed.exe" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ELSEIF "$(CFG)" == "mfcembed - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Cmd_Line "NMAKE /f mfcembed.mak" -# PROP BASE Rebuild_Opt "/a" -# PROP BASE Target_File "mfcembed.exe" -# PROP BASE Bsc_Name "mfcembed.bsc" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Cmd_Line "nmake /f "makefile.win"" -# PROP Rebuild_Opt "/a" -# PROP Target_File "WIN32_D.OBJ\mfcembed.exe" -# PROP Bsc_Name "" -# PROP Target_Dir "" - -!ENDIF - -# Begin Target - -# Name "mfcembed - Win32 Release" -# Name "mfcembed - Win32 Debug" - -!IF "$(CFG)" == "mfcembed - Win32 Release" - -!ELSEIF "$(CFG)" == "mfcembed - Win32 Debug" - -!ENDIF - -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\BrowserFrameGlue.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserFrm.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserImpl.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserImplCtxMenuLstnr.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserImplPrompt.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserImplWebPrgrsLstnr.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserToolTip.cpp -# End Source File -# Begin Source File - -SOURCE=.\BrowserView.cpp -# End Source File -# Begin Source File - -SOURCE=.\CFormatOptionTab.cpp -# End Source File -# Begin Source File - -SOURCE=.\CMarginHeaderFooter.cpp -# End Source File -# Begin Source File - -SOURCE=.\CPageSetupPropSheet.cpp -# End Source File -# Begin Source File - -SOURCE=.\Dialogs.cpp -# End Source File -# Begin Source File - -SOURCE=.\EditorFrm.cpp -# End Source File -# Begin Source File - -SOURCE=.\MfcEmbed.cpp -# End Source File -# Begin Source File - -SOURCE=.\MfcEmbed.rc -# End Source File -# Begin Source File - -SOURCE=.\MostRecentUrls.cpp -# End Source File -# Begin Source File - -SOURCE=.\Preferences.cpp -# End Source File -# Begin Source File - -SOURCE=.\ProfileMgr.cpp -# End Source File -# Begin Source File - -SOURCE=.\ProfilesDlg.cpp -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# End Source File -# Begin Source File - -SOURCE=.\winEmbedFileLocProvider.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\BrowserFrm.h -# End Source File -# Begin Source File - -SOURCE=.\BrowserImpl.h -# End Source File -# Begin Source File - -SOURCE=.\BrowserToolTip.h -# End Source File -# Begin Source File - -SOURCE=.\BrowserView.h -# End Source File -# Begin Source File - -SOURCE=.\CMarginHeaderFooter.h -# End Source File -# Begin Source File - -SOURCE=.\Dialogs.h -# End Source File -# Begin Source File - -SOURCE=.\EditorFrm.h -# End Source File -# Begin Source File - -SOURCE=.\IBrowserFrameGlue.h -# End Source File -# Begin Source File - -SOURCE=.\MfcEmbed.h -# End Source File -# Begin Source File - -SOURCE=.\MostRecentUrls.h -# End Source File -# Begin Source File - -SOURCE=.\Preferences.h -# End Source File -# Begin Source File - -SOURCE=.\ProfileMgr.h -# End Source File -# Begin Source File - -SOURCE=.\ProfilesDlg.h -# End Source File -# Begin Source File - -SOURCE=.\resource.h -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# Begin Source File - -SOURCE=.\winEmbedFileLocProvider.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# Begin Source File - -SOURCE=.\res\broken.ico -# End Source File -# Begin Source File - -SOURCE=.\res\mainfram.bmp -# End Source File -# Begin Source File - -SOURCE=.\res\mfcembed.ico -# End Source File -# Begin Source File - -SOURCE=.\res\sinsecur.ico -# End Source File -# Begin Source File - -SOURCE=.\res\ssecur.ico -# End Source File -# Begin Source File - -SOURCE=.\res\Toolbar.bmp -# End Source File -# End Group -# Begin Group "Interfaces" - -# PROP Default_Filter "*.idl" -# Begin Source File - -SOURCE=..\..\components\commandhandler\public\nsICommandManager.idl -# End Source File -# Begin Source File - -SOURCE=..\..\components\commandhandler\public\nsICommandParams.idl -# End Source File -# Begin Source File - -SOURCE=..\..\..\content\xul\document\public\nsIController.idl -# End Source File -# Begin Source File - -SOURCE=..\..\components\commandhandler\public\nsIControllerCommand.idl -# End Source File -# Begin Source File - -SOURCE=..\..\components\commandhandler\public\nsIControllerCommandManager.idl -# End Source File -# End Group -# Begin Group "implementations" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\components\commandhandler\src\nsCommandManager.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\components\commandhandler\src\nsCommandManager.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\editor\composer\src\nsComposerCommands.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\components\commandhandler\src\nsControllerCommandManager.cpp -# End Source File -# End Group -# Begin Group "Component Source Files" - -# PROP Default_Filter "*.cpp" -# Begin Source File - -SOURCE=.\components\Dialogs.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\HelperAppDlg.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\nsPrintDialogUtil.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\nsPrintProgressParams.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\PrintingPromptService.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\PrintProgressDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\components\PromptService.cpp -# End Source File -# End Group -# Begin Group "Component Header Files" - -# PROP Default_Filter "*.h" -# Begin Source File - -SOURCE=.\components\Dialogs.h -# End Source File -# Begin Source File - -SOURCE=.\components\HelperAppDlg.h -# End Source File -# Begin Source File - -SOURCE=.\components\HelperAppService.h -# End Source File -# Begin Source File - -SOURCE=.\components\nsPrintDialogUtil.h -# End Source File -# Begin Source File - -SOURCE=.\components\nsPrintProgressParams.h -# End Source File -# Begin Source File - -SOURCE=.\components\PrintingPromptService.h -# End Source File -# Begin Source File - -SOURCE=.\components\PrintProgressDialog.h -# End Source File -# Begin Source File - -SOURCE=.\components\PromptService.h -# End Source File -# Begin Source File - -SOURCE=.\components\resource.h -# End Source File -# Begin Source File - -SOURCE=.\components\stdafx.h -# End Source File -# End Group -# End Target -# End Project diff --git a/mozilla/embedding/tests/mfcembed/mfcembed.dsw b/mozilla/embedding/tests/mfcembed/mfcembed.dsw deleted file mode 100644 index 0660ff98912..00000000000 --- a/mozilla/embedding/tests/mfcembed/mfcembed.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "mfcembed"=.\mfcembed.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/mozilla/embedding/tests/mfcembed/mfcembed.htm b/mozilla/embedding/tests/mfcembed/mfcembed.htm deleted file mode 100644 index e698ab44356..00000000000 --- a/mozilla/embedding/tests/mfcembed/mfcembed.htm +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - MfcEmbed JavaScript Tests - - - - -

Exercising MfcEmbed's Interfaces

-

-This test page serves as a testbed to exercise some of the interfaces -MfcEmbed implements - such as nsIWebBrowserChrome, nsIPrompt etc. -

You can test these by loading mfcembed in the debugger and setting breakpoints -in the interface methods discussed below. Then clicking on these links -will break in the debugger at the specified locations for you to explore -these interface implementations further.

-

Open a simple JavaScript window with -defaults for size etc: -

Invokes nsIWebBrowserChrome::CreateBrowserWindow() -to create the window
-Open a JavaScript window with -only its size specified (Not Resizable) -
Invokes nsIWebBrowserChrome::CreateBrowserWindow() -to create the window and also invokes nsIWebBrowserChrome::SizeBrowserTo() -to set the window size. This also shows how we handle the chromeMask to -make the window non-resizeable
-Open a window with -chrome and its size specified (Resizable) -
Invokes nsIWebBrowserChrome::CreateBrowserWindow() -to create the window and also invokes nsIWebBrowserChrome::SizeBrowserTo() -to set the window size -
All of the above tests also invoke nsIWebBrowserChrome::FindNamedBrowserItem() -to find the named target window in the JavaScript code.
- - - diff --git a/mozilla/embedding/tests/mfcembed/mfcembed.pkg b/mozilla/embedding/tests/mfcembed/mfcembed.pkg deleted file mode 100644 index 8f465e78acc..00000000000 --- a/mozilla/embedding/tests/mfcembed/mfcembed.pkg +++ /dev/null @@ -1,4 +0,0 @@ -[mfcembed] -dist/bin/mfcembed.exe -dist/bin/mfcEmbedComponents.dll -dist/bin/mfcembed.htm diff --git a/mozilla/embedding/tests/mfcembed/res/Toolbar.bmp b/mozilla/embedding/tests/mfcembed/res/Toolbar.bmp deleted file mode 100644 index ef033d329e12e30cd107d1c400dd4b4acf991908..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1198 zcmcJPv5Ffp5QaC9!r<cniP3}K=J_MR)!Q?2s9xEm$`k3aAn{ccXn}) z<6^tbH?ym=?>I=Bj8~(PX8!qSM&S21zuq<`x9E4Q#JXa=X=cau;^*px^i9Lp^!>b{ zFX0wS3$fLA7$%gG~s}@qB(wg%lL0&w!?Jx{KEy)FTeZQIk(Mpx} diff --git a/mozilla/embedding/tests/mfcembed/res/broken.ico b/mozilla/embedding/tests/mfcembed/res/broken.ico deleted file mode 100644 index 538b7e45f7dfbe01196c1ce38eb8c8619cc430e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2126 zcmeH{El*rQ6o%iW+uXegAz(A> zwzjr(aB!f#y*=&j?rM8`Tiu(g{r#$Ux={U5^yT8GE^co0_S0tqC8|*~wam?gme3Mf za*cP$ml(P+FmyvVbl;ZIGkV6z=oy_(1-+mb^ny^(D|W@MB_b!#HPf18{ugZ z3<-t=LxLfYU`Q||7!nK#hQNd&!H{4`FeDfP9fkx$f+4|>U`Q1Wjs!m1~uz)_ro2aDroQ-P(xQh+D~j4J?3 zVPj!YK`5~Br{ae*DX-)ZKTiD%nVFrA_gycRczPs^>MP;~1e4;%93}#_& diff --git a/mozilla/embedding/tests/mfcembed/res/mainfram.bmp b/mozilla/embedding/tests/mfcembed/res/mainfram.bmp deleted file mode 100644 index bd04503b9f665ee7123d4500b9ca23a7abac0c37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2854 zcmd6pJ#HH@5QS+V1sxTMeF!5(P7y2+HbE{Uq@H363NF-YZ{adP8XZc2;!1gMIQ;Sc zcmoRoLTkyl{26}xI4k+fw}*|>@&olJT%T{8yGMKD-f92Sdu?VaaSk6Rk{Z;IxWpZg zM+{u_<1QB}T=-)bs`y_P_cpG&YWO#gwaNw8wfI<7l<192;vtd2dX(Rwtm+EnRj%3C z;z6b(;&<^tRcWe4V2HbCoTEKbDU~-fMeCAsv0iJ6r3)F6tQoW0`>dt zUI#~9;?s(TtMoLSvf&=WOBD>OG*zXPOc7~fQm@wG98R3D&V^_xCYdd|Jd%k9m>SYK z-ZItdiE2g}4N?;8QDB$0F~Y85Snlp(r-m6<_9?fzr|0^ddaa6a^Q40q&x$S$gL0{1 z%rr*H5et|0FIL}yMZ*$Twb-7H5!1O9`=t_M=%=^PSpnwxHLkQ17SSY2Fe(kxQ>g^h ziH42*vfRYv%H?$_r)GuY`;{LcD?PpOIl`?Rr*K)cg{I$!K7_(mc=C3Ii(-;rIjs=f z5)64ipp4J4;mQYEtZBZ#l2p`i`nsLr%Bw4v*XgXPf-dHnBGr^DVw(Ak$gSfg>PWz_ zbC~)yb>!3}jLb9s)T}@Kod(893@u8ajANzT`op9^o+)S?=nU(FD@%0s)Sg^oyC8{H z9myetc;MEP)59v(LMa~xK8Yu^jIR*H22uCFiq5%C{s7(PJi>o15i^bmX4(vPxWAio z9ryY#AU_jfnd047-@`)XzL?%iS$gQyFP{44kS9X)fN{{QoL~hO-&=q&20Zr*cxFAt PkaNE{wR~2C$NfnjhSXWT diff --git a/mozilla/embedding/tests/mfcembed/res/mfcembed.rc2 b/mozilla/embedding/tests/mfcembed/res/mfcembed.rc2 deleted file mode 100644 index 339464a26a1..00000000000 --- a/mozilla/embedding/tests/mfcembed/res/mfcembed.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// MFCEMBED.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/embedding/tests/mfcembed/res/sinsecur.ico b/mozilla/embedding/tests/mfcembed/res/sinsecur.ico deleted file mode 100644 index cb4e3ad2ad1a01b3cd4fb76d07aa99d992869757..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2126 zcmeH{El*rQ6o%i0ZFX-$2pCeaf+CutN8t#b1cN52IQtVY6<48~G$9#>Xq!~j@C#N| zlu51wQxt-RG%2`EDyGjl3$$sdsi|mZcRtQLGv_?_%-k#WG^f?oC3*QgCq1QKS`1U0 zkEF$U=^5rKb(7jtpH^yF`*3NQWTtIr9W6smCKGy}sPR{=KBDq-$(#S>pUwbx;I9_H z=l&*)s67qiEFSlwd!T8#%@ecVCLpKJ7Zs>;Y+cJ7a&lnj!qtmIN7xaQ&5DI$5uGqCiEJ7%Y(%I1CPh!{9JDB2{o033`d%9j);v;{7n2zd_SU0 z{7h~#3>k(@9{kwIN<2LZJ*^)jIVi*{uoXB8@#1KmgB%n%igWN_aolVwuoPGd5QTto z1z;&`EG#Mr1s48P{BR}(mg4yc7QYRC3TQA?7%B`Eh6+Q4A+8e)1%?Vkg`vQJ8!GEz zs4!F*Dh#-$qQg*Os4!FjD)9@>DjO?{3?GJVaMbYaYfMk{MtggE+TY*T!NGwJ4-a*6 za-!qoW1XFy>HPd$7Z(@0y1LTM&5fqhsjk0Oy*@hPJ#NXazXRUkFD&=#X4T-=(v7)Z ze#6wo)VS&9qja;iQW9yBaq+g))V;~(ao%;Wx1`3_BqKZO7Q diff --git a/mozilla/embedding/tests/mfcembed/res/ssecur.ico b/mozilla/embedding/tests/mfcembed/res/ssecur.ico deleted file mode 100644 index 1b51b531cb9adceefdf7c37d48ffc87e68ab6bfc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1366 zcmeHGK?=e!5Zu~=LP7cfksf`4=NyXooE(HL8v`xX+ffwM1jA)0M5+M)?VFS?kb{ZN@bhHi$ zD@tnH7TGtt{-v(-6#|dn^2;ATtpGgmRd}C!=a-1+^A`0qG(3(DJl!X(C};VcuT>=| zXJzW9ISb2X$$S#-#d*YK;7wf}F|VA-uhJ>DCYRD$rHoif$Lx&bp5HX(3O`ZKS - * Benjamin Smedberg - * - * ***** END LICENSE BLOCK ***** */ - -#include "winEmbedFileLocProvider.h" -#include "nsXPCOM.h" -#include "nsXPCOMGlue.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsDirectoryServiceDefs.h" -#include "nsILocalFile.h" -#include "nsIProperties.h" -#include "nsServiceManagerUtils.h" - -#include -#include - - -// WARNING: These hard coded names need to go away. They need to -// come from localizable resources -#define APP_REGISTRY_NAME nsEmbedCString("registry.dat") - -#define PROFILE_ROOT_DIR_NAME nsEmbedCString("Profiles") -#define DEFAULTS_DIR_NAME nsEmbedCString("defaults") -#define DEFAULTS_PREF_DIR_NAME nsEmbedCString("pref") -#define DEFAULTS_PROFILE_DIR_NAME nsEmbedCString("profile") -#define RES_DIR_NAME nsEmbedCString("res") -#define CHROME_DIR_NAME nsEmbedCString("chrome") -#define PLUGINS_DIR_NAME nsEmbedCString("plugins") -#define SEARCH_DIR_NAME nsEmbedCString("searchplugins") -#define COMPONENTS_DIR_NAME nsEmbedCString("components") - -//***************************************************************************** -// winEmbedFileLocProvider::Constructor/Destructor -//***************************************************************************** - -winEmbedFileLocProvider::winEmbedFileLocProvider(const nsACString& aAppDataDirName) -{ - mProductDirName = aAppDataDirName; -} - -winEmbedFileLocProvider::~winEmbedFileLocProvider() -{ -} - - -//***************************************************************************** -// winEmbedFileLocProvider::nsISupports -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(winEmbedFileLocProvider, nsIDirectoryServiceProvider) - -//***************************************************************************** -// winEmbedFileLocProvider::nsIDirectoryServiceProvider -//***************************************************************************** - -NS_IMETHODIMP -winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistent, nsIFile **_retval) -{ - nsCOMPtr localFile; - nsresult rv = NS_ERROR_FAILURE; - - *_retval = nsnull; - *persistent = PR_TRUE; - - if (strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) - { - rv = GetProductDirectory(getter_AddRefs(localFile)); - } - else if (strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0) - { - rv = GetProductDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendNative(APP_REGISTRY_NAME); - } - else if (strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); - } - else if (strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) { - rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME); - } - } - else if (strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 || - strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) { - rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME); - } - } - else if (strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0) - { - rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile)); - } - else if (strcmp(prop, NS_APP_RES_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(RES_DIR_NAME); - } - else if (strcmp(prop, NS_APP_CHROME_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME); - } - else if (strcmp(prop, NS_APP_PLUGINS_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); - } - else if (strcmp(prop, NS_APP_SEARCH_DIR) == 0) - { - rv = CloneMozBinDirectory(getter_AddRefs(localFile)); - if (NS_SUCCEEDED(rv)) - rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME); - } - -#ifdef XPCOM_GLUE - //--------------------------------------------------------------- - // Note that by returning a valid localFile's for NS_GRE_DIR and - // NS_GRE_COMPONENT_DIR your app is indicating to XPCOM that - // it found an GRE version with which it's compatible with and - // it intends to be "run against" that GRE - // - // Please see http://www.mozilla.org/projects/embedding/GRE.html - // for more info. on GRE - //--------------------------------------------------------------- - else if (strcmp(prop, NS_GRE_DIR) == 0) - { - rv = GRE_GetGREDirectory(getter_AddRefs(localFile)); - } -#endif - - if (localFile && NS_SUCCEEDED(rv)) - return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); - - return rv; -} - -NS_METHOD winEmbedFileLocProvider::CloneMozBinDirectory(nsILocalFile **aLocalFile) -{ - NS_ENSURE_ARG_POINTER(aLocalFile); - nsresult rv; - - if (!mMozBinDirectory) - { - // Get the mozilla bin directory - // 1. Check the directory service first for NS_XPCOM_CURRENT_PROCESS_DIR - // This will be set if a directory was passed to NS_InitXPCOM - // 2. If that doesn't work, set it to be the current process directory - - nsCOMPtr directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory)); - if (NS_FAILED(rv)) { - rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mMozBinDirectory)); - if (NS_FAILED(rv)) - return rv; - } - } - - nsCOMPtr aFile; - rv = mMozBinDirectory->Clone(getter_AddRefs(aFile)); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr lfile = do_QueryInterface (aFile); - if (!lfile) - return NS_ERROR_FAILURE; - - NS_IF_ADDREF(*aLocalFile = lfile); - return NS_OK; -} - - -//---------------------------------------------------------------------------------------- -// GetProductDirectory - Gets the directory which contains the application data folder -// -// WIN : \Mozilla -//---------------------------------------------------------------------------------------- -NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile) -{ - NS_ENSURE_ARG_POINTER(aLocalFile); - - nsresult rv; - PRBool exists; - nsCOMPtr localDir; - - nsCOMPtr directoryService = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; - rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir)); - if (NS_SUCCEEDED(rv)) - rv = localDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) - { - // On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR - localDir = nsnull; - rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir)); - } - if (NS_FAILED(rv)) return rv; - - rv = localDir->AppendNative(mProductDirName); - if (NS_FAILED(rv)) return rv; - rv = localDir->Exists(&exists); - if (NS_SUCCEEDED(rv) && !exists) - rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775); - if (NS_FAILED(rv)) return rv; - - *aLocalFile = localDir; - NS_ADDREF(*aLocalFile); - - return rv; -} - - -//---------------------------------------------------------------------------------------- -// GetDefaultUserProfileRoot - Gets the directory which contains each user profile dir -// -// WIN : \Mozilla\Users50 -//---------------------------------------------------------------------------------------- -NS_METHOD winEmbedFileLocProvider::GetDefaultUserProfileRoot(nsILocalFile **aLocalFile) -{ - NS_ENSURE_ARG_POINTER(aLocalFile); - - nsresult rv; - PRBool exists; - nsCOMPtr localDir; - - rv = GetProductDirectory(getter_AddRefs(localDir)); - if (NS_FAILED(rv)) return rv; - - // These 3 platforms share this part of the path - do them as one - rv = localDir->AppendRelativeNativePath(PROFILE_ROOT_DIR_NAME); - if (NS_FAILED(rv)) return rv; - rv = localDir->Exists(&exists); - if (NS_SUCCEEDED(rv) && !exists) - rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0775); - if (NS_FAILED(rv)) return rv; - - *aLocalFile = localDir; - NS_ADDREF(*aLocalFile); - - return rv; -} - diff --git a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h b/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h deleted file mode 100644 index 737ee63a8ef..00000000000 --- a/mozilla/embedding/tests/mfcembed/winEmbedFileLocProvider.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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): - * Conrad Carlen - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsIDirectoryService.h" -#include "nsILocalFile.h" -#include "nsEmbedString.h" -#include "nsCOMPtr.h" - -class nsILocalFile; - -//***************************************************************************** -// class winEmbedFileLocProvider -//***************************************************************************** - -class winEmbedFileLocProvider : public nsIDirectoryServiceProvider -{ -public: - // aProductDirName is the name (not path) of the dir - // in which the application registry and profiles live. - winEmbedFileLocProvider(const nsACString& aProductDirName); - - NS_DECL_ISUPPORTS - NS_DECL_NSIDIRECTORYSERVICEPROVIDER - -protected: - virtual ~winEmbedFileLocProvider(); - - NS_METHOD CloneMozBinDirectory(nsILocalFile **aLocalFile); - NS_METHOD GetProductDirectory(nsILocalFile **aLocalFile); - NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile); - - - nsEmbedCString mProductDirName; - nsCOMPtr mMozBinDirectory; -};