/* RectBgVob.java * * Copyright (c) 1999-2002, Ted Nelson and Tuomas Lukka * * You may use and distribute under the terms of either the GNU Lesser * General Public License, either version 2 of the license or, * at your choice, any later version. Alternatively, you may use and * distribute under the terms of the XPL. * * See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of * the licenses. * * This software 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 README * file for more details. * */ /* * Written by Tuomas Lukka and Tero Mäyränen */ package gzz.vob.vobs; import gzz.vob.*; import gzz.*; import gzz.util.*; import gzz.errors.*; import gzz.vob.*; import gzz.client.*; import gzz.gfx.gl.*; import java.awt.*; import java.awt.event.*; import java.util.*; import gzz.client.GraphicsAPI; /** A vob which is a rectangular background and frame. * Draws a filled (possibly with several colors) background rectangle, * surrounded by a rectangle of the current foreground color. */ public class RectBgVob extends Vob { public static final String rcsid = "$Id: RectBgVob.java,v 1.1 2002/11/02 01:23:46 benja Exp $"; public static boolean dbg = false; static final void p(String s) { if(dbg) System.out.println(s); } static final void pa(String s) { System.out.println(s); } static Rectangle rect = new Rectangle(); int nsolids = 0; Color[] solids; protected Color bg = Color.white; public void setBg(Color c){ if( c != null ) bg = c; } public Color getBg() { return bg; } boolean drawBorder = true; public void render(Graphics g, boolean fast, Vob.RenderInfo info1, Vob.RenderInfo info2) { info1.getExtRect(rect); int mx = rect.x, my=rect.y, mw = rect.width, mh = rect.height; Color oldfg = g.getColor(); // Draw a rectangle in the background color, wiping out // the already drawn stuff a little wider than we will draw. g.setColor(info1.getBgColor()); if (mh > 14) g.fillRect(mx-2, my-2, mw+4, mh+4); else g.fillRect(mx-1, my-1, mw+2, mh+2); if(nsolids == 0) { g.setColor(bg); g.fillRect(mx, my, mw, mh); } else { for(int i=0; i= 14) { g.drawRect(mx+1, my+1, mw-3, mh-3); } } g.setColor(oldfg); } Vob glList; public int addToListGL(GraphicsAPI.Window win, int[] list, int curs, int coordsys1, int coordsys2) { if(dbg) pa("Addtolistgl rectbg "+coordsys1); if(glList == null) { String bgcall = ""; if(nsolids > 0) { double w = 1.0 / nsolids; for(int i=0; i= solids.length) { Color[] n= new Color[nsolids + 10]; if(solids != null) System.arraycopy(solids, 0, n, 0, nsolids); solids = n; } solids[nsolids++] = c; return false; } /** The currently put solid colors. * null = none. There may be null references near the end * of the array. Mostly useful for checking for nullness. */ public Color[] getSolidColors() { return solids; } }