| 1 | /* GLightweightPeer.java -- |
| 2 | Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GNU Classpath. |
| 5 | |
| 6 | GNU Classpath is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | GNU Classpath is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the |
| 18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 19 | 02110-1301 USA. |
| 20 | |
| 21 | Linking this library statically or dynamically with other modules is |
| 22 | making a combined work based on this library. Thus, the terms and |
| 23 | conditions of the GNU General Public License cover the whole |
| 24 | combination. |
| 25 | |
| 26 | As a special exception, the copyright holders of this library give you |
| 27 | permission to link this library with independent modules to produce an |
| 28 | executable, regardless of the license terms of these independent |
| 29 | modules, and to copy and distribute the resulting executable under |
| 30 | terms of your choice, provided that you also meet, for each linked |
| 31 | independent module, the terms and conditions of the license of that |
| 32 | module. An independent module is a module which is not derived from |
| 33 | or based on this library. If you modify this library, you may extend |
| 34 | this exception to your version of the library, but you are not |
| 35 | obligated to do so. If you do not wish to do so, delete this |
| 36 | exception statement from your version. */ |
| 37 | |
| 38 | |
| 39 | package gnu.java.awt.peer; |
| 40 | |
| 41 | import java.awt.AWTEvent; |
| 42 | import java.awt.AWTException; |
| 43 | import java.awt.BufferCapabilities; |
| 44 | import java.awt.Color; |
| 45 | import java.awt.Component; |
| 46 | import java.awt.Cursor; |
| 47 | import java.awt.Dimension; |
| 48 | import java.awt.Font; |
| 49 | import java.awt.FontMetrics; |
| 50 | import java.awt.Graphics; |
| 51 | import java.awt.GraphicsConfiguration; |
| 52 | import java.awt.Image; |
| 53 | import java.awt.Insets; |
| 54 | import java.awt.Point; |
| 55 | import java.awt.Rectangle; |
| 56 | import java.awt.Toolkit; |
| 57 | import java.awt.event.PaintEvent; |
| 58 | import java.awt.image.ColorModel; |
| 59 | import java.awt.image.ImageObserver; |
| 60 | import java.awt.image.ImageProducer; |
| 61 | import java.awt.image.VolatileImage; |
| 62 | import java.awt.peer.ContainerPeer; |
| 63 | import java.awt.peer.LightweightPeer; |
| 64 | |
| 65 | /** |
| 66 | * A stub class that implements the ComponentPeer and ContainerPeer |
| 67 | * interfaces using callbacks into the Component and Container |
| 68 | * classes. GLightweightPeer allows the Component and Container |
| 69 | * classes to treat lightweight and heavyweight peers in the same way. |
| 70 | * |
| 71 | * Lightweight components are painted directly onto their parent |
| 72 | * containers through an Image object provided by the toolkit. |
| 73 | */ |
| 74 | public class GLightweightPeer |
| 75 | implements LightweightPeer, ContainerPeer |
| 76 | { |
| 77 | public GLightweightPeer() |
| 78 | { |
| 79 | // Nothing to do here. |
| 80 | } |
| 81 | |
| 82 | // -------- java.awt.peer.ContainerPeer implementation: |
| 83 | |
| 84 | public Insets insets() |
| 85 | { |
| 86 | // Nothing to do here for lightweights. |
| 87 | return null; |
| 88 | } |
| 89 | |
| 90 | public Insets getInsets() |
| 91 | { |
| 92 | // Nothing to do here for lightweights. |
| 93 | return null; |
| 94 | } |
| 95 | |
| 96 | public void beginValidate() |
| 97 | { |
| 98 | // Nothing to do here for lightweights. |
| 99 | } |
| 100 | |
| 101 | public void endValidate() |
| 102 | { |
| 103 | // Nothing to do here for lightweights. |
| 104 | } |
| 105 | |
| 106 | public void beginLayout() |
| 107 | { |
| 108 | // Nothing to do here for lightweights. |
| 109 | } |
| 110 | |
| 111 | public void endLayout() |
| 112 | { |
| 113 | // Nothing to do here for lightweights. |
| 114 | } |
| 115 | |
| 116 | public boolean isPaintPending() |
| 117 | { |
| 118 | // Nothing to do here for lightweights. |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | // -------- java.awt.peer.ComponentPeer implementation: |
| 123 | |
| 124 | public int checkImage(Image img, int width, int height, ImageObserver o) |
| 125 | { |
| 126 | // Nothing to do here for lightweights. |
| 127 | return -1; |
| 128 | } |
| 129 | |
| 130 | public Image createImage(ImageProducer prod) |
| 131 | { |
| 132 | // Nothing to do here for lightweights. |
| 133 | return null; |
| 134 | } |
| 135 | |
| 136 | /* This method is not called. */ |
| 137 | public Image createImage(int width, int height) |
| 138 | { |
| 139 | // Nothing to do here for lightweights. |
| 140 | return null; |
| 141 | } |
| 142 | |
| 143 | public void disable() |
| 144 | { |
| 145 | // Nothing to do here for lightweights. |
| 146 | } |
| 147 | |
| 148 | public void dispose() |
| 149 | { |
| 150 | // Nothing to do here for lightweights. |
| 151 | } |
| 152 | |
| 153 | public void enable() |
| 154 | { |
| 155 | // Nothing to do here for lightweights. |
| 156 | } |
| 157 | |
| 158 | public GraphicsConfiguration getGraphicsConfiguration() |
| 159 | { |
| 160 | // Nothing to do here for lightweights. |
| 161 | return null; |
| 162 | } |
| 163 | |
| 164 | public FontMetrics getFontMetrics(Font f) |
| 165 | { |
| 166 | // Nothing to do here for lightweights. |
| 167 | return null; |
| 168 | } |
| 169 | |
| 170 | /* Returning null here tells the Component object that called us to |
| 171 | * use its parent's Graphics. */ |
| 172 | public Graphics getGraphics() |
| 173 | { |
| 174 | // Nothing to do here for lightweights. |
| 175 | return null; |
| 176 | } |
| 177 | |
| 178 | public Point getLocationOnScreen() |
| 179 | { |
| 180 | // Nothing to do here for lightweights. |
| 181 | return null; |
| 182 | } |
| 183 | |
| 184 | public Dimension getMinimumSize() |
| 185 | { |
| 186 | return minimumSize(); |
| 187 | } |
| 188 | |
| 189 | public Dimension getPreferredSize() |
| 190 | { |
| 191 | return preferredSize(); |
| 192 | } |
| 193 | |
| 194 | /* Returning null here tells the Component object that called us to |
| 195 | * use its parent's Toolkit. */ |
| 196 | public Toolkit getToolkit() |
| 197 | { |
| 198 | // Nothing to do here for lightweights. |
| 199 | return null; |
| 200 | } |
| 201 | |
| 202 | public void handleEvent(AWTEvent e) |
| 203 | { |
| 204 | // Nothing to do here for lightweights. |
| 205 | } |
| 206 | |
| 207 | public void hide() |
| 208 | { |
| 209 | // Nothing to do here for lightweights. |
| 210 | } |
| 211 | |
| 212 | public boolean isFocusable() |
| 213 | { |
| 214 | // Nothing to do here for lightweights. |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | public boolean isFocusTraversable() |
| 219 | { |
| 220 | // Nothing to do here for lightweights. |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | public Dimension minimumSize() |
| 225 | { |
| 226 | return new Dimension(0, 0); |
| 227 | } |
| 228 | |
| 229 | public Dimension preferredSize() |
| 230 | { |
| 231 | return new Dimension(0, 0); |
| 232 | } |
| 233 | |
| 234 | public void paint(Graphics graphics) |
| 235 | { |
| 236 | // Nothing to do here for lightweights. |
| 237 | } |
| 238 | |
| 239 | public boolean prepareImage(Image img, int width, int height, |
| 240 | ImageObserver o) |
| 241 | { |
| 242 | // Nothing to do here for lightweights. |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | public void print(Graphics graphics) |
| 247 | { |
| 248 | // Nothing to do here for lightweights. |
| 249 | } |
| 250 | |
| 251 | public void repaint(long tm, int x, int y, int width, int height) |
| 252 | { |
| 253 | // Nothing to do here for lightweights. |
| 254 | } |
| 255 | |
| 256 | public void requestFocus() |
| 257 | { |
| 258 | // Nothing to do here for lightweights. |
| 259 | } |
| 260 | |
| 261 | public boolean requestFocus(Component source, boolean bool1, boolean bool2, |
| 262 | long x) |
| 263 | { |
| 264 | // Nothing to do here for lightweights. |
| 265 | return false; |
| 266 | } |
| 267 | |
| 268 | public void reshape(int x, int y, int width, int height) |
| 269 | { |
| 270 | // Nothing to do here for lightweights. |
| 271 | } |
| 272 | |
| 273 | public void setBackground(Color color) |
| 274 | { |
| 275 | // Nothing to do here for lightweights. |
| 276 | } |
| 277 | |
| 278 | public void setBounds(int x, int y, int width, int height) |
| 279 | { |
| 280 | // Nothing to do here for lightweights. |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Sets the cursor on the heavy-weight parent peer. |
| 285 | * Called by the MouseListener on mouse enter. |
| 286 | */ |
| 287 | public void setCursor(Cursor cursor) |
| 288 | { |
| 289 | // Nothing to do here for lightweights. |
| 290 | } |
| 291 | |
| 292 | public void setEnabled(boolean enabled) |
| 293 | { |
| 294 | // Nothing to do here for lightweights. |
| 295 | } |
| 296 | |
| 297 | public void setEventMask(long eventMask) |
| 298 | { |
| 299 | // Nothing to do here for lightweights. |
| 300 | } |
| 301 | |
| 302 | public void setFont(Font font) |
| 303 | { |
| 304 | // Nothing to do here for lightweights. |
| 305 | } |
| 306 | |
| 307 | public void setForeground(Color color) |
| 308 | { |
| 309 | // Nothing to do here for lightweights. |
| 310 | } |
| 311 | |
| 312 | public void setVisible(boolean visible) |
| 313 | { |
| 314 | // Nothing to do here for lightweights. |
| 315 | } |
| 316 | |
| 317 | public void show() |
| 318 | { |
| 319 | // Nothing to do here for lightweights. |
| 320 | } |
| 321 | |
| 322 | public ColorModel getColorModel() |
| 323 | { |
| 324 | // Nothing to do here for lightweights. |
| 325 | return null; |
| 326 | } |
| 327 | |
| 328 | public boolean isObscured() |
| 329 | { |
| 330 | // Nothing to do here for lightweights. |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | public boolean canDetermineObscurity() |
| 335 | { |
| 336 | // Nothing to do here for lightweights. |
| 337 | return false; |
| 338 | } |
| 339 | |
| 340 | public void coalescePaintEvent(PaintEvent e) |
| 341 | { |
| 342 | // Nothing to do here for lightweights. |
| 343 | } |
| 344 | |
| 345 | public void updateCursorImmediately() |
| 346 | { |
| 347 | // Nothing to do here for lightweights. |
| 348 | } |
| 349 | |
| 350 | public VolatileImage createVolatileImage(int width, int height) |
| 351 | { |
| 352 | // Nothing to do here for lightweights. |
| 353 | return null; |
| 354 | } |
| 355 | |
| 356 | public boolean handlesWheelScrolling() |
| 357 | { |
| 358 | // Nothing to do here for lightweights. |
| 359 | return false; |
| 360 | } |
| 361 | |
| 362 | public void createBuffers(int x, BufferCapabilities capabilities) |
| 363 | throws AWTException |
| 364 | { |
| 365 | // Nothing to do here for lightweights. |
| 366 | } |
| 367 | |
| 368 | public Image getBackBuffer() |
| 369 | { |
| 370 | // Nothing to do here for lightweights. |
| 371 | return null; |
| 372 | } |
| 373 | |
| 374 | public void flip(BufferCapabilities.FlipContents contents) |
| 375 | { |
| 376 | // Nothing to do here for lightweights. |
| 377 | } |
| 378 | |
| 379 | public void destroyBuffers() |
| 380 | { |
| 381 | // Nothing to do here for lightweights. |
| 382 | } |
| 383 | |
| 384 | public boolean isRestackSupported() |
| 385 | { |
| 386 | // Nothing to do here for lightweights. |
| 387 | return false; |
| 388 | } |
| 389 | |
| 390 | public void cancelPendingPaint(int x, int y, int width, int height) |
| 391 | { |
| 392 | // Nothing to do here for lightweights. |
| 393 | } |
| 394 | |
| 395 | public void restack() |
| 396 | { |
| 397 | // Nothing to do here for lightweights. |
| 398 | } |
| 399 | |
| 400 | public Rectangle getBounds() |
| 401 | { |
| 402 | // Nothing to do here for lightweights. |
| 403 | return null; |
| 404 | } |
| 405 | |
| 406 | public void reparent(ContainerPeer parent) |
| 407 | { |
| 408 | // Nothing to do here for lightweights. |
| 409 | } |
| 410 | |
| 411 | public void setBounds(int x, int y, int z, int width, int height) |
| 412 | { |
| 413 | // Nothing to do here for lightweights. |
| 414 | } |
| 415 | |
| 416 | public boolean isReparentSupported() |
| 417 | { |
| 418 | // Nothing to do here for lightweights. |
| 419 | return true; |
| 420 | } |
| 421 | |
| 422 | public void layout() |
| 423 | { |
| 424 | // Nothing to do here for lightweights. |
| 425 | } |
| 426 | } |