OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [xlib/] [natDrawable.cc] - Blame information for rev 861

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* Copyright (C) 2000  Free Software Foundation
2
 
3
   This file is part of libgcj.
4
 
5
This software is copyrighted work licensed under the terms of the
6
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7
details.  */
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
 
21
jboolean 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
 
46
jint gnu::gcj::xlib::Drawable::getDepth ()
47
{
48
  ::Display* dpy = (::Display*) (getDisplay ()->display);
49
  ::Window root;
50
  int x, y;
51
  unsigned int w, h, bw, depth;
52
 
53
  Status status = XGetGeometry (dpy, getXID(), &root,
54
                                &x, &y, &w, &h,
55
                                &bw, &depth);
56
  switch (status)
57
  {
58
    case BadDrawable:
59
      throw new XException (display, status);
60
    default:
61
      ; // All OK, NOP.
62
  }
63
  return (jint)depth;
64
}
65
 
66
java::awt::Rectangle*
67
gnu::gcj::xlib::Drawable::getBounds(::java::awt::Rectangle* rv)
68
{
69
  ::Display* dpy = (::Display*) (getDisplay()->display);
70
 
71
  ::Window root;
72
  int x, y;
73
  unsigned int w, h, bw, depth;
74
 
75
  Status status = XGetGeometry(dpy, getXID(), &root,
76
                               &x, &y, &w, &h,
77
                               &bw, &depth);
78
 
79
  switch (status)
80
    {
81
    case BadDrawable:
82
      throw new XException(display, status);
83
    default:
84
      ; // All OK, NOP.
85
    }
86
 
87
  if (rv == 0)
88
    {
89
      rv = new ::java::awt::Rectangle(x, y, w, h);
90
    }
91
  else
92
    {
93
      rv->x = x;
94
      rv->y = y;
95
      rv->width = w;
96
      rv->height = h;
97
    }
98
  return rv;
99
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.