New fonts prefs panel. Bug 28899. r=fabian, sr=ben.

This commit is contained in:
gerv%gerv.net 2001-05-19 15:44:13 +00:00
parent 67c55cf62a
commit 07cb655f21
7 changed files with 366 additions and 134 deletions

View File

@ -32,6 +32,7 @@ comm.jar:
content/communicator/pref/pref-download.xul (prefwindow/resources/content/pref-download.xul)
content/communicator/pref/pref-fonts.js (prefwindow/resources/content/pref-fonts.js)
content/communicator/pref/pref-fonts.xul (prefwindow/resources/content/pref-fonts.xul)
content/communicator/pref/pref-calibrate-screen.xul (prefwindow/resources/content/pref-calibrate-screen.xul)
content/communicator/pref/pref-history.xul (prefwindow/resources/content/pref-history.xul)
content/communicator/pref/pref-languages.xul (prefwindow/resources/content/pref-languages.xul)
content/communicator/pref/pref-languages-add.xul (prefwindow/resources/content/pref-languages-add.xul)

View File

@ -10,6 +10,7 @@ pref-charset.js
pref-charset.xul
pref-cache.js
pref-cache.xul
pref-calibrate-screen.xul
pref-colors.js
pref-colors.xul
pref-themes.xul

View File

@ -48,6 +48,7 @@ CHROME_CONTENT = \
.\pref-debug2.xul \
.\pref-download.xul \
.\pref-fonts.xul \
.\pref-calibrate-screen.xul \
.\pref-fonts.js \
.\pref-history.xul \
.\pref-languages.xul \

View File

@ -0,0 +1,72 @@
<?xml version="1.0"?>
<!--
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 Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-2000 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
-->
<?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?>
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-fonts.dtd" >
<window id="calibrateScreen"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&calibrateDialog.title;"
class="dialog"
onload="Init();"
orient="vertical"
persist="screenX screenY">
<script type="application/x-javascript"
src="chrome://communicator/content/pref/pref-fonts.js"/>
<box orient="vertical" align="center">
<box id="horizRuler" orient="vertical" width="300" height="30" style="margin: 10px; margin-bottom: 0px">
<box height="10px" style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;"/>
<box height="10px" style="border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;"/>
</box>
<box align="center">
<text value="&calibrate.instructions;"/>
</box>
<separator class="thin"/>
<hbox align="center" autostretch="never" valign="middle">
<textbox id="horizSize" size="5"/>
<menulist id="units" persist="value">
<menupopup>
<menuitem value="centimetres" label="&units.centimetres;"/>
<menuitem value="inches" label="&units.inches;"/>
</menupopup>
</menulist>
</hbox>
<separator/>
<keyset id="dialogKeys"/>
<box id="okCancelButtonsRight"/>
</box>
</window>

View File

