javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/SharedGCWrapper.java
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 04 Oct 2010 00:10:53 +0300
changeset 79 2f468c1958d0
parent 21 2a9601315dfc
permissions -rw-r--r--
Revision: v2.2.15 Kit: 201039

/*******************************************************************************
 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Nokia Corporation - initial implementation 
 *******************************************************************************/
package org.eclipse.swt.internal.qt;

import org.eclipse.swt.internal.qt.graphics.GraphicsContext;

public final class SharedGCWrapper {

    private static GraphicsContext gc;

    /**
     * Returns the shared GraphicsContext that can be used for drawing or null if
     * the shared GraphicContext is already being used and is unavailable. 
     */
    public static GraphicsContext getSharedGC() {
        if(gc == null || gc.isDisposed()) {
            gc = new GraphicsContext();
        } else if(gc.isActive()) {
            return null;
        }
        return gc;
    }
}