Update of /cvsroot/freevo/freevo/WIP/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18829/gui

Added Files:
        ZIndexRenderer.py debug.py listboxdemo.py optiondemo.py 
        scrolldemo.py 
Log Message:
Moved unneeded gui stuff to this dir


--- NEW FILE: ZIndexRenderer.py ---
#!/usr/bin/env python
#-----------------------------------------------------------------------
# ZIndexRenderer - A class for handling layers of stuff.
#-----------------------------------------------------------------------
# $Id: ZIndexRenderer.py,v 1.1 2004/02/18 21:56:50 dischi Exp $
#
#-----------------------------------------------------------------------
# $Log: ZIndexRenderer.py,v $
# Revision 1.1  2004/02/18 21:56:50  dischi
# Moved unneeded gui stuff to this dir
#
# Revision 1.11  2003/10/14 17:46:54  dischi
# fix crash on DEBUG>1
#
# Revision 1.10  2003/10/12 10:56:19  dischi
# change debug to use _debug_ and set level to 2
#
# Revision 1.9  2003/07/12 10:11:34  dischi
# load osd only when needed
#
#-----------------------------------------------------------------------
#
# Freevo - A Home Theater PC framework
#
# Copyright (C) 2002 Krister Lagerstrom, et al.
#
# 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 MER-
# CHANTABILITY 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
#
# ----------------------------------------------------------------------

import config
import osd
import pygame


_singleton = None

def get_singleton():
    """
    Singleton is a good way to keep an object consistant over several
    instances..
    """
    global _singleton
    if _singleton == None:
        _singleton = ZIndexRenderer()

    return _singleton


class ZIndexRenderer:
    """
    Keeps track of what is on top of under what.

    A simple render class updating the erasearea information of all GUI
    objects visible on screen. Handling screen updates on erase and
    draw.

    This should give you GUI objects you can freely move around under
    or over other objects on screen. We probably won't use very
    complicated screens so often, but this should handle it.

    Notes: I'd really like thoughts on this. I'm thinking about
           inheriting a render class from pygame.sprite, but I can't
           find a real good use for it yet.
    Todo:  Need to optimize the update functions. Only update rectangles
           which have coordinates inside the changing rectangle, only save
           the needed part of the the background.
           Implement 'raise' and 'lower' when I need them.
    """
    
    def __init__(self):
        """
        Don't know what to do with constructor yet, but I'm sure I want it.
        """
        self.zindex = []

    def get_zindex(self):
        """
        Return a reference to the zindex.
        """
        return self.zindex

    def add_object(self, object):
        """
        Appends a reference to object to the zindex list.
        All objects are put 'on top of each other' in the order they
        are instanticed.
 
        Arguments: object - the object to add
        Returns:   index  - the index no in the stack.
        Note:      Should objects themselves be alowed to raise or lower
                   themselves in the stack?
        """ 
        self.zindex.append(object)
        return self.zindex.index(object)
 
    def del_object(self, object):
        """
        Really delete object from stack.

        Arguments: object to delete.
        Notes:     Maybe rename to kill.
        """
        self.zindex.remove(object)


    def update_hide(self, object):
        """
        Updates all affected objects when there is a hide.
        
        Notify objects above the calling object to do a redraw.
        Does anyone have a better idea for a name for this function?
        """

        return
    
        # oi = self.zindex.index(object)
        # if not len(self.zindex) > (oi+1):
        #     return

        # ol   = self.zindex[(oi+1):]
        # t_bg = object.bg_image.convert()
        # for o in ol:
        #     if o.is_visible():
        #         if o.border:
        #             # Erase a little bigger area when we have borders.
        #             x,y,w,h = o.border.get_erase_rect()
        #         else:
        #             x,y,w,h = o.get_rect()
                    
        #         o.bg_image.blit(t_bg, (x,y), (x,y,w,h))
        #         o._erase()

        # for o in ol:
        #     if o.is_visible():
        #         o.bg_image = osd.screen.convert()
        #         o._draw()

        for o in self.zindex:
            if o == object:
                if o.bg_surface:
                    # osd.putsurface(o.bg_surface, o.left, o.top)
                    # osd.update()
                    if config.DEBUG > 1:
                        o.bg_image = o.bg_surface.convert()
                        iname = '/tmp/last-hide.bmp' 
                        pygame.image.save( o.bg_image, iname )
                        iname = '/tmp/last-screen.bmp' 
                        pygame.image.save( osd.get_singleton().screen.convert(), iname 
)


    def update_show(self, object):        
        """
        Updates all affected objects when there is a show.
        
        Notify objects above the calling object to do a redraw.
        Does anyone have a better idea for a name for this function?
        """

        # oi = self.zindex.index(object) 
        # ol = self.zindex[(oi):]

        # object.bg_surface = osd.getsurface(object.left, object.top, 
        #                                    object.width, object.height)
        # object.bg_image = object.bg_surface.convert()

        # if object.bg_image: t_bg = object.bg_image.convert()
        # xx = 0
        # for o in ol:
        #     if not o == object and o.is_visible():
        #         if o.border:
        #             x,y,w,h = o.border.get_erase_rect()
        #         else:
        #             x,y,w,h = o.get_rect()
 
        #         if t_bg: o.bg_image.blit( t_bg, (x,y), (x,y,w,h))
        #         o._erase() 

        xx = 0
        for o in self.zindex:
            if o == object:
                # o.bg_surface = osd.getsurface(o.left, o.top, 
                #                               o.width, o.height)
                # if config.DEBUG > 1:
                #     o.bg_image = o.bg_surface.convert()
                #     iname = '/tmp/bg1-%s.bmp' % xx
                #     pygame.image.save( o.bg_image, iname )
                o.draw()
            xx += 1

        # xx = 0
        # for o in ol:
        #     if o == object or o.is_visible():
        #         o.bg_image = osd.screen.convert()
        #         iname = '/tmp/bg2-%s.bmp' % xx
        #         pygame.image.save( o.bg_image, iname )
        #         xx = xx + 1
        #         o._draw()



