source: trunk/gcc/libjava/gnu/gcj/xlib/natDrawable.cc

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: 1.7 KB
Line 
1/* Copyright (C) 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
9#include <X11/Xlib.h>
10
11#include <gcj/cni.h>
12#include <gnu/gcj/RawData.h>
13
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>
18
19#include <java/awt/Rectangle.h>
20
21jboolean gnu::gcj::xlib::Drawable::copyIntoXImageImpl(XImage* image,
22 jint x, jint y,
23 jint width, jint height,
24 jint destX, jint destY)
25{
26 ::Display* dpy = (::Display*) (getDisplay()->display);
27 ::XImage* ximage = (::XImage*) image->structure;
28 int format = image->getFormat();
29 int xid = getXID();
30
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;
39
40 if (result != ximage)
41 throw new XException(MSG_XGETSUBIMAGE_FAILED);
42
43 return true;
44}
45
46java::awt::Rectangle*
47gnu::gcj::xlib::Drawable::getBounds(java::awt::Rectangle* rv)
48{
49 ::Display* dpy = (::Display*) (getDisplay()->display);
50
51 ::Window root;
52 int x, y;
53 unsigned int w, h, bw, depth;
54
55 Status status = XGetGeometry(dpy, getXID(), &root,
56 &x, &y, &w, &h,
57 &bw, &depth);
58
59 switch (status)
60 {
61 case BadDrawable:
62 throw new XException(display, status);
63 default:
64 ; // All OK, NOP.
65 }
66
67 if (rv == 0)
68 {
69 rv = new java::awt::Rectangle(x, y, w, h);
70 }
71 else
72 {
73 rv->x = x;
74 rv->y = y;
75 rv->width = w;
76 rv->height = h;
77 }
78 return rv;
79}
Note: See TracBrowser for help on using the repository browser.