#! /usr/bin/env python
#
#    <one line to give the program's name and a brief idea of what it does.>
#    Copyright (C) 2001  Michael Urman
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU 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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

"""
gmtest.py

Test gamemenu as an import item.
"""

import pygame
from pygame import *
import gamemenu

# i want shadowed text :)  - forget caching though in this example.
class ShadowText(gamemenu.Text):
    def render_str(self, str):
        font = pygame.font.Font(None, 36)
        magenta = font.render(str, 1, (255, 80, 230))
        dkblue = font.render(str, 1, (20, 20, 80))
        w, h = magenta.get_size()
        image = pygame.Surface((w+3, h+3), magenta.get_flags(), magenta)
        for i in (3,2,1):
            image.blit(dkblue, (i,i))
        image.blit(magenta, (0,0))
        image_sel = self.hilight(image)
        image_dis = self.desaturate(image)
        self.images = (image, image_sel, image_dis)

pygame.display.init()
pygame.font.init()
screen = pygame.display.set_mode((640,480))
screen.fill((127,127,127))
pygame.display.update()

menu = gamemenu.CircleTextMenu()
menu.set_radius((100,100))
for id, text, desc in (
    ('python', 'Python', 'Wonderful Programming Language'),
    ('pygame', 'Pygame', 'Wonderful game writing library'),
    ('pete', 'ShredWheat', 'THE MACHINE')):
    menu.add_item(id, text=ShadowText(text), desc=desc)

for i in range(3):
    sel = menu.run((320,240), screen)
    menu.set_items_enable(0, sel)