--- NEW FILE: debug.py ---
#!/usr/bin/env python
#-----------------------------------------------------------------------
# debug
#-----------------------------------------------------------------------
# $Id: debug.py,v 1.1 2004/02/18 21:56:50 dischi Exp $
#-----------------------------------------------------------------------
#
# Freevo - A Home Theater PC framework
#
# Copyright (C) 2002 Krister Lagerstrom, et al.
#
# 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 MER-
# CHANTABILITY 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
#
# ----------------------------------------------------------------------

import time 
import pygame

from pygame.locals  import *

import util

# ======================================================================
# XXX These functions are here for debug.. I'll remove them in time.
# ======================================================================
clock = pygame.time.Clock()
def wait_loop():
    while 1:
        clock.tick(20)
        for event in pygame.event.get():
            if event.type == KEYDOWN:
                return


def save_images( pb1, pb2, pb3 ):
    if pb1.bg_image:
        pygame.image.save( pb1.bg_image, '/tmp/bp1.bmp' )
    if pb2.bg_image:
        pygame.image.save( pb2.bg_image, '/tmp/bp2.bmp' )
    if pb3.bg_image:
        pygame.image.save( pb3.bg_image, '/tmp/bp3.bmp' )

def save_image( obj ):
    if obj.bg_image:
        pygame.image.save( obj.bg_image,
                           '/tmp/'+str(obj.__class__.__name__)+'.bmp')
    elif obj.parent.bg_image:
        pygame.image.save( obj.parent.bg_image,
                           '/tmp/parent'+str(obj.__class__.__name__)+'.bmp')
        

# ======================================================================
# Main: used for testing.
# ======================================================================

if __name__ == '__main__':
    
    osd.clearscreen()
    
    osd.drawbitmap( 'share/images/aubin_bg1.png' )
    osd.drawstring('Hello Sailor' + str(time.time()), 10, 10,
                   font='share/fonts/Vera.ttf',ptsize=14)
    
    osd.update()

    pb  = util.SynchronizedObject( PopupBox(100, 100, 300, 150,
                                               'Hello again sailor',
                                               bg_color=Color((255,0,0,128)),
                                               border=Border.BORDER_FLAT,
                                               bd_width=1)
                                      )

    pb2 = util.SynchronizedObject( PopupBox(200, 150, 300, 150,
                                               'Hello twice sailor',
                                               bg_color=Color((0,255,0,128)),
                                               border=Border.BORDER_FLAT,
                                               bd_width=2)
                                      )
                                      
    pb3 = util.SynchronizedObject( PopupBox(300, 200, 300, 150,
                                               'Hello trice sailor',
                                               bg_color=Color((0,0,192,128)),
                                               border=Border.BORDER_FLAT,
                                               bd_width=3) )
    
    pb4 = util.SynchronizedObject( PopupBox(200, 200, 300, 150,
                                               'Hello trice sailor',
                                               bg_color=Color((255,128,0,128)),
                                               border=Border.BORDER_FLAT) )
    

    print "Showing first rectangle..."
    pb.show()
    save_images( pb, pb2, pb3 )
    osd.update()
                                      
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing second rectangle..."
    pb2.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing third rectangle..."
    pb3.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing fourth rectangle..."
    pb4.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Hiding second rectangle..."
    pb2.hide()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing second rectangle..."
    pb2.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Hiding first rectangle..."
    pb.hide()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing first rectangle..."
    pb.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Hiding second rectangle..."
    pb2.hide()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Showing second rectangle..."
    pb2.show()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Hiding first rectangle..."
    pb.hide()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()

    print "Hiding SECOND rectangle..."
    pb2.hide()
    save_images( pb, pb2, pb3 )
    osd.update()
    print "  Waiting at bottom of cycle..."
    wait_loop()


