package cnp.ew.image;

import  java.awt.*;
import java.util.*;
import	cnp.ew.misc.*;
import cnp.ew.util.*;
import cnp.ew.displayer.*;
import cnp.ew.spin.*;
import cnp.ew.misc.*;
import cnp.ew.image.*;

public class CpTestImageBuilder extends Frame {

    boolean hasOutputRects=false;
static int gifId;
    static int newId;
    static int openId;
    static int saveId;
    static int printId;
    static int previewId;
    static int findId;
    static int cutId;
    static int copyId;
    static int pasteId;
    static int undoId;
    static int insertDateId;
    static int boldId;
    static int italicId;
    static int underlineId;
    static int colorId;
    static int leftId;
    static int rightId;
    static int centerId;
    static int bulletId;
    static int boldpId;
    static int italicpId;
    static int underlinepId;
    static int leftpId;
    static int rightpId;
    static int centerpId;
    static int bulletpId;
    static int leftMarginId;
    static int firstIndentId;
    static int rightMarginId;

    static {
         gifId = CpToolkit.registerImageName("homer1.gif");
         newId = CpToolkit.registerImageName("wpnew.gif");
         openId = CpToolkit.registerImageName("wpopen.gif");
         saveId = CpToolkit.registerImageName("wpsave.gif");
         printId = CpToolkit.registerImageName("wpprint.gif");
         previewId = CpToolkit.registerImageName("wppreview.gif");
         findId = CpToolkit.registerImageName("wpfind.gif");
         cutId = CpToolkit.registerImageName("wpcut.gif");
         copyId = CpToolkit.registerImageName("wpcopy.gif");
         pasteId = CpToolkit.registerImageName("wppaste.gif");
         undoId = CpToolkit.registerImageName("wpundo.gif");
         insertDateId = CpToolkit.registerImageName("wpinsertDate.gif");
         boldId = CpToolkit.registerImageName("wpbold.gif");
         italicId = CpToolkit.registerImageName("wpitalic.gif");
         underlineId = CpToolkit.registerImageName("wpunderline.gif");
         colorId = CpToolkit.registerImageName("wpcolor.gif");
         leftId = CpToolkit.registerImageName("wpleft.gif");
         rightId = CpToolkit.registerImageName("wpright.gif");
         centerId = CpToolkit.registerImageName("wpcenter.gif");
         bulletId = CpToolkit.registerImageName("wpbullet.gif");
         boldpId = CpToolkit.registerImageName("wpboldp.gif");
         italicpId = CpToolkit.registerImageName("wpitalicp.gif");
         underlinepId = CpToolkit.registerImageName("wpunderlinep.gif");
         leftpId = CpToolkit.registerImageName("wpleftp.gif");
         rightpId = CpToolkit.registerImageName("wprightp.gif");
         centerpId = CpToolkit.registerImageName("wpcenterp.gif");
         bulletpId = CpToolkit.registerImageName("wpbulletp.gif");
         leftMarginId = CpToolkit.registerImageName("wpleftMargin.gif");
         firstIndentId = CpToolkit.registerImageName("wpfirstIndent.gif");
         rightMarginId = CpToolkit.registerImageName("wprightMargin.gif");
    }


    int [] ids = {
        gifId, newId, openId, saveId, printId, previewId, findId, cutId, copyId, pasteId, undoId,
        insertDateId, boldId, italicId, underlineId, colorId, leftId, rightId, centerId, bulletId,
        boldpId, italicpId, italicpId, underlinepId, leftpId, rightpId, centerpId,bulletpId, leftMarginId,
        firstIndentId, rightMarginId
    };


	CpTestImageBuilder () {
		super("CpTestImageBuilder");
		reshape(100, 100, 600, 300);
		show();
	}

	public void paint(Graphics g)
	{
	     Vector images = new Vector(40);
         for (int i = 0; i < ids.length; i++) {
            images.addElement(CpToolkit.getImage(ids[i]));
         }
         CpPackedImage packedImage = CpImageGetter.getDefault().createPackedImage(this, images);

         packedImage.paintImageOn(this, g);
         if (!hasOutputRects) {
            packedImage.outputRectsOn("rects.txt");
         }

    }


	public static void main (String argv[]) {
		new CpTestImageBuilder();
    }

	public boolean handleEvent (Event evt) {

		switch(evt.id) {
		case Event.WINDOW_DESTROY:
			System.exit(0);
		case Event.ACTION_EVENT:
		}
		return super.handleEvent(evt);
	}
}


