javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBufferSymbian.java
author hgs
Fri, 29 Oct 2010 11:49:32 +0300
changeset 87 1627c337e51e
parent 35 85266cc22c7f
permissions -rw-r--r--
v2.2.21_1

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
package javax.microedition.lcdui;

import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.qt.graphics.GraphicsContext;
import org.eclipse.swt.widgets.Internal_PackageSupport;
import org.eclipse.swt.internal.qt.graphics.WindowSurface;

final class CanvasBufferSymbian extends Buffer
{
    private Canvas host;
    private WindowSurface surface;

    CanvasBufferSymbian(Canvas canvas, Control ctrl)
    {
        super();
        setControlBounds(ctrl);
        host = canvas;
    }
    
    void ensureWindowSurface() 
    {
    	if(surface == null)
    	{
    	    surface = Internal_PackageSupport.getWindowsurface(host.getShell());
    	}
    }
    
    void beginPaint(int x, int y, int w, int h) {
		ensureWindowSurface();
		Rectangle rect = toWindowCoordinates(x, y, w, h);
		surface.beginPaint(rect.x, rect.y, rect.width, rect.height);		
	}
	
    void endPaint() {
		surface.endPaint();
	}
	
	void blit(GraphicsContext gc, Widget widget)
	{
	    if( surface != null )
	    {
    		surface.flush();
    	}
	}
	
    int getHostType()
    {
        return HOST_TYPE_CANVAS;
    }

    Object getHost()
    {
        return host;
    }

    void bindToHost(GraphicsContext gc)
    {
    	gc.bindTarget(surface);
    }

	boolean isPaintingActive() {
		return false;
	}
	
    WindowSurface getWindowSurface()
    {
        return surface;
    }
}