source: trunk/gcc/libjava/gnu/gcj/xlib/Drawable.java

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.0 KB
Line 
1/* Copyright (C) 1999, 2000 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9package gnu.gcj.xlib;
10
11import java.awt.Rectangle;
12
13/** An X11 drawable.
14 *
15 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
16 */
17public class Drawable extends XID
18{
19 public Drawable(Display display, int xid)
20 {
21 super(display, xid);
22 }
23
24 /**
25 * Gets as much as possible of the image data within the requested
26 * region. Data from obscured parts of windows may not be
27 * retrievable.
28 *
29 * @param dest where to place the image data.
30 *
31 * @return the actual region of image data that was retrieved.
32 */
33 public Rectangle copyIntoXImage(XImage dest, Rectangle bounds,
34 int destX, int destY)
35 {
36 Rectangle newBounds = null;
37 int tries = 5;
38 while (!bounds.isEmpty())
39 {
40 if (copyIntoXImageImpl(dest, bounds.x, bounds.y,
41 bounds.width, bounds.height,
42 destX, destY))
43 return bounds;
44
45 // failed, likely due to wrong bounds...
46
47 newBounds = getBounds(newBounds);
48
49 bounds = newBounds.intersection(bounds);
50
51 tries--;
52
53 if (tries < 0)
54 throw new RuntimeException("copyIntoXImage is buggy");
55
56 }
57
58 return bounds; // always empty
59 }
60
61
62
63 /**
64 * Performs an XGetSubImage. This method will fail if the X server
65 * does not possess the requested image data. This might occur when
66 * requesting the image date of a window that is partially obscured.
67 *
68 * @param desitantionImage where to place the image data
69 *
70 * @return false if method was unable to read the requested region.
71 */
72 private native boolean copyIntoXImageImpl(XImage destinationImage,
73 int x, int y,
74 int width, int height,
75 int destX, int destY);
76
77 public native Rectangle getBounds(Rectangle rv);
78
79 private static final String MSG_XGETSUBIMAGE_FAILED =
80 "XGetSubImage() failed.";
81
82}
Note: See TracBrowser for help on using the repository browser.