libjava/ChangeLog:
[official-gcc.git] / libjava / gnu / gcj / xlib / natDrawable.cc
blob371a92bfe04603e0cacd6e4d8480b1f9cf4c8c41
1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 #include <X11/Xlib.h>
11 #include <gcj/cni.h>
12 #include <gnu/gcj/RawData.h>
14 #include <gnu/gcj/xlib/XException.h>
15 #include <gnu/gcj/xlib/Display.h>
16 #include <gnu/gcj/xlib/Drawable.h>
17 #include <gnu/gcj/xlib/XImage.h>
19 #include <java/awt/Rectangle.h>
21 jboolean gnu::gcj::xlib::Drawable::copyIntoXImageImpl(XImage* image,
22 jint x, jint y,
23 jint width, jint height,
24 jint destX, jint destY)
26 ::Display* dpy = (::Display*) (getDisplay()->display);
27 ::XImage* ximage = (::XImage*) image->structure;
28 int format = image->getFormat();
29 int xid = getXID();
31 ::XImage* result = XGetSubImage(dpy, xid,
32 x, y, width, height,
33 ~0, // plane mask
34 format,
35 ximage,
36 destX, destY);
37 if (result == 0)
38 return false;
40 if (result != ximage)
41 throw new XException(MSG_XGETSUBIMAGE_FAILED);
43 return true;
46 jint gnu::gcj::xlib::Drawable::getDepth ()
48 ::Display* dpy = (::Display*) (getDisplay ()->display);
49 ::Window root;
50 int x, y;
51 unsigned int w, h, bw, depth;
53 Status status = XGetGeometry (dpy, getXID(), &root,
54 &x, &y, &w, &h,
55 &bw, &depth);
56 switch (status)
58 case BadDrawable:
59 throw new XException (display, status);
60 default:
61 ; // All OK, NOP.
63 return (jint)depth;
66 java::awt::Rectangle*
67 gnu::gcj::xlib::Drawable::getBounds(::java::awt::Rectangle* rv)
69 ::Display* dpy = (::Display*) (getDisplay()->display);
71 ::Window root;
72 int x, y;
73 unsigned int w, h, bw, depth;
75 Status status = XGetGeometry(dpy, getXID(), &root,
76 &x, &y, &w, &h,
77 &bw, &depth);
79 switch (status)
81 case BadDrawable:
82 throw new XException(display, status);
83 default:
84 ; // All OK, NOP.
87 if (rv == 0)
89 rv = new ::java::awt::Rectangle(x, y, w, h);
91 else
93 rv->x = x;
94 rv->y = y;
95 rv->width = w;
96 rv->height = h;
98 return rv;