author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:10:53 +0300 | |
changeset 79 | 2f468c1958d0 |
permissions | -rw-r--r-- |
79
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/******************************************************************************* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. This program and the accompanying materials |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* which accompanies this distribution, and is available at |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* Contributors: |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Nokia Corporation - initial implementation |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
*******************************************************************************/ |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
package org.eclipse.swt.internal.extension; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
import org.eclipse.swt.graphics.Internal_GfxPackageSupport; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
import org.eclipse.swt.widgets.Internal_PackageSupport; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
import org.eclipse.swt.widgets.Control; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
import org.eclipse.swt.graphics.Rectangle; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
import org.eclipse.swt.graphics.GC; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
import org.eclipse.swt.internal.qt.graphics.WindowSurface; |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
public final class GraphicsUtil { |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
/** |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
* Ends window surface session started with startExternalRendering() -call. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
* Must be called after the rendering of external renderer has finished. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
* @param gc The gc instance where the rendering is targeted |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
*/ |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
public static void endExternalRendering(GC gc) { |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
Internal_GfxPackageSupport.endExternalRendering(gc); |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
} |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
/** |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
* Returns the WindowSurface instance that is the ultimate target of the |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
* rendering for the given gc instance. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
* @param gc The gc instance asossiated with the WindowSurface |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
* @return The WindowSurface instance that is the target of given gc instance |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
*/ |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
public static WindowSurface getWindowSurface(GC gc) { |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
return Internal_GfxPackageSupport.getWindowSurface(gc); |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
} |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
/** |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
* Start a window surface rendering session on the surface that is the |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
* target of the given gc instance. This method must be called before |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
* rendering to the window surface from external rendering APIs like m3g and m2g. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
* The caller must not render outside the area defined by the returned rectangle, |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
* as it may result in rendering on top of other controls. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
* @param gc The gc instance where the rendering is targeted |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
* @return The current clip of the gc in window surface coordinates or |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
* null if the target of given gc is not a Control |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
*/ |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
public static Rectangle startExternalRendering(GC gc) { |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
return Internal_GfxPackageSupport.startExternalRendering(gc); |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
} |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
|
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
/** |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
* Converts the given rectangle to window surface coordinates. |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
* |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
* @param c The Control instance on which coordinates the conversion is done |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
* @param rect The rectangle to be converted |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
* @return Rectangcular area in window surface coordinates |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
*/ |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
public static Rectangle toWindowSurface(Control c, Rectangle rect) { |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
return Internal_PackageSupport.toWindowSurface(c, rect); |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
} |
2f468c1958d0
Revision: v2.2.15
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
} |