/* SelectListVob.java * * Copyright (c) 2003, Matti J. Katila * This file is part of Libvob. * * Libvob is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Libvob is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with Libvob; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * */ /* * Written by Matti J. Katila */ package org.nongnu.libvob.vobs.lava; import org.nongnu.libvob.vobs.*; import org.nongnu.libvob.*; import java.awt.*; /** Immutable class to contain items in list. * This Vob is usefull for listing items. Can be used i.e., * to show a list after mouse click. * @see SelectItemVob */ public class SelectListVob extends AbstractVob { public static boolean dbg = false; private static void p(String s) { System.out.println("SelectListVob:: "+s); } private final SelectItemVob[] items; private final RectBgVob bg; public SelectListVob(SelectItemVob[] items) { this(items, new Color(.9f, .9f, 1)); } /** @param items the items in list. * @param bgColor background color of list */ public SelectListVob(SelectItemVob[] items, Color bgColor) { this.items = items; this.bg = new RectBgVob(bgColor); } public void render(Graphics g, boolean fast, RenderInfo info1, RenderInfo info2) { throw new Error("Not implemented"); } private float xRatio = 0, yRatio = 0; public int putGL(VobScene vs, int into) { vs.put(bg, into); float [] size = new float[3]; vs.coords.getSqSize(into, size); if (dbg) p("size:"+size[0]+","+size[1]); float x = 0, y = 0; xRatio = size[0]/getWidth(); yRatio = size[1]/getHeight(); for (int i=0; i= y_tmp && y < y_tmp + yRatio * items[i].getHeight()) return items[i]; y_tmp += items[i].getHeight() * yRatio; } return null; } private boolean miss(float x, float y) { if (x < 0 || x > xRatio * getWidth() || y < 0 || y > yRatio * getHeight()) { if (dbg) p("miss"); return true; } return false; } private void cleanSelects(VobScene vs) { for (int i=0; i