Mercurial > enso_core
view enso/graphics/transparentwindow.py @ 40:835c7c35e4c4
The graphics subsystem now operates entirely in points.
author | Andrew Wilson <andrew@humanized.com> |
---|---|
date | Sun, 24 Feb 2008 17:24:55 -0600 |
parents | 5e4c680f49a3 |
children | f198e567f744 |
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 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() )