@ -1,3 +1,26 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Gervase Markham <gerv@gerv.net>
*/
try
{
var fontList = Components.classes["@mozilla.org/gfx/fontlist;1"].createInstance();
@ -8,10 +31,10 @@ try
}
catch(e)
{
dump("failed to get font list or pref object: "+e+", "+fileName+" "+lineNum+"\n");
dump("failed to get font list or pref object: "+e+" in pref-fonts.js\n");
}
var fontTypes = ["serif","sans-serif", /*"cursive", "fantasy",*/"monospace"];
var fontTypes = ["serif", "sans-serif", "cursive", "fantasy", "monospace"];
var variableSize, fixedSize, languageList;
var languageData = [];
var currentLanguage;
@ -23,7 +46,7 @@ function GetFields()
var dataObject = [];
// store data for language independent widgets
var lists = ["selectLangs", "defaultFont"];
var lists = ["selectLangs", "proportionalFont"];
for( var i = 0; i < lists.length; i++ )
{
if( !dataObject.dataEls )
@ -32,9 +55,9 @@ function GetFields()
dataObject.dataEls[ lists[i] ].value = document.getElementById( lists[i] ).value;
}
dataObject.defaultFont = document.getElementById( "defaultFont" ).value;
dataObject.fontDPI = document.getElementById( "browserScreenResolution" ).value;
dataObject.useDocFonts = document.getElementById( "browserUseDocumentFonts" ).checked ? 0 : 1;
dataObject.defaultFont = document.getElementById( "proportionalFont" ).value;
dataObject.fontDPI = document.getElementById( "screenResolution" ).value;
dataObject.useDocFonts = document.getElementById( "browserUseDocumentFonts" ).checked ? 1 : 0;
// save current state for language dependent fields and store
saveState();
@ -49,7 +72,9 @@ function SetFields( aDataObject )
languageData = aDataObject.languageData ? aDataObject.languageData : languageData ;
currentLanguage = aDataObject.currentLanguage ? aDataObject.currentLanguage : null ;
var lists = ["selectLangs", "defaultFont"];
var lists = ["selectLangs", "proportionalFont"];
var prefvalue;
for( var i = 0; i < lists.length; i++ )
{
var element = document.getElementById( lists[i] );
@ -71,23 +96,47 @@ function SetFields( aDataObject )
}
}
var resolutionField = document.getElementById( "browserScreenResolution" );
if( aDataObject.fontDPI != undefined )
resolutionField.value = aDataObject.fontDPI;
var screenResolution = document.getElementById( "screenResolution" );
var resolution;
if( aDataObject.fontDPI )
{
resolution = aDataObject.fontDPI;
}
else
{
var prefvalue = parent.hPrefWindow.getPref( resolutionField.getAttribute("preftype"), resolutionField.getAttribute("prefstring") );
prefvalue = parent.hPrefWindow.getPref( "int", "browser.display.screen_resolution" );
if( prefvalue != "!/!ERROR_UNDEFINED_PREF!/!" )
resolutionField.value = prefvalue;
resolution = prefvalue;
else
resolution = 96; // If it all goes horribly wrong, fall back on 96.
}
var userResolution = document.getElementById("userResolution");
// If it's one of the hard-coded values, this will work...
try
{
screenResolution.selectedItem = screenResolution.getElementsByAttribute( "value", resolution )[0];
userResolution.setAttribute("hidden", "true");
}
catch (e)
{
// Otherwise we need to set up the userResolution field
userResolution.setAttribute("value", resolution);
userResolution.setAttribute("label", resolution);
userResolution.removeAttribute("hidden");
screenResolution.selectedItem = userResolution;
}
var useDocFontsCheckbox = document.getElementById( "browserUseDocumentFonts" );
if( aDataObject.useDocFonts != undefined )
useDocFontsCheckbox.checked = aDataObject.useDocFonts ? false : true;
useDocFontsCheckbox.checked = aDataObject.useDocFonts ? true : false;
else
{
var prefvalue = parent.hPrefWindow.getPref( useDocFontsCheckbox.getAttribute("preftype"), useDocFontsCheckbox.getAttribute("prefstring") );
prefvalue = parent.hPrefWindow.getPref( "int", "browser.display.use_document_fonts" );
if( prefvalue != "!/!ERROR_UNDEFINED_PREF!/!" )
useDocFontsCheckbox.checked = prefvalue ? false : true ;
useDocFontsCheckbox.checked = prefvalue ? true : false ;
}
}
@ -354,3 +403,85 @@ function selectLanguage()
currentLanguage = languageList.value;
}
function changeScreenResolution()
{
var screenResolution = document.getElementById("screenResolution");
var userResolution = document.getElementById("userResolution");
if (screenResolution.value == "other")
{
// If the user selects "Other..." we bring up the calibrate screen dialog
var rv = { newdpi : 0 };
calscreen = window.openDialog("chrome://communicator/content/pref/pref-calibrate-screen.xul",
"",
"modal=yes,chrome,resizeable=no,centerscreen",
rv);
if (rv.newdpi != -1)
{
// They have entered values, and we have a DPI value back
userResolution.setAttribute("value", rv.newdpi);
userResolution.setAttribute("label", rv.newdpi + " dpi");
userResolution.removeAttribute("hidden");
screenResolution.selectedItem = userResolution;
}
else
{
// They've cancelled. We can't leave "Other..." selected, so...
var defaultResolution = document.getElementById("defaultResolution");
screenResolution.selectedItem = defaultResolution;
userResolution.setAttribute("hidden", "true");
}
}
else if (!(screenResolution.value == userResolution.value))
{
// User has selected one of the hard-coded resolutions
userResolution.setAttribute("hidden", "true");
}
}
// "Calibrate screen" dialog code
function Init()
{
sizeToContent();
doSetOKCancel(onOK, onCancel);
document.getElementById("horizSize").focus();
}
function onOK()
{
// Get value from the dialog to work out dpi
var horizSize = parseFloat(document.getElementById("horizSize").value);
var units = document.getElementById("units").value;
if (!horizSize || horizSize < 0)
{
// We can't calculate anything without a proper value
window.arguments[0].newdpi = -1;
return true;
}
// Convert centimetres to inches.
// The magic number is allowed because it's a fundamental constant :-)
if (units === "centimetres")
{
horizSize /= 2.54;
}
// These shouldn't change, but you can't be too careful.
var horizBarLengthPx = document.getElementById("horizRuler").boxObject.width;
var horizDPI = parseInt(horizBarLengthPx) / horizSize;
// Average the two <shrug>.
window.arguments[0].newdpi = Math.round(horizDPI);
return true;
}
function onCancel()
{
// We return zero to show that no value has been given.
window.arguments[0].newdpi = -1;
return true;
}

