home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 December
/
PCWorld_2005-12_cd.bin
/
komunikace
/
netscape
/
nsb-install-8-0.exe
/
chrome
/
browser.jar
/
content
/
browser
/
setWallpaper.xul
< prev
next >
Wrap
Extensible Markup Language
|
2005-09-26
|
7KB
|
191 lines
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/setWallpaper.dtd">
<dialog xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="aboutDialog"
buttons="accept,cancel"
buttonlabelaccept="&setWallpaper.title;"
onload="onLoad();"
ondialogaccept="onAccept();"
title="&setWallpaper.title;"
style="width: 299px">
<stringbundle id="bundle_wallpaper" src="chrome://browser/locale/browser.properties"/>
<script type="application/x-javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/x-javascript" src="chrome://browser/content/contentAreaUtils.js"/>
<script type="application/x-javascript">
<![CDATA[
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const ISS = Components.interfaces.nsIShellService;
var gPosition = ISS.BACKGROUND_STRETCH;
var gMonitor;
var gWidth, gHeight, gBackgroundColor = 0;
function HexToR(h) { return parseInt((cutHex(h)).substring(0,2),16) }
function HexToG(h) { return parseInt((cutHex(h)).substring(2,4),16) }
function HexToB(h) { return parseInt((cutHex(h)).substring(4,6),16) }
function cutHex(h) { return (h.charAt(0)=="#") ? h.substring(1,7) : h}
function RGBToHex(r, g, b)
{
var rHex = r.toString(16).toUpperCase();
var gHex = g.toString(16).toUpperCase();
var bHex = b.toString(16).toUpperCase();
if (rHex.length == 1) rHex ='0' + rHex;
if (gHex.length == 1) gHex ='0' + gHex;
if (bHex.length == 1) bHex ='0' + bHex;
return '#' + rHex + gHex + bHex;
}
function onLoad()
{
gMonitor = document.getElementById("monitor");
gWidth = window.arguments[0].width;
gHeight = window.arguments[0].height;
initColor();
updatePosition(parseInt(document.getElementById("menuPosition").value));
}
function initColor()
{
var color = 0;
var shell = getShellService();
if (shell)
color = shell.desktopBackgroundColor;
const rMask = 4294901760;
const gMask = 65280;
const bMask = 255;
var r = (color & rMask) >> 16;
var g = (color & gMask) >> 8;
var b = (color & bMask);
gBackgroundColor = RGBToHex(r, g, b);
var colorpicker = document.getElementById("desktopColor");
colorpicker.color = RGBToHex(r, g, b);
}
function createImage()
{
var img = document.createElementNS(xulNS, "image");
const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent;
if (window.arguments[0] instanceof nsIImageLoadingContent) {
var request = window.arguments[0].QueryInterface(nsIImageLoadingContent)
.getRequest(nsIImageLoadingContent.CURRENT_REQUEST);
if (!request)
return false;
}
if (makeURL(window.arguments[0].src).scheme == "javascript")
return false;
img.setAttribute("src", window.arguments[0].src);
return img;
}
function stretchImage()
{
updateColor(gBackgroundColor);
var img = createImage();
img.width = parseInt(gMonitor.style.width);
img.height = parseInt(gMonitor.style.height);
gMonitor.appendChild(img);
}
function tileImage()
{
gMonitor.style.backgroundColor = 'white';
var bundle = document.getElementById("bundle_wallpaper");
var previewStr = bundle.getString("WallpaperNoPreview");
var text = document.createElementNS(xulNS, "label");
text.setAttribute("id", "noPreviewAvailable");
text.setAttribute("value", previewStr);
gMonitor.appendChild(text);
}
function centerImage()
{
updateColor(gBackgroundColor);
var img = createImage();
var width = gWidth*gMonitor.boxObject.width/screen.width;
var height = gHeight*gMonitor.boxObject.height/screen.height;
img.width = Math.floor(width);
img.height = Math.floor(height);
gMonitor.appendChild(img);
}
function onAccept()
{
var r = HexToR(gBackgroundColor);
var g = HexToG(gBackgroundColor);
var b = HexToB(gBackgroundColor);
var shell = getShellService();
if (shell) {
shell.setDesktopBackground(window.arguments[0], gPosition);
shell.desktopBackgroundColor = (r << 16) | (g << 8) | b;
document.persist("menuPosition", "value");
}
}
function updateColor(color)
{
gBackgroundColor = color;
if (gPosition != ISS.BACKGROUND_TILE)
gMonitor.style.backgroundColor = color;
}
function updatePosition(position)
{
if (gMonitor.childNodes.length)
gMonitor.removeChild(gMonitor.firstChild);
gPosition = position;
if (gPosition == ISS.BACKGROUND_TILE)
tileImage();
else if (gPosition == ISS.BACKGROUND_STRETCH)
stretchImage();
else
centerImage();
}
]]>
</script>
<hbox align="center" id="foo">
<label value="&position.label;"/>
<menulist id="menuPosition" label="&position.label;" oncommand="updatePosition(parseInt(this.value));">
<menupopup>
<menuitem label="¢er.label;" value="2"/>
<menuitem label="&tile.label;" value="0"/>
<menuitem label="&stretch.label;" value="1"/>
</menupopup>
</menulist>
<spacer flex="1"/>
<label value="&color.label;"/>
<colorpicker type="button" id="desktopColor" onchange="updateColor(this.color);"/>
</hbox>
<groupbox align="center">
<caption label="&preview.label;"/>
<stack>
<vbox id="monitor" align="center" pack="center"
style="width: 153px !important; height: 114px !important; overflow: hidden;"
left="13" top="18"/>
<image src="chrome://browser/content/monitor.png"/>
</stack>
</groupbox>
</dialog>