Landing print preview toolbar and UI.

b=111235; r=law; sr=hewitt
This commit is contained in:
sgehani%netscape.com 2002-02-20 06:19:39 +00:00
parent 93ea378169
commit 4ff1572cca
28 changed files with 608 additions and 38 deletions

View File

@ -5524,24 +5524,10 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
#endif
#ifdef NS_PRINT_PREVIEW
// Use the "else" case when the UI is checked in
// and remove "if-then" part
#if 1
// if we are printing another URL, then exit
// the reason we check here is because this method can be called while
// another is still in here (the printing dialog is a good example).
// the only time we can print more than one job at a time is the regression tests
if (mIsDoingPrintPreview) {
ReturnToGalleyPresentation();
return NS_OK;
}
#else
if (mIsDoingPrintPreview) {
mOldPrtPreview = mPrtPreview;
mPrtPreview = nsnull;
}
#endif
mPrt = new PrintData();
if (mPrt == nsnull) {
@ -5576,8 +5562,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
mIsCreatingPrintPreview = PR_TRUE;
mIsDoingPrintPreview = PR_TRUE;
mIsDoingPrintPreview = PR_TRUE;
// Very important! Turn Off scripting
TurnScriptingOn(PR_FALSE);
@ -5685,7 +5669,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
if (!mPrt->mShrinkToFit) {
double scaling;
mPrt->mPrintSettings->GetScaling(&scaling);
if (scaling < 1.0) {
if (scaling <= 1.0) {
mDeviceContext->SetCanonicalPixelScale(float(scaling));
}
}

View File

@ -5524,24 +5524,10 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
#endif
#ifdef NS_PRINT_PREVIEW
// Use the "else" case when the UI is checked in
// and remove "if-then" part
#if 1
// if we are printing another URL, then exit
// the reason we check here is because this method can be called while
// another is still in here (the printing dialog is a good example).
// the only time we can print more than one job at a time is the regression tests
if (mIsDoingPrintPreview) {
ReturnToGalleyPresentation();
return NS_OK;
}
#else
if (mIsDoingPrintPreview) {
mOldPrtPreview = mPrtPreview;
mPrtPreview = nsnull;
}
#endif
mPrt = new PrintData();
if (mPrt == nsnull) {
@ -5576,8 +5562,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
mIsCreatingPrintPreview = PR_TRUE;
mIsDoingPrintPreview = PR_TRUE;
mIsDoingPrintPreview = PR_TRUE;
// Very important! Turn Off scripting
TurnScriptingOn(PR_FALSE);
@ -5685,7 +5669,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
if (!mPrt->mShrinkToFit) {
double scaling;
mPrt->mPrintSettings->GetScaling(&scaling);
if (scaling < 1.0) {
if (scaling <= 1.0) {
mDeviceContext->SetCanonicalPixelScale(float(scaling));
}
}

View File

@ -40,6 +40,7 @@
========================================================================== */
@import url("chrome://global/skin/");
@import url("chrome://communicator/content/communicator.css");
@import url("chrome://communicator/skin/brand.css");
@import url("chrome://communicator/skin/button.css");
@import url("chrome://communicator/skin/formatting.css");
@ -97,4 +98,4 @@
.sidebarTree {
border: none;
margin: 0px !important;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

View File

@ -57,6 +57,8 @@ classic.jar:
skin/classic/communicator/brand/throbber16-anim.gif (communicator/brand/throbber16-anim.gif)
skin/classic/communicator/icons/offline.gif (communicator/icons/offline.gif)
skin/classic/communicator/icons/online.gif (communicator/icons/online.gif)
skin/classic/communicator/icons/pg-landscape.gif (communicator/icons/pg-landscape.gif)
skin/classic/communicator/icons/pg-portrait.gif (communicator/icons/pg-portrait.gif)
skin/classic/communicator/icons/content-large.gif (communicator/icons/content-large.gif)
skin/classic/communicator/icons/content-small.gif (communicator/icons/content-small.gif)
skin/classic/communicator/icons/search-act.gif (communicator/icons/search-act.gif)
@ -103,12 +105,18 @@ classic.jar:
skin/classic/global/filepicker/dir-open.gif (global/filepicker/dir-open.gif)
skin/classic/global/arrow/arrow-dn-dis.gif (global/arrow/arrow-dn-dis.gif)
skin/classic/global/arrow/arrow-dn-hov.gif (global/arrow/arrow-dn-hov.gif)
skin/classic/global/arrow/arrow-dn-sharp.gif (global/arrow/arrow-dn-sharp.gif)
skin/classic/global/arrow/arrow-lft-dis.gif (global/arrow/arrow-lft-dis.gif)
skin/classic/global/arrow/arrow-lft-hov.gif (global/arrow/arrow-lft-hov.gif)
skin/classic/global/arrow/arrow-lft-sharp.gif (global/arrow/arrow-lft-sharp.gif)
skin/classic/global/arrow/arrow-lft-sharp-end.gif (global/arrow/arrow-lft-sharp-end.gif)
skin/classic/global/arrow/arrow-rit-dis.gif (global/arrow/arrow-rit-dis.gif)
skin/classic/global/arrow/arrow-rit-hov.gif (global/arrow/arrow-rit-hov.gif)
skin/classic/global/arrow/arrow-rit-sharp.gif (global/arrow/arrow-rit-sharp.gif)
skin/classic/global/arrow/arrow-rit-sharp-end.gif (global/arrow/arrow-rit-sharp-end.gif)
skin/classic/global/arrow/arrow-up-dis.gif (global/arrow/arrow-up-dis.gif)
skin/classic/global/arrow/arrow-up-hov.gif (global/arrow/arrow-up-hov.gif)
skin/classic/global/arrow/arrow-up-sharp.gif (global/arrow/arrow-up-sharp.gif)
skin/classic/global/arrow/arrow-dn.gif (global/arrow/arrow-dn.gif)
skin/classic/global/arrow/arrow-lft.gif (global/arrow/arrow-lft.gif)
skin/classic/global/arrow/arrow-rit.gif (global/arrow/arrow-rit.gif)

View File

@ -40,6 +40,7 @@
========================================================================== */
@import url("chrome://global/skin/");
@import url("chrome://communicator/content/communicator.css");
@import url("chrome://communicator/skin/brand.css");
@import url("chrome://communicator/skin/button.css");
@import url("chrome://communicator/skin/formatting.css");
@ -80,4 +81,4 @@
.sidebarTree {
border: none;
margin: 0px !important;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

View File

@ -35,6 +35,8 @@ modern.jar:
skin/modern/communicator/icons/lock-secure.gif (communicator/icons/lock-secure.gif)
skin/modern/communicator/icons/offline.gif (communicator/icons/offline.gif)
skin/modern/communicator/icons/online.gif (communicator/icons/online.gif)
skin/modern/communicator/icons/pg-landscape.gif (communicator/icons/pg-landscape.gif)
skin/modern/communicator/icons/pg-portrait.gif (communicator/icons/pg-portrait.gif)
skin/modern/communicator/icons/turbo-systray.gif (communicator/icons/turbo-systray.gif)
skin/modern/communicator/icons/btn1.gif (communicator/icons/btn1.gif)
skin/modern/communicator/icons/search.gif (communicator/icons/search.gif)
@ -146,12 +148,18 @@ modern.jar:
skin/modern/global/scrollbars-mini.css (global/scrollbars-mini.css)
skin/modern/global/arrow/arrow-dn-dis.gif (global/arrow/arrow-dn-dis.gif)
skin/modern/global/arrow/arrow-dn.gif (global/arrow/arrow-dn.gif)
skin/modern/global/arrow/arrow-dn-sharp.gif (global/arrow/arrow-dn-sharp.gif)
skin/modern/global/arrow/arrow-lft-dis.gif (global/arrow/arrow-lft-dis.gif)
skin/modern/global/arrow/arrow-lft.gif (global/arrow/arrow-lft.gif)
skin/modern/global/arrow/arrow-lft-sharp.gif (global/arrow/arrow-lft-sharp.gif)
skin/modern/global/arrow/arrow-lft-sharp-end.gif (global/arrow/arrow-lft-sharp-end.gif)
skin/modern/global/arrow/arrow-rit-dis.gif (global/arrow/arrow-rit-dis.gif)
skin/modern/global/arrow/arrow-rit.gif (global/arrow/arrow-rit.gif)
skin/modern/global/arrow/arrow-rit-sharp.gif (global/arrow/arrow-rit-sharp.gif)
skin/modern/global/arrow/arrow-rit-sharp-end.gif (global/arrow/arrow-rit-sharp-end.gif)
skin/modern/global/arrow/arrow-up-dis.gif (global/arrow/arrow-up-dis.gif)
skin/modern/global/arrow/arrow-up.gif (global/arrow/arrow-up.gif)
skin/modern/global/arrow/arrow-up-sharp.gif (global/arrow/arrow-up-sharp.gif)
skin/modern/global/button/tbmbtn-arrow-act.gif (global/button/tbmbtn-arrow-act.gif)
skin/modern/global/button/tbmbtn-arrow-hov.gif (global/button/tbmbtn-arrow-hov.gif)
skin/modern/global/button/tbmbtn-arrow.gif (global/button/tbmbtn-arrow.gif)

View File

@ -22,6 +22,7 @@
* Contributor(s):
* Blake Ross <blakeross@telocity.com>
* Peter Annema <disttsc@bart.nl>
* Samir Gehani <sgehani@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
@ -39,6 +40,8 @@
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
var gPrintSettings = null;
var gChromeState = null; // chrome state before we went into print preview
var gOldCloseHandler = null; // close handler before we went into print preview
function getWebNavigation()
{
@ -71,6 +74,121 @@ function BrowserReloadWithFlags(reloadFlags)
}
}
function toggleAffectedChrome(aHide)
{
// chrome to toggle includes:
// (*) menubar
// (*) navigation bar
// (*) personal toolbar
// (*) tab browser ``strip''
// (*) sidebar
if (!gChromeState)
gChromeState = new Object;
var chrome = new Array;
var i = 0;
chrome[i++] = document.getElementById("main-menubar");
chrome[i++] = document.getElementById("nav-bar");
chrome[i++] = document.getElementById("PersonalToolbar");
// sidebar states map as follows:
// was-hidden => hide/show nothing
// was-collapsed => hide/show only the splitter
// was-shown => hide/show the splitter and the box
if (aHide)
{
// going into print preview mode
if (sidebar_is_collapsed())
{
gChromeState.sidebar = "was-collapsed";
chrome[i++] = document.getElementById("sidebar-splitter");
}
else if (sidebar_is_hidden())
gChromeState.sidebar = "was-hidden";
else
{
gChromeState.sidebar = "was-visible";
chrome[i++] = document.getElementById("sidebar-box");
chrome[i++] = document.getElementById("sidebar-splitter");
}
}
else
{
// restoring normal mode (i.e., leaving print preview mode)
if (gChromeState.sidebar == "was-collapsed" ||
gChromeState.sidebar == "was-visible")
chrome[i++] = document.getElementById("sidebar-splitter");
if (gChromeState.sidebar == "was-visible")
chrome[i++] = document.getElementById("sidebar-box");
}
// now that we've figured out which elements we're interested, toggle 'em
for (i = 0; i < chrome.length; ++i)
{
if (aHide)
chrome[i].hidden = true;
else
chrome[i].hidden = false;
}
// if we are unhiding and sidebar used to be there rebuild it
if (!aHide && gChromeState.sidebar == "was-visible")
SidebarRebuild();
// now deal with the tab browser ``strip''
var theTabbrowser = document.getElementById("content");
if (aHide) // normal mode -> print preview
{
gChromeState.hadTabStrip = theTabbrowser.getStripVisibility();
theTabbrowser.setStripVisibilityTo(false);
}
else // print preview -> normal mode
{
// tabs were showing before entering print preview
if (gChromeState.hadTabStrip)
{
theTabbrowser.setStripVisibilityTo(true);
gChromeState.hadTabStrip = false; // reset
}
}
}
function showPrintPreviewToolbar()
{
toggleAffectedChrome(true);
const kXULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var printPreviewTB = document.createElementNS(kXULNS, "toolbar");
printPreviewTB.setAttribute("printpreview", true);
printPreviewTB.setAttribute("id", "print-preview-toolbar");
var navTB = document.getElementById("nav-bar");
navTB.parentNode.appendChild(printPreviewTB);
}
function BrowserExitPrintPreview()
{
// exit print preview galley mode in content area
var ifreq = _content.QueryInterface(
Components.interfaces.nsIInterfaceRequestor);
var webBrowserPrint = ifreq.getInterface(
Components.interfaces.nsIWebBrowserPrint);
webBrowserPrint.exitPrintPreview();
_content.focus();
// remove the print preview toolbar
var navTB = document.getElementById("nav-bar");
var printPreviewTB = document.getElementById("print-preview-toolbar");
navTB.parentNode.removeChild(printPreviewTB);
// restore chrome to original state
toggleAffectedChrome(false);
// restore old onclose handler if we found one before previewing
var mainWin = document.getElementById("main-window");
mainWin.setAttribute("onclose", gOldCloseHandler);
}
function GetPrintSettings(webBrowserPrint)
{
@ -94,14 +212,26 @@ function GetPrintSettings(webBrowserPrint)
} catch (e) {
alert("GetPrintSettings "+e);
}
return gPrintSettings;
}
function BrowserPrintPreview()
{
var mainWin = document.getElementById("main-window");
// save previous close handler to restoreon exiting print preview mode
if (mainWin.hasAttribute("onclose"))
gOldCloseHandler = mainWin.getAttribute("onclose");
else
gOldCloseHandler = null;
mainWin.setAttribute("onclose", "BrowserExitPrintPreview(); return false;");
try {
var ifreq = _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
var webBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
var ifreq = _content.QueryInterface(
Components.interfaces.nsIInterfaceRequestor);
var webBrowserPrint = ifreq.getInterface(
Components.interfaces.nsIWebBrowserPrint);
if (webBrowserPrint) {
gPrintSettings = GetPrintSettings(webBrowserPrint);
webBrowserPrint.printPreview(gPrintSettings);
@ -113,6 +243,9 @@ function BrowserPrintPreview()
// dump(e); // if you need to debug
}
// show the toolbar after we go into print preview mode so
// that we can initialize the toolbar with total num pages
showPrintPreviewToolbar();
}

View File

@ -2,6 +2,7 @@ comm.jar:
content/communicator-platform/contents.rdf (resources/content/contents-platform.rdf)
content/communicator-region/contents.rdf (resources/content/contents-region.rdf)
content/communicator/contents.rdf (resources/content/contents.rdf)
content/communicator/communicator.css (resources/content/communicator.css)
content/communicator/communicatorOverlay.xul (resources/content/communicatorOverlay.xul)
content/communicator/utilityOverlay.xul (resources/content/utilityOverlay.xul)
content/communicator/utilityOverlay.js (resources/content/utilityOverlay.js)
@ -27,6 +28,7 @@ comm.jar:
content/communicator/findUtils.js (resources/content/findUtils.js)
content/communicator/printPageSetup.js (resources/content/printPageSetup.js)
content/communicator/printPageSetup.xul (resources/content/printPageSetup.xul)
content/communicator/printPreviewBindings.xml (resources/content/printPreviewBindings.xml)
en-US.jar:
locale/en-US/communicator/contents.rdf (resources/locale/en-US/contents.rdf)
@ -42,6 +44,7 @@ en-US.jar:
locale/en-US/communicator/askViewZoom.dtd (resources/locale/en-US/askViewZoom.dtd)
locale/en-US/communicator/viewZoomOverlay.dtd (resources/locale/en-US/viewZoomOverlay.dtd)
locale/en-US/communicator/viewZoomOverlay.properties (resources/locale/en-US/viewZoomOverlay.properties)
locale/en-US/communicator/printPreview.dtd (resources/locale/en-US/printPreview.dtd)
locale/en-US/communicator/printPageSetup.dtd (resources/locale/en-US/printPageSetup.dtd)
locale/en-US/communicator/printPageSetup.properties (resources/locale/en-US/printPageSetup.properties)

View File

@ -0,0 +1,82 @@
/* ***** 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) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Samir Gehani <sgehani@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 ***** */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: print preview toolbar ::::: */
toolbar[printpreview="true"] {
-moz-binding: url("chrome://communicator/content/printPreviewBindings.xml#printpreviewtoolbar");
}
/* ..... page navigation ..... */
.home-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-lft-sharp-end.gif");
}
.end-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-rit-sharp-end.gif");
}
.last-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-lft-sharp.gif");
}
.next-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-rit-sharp.gif");
}
/* ...... scale in/decrement ..... */
.up-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-up-sharp.gif");
}
.down-arrow {
list-style-image: url("chrome://global/skin/arrow/arrow-dn-sharp.gif");
}
/* ..... orientation ..... */
.portrait-page {
list-style-image: url("chrome://communicator/skin/icons/pg-portrait.gif");
}
.landscape-page {
list-style-image: url("chrome://communicator/skin/icons/pg-landscape.gif");
}

