/* * Well, I better reuse this thing pretty often. */ class ScrollPanel { HScrollbar[] scrolls; Hashtable byName; int index; int y; int loose; int barHeight; ScrollPanel(int len, int yIn) { this(len,yIn,16); } ScrollPanel(int len, int yIn, int looseness){ scrolls = new HScrollbar[len]; byName = new Hashtable(); index = 0; y = yIn; loose = looseness; barHeight = 10; } ScrollPanel(int len){ this(len,20); } HScrollbar addBBar(String name, int maxim){ BHScrollbar item = new BHScrollbar(name, 0,y + (index * 2 * barHeight),width,barHeight,loose,maxim); push(item); return item; } HScrollbar addIBar(String name, int maxim){ IHScrollbar item = new IHScrollbar(name, 0,y + (index * 2 * barHeight),width,barHeight,loose,maxim); push(item); return item; } HScrollbar addBar(String name, int maxim) { return addBar(name, 0, y + (index * 2 *barHeight), width, barHeight, loose, maxim); } HScrollbar addBar(String name, int xp, int yp, int sw, int sh, int l, int maxim ){ HScrollbar item = new HScrollbar (name, xp,yp,sw,sh,l, maxim); push(item); return item; } void push(HScrollbar item){ if (full()) sResize(); scrolls[index] = item; index++; byName.put(item.title, item); } private boolean full(){ return index == scrolls.length; } private void sResize(){ HScrollbar[] newscrolls = new HScrollbar[scrolls.length * 2]; for(int i=0; i < scrolls.length; i++){ newscrolls[i] = scrolls[i]; } scrolls = newscrolls; } float getVal(String name){ HScrollbar item = (HScrollbar) byName.get(name); return item.getVal(); } float getPos(String name){ HScrollbar item = (HScrollbar) byName.get(name); return item.getPos(); } boolean overScrolls(){ for(int i = 0; i < index; i++){ if(scrolls[i].over()){return true;} } return false; } void displayScrolls(){ //if(overScrolls()){ for(int i = 0; i < index; i++){ scrolls[i].display(); } //return true; //} //return false; } void updateScrolls(){ for(int i = 0; i < index; i++){ scrolls[i].update(); //palette[i][0] = scrolls[i].spos/width; } } }