import PodSix
PodSix.engine = "pygame"
from PodSix.Resource import *

from PodSix.Game import Game
from PodSix.GUI.Button import *

class MyTextButton(TextButton):
	def Pressed(self):
		print "Pressed the text button"

class MyImageButton(ImageButton):
	def Pressed(self):
		print "Pressed the image button"

class MyImageRadioButton(ImageRadioButton):
	def Pressed(self):
		print "Changed the radiobutton", self.group.selected.name
		for b in self.group.objects:
			print b.down

class Core(Game, EventMonitor):
	def __init__(self):
		gfx.Caption('Test Button Input')
		gfx.SetSize([320, 240])
		gfx.LoadFont("hemihead", 0.04, "default")
		Game.__init__(self)
		EventMonitor.__init__(self)
		# text button test
		self.Add(MyTextButton("hello", {"centerx": 0.3, "centery": 0.2}, colors=[[0, 0, 0], [255, 0, 0]]))
		self.Add(MyTextButton("yes yes", {"centerx": 0.7, "centery": 0.2}, colors=[[0, 0, 0], [255, 0, 0]], toggle=True))
		# image button tests - non toggling
		self.Add(MyImageButton([Image("resources/heart.gif"), Image("resources/heart2.gif")], [gfx.width * 0.4, gfx.height * 0.5]))
		self.Add(MyImageButton([Image("resources/heart.gif"), Image("resources/heart2.gif"), Image("resources/heart3.gif")], [gfx.width * 0.6, gfx.height * 0.5]))
		# image button tests - toggling
		self.Add(MyImageButton([Image("resources/heart.gif"), Image("resources/heart2.gif")], [gfx.width * 0.4, gfx.height * 0.6], toggle=True))
		self.Add(MyImageButton([Image("resources/heart.gif"), Image("resources/heart2.gif"), Image("resources/heart3.gif")], [gfx.width * 0.6, gfx.height * 0.6], toggle=True))
		# radio buttons test
		radiogroup = ImageRadioButtonGroup()
		self.Add(radiogroup)
		MyImageRadioButton([Image("resources/heart.gif"), Image("resources/heart2.gif")], [gfx.width * 0.4, gfx.height * 0.7], "hello 1", radiogroup)
		MyImageRadioButton([Image("resources/heart.gif"), Image("resources/heart2.gif")], [gfx.width * 0.5, gfx.height * 0.7], "hello 2", radiogroup)
		MyImageRadioButton([Image("resources/heart.gif"), Image("resources/heart2.gif")], [gfx.width * 0.6, gfx.height * 0.7], "hello 3", radiogroup)
	
	def Run(self):
		gfx.SetBackgroundColor([255, 255, 255])
		Game.Run(self)
		gfx.Flip()
	
	def KeyDown_escape(self, e):
		self.Quit()
	
	def Pump(self):
                Game.Pump(self)
                EventMonitor.Pump(self)

c = Core()
c.Launch()


