view enso/graphics/transparentwindow.py @ 53:f198e567f744

Enso now uses a custom version of cairo, which is located at enso.cairo. This module is just a shadow module that delegates to a platform-specific provider implementation (such as enso_osx).
author Atul Varma <varmaa@toolness.com>
date Mon, 25 Feb 2008 20:00:37 -0800
parents 835c7c35e4c4
children 9567b820b299
line wrap: on
line source

import enso.providers

_graphics = enso.providers.getInterface( "graphics" )

# Import the TransparentWindow class into our namespace.
#TransparentWindow = _graphics.TransparentWindow

from enso.graphics.measurement import pointsToPixels, pixelsToPoints
from enso.graphics.measurement import convertUserSpaceToPoints
from enso import cairo

class TransparentWindow( object ):
    def __init__( self, xPos, yPos, width, height ):
        # Convert from points to pixels
        xPos = int( pointsToPixels( xPos ) )
        yPos = int( pointsToPixels( yPos ) )
        width = max( int( pointsToPixels( width ) ), 1 )
        height = max( int( pointsToPixels( height ) ), 1 )
        
        self._impl = _graphics.TransparentWindow( xPos, yPos,
                                                  width, height )

    def makeCairoContext( self ):
        context = cairo.Context( self._impl.makeCairoSurface() )
        convertUserSpaceToPoints( context )
        return context

    def update( self ):
        return self._impl.update()

    def setOpacity( self, opacity ):
        return self._impl.setOpacity( opacity )

    def getOpacity( self ):
        return self._impl.getOpacity()

    def setPosition( self, x, y ):
        x = int( pointsToPixels( x ))
        y = int( pointsToPixels( y ))
        return self._impl.setPosition( x, y )

    def getX( self ):
        return pixelsToPoints( self._impl.getX() )

    def getY( self ):
        return pixelsToPoints( self._impl.getY() )

    def setSize( self, width, height ):
        width = max( int(pointsToPixels(width)), 1 )
        height = max( int(pointsToPixels(height)), 1 )
        return self._impl.setSize( width, height )

    def getWidth( self ):
        return pixelsToPoints( self._impl.getWidth() )

    def getHeight( self ):
        return pixelsToPoints( self._impl.getHeight() )

    def getMaxWidth( self ):
        return pixelsToPoints( self._impl.getMaxWidth() )

    def getMaxHeight( self ):
        return pixelsToPoints( self._impl.getMaxHeight() )