// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:41:54
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/api/Button

package com.macromedia.generator.api;

import com.macromedia.generator.api.peer.ButtonPeer;

// Referenced classes of package com.macromedia.generator.api:
//            GenObject, GeneratorApiException, Rect, Action, 
//            Script, Matrix, Shape, Text

public class Button extends GenObject
{

    public Button()
        throws GeneratorApiException
    {
        peer = ButtonPeer.New();
        if(peer == 0)
            throw new GeneratorApiException("unable to create peer");
        else
            return;
    }

    protected Button(int i)
        throws GeneratorApiException
    {
        peer = i;
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        else
            return;
    }

    public Button(boolean flag)
        throws GeneratorApiException
    {
        if(flag)
            peer = ButtonPeer.New2();
        else
            peer = ButtonPeer.New();
        if(peer == 0)
            throw new GeneratorApiException("unable to create peer");
        else
            return;
    }

    public void addAction(Action action)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ButtonPeer.AddAction(peer, action.peer);
        if(i == 0)
            throw new GeneratorApiException("error adding action");
        else
            return;
    }

    public void addScript(Script script, Matrix matrix, int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = ButtonPeer.AddScript(peer, script.peer, matrix.peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error adding script");
        else
            return;
    }

    public void addShape(Shape shape, Matrix matrix, int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = 1;
        k = ButtonPeer.AddShape(peer, shape.peer, matrix.peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error adding shape");
        else
            return;
    }

    public void addText(Text text, Matrix matrix, int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = ButtonPeer.AddShape(peer, text.peer, matrix.peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error adding text");
        else
            return;
    }

    protected void finalize()
        throws Throwable
    {
        if(peer != 0)
            ButtonPeer.Release(peer);
        peer = 0;
    }

    public Rect getBounds()
        throws GeneratorApiException
    {
        int ai[] = new int[1];
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int i = ButtonPeer.GetBounds(peer, ai);
        if(i == 0)
            throw new GeneratorApiException("error getting bounds");
        else
            return new Rect(ai[0]);
    }

    public void release()
    {
        if(peer != 0)
            ButtonPeer.Release(peer);
        peer = 0;
    }

    public void setCenter(int i, int j)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int k = ButtonPeer.SetCenter(peer, i, j);
        if(k == 0)
            throw new GeneratorApiException("error setting center");
        else
            return;
    }

    public void setTracking(int i)
        throws GeneratorApiException
    {
        if(peer == 0)
            throw new GeneratorApiException("invalid peer");
        int j = ButtonPeer.SetTracking(peer, i);
        if(j == 0)
            throw new GeneratorApiException("error setting tracking");
        else
            return;
    }

    public static final int buttonStateNone = 0;
    public static final int buttonStateUp = 1;
    public static final int buttonStateOver = 2;
    public static final int buttonStateDown = 4;
    public static final int buttonStateTest = 8;
    public static final int buttonTrackAsButton = 0;
    public static final int buttonTrackAsMenu = 1;
}