OSDN Git Service

2003-04-19 Scott Gilbertson <scottg@mantatest.com>
[pf3gnuchains/gcc-fork.git] / libjava / gnu / gcj / xlib / natClip.cc
1 /* 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 // Needed to avoid linking in libstdc++
10 #ifndef __STL_USE_EXCEPTIONS
11 #   include <java/lang/OutOfMemoryError.h>
12 #   define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError()
13 #endif 
14
15 #include <vector>
16
17 #include <X11/Xlib.h>
18 #include <gcj/cni.h>
19 #include <gnu/gcj/RawData.h>
20 #include <java/awt/Rectangle.h>
21
22 #include "gnu/gcj/xlib/Clip.h"
23
24 typedef java::awt::Rectangle AWTRect;
25 typedef JArray<AWTRect*> AWTRectArray;
26 typedef std::vector<XRectangle> XRectVector;
27
28 void gnu::gcj::xlib::Clip::init(AWTRectArray* rectangles)
29 {
30   // Prepare rectangles:
31   
32   int numRect = JvGetArrayLength(rectangles);
33   XRectVector* xrectvector = new XRectVector(numRect);
34   
35   for (int i=0; i<numRect; i++)
36     {
37       AWTRect* awtrect = elements(rectangles)[i];
38       XRectangle& xrect = (*xrectvector)[i];
39       
40       xrect.x      = awtrect->x;
41       xrect.y      = awtrect->y;
42       xrect.width  = awtrect->width;
43       xrect.height = awtrect->height;
44     }
45
46   xrects = reinterpret_cast<gnu::gcj::RawData*>(xrectvector);
47 }
48
49 void gnu::gcj::xlib::Clip::dispose()
50 {
51   if (xrects)
52   {
53     delete xrects; 
54     xrects = 0;
55   }
56 }