// (c): Matti J. Katila package org.nongnu.libvob.vobs; import org.nongnu.libvob.*; import java.util.*; import java.awt.*; /** Vob usefull for listing items. Can be used i.e., * to show a list after mouse click. Click can be recognized * through Key object. */ public class SelectListVob extends AbstractVob { public static boolean dbg = false; private static void p(String s) { System.out.println("SelectListVob:: "+s); } public class Key { public Object object = null; public Key(Object obj) { this.object = obj; } } private RectBgVob bg; private TextStyle style; private Color textColor = Color.black; private final float scale; public SelectListVob(TextStyle style) { this(style, new Color(.9f, .9f, 1)); } public SelectListVob(TextStyle style, Color bgColor) { this.style = style; this.bg = new RectBgVob(bgColor); scale = style.getScaleByHeight(22); } private ArrayList keys = new ArrayList(); private ArrayList vobs = new ArrayList(); public void add(String text, Object key) { this.add(text, new Key(key)); } public void add(String text, Key key) { keys.add(key); vobs.add(new TextVob(style, text, false)); } public void render(Graphics g, boolean fast, RenderInfo info1, RenderInfo info2) { throw new Error("Not implemented"); } public int putGL(VobScene vs, int into) { vs.put(bg, into); if (vobs.size() == 0) return 0; float [] size = new float[3]; vs.coords.getSqSize(into, size); p("size:"+size[0]+","+size[1]); float w = getWidth(), h = getHeight(); float y = 0, hInc = size[1]/vobs.size(), x = 0.065f * size[0]; for (int i=0; i