home *** CD-ROM | disk | FTP | other *** search
- /**
- * scrollbar.js
- * by gary smith
- * sample code
- * under construction.....
- */
-
- function ScrollBar(l) {
- this.cScrollBarLayer = null;
- this.cScrollBarParentLayer = null;
- this.cScrollBarLayout = "vertical";
- this.cScrollBarLeft = 0;
- this.cScrollBarTop = 0;
- this.cScrollBarWidth = null;
- this.cScrollBarHeight = null;
-
- this.cScrollBarShow = cScrollBarShow;
- this.setCScrollBarLayer = setCScrollBarLayer;
- this.setCScrollBarParentLayer = setCScrollBarParentLayer;
- this.setCScrollBarLeft = setCScrollBarLeft;
- this.setCScrollBarTop = setCScrollBarTop;
- this.setCScrollBarWidth = setCScrollBarWidth;
- this.setCScrollBarHeight = setCScrollBarHeight;
-
- this.cScrollBarOnMouseOver = cScrollBarOnMouseOver;
- this.cScrollBarAction = cScrollBarAction;
-
- this.cDrag = cDrag;
- this.cDragStart = cDragStart;
- this.cDragEnd = cDragEnd;
- this.cDragSet = cDragSet;
- this.cDragRestrict = cDragRestrict;
- }
-
- function cScrollBarShow(l) {
- var l = l || this.cScrollBarLayer;
- this.cScrollBarLayer = l;
- var p = this.cScrollBarParentLayer;
- if (!l.height) {
- java.lang.System.out.println("this.cScrollBarLayer.height=" + l.height);
- //return;
- }
- if (this.cScrollBarLayout == "horizontal") {
- var width = this.cScrollBarWidth || l.clip.width || 100;
- var height = this.cScrollBarHeight || 15;
- var left = this.cScrollBarLeft || l.left || 0;
- var top = this.cScrollBarTop || l.top + l.clip.height || 0;
- java.lang.System.out.println("width=" + width);
- java.lang.System.out.println("height=" + height);
- java.lang.System.out.println("left=" + left);
- java.lang.System.out.println("top=" + top);
-
- var scrollbar = makeLayer("scrollbar", "", p, width,height, left,top, '#DDDDDD');
- var up = makeLayer("up", "", scrollbar, height -1, height -1, 1, 1, '#000000');
- var down = makeLayer("down", "", scrollbar, height -1, height -1, scrollbar.clip.width - height +1, 1, '#000000');
- var scroller = makeLayer("scroller", "", scrollbar, height -1, height -1, height,1, '#000000');
- up.direction = "left";
- down.direction = "right";
-
- var foo1 = (l.width || 1000) / (l.clip.width - (height * 2) );
- foo1 = (width / foo1) + 4;
-
- scroller.clip.width = foo1;
- scroller.listener = this.cScrollBarAction;
- scroller.cScrollBarLayer = l;
- this.cDragRestrict("y");
- } else {
- var width = this.cScrollBarWidth || 15;
- var height = this.cScrollBarHeight || l.clip.height || 100;
- var left = this.cScrollBarLeft || l.left + l.clip.width || 0;
- var top = this.cScrollBarTop || l.top || 0;
-
- java.lang.System.out.println("width=" + width);
- java.lang.System.out.println("height=" + height);
- java.lang.System.out.println("left=" + left);
- java.lang.System.out.println("top=" + top);
-
- var scrollbar = makeLayer("scrollbar", "", p, width,height, left,top, '#DDDDDD');
- var up = makeLayer("up", "", scrollbar, width -1, width -1, 1, 1, '#000000');
- var down = makeLayer("down", "", scrollbar, width -1, width, 1, scrollbar.clip.height - width, '#000000');
- var scroller = makeLayer("scroller", "", scrollbar, width -1,width -1, 1,width, '#000000');
- up.direction = "up";
- down.direction = "down";
-
- java.lang.System.out.println("width=" + width);
- java.lang.System.out.println("h=" + l.height);
- java.lang.System.out.println("ch=" + l.clip.height);
-
- var foo1 = (l.height || 3000) / (l.clip.height - (width * 2) );
- java.lang.System.out.println("foo1=" + foo1);
- foo1 = (height / foo1) + 4;
- java.lang.System.out.println("foo1=" + foo1);
- //foo1 = l.height / foo1;
- //java.lang.System.out.println("foo1=" + foo1);
- //var foo1 = 30;
-
- scroller.clip.height = foo1;
- scroller.listener = this.cScrollBarAction;
- scroller.cScrollBarLayer = l;
- this.cDragRestrict("x");
- }
-
- up.lite = makeLayer("up", "", up, up.clip.width -1, up.clip.height -1, 0,0, '#FFFFFF');
- up.dark = makeLayer("up", "", up, up.clip.width -2, up.clip.height -2, 1,1, '#666666');
- up.shade = makeLayer("up", "", up, up.clip.width -3, up.clip.height -3, 1,1, '#CCCCCC');
- up.value = makeLayer("up", "", up, up.clip.width -4, up.clip.height -4, 2,2, '#C1CDCD');
- up.value.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN|Event.MOUSEDRAG);
- up.value.onmousedown = this.cScrollBarAction;
- ////up.value.onmouseup=this.cScrollBarDirection;
- up.value.cScrollBarLayer = l;
- up.value.direction = up.direction;
-
- down.lite = makeLayer("down", "", down, down.clip.width -1, down.clip.height -1, 0,0, '#FFFFFF');
- down.dark = makeLayer("down", "", down, down.clip.width -2, down.clip.height -2, 1,1, '#666666');
- down.shade = makeLayer("down", "", down, down.clip.width -3, down.clip.height -3, 1,1, '#CCCCCC');
- down.value = makeLayer("down", "", down, down.clip.width -4, down.clip.height -4, 2,2, '#C1CDCD');
- down.value.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN|Event.MOUSEDRAG);
- down.value.onmousedown=this.cScrollBarAction;
- down.value.cScrollBarLayer = l;
- down.value.direction = down.direction;
-
- //scroller.watch("top", this.cScrollBarAction);
- scroller.lite = makeLayer("scroller", "", scroller, scroller.clip.width -1, scroller.clip.height -1, 0,0, '#FFFFFF');
- scroller.dark = makeLayer("scroller", "", scroller, scroller.clip.width -2, scroller.clip.height -2, 1,1, '#666666');
- scroller.shade = makeLayer("scroller", "", scroller, scroller.clip.width -3, scroller.clip.height -3, 1,1, '#CCCCCC');
- scroller.value = makeLayer("scroller", "", scroller, scroller.clip.width -4, scroller.clip.height -4, 2,2, '#C1CDCD');
- scroller.value.that = this;
- scroller.value.cDragSet = this.cDragSet;
- scroller.value.onmouseover = this.cScrollBarOnMouseOver;
- //scroller.value.onFocus = this.onDialogButton;
- }
-
- function cScrollBarAction(e,x,y) {
- // java.lang.System.out.println("top=" + this.cScrollBarLayer.top)
- // java.lang.System.out.println("width=" + this.cScrollBarLayer.width);
- // java.lang.System.out.println("height=" + this.cScrollBarLayer.height);
- // java.lang.System.out.println("clip.height=" + this.cScrollBarLayer.clip.height);
-
- var l = this.cScrollBarLayer;
- if (x) {
- l.left += -x;
- l.clip.left += x;
- l.clip.right += x;
- } else if (y) {
- var foo1 = (l.height || 3000) / l.clip.height;
- if(foo1) y *= foo1;
- l.top += -y;
- l.clip.top += y;
- l.clip.bottom += y;
- } else if (this.direction == "up") {
- l.top += 5;
- l.clip.top += -5;
- l.clip.bottom += -5;
- } else if (this.direction == "down") {
- l.top += -5;
- l.clip.top += 5;
- l.clip.bottom += 5;
- } else if (this.direction == "right") {
- l.left += -5;
- l.clip.left += 5;
- l.clip.right += 5;
- } else if (this.direction == "left") {
- l.left += 5;
- l.clip.left += -5;
- l.clip.right += -5;
- } else {
- java.lang.System.out.println("scroll direction=" + this.direction)
- }
- }
-
- function setCScrollBarLayer(l) {
- this.cScrollBarLayer = l;
- }
- function setCScrollBarParentLayer(l) {
- this.cScrollBarParentLayer = l;
- }
- function setCScrollBarLeft(i) {
- this.cScrollBarLeft = i;
- }
- function setCScrollBarTop(i) {
- this.cScrollBarTop = i;
- }
- function setCScrollBarWidth(i) {
- this.cScrollBarWidth = i;
- }
- function setCScrollBarHeight(i) {
- this.cScrollBarHeight = i;
- }
-
- function cScrollBarOnMouseOver() {
- this.cDragSet(this);
- }
-
-
-
- function cDragSet(l) {
- cDragObj = l.that;
- cDragObj.cDragLayer = l.cDragLayer || l.parentLayer || l;
- cDragObj.cDragLayer.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN|Event.MOUSEDRAG);
- cDragObj.cDragLayer.onmousedown=cDragStart;
- cDragObj.cDragLayer.onmouseup=cDragEnd;
- }
-
- function cDragRestrict(direction) {
- this.cDragDirection = direction;
- }
-
- function cDrag(e) {
- var x = window.innerWidth;
- var y = window.innerHeight;
- if(e.pageX > -5 && e.pageY > -5 && e.pageX < x && e.pageY < y) {
- //cDragObj.cDragLayer.moveBy(e.pageX-cDragObj.offX,e.pageY-cDragObj.offY);
- x = e.pageX-cDragObj.offX;
- y = e.pageY-cDragObj.offY;
- if (cDragObj.cDragDirection == "x")
- x = null;
- if (cDragObj.cDragDirection == "y")
- y = null;
- cDragObj.cDragLayer.moveBy(x,y);
- if (cDragObj.cDragLayer.listener)
- cDragObj.cDragLayer.listener(e,x,y);
- } else {
- if(cDragObj.cDragLayer.that.dialogMorph) {
- cDragEnd(e);
- dialogWinMorph(e, this);
- }
- }
- cDragObj.offX = e.pageX;
- cDragObj.offY = e.pageY;
- cDragObj.dragged = true;
- }
-
- function dialogWinMorph(e, l) {
- //java.lang.System.out.println("value=" + l.that.dialogContent);
- //java.lang.System.out.println("l.pageX=" + l.pageX);
- if(!l.that) return;
- if(!window.dialogWinMorphs)
- window.dialogWinMorphs = new Array();
- java.lang.System.out.println("len=" + window.dialogWinMorphs.length);
- l.that.win.base.visibility = "hide";
- //if(!l.that.dialogMorphWin) l.that.dialogMorphWin = {};
- //if(!l.that.dialogMorphWin.close) {
- var width = l.that.dialogWidth +20;
- var height = l.that.dialogHeight +20;
- var y = l.pageY + window.screenY + window.outerHeight - window.innerHeight -20;
- if(l.pageX > 0)
- var x = window.screenX + window.outerWidth;
- else
- var x = window.screenX - 100;
- var id = window.dialogWinMorphs.length;
- var win = window.open("",'win' + id,'outerWidth='+ width +',outerHeight='+ height +',left='+ x +',top='+ y);
- win.document.open("text/html");
- win.document.writeln('<BODY BGCOLOR="'+ l.that.dialogBgColor +'">');
- win.document.writeln('<TITLE>'+ l.that.dialogTitle +'</TITLE>');
- win.document.writeln(l.that.dialogContent +'</BODY>');
- win.document.close();
- NdialogLabel = null;
- if(window.dev)
- win.dev = window.dev;
- win.focus();
- window.dialogWinMorphs[l.that.dialogTitle] = win;
- window.dialogWinMorphs[id] = win;
- //}
- }
-
- function cDragStart(e) {
- //java.lang.System.out.println("this=" + this);
- cDragObj.cDragLayer.captureEvents(Event.MOUSEMOVE);
- cDragObj.cDragLayer.onmousemove=cDrag;
- cDragObj.offX=e.pageX;
- cDragObj.offY=e.pageY;
- }
-
- function cDragEnd(e) {
- cDragObj.cDragLayer.onmousemove=0;
- if(cDragObj.dragged == true) {
- if(cDragObj.refresh) {
- cDragObj.cDragLayer.visibility="hide";
- setTimeout('if(cDragObj.cDragLayer) cDragObj.cDragLayer.visibility="inherit";',1);
- }
- cDragObj.cDragLayer.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.MOUSEMOVE|Event.MOUSEDRAG);
- cDragObj.dragged = false;
- if(e.pageY < 0)
- cDragObj.cDragLayer.top = -5;
- //if(e.pageX > window.width) cDragObj.cDragLayer.top = window.width -20;
- }
- }
-
-
- function makeLayer(label, content, parentLyr, width, height, x, y, color, viso) {
- if (!content)
- content = " "; //
- if (parentLyr)
- var l = new Layer(width || 0, parentLyr);
- else
- var l = new Layer(width || 0);
- 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;
- if (x)
- l.left += x;
- if (y)
- l.top += 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;
- }
-