|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package javax.microedition.lcdui; |
|
18 |
|
19 import org.eclipse.swt.widgets.Control; |
|
20 import org.eclipse.swt.widgets.Widget; |
|
21 import org.eclipse.swt.graphics.Rectangle; |
|
22 import org.eclipse.swt.internal.qt.graphics.GraphicsContext; |
|
23 import org.eclipse.swt.widgets.Internal_PackageSupport; |
|
24 import org.eclipse.swt.internal.qt.graphics.WindowSurface; |
|
25 |
|
26 final class CanvasBufferSymbian extends Buffer |
|
27 { |
|
28 private Canvas host; |
|
29 private WindowSurface surface; |
|
30 |
|
31 CanvasBufferSymbian(Canvas canvas, Control ctrl) |
|
32 { |
|
33 super(); |
|
34 setControlBounds(ctrl); |
|
35 host = canvas; |
|
36 } |
|
37 |
|
38 void ensureWindowSurface() |
|
39 { |
|
40 if(surface == null) |
|
41 { |
|
42 surface = Internal_PackageSupport.getWindowsurface(host.getShell()); |
|
43 } |
|
44 } |
|
45 |
|
46 void beginPaint(int x, int y, int w, int h) { |
|
47 ensureWindowSurface(); |
|
48 Rectangle rect = toWindowCoordinates(x, y, w, h); |
|
49 surface.beginPaint(rect.x, rect.y, rect.width, rect.height); |
|
50 } |
|
51 |
|
52 void endPaint() { |
|
53 surface.endPaint(); |
|
54 } |
|
55 |
|
56 void blit(GraphicsContext gc, Widget widget) |
|
57 { |
|
58 if( surface != null ) |
|
59 { |
|
60 surface.flush(); |
|
61 } |
|
62 } |
|
63 |
|
64 int getHostType() |
|
65 { |
|
66 return HOST_TYPE_CANVAS; |
|
67 } |
|
68 |
|
69 Object getHost() |
|
70 { |
|
71 return host; |
|
72 } |
|
73 |
|
74 void bindToHost(GraphicsContext gc) |
|
75 { |
|
76 gc.bindTarget(surface); |
|
77 } |
|
78 |
|
79 boolean isPaintingActive() { |
|
80 return false; |
|
81 } |
|
82 |
|
83 WindowSurface getWindowSurface() |
|
84 { |
|
85 return surface; |
|
86 } |
|
87 } |