home *** CD-ROM | disk | FTP | other *** search
- /**
- * statusbar.js
- * by gary smith July 1997
- * for sample code (still under construction)
- * see also menubar.js
- */
-
- function StatusBar(width, height) {
- this.statusBarBgColor = "#C1CDCD"; //CDB79E
- this.bar = new Layer(0);
- this.bar.document.bgColor = "#000000";
- this.bar.document.writeln(' ');
- this.bar.document.close();
- this.bar.clip.width = width || window.innerWidth || 100;
- this.bar.clip.height = height || 20;
- this.bar.left = 0;
- this.bar.top = window.innerHeight - 20;
- this.barWidth = this.bar.clip.width;
- this.bar.clip.height += 3;
- this.barHeight = this.bar.clip.height;
- this.bar.visibility = 'inherit';
- this.bar.shadow = makeLayer('m', ' ', this.bar, this.barWidth -1, this.barHeight -1, 0,0, '#888888');
- this.bar.lite = makeLayer('m', ' ', this.bar, this.barWidth -2, this.barHeight -2, 0,0, '#EEEEEE');
- this.bar.body = makeLayer('m', ' ', this.bar, this.barWidth -3, this.barHeight -3, 1,1, this.statusBarBgColor);
- this.bar.band = makeLayer('m', ' ', this.bar, this.barWidth -3, 1, 1,3, '#888888');
- this.bar.body.onFocus = onStatusBar;
- this.bar.body.StatusBar = true;
- this.prev = null;
- this.countItems = 0;
- this.items = new Array();
-
- this.addStatusBarItem = addStatusBarItem;
- this.setStatusBarBgColor = setStatusBarBgColor;
- this.moveStatusBarItem = moveStatusBarItem;
- this.moveStatusBar = moveStatusBar;
- this.onStatusBar = onStatusBar;
- this.resizeStatusBar = resizeStatusBar;
- }
-
- function addStatusBarItem(label, label_focus, action, width,height, x,y) {
- //var label = '<NOBR><DIV ID=sysFont>' + label + '</DIV></NOBR>';
- //var label_focus = '<NOBR><DIV ID=sysFont>' + label_focus + '</DIV></NOBR>';
- if(label_focus.indexOf(" HREF") == -1) label_focus = '<A HREF="#">' + label_focus + '</A>';
- if(label.indexOf("<DIV ID") == -1) {
- label = '<NOBR><DIV ID=sysFont>' + label + '</DIV></NOBR>';
- label_focus = '<NOBR><DIV ID=sysFont>' + label_focus + '</DIV></NOBR>';
- }
- //java.lang.System.out.println("label=" + label_focus);
- var item = makeLayer('label', label, this.bar, 0,0, 1,4, "", "hide");
- item.focus = makeLayer('label_focus', label_focus, this.bar, 0,0, 1,4, "", "hide");
- item.label = label;
- item.bar = this.bar;
- item.focus.ref = item;
- if(x) {
- item.left = x;
- } else if(this.items[this.countItems -1]) {
- item.left = this.items[this.countItems -1].left + this.items[this.countItems -1].clip.width +5;
- }
- if(y) {
- item.top = y;
- item.focus.top = y;
- }
- item.focus.left = item.left;
- item.visibility = 'inherit';
- item.focus.visibility = 'hide';
- item.onMouseOver = onStatusBarItem_MouseOver;
- item.focus.onMouseOut = onStatusBarItem_MouseOut;
- item.onFocus = this.onStatusBar;
- item.focus.onFocus = this.onStatusBar;
- item.focus.action = action;
- item.ref = this;
- if(item.menuLayer) item.menuLayer = item.menuLayer;
- this.items[item] = item;
- this.items[this.countItems] = item;
- this.countItems++;
- }
-
- function onStatusBarItem_MouseOver(e) {
- if(window.activeStatusBarItem) window.activeStatusBarItem.visibility = "hide";
- this.focus.visibility = "inherit";
- onStatusBar(e,this);
- window.activeStatusBarItem = this.focus;
- }
-
- function onStatusBarItem_MouseOut(e) {
- //this.bgColor = "#BEBEBE";
- this.visibility = "hide";
- }
-
- function onStatusBar(e,lyr) {
- //java.lang.System.out.println("e.target.name=" + e.target.name);
-
- if(!lyr) {
- var l = this;
- if(window.activeStatusBarItem) window.activeStatusBarItem.visibility = "hide";
- if(l.action) eval( l.action );
- if(l.StatusBar) return;
- } else {
- var l = lyr;
- }
- if(l.menuLayer) {
- l.menuLayer.left = l.left + l.bar.left;
- l.menuLayer.top = l.top + l.clip.height + l.bar.top;
- l.menuLayer.visibility = 'inherit';
- }
-
- }
-
- function moveStatusBarItem(item, x, y) {
- if(typeof(item) == 'string') {
- item = this.items[item];
- }
- if(x) {
- item.left = x;
- item.focus.left = x;
- }
- if(y) {
- item.top = y;
- item.focus.top = y;
- }
- }
-
- function moveStatusBar(x,y) {
- if(x) this.bar.left = x;
- if(y) this.bar.top = y;
- }
-
- function resizeStatusBar(w, h) {
- if(w) {
- this.bar.clip.width = w;
- this.bar.shadow.clip.width = w -1;
- this.bar.lite.clip.width = w -2;
- this.bar.body.clip.width = w -3;
- this.bar.band.clip.width = w -3;
- }
- if(h) {
- this.bar.clip.height = h;
- this.bar.shadow.clip.height = h -1;
- this.bar.lite.clip.height = h -2;
- this.bar.body.clip.height = h -3;
- this.bar.band.clip.height = h -3;
- }
- }
-
- function setStatusBarBgColor(str) {
- this.statusBarBgColor = str;
- }
-
- function makeLayer(label, content, parentLyr, width, height, x, y, color, viso) {
- //java.lang.System.out.println(""+ parentLyr);
- if(!content) content = " ";
- if(parentLyr) var l = new Layer(width, parentLyr);
- else var l = new Layer(width);
- l.document.ids.font14.fontSize = 14;
- l.document.ids.sysFont.fontSize = 12;
- l.document.ids.sysFont.fontFamily = "Arial, Espy, sans-serif";
- l.document.open("text/html");
- l.document.writeln(content);
- l.document.close();
- l.label = label;
- l.moveTo(x,y);
- if(color != "") l.bgColor = color;
- if(width) l.clip.width = width;
- if(height) l.clip.height = height;
- if(!viso) l.visibility = "inherit";
- return l;
- }