--- NEW FILE: listboxdemo.py ---
#if 0 /*
# -----------------------------------------------------------------------
# listboxdemo.py - lets demonstrate the listbox
# -----------------------------------------------------------------------
# $Id: listboxdemo.py,v 1.1 2004/02/18 21:56:50 dischi Exp $
#
# Notes:
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: listboxdemo.py,v $
# Revision 1.1  2004/02/18 21:56:50  dischi
# Moved unneeded gui stuff to this dir
#
# Revision 1.12  2003/10/12 10:56:19  dischi
# change debug to use _debug_ and set level to 2
#
# Revision 1.11  2003/07/13 19:28:58  rshortt
# Bugfix.
#
# Revision 1.10  2003/05/27 17:53:34  dischi
# Added new event handler module
#
# Revision 1.9  2003/05/21 00:02:47  rshortt
# Updates for changes elsewhere.
#
# Revision 1.8  2003/05/15 02:21:54  rshortt
# got RegionScroller, ListBox, ListItem, OptionBox working again, although
# they suffer from the same label alignment bouncing bug as everything else
#
# Revision 1.7  2003/04/24 19:56:29  dischi
# comment cleanup for 1.3.2-pre4
#
# Revision 1.6  2003/04/20 13:02:30  dischi
# make the rc changes here, too
#
# Revision 1.5  2003/03/30 15:54:07  rshortt
# Added 'parent' as a constructor argument for PopupBox and all of its
# derivatives.
#
# Revision 1.4  2003/03/09 21:37:06  rshortt
# Improved drawing.  draw() should now be called instead of _draw(). draw()
# will check to see if the object is visible as well as replace its bg_surface
# befire drawing if it is available which will make transparencies redraw
# correctly instead of having the colour darken on every draw.
#
# Revision 1.3  2003/03/05 03:53:34  rshortt
# More work hooking skin properties into the GUI objects, and also making
# better use of OOP.
#
# ListBox and others are working again, although I have a nasty bug regarding
# alpha transparencies and the new skin.
#
# Revision 1.2  2003/02/24 12:14:57  rshortt
# Removed more unneeded self.parent.refresh() calls.
#
# Revision 1.1  2003/02/23 18:24:04  rshortt
# New classes.  ListBox is a subclass of RegionScroller so that it can
# scroll though a list of ListItems which are drawn to a surface.
# Also included is a listboxdemo to demonstrate and test everything.
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# 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 MER-
# CHANTABILITY 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
#
# ----------------------------------------------------------------------- */
#endif
import config

from GUIObject      import *
from PopupBox       import *
from ListBox        import *
from ListItem       import *
from Color          import *
from Button         import *
from Border         import *
from Label          import *
from types          import *

import event as em

class listboxdemo(PopupBox):
    """
    left      x coordinate. Integer
    top       y coordinate. Integer
    width     Integer
    height    Integer
    text      String to print.
    bg_color  Background color (Color)
    fg_color  Foreground color (Color)
    icon      icon
    border    Border
    bd_color  Border color (Color)
    bd_width  Border width Integer
    """

    def __init__(self, parent=None, text=" ", left=None, top=None, width=500, 
                 height=350, bg_color=None, fg_color=None, icon=None,
                 border=None, bd_color=None, bd_width=None):

        handler = None

        PopupBox.__init__(self, parent, text, handler, left, top, width, height, 
                          bg_color, fg_color, icon, border, bd_color, bd_width)


        self.set_h_align(Align.CENTER)

        # self.label.top = self.top + 25

        self.pb = ListBox(left=25, top=75, width=450, height=250)
        for i in range(20):
            iname = "Item %s" % i
            self.pb.add_item(text=iname, value=i)

        self.pb.toggle_selected_index(0)
        self.add_child(self.pb)


    def eventhandler(self, event):

        if event in (em.INPUT_UP, em.INPUT_DOWN, em.INPUT_LEFT, em.INPUT_RIGHT ):
            return self.pb.eventhandler(event)

        elif event == em.INPUT_ENTER or event == em.INPUT_EXIT:
            self.destroy()

        else:
            return self.parent.eventhandler(event)