View File

@ -33,15 +33,17 @@
<stringbundle id="bundle_prefutilities"
src="chrome://communicator/locale/pref/prefutilities.properties"/>
<script type="application/x-javascript" src="chrome://communicator/content/pref/pref-fonts.js"/>
<script type="application/x-javascript"
src="chrome://communicator/content/pref/pref-fonts.js"/>
<box class="box-smallheader" title="&lHeader;"/>
<titledbox orient="vertical">
<label value="&displayFonts;"/>
<box autostretch="never" valign="middle">
<text class="label small-margin" value="&language.label;" accesskey="&language.accesskey;" for="selectLangs"/>
<label>
<text class="label small-margin"
value="&language.label;"
accesskey="&language.accesskey;"
for="selectLangs"/>
<menulist id="selectLangs" class="small-margin" oncommand="selectLanguage();" persist="value">
<menupopup>
<menuitem value="x-western" label="&font.langGroup.latin1;"/>
@ -61,27 +63,32 @@
<menuitem value="ar" label="&font.langGroup.arabic;"/>
</menupopup>
</menulist>
<spring flex="1"/>
</box>
<text class="label" value="&variableFonts.label;"/>
</label>
<grid>
<columns>
<column/>
<column flex="1"/>
<column/>
<column/>
<column/>
<column width="60"/>
</columns>
<rows>
<row autostretch="never" valign="middle">
<text class="label small-margin" value="&serif.label;" accesskey="&serif.accesskey;" for="serif"/>
<menulist id="serif" class="small-margin" flex="1" style="width: 0px;">
<menupopup/>
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&proportional.label;"
accesskey="&proportional.accesskey;"
for="proportionalFont"/>
</box>
<menulist id="proportionalFont" class="small-margin" flex="1" style="width: 0px;"
preftype="string" prefstring="font.default">
<menupopup>
<menuitem value="serif"
label="&useDefaultFontSerif.label;"/>
<menuitem value="sans-serif"
label="&useDefaultFontSansSerif.label;"/>
</menupopup>
</menulist>
<text class="label small-margin" value="&size.label;" accesskey="&sizeVar.accesskey;" for="sizeVar"/>
<menulist id="sizeVar" class="small-margin">
<menupopup>
<menuitem value="8" label="8"/>
@ -107,101 +114,126 @@
<menuitem value="72" label="72"/>
</menupopup>
</menulist>
<text class="label" value="&units.label;"/>
</row>
<row autostretch="never" valign="middle">
<text class="label small-margin" value="&sans-serif.label;" accesskey="&sans-serif.accesskey;" for="sans-serif"/>
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&serif.label;"
accesskey="&serif.accesskey;"
for="serif"/>
</box>
<menulist id="serif" class="small-margin" flex="1" style="width: 0px;">
<menupopup/>
</menulist>
<spring/>
</row>
<row autostretch="never" valign="middle">
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&sans-serif.label;"
accesskey="&sans-serif.accesskey;"
for="sans-serif"/>
</box>
<menulist id="sans-serif" class="small-margin" flex="1" style="width: 0px;">
<menupopup/>
</menulist>
<spring/>
<spring/>
<spring/>
</row>
<!--
<row autostretch="never" valign="middle">
<text class="label small-margin" value="&cursive.label;" accesskey="&cursive.accesskey;" for="cursive"/>
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&cursive.label;"
accesskey="&cursive.accesskey;"
for="cursive"/>
</box>
<menulist id="cursive" class="small-margin">
<menupopup/>
</menulist>
<spring/>
<spring/>
<spring/>
</row>
<row autostretch="never" valign="middle">
<text class="label small-margin" value="&fantasy.label;" accesskey="&fantasy.accesskey;" for="fantasy"/>
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&fantasy.label;"
accesskey="&fantasy.accesskey;"
for="fantasy"/>
</box>
<menulist id="fantasy" class="small-margin">
<menupopup/>
</menulist>
<spring/>
<spring/>
<spring/>
</row>
-->
<row autostretch="never" valign="middle">
<box autostretch="never" halign="right">
<text class="label small-margin"
value="&monospace.label;"
accesskey="&monospace.accesskey;"
for="monospace"/>
</box>
<menulist id="monospace" class="small-margin"
flex="1" style="width: 0px;" crop="right">
<menupopup/>
</menulist>
<menulist id="sizeMono" class="small-margin">
<menupopup>
<menuitem value="8" label="8"/>
<menuitem value="9" label="9"/>
<menuitem value="10" label="10"/>
<menuitem value="11" label="11"/>
<menuitem value="12" label="12"/>
<menuitem value="13" label="13"/>
<menuitem value="14" label="14"/>
<menuitem value="15" label="15"/>
<menuitem value="16" label="16"/>
<menuitem value="18" label="18"/>
<menuitem value="20" label="20"/>
<menuitem value="24" label="24"/>
<menuitem value="26" label="26"/>
<menuitem value="28" label="28"/>
<menuitem value="32" label="32"/>
<menuitem value="36" label="36"/>
<menuitem value="40" label="40"/>
<menuitem value="48" label="48"/>
<menuitem value="56" label="56"/>
<menuitem value="64" label="64"/>
<menuitem value="72" label="72"/>
</menupopup>
</menulist>
</row>
</rows>
</grid>
<box autostretch="never" valign="middle" class="indent">
<text class="label" value="&default.type.label;"/>
<radiogroup id="defaultFont" preftype="string" prefstring="font.default">
<radio group="defaultFont" value="serif" label="&useDefaultFontSerif.label;" accesskey="&useDefaultFontSerif.accesskey;"/>
<radio group="defaultFont" value="sans-serif" label="&useDefaultFontSansSerif.label;" accesskey="&useDefaultFontSansSerif.accesskey;"/>
</radiogroup>
</box>
<separator class="thin"/>
<text class="label" value="&fixedFonts.label;"/>
<hbox autostretch="never" valign="middle">
<text class="label small-margin" value="&monospace.label;" accesskey="&monospace.accesskey;" for="monospace"/>
<menulist id="monospace" class="small-margin" flex="1" style="width: 0px;" crop="right">
<menupopup/>
</menulist>
<text class="label small-margin" value="&size.label;" accesskey="&sizeMono.accesskey;" for="sizeMono"/>
<menulist id="sizeMono" class="small-margin">
<menupopup>
<menuitem value="8" label="8"/>
<menuitem value="9" label="9"/>
<menuitem value="10" label="10"/>
<menuitem value="11" label="11"/>
<menuitem value="12" label="12"/>
<menuitem value="13" label="13"/>
<menuitem value="14" label="14"/>
<menuitem value="15" label="15"/>
<menuitem value="16" label="16"/>
<menuitem value="18" label="18"/>
<menuitem value="20" label="20"/>
<menuitem value="24" label="24"/>
<menuitem value="26" label="26"/>
<menuitem value="28" label="28"/>
<menuitem value="32" label="32"/>
<menuitem value="36" label="36"/>
<menuitem value="40" label="40"/>
<menuitem value="48" label="48"/>
<menuitem value="56" label="56"/>
<menuitem value="64" label="64"/>
<menuitem value="72" label="72"/>
</menupopup>
</menulist>
<text class="label" value="&units.label;"/>
</hbox>
<!-- note that this removes the ability to select dynamic fonts -->
<checkbox id="browserUseDocumentFonts" class="small-margin"
label="&useDocumentFonts.label;" accesskey="&useDocumentFonts.accesskey;"
preftype="int" prefstring="browser.display.use_document_fonts"/>
</titledbox>
<titledbox orient="vertical">
<label value="&fontScaling;"/>
<html>&fontScalingIntro;</html>
<box autostretch="never" valign="middle">
<text class="label" value="&resolution.label;" accesskey="&resolution.accesskey;" for="browserScreenResolution"/>
<textbox id="browserScreenResolution" size="4" maxlength="3" value="&defaultScaling;" preftype="int" prefstring="browser.display.screen_resolution"/>
<text class="label" value="&fontScalingExample;"/>
</box>
</titledbox>
<separator class="thin"/>
<box autostretch="never">
<!-- Unchecking this removes the ability to select dynamic fonts -->
<checkbox id="browserUseDocumentFonts"
clas="small-margin"
label="&useDocumentFonts.label;"
accesskey="&useDocumentFonts.accesskey;"/>
</box>
<separator class="thin"/>
<box autostretch="never" valign="middle">
<text class="label small-margin"
value="&resolution.label;"
accesskey="&resolution.accesskey;"
for="screenResolution"/>
<menulist id="screenResolution"
oncommand="changeScreenResolution()">
<menupopup>
<menuitem value="72" label="72 dpi"/>
<menuitem value="96"
label="96 dpi (&resolution.default;)"
id="defaultResolution"/>
<menuseparator/>
<menuitem id="userResolution" hidden="true"/>
<menuitem value="other" label="&resolution.other;"/>
</menupopup>
</menulist>
</box>
</window>

