Fixed "Print" so it works.

This commit is contained in:
rods%netscape.com 1999-04-01 20:57:38 +00:00
parent a7750b142c
commit 6ed80d150c
2 changed files with 20 additions and 39 deletions

View File

@ -765,7 +765,7 @@ nsBrowserAppCore::OpenWindow()
{
nsIFileWidget *fileWidget;
nsString title("FileWidget Title <here> mode = save");
nsString title("Open File");
nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget);
nsString titles[] = {"All Readable Files", "HTML Files",
@ -812,38 +812,7 @@ void nsBrowserAppCore::SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum,
NS_IMETHODIMP
nsBrowserAppCore::PrintPreview()
{
if (!mWebShell)
return NS_OK;
//////////////////////////////////////////////////////
// This is Experimental code showing one approach
// to dynamically changing the toolbar icons.
//////////////////////////////////////////////////////
// first get the toolbar child WebShell
nsCOMPtr<nsIContentViewer> cv;
mWebShell->GetContentViewer(getter_AddRefs(cv));
if (!cv)
return NS_OK;
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
if (!docv)
return NS_OK;
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(*getter_AddRefs(doc));
if (!doc)
return NS_OK;
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(doc));
nsCOMPtr<nsIDOMNode> parentNode(GetParentNodeFromDOMDoc(domDoc));
SetButtonImage(parentNode, 1, "resource:/res/toolbar/TB_NewBack.gif");
SetButtonImage(parentNode, 2, "resource:/res/toolbar/TB_NewForward.gif");
SetButtonImage(parentNode, 3, "resource:/res/toolbar/TB_NewReload.gif");
SetButtonImage(parentNode, 4, "resource:/res/toolbar/TB_NewStop.gif");
SetButtonImage(parentNode, 5, "resource:/res/toolbar/TB_NewHome.gif");
SetButtonImage(parentNode, 6, "resource:/res/toolbar/TB_NewPrint.gif");
return NS_OK;
}
@ -866,13 +835,15 @@ nsBrowserAppCore::Copy()
NS_IMETHODIMP
nsBrowserAppCore::Print()
{
nsIContentViewer *viewer = nsnull;
if (nsnull != mContentAreaWebShell) {
nsIContentViewer *viewer = nsnull;
mWebShell->GetContentViewer(&viewer);
mContentAreaWebShell->GetContentViewer(&viewer);
if (nsnull != viewer) {
viewer->Print();
NS_RELEASE(viewer);
if (nsnull != viewer) {
viewer->Print();
NS_RELEASE(viewer);
}
}
return NS_OK;
}

View File

@ -178,6 +178,16 @@
}
}
function BrowserPrint()
{
// Borrowing this method to show how to
// dynamically change icons
appCore = XPAppCoresManager.Find("BrowserAppCore");
if (appCore != null) {
appCore.print();
}
}
function BrowserSetDocumentCharacterSet(aCharset)
{
appCore = XPAppCoresManager.Find("BrowserAppCore");
@ -367,9 +377,9 @@
<menuitem name="Synchronize..." onclick="BrowserReload();"/>
</menu>
<separator />
<menuitem name="Print Setup" onclick=""/>
<menuitem name="Print Setup" onclick=";"/>
<menuitem name="Print Preview" onclick=""/>
<menuitem name="Print" onclick=""/>
<menuitem name="Print" onclick="BrowserPrint()"/>
<separator />
<menuitem name="Close" onclick="BrowserClose();"/>
<menuitem name="Quit" onclick="BrowserExit();"/>