--- NEW FILE: optiondemo.py ---
#if 0 /*
# -----------------------------------------------------------------------
# optiondemo.py - lets demonstrate the option box
# -----------------------------------------------------------------------
# $Id: optiondemo.py,v 1.1 2004/02/18 21:56:50 dischi Exp $
#
# Notes:
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: optiondemo.py,v $
# Revision 1.1  2004/02/18 21:56:50  dischi
# Moved unneeded gui stuff to this dir
#
# Revision 1.12  2003/10/12 10:56:19  dischi
# change debug to use _debug_ and set level to 2
#
# Revision 1.11  2003/07/13 19:28:58  rshortt
# Bugfix.
#
# Revision 1.10  2003/05/27 17:53:34  dischi
# Added new event handler module
#
# Revision 1.9  2003/05/21 00:02:47  rshortt
# Updates for changes elsewhere.
#
# Revision 1.8  2003/05/15 02:21:54  rshortt
# got RegionScroller, ListBox, ListItem, OptionBox working again, although
# they suffer from the same label alignment bouncing bug as everything else
#
# Revision 1.7  2003/04/24 19:56:30  dischi
# comment cleanup for 1.3.2-pre4
#
# Revision 1.6  2003/04/20 13:02:30  dischi
# make the rc changes here, too
#
# Revision 1.5  2003/03/30 15:54:07  rshortt
# Added 'parent' as a constructor argument for PopupBox and all of its
# derivatives.
#
# Revision 1.4  2003/03/09 21:37:06  rshortt
# Improved drawing.  draw() should now be called instead of _draw(). draw()
# will check to see if the object is visible as well as replace its bg_surface
# befire drawing if it is available which will make transparencies redraw
# correctly instead of having the colour darken on every draw.
#
# Revision 1.3  2003/03/05 03:53:34  rshortt
# More work hooking skin properties into the GUI objects, and also making
# better use of OOP.
#
# ListBox and others are working again, although I have a nasty bug regarding
# alpha transparencies and the new skin.
#
# Revision 1.2  2003/02/24 12:10:24  rshortt
# Fixed a bug where a popup would reapear after it was disposed of since its
# parent would redraw it before it completely left.
#
# Revision 1.1  2003/02/24 11:58:28  rshortt
# Adding OptionBox and optiondemo.  Also some minor cleaning in a few other
# objects.
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# 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 MER-
# CHANTABILITY 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
#
# ----------------------------------------------------------------------- */
#endif
import config

from GUIObject      import *
from PopupBox       import *
from OptionBox      import *
from ListItem       import *
from Color          import *
from Button         import *
from Border         import *
from Label          import *
from types          import *

import event as em

class optiondemo(PopupBox):
    """
    left      x coordinate. Integer
    top       y coordinate. Integer
    width     Integer
    height    Integer
    text      String to print.
    bg_color  Background color (Color)
    fg_color  Foreground color (Color)
    icon      icon
    border    Border
    bd_color  Border color (Color)
    bd_width  Border width Integer
    """

    def __init__(self, parent=None, text=" ", left=None, top=None, width=500, 
                 height=350, bg_color=None, fg_color=None, icon=None,
                 border=None, bd_color=None, bd_width=None):

        handler = None

        PopupBox.__init__(self, parent, text, handler, left, top, width, height, 
                          bg_color, fg_color, icon, border, bd_color, bd_width)


        # self.label.top = self.top + 25

        self.ob = OptionBox('Default')
        self.ob.set_h_align(Align.CENTER)
        self.ob.set_v_align(Align.CENTER)
      
        for i in range(20):
            iname = "Item %s" % i
            self.ob.add_item(text=iname, value=i)

        self.ob.toggle_selected_index(0)
        self.ob.toggle_selected()
        self.add_child(self.ob)
        # print 'CP: %s,%s' % self.ob.calc_position()
        # self.ob.set_position(self.ob.calc_position())
        # self.ob.set_position(371, 275)


    def eventhandler(self, event):

        if event in (em.INPUT_UP, em.INPUT_DOWN, em.INPUT_LEFT, em.INPUT_RIGHT ):
            self.ob.change_item(event)
            self.draw()

        elif event == em.INPUT_ENTER:
            if self.ob.selected or self.ob.list.is_visible():
                print '  Want to toggle_box'
                self.ob.toggle_box()
                self.draw()

        elif event == em.INPUT_EXIT:
            self.destroy()

        else:
            return self.parent.eventhandler(event)

        self.osd.update(self.get_rect())



