#
#		User-defined scrollable views used by test programs
#

from GUI import ScrollableView, Color, Font
from GUI.StdFonts import system_font, application_font
from GUI.StdColors import black, red, green, blue, yellow, white
from TestInput import TestKeyEvents, TestTrackMouse

class TestScrollableDrawing(ScrollableView):

    def __init__(self, **kwds):
        ScrollableView.__init__(self, **kwds)
        self.extent = (0, 0, 1000, 1000)
    
#	def mac_dump_viewport(self):
#		from Carbon.Qd import GetPort, GetRegionBounds, GetClip, NewRgn
#		print "..._mac_origin =", self._mac_origin
#		port = GetPort()
#		rgn = NewRgn()
#		port.GetPortVisibleRegion(rgn)
#		print "...port vis rgn bounds =", GetRegionBounds(rgn)
#		GetClip(rgn)
#		print "...port clip rgn bounds =", GetRegionBounds(rgn)
#		r = self.viewed_rect()
#		print "...viewed_rect =", r
    
    def blue_update_rgn(self, c):
        c.forecolor = blue
        c.fill_rect(self.viewed_rect())

    def draw(self, c, r):
        viewed_rect = self.viewed_rect()
        c.forecolor = white
        c.fill_rect(viewed_rect)
        c.forecolor = red
        x = 10
        y = 10
        for i in xrange(0, 20):
            c.newpath()
            c.moveto(x + 20, y)
            c.rlineto(20, 30)
            c.rlineto(-40, 0)
            c.closepath()
            c.fill()
            x += 40
            y += 40


class TestScrollableView(TestKeyEvents, TestTrackMouse, TestScrollableDrawing):
    pass