View File

@ -0,0 +1,313 @@
<?xml version="1.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 the print preview toolbar.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Samir Gehani <sgehani@netscape.com> (Original Author)
-
- 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 LGPL or the GPL. 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 ***** -->
<!DOCTYPE window SYSTEM "chrome://communicator/locale/printPreview.dtd">
<bindings id="printPreviewBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="printpreviewtoolbar"
extends="chrome://global/content/bindings/toolbar.xml#toolbar">
<content>
<xul:button label="&print.label;" oncommand="BrowserPrint();"/>
<xul:button label="&pageSetup.label;"
oncommand="BrowserPrintSetup();"/>
<xul:vbox align="center" pack="center">
<xul:label value="&page.label;"/>
</xul:vbox>
<xul:toolbarbutton class="toolbarbutton-icon home-arrow"
oncommand="parentNode.navigate(0, 0, 'home');"/>
<xul:toolbarbutton class="toolbarbutton-icon last-arrow"
oncommand="parentNode.navigate(-1, 0, 0);"/>
<xul:hbox align="center" pack="center">
<xul:textbox size="3" value="1" lastvalid="1"
onkeypress="if (event.keyCode==13) navigate(0, this.value, 0);"/>
<xul:label value="&of.label;"/>
<xul:label value="1"/>
</xul:hbox>
<xul:toolbarbutton class="toolbarbutton-icon next-arrow"
oncommand="parentNode.navigate(1, 0, 0);"/>
<xul:toolbarbutton class="toolbarbutton-icon end-arrow"
oncommand="parentNode.navigate(0, 0, 'end');"/>
<xul:toolbarseparator class="toolbarseparator-primary"/>
<xul:vbox align="center" pack="center">
<xul:label value="&scale.label;"/>
</xul:vbox>
<xul:hbox align="center" pack="center">
<xul:textbox size="3" align="end" value="100" lastvalid="100"
onkeypress="if (event.keyCode==13) parentNode.parentNode.scale(0, this.value);"/>
<xul:label value="&percent.label;"/>
</xul:hbox>
<xul:vbox align="center" pack="center">
<xul:toolbarbutton class="toolbarbutton-icon up-arrow"
oncommand="parentNode.parentNode.scale(1, 0);"/>
<xul:toolbarbutton class="toolbarbutton-icon down-arrow"
oncommand="parentNode.parentNode.scale(-1, 0);"/>
</xul:vbox>
<xul:toolbarseparator class="toolbarseparator-primary"/>
<xul:vbox align="center" pack="center">
<xul:hbox align="center" pack="center">
<xul:toolbarbutton label="&portrait.label;" checked="true"
type="radio" group="orient" class="portrait-page"
oncommand="parentNode.parentNode.parentNode.orient('portrait');"/>
<xul:toolbarbutton label="&landscape.label;"
type="radio" group="orient" class="landscape-page"
oncommand="parentNode.parentNode.parentNode.orient('landscape');"/>
</xul:hbox>
</xul:vbox>
<xul:toolbarseparator/>
<xul:toolbarseparator class="toolbarseparator-primary"/>
<xul:button label="&close.label;"
oncommand="BrowserExitPrintPreview();"/>
</content>
<implementation>
<field name="mDebug">
false
</field>
<field name="mPageTextBox">
document.getAnonymousNodes(this)[5].childNodes[0]
</field>
<field name="mTotalPages">
document.getAnonymousNodes(this)[5].childNodes[2]
</field>
<field name="mScaleTextBox">
document.getAnonymousNodes(this)[10].firstChild
</field>
<field name="mOrientButtonsBox">
document.getAnonymousNodes(this)[13].firstChild
</field>
<field name="mPortaitButton">
this.mOrientButtonsBox.childNodes[0]
</field>
<field name="mLandscapeButton">
this.mOrientButtonsBox.childNodes[1]
</field>
<constructor>
<![CDATA[
this._debug("constructor");
var print = _getWebBrowserPrint();
this.mTotalPages.value = print.printPreviewNumPages;
var settings = print.globalPrintSettings;
if (settings.orientation ==
Components.interfaces.nsIPrintSettings.kLandscapeOrientation)
this.orient('landscape');
var normalizedScale = parseInt(settings.scaling * 100);
this.mScaleTextBox.value = normalizedScale;
]]>
</constructor>
<method name="navigate">
<parameter name="aDirection"/>
<parameter name="aPageNum"/>
<parameter name="aHomeOrEnd"/>
<body>
<![CDATA[
this._debug("navigate: " + aDirection + " " + aPageNum +
" " + aHomeOrEnd);
var print = this._getWebBrowserPrint();
var validInput = false;
// we use only one of aHomeOrEnd, aDirection, or aPageNum
if (aHomeOrEnd)
{
var homeOrEnd;
if (aHomeOrEnd == "home")
{
homeOrEnd = print.PRINTPREVIEW_HOME;
this.mPageTextBox.value = 1;
}
else
{
homeOrEnd = print.PRINTPREVIEW_END;
this.mPageTextBox.value = print.printPreviewNumPages;
}
print.printPreviewNavigate(homeOrEnd, 0);
validInput = true;
}
else if (aDirection)
{
var textBoxStr = this.mPageTextBox.value;
var newPageNum = parseInt(textBoxStr) + aDirection;
var total = print.printPreviewNumPages;
// bounds check potentially user-entered number
if (newPageNum > 0 && newPageNum <= total)
{
this.mPageTextBox.value = newPageNum;
print.printPreviewNavigate(
print.PRINTPREVIEW_GOTO_PAGENUM, newPageNum);
validInput = true;
}
}
else
{
var total = print.printPreviewNumPages;
// bounds check potentially user-entered number
if (aPageNum > 0 && aPageNum <= total)
{
// store the valid page number for future use to replace
// the textbox value if erroneous input made it in
this.mPageTextBox.setAttribute("lastvalid", aPageNum);
print.printPreviewNavigate(
print.PRINTPREVIEW_GOTO_PAGENUM, aPageNum);
validInput = true;
}
}
if (!validInput)
{
// restore last known valid value in place of erroneous input
this.mPageTextBox.value =
this.mPageTextBox.getAttribute("lastvalid");
}
]]>
</body>
</method>
<method name="scale">
<parameter name="aDirection"/>
<parameter name="aValue"/>
<body>
<![CDATA[
this._debug("scale: " + aDirection + " " + aValue);
// we use only one of aDirection or aValue
var newValue;
if (aDirection)
newValue = parseInt(this.mScaleTextBox.value) + aDirection;
else
newValue = parseInt(aValue);
// bounds check the new value
if (newValue >= 50 && newValue <= 100)
{
this.mScaleTextBox.value = newValue;
// store the valid page number for future use to replace
// the textbox value if erroneous input made it in
this.mScaleTextBox.setAttribute("lastvalid", newValue);
var print = this._getWebBrowserPrint();
var settings = print.globalPrintSettings;
settings.scaling = newValue/100.0;
print.printPreview(settings);
// update total number of pages since this could have changed
this.mTotalPages.value = print.printPreviewNumPages;
}
else
{
// restore last valid value if erroneous input was found
this.mScaleTextBox.value =
this.mScaleTextBox.getAttribute("lastvalid");
}
]]>
</body>
</method>
<method name="orient">
<parameter name="aOrientation"/>
<body>
<![CDATA[
this._debug("orient: " + aOrientation);
var orientValue;
const kIPrintSettings = Components.interfaces.nsIPrintSettings;
if (aOrientation == "portrait")
{
this.mPortaitButton.checked = true;
this.mLandscapeButton.checked = false;
orientValue = kIPrintSettings.kPortraitOrientation;
}
else
{
this.mPortaitButton.checked = false;
this.mLandscapeButton.checked = true;
orientValue = kIPrintSettings.kLandscapeOrientation;
}
var print = this._getWebBrowserPrint();
var settings = print.globalPrintSettings;
settings.orientation = orientValue;
print.printPreview(settings);
// update total number of pages since this could have changed
this.mTotalPages.value = print.printPreviewNumPages;
]]>
</body>
</method>
<method name="_getWebBrowserPrint">
<body>
<![CDATA[
var ifreq = _content.QueryInterface(
Components.interfaces.nsIInterfaceRequestor);
return ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint);
]]>
</body>
</method>
<method name="_debug">
<parameter name="aMsg"/>
<body>
<![CDATA[
if (this.mDebug)
dump("\t *** pptoolbar: " + aMsg + "\n");
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

View File

@ -0,0 +1,47 @@
<!-- ***** 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 the print preview toolbar.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Samir Gehani <sgehani@netscape.com> (Original Author)
-
- 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 LGPL or the GPL. 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 ***** -->
<!ENTITY print.label "Print...">
<!ENTITY pageSetup.label "Page Setup...">
<!ENTITY page.label "Page:">
<!ENTITY of.label "of">
<!ENTITY scale.label "Scale:">
<!ENTITY percent.label "&#037;">
<!ENTITY portrait.label "Portrait">
<!ENTITY landscape.label "Landscape">
<!ENTITY close.label "Close">

View File

@ -526,6 +526,12 @@
</body>
</method>
<method name="getStripVisibility">
<body>
return !this.mStrip.collapsed;
</body>
</method>
<method name="addTab">
<parameter name="aURI"/>
<parameter name="aReferrerURI"/>