Bug 377410 - remove mfcembed, r=dougt

git-svn-id: svn://10.0.0.236/trunk@224494 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
benjamin%smedbergs.us
2007-04-13 17:22:43 +00:00
parent 817b30368a
commit 95cc240945
74 changed files with 0 additions and 15265 deletions

View File

@@ -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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<nsIURI> 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<nsIURI> 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<nsIURI> 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<nsIDOMNode> node;
aInfo->GetTargetNode(getter_AddRefs(node));
if(!node)
GOTO_BUILD_CTX_MENU;
nsCOMPtr<nsIDOMDocument> domDoc;
rv = node->GetOwnerDocument(getter_AddRefs(domDoc));
if(NS_FAILED(rv))
GOTO_BUILD_CTX_MENU;
nsCOMPtr<nsIDOMHTMLDocument> 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();
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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);
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<TCHAR *>((LPCTSTR)url);
InsertItem(&ci);
if(bAddToMRUList)
m_MRUList.AddURL(T2CA(url));
}
inline void LoadMRUList() {
for (int i=0;i<m_MRUList.GetNumURLs();i++)
{
USES_CONVERSION;
CString urlStr(A2CT(m_MRUList.GetURL(i)));
AddURLToList(urlStr, false);
}
}
inline BOOL EditCtrlHasFocus() {
return (GetEditCtrl()->m_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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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;
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<nsIWebBrowser> mWebBrowser;
};
#endif //_BROWSERIMPL_H

View File

@@ -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 <chak@netscape.com>
*
* ***** 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;
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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;
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<nsIDOMWindow> domWindow;
nsCOMPtr<nsIDOMWindow> 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;
}

View File

@@ -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 <adamlock@netscape.com>
*
* ***** 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);
}

View File

@@ -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 <adamlock@netscape.com>
*
* ***** 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_)

File diff suppressed because it is too large Load Diff

View File

@@ -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 <chak@netscape.com>
* Rod Spears <rods@netscape.com>
*
* ***** 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<nsIWebBrowser> mWebBrowser;
nsCOMPtr<nsIBaseWindow> mBaseWindow;
nsCOMPtr<nsIWebNavigation> 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<nsIPrintSettings> 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

View File

@@ -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

View File

@@ -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 <rods@netscape.com>
*
* ***** 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_)

View File

@@ -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;i<gNumPaperSizes;i++)
{
cbx->AddString(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<gNumPaperSizes;i++)
{
if (gPaperSize[i].mUnit == aUnit &&
gPaperSize[i].mWidth == aW &&
gPaperSize[i].mHeight == aH)
{
return i;
}
}
// find the first user defined
for (i=0;i<gNumPaperSizes;i++)
{
if (gPaperSize[i].mIsUserDefined)
{
return i;
}
}
return -1;
}
int CFormatOptionTab::GetPaperSizeIndex(const CString& aStr)
{
for (int i=0;i<gNumPaperSizes;i++)
{
if (!aStr.Compare(gPaperSize[i].mDesc))
{
return i;
}
}
return -1;
}

View File

@@ -1,100 +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 <rods@netscape.com>
*
* ***** 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<nsIPrintSettings> 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_)

View File

@@ -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);
}

View File

@@ -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 <rods@netscape.com>
*
* ***** 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_)

View File

@@ -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 <rods@netscape.com>
*
* ***** 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);
}

View File

@@ -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 <rods@netscape.com>
*
* ***** 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_)

View File

@@ -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 <chak@netscape.com>
*
* ***** 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);
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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_

View File

