#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-

# Description: Abacum, programming language
# Copyright (C) 2007 by Rafael Treviño Menéndez
# Author: Rafael Treviño Menéndez <skasi.7@gmail.com>

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import pygame

pos = None
size = None
background = None
final = None

SQUARE_SIZE = 50

def createBackground ():
	global background
	background = pygame.Surface (size)
	for x in xrange (15, size[0], SQUARE_SIZE):
		for y in xrange (25, size[1], SQUARE_SIZE):
			pygame.draw.line (background, (100, 100, 100), (x, y), (x + 20, y))
	for x in xrange (25, size[0], SQUARE_SIZE):
		for y in xrange (15, size[1], SQUARE_SIZE):
			pygame.draw.line (background, (100, 100, 100), (x, y), (x, y + 20))

testSurface = None

def createTestSurface ():
	global testSurface
	testSurface = pygame.Surface ((40, 40))
	testSurface.fill ((0, 200, 200))

def init (left, top, width, height):
	global pos, size, final
	pos = left, top
	size = width, height
	createBackground ()
	createTestSurface ()

	final = pygame.Surface (size)

def mouse (events):
	if events:
		print '*** toolbar Events ***'
	for event in events:
		print event

def update ():
	final.blit (background, (0, 0))
	testSurface.set_alpha (127)
	final.blit (testSurface, (30, 30))

	return final