View File

@ -2,23 +2,27 @@
<!-- LOCALIZATION NOTE : FILE 'Fonts' prefs dialog -->
<!ENTITY lHeader "Fonts">
<!ENTITY displayFonts "Default Fonts for Displaying Web Pages">
<!ENTITY language.label "Language encoding:">
<!ENTITY language.accesskey "o">
<!ENTITY language.label "Fonts for:">
<!ENTITY language.accesskey "t">
<!ENTITY proportional.label "Proportional:">
<!ENTITY proportional.accesskey "p">
<!ENTITY serif.label "Serif:">
<!ENTITY serif.accesskey "f">
<!ENTITY sans-serif.label "Sans Serif:">
<!ENTITY sans-serif.accesskey "s">
<!ENTITY serif.accesskey "s">
<!ENTITY sans-serif.label "Sans-serif:">
<!ENTITY sans-serif.accesskey "n">
<!ENTITY monospace.label "Monospace:">
<!ENTITY monospace.accesskey "m">
<!-- LOCALIZATION NOTE (fantasy.select): 'Fantasy' means 'Ornate' -->
<!-- LOCALIZATION NOTE (fantasy.label): 'Fantasy' means 'Ornate' -->
<!ENTITY fantasy.label "Fantasy:">
<!ENTITY fantasy.accesskey "t">
<!ENTITY fantasy.accesskey "f">
<!ENTITY cursive.label "Cursive:">
<!ENTITY cursive.accesskey "c">
<!ENTITY fontsize.units "pixels">
<!ENTITY font.langGroup.latin1 "Western">
<!ENTITY font.langGroup.latin2 "Central European">
<!ENTITY font.langGroup.japanese "Japanese">
@ -35,23 +39,14 @@
<!ENTITY font.langGroup.hebrew "Hebrew">
<!ENTITY font.langGroup.arabic "Arabic">
<!-- LOCALIZATION NOTE (size1.option): DONT_TRANSLATE -->
<!ENTITY size.label "Size:">
<!ENTITY sizeVar.accesskey "z">
<!ENTITY sizeMono.accesskey "i">
<!-- default font type -->
<!ENTITY default.type.label "Default Type:">
<!ENTITY useDefaultFontSerif.label "Serif">
<!ENTITY useDefaultFontSerif.accesskey "r">
<!ENTITY useDefaultFontSansSerif.label "Sans Serif">
<!ENTITY useDefaultFontSansSerif.accesskey "n">
<!ENTITY newLanguages.label "New languages can be configured using the Languages Panel.">
<!ENTITY useDocumentFonts.label "Always use my font settings, overriding web page font">
<!ENTITY useDocumentFonts.accesskey "u">
<!ENTITY useDocumentFonts.label "Allow documents to use other fonts">
<!ENTITY useDocumentFonts.accesskey "o">
<!-- leaving this stuff in for now -->
@ -66,14 +61,13 @@
<!ENTITY useDocFontDynamic.accesskey "a">
<!-- font scaling -->
<!ENTITY fontScaling "Screen Resolution">
<!ENTITY fontScalingIntro "Choose a screen resolution. A larger value can improve text readability on some displays.">
<!ENTITY defaultScaling "96">
<!ENTITY fontScalingExample "dpi. (e.g. 96dpi)">
<!ENTITY resolution.label "Screen resolution:">
<!ENTITY resolution.accesskey "e">
<!ENTITY resolution.label "Display resolution:">
<!ENTITY resolution.accesskey "r">
<!ENTITY resolution.other "Other...">
<!ENTITY resolution.default "default">
<!ENTITY fixedFonts.label "Fixed-width fonts:">
<!ENTITY variableFonts.label "Variable-width fonts:">
<!ENTITY units.label "pixels">
<!-- screen calibration dialog -->
<!ENTITY calibrateDialog.title "Calibrate Resolution">
<!ENTITY calibrate.instructions "The length of the line above is:">
<!ENTITY units.inches "inches">
<!ENTITY units.centimetres "centimeters">