@@ -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 <mjudge@netscape.com>
* Chak Nanga <chak@netscape.com>
*
* ***** 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<nsICommandParams> 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<nsICommandParams> 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<nsIDOMWindow> 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<nsIDOMWindow> 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<nsIDOMWindow> 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<nsICommandParams> 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<nsICommandParams> 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 = " &nbsp;<A HREF=\"" + linkLocation + "\">" + linkText + "</A>&nbsp; ";
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<nsIHTMLEditor> htmlEditor;
GetHTMLEditor(getter_AddRefs(htmlEditor));
if (htmlEditor)
htmlEditor->InsertHTML(htmlToInsert);
}
void CEditorFrame::ShowEditLinkDlg()
{
nsCOMPtr<nsIDOMHTMLAnchorElement> 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<nsIHTMLEditor> 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<nsIHTMLEditor> htmlEditor;
GetHTMLEditor(getter_AddRefs(htmlEditor));
if (!htmlEditor)
return FALSE;
nsCOMPtr<nsIDOMElement> 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<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(domElement, &rv));
if (NS_SUCCEEDED(rv))
rv = linkElement->GetHref(linkLocation);
if (NS_FAILED(rv))
return FALSE;
// Determine linkText
nsCOMPtr<nsIDOMNode> 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<nsICommandParams> 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<nsICommandParams> 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<nsIEditor> editor;
GetEditor(getter_AddRefs(editor));
if (!editor)
{
return;
}
editor->QueryInterface(NS_GET_IID(nsIHTMLEditor), (void**)htmlEditor);
}
BOOL CEditorFrame::InLink()
{
nsCOMPtr<nsIHTMLEditor> htmlEditor;
GetHTMLEditor(getter_AddRefs(htmlEditor));
if (htmlEditor)
{
nsCOMPtr<nsIDOMElement> domElememt;
htmlEditor->GetElementOrParentByTagName(nsEmbedString(L"href"),
nsnull,
getter_AddRefs(domElememt));
return domElememt ? TRUE : FALSE;
}
return false;
}

View File

@@ -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 <mjudge@netscape.com>
* Chak Nanga <chak@netscape.com>
*
* ***** 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<nsICommandManager> mCommandManager;
nsCOMPtr<nsIDOMWindow> mDOMWindow;
nsCOMPtr<nsIEditingSession> mEditingSession;
};
#endif //_EDITORFRM_H_

View File

@@ -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 <chak@netscape.com>
*
* ***** 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

View File

@@ -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)

View File

@@ -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 <chak@netscape.com>
* Conrad Carlen <ccarlen@netscape.com>
*
* ***** 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 <io.h>
#include <fcntl.h>
#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<nsIComponentRegistrar> 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<InitPromptServiceType>(::GetProcAddress(overlib, kPromptServiceInitFuncName));
MakeFactory = reinterpret_cast<MakeFactoryType>(::GetProcAddress(overlib, kPromptServiceFactoryFuncName));
if (InitLib && MakeFactory) {
InitLib(overlib);
nsCOMPtr<nsIFactory> 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<InitHelperAppDlgType>(::GetProcAddress(overlib, kHelperAppDlgInitFuncName));
MakeFactory = reinterpret_cast<MakeFactoryType>(::GetProcAddress(overlib, kHelperAppDlgFactoryFuncName));
if (InitLib && MakeFactory) {
InitLib(overlib);
nsCOMPtr<nsIFactory> 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<InitPrintingPromptServiceType>(::GetProcAddress(overlib, kPrintingPromptServiceInitFuncName));
MakeFactory = reinterpret_cast<MakeFactoryType>(::GetProcAddress(overlib, kPrintingPromptServiceFactoryFuncName));
if (InitLib && MakeFactory) {
InitLib(overlib);
nsCOMPtr<nsIFactory> 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<nsILocalFile> 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<nsIPref> 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<nsIProfileSharingSetup> 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<nsIObserverService> 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<nsIFile> appDataDir;
NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR,
getter_AddRefs(appDataDir));
if (!appDataDir)
return FALSE;
nsCOMPtr<nsProfileDirServiceProvider> profProvider;
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(profProvider));
if (!profProvider)
return FALSE;
profProvider->Register();
nsCOMPtr<nsILocalFile> 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<nsIPref> 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<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, this));
if (windowCreator) {
nsCOMPtr<nsIWindowWatcher> 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<nsIProfileChangeStatus> 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();
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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

View File

@@ -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

View File

@@ -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 <rods@netscape.com>
*
* ***** 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<MAX_URLS;i++) {
mURLs[i] = NULL;
}
FILE * fd = GetFD("r");
if (fd) {
char line[512];
while (fgets(line, 512, fd)) {
if (strlen(line) > 1) {
line[strlen(line)-1] = 0;
mURLs[mNumURLs++] = _strdup(line);
}
}
fclose(fd);
}
}
FILE * CMostRecentUrls::GetFD(const char * aMode)
{
FILE * fd = nsnull;
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> 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;i<MAX_URLS;i++) {
if(mURLs[i])
fprintf(fd, "%s\n", mURLs[i]);
}
fclose(fd);
}
for (int i=0;i<MAX_URLS;i++) {
if(mURLs[i])
free(mURLs[i]);
}
}
char * CMostRecentUrls::GetURL(int aInx)
{
if (aInx < mNumURLs) {
return mURLs[aInx];
}
return NULL;
}
void CMostRecentUrls::AddURL(const char * aURL)
{
char szTemp[512];
strncpy(szTemp, aURL, sizeof(szTemp));
szTemp[sizeof(szTemp) - 1] = '\0';
// check to see if an existing url matches the one passed in
int i = 0;
for (; i<MAX_URLS-1; i++)
{
if(mURLs[i])
{
if(strcmpi(mURLs[i], szTemp) == 0)
break;
}
}
// if there was a match "i" will point to matching url entry
// if not i will be MAX_URLS-1
// move all url entries before this one down
for (; i>0; 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);
}

