* Filters/FilterTiff.cs: Compilation fix for 1.1.14
[beagle.git] / mozilla-extension / content / jslib / xul / commonWindow.js
blob6e1993f06976c2f40519d7a8af7a0f08195384cc
1 /*** -*- Mode: Javascript; tab-width: 2;
3 The contents of this file are subject to the Mozilla Public
4 License Version 1.1 (the "License"); you may not use this file
5 except in compliance with the License. You may obtain a copy of
6 the License at http://www.mozilla.org/MPL/
8 Software distributed under the License is distributed on an "AS
9 IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 implied. See the License for the specific language governing
11 rights and limitations under the License.
13 The Original Code is Mozdev Group, Inc. code.
14 The Initial Developer of the Original Code is Pete Collins.
16 Portions created by Mozdev Group, Inc. are
17 Copyright (C) 2003 Mozdev Group, Inc. All
18 Rights Reserved.
20 Contributor(s): Pete Collins <pete@mozdev.org)> (original author)
21 Henrik Gemal <http://gemal.dk>
23 ***/
25 /****************** Globals **********************/
27 if(typeof(JS_LIB_LOADED)=='boolean') {
29 const JS_COMMONWINDOW_FILE = "commonWindow.js";
30 const JS_COMMONWINDOW_LOADED = true;
32 const JS_TOP_LEFT = 0;
33 const JS_TOP_CENTER = 1;
34 const JS_TOP_RIGHT = 2;
36 const JS_MIDDLE_LEFT = 3;
37 const JS_MIDDLE_CENTER = 4;
38 const JS_MIDDLE_RIGHT = 5;
40 const JS_BOTTOM_LEFT = 6;
41 const JS_BOTTOM_CENTER = 7;
42 const JS_BOTTOM_RIGHT = 8;
43 const JS_UNINSTALL_URL = JS_LIB_PATH + "install/uninstall.xul";
45 /****************** Common Dialog Object Class *********************/
47 function CommonWindow(aURL, aWidth, aHeight)
49 if (typeof(aWidth)=="number")
50 this.mWidth=aWidth;
52 if (typeof(aHeight)=="number")
53 this.mHeight=aHeight;
55 if (typeof(aURL)=="string")
56 this.mURL=aURL;
58 return;
60 } // constructor
62 CommonWindow.prototype = {
64 mWidth : 0,
65 mHeight : 0,
66 mURL : null,
67 mPosition : JS_TOP_LEFT,
68 mX : 0,
69 mY : 0,
71 set width (aWidth) {
72 this.mWidth = aWidth;
75 get width () {
76 return this.mWidth;
79 set height (aHeight) {
80 this.mHeight = aHeight;
83 get height () {
84 return this.mHeight;
87 set position (aPos)
89 var x,y;
90 switch (aPos) {
91 case JS_MIDDLE_CENTER:
92 this.mPosition=aPos;
93 x = Math.round(this.mWidth/2);
94 y = Math.round(this.mHeight/2);
96 var sY = window.screen.height/2;
97 var sX = window.screen.width/2;
99 jslibPrint("width: "+this.mWidth);
100 jslibPrint("height: "+this.mHeight);
102 jslibPrint("x: "+x+"y: "+y);
103 jslibPrint("sX: "+sX+"sY: "+sY);
105 this.mY = sY-y;
106 this.mX = sX-x;
107 jslibPrint("mX: "+this.mX);
108 jslibPrint("mY: "+this.mY);
109 break;
111 default:
112 this.mPosition=JS_TOP_LEFT;
113 jslibDebug("not implemented yet setting to JS_TOP_LEFT for now");
117 get position () {
119 var rv="";
120 switch (this.mPosition) {
121 case JS_TOP_LEFT:
122 rv="JS_TOP_LEFT";
123 break;
125 case JS_TOP_CENTER:
126 rv="JS_TOP_CENTER";
127 break;
129 case JS_TOP_RIGHT:
130 rv="JS_TOP_RIGHT";
131 break;
133 case JS_MIDDLE_LEFT:
134 rv="JS_MIDDLE_LEFT";
135 break;
137 case JS_MIDDLE_CENTER:
138 rv="JS_MIDDLE_CENTER";
139 break;
141 case JS_MIDDLE_RIGHT:
142 rv="JS_MIDDLE_RIGHT";
143 break;
145 case JS_BOTTOM_LEFT:
146 rv="JS_BOTTOM_LEFT";
147 break;
149 case JS_BOTTOM_CENTER:
150 rv="JS_BOTTOM_CENTER";
151 break;
153 case JS_BOTTOM_RIGHT:
154 rv="JS_BOTTOM_RIGHT";
155 break;
157 return rv;
160 set url (aURL) {
161 this.mURL = aURL;
164 get url () {
165 return this.mURL;
168 openFullScreen : function () {
170 if (!this.mURL)
171 return;
173 var h = window.screen.height;
174 var w = window.screen.width;
176 var win_prefs = "chrome,dialog=no,width="+w+
177 ",height="+h+",screenX=0,screenY=0";
179 window.openDialog(this.mURL, "_blank", win_prefs);
182 openWebTop : function () {
184 if (!this.mURL)
185 return;
187 var h = window.screen.height;
188 var w = window.screen.width;
189 var win_prefs = "chrome,popup,scrollbars=yes,width="+w+
190 ",height="+h+",screenX=0,screenY=0";
192 jslibDebug(this.mURL+"_blank"+win_prefs);
193 window.openDialog(this.mURL, "_blank", win_prefs);
196 openUninstallWindow : function (aPackage, aCallback) {
198 if (!aPackage) {
199 jslibDebug("Please provide a package name to uninstall")
200 return;
202 var win_prefs = "chrome,dialog,dependent=no,resize=yes,screenX="+this.mX+
203 ",screenY="+this.mY+
204 ",width="+this.mWidth+",height="+this.mHeight;
206 window.openDialog(JS_UNINSTALL_URL, "_blank", win_prefs, aPackage, aCallback);
209 openAbout : function () {
211 if (!this.mURL)
212 return;
214 var h = this.mHeight;
215 var w = this.mWidth;
216 var win_prefs = "chrome,dialog,modal,dependent=no,resize=no,width="+w+
217 ",height="+h+",screenX="+this.mX+",screenY="+this.mY;
219 window.openDialog(this.mURL, "_blank", win_prefs);
222 openSplash : function () {
224 jslibPrint("open splash . . . ");
226 if (!this.mURL)
227 return;
229 var h = this.mHeight;
230 var w = this.mWidth;
231 var popup="popup,";
232 if (/Mac/g.test(window.navigator.platform))
233 popup="";
234 var win_prefs = "chrome,dialog=no,titlebar=no,"+popup+"width="+w+
235 ",height="+h+",screenX="+this.mX+",screenY="+this.mY;
237 window.openDialog(this.mURL, "_blank", win_prefs);
240 open : function ()
242 if (!this.mURL)
243 return;
245 var win_prefs = "chrome,dialog=no,dependent=no,resize=yes,screenX="+this.mX+",screenY="+this.mY+
246 ",width="+this.mWidth+",height="+this.mHeight;
248 window.openDialog(this.mURL, "_blank", win_prefs);
251 openDialog : function () {
253 if (!this.mURL)
254 return;
256 var win_prefs = "chrome,dialog,dependent=yes,resize=yes,screenX="+this.mX+",screenY="+this.mY+
257 ",width="+this.mWidth+",height="+this.mHeight;
259 window.openDialog(this.mURL, "_blank", win_prefs);
262 openModalDialog : function () {
264 if (!this.mURL)
265 return;
267 var win_prefs = "chrome,dialog,dependent=no,modal,resize=yes,screenX="+this.mX+",screenY="+this.mY+
268 ",width="+this.mWidth+",height="+this.mHeight;
270 window.openDialog(this.mURL, "_blank", win_prefs);
273 get openWindows ()
275 var wm = jslibGetService("@mozilla.org/appshell/window-mediator;1",
276 "nsIWindowMediator");
277 jslibDebug(wm);
278 var enumerator = wm.getEnumerator(null);
280 var winArray = new Array();
281 while (enumerator.hasMoreElements()) {
282 var domWindow = enumerator.getNext();
283 winArray.push(domWindow);
286 return winArray;
288 /********************* help *****************************
289 * void getter help
291 * Returns the methods in this object
293 * return values on success and failure
294 * aStr The methods in this object
296 * useage:
297 * <string> = obj.help;
298 ****************************************************/
299 get help() {
301 const help =
303 "\n\nFunction and Attribute List:\n" +
304 "\n";
306 return help;
311 jslibDebug('*** load: '+JS_COMMONWINDOW_FILE+' OK');
313 } // END BLOCK JS_LIB_LOADED CHECK
315 // If jslib base library is not loaded, dump this error.
316 else {
317 dump("JS_BASE library not loaded:\n"
318 + " \tTo load use: chrome://jslib/content/jslib.js\n"
320 + " \tThen: include('chrome://jslib/content/xul/commonWindow.js');\n\n");
322 }; // END FileSystem Class