/*
Class Point

WidgetBase¸¦ ±â¹ÝÀ¸·Î À§Á¬ Á¦ÀÛ°ú ½ÇÁ¦ ¾îÇÃ¸®ÄÉÀÌ¼Ç¿¡¼­ ¸¹ÀÌ ¾²´Â Å¬·¡½ºÀÔ´Ï´Ù.
Å¬·¡½ºÇïÆÛ Class Àü¿ª°´Ã¼ÀÇ ¾²ÀÓ°ú Å¬·¡½º Á¤ÀÇ¸¦ ¾î¶»°Ô ÇÏ´ÂÁö º¸¿©ÁÖ´Â °£´ÜÇÏ°í À¯¿ëÇÑ ¿¹Á¦ÀÔ´Ï´Ù. 
*/
var Point = Class.create();
Point.prototype = 
{
	x: 0,
	y: 0,
	constructorFunction: function(x, y)
	{
		this.x = x;
		this.y = y;
	},
	move: function(x,y)
	{
		this.x += x;
		this.y += y;
	}
}
/*
Class Rect

WidgetBase¸¦ ±â¹ÝÀ¸·Î À§Á¬ Á¦ÀÛ°ú ½ÇÁ¦ ¾îÇÃ¸®ÄÉÀÌ¼Ç¿¡¼­ ¸¹ÀÌ ¾²´Â Å¬·¡½ºÀÔ´Ï´Ù.
Å¬·¡½ºÇïÆÛ Class Àü¿ª°´Ã¼ÀÇ ¾²ÀÓ°ú Å¬·¡½º Á¤ÀÇ¸¦ ¾î¶»°Ô ÇÏ´ÂÁö º¸¿©ÁÖ´Â °£´ÜÇÏ°í À¯¿ëÇÑ ¿¹Á¦ÀÔ´Ï´Ù.  
*/ 
var Rect = Class.create();
Rect.prototype =
{
	left: 0,
	top: 0,
	right: 0,
	bottom: 0,
	constructorFunction: function(l, t, r, b)
	{
		this.left   = l;
		this.top    = t;
		this.right  = r;
		this.bottom = b;
	},
	width: function()
	{
		return (width = this.right - this.left + 1);
	},
	height: function()
	{
		return (this.bottom - this.top + 1);
	},
	topLeft: function()
	{
		return new Point(this.left, this.top);
	},
	topRight: function()
	{
		return new Point(this.right, this.top);
	},
	bottomLeft: function()
	{
		return new Point(this.left, this.bottom);
	},
	bottomRight: function()
	{
		return new Point(this.right, this.bottom);
	},
	inRect: function(x, y)
	{
		return ((this.left <= x && x <= this.right) && (this.top <= y && y <= this.bottom));
	},	
	ptInRect: function(pt)
	{
		var x = pt.x;
		var y = pt.y;
		
		return ((this.left <= x && x <= this.right) && (this.top <= y && y <= this.bottom));
	},
	deflateRect: function(l, t, r, b)
	{
		this.left   += l;
		this.top    += t;
		this.right  -= r;
		this.bottom -= b;
	},
	inflateRect: function(l, t, r, b)
	{
		this.left   -= l;
		this.top    -= t;
		this.right  += r;
		this.bottom += b;
	}
}
/*
Class List

WidgetBase¸¦ ±â¹ÝÀ¸·Î À§Á¬ Á¦ÀÛ°ú ½ÇÁ¦ ¾îÇÃ¸®ÄÉÀÌ¼Ç¿¡¼­ ¸¹ÀÌ ¾²´Â ÄÝ·º¼Ç Å¬·¡½ºÀÔ´Ï´Ù.
ÀÚ·á±¸Á¶ ¸®½ºÆ®¸¦ °£´ÜÈ÷ ±¸ÇöÇÑ °ÍÀÎµ¥.. ´õ º¹ÀâÇÑ ÇØ½Ã, Æ®¸®, ¸ÊµîÀÇ ±¸ÇöÀº ÀÚ¹Ù½ºÅ©¸³Æ®¿¡¼­´Â 
±×¸® ¾î·ÆÁö¾Ê°í º°·Î ÇÊ¿äµµ »ç½Ç ¾ø½À´Ï´Ù.
   
Å¬·¡½ºÇïÆÛ Class Àü¿ª°´Ã¼ÀÇ ¾²ÀÓ°ú Å¬·¡½º Á¤ÀÇ¸¦ ¾î¶»°Ô ÇÏ´ÂÁö º¸¿©ÁÖ´Â °£´ÜÇÏ°í À¯¿ëÇÑ ¿¹Á¦ÀÔ´Ï´Ù.  
*/
var List = Class.create();
List.prototype =
{
	array: null,
	
	constructorFunction: function()
	{
		this.array = new Array(0)
	},
	addTail: function(e)
	{
		var index = this.array.length;
		this.insertAt(index, e);
		return index;
	},
	addHead: function(e)
	{
		this.insertAt(0,e);
	},
	removeTail: function()
	{
		return this.removeAt(this.array.length - 1);
	},
	removeHead: function()
	{
		return this.removeAt(0);
	},
	removeAll: function()
	{
		while(0 < this.size())
		{
			this.removeTail();
		}
	},
	insertAt: function(i, e)
	{
		var before = this.array.slice(0, i);
		var after = this.array.slice(i);
		before.push(e);
		this.array = before.concat(after);
	},
	removeAt: function(i)
	{
		var before = this.array.slice(0, i+1);
		var after = this.array.slice(i+1);
		r = before.pop();
		this.array = before.concat(after);
		return r;
	},
	getAt: function(i)
	{
		if(i < 0 || this.array.length <= i)
			return null;

		return this.array[i];
	},
	setAt: function(i, o)
	{
		if(i < 0 || this.array.length <= i)
			return null;

		this.array[i] = o;
	},
	size: function()
	{
		return this.array.length;
	}
}