1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
14 # The Original Code is Mozilla Firebird about dialog.
16 # The Initial Developer of the Original Code is
17 # Blake Ross (blake@blakeross.com).
18 # Portions created by the Initial Developer are Copyright (C) 2002
19 # the Initial Developer. All Rights Reserved.
22 # Blake Ross <blake@blakeross.com>
23 # Ben Goodger <ben@mozilla.org>
24 # Dão Gottwald <dao@design-noir.de>
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the LGPL or the GPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
40 var
Ci = Components.interfaces;
47 _position :
"STRETCH",
56 return Components.classes[
"@mozilla.org/browser/shell-service;1"]
57 .getService(
Ci.nsIShellService);
62 this._canvas = document.getElementById(
"screen");
63 this._screenWidth = screen.width;
64 this._screenHeight = screen.height;
66 document.documentElement.getButton(
"accept").hidden =
true;
68 if (this._screenWidth / this._screenHeight >= 1.6)
69 document.getElementById(
"monitor").setAttribute(
"aspectratio",
"16:10");
73 self.init(
window.arguments[0]);
77 init:
function (aImage)
82 this._canvas.width = this._canvas.clientWidth;
83 this._canvas.height = this._canvas.clientHeight;
85 var ctx = this._canvas.getContext(
"2d");
86 ctx.scale(this._canvas.clientWidth /
this._screenWidth,
this._canvas.clientHeight /
this._screenHeight);
93 var setDesktopBackground = document.getElementById(
"setDesktopBackground");
94 setDesktopBackground.hidden =
false;
95 var
bundle = document.getElementById(
"backgroundBundle");
96 setDesktopBackground.label = bundle.getString(
"DesktopBackgroundSet");
97 setDesktopBackground.disabled =
false;
99 document.getElementById(
"showDesktopPreferences").hidden =
true;
101 this.updatePosition();
105 _initColor:
function ()
107 var color = this._shell.desktopBackgroundColor;
109 const rMask = 4294901760;
112 var r = (color & rMask) >> 16;
113 var g = (color & gMask) >> 8;
114 var b = (color & bMask);
115 this.updateColor(this._rgbToHex(r, g, b));
117 var colorpicker = document.getElementById(
"desktopColor");
118 colorpicker.color = this._backgroundColor;
121 updateColor:
function (aColor)
123 this._backgroundColor = aColor;
124 this._canvas.style.backgroundColor = aColor;
128 _hexStringToLong:
function (aString)
130 return parseInt(aString.substring(1,3), 16) << 16 |
131 parseInt(aString.substring(3,5), 16) << 8 |
132 parseInt(aString.substring(5,7), 16);
135 _rgbToHex:
function (aR, aG, aB)
137 return "#" + [aR, aG, aB].map(
function(aInt) aInt.toString(16).replace(/^(.)$/,
"0$1"))
138 .join(
"").toUpperCase();
143 if (aTopic ==
"shell:desktop-background-changed") {
144 document.getElementById(
"setDesktopBackground").hidden =
true;
145 document.getElementById(
"showDesktopPreferences").hidden =
false;
147 Components.classes[
"@mozilla.org/observer-service;1"]
148 .getService(
Ci.nsIObserverService)
149 .removeObserver(
this,
"shell:desktop-background-changed");
153 showDesktopPrefs:
function()
155 this._shell.openApplication(
Ci.nsIMacShellService.APPLICATION_DESKTOP);
159 setDesktopBackground:
function ()
162 document.persist(
"menuPosition",
"value");
163 this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
165 Components.classes[
"@mozilla.org/observer-service;1"]
166 .getService(
Ci.nsIObserverService)
167 .addObserver(
this,
"shell:desktop-background-changed",
false);
169 var
bundle = document.getElementById(
"backgroundBundle");
170 var setDesktopBackground = document.getElementById(
"setDesktopBackground");
171 setDesktopBackground.disabled =
true;
172 setDesktopBackground.label = bundle.getString(
"DesktopBackgroundDownloading");
174 this._shell.setDesktopBackground(this._image,
175 Ci.nsIShellService[
"BACKGROUND_" +
this._position]);
178 updatePosition:
function ()
180 var ctx = this._canvas.getContext(
"2d");
181 ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
184 this._position = document.getElementById(
"menuPosition").value;
187 switch (this._position) {
190 ctx.fillStyle = ctx.createPattern(this._image,
"repeat");
191 ctx.fillRect(0, 0, this._screenWidth, this._screenHeight);
195 ctx.drawImage(this._image, 0, 0, this._screenWidth, this._screenHeight);
198 var x = (this._screenWidth - this._image.naturalWidth) / 2;
199 var
y = (this._screenHeight - this._image.naturalHeight) / 2;
200 ctx.drawImage(this._image, x, y);
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe