import pygame

class Element:
	def __init__(self, width, height, position, bgcolor = (255,255,255,0)):
		self.surface = pygame.Surface((width, height), pygame.SRCALPHA).convert_alpha()
		self.width = width
		self.height = height
		self.on_click = None
		self.position = position
		self.x, self.y = position
		self.bgcolor = bgcolor

		self.init()

	def init(self): # Override this
		pass

	def getSurface(self):
		return self.surface

	def getPosition(self):
		return self.position

	def getSize(self):
		return (self.width, self.height)

	def setOnClick(self, func, args = None):
		if not args: args = []
		self.on_click = (func, args)

	def onClick(self):
		if not self.on_click: return False

		func, args = self.on_click
		func(*args)
		return True