--- NEW FILE: scrolldemo.py ---
#if 0 /*
# -----------------------------------------------------------------------
# scrolldemo.py - lets demonstrate scrolling capabilities
# -----------------------------------------------------------------------
# $Id: scrolldemo.py,v 1.1 2004/02/18 21:56:50 dischi Exp $
#
# Notes:
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: scrolldemo.py,v $
# Revision 1.1  2004/02/18 21:56:50  dischi
# Moved unneeded gui stuff to this dir
#
# Revision 1.11  2003/10/12 10:56:19  dischi
# change debug to use _debug_ and set level to 2
#
# Revision 1.10  2003/05/27 17:53:34  dischi
# Added new event handler module
#
# Revision 1.9  2003/05/21 00:02:47  rshortt
# Updates for changes elsewhere.
#
# Revision 1.8  2003/05/02 01:09:03  rshortt
# Changes in the way these objects draw.  They all maintain a self.surface
# which they then blit onto their parent or in some cases the screen.  Label
# should also wrap text semi decently now.
#
# Revision 1.7  2003/04/24 19:56:31  dischi
# comment cleanup for 1.3.2-pre4
#
# Revision 1.6  2003/04/20 13:02:30  dischi
# make the rc changes here, too
#
# Revision 1.5  2003/03/30 15:54:07  rshortt
# Added 'parent' as a constructor argument for PopupBox and all of its
# derivatives.
#
# Revision 1.4  2003/03/09 21:37:06  rshortt
# Improved drawing.  draw() should now be called instead of _draw(). draw()
# will check to see if the object is visible as well as replace its bg_surface
# befire drawing if it is available which will make transparencies redraw
# correctly instead of having the colour darken on every draw.
#
# Revision 1.3  2003/03/05 03:53:34  rshortt
# More work hooking skin properties into the GUI objects, and also making
# better use of OOP.
#
# ListBox and others are working again, although I have a nasty bug regarding
# alpha transparencies and the new skin.
#
# Revision 1.2  2003/02/24 12:14:57  rshortt
# Removed more unneeded self.parent.refresh() calls.
#
# Revision 1.1  2003/02/19 00:58:18  rshortt
# Added scrolldemo.py for a better demonstration.  Use my audioitem.py
# to test.
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# 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 MER-
# CHANTABILITY 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
#
# ----------------------------------------------------------------------- */
#endif
import config

from GUIObject      import *
from PopupBox       import *
from RegionScroller import *
from Color          import *
from Button         import *
from Border         import *
from Label          import *
from types          import *

import event as em


class scrolldemo(PopupBox):
    """
    left      x coordinate. Integer
    top       y coordinate. Integer
    width     Integer
    height    Integer
    text      String to print.
    bg_color  Background color (Color)
    fg_color  Foreground color (Color)
    icon      icon
    border    Border
    bd_color  Border color (Color)
    bd_width  Border width Integer
    """

    def __init__(self, parent='osd', text=' ', left=None, top=None, width=500, 
                 height=350, bg_color=None, fg_color=None, icon=None,
                 border=None, bd_color=None, bd_width=None):

        handler = None

        PopupBox.__init__(self, parent, text, handler, left, top, width, height, 
                          bg_color, fg_color, icon, border, bd_color, bd_width)


        self.set_h_align(Align.CENTER)

        surf = self.osd.getsurface(0, 0, 700, 500)
        self.pb = RegionScroller(surf, 50,50, width=450, height=250)
        self.add_child(self.pb)


    def eventhandler(self, event):

        if event in (em.INPUT_UP, em.INPUT_DOWN, em.INPUT_LEFT, em.INPUT_RIGHT ):
           return self.pb.eventhandler(event)

        elif event == em.INPUT_ENTER or event == em.INPUT_EXIT:
            self.destroy()

        else:
            return self.parent.eventhandler(event)





-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to