// Path: src/input/Event.java
// public static enum EventType {
// 	Key(1<<0),
// 	Mouse(1<<1),
// 	Custom(1<<2);
// 		
// 	private EventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }
// 
// Path: src/input/MouseEvent.java
// public static enum MouseEventType {
// 	Move	(1<<0),
// 	Enter	(1<<1),
// 	Leave	(1<<2),
// 	Press	(1<<3),
// 	Release	(1<<4),
// 	Scroll	(1<<5);
// 		
// 	public static final int ButtonMask = Press.getMask() | Release.getMask();
// 	public static final int MotionMask = Move.getMask() | Enter.getMask() | Leave.getMask();
// 	public static final int ScrollMask = Scroll.getMask();
// 		
// 	private MouseEventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }
// 
// Path: src/input/KeyEvent.java
// public static enum KeyEventType {
// 	Press	(1<<0),
// 	Release	(1<<1);
// 		
// 	public static final int ButtonMask = Press.getMask() | Release.getMask();
// 		
// 	private KeyEventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }


import java.util.ArrayList;
import java.util.Collection;
import input.*;
import input.Event.EventType;
import input.MouseEvent.MouseEventType;
import input.KeyEvent.KeyEventType;
import util.*;
package gui;



public class Widget {
	//public final static int NUM_LAYERS = 10;
	
	protected void onRender(RenderTarget t) {}
	protected void onLayout() {}
	
	protected final void internalOnEvent(Event e) {
		//not visible, break off
		if (!mVisible) 
			return;
		
		//make up to date
		if (!mRectValid)
			internalOnLayout(false);
		
		//clear any pending child removals, event handling may remove some children
		removePendingChildren();
		
		//do children, last added is on top, so it gets a chance 
		//at the event first
		mChildLock = true;
		for (int i = mChildren.size()-1; i >= 0; --i) {
			mChildren.get(i).internalOnEvent(e);
			if (e.consumed())
				return;
		}
		mChildLock = false;
		
		//if mouse is over, handle event
		if (contains(e.getInput().getMousePos())) {
			//active? consume the event
			if (mActive)
				e.consume();
			
			//set the input's MouseTarget to this
			e.getInput().setMouseTarget(this);
			
			//dispatch
// Path: src/input/Event.java
// public static enum EventType {
// 	Key(1<<0),
// 	Mouse(1<<1),
// 	Custom(1<<2);
// 		
// 	private EventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }
// 
// Path: src/input/MouseEvent.java
// public static enum MouseEventType {
// 	Move	(1<<0),
// 	Enter	(1<<1),
// 	Leave	(1<<2),
// 	Press	(1<<3),
// 	Release	(1<<4),
// 	Scroll	(1<<5);
// 		
// 	public static final int ButtonMask = Press.getMask() | Release.getMask();
// 	public static final int MotionMask = Move.getMask() | Enter.getMask() | Leave.getMask();
// 	public static final int ScrollMask = Scroll.getMask();
// 		
// 	private MouseEventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }
// 
// Path: src/input/KeyEvent.java
// public static enum KeyEventType {
// 	Press	(1<<0),
// 	Release	(1<<1);
// 		
// 	public static final int ButtonMask = Press.getMask() | Release.getMask();
// 		
// 	private KeyEventType(int mask) {
// 		mMask = mask;
// 	}
// 		
// 	public int getMask() {
// 		return mMask;
// 	}
// 		
// 	private int mMask;
// }


// Path: src/gui/Widget.java
import java.util.ArrayList;
import java.util.Collection;
import input.*;
import input.Event.EventType;
import input.MouseEvent.MouseEventType;
import input.KeyEvent.KeyEventType;
import util.*;

package gui;



public class Widget {
	//public final static int NUM_LAYERS = 10;
	
	protected void onRender(RenderTarget t) {}
	protected void onLayout() {}
	
	protected final void internalOnEvent(Event e) {
		//not visible, break off
		if (!mVisible) 
			return;
		
		//make up to date
		if (!mRectValid)
			internalOnLayout(false);
		
		//clear any pending child removals, event handling may remove some children
		removePendingChildren();
		
		//do children, last added is on top, so it gets a chance 
		//at the event first
		mChildLock = true;
		for (int i = mChildren.size()-1; i >= 0; --i) {
			mChildren.get(i).internalOnEvent(e);
			if (e.consumed())
				return;
		}
		mChildLock = false;
		
		//if mouse is over, handle event
		if (contains(e.getInput().getMousePos())) {
			//active? consume the event
			if (mActive)
				e.consume();
			
			//set the input's MouseTarget to this
			e.getInput().setMouseTarget(this);
			
			//dispatch
			if (e.getEventType() == EventType.Mouse) {