|
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 /** |
|
18 * |
|
19 */ |
|
20 package com.nokia.microedition.media.animation; |
|
21 |
|
22 import org.eclipse.ercp.swt.mobile.MobileShell; |
|
23 import org.eclipse.swt.SWT; |
|
24 import org.eclipse.swt.events.ControlListener; |
|
25 import org.eclipse.swt.events.FocusListener; |
|
26 import org.eclipse.swt.events.KeyListener; |
|
27 import org.eclipse.swt.events.MouseListener; |
|
28 import org.eclipse.swt.events.MouseMoveListener; |
|
29 import org.eclipse.swt.events.PaintListener; |
|
30 import org.eclipse.swt.events.TraverseListener; |
|
31 import org.eclipse.swt.graphics.Color; |
|
32 import org.eclipse.swt.graphics.Font; |
|
33 import org.eclipse.swt.graphics.Point; |
|
34 import org.eclipse.swt.graphics.Rectangle; |
|
35 import org.eclipse.swt.widgets.Composite; |
|
36 import org.eclipse.swt.widgets.Control; |
|
37 import org.eclipse.swt.widgets.Display; |
|
38 import org.eclipse.swt.widgets.Menu; |
|
39 import org.eclipse.swt.widgets.Shell; |
|
40 |
|
41 /** |
|
42 * This class will act like a proxy Control |
|
43 * @author d35kumar |
|
44 */ |
|
45 class ProxyControl extends Control { |
|
46 |
|
47 /** |
|
48 * this will be actual Shell, for which this class is acting like proxy |
|
49 */ |
|
50 Control iControl; |
|
51 |
|
52 public ProxyControl() { |
|
53 super(Display.getDefault().getActiveShell(), SWT.BORDER); |
|
54 } |
|
55 |
|
56 /** |
|
57 * Actual Control will be created here |
|
58 */ |
|
59 public boolean setParent(Composite parent){ |
|
60 iControl= new Shell((Shell)parent); |
|
61 return true; |
|
62 } |
|
63 |
|
64 /** |
|
65 * |
|
66 */ |
|
67 public void addControlListener(ControlListener aListener){ |
|
68 if(iControl!=null){ |
|
69 iControl.addControlListener(aListener); |
|
70 } |
|
71 } |
|
72 /** |
|
73 * |
|
74 */ |
|
75 public void addFocusListener(FocusListener listener){ |
|
76 if(iControl!=null)iControl.addFocusListener(listener); |
|
77 } |
|
78 /** |
|
79 * |
|
80 */ |
|
81 public void addKeyListener(KeyListener listener){ |
|
82 if(iControl!=null)iControl.addKeyListener(listener); |
|
83 } |
|
84 public void addMouseListener(MouseListener listener){ |
|
85 if(iControl!=null)iControl.addMouseListener(listener); |
|
86 } |
|
87 public void addMouseMoveListener(MouseMoveListener listener){ |
|
88 if(iControl!=null)iControl.addMouseMoveListener(listener); |
|
89 } |
|
90 /** |
|
91 * |
|
92 */ |
|
93 public void addPaintListener(PaintListener aListener){ |
|
94 if(iControl!=null)iControl.addPaintListener(aListener); |
|
95 |
|
96 } |
|
97 |
|
98 public void addTraverseListener(TraverseListener listener){ |
|
99 if(iControl!=null)iControl.addTraverseListener(listener); |
|
100 } |
|
101 public Point computeSize(int wHint, |
|
102 int hHint){ |
|
103 Point point=null; |
|
104 if(iControl!=null)point=iControl.computeSize(wHint, hHint); |
|
105 System.out.println("ProxyControl::computeSize()"+point); |
|
106 return point; |
|
107 } |
|
108 |
|
109 public Point computeSize(int wHint, |
|
110 int hHint, |
|
111 boolean changed){ |
|
112 Point point=null; |
|
113 if(iControl!=null)point=iControl.computeSize(wHint, hHint,changed); |
|
114 System.out.println("ProxyControl::computeSize()"+point+"Bolean changed "+changed); |
|
115 return point; |
|
116 } |
|
117 |
|
118 public Color getBackground(){ |
|
119 Color color=null; |
|
120 if(iControl!=null)color=iControl.getBackground(); |
|
121 System.out.println("ProxyControl::getBackground()"); |
|
122 return color; |
|
123 } |
|
124 public int getBorderWidth(){ |
|
125 if(iControl!=null)return iControl.getBorderWidth(); |
|
126 else return 0; |
|
127 } |
|
128 public Rectangle getBounds(){ |
|
129 if(iControl!=null) return iControl.getBounds(); |
|
130 else return null; |
|
131 } |
|
132 public boolean getEnabled(){ |
|
133 if(iControl!=null) return iControl.getEnabled(); |
|
134 else return false; |
|
135 } |
|
136 public Font getFont(){ |
|
137 if(iControl!=null)return iControl.getFont(); |
|
138 else return null; |
|
139 } |
|
140 public Color getForeground(){ |
|
141 if(iControl!=null) return iControl.getForeground(); |
|
142 else return null; |
|
143 } |
|
144 |
|
145 public java.lang.Object getLayoutData(){ |
|
146 if(iControl!=null) return iControl.getLayoutData(); |
|
147 else return null; |
|
148 } |
|
149 |
|
150 public Point getLocation(){ |
|
151 if(iControl!=null) return iControl.getLocation(); |
|
152 else return null; |
|
153 } |
|
154 |
|
155 public Menu getMenu(){ |
|
156 if(iControl!=null) return iControl.getMenu(); |
|
157 else return null; |
|
158 } |
|
159 public Composite getParent(){ |
|
160 if(iControl!=null) return iControl.getParent(); |
|
161 else return null; |
|
162 } |
|
163 public Shell getShell(){ |
|
164 if(iControl!=null) return iControl.getShell(); |
|
165 else return null; |
|
166 } |
|
167 public Point getSize(){ |
|
168 if(iControl!=null) return iControl.getSize(); |
|
169 else return null; |
|
170 } |
|
171 |
|
172 public java.lang.String getToolTipText(){ |
|
173 if(iControl!=null) return iControl.getToolTipText(); |
|
174 else return null; |
|
175 } |
|
176 public boolean getVisible(){ |
|
177 if(iControl!=null) return iControl.getVisible(); |
|
178 else return false; |
|
179 } |
|
180 public boolean isEnabled(){ |
|
181 if(iControl!=null) return iControl.isEnabled(); |
|
182 else return false; |
|
183 } |
|
184 |
|
185 public boolean isFocusControl(){ |
|
186 if(iControl!=null) return iControl.isFocusControl(); |
|
187 else return false; |
|
188 } |
|
189 public boolean isReparentable(){ |
|
190 if(iControl!=null) return iControl.isReparentable(); |
|
191 else return false; |
|
192 } |
|
193 |
|
194 public boolean isVisible(){ |
|
195 if(iControl!=null)return iControl.isVisible(); |
|
196 else return false; |
|
197 } |
|
198 public void moveAbove(Control control){ |
|
199 if(iControl!=null) iControl.moveAbove(control); |
|
200 } |
|
201 public void moveBelow(Control control){ |
|
202 if(iControl!=null) iControl.moveBelow(control); |
|
203 } |
|
204 public void pack(){ |
|
205 if(iControl!=null) iControl.pack(); |
|
206 } |
|
207 public void pack(boolean changed){ |
|
208 if(iControl!=null) iControl.pack(changed); |
|
209 } |
|
210 public void redraw(){ |
|
211 if(iControl!=null) iControl.redraw(); |
|
212 } |
|
213 public void redraw(int x, |
|
214 int y, |
|
215 int width, |
|
216 int height, |
|
217 boolean all){ |
|
218 if(iControl!=null) iControl.redraw(x,y,width,height, all); |
|
219 } |
|
220 public void removeControlListener(ControlListener listener){ |
|
221 if(iControl!=null) iControl.removeControlListener(listener); |
|
222 } |
|
223 public void removeFocusListener(FocusListener listener){ |
|
224 if(iControl!=null) iControl.removeFocusListener(listener); |
|
225 } |
|
226 public void removeMouseListener(MouseListener listener){ |
|
227 if(iControl!=null) iControl.removeMouseListener(listener); |
|
228 } |
|
229 public void removeMouseMoveListener(MouseMoveListener listener){ |
|
230 if(iControl!=null) iControl.removeMouseMoveListener(listener); |
|
231 } |
|
232 public void removePaintListener(PaintListener listener){ |
|
233 if(iControl!=null)iControl.removePaintListener(listener); |
|
234 } |
|
235 public void removeTraverseListener(TraverseListener listener){ |
|
236 if(iControl!=null)iControl.removeTraverseListener(listener); |
|
237 } |
|
238 public void setBounds(int x, |
|
239 int y, |
|
240 int width, |
|
241 int height){ |
|
242 if(iControl!=null)iControl.setBounds(x, y, width, height); |
|
243 } |
|
244 public void setBounds(Rectangle rect){ |
|
245 if(iControl!=null)iControl.setBounds(rect); |
|
246 } |
|
247 public void setCapture(boolean capture){ |
|
248 if(iControl!=null)iControl.setCapture(capture); |
|
249 } |
|
250 public void setEnabled(boolean enabled){ |
|
251 if(iControl!=null)iControl.setEnabled(enabled); |
|
252 } |
|
253 public boolean setFocus(){ |
|
254 if(iControl!=null) return iControl.setFocus(); |
|
255 else return false; |
|
256 } |
|
257 public void setFont(Font font){ |
|
258 if(iControl!=null)iControl.setFont(font); |
|
259 } |
|
260 public void setForeground(Color color){ |
|
261 if(iControl!=null)iControl.setForeground(color); |
|
262 } |
|
263 public void setLayoutData(java.lang.Object layoutData){ |
|
264 if(iControl!=null)iControl.setLayoutData(layoutData); |
|
265 } |
|
266 public void setLocation(int x, |
|
267 int y){ |
|
268 if(iControl!=null)iControl.setLocation(x, y); |
|
269 } |
|
270 |
|
271 public void setLocation(Point location){ |
|
272 if(iControl!=null)iControl.setLocation(location); |
|
273 } |
|
274 public void setMenu(Menu menu){ |
|
275 if(iControl!=null)iControl.setMenu(menu); |
|
276 } |
|
277 public void setRedraw(boolean redraw){ |
|
278 if(iControl!=null)iControl.setRedraw(redraw); |
|
279 } |
|
280 public void setSize(int width, |
|
281 int height){ |
|
282 if(iControl!=null) iControl.setSize(width, height); |
|
283 } |
|
284 |
|
285 public void setSize(Point size){ |
|
286 if(iControl!=null) iControl.setSize(size); |
|
287 } |
|
288 public void setToolTipText(java.lang.String string){ |
|
289 if(iControl!=null)iControl.setToolTipText(string); |
|
290 } |
|
291 public void setVisible(boolean visible){ |
|
292 if(iControl!=null)iControl.setVisible(visible); |
|
293 } |
|
294 public Point toControl(int x, |
|
295 int y){ |
|
296 if(iControl!=null)return iControl.toControl(x, y); |
|
297 else return null; |
|
298 } |
|
299 public Point toControl(Point point){ |
|
300 if(iControl!=null) return iControl.toControl(point); |
|
301 else return null; |
|
302 } |
|
303 public Point toDisplay(int x, |
|
304 int y){ |
|
305 if(iControl!=null)return iControl.toDisplay(x,y); |
|
306 else return null; |
|
307 } |
|
308 public Point toDisplay(Point point){ |
|
309 if(iControl!=null)return iControl.toDisplay(point); |
|
310 else return null; |
|
311 } |
|
312 public boolean traverse(int traversal){ |
|
313 if(iControl!=null)return iControl.traverse(traversal); |
|
314 else return false; |
|
315 } |
|
316 public void update(){ |
|
317 if(iControl!=null)iControl.update(); |
|
318 } |
|
319 |
|
320 public void checkSubclass() { |
|
321 // do nothing,sub-classing allowed |
|
322 } |
|
323 } |