1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
# -*- indent-tabs-mode: t -*-
""" Application style class for puddding """
import soya.pudding as pudding
__revision__ = '$Revision: 1.1 $'
import os
import soya
from soya.opengl import *
import soya.pudding.style
from soya.pudding.style import STYLE_NONE
class Style(pudding.style.Style):
""" Application style for pudding """
def __init__(self):
pudding.style.Style.__init__(self)
font_file = os.path.join( soya.DATADIR, "FreeSans.ttf")
self.default_font = soya.Font(font_file, 10, 10)
self.button_border_width = 2
self.button_background = (.4, .4, .4, .9)
def draw_button(self, width, height, background = None, border = None,
border_width = None):
glEnable(GL_BLEND)
if background != STYLE_NONE:
glColor4f( *( background or self.button_background) )
glBegin(GL_QUADS)
glVertex3f( 0, 0, 0)
glVertex3f( 0, height, 0)
glVertex3f( width, height, 0)
glVertex3f( width, 0, 0)
glEnd()
if border != STYLE_NONE and border_width != 0:
color = border or self.box_border
bwidth = border_width or self.button_border_width
glColor4f( *color )
glLineWidth( bwidth )
glColor4f(color[0] - .2, color[1] - .2, color[2] - .2, color[3])
glBegin(GL_LINES)
glVertex3f( 0, 0, 0)
glVertex3f( 0, height + bwidth, 0)
glVertex3f( 0, 0, 0)
glVertex3f( width, 0, 0)
glEnd()
glColor4f(color[0] + .2, color[1] + .2, color[2] + .2, color[3])
glBegin(GL_LINES)
glVertex3f( width, 0 , 0)
glVertex3f( width, height + bwidth, 0)
glVertex3f( 0, height , 0)
glVertex3f( width , height, 0)
glEnd()
glDisable(GL_BLEND)
|