home *** CD-ROM | disk | FTP | other *** search
- // Lemon (HK) Ltd
- // last modified on 30 July 1999
-
- __registered_ScrollBox = new Array();
- SCROLLING_FACTOR=24;
-
- function ScrollBox(src,margin,direction) {
- this.lyr = SimpleLayer;
- this.lyr(src);
- __registered_ScrollBox[__registered_ScrollBox.length] = this;
- if (direction==null) direction=0;
- if (direction==0 || direction==2) {
- this.up = new Button(src+".ScrollUp");
- this.down = new Button(src+".ScrollDown");
- this.up.onPress=ScrollBoxUp;
- this.down.onPress=ScrollBoxDown;
- this.up.resize(margin, this.up.h);
- this.down.resize(margin, this.up.h);
- }
- if (direction==1 || direction==2)
- {
- this.left = new Button(src+".ScrollLeft");
- this.right = new Button(src+".ScrollRight");
- this.left.onPress=ScrollBoxLeft;
- this.right.onPress=ScrollBoxRight;
- this.left.resize(this.left.w, margin);
- this.right.resize(this.left.w, margin);
- }
- this.content = new SimpleLayer(src+".ScrollBody");
- this.content.moveTo(0,0);
- if (this.content.h < this.h) this.content.resize(this.content.w, this.h);
- this.redraw=ScrollBoxRedraw;
- this.redraw();
- }
- function ScrollBoxUp() { ScrollBoxScrollIt(this, 1, true); }
- function ScrollBoxDown() { ScrollBoxScrollIt(this, -1, true); }
- function ScrollBoxLeft() { ScrollBoxScrollIt(this, 1, false); }
- function ScrollBoxRight() { ScrollBoxScrollIt(this, -1, false); }
- function ScrollBoxScrollIt(target,dir,vert) {
- var scrollbox = getParent(target.path);
- var obj = findObject(scrollbox, __registered_ScrollBox);
- if (obj && vert) {
- var dh = obj.content.h - obj.h;
- var dy = dir * SCROLLING_FACTOR;
- if (dy > 0 && dy + obj.content.y > 0) dy = -obj.content.y;
- if (dy < 0 && dy + obj.content.y < -dh) dy = - obj.content.y - dh;
- obj.content.moveBy(obj.content.x,dy);
- }
- if (obj && !vert) {
- var dw = obj.content.w - obj.w;
- var dx = dir * SCROLLING_FACTOR;
- if (dx > 0 && dx + obj.content.x > 0) dx = -obj.content.x;
- if (dx < 0 && dx + obj.content.x < -dw) dx = - obj.content.x - dw;
- obj.content.moveBy(dx,obj.content.y);
- }
- }
- function ScrollBoxRedraw() {
- var w = this.w-this.up.w;
- if (NS) this.content.obj.clip.width = w;
- else this.content.obj.style.pixelWidth = w;
-
- this.up.moveTo(w, 0);
- this.down.moveTo(w, this.h-this.down.w);
- }
-