View File

@@ -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 <rods@netscape.com>
*
* ***** 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;
};

View File

@@ -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 <chak@netscape.com>
*
* ***** 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()

View File

@@ -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 <chak@netscape.com>
*
* ***** 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_

View File

@@ -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 <ccarlen@netscape.com>
*
* ***** 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<nsIProfile> 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<nsIProfile> 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<nsIRegistry> 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<nsIRegistry> 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;
}

View File

@@ -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 <ccarlen@netscape.com>
*
* ***** 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

View File

@@ -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 <afxpriv.h>
#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<nsIProfile> 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<nsIProfile> 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<nsIProfile> 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<nsIProfile> 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<nsIProfile> 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();
}

View File

@@ -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_)

View File

@@ -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 <chak@netscape.com>
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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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"

View File

@@ -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 <chak@netscape.com>
*
* ***** 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 <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#include <afxpriv.h> // Needed for MFC MBCS/Unicode Conversion Macros
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // 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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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
}

View File

@@ -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 <chak@netscape.com>
*
* ***** 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_

View File

@@ -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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<nsIDOMWindow> domWnd(do_GetInterface(aWindowContext));
if(!domWnd)
return NULL;
CWnd *retWnd = NULL;
nsCOMPtr<nsIWebBrowserChrome> chrome;
if(mWWatch)
{
nsCOMPtr<nsIDOMWindow> 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<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome));
if (site)
{
HWND w;
site->GetSiteWindow(reinterpret_cast<void **>(&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<nsILocalFile> 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<nsIMIMEInfo> 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<nsIURI> 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()

View File

@@ -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 <chak@netscape.com>
*
* ***** 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<nsIWindowWatcher> 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<nsIHelperAppLauncher> 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<nsIHelperAppLauncher> 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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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<nsIWebBrowserPrint> m_WebBrowserPrint;
nsCOMPtr<nsIPrintProgressParams> m_PPParams;
nsCOMPtr<nsIWebProgressListener> m_PrintListener;
nsCOMPtr<nsIPrintSettings> 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_)

View File

@@ -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<nsIWindowWatcher> mWWatch;
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
nsCOMPtr<nsIObserver> 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<nsIWebBrowserChrome> chrome;
CWnd *val = 0;
if (mWWatch) {
nsCOMPtr<nsIDOMWindow> 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<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome));
if (site) {
HWND w;
site->GetSiteWindow(reinterpret_cast<void **>(&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<nsIRunnable> 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;
}

View File

@@ -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

View File

@@ -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<nsIWindowWatcher> 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<nsIWebBrowserChrome> chrome;
CWnd *val = 0;
if (mWWatch) {
nsCOMPtr<nsIDOMWindow> 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<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome));
if (site) {
HWND w;
site->GetSiteWindow(reinterpret_cast<void **>(&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;
}

View File

@@ -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

View File

@@ -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___ */

View File

@@ -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 <rods@netscape.com>
*
* ***** 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;
}

View File

@@ -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 <rods@netscape.com>
*
* ***** 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

View File

@@ -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

View File

@@ -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 <chak@netscape.com>
*
* ***** 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 <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#include <afxpriv.h> // Needed for MFC MBCS/Unicode Conversion Macros
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // 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

View File

@@ -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

View File

@@ -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>
{{{
}}}
###############################################################################

View File

@@ -1,58 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=x-user-defined">
<meta name="GENERATOR" content="Mozilla/4.7 [en] (WinNT; U) [Netscape]">
<title> MfcEmbed JavaScript Tests </title>
<script language="JavaScript">
// Open a window with default size/style
function ShowWin()
{
window.open("http://www.mozilla.org", "theWin1");
}
// Open a window with specific size
function ShowWinSpecificSize()
{
window.open("http://www.mozilla.org", "theWin2", "width=400, height=600");
}
// Open a window with chrome + specific size
function ShowWinSpecificSizeWithChrome()
{
window.open("http://www.mozilla.org", "theWin3", "menubar=yes, toolbar=yes, status=yes, resizable=yes, width=400, height=600");
}
</script>
</head>
<body>
<h1>Exercising MfcEmbed's Interfaces</h1>
<p>
This test page serves as a testbed to exercise some of the interfaces
MfcEmbed implements - such as nsIWebBrowserChrome, nsIPrompt etc.
<p>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.</p>
<p><a href="javascript:ShowWin()">Open a simple JavaScript window with
defaults for size etc:</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window</font></blockquote>
<a href="javascript:ShowWinSpecificSize()">Open a JavaScript window with
only its size specified (Not Resizable)</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window and also invokes <i>nsIWebBrowserChrome::SizeBrowserTo()</i>
to set the window size. This also shows how we handle the chromeMask to
make the window non-resizeable</font></blockquote>
<a href="javascript:ShowWinSpecificSizeWithChrome()">Open a window with
chrome and its size specified (Resizable)</a>
<blockquote><font size=-1>Invokes <i>nsIWebBrowserChrome::CreateBrowserWindow()</i>
to create the window and also invokes <i>nsIWebBrowserChrome::SizeBrowserTo()</i>
to set the window size</font>
<br><font size=-1>All of the above tests also invoke<i> nsIWebBrowserChrome::FindNamedBrowserItem()</i>
to find the named target window in the JavaScript code.</font></blockquote>
</body>
</html>

View File

@@ -1,4 +0,0 @@
[mfcembed]
dist/bin/mfcembed.exe
dist/bin/mfcEmbedComponents.dll
dist/bin/mfcembed.htm

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -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...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1,153 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by mfcembed.rc
//
#define IDD_ABOUTBOX 100
#define ID_TOOLBAR_UPDATE 101
#define IDR_MAINFRAME 128
#define IDR_MOZEMBTYPE 129
#define IDR_EDITOR 129
#define IDR_CTXMENU_DOCUMENT 130
#define IDR_CTXMENU_LINK 131
#define IDR_CTXMENU_TEXT 132
#define IDR_CTXMENU_IMAGE 133
#define IDD_PROMPT_DIALOG 134
#define IDD_PROMPT_PASSWORD_DIALOG 135
#define IDD_PROMPT_USERPASS_DIALOG 136
#define IDD_PROFILES 137
#define IDD_PROFILE_NEW 138
#define IDD_PROFILE_RENAME 139
#define IDD_FINDDLG 140
#define IDD_PREFS_START_PAGE 142
#define IDR_SECURITY_LOCK 143
#define IDR_SECURITY_UNLOCK 144
#define IDR_SECURITY_BROKEN 145
#define IDS_NOSECURITY_INFO 146
#define IDS_ENCRYPTION_HIGH_GRADE 147
#define IDS_ENCRYPTION_LOW_GRADE 148
#define IDS_ENCRYPTION_NONE 149
#define IDS_SRCH_STR_NOT_FOUND 150
#define IDD_PRINTSETUP_DIALOG 152
#define IDS_VIEW_FRAME_SOURCE 153
#define IDS_OPEN_FRAME_IN_NEW_WINDOW 154
#define IDR_CTXMENU_EDITOR 155
#define IDD_HEADERFOOTER_TAB 156
#define IDD_FORMAT_OPTIONS_TAB 157
#define IDD_CUSTOM_PROMPT_DIALOG 159
#define IDD_DIALOG_LINK_PROPERTIES 160
#define IDS_PROFILES_FOLDER_NAME 180
#define IDS_PROFILES_NONSHARED_NAME 181
#define ID_URL_BAR 1001
#define ID_PROG_BAR 1002
#define IDC_PROMPT_ANSWER 1003
#define IDC_PROMPT_QUESTION 1004
#define IDC_PROMPT_TEXT 1005
#define IDC_USERNAME 1006
#define IDC_PASSWORD 1007
#define IDC_CHECK_SAVE_PASSWORD 1008
#define IDC_USERNAME_LABEL 1009
#define IDC_PASSWORD_LABEL 1010
#define IDC_LIST1 1011
#define IDC_PROF_RENAME 1012
#define IDC_PROF_DELETE 1013
#define IDC_PROF_NEW 1014
#define IDC_CHECK_ASK_AT_START 1015
#define IDC_NEW_PROF_NAME 1016
#define IDC_LOCALE_COMBO 1017
#define IDC_NEW_NAME 1018
#define IDC_PPD_DOC_TXT 1020
#define IDC_PPD_DOC_TITLE_STATIC 1021
#define IDC_LEFT_MARGIN_TXT 1022
#define IDC_TOP_MARGIN_TXT 1023
#define IDC_BOTTOM_MARGIN_TXT 1024
#define IDC_RIGHT_MARGIN_TXT 1026
#define IDC_PRT_BGCOLORS 1027
#define IDC_SCALE 1028
#define IDC_SCALE_TXT 1030
#define IDC_PRT_BGIMAGES 1031
#define IDC_PAPER_SIZE_CBX 1032
#define IDC_UD_PAPER_HGT 1033
#define IDC_UD_PAPER_WDTH 1034
#define IDC_UD_WIDTH_LBL 1035
#define IDC_UD_HEIGHT_LBL 1036
#define IDC_INCHES_RD 1037
#define IDC_MILLI_RD 1038
#define IDC_HDR_LEFT_TXT 1039
#define IDC_HDR_MID_TXT 1040
#define IDC_MATCH_WHOLE_WORD 0x0410
#define IDC_HDR_RIGHT_TXT 1041
#define IDC_MATCH_CASE 0x0411
#define IDC_WRAP_AROUND 1042
#define IDC_FTR_LEFT_TXT 1042
#define IDC_TAB1 1042
#define IDC_PRINTSETUP_TAB_CTRL 1042
#define IDC_SEARCH_BACKWARDS 1043
#define IDC_FTR_MID_TXT 1043
#define IDC_FTR_RIGHT_TXT 1044
#define IDC_FTR_LEFT_CMBX 1045
#define IDC_FTR_CENTER_CMBX 1047
#define IDC_FTR_RIGHT_CMBX 1048
#define IDC_HDR_LEFT_CMBX 1049
#define IDC_HDR_CENTER_CMBX 1050
#define IDC_HDR_RIGHT_CMBX 1051
#define IDC_RADIO_BLANK_PAGE 1053
#define IDC_RADIO_HOME_PAGE 1054
#define IDC_EDIT_HOMEPAGE 1055
#define IDC_PRT_PORTRAIT_RD 1056
#define IDC_PRT_LANDSCAPE_RD 1057
#define IDC_EDIT_LINK_TEXT 1058
#define IDC_EDIT_LINK_LOCATION 1059
#define IDC_FIND_EDIT 0x0480
#define ID_NAV_BACK 32773
#define ID_NAV_FORWARD 32774
#define ID_NAV_HOME 32775
#define ID_NAV_STOP 32776
#define ID_NAV_RELOAD 32777
#define ID_EDIT_SELECT_NONE 32778
#define ID_NEW_BROWSER 32779
#define ID_VIEW_SOURCE 32780
#define ID_VIEW_INFO 32781
#define ID_VIEW_IMAGE 32782
#define ID_OPEN_LINK_IN_NEW_WINDOW 32783
#define ID_SAVE_LINK_AS 32784
#define ID_SAVE_IMAGE_AS 32785
#define ID_COPY_LINK_LOCATION 32786
#define ID_MANAGE_PROFILES 32787
#define ID_EDIT_PREFERENCES 32788
#define ID_FILE_PRINTPREVIEW 32789
#define ID_FILE_PRINTSETUP 32790
#define ID_VIEW_FRAME_SOURCE 32791
#define ID_OPEN_FRAME_IN_NEW_WINDOW 32792
#define ID_BOLD 32793
#define ID_UNDERLINE 32794
#define ID_ITALICS 32795
#define ID_NEW_EDITORWINDOW 32796
#define ID_INDENT 32797
#define ID_OUTDENT 32798
#define ID_FONTBLACK 32799
#define ID_FONTRED 32800
#define ID_BGCOLOR 32801
#define ID_NOBGCOLOR 32802
#define ID_FONTSIZEINCREASE 32803
#define ID_FONTSIZEDECREASE 32804
#define ID_ARIAL 32805
#define ID_TIMES 32806
#define ID_COURIER 32807
#define ID_ALIGNLEFT 32808
#define ID_ALIGNCENTER 32809
#define ID_ALIGNRIGHT 32810
#define ID_INSERTLINK 32811
#define ID_EDITOR_UNDO 32813
#define ID_EDITOR_REDO 32814
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 160
#define _APS_NEXT_COMMAND_VALUE 32815
#define _APS_NEXT_CONTROL_VALUE 1058
#define _APS_NEXT_SYMED_VALUE 102
#endif
#endif

View File

@@ -1,288 +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 <conrad@ingress.com>
* Benjamin Smedberg <bsmedberg@covad.net>
*
* ***** 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 <windows.h>
#include <shlobj.h>
// 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<nsILocalFile> 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<nsIProperties> 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<nsIFile> aFile;
rv = mMozBinDirectory->Clone(getter_AddRefs(aFile));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsILocalFile> 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 : <Application Data folder on user's machine>\Mozilla
//----------------------------------------------------------------------------------------
NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
PRBool exists;
nsCOMPtr<nsILocalFile> localDir;
nsCOMPtr<nsIProperties> 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 : <Application Data folder on user's machine>\Mozilla\Users50
//----------------------------------------------------------------------------------------
NS_METHOD winEmbedFileLocProvider::GetDefaultUserProfileRoot(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv;
PRBool exists;
nsCOMPtr<nsILocalFile> 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;
}

View File

@@ -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 <conrad@ingress.com>
*
* ***** 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<nsILocalFile> mMozBinDirectory;
};